feat: 修改交易统计逻辑以包括不同支付方式的商品交易金额
This commit is contained in:
parent
7524805421
commit
7dc73909ba
@ -224,52 +224,62 @@ class TradeStatisticLogic extends BaseLogic
|
||||
|
||||
$Chain['goods'] = $OrderCurve;
|
||||
|
||||
/** 购买会员金额 */
|
||||
// $memberMoney = $this->getMemberTotalMoney($where, 'sum');
|
||||
// $lastMemberMoney = $this->getMemberTotalMoney($dateWhere, 'sum', "", $isNum);
|
||||
// $memberCurve = $this->getMemberTotalMoney($where, 'group', "create_time");
|
||||
// $MemberChain = countRate($memberMoney, $lastMemberMoney);
|
||||
// $topData[3] = [
|
||||
// 'title' => '购买会员金额',
|
||||
// 'desc' => '选定条件下,用户成功购买付费会员的金额',
|
||||
// 'total_money' => $memberMoney,
|
||||
// 'rate' => $MemberChain,
|
||||
// 'value' => $memberCurve['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'],
|
||||
//微信支付商品
|
||||
$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[3] = [
|
||||
'title' => '微信支付金额',
|
||||
'desc' => '用户下单时使用微信实际支付的金额',
|
||||
'total_money' => $wechatOrderMoney,
|
||||
'rate' => $wechatOrderChain,
|
||||
'value' => $wechatOrderCurve['y'],
|
||||
'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');
|
||||
$lastOfflineMoney = $this->getOfflineTotalMoney($dateWhere, 'sum', "", $isNum);
|
||||
$offlineCurve = $this->getOfflineTotalMoney($where, 'group', "create_time");
|
||||
$offlineChain = countRate($offlineMoney, $lastOfflineMoney);
|
||||
$topData[5] = [
|
||||
'title' => '线下收银金额',
|
||||
'desc' => '选定条件下,用户在线下扫码支付的金额',
|
||||
$topData[6] = [
|
||||
'title' => '现金金额',
|
||||
'desc' => '选定条件下,用户在线下现金支付的金额',
|
||||
'total_money' => $offlineMoney,
|
||||
'rate' => $offlineChain,
|
||||
'value' => $offlineCurve['y'],
|
||||
@ -300,6 +310,28 @@ class TradeStatisticLogic extends BaseLogic
|
||||
];
|
||||
$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');
|
||||
$lastOutOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $dateWhere['create_time']], 'sum', "", $isNum);
|
||||
@ -324,7 +356,7 @@ class TradeStatisticLogic extends BaseLogic
|
||||
$lastOutTotalMoney = bcadd($lastOutYeMoney, 0, 2);
|
||||
$outTotalCurve = $this->totalArrData([$outYeCurve, 0]);
|
||||
$outTotalChain = countRate($outTotalMoney, $lastOutTotalMoney);
|
||||
$topData[6] = [
|
||||
$topData[11] = [
|
||||
'title' => '支出金额',
|
||||
'desc' => '余额支付金额、支付佣金金额',
|
||||
'total_money' => $outTotalMoney,
|
||||
@ -335,26 +367,6 @@ class TradeStatisticLogic extends BaseLogic
|
||||
];
|
||||
$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');
|
||||
$userSignTwo = $this->getUserSign($where, 'sum', "", $isNum);
|
||||
@ -390,53 +402,6 @@ class TradeStatisticLogic extends BaseLogic
|
||||
];
|
||||
$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 */
|
||||
$inTotalMoney = $this->tradeTotalMoney($where, "sum");
|
||||
@ -779,12 +744,12 @@ class TradeStatisticLogic extends BaseLogic
|
||||
// }
|
||||
switch ($selectType) {
|
||||
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']));
|
||||
})->sum($offlineSumField);
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
throw new \Exception('getOfflineTotalMoney:selectType参数错误');
|
||||
|
Loading…
x
Reference in New Issue
Block a user