diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 005c32207..144b89d03 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -92,9 +92,9 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']); self::dealProductLog($order); - if ($order['shipping_type'] == 3) { - self::descStock($order['id']); - } +// if ($order['shipping_type'] == 3) { +// self::descStock($order['id']); +// } self::afterPay($order); if ($extra && $extra['store_id']) { $params = [ @@ -289,7 +289,7 @@ class PayNotifyLogic extends BaseLogic $user = User::where('id', $order['uid'])->findOrEmpty(); $capitalFlowDao = new CapitalFlowLogic($user); $deal_money = bcdiv($extra['amount']['refund'], 100, 2); - + $check_user_sing = UserSign::where('order_id',$order['order_id'])->count(); if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) { if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额 $user->now_money = bcadd($user->now_money, $deal_money, 2); @@ -299,7 +299,6 @@ class PayNotifyLogic extends BaseLogic //退款 $capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money); } - if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款 if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款 $user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2); $user->save(); @@ -308,6 +307,14 @@ class PayNotifyLogic extends BaseLogic //退款 $capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money); } + if($check_user_sing){ + self::descUserSing($order); + } + return true; + } + //积分 + if($check_user_sing){ + self::descUserSing($order); } //微信日志 user_order_refund $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1); @@ -317,9 +324,38 @@ class PayNotifyLogic extends BaseLogic return true; // self::afterPay($order,$extra['transaction_id']); } + + //退积分 + public static function descUserSing($order) + { + $user_sing = new UserSign(); + if ($order['uid'] > 0 ) { + $user_number = bcmul($order['refund_price'], '0.10', 2); + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '退款扣除兑换券', + 'financial_pm' => 0, + 'store_id' => $order['store_id'], + 'number' => $user_number, + ]; + $user_sing->save($sing); + $now_int = User::where('id',$order['uid'])->find(); + if($now_int){ + if($now_int['integral'] > $user_number){ + User::where('id',$order['uid'])->dec('integral',$user_number)->update(); + }else{ + User::where('id',$order['uid'])->dec('integral',$now_int['integral'])->update(); + } + + } + } + return true; + } + /** * 财务退还金额相关 * @param $orderSn @@ -407,6 +443,7 @@ class PayNotifyLogic extends BaseLogic 'uid' => $order['uid'], 'order_id' => $order['order_id'], 'title' => '购买商品获得兑换券', + 'financial_pm' => 1, 'store_id' => $order['store_id'], 'number' => $user_number, ]; @@ -557,6 +594,7 @@ class PayNotifyLogic extends BaseLogic 'uid' => $order['uid'], 'order_id' => $order['order_id'], 'title' => '购买商品获得兑换券', + 'financial_pm' => 1, 'store_id' => $order['store_id'], 'number' => $user_number, ]; @@ -592,6 +630,7 @@ class PayNotifyLogic extends BaseLogic 'uid' => $order['uid'], 'order_id' => $order['order_id'], 'title' => '购买商品获得兑换券', + 'financial_pm' => 1, 'store_id' => $order['store_id'], 'number' => $user_number, 'status' => 0,