HomeService.js 2.25 KB
'use strict';

import Request from './Request';
import moment from 'moment';

export default class UserService {

	constructor () {
		this.api = new Request();
	}

	async overview(brandId) {
		let dateId = moment().format('YYYYMMDD'); //20160524
		return await this.api.get({
			url: '',
			body: {
				method: 'app.shops.shopbusinessoverview',
				brandId,
				dateId
			}
		})
		.then((json) => {
			return json;
		})
		.catch((error) => {
			throw(error);
		});
	}

	async brandRank(brandId) {
		let dateId = moment().format('YYYYMMDD'); //20160524
		return await this.api.get({
			url: '',
			body: {
				method: 'app.shops.shopbrandrank',
				brandId,
				dateId
			}
		})
		.then((json) => {
			return json;
		})
		.catch((error) => {
			throw(error);
		});
	}

	async accountSettlementData(params) {
		return await this.api.get({
			url:'',
			body: {
				method: 'app.shops.accountbalance',
				...param
			}
		})
		.then((json) => {
			return json;
		})
		.catch((error) => {
			throw(error);
		})
	}

	async saleStats(params) {

		return await this.api.get({
			url:'',
			body: {
				method: 'app.shops.sales',
				...params,
			}
		})
		.then((json) => {
			return json;
		})
		.catch((error) => {
			throw(error);
		})
	}

	async refoundStats(params) {
		return await this.api.get({
			url:'',
			body: {
				method: 'app.shops.refund',
				...params,
			}
		})
		.then((json) => {
			return json;
		})
		.catch((error) => {
			throw(error);
		})
	}

	async stockStatsData(params) {
		return await this.api.get({
			url: '',
			body: {
				method: 'app.shops.storagestatistics',
				...params,
			}
		})
		.then((json) => {
			return json;
		})
		.catch((error) => {
			throw(error);
		})
	}

	async deliveryStatsData(params) {
		return await this.api.get({
			url: '',
			body: {
				method: 'app.shops.storagein',
				page: params.page,
				size: params.size,
				beginTime: moment(params.beginTime).format('YYYYMMDD'),
				endTime: moment(params.endTime).format('YYYYMMDD'),
				brandId: params.brandId,
			}
		})
		.then((json) => {
			return json;
		})
		.catch((error) => {
			throw(error);
		})
	}

	async requestStatsData() {
		return await this.api.get({
			url: '/',
			body: {

			}
		})
		.then((json) => {
			return json;
		})
		.catch((error) => {
			throw(error);
		})
	}
}