Mike 7 years ago
parent
commit
04a0c39ec0

+ 32 - 9
server/app/Http/Controllers/Api/V1/PayController.php

xqd
@@ -393,17 +393,40 @@ class PayController extends Controller
         if ($validator->fails()) {
             return $this->validatorError($validator->messages()->all(), ErrorCode::CLIENT_WRONG_PARAMS);
         }
-        $order = new OrderInfoModel();
+//        $order = new OrderInfoModel();
 
         Log::info($data['number']);
-        $order->code            = $data['code'];
-        $order->transaction_id  = $data['transaction_id'];
-        $order->user_id         = $data['user_id'];
-        $order->goods_id        = $data['goods_id'];
-        $order->price           = $data['price'];
-        $order->number          = $data['number'];
-        $order->amount          = $data['amount'];
-        $order->pay_type        = $data['pay_type'];
+
+        $AppleProducts = OrderInfoModel::getAllAppleProducts();
+        $coin = 0 ;
+        if(isset($AppleProducts[$data['number']])){
+            $coin = $AppleProducts[$data['number']];
+        }
+//        $order->code            = $data['code'];
+//        $order->transaction_id  = $data['transaction_id'];
+//        $order->user_id         = $data['user_id'];
+//        $order->goods_id        = $data['goods_id'];
+//        $order->price           = $data['price'];
+//        $order->number          = $data['number'];
+//        $order->amount          = $data['amount'];
+//        $order->pay_type        = $data['pay_type'];
+
+        //更新订单状态
+//        $order->status = OrderInfoModel::STATUS_FINISHED;
+//        $order->save();
+
+        $u = Auth::user();
+        $u->coin += $coin;
+        $u->save();
+        //记日志
+        $_types = AccountLog::getAllType();
+        $_ops = AccountLog::getAllop();
+        $this->logAccount($_types[AccountLog::TYPE_CASH], $u->id, $u->name,$coin,
+            $_ops[AccountLog::OP_CHARGE],
+            $_types[AccountLog::TYPE_COIN], $u->id,$u->name,$coin,$data['number'],'');
+
+
+        \Log::info('支付完成');
         if (isset($data['ext_info'])) {
             $order->ext_info = $data['ext_info'];
         }

+ 20 - 0
server/app/Models/OrderInfoModel.php

xqd xqd
@@ -39,6 +39,22 @@ class OrderInfoModel extends Model
 //        self::PAY_TYPE_UNIONPAY     => '银联支付',
     ];
 
+    //苹果支付金额
+    private static $_apple_products = [
+        self::Apple_Product1      => 1,
+        self::Apple_Product2      => 6,
+        self::Apple_Product3      => 50,
+        self::Apple_Product4      => 188,
+        self::Apple_Product5      => 898,
+    ];
+
+    //苹果支付类型
+    const Apple_Product1    = 'apple100000';
+    const Apple_Product2    = 'apple100001';
+    const Apple_Product3    = 'apple100002';
+    const Apple_Product4    = 'apple100003';
+    const Apple_Product5    = 'apple100004';
+
     //订单状态定义
     const STATUS_PENDING    = 0;
     const STATUS_FINISHED   = 1;
@@ -63,4 +79,8 @@ class OrderInfoModel extends Model
     public static function getAllPayTypes() {
         return self::$_pay_types;
     }
+
+    public static function getAllAppleProducts() {
+        return self::$_apple_products;
+    }
 }