From 17239d39e84b80babded41e3193e62e875bb65a3 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 18 Jun 2024 15:27:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BBvip=E4=B8=BA1=E5=BE=97?= =?UTF-8?q?=E6=97=B6=E5=80=99=E5=BE=97=E5=86=BB=E7=BB=93=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E5=92=8C=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=BE=97=E5=B8=A6=E8=BF=94=E5=9B=9E=E5=86=BB=E7=BB=93=E9=87=91?= =?UTF-8?q?=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/user/UserLogic.php | 6 ++-- app/common/logic/PayNotifyLogic.php | 43 ++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index bdbd7351..e6b49391 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -15,6 +15,8 @@ use app\common\{logic\BaseLogic, model\user\UserRecharge, model\user\UserShip, service\wechat\WeChatMnpService}; +use think\facade\Db; + /** * 会员逻辑层 @@ -90,8 +92,8 @@ class UserLogic extends BaseLogic $data['store_id'] = $check['store_id']; } } - $data['return_money'] = StoreFinanceFlow:: - where(['user_id'=>$uid,'status'=>0,'financial_pm'=>0]) + $data['return_money'] = Db::name('vip_flow')-> + where(['user_id'=>$uid,'status'=>0]) ->sum('number'); }else{ diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index a9c5d72c..f7923921 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -10,6 +10,7 @@ use app\common\model\finance\PayNotifyLog; use app\common\model\pay\PayNotify; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_order\StoreOrder; +use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\system_store\SystemStore; use app\common\model\user\User; use app\common\model\user\UserAddress; @@ -114,7 +115,7 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price'],'',1,$order['store_id']); if ($user['user_ship'] == 1) { - VipLogic::dealVipAmount($order, PayEnum::PURCHASE_FUNDS); + self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS); } // self::afterPay($order); @@ -311,6 +312,11 @@ class PayNotifyLogic extends BaseLogic //商户应该获得的钱 每个商品的price-ot_price 利润 // if (isset($order->profit) && $order->profit > 0) { if ($order['uid'] > 0) { + //用户下单该用户等级为1得时候才处理冻结金额 + $user = User::where('id', $order['uid'])->find(); + if ($user['user_ship'] == 1) { + self::dealVipAmount($order, $order['pay_type']); + } $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], @@ -460,4 +466,39 @@ class PayNotifyLogic extends BaseLogic ]; PayNotify::create($data); } + + + /** + * 处理用户为vip1时得冻结资金 + * @param $order + * @param $pay_type + * @param $transaction_id + * @return true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function dealVipAmount($order,$pay_type =1, $transaction_id = 0) + { + $detail = StoreOrderCartInfo::where('oid',$order['id'])->select()->toArray(); + $total_vip = 0; + foreach ($detail as $value){ + $total_vip +=$value['cart_info']['vip_frozen_price']; + } + $data=[ + 'order_id' => $order['id'], + 'transaction_id' => $transaction_id??0, + 'order_sn' =>$order['order_id'], + 'user_id' => $order['uid'], + 'number' => $total_vip, + 'pay_type' => $pay_type??1, + 'status' => 0, + 'store_id' => $order['store_id'], + 'staff_id' => $order['staff_id'], + 'create_time'=>time() + ]; + Db::name('vip_flow')->insert($data); + return true; + } + }