From df67ee76991e90fe2747cf2c0918e9bb5d5b47d2 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 18:59:34 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A4=BC=E5=93=81?= =?UTF-8?q?=E5=88=B8=E6=A0=B8=E9=94=80=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 5 +++++ app/common/logic/PayNotifyLogic.php | 25 ++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index f1d156db3..e9eb7e96c 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -458,6 +458,11 @@ class OrderLogic extends BaseLogic $money=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>2])->value('number'); $financeFlowLogic->updateStatusStore($order['id'],$order['store_id'],$money,$deposit); + $check = Db::name('user_sign_log')->where('order_id',$order['order_id'])->find(); + if($check){ + User::where('id',$order['uid'])->inc('purchase_funds',$check['number'])->update(); + } + Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 98e90d31b..db33821e3 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -256,11 +256,12 @@ class PayNotifyLogic extends BaseLogic ]; if($one['back_num'] >= $backPurchase){ + $wait = bcsub($one['back_num'],$backPurchase,2)??0; - $data['number'] =$backPurchase; + $data['number'] =$wait; Db::name('user_sign_log')->insert($data); //总的减去采购款百分之十剩余的 - $wait = bcsub($one['back_num'],$backPurchase,2)??0; + if(empty($wait)){ UserSign::where('id',$one['id'])->update( @@ -273,13 +274,13 @@ class PayNotifyLogic extends BaseLogic //add UserSign::where('id',$one['id'])->update( [ - 'back_num'=>$wait + 'back_num'=>$backPurchase ] ); } //并且加到对应的用户的采购款中 - User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); +// User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); } else{ //对比采购款支付的多少 多了就拿冻结金额即可 @@ -293,7 +294,7 @@ class PayNotifyLogic extends BaseLogic ] ); //并且加到对应的用户的采购款中 - User::where('id',$order['uid'])->inc('purchase_funds',$one['number'])->update(); +// User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); } } @@ -322,8 +323,18 @@ class PayNotifyLogic extends BaseLogic ]; $data['number'] =$check; Db::name('user_sign')->insert($data); + + $data = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '充值获得冻结兑换券', + 'financial_pm' => 1, + 'type' => 1, + ]; + $data['number'] =$backPurchase; + Db::name('user_sign_log')->insert($data); } - User::where('id',$order['uid'])->inc('purchase_funds',$backPurchase)->update();//add +// User::where('id',$order['uid'])->inc('purchase_funds',$backPurchase)->update();//add }else{ //log @@ -336,7 +347,7 @@ class PayNotifyLogic extends BaseLogic ]; $data['number'] =$check; Db::name('user_sign_log')->insert($data); - User::where('id',$order['uid'])->inc('purchase_funds',$check)->update();//add +// User::where('id',$order['uid'])->inc('purchase_funds',$check)->update();//add } } From b5a6fab3b21e5707837dec2142c00b313a09c15b Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 19:04:10 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index e9eb7e96c..ed335f205 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -461,6 +461,7 @@ class OrderLogic extends BaseLogic $check = Db::name('user_sign_log')->where('order_id',$order['order_id'])->find(); if($check){ User::where('id',$order['uid'])->inc('purchase_funds',$check['number'])->update(); + Db::name('user_sign_log')->where('order_id',$order['order_id'])->update(['status'=>1]); } Db::commit(); From 862b05496e3a793716c87febed6b11407bc0761a Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 19:11:10 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index db33821e3..2eebad45c 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -211,6 +211,7 @@ class PayNotifyLogic extends BaseLogic 'type'=>1, 'status'=>0 ])->count(); + if($count){ self::addFlowLog($order); } @@ -257,12 +258,9 @@ class PayNotifyLogic extends BaseLogic if($one['back_num'] >= $backPurchase){ $wait = bcsub($one['back_num'],$backPurchase,2)??0; - - $data['number'] =$wait; + $data['number'] =$backPurchase; Db::name('user_sign_log')->insert($data); //总的减去采购款百分之十剩余的 - - if(empty($wait)){ UserSign::where('id',$one['id'])->update( [ @@ -274,7 +272,7 @@ class PayNotifyLogic extends BaseLogic //add UserSign::where('id',$one['id'])->update( [ - 'back_num'=>$backPurchase + 'back_num'=>$wait ] ); } From f64294494cee8a7f3ba55aad1561794826604295 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 19:34:08 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=86=BB=E7=BB=93=E7=A4=BC=E5=93=81=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 49 +++++++++++++++++++++++++++-- app/common/logic/PayNotifyLogic.php | 13 +++++--- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index ed335f205..f30d16240 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -458,9 +458,54 @@ class OrderLogic extends BaseLogic $money=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>2])->value('number'); $financeFlowLogic->updateStatusStore($order['id'],$order['store_id'],$money,$deposit); - $check = Db::name('user_sign_log')->where('order_id',$order['order_id'])->find(); + $check = Db::name('user_sign_log')->where('order_id',$order['order_id']) + ->where(['status'=>0]) + ->find(); if($check){ - User::where('id',$order['uid'])->inc('purchase_funds',$check['number'])->update(); +// User::where('id',$order['uid'])->inc('purchase_funds',$check['number'])->update(); +// $user_number = bcmul($order['pay_price'], '0.10', 2); + + $base = UserSign::where([ + 'uid'=>$order['uid'], + 'type'=>1, + 'status'=>0 + ])->find(); + $user_sing = new UserSign(); + if($base['number'] > 0 && $base['number'] >= $check['number']){ + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'].'-b', + 'title' => '返还兑换券', + 'financial_pm' => 1, + 'store_id' => $order['store_id'], + ]; + $sing['number'] = $check['number']; + $user_sing->save($sing); + if($base['number'] == $check['number']){ + UserSign::where([ + 'uid'=>$order['uid'], + 'type'=>1, + 'status'=>0 + ])->update(['status'=>1]); + } + } + if($base['number'] < $check['number']){ + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'].'-b', + 'title' => '返还兑换券', + 'financial_pm' => 1, + 'store_id' => $base['number'], + ]; + $sing['number'] = $check['number']; + $user_sing->save($sing); + UserSign::where([ + 'uid'=>$order['uid'], + 'type'=>1, + 'status'=>0 + ])->update(['status'=>1]); + } + Db::name('user_sign_log')->where('order_id',$order['order_id'])->update(['status'=>1]); } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 2eebad45c..373aa64c0 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -236,10 +236,12 @@ class PayNotifyLogic extends BaseLogic ]); $query1 = clone $query; $ids = $query->column('id'); - $check = $query->sum('back_num'); + $check = $query->sum('number'); $count = $query1->count(); if($check && $check >0){ - $backPurchase = bcsub($order['pay_price'],0.1,2); + $backPurchase = bcmul($order['pay_price'],0.1,2); + + if($count == 1){ //存在拆单子否 //少了就冻结减去这个对应的金额 @@ -259,12 +261,13 @@ class PayNotifyLogic extends BaseLogic if($one['back_num'] >= $backPurchase){ $wait = bcsub($one['back_num'],$backPurchase,2)??0; $data['number'] =$backPurchase; + Db::name('user_sign_log')->insert($data); //总的减去采购款百分之十剩余的 if(empty($wait)){ UserSign::where('id',$one['id'])->update( [ - 'back_num'=>0, + 'number'=>0, 'status'=>1 ] ); @@ -272,7 +275,7 @@ class PayNotifyLogic extends BaseLogic //add UserSign::where('id',$one['id'])->update( [ - 'back_num'=>$wait + 'number'=>$wait ] ); } @@ -287,7 +290,7 @@ class PayNotifyLogic extends BaseLogic Db::name('user_sign_log')->insert($data); UserSign::where('id',$one['id'])->update( [ - 'back_num'=>0, + 'number'=>0, 'status'=>1 ] ); From fb03d9c2ff9d2670c905311b20c14d580416cda4 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 19:43:44 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=A0=B8=E9=94=80=E5=90=8E=E5=88=B0?= =?UTF-8?q?=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 13 ++++++++- app/common/logic/PayNotifyLogic.php | 44 ++++++++++++++--------------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index f30d16240..347b25849 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -460,7 +460,7 @@ class OrderLogic extends BaseLogic $check = Db::name('user_sign_log')->where('order_id',$order['order_id']) ->where(['status'=>0]) - ->find(); + ->find();//$check['number']扣的 if($check){ // User::where('id',$order['uid'])->inc('purchase_funds',$check['number'])->update(); // $user_number = bcmul($order['pay_price'], '0.10', 2); @@ -481,6 +481,11 @@ class OrderLogic extends BaseLogic ]; $sing['number'] = $check['number']; $user_sing->save($sing); + //减少 + UserSign::where('id',$check['id'])->update( + [ + 'number'=>$check['number'] + ]); if($base['number'] == $check['number']){ UserSign::where([ 'uid'=>$order['uid'], @@ -499,6 +504,12 @@ class OrderLogic extends BaseLogic ]; $sing['number'] = $check['number']; $user_sing->save($sing); + + UserSign::where('id',$check['id'])->update( + [ + 'number'=>$base['number'] + ]); + UserSign::where([ 'uid'=>$order['uid'], 'type'=>1, diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 373aa64c0..f02c22d70 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -259,26 +259,26 @@ class PayNotifyLogic extends BaseLogic ]; if($one['back_num'] >= $backPurchase){ - $wait = bcsub($one['back_num'],$backPurchase,2)??0; +// $wait = bcsub($one['back_num'],$backPurchase,2)??0; $data['number'] =$backPurchase; Db::name('user_sign_log')->insert($data); //总的减去采购款百分之十剩余的 - if(empty($wait)){ - UserSign::where('id',$one['id'])->update( - [ - 'number'=>0, - 'status'=>1 - ] - ); - }else{ - //add - UserSign::where('id',$one['id'])->update( - [ - 'number'=>$wait - ] - ); - } +// if(empty($wait)){ +// UserSign::where('id',$one['id'])->update( +// [ +// 'number'=>0, +// 'status'=>1 +// ] +// ); +// }else{ +// //add +// UserSign::where('id',$one['id'])->update( +// [ +// 'number'=>$wait +// ] +// ); +// } //并且加到对应的用户的采购款中 // User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); @@ -288,12 +288,12 @@ class PayNotifyLogic extends BaseLogic $data['number'] =$one['number']; //都存到对应的log日志 Db::name('user_sign_log')->insert($data); - UserSign::where('id',$one['id'])->update( - [ - 'number'=>0, - 'status'=>1 - ] - ); +// UserSign::where('id',$one['id'])->update( +// [ +// 'number'=>0, +// 'status'=>1 +// ] +// ); //并且加到对应的用户的采购款中 // User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); } From 614c34db8ea384422b487fad7b57f0edb3a51925 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 19:55:56 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 14 ++++++-------- app/common/logic/PayNotifyLogic.php | 4 +++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 347b25849..b694a0c78 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -478,19 +478,18 @@ class OrderLogic extends BaseLogic 'title' => '返还兑换券', 'financial_pm' => 1, 'store_id' => $order['store_id'], + 'status' => 1, ]; $sing['number'] = $check['number']; $user_sing->save($sing); //减少 - UserSign::where('id',$check['id'])->update( + UserSign::where('id',$check['sid'])->update( [ 'number'=>$check['number'] ]); if($base['number'] == $check['number']){ UserSign::where([ - 'uid'=>$order['uid'], - 'type'=>1, - 'status'=>0 + 'id'=>$order['sid'] ])->update(['status'=>1]); } } @@ -501,19 +500,18 @@ class OrderLogic extends BaseLogic 'title' => '返还兑换券', 'financial_pm' => 1, 'store_id' => $base['number'], + 'status' => 1, ]; $sing['number'] = $check['number']; $user_sing->save($sing); - UserSign::where('id',$check['id'])->update( + UserSign::where('id',$check['sid'])->update( [ 'number'=>$base['number'] ]); UserSign::where([ - 'uid'=>$order['uid'], - 'type'=>1, - 'status'=>0 + 'id'=>$order['sid'] ])->update(['status'=>1]); } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index f02c22d70..e746a956b 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -251,6 +251,7 @@ class PayNotifyLogic extends BaseLogic 'status'=>0 ])->find(); $data = [ + 'sid'=>$one['id'], 'uid' => $order['uid'], 'order_id' => $order['order_id'], 'title' => '充值获得冻结兑换券', @@ -323,10 +324,11 @@ class PayNotifyLogic extends BaseLogic 'type' => 1, ]; $data['number'] =$check; - Db::name('user_sign')->insert($data); + $sid = Db::name('user_sign')->insertGetId($data); $data = [ 'uid' => $order['uid'], + 'sid' => $sid, 'order_id' => $order['order_id'], 'title' => '充值获得冻结兑换券', 'financial_pm' => 1, From a6c5da49d65090d43f338b0df474720bc914a4ec Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 20:00:29 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=A3=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index b694a0c78..206f9b115 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -483,10 +483,7 @@ class OrderLogic extends BaseLogic $sing['number'] = $check['number']; $user_sing->save($sing); //减少 - UserSign::where('id',$check['sid'])->update( - [ - 'number'=>$check['number'] - ]); + UserSign::where('id',$check['sid'])->dec('number',$check['number'])->update(); if($base['number'] == $check['number']){ UserSign::where([ 'id'=>$order['sid'] @@ -505,10 +502,8 @@ class OrderLogic extends BaseLogic $sing['number'] = $check['number']; $user_sing->save($sing); - UserSign::where('id',$check['sid'])->update( - [ - 'number'=>$base['number'] - ]); + UserSign::where('id',$check['sid'])->dec('number',$base['number'])->update(); + UserSign::where([ 'id'=>$order['sid']