From 4292c803013337352a977fd388a400b1c5969d3b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 18 Jun 2024 09:21:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91=E4=BB=A5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E7=94=A8=E6=88=B7=E7=AD=BE=E5=88=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 56 ++++++++++++++++------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 9a4e21e80..ebc034de2 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -155,10 +155,10 @@ class PayNotifyLogic extends BaseLogic $extra['create_time'] = $order['create_time']; // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); Redis::send('push-platform-print', ['id' => $order['id']]); - } + } // else { - // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); - // Db::name('order_middle')->insert(['c_order_id' => $order['id']]); + // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); + // Db::name('order_middle')->insert(['c_order_id' => $order['id']]); // } if (!empty($extra['payer']['openid']) && $order->pay_type == 7) { Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5); @@ -276,14 +276,13 @@ class PayNotifyLogic extends BaseLogic if ($order->pay_type == 9) { $order->status = 2; self::afterPay($order); - } if ($order->pay_type == 9) { $extra['create_time'] = $order['create_time']; // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); Redis::send('push-platform-print', ['id' => $order['id']]); - } + } // else { // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); // } @@ -298,6 +297,8 @@ 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']]; // if ($order->pay_type != 9 || $order->pay_type != 10) { @@ -305,6 +306,15 @@ class PayNotifyLogic extends BaseLogic $count_frees = 0; //商户应该获得的钱 每个商品的price-ot_price 利润 // if (isset($order->profit) && $order->profit > 0) { + if($order['uid']>0){ + $sing = [ + 'uid' => $order['uid'], + 'title' => '购买商品获得兑换券', + 'store_id' => $order['store_id'], + 'number' => bcmul($order['pay_price'], '0.01', 2), + ]; + $user_sing->save($sing); + } //平台手续费 $fees = bcdiv(bcmul($order['pay_price'], '0.02', 2), 1, 2); @@ -362,14 +372,14 @@ class PayNotifyLogic extends BaseLogic $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); if ($arr1) { $village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id'); - if($village_uid){ + if ($village_uid) { User::where('id', $village_uid)->inc('integral', $fees)->update(); } } $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); if ($arr2) { $brigade_uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id'); - if($brigade_uid){ + if ($brigade_uid) { User::where('id', $brigade_uid)->inc('integral', $fees)->update(); } } @@ -377,23 +387,22 @@ class PayNotifyLogic extends BaseLogic } if ($fees > 0) { //村长获得 - $sing=[]; - $user_sing=new UserSign(); + $sing = []; - $sing[]=[ - 'uid'=>$village_uid, - 'title'=>'村长订单获得兑换券', - 'store_id'=>$order['store_id'], - 'number'=>$fees, + $sing[] = [ + 'uid' => $village_uid, + 'title' => '村长订单获得兑换券', + 'store_id' => $order['store_id'], + 'number' => $fees, ]; - $sing[]=[ - 'uid'=>$brigade_uid, - 'title'=>'队长订单获得兑换券', - 'store_id'=>$order['store_id'], - 'number'=>$fees, + $sing[] = [ + 'uid' => $brigade_uid, + 'title' => '队长订单获得兑换券', + 'store_id' => $order['store_id'], + 'number' => $fees, ]; // if ($village_uid > 0) { - // $financeLogic->other_arr['vip_uid'] = $village_uid; + // $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']); @@ -410,14 +419,13 @@ class PayNotifyLogic extends BaseLogic $financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); } } - $fees=bcsub($order['pay_price'], $count_frees, 2); + $fees = bcsub($order['pay_price'], $count_frees, 2); //供应链订单获得 if ($fees > 0) { - $financeLogic->in($transaction_id,$fees , OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - } -// } + // } $financeLogic->save(); // } }