feat: 修改交易统计逻辑以包括不同支付方式的商品交易金额
This commit is contained in:
parent
7524805421
commit
7dc73909ba
@ -224,52 +224,62 @@ class TradeStatisticLogic extends BaseLogic
|
|||||||
|
|
||||||
$Chain['goods'] = $OrderCurve;
|
$Chain['goods'] = $OrderCurve;
|
||||||
|
|
||||||
/** 购买会员金额 */
|
//微信支付商品
|
||||||
// $memberMoney = $this->getMemberTotalMoney($where, 'sum');
|
$wechatOrderMoney = $this->getOrderTotalMoney(['pay_type' => [7, 9], 'create_time' => $where['create_time']], 'sum');
|
||||||
// $lastMemberMoney = $this->getMemberTotalMoney($dateWhere, 'sum', "", $isNum);
|
$lastWechatOrderMoney = $this->getOrderTotalMoney(['pay_type' => [7, 9], 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
|
||||||
// $memberCurve = $this->getMemberTotalMoney($where, 'group', "create_time");
|
$wechatOrderCurve = $this->getOrderTotalMoney(['pay_type' => [7, 9], 'create_time' => $where['create_time']], 'group', 'create_time');
|
||||||
// $MemberChain = countRate($memberMoney, $lastMemberMoney);
|
$wechatOrderChain = countRate($wechatOrderMoney, $lastWechatOrderMoney);
|
||||||
// $topData[3] = [
|
$topData[3] = [
|
||||||
// 'title' => '购买会员金额',
|
'title' => '微信支付金额',
|
||||||
// 'desc' => '选定条件下,用户成功购买付费会员的金额',
|
'desc' => '用户下单时使用微信实际支付的金额',
|
||||||
// 'total_money' => $memberMoney,
|
'total_money' => $wechatOrderMoney,
|
||||||
// 'rate' => $MemberChain,
|
'rate' => $wechatOrderChain,
|
||||||
// 'value' => $memberCurve['y'],
|
'value' => $wechatOrderCurve['y'],
|
||||||
// 'type' => 1,
|
|
||||||
// 'sign' => 'member',
|
|
||||||
// ];
|
|
||||||
// $Chain['member'] = $memberCurve;
|
|
||||||
|
|
||||||
/** 充值金额 */
|
|
||||||
$rechgeMoneyHome = $this->getRechargeTotalMoney($where, 'sum');
|
|
||||||
$rechgeMoneyAdmin = $this->getBillYeTotalMoney($where, 'sum');
|
|
||||||
$rechgeMoneyTotal = bcadd($rechgeMoneyHome, $rechgeMoneyAdmin, 2);
|
|
||||||
$lastRechgeMoneyHome = $this->getRechargeTotalMoney($dateWhere, 'sum', "", $isNum);
|
|
||||||
$lastRechgeMoneyAdmin = $this->getBillYeTotalMoney($dateWhere, 'sum', "", $isNum);
|
|
||||||
$lastRechgeMoneyTotal = bcadd($lastRechgeMoneyHome, $lastRechgeMoneyAdmin, 2);
|
|
||||||
$RechgeHomeCurve = $this->getRechargeTotalMoney($where, 'group', "create_time");
|
|
||||||
$RechgeAdminCurve = $this->getBillYeTotalMoney($where, 'group', "create_time");
|
|
||||||
$RechgeTotalCurve = $this->totalArrData([$RechgeHomeCurve, $RechgeAdminCurve]);
|
|
||||||
$RechgeChain = countRate($rechgeMoneyTotal, $lastRechgeMoneyTotal);
|
|
||||||
$topData[4] = [
|
|
||||||
'title' => '充值金额',
|
|
||||||
'desc' => '选定条件下,用户成功充值的金额',
|
|
||||||
'total_money' => $rechgeMoneyTotal,
|
|
||||||
'rate' => $RechgeChain,
|
|
||||||
'value' => $RechgeTotalCurve['y'],
|
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
'sign' => 'rechge',
|
'sign' => 'wechat',
|
||||||
];
|
];
|
||||||
$Chain['rechage'] = $RechgeTotalCurve;
|
$Chain['wechat'] = $wechatOrderCurve;
|
||||||
|
|
||||||
|
//支付宝支付商品
|
||||||
|
$aliPayOrderMoney = $this->getOrderTotalMoney(['pay_type' => 13, 'create_time' => $where['create_time']], 'sum');
|
||||||
|
$lastAlipayOrderMoney = $this->getOrderTotalMoney(['pay_type' => 13, 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
|
||||||
|
$aliPayOrderCurve = $this->getOrderTotalMoney(['pay_type' => 13, 'create_time' => $where['create_time']], 'group', 'create_time');
|
||||||
|
$aliPayOrderChain = countRate($aliPayOrderMoney, $lastAlipayOrderMoney);
|
||||||
|
$topData[4] = [
|
||||||
|
'title' => '支付宝支付金额',
|
||||||
|
'desc' => '用户下单时使用支付宝实际支付的金额',
|
||||||
|
'total_money' => $aliPayOrderMoney,
|
||||||
|
'rate' => $aliPayOrderChain,
|
||||||
|
'value' => $aliPayOrderCurve['y'],
|
||||||
|
'type' => 1,
|
||||||
|
'sign' => 'ali_pay',
|
||||||
|
];
|
||||||
|
$Chain['ali_pay'] = $aliPayOrderCurve;
|
||||||
|
|
||||||
|
//采购款支付商品
|
||||||
|
$fundsOrderMoney = $this->getOrderTotalMoney(['pay_type' => 18, 'create_time' => $where['create_time']], 'sum');
|
||||||
|
$lastFundsOrderMoney = $this->getOrderTotalMoney(['pay_type' => 18, 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
|
||||||
|
$fundsOrderCurve = $this->getOrderTotalMoney(['pay_type' => 18, 'create_time' => $where['create_time']], 'group', 'create_time');
|
||||||
|
$fundsOrderChain = countRate($fundsOrderMoney, $lastFundsOrderMoney);
|
||||||
|
$topData[5] = [
|
||||||
|
'title' => '采购支付金额',
|
||||||
|
'desc' => '用户下单时使用采购实际支付的金额',
|
||||||
|
'total_money' => $fundsOrderMoney,
|
||||||
|
'rate' => $fundsOrderChain,
|
||||||
|
'value' => $fundsOrderCurve['y'],
|
||||||
|
'type' => 1,
|
||||||
|
'sign' => 'funds',
|
||||||
|
];
|
||||||
|
$Chain['funds'] = $fundsOrderCurve;
|
||||||
|
|
||||||
/** 线下收银 */
|
/** 线下收银 */
|
||||||
$offlineMoney = $this->getOfflineTotalMoney($where, 'sum');
|
$offlineMoney = $this->getOfflineTotalMoney($where, 'sum');
|
||||||
$lastOfflineMoney = $this->getOfflineTotalMoney($dateWhere, 'sum', "", $isNum);
|
$lastOfflineMoney = $this->getOfflineTotalMoney($dateWhere, 'sum', "", $isNum);
|
||||||
$offlineCurve = $this->getOfflineTotalMoney($where, 'group', "create_time");
|
$offlineCurve = $this->getOfflineTotalMoney($where, 'group', "create_time");
|
||||||
$offlineChain = countRate($offlineMoney, $lastOfflineMoney);
|
$offlineChain = countRate($offlineMoney, $lastOfflineMoney);
|
||||||
$topData[5] = [
|
$topData[6] = [
|
||||||
'title' => '线下收银金额',
|
'title' => '现金金额',
|
||||||
'desc' => '选定条件下,用户在线下扫码支付的金额',
|
'desc' => '选定条件下,用户在线下现金支付的金额',
|
||||||
'total_money' => $offlineMoney,
|
'total_money' => $offlineMoney,
|
||||||
'rate' => $offlineChain,
|
'rate' => $offlineChain,
|
||||||
'value' => $offlineCurve['y'],
|
'value' => $offlineCurve['y'],
|
||||||
@ -300,6 +310,28 @@ class TradeStatisticLogic extends BaseLogic
|
|||||||
];
|
];
|
||||||
$Chain['out_ye'] = $outYeCurve;
|
$Chain['out_ye'] = $outYeCurve;
|
||||||
|
|
||||||
|
/** 充值金额 */
|
||||||
|
$rechgeMoneyHome = $this->getRechargeTotalMoney($where, 'sum');
|
||||||
|
$rechgeMoneyAdmin = $this->getBillYeTotalMoney($where, 'sum');
|
||||||
|
$rechgeMoneyTotal = bcadd($rechgeMoneyHome, $rechgeMoneyAdmin, 2);
|
||||||
|
$lastRechgeMoneyHome = $this->getRechargeTotalMoney($dateWhere, 'sum', "", $isNum);
|
||||||
|
$lastRechgeMoneyAdmin = $this->getBillYeTotalMoney($dateWhere, 'sum', "", $isNum);
|
||||||
|
$lastRechgeMoneyTotal = bcadd($lastRechgeMoneyHome, $lastRechgeMoneyAdmin, 2);
|
||||||
|
$RechgeHomeCurve = $this->getRechargeTotalMoney($where, 'group', "create_time");
|
||||||
|
$RechgeAdminCurve = $this->getBillYeTotalMoney($where, 'group', "create_time");
|
||||||
|
$RechgeTotalCurve = $this->totalArrData([$RechgeHomeCurve, $RechgeAdminCurve]);
|
||||||
|
$RechgeChain = countRate($rechgeMoneyTotal, $lastRechgeMoneyTotal);
|
||||||
|
$topData[12] = [
|
||||||
|
'title' => '充值金额',
|
||||||
|
'desc' => '选定条件下,用户成功充值的金额',
|
||||||
|
'total_money' => $rechgeMoneyTotal,
|
||||||
|
'rate' => $RechgeChain,
|
||||||
|
'value' => $RechgeTotalCurve['y'],
|
||||||
|
'type' => 1,
|
||||||
|
'sign' => 'rechge',
|
||||||
|
];
|
||||||
|
$Chain['rechage'] = $RechgeTotalCurve;
|
||||||
|
|
||||||
//商品退款金额
|
//商品退款金额
|
||||||
$outOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $where['create_time']], 'sum');
|
$outOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $where['create_time']], 'sum');
|
||||||
$lastOutOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
|
$lastOutOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
|
||||||
@ -324,7 +356,7 @@ class TradeStatisticLogic extends BaseLogic
|
|||||||
$lastOutTotalMoney = bcadd($lastOutYeMoney, 0, 2);
|
$lastOutTotalMoney = bcadd($lastOutYeMoney, 0, 2);
|
||||||
$outTotalCurve = $this->totalArrData([$outYeCurve, 0]);
|
$outTotalCurve = $this->totalArrData([$outYeCurve, 0]);
|
||||||
$outTotalChain = countRate($outTotalMoney, $lastOutTotalMoney);
|
$outTotalChain = countRate($outTotalMoney, $lastOutTotalMoney);
|
||||||
$topData[6] = [
|
$topData[11] = [
|
||||||
'title' => '支出金额',
|
'title' => '支出金额',
|
||||||
'desc' => '余额支付金额、支付佣金金额',
|
'desc' => '余额支付金额、支付佣金金额',
|
||||||
'total_money' => $outTotalMoney,
|
'total_money' => $outTotalMoney,
|
||||||
@ -335,26 +367,6 @@ class TradeStatisticLogic extends BaseLogic
|
|||||||
];
|
];
|
||||||
$Chain['out'] = $outTotalCurve;
|
$Chain['out'] = $outTotalCurve;
|
||||||
|
|
||||||
/** 交易毛利金额*/
|
|
||||||
// $jiaoyiMoney = $this->tradeTotalMoney($where, "sum");
|
|
||||||
|
|
||||||
// $jiaoyiMoney = bcsub($jiaoyiMoney, $outTotalMoney, 2);
|
|
||||||
// $lastJiaoyiMoney = $this->tradeTotalMoney($dateWhere, "sum", $isNum);
|
|
||||||
// $lastJiaoyiMoney = bcsub($lastJiaoyiMoney, $lastOutTotalMoney, 2);
|
|
||||||
// $jiaoyiCurve = $this->tradeGroupMoney($where, "group");
|
|
||||||
// $jiaoyiCurve = $this->subdutionArrData($jiaoyiCurve, $outTotalCurve);
|
|
||||||
// $jiaoyiChain = countRate($jiaoyiMoney, $lastJiaoyiMoney);
|
|
||||||
// $topData[1] = [
|
|
||||||
// 'title' => '交易毛利金额',
|
|
||||||
// 'desc' => '交易毛利金额 = 营业额 - 支出金额',
|
|
||||||
// 'total_money' => $jiaoyiMoney,
|
|
||||||
// 'rate' => $jiaoyiChain,
|
|
||||||
// 'value' => $jiaoyiCurve['y'],
|
|
||||||
// 'type' => 1,
|
|
||||||
// 'sign' => 'jiaoyi',
|
|
||||||
// ];
|
|
||||||
// $Chain['jiaoyi'] = $jiaoyiCurve;
|
|
||||||
|
|
||||||
//兑换礼品券
|
//兑换礼品券
|
||||||
$userSign = $this->getUserSign($where, 'sum');
|
$userSign = $this->getUserSign($where, 'sum');
|
||||||
$userSignTwo = $this->getUserSign($where, 'sum', "", $isNum);
|
$userSignTwo = $this->getUserSign($where, 'sum', "", $isNum);
|
||||||
@ -390,53 +402,6 @@ class TradeStatisticLogic extends BaseLogic
|
|||||||
];
|
];
|
||||||
$Chain['deposit'] = $OrderDepositCurve;
|
$Chain['deposit'] = $OrderDepositCurve;
|
||||||
|
|
||||||
//微信支付商品
|
|
||||||
$wechatOrderMoney = $this->getOrderTotalMoney(['pay_type' => [7, 9], 'create_time' => $where['create_time']], 'sum');
|
|
||||||
$lastWechatOrderMoney = $this->getOrderTotalMoney(['pay_type' => [7, 9], 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
|
|
||||||
$wechatOrderCurve = $this->getOrderTotalMoney(['pay_type' => [7, 9], 'create_time' => $where['create_time']], 'group', 'create_time');
|
|
||||||
$wechatOrderChain = countRate($wechatOrderMoney, $lastWechatOrderMoney);
|
|
||||||
$topData[11] = [
|
|
||||||
'title' => '微信支付金额',
|
|
||||||
'desc' => '用户下单时使用微信实际支付的金额',
|
|
||||||
'total_money' => $wechatOrderMoney,
|
|
||||||
'rate' => $wechatOrderChain,
|
|
||||||
'value' => $wechatOrderCurve['y'],
|
|
||||||
'type' => 1,
|
|
||||||
'sign' => 'wechat',
|
|
||||||
];
|
|
||||||
$Chain['wechat'] = $wechatOrderCurve;
|
|
||||||
|
|
||||||
//支付宝支付商品
|
|
||||||
$aliPayOrderMoney = $this->getOrderTotalMoney(['pay_type' =>13, 'create_time' => $where['create_time']], 'sum');
|
|
||||||
$lastAlipayOrderMoney = $this->getOrderTotalMoney(['pay_type' => 13, 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
|
|
||||||
$aliPayOrderCurve = $this->getOrderTotalMoney(['pay_type' =>13, 'create_time' => $where['create_time']], 'group', 'create_time');
|
|
||||||
$aliPayOrderChain = countRate($aliPayOrderMoney, $lastAlipayOrderMoney);
|
|
||||||
$topData[12] = [
|
|
||||||
'title' => '支付宝支付金额',
|
|
||||||
'desc' => '用户下单时使用支付宝实际支付的金额',
|
|
||||||
'total_money' => $aliPayOrderMoney,
|
|
||||||
'rate' => $aliPayOrderChain,
|
|
||||||
'value' => $aliPayOrderCurve['y'],
|
|
||||||
'type' => 1,
|
|
||||||
'sign' => 'ali_pay',
|
|
||||||
];
|
|
||||||
$Chain['ali_pay'] = $aliPayOrderCurve;
|
|
||||||
|
|
||||||
//采购款支付商品
|
|
||||||
$fundsOrderMoney = $this->getOrderTotalMoney(['pay_type' =>18, 'create_time' => $where['create_time']], 'sum');
|
|
||||||
$lastFundsOrderMoney = $this->getOrderTotalMoney(['pay_type' => 18, 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
|
|
||||||
$fundsOrderCurve = $this->getOrderTotalMoney(['pay_type' =>18, 'create_time' => $where['create_time']], 'group', 'create_time');
|
|
||||||
$fundsOrderChain = countRate($fundsOrderMoney, $lastFundsOrderMoney);
|
|
||||||
$topData[13] = [
|
|
||||||
'title' => '采购支付金额',
|
|
||||||
'desc' => '用户下单时使用采购实际支付的金额',
|
|
||||||
'total_money' => $fundsOrderMoney,
|
|
||||||
'rate' => $fundsOrderChain,
|
|
||||||
'value' => $fundsOrderCurve['y'],
|
|
||||||
'type' => 1,
|
|
||||||
'sign' => 'funds',
|
|
||||||
];
|
|
||||||
$Chain['funds'] = $fundsOrderCurve;
|
|
||||||
|
|
||||||
/** @var 营业额 $inTotalMoney */
|
/** @var 营业额 $inTotalMoney */
|
||||||
$inTotalMoney = $this->tradeTotalMoney($where, "sum");
|
$inTotalMoney = $this->tradeTotalMoney($where, "sum");
|
||||||
@ -779,12 +744,12 @@ class TradeStatisticLogic extends BaseLogic
|
|||||||
// }
|
// }
|
||||||
switch ($selectType) {
|
switch ($selectType) {
|
||||||
case "sum":
|
case "sum":
|
||||||
$totalMoney = $storeOrder->where('pay_type', 'in', [9, 13, 17])->when(isset($where['timeKey']), function ($query) use ($where) {
|
$totalMoney = $storeOrder->where('pay_type', 17)->when(isset($where['timeKey']), function ($query) use ($where) {
|
||||||
$query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time']));
|
$query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time']));
|
||||||
})->sum($offlineSumField);
|
})->sum($offlineSumField);
|
||||||
break;
|
break;
|
||||||
case "group":
|
case "group":
|
||||||
$totalMoney = $storeOrder->getCurveData(['pay_type' => ['in' => [9, 13, 17]]], $where, 'count(pay_price)', $group);
|
$totalMoney = $storeOrder->getCurveData(['pay_type' => 17], $where, 'count(pay_price)', $group);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new \Exception('getOfflineTotalMoney:selectType参数错误');
|
throw new \Exception('getOfflineTotalMoney:selectType参数错误');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user