Mike %!s(int64=7) %!d(string=hai) anos
pai
achega
3340421575
Modificáronse 1 ficheiros con 11 adicións e 57 borrados
  1. 11 57
      server/app/Http/Controllers/Api/V1/PayController.php

+ 11 - 57
server/app/Http/Controllers/Api/V1/PayController.php

xqd xqd xqd xqd xqd xqd
@@ -3,7 +3,9 @@
 namespace App\Http\Controllers\Api\V1;
 
 use Omnipay\Omnipay;
+use App\Helper\LogHelper;
 use App\Helper\PayHelper;
+use App\Helper\JpushHelper;
 use App\UserInfoModel;
 use App\Models\OrderInfoModel;
 use App\Models\AccountLog;
@@ -13,8 +15,7 @@ use Config, Auth, DB ,Validator;
 
 class PayController extends Controller
 {
-    use PayHelper;
-
+    use PayHelper, LogHelper,JpushHelper;
 
     public function alipayNotify() {
         $rawInfo = Request::all();
@@ -94,17 +95,11 @@ class PayController extends Controller
 
                     //记日志
                     $amount = $rawInfo['total_amount'] * 100;
-                    if (empty($extInfo)) {
-                        $this->logAccount($tp, $u->id, $u->name,
+
+                    $this->logAccount($tp, $u->id, $u->name,
                             AccountLog::OP_CHARGE, $cType, $master_amount,
                             AccountLog::DIRECTION_INC, $cType == AccountLog::TYPE_BALANCE ? $u->balance : $u->credit, AccountLog::CHANNEL_ALIPAY);
-                    } else {
-                        //续消费
 
-                        $this->logAccount($tp, $u->id, $u->name,
-                            AccountLog::OP_CC, $cType, $master_amount,
-                            AccountLog::DIRECTION_INC, $cType == AccountLog::TYPE_BALANCE ? $u->balance : $u->credit, AccountLog::CHANNEL_ALIPAY);
-                    }
                     \Log::info('支付完成');
 
                 } else {
@@ -112,7 +107,6 @@ class PayController extends Controller
                     \Log::error('保存数据失败');
                 }
 
-
                 DB::commit();
 
                 return 'success';
@@ -157,47 +151,15 @@ class PayController extends Controller
                     \Log::error('找不到订单' . $out_trade_no);
                     return 'fail';
                 }
-                $master_amount =  $order->number;
-                $slave_amount = 0;
-                if (!empty($order->ext_info)) {
-                    $extInfo = json_decode($order->ext_info, true);
-                    if ($extInfo !== null) {
-                        $cc = $extInfo['cc_bonus'];
-                        $master_amount = round(($cc / 100) * $order->number);
-                        $slave_amount = $order->number - $master_amount;
-                    }
-                }
-                $tp = '';
-//                $u = null;
-                if ($order->user_type == OrderInfoModel::USER_TYPE_MERCHANT) {
-                    $tp = 'Merchant';
-//                    $u = Merchant::find($order->user_id);
-                } elseif ($order->user_type == OrderInfoModel::USER_TYPE_MEMBER) {
-                    $tp = 'Member';
-                    //Not handled here
-                }
                 $u = UserInfoModel::find($order->user_id);
                 if (!$u) {
-                    \Log::error('用户不存在' . $order->user_type . ', ' . $order->user_id);
+                    \Log::error('用户不存在' . $order->user_id . ', ' . $order->user_id);
                     return 'success';
                 }
 
                 DB::beginTransaction();
-
-                if ($order->goods_type == OrderInfoModel::GOODS_TYPE_BALANCE||$order->goods_type == OrderInfoModel::GOODS_TYPE_COSUME) {
-                    $cType = AccountLog::TYPE_BALANCE;
-//                    $u->account_balance += $order->number;
-                    $u->balance += $master_amount;
-                } elseif ($order->goods_type == OrderInfoModel::GOODS_TYPE_CREDIT) {
-                    $cType = AccountLog::TYPE_CREDIT;
-//                    $u->credit_balance += $order->number;
-                    $u->credit += $master_amount;
-                } else {
-                    \Log::error('商品不存在' . $order->goods_type);
-                    return 'success';
-                }
-                //测试
-                \Log::info('支付金额 '.$master_amount);
+                $cType = AccountLog::TYPE_COIN;
+                $u->coin += $order->number;
                 if ($u->save()) {
 
                     //更新订单状态
@@ -205,17 +167,9 @@ class PayController extends Controller
                     $order->save();
 
                     //记日志
-                    $amount = $rawInfo['total_fee'] * 100;
-                    if (empty($extInfo)) {
-                        $this->logAccount($tp, $u->id, $u->name,
-                            AccountLog::OP_CHARGE, $cType, $master_amount,
-                            AccountLog::DIRECTION_INC, $cType == AccountLog::TYPE_BALANCE ? $u->balance : $u->credit, AccountLog::CHANNEL_WECHATPAY);
-                    } else {
-
-                        $this->logAccount($tp, $u->id, $u->name,
-                            AccountLog::OP_CC, $cType, $master_amount,
-                            AccountLog::DIRECTION_INC, $cType == AccountLog::TYPE_BALANCE ? $u->balance : $u->credit, AccountLog::CHANNEL_WECHATPAY);
-                    }
+//                    $this->logAccount($tp, $u->id, $u->name,
+//                        AccountLog::OP_CHARGE, $cType, $master_amount,
+//                        AccountLog::DIRECTION_INC, $cType == AccountLog::TYPE_BALANCE ? $u->balance : $u->credit, AccountLog::CHANNEL_WECHATPAY);
 
                     \Log::info('支付完成');