shish 1 vuosi sitten
vanhempi
commit
a097cd8df6

+ 25 - 1
app-mall/controllers/OrderController.php

@@ -380,7 +380,31 @@ class OrderController extends BaseController
     {
         $post = Yii::$app->request->post();
         $orderSn = $post['orderSn'] ?? '';
-        
+        //避免重复提交
+        util::checkRepeatCommit($orderSn, 10);
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
+            if (empty($order)) {
+                util::fail('没有找到订单');
+            }
+            if ($order->shopId != $this->shopId) {
+                util::fail('不是你的订单');
+            }
+            $payWay = dict::getDict('payWay', 'balancePay');
+            $date = date("Y-m-d H:i:s");
+            $order->payTime = $date;
+            $order->payWay = $payWay;
+            $order->save();
+            \bizHd\order\classes\OrderClass::payAfter($order, $payWay);
+            $transaction->commit();
+            util::complete('支付成功');
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::error("支付原因:" . $e->getMessage());
+            util::fail('支付失败');
+        }
     }
 
     //获取商城下单要用的微信支付和小程序支付参数 ssh 2019.21.3

+ 2 - 2
biz-hd/order/classes/OrderClass.php

@@ -255,7 +255,7 @@ class OrderClass extends BaseClass
         if (empty($order)) {
             util::fail('没有找到订单');
         }
-        if (isset($order->status) == false) {
+        if (!isset($order->status)) {
             util::fail('没有找到订单的状态');
         }
         $orderSn = $order->orderSn ?? '';
@@ -339,7 +339,7 @@ class OrderClass extends BaseClass
         }
 
         //客户使用余额付款
-        if ($order->hasPay == 4) {
+        if ($payWay == dict::getDict('payWay', 'balancePay')) {
 
         }
 

+ 18 - 12
biz-hd/order/services/OrderService.php

@@ -29,7 +29,7 @@ class OrderService extends BaseService
 
     public static function createFinishOrder($data, $custom, $hasPay = 1)
     {
-        $payWay = $data['payWay'] ?? dict::getDict('payWay', 'wxPay');
+        $payWay = $data['payWay'] ?? 0;
         $orderSn = orderSn::getOrderSn();
         $customId = $custom['id'] ?? 0;
         $hdId = $custom['hdId'] ?? 0;
@@ -163,28 +163,29 @@ class OrderService extends BaseService
                 $groupGoodsData[] = ['goodsId' => $currentId, 'num' => $num, 'name' => $name, 'unitPrice' => $unitPrice];
             }
             if ($property == dict::getDict('property', 'item')) {
-                $name = $itemInfo[$currentId]['name'] ?? '';
-                $cover = $itemInfo[$currentId]['cover'] ?? '';
+                $currentInfo = $itemInfo[$currentId] ?? [];
+                $name = $currentInfo['name'] ?? '';
+                $cover = $currentInfo['cover'] ?? '';
                 if (!empty($groupCover)) {
                     $groupCover = $cover;
                 }
-                $ratio = $itemInfo[$currentId]['ratio'] ?? 20;
-                $currentMainId = $itemInfo[$currentId]['mainId'] ?? 0;
+                $ratio = $currentInfo['ratio'] ?? 20;
+                $currentMainId = $currentInfo['mainId'] ?? 0;
                 if ($currentMainId != $mainId) {
                     util::fail('不是您的花材' . $mainId . ' ' . $currentMainId);
                 }
                 if ($unitType == dict::getDict('unitType', 'big')) {
-                    $unitName = $itemInfo[$currentId]['bigUnit'] ?? '';
-                    $unitId = $itemInfo[$currentId]['bigUnitId'] ?? 0;
+                    $unitName = $currentInfo['bigUnit'] ?? '';
+                    $unitId = $currentInfo['bigUnitId'] ?? 0;
                     $totalNum = $num;
                 } else {
-                    $unitName = $itemInfo[$currentId]['smallUnit'] ?? '';
-                    $unitId = $itemInfo[$currentId]['smallUnitId'] ?? 0;
+                    $unitName = $currentInfo['smallUnit'] ?? '';
+                    $unitId = $currentInfo['smallUnitId'] ?? 0;
                     $totalNum = bcdiv($num, $ratio, 2);
                 }
-                $ptItemId = $itemInfo[$currentId]['itemId'] ?? 0;
-                $classId = $itemInfo[$currentId]['classId'] ?? 0;
-                $belongCost = $itemInfo[$currentId]['belongCost'] ?? 0;
+                $ptItemId = $currentInfo['itemId'] ?? 0;
+                $classId = $currentInfo['classId'] ?? 0;
+                $belongCost = $currentInfo['belongCost'] ?? 0;
                 $currentItemData = [
                     'name' => $name,
                     'cover' => $cover,
@@ -304,6 +305,11 @@ class OrderService extends BaseService
             }
         }
 
+        //hasPay balance 转化成余额支付方式
+        if ($hasPay == dict::getDict('hasPay', 'balance')) {
+            $payWay = dict::getDict('payWay', 'balancePay');
+        }
+
         $data['actPrice'] = $modifyPrice;
         $data['realPrice'] = $modifyPrice;
         $data['customId'] = $customId;