Browse Source

fix():修改配置

geek 4 years ago
parent
commit
fdc1f94361

+ 10 - 0
application/api/controller/Order.php

@@ -385,4 +385,14 @@ class Order extends BaseController {
         ])->update(['status' => OrderModel::IS_DELETE]);
         Until::output([]);
     }
+
+    public function payOrderAgain() {
+        $input = Until::getInput();
+        $rule = [
+            'orderId|订单id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $data = (new OrderService())->payAgain((int)$input['orderId']);
+        Until::output($data);
+    }
 }

+ 36 - 2
application/common/service/OrderService.php

@@ -74,9 +74,9 @@ class OrderService {
         //}
         $otherData = [
             'openId'   => $userInfo['open_id'],
-            'attach'   => strtoupper($this->userName),
+            'attach'   => 'storeId:'.$input['storeId'],
             'money'    => $orderMoney * 100,
-            'mark'     => '购买了',
+            'mark'     => '购买了'.$productInfo['product_name'],
             'orderId'  => $orderSn,
             'username' => $userInfo['name'],
             'payCode'  => strtoupper($this->userName),
@@ -94,10 +94,44 @@ class OrderService {
         return $order;
     }
 
+    public function payAgain(int $orderId) {
+        $model = new OrderModel();
+        $info = $model::where(['id' => $orderId])->find();
+        $productInfo = (new ProductModel())::where(['id' => $info['product_id']])->find();
+        if ($info['status'] === OrderModel::IS_PAY) {
+            throw new ApiException('订单已支付');
+        }
+        $userInfo = (new UserModel())::where(['id' => Until::$userId])->find();
+        if (empty($userInfo)) {
+            throw new ApiException('无此用户');
+        }
+        $otherData = [
+            'openId'   => $userInfo['open_id'],
+            'attach'   => 'storeId:'.$info['store_id'],
+            'money'    => $info['order_money'] * $info['num'] * 100,
+            'mark'     => '购买了'.$productInfo['product_name'] ?? '',
+            'orderId'  => $info['order_sn'],
+            'username' => $userInfo['name'],
+            'payCode'  => strtoupper($this->userName),
+        ];
+        $wxOrderInfo = $this->createOrderForOther($otherData);
+        $order = [
+            'nonceStr'  => $wxOrderInfo['nonceStr'],
+            'package'   => $wxOrderInfo['pack'],
+            'paySign'   => $wxOrderInfo['paySign'],
+            'timeStamp' => $wxOrderInfo['timeStamp'],
+            'signType'  => $wxOrderInfo['signType'],
+            'orderSn' => $info['order_sn'],
+            'orderId' => $orderId
+        ];
+        return $order;
+    }
+
 
     public function getPayToken() {
         $key = 'payToken' . $this->userName;
         $token = Cache::get($key);
+        $token = '';
         if (empty($token)) {
             $token = $this->getAuthPay();
             Cache::set($key, $token,'7100');

+ 1 - 1
application/common/until/Until.php

@@ -135,7 +135,7 @@ class Until {
                 //                'admin_id' => self::$adminId,
                 'url'    => Request::url(),
                 'token'  => Request::header('token'),
-                'input'  => file_get_contents("php://input"),
+                'input'  => file_get_contents("php://input") ?: json_encode(Request::input()),
                 'output' => json_encode($re),
                 'time'   => time() - self::$startTime
             ]);

+ 2 - 1
config/app.php

@@ -148,7 +148,8 @@ $config =  [
 
 ];
 if (GENV === 'test') {
-    $config['domain'] = 'https://vapi.hsayi.com/';
+//    $config['domain'] = 'https://vapi.hsayi.com/';
+    $config['domain'] = 'https://oapi.shpr.top/';
 }
 
 return $config;