From 7dc73909ba7479a44a3e2a8ea6ab3828c9d855b9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 21 Jun 2024 11:46:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=80=BB=E8=BE=91=E4=BB=A5=E5=8C=85=E6=8B=AC?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BA=A4=E6=98=93=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/statistic/TradeStatisticLogic.php | 181 +++++++----------- 1 file changed, 73 insertions(+), 108 deletions(-) diff --git a/app/admin/logic/statistic/TradeStatisticLogic.php b/app/admin/logic/statistic/TradeStatisticLogic.php index cdc1be899..90408c87e 100644 --- a/app/admin/logic/statistic/TradeStatisticLogic.php +++ b/app/admin/logic/statistic/TradeStatisticLogic.php @@ -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参数错误');