From 5ac275022791d0f0b5ca818bfc0b3be564dd1b19 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 23 Jun 2024 13:05:52 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat(PayNotifyLogic):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E9=98=9F=E9=95=BF=E5=92=8C=E6=9D=91?= =?UTF-8?q?=E9=95=BF=E8=AE=A2=E5=8D=95=E8=8E=B7=E5=BE=97=E5=85=91=E6=8D=A2?= =?UTF-8?q?=E5=88=B8=E7=9A=84=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BA=86=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 96 ++++++++++++++--------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 1349cfbe6..6be163d6c 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -518,56 +518,56 @@ class PayNotifyLogic extends BaseLogic } if ($fees > 0) { //村长获得 - $sing = []; + // $sing = []; - $sing[] = [ - 'uid' => $village_uid, - 'order_id' => $order['order_id'], - 'title' => '村长订单获得兑换券', - 'store_id' => $order['store_id'], - 'number' => $fees, - 'financial_pm' => 1, - 'user_ship' => 2, - ]; - $sing[] = [ - 'uid' => $brigade_uid, - 'order_id' => $order['order_id'], - 'title' => '队长订单获得兑换券', - 'store_id' => $order['store_id'], - 'number' => $fees, - 'financial_pm' => 1, - 'user_ship' => 3, - ]; - $sing[] = [ - 'uid' => $village_uid, - 'order_id' => $order['order_id'], - 'title' => '订单扣除兑换券', - 'store_id' => $order['store_id'], - 'number' => $fees, - 'financial_pm' => 0, - 'user_ship' => 2, - ]; - $sing[] = [ - 'uid' => $brigade_uid, - 'order_id' => $order['order_id'], - 'title' => '订单扣除兑换券', - 'store_id' => $order['store_id'], - 'number' => $fees, - 'financial_pm' => 0, - 'user_ship' => 3, - ]; - // if ($village_uid > 0) { - // $financeLogic->other_arr['vip_uid'] = $village_uid; - // } - // $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); - // $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + // $sing[] = [ + // 'uid' => $village_uid, + // 'order_id' => $order['order_id'], + // 'title' => '村长订单获得兑换券', + // 'store_id' => $order['store_id'], + // 'number' => $fees, + // 'financial_pm' => 1, + // 'user_ship' => 2, + // ]; + // $sing[] = [ + // 'uid' => $brigade_uid, + // 'order_id' => $order['order_id'], + // 'title' => '队长订单获得兑换券', + // 'store_id' => $order['store_id'], + // 'number' => $fees, + // 'financial_pm' => 1, + // 'user_ship' => 3, + // ]; + // $sing[] = [ + // 'uid' => $village_uid, + // 'order_id' => $order['order_id'], + // 'title' => '订单扣除兑换券', + // 'store_id' => $order['store_id'], + // 'number' => $fees, + // 'financial_pm' => 0, + // 'user_ship' => 2, + // ]; + // $sing[] = [ + // 'uid' => $brigade_uid, + // 'order_id' => $order['order_id'], + // 'title' => '订单扣除兑换券', + // 'store_id' => $order['store_id'], + // 'number' => $fees, + // 'financial_pm' => 0, + // 'user_ship' => 3, + // ]; + if ($village_uid > 0) { + $financeLogic->other_arr['vip_uid'] = $village_uid; + } + $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //队长获得 - // if ($brigade_uid > 0) { - // $financeLogic->other_arr['vip_uid'] = $brigade_uid; - // } - // $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); - // $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - $user_sing->saveAll($sing); + if ($brigade_uid > 0) { + $financeLogic->other_arr['vip_uid'] = $brigade_uid; + } + $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + // $user_sing->saveAll($sing); //其他获得 $financeLogic->other_arr['vip_uid'] = 0; $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); From 3723c9c04750cadaeb3b0042168f1912d1892692 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 23 Jun 2024 19:07:44 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat(PayNotifyLogic):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 144 +++++++++++++--------------- 1 file changed, 68 insertions(+), 76 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 6be163d6c..bfd362fd3 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -82,15 +82,15 @@ class PayNotifyLogic extends BaseLogic $user->save(); if ($order['spread_uid'] > 0 && $user['user_ship'] == 1) { - $oldUser = User::where('id',$order['spread_uid'])->value('purchase_funds'); + $oldUser = User::where('id', $order['spread_uid'])->value('purchase_funds'); if ($oldUser < $order['pay_price']) { $order['pay_price'] = $oldUser; } } $capitalFlowDao = new CapitalFlowLogic($user); - $capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'],'',0,$order['store_id']); + $capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']); self::dealProductLog($order); - if($order['shipping_type'] == 3){ + if ($order['shipping_type'] == 3) { self::descStock($order['id']); } // self::afterPay($order); @@ -136,16 +136,15 @@ class PayNotifyLogic extends BaseLogic ]; (new UserSign())->saveAll($sing); - if($extra && $extra['store_id']){ + if ($extra && $extra['store_id']) { $params = [ - 'verify_code'=>$order['verify_code'], - 'store_id'=>$extra['store_id'], - 'staff_id'=>$extra['staff_id'] + 'verify_code' => $order['verify_code'], + 'store_id' => $extra['store_id'], + 'staff_id' => $extra['staff_id'] ]; OrderLogic::lessWriteOff($params); } self::dealProductLog($order); - } @@ -176,23 +175,23 @@ class PayNotifyLogic extends BaseLogic $user->save(); $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) { -// self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS); -// } + $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price'], '', 1, $order['store_id']); + // if ($user['user_ship'] == 1) { + // self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS); + // } - if($extra && $extra['store_id']){ + if ($extra && $extra['store_id']) { $params = [ - 'verify_code'=>$order['verify_code'], - 'store_id'=>$extra['store_id'], - 'staff_id'=>$extra['staff_id'] + 'verify_code' => $order['verify_code'], + 'store_id' => $extra['store_id'], + 'staff_id' => $extra['staff_id'] ]; OrderLogic::writeOff($params); } self::dealProductLog($order); -// if($order['shipping_type'] == 3){ -// self::descStock($order['id']); -// } + // if($order['shipping_type'] == 3){ + // self::descStock($order['id']); + // } // self::afterPay($order); // Redis::send('push-platform-print', ['id' => $order['id']], 60); @@ -228,11 +227,11 @@ class PayNotifyLogic extends BaseLogic } else { $capitalFlowDao = new CapitalFlowLogic($user); //微信支付和用户余额无关 - $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1,$order['store_id']); + $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1, $order['store_id']); } self::dealProductLog($order); - if($order['shipping_type'] == 3){ + if ($order['shipping_type'] == 3) { self::descStock($order['id']); } @@ -333,7 +332,7 @@ class PayNotifyLogic extends BaseLogic $cashFlowLogic = new CashFlowLogic(); $cashFlowLogic->insert($order['store_id'], $order['pay_price']); self::dealProductLog($order); - if($order['shipping_type'] == 3){ + if ($order['shipping_type'] == 3) { self::descStock($order['id']); } // Redis::send('push-platform-print', ['id' => $order['id']]); @@ -367,7 +366,7 @@ class PayNotifyLogic extends BaseLogic self::afterPay($order); } self::dealProductLog($order); - if($order['shipping_type'] == 3){ + if ($order['shipping_type'] == 3) { self::descStock($order['id']); } @@ -398,19 +397,18 @@ class PayNotifyLogic extends BaseLogic $user = User::where('id', $order['uid'])->find(); //纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额) if ($order['spread_uid'] > 0) { - $oldUser = User::where('id',$order['spread_uid'])->field('purchase_funds,user_ship')->find(); - if ($oldUser && $oldUser['user_ship'] == 1){ + $oldUser = User::where('id', $order['spread_uid'])->field('purchase_funds,user_ship')->find(); + if ($oldUser && $oldUser['user_ship'] == 1) { if ($oldUser['purchase_funds'] < $order['pay_price']) { $vipFen = $oldUser['purchase_funds']; } } - } - elseif ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY){ + } elseif ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) { $vipFrozenAmount = self::dealFrozenPrice($order['id']); //为1的时候要去减活动价 -// $final_price = bcsub($order['pay_price'],$order['deduction_price'],2); -// d($final_price,$vipFrozenAmount); - $order['pay_price'] = bcsub($order['pay_price'],$vipFrozenAmount,2); + // $final_price = bcsub($order['pay_price'],$order['deduction_price'],2); + // d($final_price,$vipFrozenAmount); + $order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2); self::dealVipAmount($order, $order['pay_type']); } @@ -449,14 +447,14 @@ class PayNotifyLogic extends BaseLogic if ($deposit > 0) { if ($deposit > $store_profit) { if ($store_profit > 0) { - SystemStore::where('id',$order['store_id'])->inc('paid_deposit',$store_profit)->update(); + SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $store_profit)->update(); $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 } } else { $money = bcsub($store_profit, $deposit, 2); if ($deposit > 0) { - SystemStore::where('id',$order['store_id'])->inc('paid_deposit',$deposit)->update(); + SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $deposit)->update(); $financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); } if ($money) { @@ -473,16 +471,16 @@ class PayNotifyLogic extends BaseLogic // if ($order['is_vip'] >= 1) { if ($order['spread_uid'] > 0) { $financeLogic->other_arr['vip_uid'] = $order['spread_uid']; - if($vipFen){ + if ($vipFen) { $fees = bcdiv(bcmul($vipFen, '0.08', 2), 1, 2); - }else{ + } else { $fees = bcdiv(bcmul($order['pay_price'], '0.08', 2), 1, 2); } $count_frees = bcadd($count_frees, $fees, 2); if ($fees > 0) { User::where('id', $order['spread_uid'])->inc('now_money', $fees)->update(); //记录用户余额收入 - $GiveUser = User::where('id',$order['spread_uid'])->find(); + $GiveUser = User::where('id', $order['spread_uid'])->find(); $capitalFlowDao = new CapitalFlowLogic($GiveUser); $capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees); @@ -503,7 +501,7 @@ class PayNotifyLogic extends BaseLogic $uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id'); if ($uid) { User::where('id', $uid)->inc('integral', $fees)->update(); - $village_uid=$uid; + $village_uid = $uid; } } $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); @@ -511,7 +509,7 @@ class PayNotifyLogic extends BaseLogic $uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id'); if ($uid) { User::where('id', $uid)->inc('integral', $fees)->update(); - $brigade_uid=$uid; + $brigade_uid = $uid; } } } @@ -557,12 +555,14 @@ class PayNotifyLogic extends BaseLogic // 'user_ship' => 3, // ]; if ($village_uid > 0) { - $financeLogic->other_arr['vip_uid'] = $village_uid; + SystemStore::where('id', $village_uid)->inc('store_money', $fees)->update(); + $financeLogic->other_arr['vip_uid'] = $village_uid; } $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //队长获得 if ($brigade_uid > 0) { + SystemStore::where('id', $brigade_uid)->inc('store_money', $fees)->update(); $financeLogic->other_arr['vip_uid'] = $brigade_uid; } $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); @@ -616,10 +616,10 @@ class PayNotifyLogic extends BaseLogic public static function dealFrozenPrice($oid) { - $detail = StoreOrderCartInfo::where('oid',$oid)->select()->toArray(); + $detail = StoreOrderCartInfo::where('oid', $oid)->select()->toArray(); $total_vip = 0; - foreach ($detail as $value){ - $total_vip +=$value['cart_info']['vip_frozen_price']; + foreach ($detail as $value) { + $total_vip += $value['cart_info']['vip_frozen_price']; } return $total_vip; } @@ -635,20 +635,20 @@ class PayNotifyLogic extends BaseLogic * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public static function dealVipAmount($order,$pay_type =1,$transaction_id = 0) + public static function dealVipAmount($order, $pay_type = 1, $transaction_id = 0) { $total_vip = self::dealFrozenPrice($order['id']); - $data=[ + $data = [ 'order_id' => $order['id'], - 'transaction_id' => $transaction_id??0, - 'order_sn' =>$order['order_id'], + 'transaction_id' => $transaction_id ?? 0, + 'order_sn' => $order['order_id'], 'user_id' => $order['uid'], 'number' => $total_vip, - 'pay_type' => $pay_type??1, + 'pay_type' => $pay_type ?? 1, 'status' => 0, 'store_id' => $order['store_id'], 'staff_id' => $order['staff_id'], - 'create_time'=>time() + 'create_time' => time() ]; Db::name('vip_flow')->insert($data); return true; @@ -667,55 +667,52 @@ class PayNotifyLogic extends BaseLogic $store_id = $order['store_id']; $cart_id = $order['cart_id']; $uid = $order['uid']; - if($uid && $cart_id && $store_id){ - $cart_id = explode(',',$cart_id); + if ($uid && $cart_id && $store_id) { + $cart_id = explode(',', $cart_id); $productLog = StoreProductLog::where([ - 'uid'=>$uid - ])->whereIn('cart_id',$cart_id) + 'uid' => $uid + ])->whereIn('cart_id', $cart_id) ->select()->toArray(); - foreach ($productLog as &$value){ + foreach ($productLog as &$value) { $value['pay_uid'] = $uid; $value['oid'] = $order['id']; $cart_info = StoreOrderCartInfo::where([ - 'uid'=>$uid,'old_cart_id'=>$value['cart_id'],'store_id'=>$store_id + 'uid' => $uid, 'old_cart_id' => $value['cart_id'], 'store_id' => $store_id ])->find(); - $value['order_num'] = $cart_info['cart_num']??1; - $value['pay_num'] = $cart_info['cart_num']??1; - $value['pay_price'] = $cart_info['price']??0; - $value['cost_price'] = $cart_info['cart_info']['cost']??0; + $value['order_num'] = $cart_info['cart_num'] ?? 1; + $value['pay_num'] = $cart_info['cart_num'] ?? 1; + $value['pay_price'] = $cart_info['price'] ?? 0; + $value['cost_price'] = $cart_info['cart_info']['cost'] ?? 0; $value['update_time'] = time(); - unset($value['create_time'],$value['delete_time']); + unset($value['create_time'], $value['delete_time']); } (new StoreProductLog())->saveAll($productLog); } return true; - } public static function descSwap($oid) { $updateData = []; - $goods_list = StoreOrderCartInfo::where('oid',$oid)->select()->toArray(); + $goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray(); foreach ($goods_list as $v) { - $StoreBranchProduct =StoreBranchProduct::where( + $StoreBranchProduct = StoreBranchProduct::where( [ - 'store_id'=>$v['store_id'], - 'product_id'=>$v['product_id'], + 'store_id' => $v['store_id'], + 'product_id' => $v['product_id'], ] )->withTrashed()->find(); $updateData[] = [ 'id' => $StoreBranchProduct['id'], - 'swap' => $StoreBranchProduct['swap']-$v['cart_num'], + 'swap' => $StoreBranchProduct['swap'] - $v['cart_num'], 'sales' => ['inc', $v['cart_num']] ]; - } (new StoreBranchProduct())->saveAll($updateData); - } @@ -730,26 +727,21 @@ class PayNotifyLogic extends BaseLogic public static function descStock($oid) { $updateData = []; - $goods_list = StoreOrderCartInfo::where('oid',$oid)->select()->toArray(); + $goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray(); foreach ($goods_list as $v) { - $StoreBranchProduct =StoreBranchProduct::where( + $StoreBranchProduct = StoreBranchProduct::where( [ - 'store_id'=>$v['store_id'], - 'product_id'=>$v['product_id'], + 'store_id' => $v['store_id'], + 'product_id' => $v['product_id'], ] )->withTrashed()->find(); $updateData[] = [ 'id' => $StoreBranchProduct['id'], - 'stock' => $StoreBranchProduct['stock']-$v['cart_num'], + 'stock' => $StoreBranchProduct['stock'] - $v['cart_num'], 'sales' => ['inc', $v['cart_num']] ]; - } (new StoreBranchProduct())->saveAll($updateData); - } - - - } From 51a44f81051048d430ab2033549432d20d4d961a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 23 Jun 2024 19:37:34 +0800 Subject: [PATCH 3/7] =?UTF-8?q?feat(store=5Forder):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=94=AF=E4=BB=98=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=BC=9A=E5=91=98=E4=BB=B7=E5=92=8C?= =?UTF-8?q?=E5=95=86=E6=88=B7=E4=BB=B7=E6=A0=BC=E8=AE=A1=E7=AE=97=E9=94=99?= =?UTF-8?q?=E8=AF=AF=EF=BC=8C=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BA=86=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/store/StoreController.php | 2 +- app/api/lists/order/CartList.php | 24 ++++++++--------- app/api/lists/product/ProductLists.php | 2 +- app/api/logic/order/OrderLogic.php | 28 ++++++++++---------- app/common/logic/PayNotifyLogic.php | 6 ++++- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 9d23fd0fb..6a2b27056 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -80,7 +80,7 @@ class StoreController extends BaseApiController 'uid'=>$find['id'], 'staff_id'=>0, 'order_id'=>getNewOrderId('CZ'), - 'price'=>0.01, + 'price'=>1000, 'recharge_type'=>'INDUSTRYMEMBERS', ]; $order = UserRecharge::create($data); diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index 652c9eedf..c10cff8de 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -65,22 +65,22 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists foreach ($list as $key => &$item) { $find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id' => $item['store_id']]) - ->field('product_id,image,price,cost,store_name,unit,delete_time,vip_price') + ->field('product_id,image,cost price,cost,store_name,unit,delete_time,vip_price') ->withTrashed() ->find(); if ($find) { - if ($user && $user['user_ship'] == 1) { - //更新 会员为1的时候原价减去会员价 - $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2); - $this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2); - }elseif ($user && $user['user_ship'] == 4) { - //更新 为4商户的时候减去商户价格 - $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2); - $this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2); - }else{ - $this->activity_price =0; - } + // if ($user && $user['user_ship'] == 1) { + // //更新 会员为1的时候原价减去会员价 + // $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2); + // $this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2); + // }elseif ($user && $user['user_ship'] == 4) { + // //更新 为4商户的时候减去商户价格 + // $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2); + // $this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2); + // }else{ + // $this->activity_price =0; + // } $item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2); $this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2); $item['imgs'] = $find['image']; diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index f8e219939..1adf1ba6c 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -106,7 +106,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L $this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['stock', '>', 0]; return StoreBranchProduct::where($this->searchWhere) - ->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) + ->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'cost price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) ->with(['className', 'unitName']) ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index f918c51d4..5385eed18 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -74,7 +74,7 @@ class OrderLogic extends BaseLogic /** 计算价格 */ foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,vip_price,cost,purchase,product_id')->withTrashed()->find(); if (!$find) { continue; } @@ -85,19 +85,19 @@ class OrderLogic extends BaseLogic $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 $cart_select[$k]['vip'] = 0; - if ($user && $user['user_ship'] == 1) { - //更新 会员为1的时候原价减去会员价 - $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); - $cart_select[$k]['deduction_price'] =$deduction_price_count; - self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); - $cart_select[$k]['vip'] =1; - } - if ($user && $user['user_ship'] == 4) { - //更新 为4商户的时候减去商户价格 - $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); - $cart_select[$k]['deduction_price'] =$deduction_price_count; - self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); - } + // if ($user && $user['user_ship'] == 1) { + // //更新 会员为1的时候原价减去会员价 + // $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); + // $cart_select[$k]['deduction_price'] =$deduction_price_count; + // self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + // $cart_select[$k]['vip'] =1; + // } + // if ($user && $user['user_ship'] == 4) { + // //更新 为4商户的时候减去商户价格 + // $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); + // $cart_select[$k]['deduction_price'] =$deduction_price_count; + // self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + // } //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index bfd362fd3..b2c1ea596 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -389,7 +389,11 @@ class PayNotifyLogic extends BaseLogic public static function afterPay($order, $transaction_id = 0) { $financeLogic = new StoreFinanceFlowLogic(); - $user_sing = new UserSign(); + // $user_sing = new UserSign(); + $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 + $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id,$order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + return false; $vipFen = 0; if ($order['uid'] > 0) { // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 From 6641010821df45e5bc85c21a3fd1f7082fd199c7 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 23 Jun 2024 19:53:49 +0800 Subject: [PATCH 4/7] =?UTF-8?q?feat(PayNotifyLogic):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index b2c1ea596..4e4993303 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -389,11 +389,14 @@ class PayNotifyLogic extends BaseLogic public static function afterPay($order, $transaction_id = 0) { $financeLogic = new StoreFinanceFlowLogic(); - // $user_sing = new UserSign(); + //-----临时活动更改 + $financeLogic->order = $order; + $financeLogic->user = ['uid' => $order['uid']]; $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); $financeLogic->out($transaction_id,$order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); return false; + $user_sing = new UserSign(); $vipFen = 0; if ($order['uid'] > 0) { // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 From c6bcec76faadadb9771385922d0823bcaafe0c81 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 23 Jun 2024 19:56:55 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat(OrderLogic,=20PayNotifyLogic):=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95=E5=92=8C=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=8D=95=E8=8E=B7=E5=92=8C=E5=A4=84=E7=90=86=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BA=86=E5=BA=93=E5=AD=98=E6=9B=B4=E6=96=B0=E9=94=99?= =?UTF-8?q?=E8=AF=AF=EF=BC=8C=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BA=86=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 1 + app/common/logic/PayNotifyLogic.php | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 5385eed18..14654eab6 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -446,6 +446,7 @@ class OrderLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); + d($e); self::setError($e->getMessage()); return false; } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 4e4993303..b8df492bd 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -742,11 +742,14 @@ class PayNotifyLogic extends BaseLogic 'product_id' => $v['product_id'], ] )->withTrashed()->find(); - $updateData[] = [ - 'id' => $StoreBranchProduct['id'], - 'stock' => $StoreBranchProduct['stock'] - $v['cart_num'], - 'sales' => ['inc', $v['cart_num']] - ]; + if($StoreBranchProduct){ + $updateData[] = [ + 'id' => $StoreBranchProduct['id'], + 'stock' => $StoreBranchProduct['stock'] - $v['cart_num'], + 'sales' => ['inc', $v['cart_num']] + ]; + } + } (new StoreBranchProduct())->saveAll($updateData); From e7a74c1b106761012e5e7fb316728cda751cdd0d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 23 Jun 2024 20:12:14 +0800 Subject: [PATCH 6/7] =?UTF-8?q?feat(PayNotifyLogic):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=85=91=E6=8D=A2=E5=88=B8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index b8df492bd..392cf64cb 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -389,14 +389,24 @@ class PayNotifyLogic extends BaseLogic public static function afterPay($order, $transaction_id = 0) { $financeLogic = new StoreFinanceFlowLogic(); + $user_sing = new UserSign(); //-----临时活动更改 $financeLogic->order = $order; $financeLogic->user = ['uid' => $order['uid']]; $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); $financeLogic->out($transaction_id,$order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $user_number = bcmul($order['pay_price'], '0.10', 2); + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '购买商品获得兑换券', + 'store_id' => $order['store_id'], + 'number' => $user_number, + ]; + $user_sing->save($sing); + User::where('id', $order['uid'])->inc('integral', $user_number)->update(); return false; - $user_sing = new UserSign(); $vipFen = 0; if ($order['uid'] > 0) { // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 From 3e425d97fc876d2d5e568b9cbbcf697842711b09 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 23 Jun 2024 20:12:50 +0800 Subject: [PATCH 7/7] =?UTF-8?q?feat(PayNotifyLogic):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=A2=E5=8D=95=E6=94=AF=E4=BB=98=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 392cf64cb..eb0f42696 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -395,17 +395,19 @@ class PayNotifyLogic extends BaseLogic $financeLogic->user = ['uid' => $order['uid']]; $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); - $financeLogic->out($transaction_id,$order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - $user_number = bcmul($order['pay_price'], '0.10', 2); - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'title' => '购买商品获得兑换券', - 'store_id' => $order['store_id'], - 'number' => $user_number, - ]; - $user_sing->save($sing); - User::where('id', $order['uid'])->inc('integral', $user_number)->update(); + $financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + if ($order['uid'] > 0) { + $user_number = bcmul($order['pay_price'], '0.10', 2); + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '购买商品获得兑换券', + 'store_id' => $order['store_id'], + 'number' => $user_number, + ]; + $user_sing->save($sing); + User::where('id', $order['uid'])->inc('integral', $user_number)->update(); + } return false; $vipFen = 0; if ($order['uid'] > 0) { @@ -752,14 +754,13 @@ class PayNotifyLogic extends BaseLogic 'product_id' => $v['product_id'], ] )->withTrashed()->find(); - if($StoreBranchProduct){ + if ($StoreBranchProduct) { $updateData[] = [ 'id' => $StoreBranchProduct['id'], 'stock' => $StoreBranchProduct['stock'] - $v['cart_num'], 'sales' => ['inc', $v['cart_num']] ]; } - } (new StoreBranchProduct())->saveAll($updateData);