|
|
@ -48,38 +48,39 @@ class couponReport extends Command |
|
|
|
|
|
|
|
|
// 统计优惠券订单数据-金额
|
|
|
// 统计优惠券订单数据-金额
|
|
|
$orderTotal = DB::select("SELECT
|
|
|
$orderTotal = DB::select("SELECT
|
|
|
coupon.title 优惠券标题 |
|
|
|
|
|
,SUM(money) '使用优惠券消费总额(实付总金额)' |
|
|
|
|
|
,SUM(total_money) '订单总额(不包含配送费,含包装费)' |
|
|
|
|
|
,SUM(dada_fee) 配送费 |
|
|
|
|
|
,SUM(yhq_money2) 优惠总金额 |
|
|
|
|
|
,COUNT(om.id) '总订单数量' |
|
|
|
|
|
|
|
|
uses.system_coupon_id as ID |
|
|
|
|
|
,coupon.title '优惠券标题' |
|
|
|
|
|
,SUM(om.money) as '使用优惠券消费总额(实付总金额)' |
|
|
|
|
|
,SUM(om.total_money) as '订单总额(不包含配送费,含包装费)' |
|
|
|
|
|
,SUM(om.dada_fee) as '配送费' |
|
|
|
|
|
,SUM(om.yhq_money2)as '优惠总金额' |
|
|
|
|
|
,COUNT(om.id) as '总订单数量' |
|
|
FROM |
|
|
FROM |
|
|
ims_system_coupon_user_use couu |
|
|
|
|
|
INNER JOIN ims_cjdc_order_main om ON couu.order_main_id = om.id |
|
|
|
|
|
INNER JOIN ims_system_coupon_user coupon ON coupon.id=couu.system_coupon_id |
|
|
|
|
|
WHERE couu.`status` = 1 |
|
|
|
|
|
AND om.time_add BETWEEN ? AND ? |
|
|
|
|
|
GROUP BY couu.system_coupon_id",
|
|
|
|
|
|
|
|
|
ims_system_coupon_user_use uses |
|
|
|
|
|
INNER JOIN ims_cjdc_order_main om ON uses.order_main_id = om.id |
|
|
|
|
|
INNER JOIN ims_system_coupon_user coupon ON coupon.id=uses.system_coupon_id |
|
|
|
|
|
WHERE uses.`status` = 1 AND om.time_add BETWEEN ? AND ? |
|
|
|
|
|
GROUP BY uses.system_coupon_id ORDER BY uses.system_coupon_id DESC",
|
|
|
$where |
|
|
$where |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
// 查询领取数量和统计数量-总数
|
|
|
// 查询领取数量和统计数量-总数
|
|
|
$receiveCoupon = DB::select("SELECT
|
|
|
$receiveCoupon = DB::select("SELECT
|
|
|
coupon.id ID |
|
|
|
|
|
,title 优惠券标题 |
|
|
|
|
|
,full_amount as 满足金额 |
|
|
|
|
|
,discounts as 优惠金额 |
|
|
|
|
|
,inventory AS 发放数量 |
|
|
|
|
|
,inventory_use as 已领取数量 |
|
|
|
|
|
,IFNULL((SELECT SUM(IFNULL(number,0)) FROM ims_system_coupon_user_use WHERE system_coupon_id = coupon.id AND use_time BETWEEN ? AND ?),0) AS 使用数量 |
|
|
|
|
|
|
|
|
coupon.id as ID |
|
|
|
|
|
,title as '优惠券标题' |
|
|
|
|
|
,full_amount as '满足金额' |
|
|
|
|
|
,discounts as '优惠金额' |
|
|
|
|
|
,inventory AS '发放数量' |
|
|
|
|
|
,SUM(IFNULL(receive.number,0)) as '领取数量' |
|
|
|
|
|
,IFNULL((SELECT SUM(IFNULL(number,0)) FROM ims_system_coupon_user_use WHERE system_coupon_id = coupon.id AND status = 1 AND use_time BETWEEN ? AND ?),0) AS 使用数量 |
|
|
FROM |
|
|
FROM |
|
|
ims_system_coupon_user coupon |
|
|
ims_system_coupon_user coupon |
|
|
LEFT JOIN ims_system_coupon_user_receive receive ON coupon.id = receive.system_coupon_user_id |
|
|
LEFT JOIN ims_system_coupon_user_receive receive ON coupon.id = receive.system_coupon_user_id |
|
|
WHERE receive.created_at BETWEEN ? AND ? |
|
|
WHERE receive.created_at BETWEEN ? AND ? |
|
|
GROUP BY coupon.id",
|
|
|
|
|
|
|
|
|
GROUP BY coupon.id ORDER BY coupon.id DESC",
|
|
|
array_merge($where,$where) |
|
|
array_merge($where,$where) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
// 查询优惠券订单用户数据
|
|
|
// 查询优惠券订单用户数据
|
|
|
// $orderList = DB::select("SELECT
|
|
|
// $orderList = DB::select("SELECT
|
|
|
// uu.id AS 序号
|
|
|
// uu.id AS 序号
|
|
|
@ -116,7 +117,7 @@ class couponReport extends Command |
|
|
if($return){ |
|
|
if($return){ |
|
|
// return json_encode(compact($orderTotal,$receiveCoupon,$orderList));
|
|
|
// return json_encode(compact($orderTotal,$receiveCoupon,$orderList));
|
|
|
}else{ |
|
|
}else{ |
|
|
$this->table(['优惠券标题','使用优惠券消费总额(实付总金额)','订单总额(不包含配送费,含包装费)','配送费','优惠总金额','总订单数量'],$orderArray); |
|
|
|
|
|
|
|
|
$this->table(['ID','优惠券标题','使用优惠券消费总额(实付总金额)','订单总额(不包含配送费,含包装费)','配送费','优惠总金额','总订单数量'],$orderArray); |
|
|
$this->table(['ID','优惠券标题','满足金额','优惠金额','发放数量','已领取数量','使用数量'],$receiveArray); |
|
|
$this->table(['ID','优惠券标题','满足金额','优惠金额','发放数量','已领取数量','使用数量'],$receiveArray); |
|
|
// $this->table(['序号','使用状态','用户ID','订单号','订单金额','优惠券种类','用户昵称','用户姓名','用户电话','用户地址'],$listArray);
|
|
|
// $this->table(['序号','使用状态','用户ID','订单号','订单金额','优惠券种类','用户昵称','用户姓名','用户电话','用户地址'],$listArray);
|
|
|
} |
|
|
} |
|
|
|