利润报表
利润报表
字段可选
M:must 必填
O:optional 选填
C: conditional 某些条件下必选
/data_center/profit/daily/ 每日利润报表
描述
拉取一定时间区间内的利润报表
Method
GET
请求
begin M datetime 开始日期
end M datetime 开始日期
export O bool 是否导出,默认为0不导出
//session
station_id M string 站点ID
响应
code M int 返回码,0表示成功,其他表示错误
msg M string 错误信息
data M string 返回json数据
[{
"gross_profit_rate" M string 毛利率
"real_refund_money" M float 实际退货金额
"ASP" M float ASP(订单均价)
"freight" M float 运费
"orderedtime" M datetime 下单日期
"customer_ordered" M int 下单客户数
"money_delivered" M float 送货金额
"money_per_customer" M float 客单价
"money_cost" M float 成本
"gross_profit" M float 毛利
"abnormal_money" M float 异常金额
"sale_money_with_freight" M float 销售额(包括运费)
"money_ordered" M float 下单金额
"sale_money" M float 销售额
"amount_ordered" M int 下单数
}]
示例
request
http://station.guanmai.cn/data_center/profit/daily/?begin=2016-10-28&end=2016-10-28&export=0
response
{
"msg": "ok",
"code": 0,
"data": [{
"gross_profit_rate": "100.00%",
"real_refund_money": 0.0,
"ASP": 96.7,
"freight": 0.0,
"orderedtime": "2016-10-28",
"customer_ordered": 4,
"money_delivered": 676.92,
"money_per_customer": 169.23,
"money_cost": 0.0,
"gross_profit": 676.92,
"abnormal_money": 0.0,
"sale_money_with_freight": 676.92,
"money_ordered": 676.92,
"sale_money": 676.92,
"amount_ordered": 7
}]
}
逻辑
统计的日期包括近两天的
近两天的那部分临时统计
删除原有的统计数据
生成新的统计数据
统计信息以站点ID,下单日期,销售单ID为单位来统计
每条统计下统计商品,商户,异常,退货几个维度的数据
特殊逻辑是
1.运费是重复记录在所有的统计数据中的
2.非商品异常不对应任何一个销售单ID,所以非商品异常会随机的写到某个销售单的统计内,
并且在总的统计下再写一遍,上游展示销售单统计时减去非商品异常的内容就可以得到正确的统计值
拉取需要的时间区间的所有统计
将相同日期的数据相加后生成最后的统计返回