diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 1dc074f92..8dc4245b5 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -206,6 +206,14 @@ class PayNotifyLogic extends BaseLogic OrderLogic::writeOff($params); } self::dealProductLog($order); + $count = UserSign::where([ + 'uid'=>$order['uid'], + 'type'=>1, + 'status'=>0 + ])->count(); + if($count){ + self::addFlowLog($order); + } // if($order['shipping_type'] == 3){ // self::descStock($order['id']); // } @@ -220,9 +228,9 @@ class PayNotifyLogic extends BaseLogic { //查询当前用户有无对应的充值的冻结金额 if($order['uid'] >0 ){ - $query = VipFlow::where([ - 'user_id'=>$order['uid'], - 'type'=>2, + $query = UserSign::where([ + 'uid'=>$order['uid'], + 'type'=>1, 'status'=>0 ]); $query1 = clone $query; @@ -234,30 +242,26 @@ class PayNotifyLogic extends BaseLogic if($count == 1){ //存在拆单子否 //少了就冻结减去这个对应的金额 - $one = VipFlow::where([ - 'user_id'=>$order['uid'], - 'type'=>2, + $one = UserSign::where([ + 'uid'=>$order['uid'], + 'type'=>1, 'status'=>0 ])->find(); $data = [ - 'vip_flow_id'=>$one['id'], - 'order_id' => $order['id'], - 'order_sn' => $order['order_id'], - 'user_id' => $order['uid'], - 'pay_type' => $pay_type ?? 1, - 'status' => 1, + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '充值获得冻结兑换券', + 'financial_pm' => 1, 'type' => 1, - 'store_id' => $order['store_id'], - 'staff_id' => $order['staff_id'], - 'create_time' => time() ]; + if($one['back_num'] >= $backPurchase){ $data['number'] =$backPurchase; - Db::name('la_vip_flow_log')->insert($data); + Db::name('user_sign_log')->insert($data); //总的减去采购款百分之十剩余的 $wait = bcsub($one['back_num'],$backPurchase,2); if(empty($wait)){ - VipFlow::where('id',$one['id'])->update( + UserSign::where('id',$one['id'])->update( [ 'back_num'=>0, 'status'=>1 @@ -265,7 +269,7 @@ class PayNotifyLogic extends BaseLogic ); }else{ //add - VipFlow::where('id',$one['id'])->update([ + UserSign::where('id',$one['id'])->update([ [ 'back_num'=>$wait ] @@ -273,12 +277,13 @@ class PayNotifyLogic extends BaseLogic } //并且加到对应的用户的采购款中 User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); - }else{ + } + else{ //对比采购款支付的多少 多了就拿冻结金额即可 $data['number'] =$one['number']; //都存到对应的log日志 - Db::name('la_vip_flow_log')->insert($data); - VipFlow::where('id',$one['id'])->update( + Db::name('user_sign_log')->insert($data); + UserSign::where('id',$one['id'])->update( [ 'back_num'=>0, 'status'=>1 @@ -292,56 +297,44 @@ class PayNotifyLogic extends BaseLogic //大于0的时候 //先处理金额大的再处理剩余的 /**** 把所有的金额改为正的再加一条后再加***/ - VipFlow::where([ - 'user_id'=>$order['uid'], - 'type'=>2, + UserSign::where([ + 'uid'=>$order['uid'], + 'type'=>1, 'status'=>0 ])->update([ 'status'=>1, - 'remark'=>json_encode($ids) + 'title'=>json_encode($ids) ]); if ($check >= $backPurchase) { //补一条待解冻的 -// $data = [ -// 'order_id' => $order['id'], -// 'transaction_id' => $transaction_id ?? 0, -// 'order_sn' => $order['order_id'], -// 'user_id' => $order['uid'], -// 'number' => $total_vip, -// 'back_num' => $total_vip, -// 'pay_type' => $pay_type ?? 1, -// 'status' => 0, -// 'type' => 1, -// 'store_id' => $order['store_id'], -// 'staff_id' => $order['staff_id'], -// 'create_time' => time() -// ]; -// Db::name('vip_flow')->insert($data); + $left = bcsub($check,$backPurchase,2); + if($left > 0){ + $data = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '补冻结兑换券', + 'financial_pm' => 0, + 'type' => 1, + ]; + $data['number'] =$check; + Db::name('user_sign')->insert($data); + } + User::where('id',$order['uid'])->inc('purchase_funds',$backPurchase)->update();//add }else{ //log $data = [ - 'vip_flow_id'=>0, - 'remark'=>$ids, - 'order_id' => $order['id'], - 'order_sn' => $order['order_id'], - 'user_id' => $order['uid'], - 'pay_type' => $pay_type ?? 1, - 'status' => 1, + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '充值获得冻结兑换券', + 'financial_pm' => 1, 'type' => 1, - 'store_id' => $order['store_id'], - 'staff_id' => $order['staff_id'], - 'create_time' => time() ]; $data['number'] =$check; - Db::name('la_vip_flow_log')->insert($data); + Db::name('user_sign_log')->insert($data); User::where('id',$order['uid'])->inc('purchase_funds',$check)->update();//add } - - - - } } @@ -349,11 +342,7 @@ class PayNotifyLogic extends BaseLogic } - - - - - + return true; } /** @@ -598,21 +587,19 @@ class PayNotifyLogic extends BaseLogic public static function dealRechargeFrozen($order) { $total_vip = bcmul($order['price'],0.1,2); - $data = [ - 'order_id' => $order['id'], - 'transaction_id' => $transaction_id ?? 0, - 'order_sn' => $order['order_id'], - 'user_id' => $order['uid'], + $user_sing = new UserSign(); + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '充值获得冻结兑换券', + 'financial_pm' => 1, + 'store_id' => $order['store_id'], + 'type' => 1, 'number' => $total_vip, 'back_num' => $total_vip, - 'pay_type' => $pay_type ?? 1, - 'status' => 0, - 'type' => 1, - 'store_id' => $order['store_id'], - 'staff_id' => $order['staff_id'], - 'create_time' => time() ]; - Db::name('vip_flow')->insert($data); + $user_sing->save($sing); + return true; } @@ -794,8 +781,7 @@ class PayNotifyLogic extends BaseLogic $order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2); self::dealVipAmount($order, $order['pay_type']); } - if($order['total_price'] > 500 && $order['pay_type'] !=18 - && $order['pay_type'] !=3){ + if($order['total_price'] >= 500 ){ $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'],