瀏覽代碼

充值销账

shish 1 年之前
父節點
當前提交
75f4b14b90
共有 1 個文件被更改,包括 18 次插入27 次删除
  1. 18 27
      app-hd/controllers/SettleController.php

+ 18 - 27
app-hd/controllers/SettleController.php

@@ -27,7 +27,10 @@ class SettleController extends BaseController
 
             $staff = $this->shopAdmin;
             $payWay = $post['payWay'] ?? dict::getDict('payWay', 'wxPay');
-            $id = $post['id'] ?? '';
+            $idData = $post['id'] ?? '';
+            if (is_numeric($idData)) {
+                util::fail('请求参数错误');
+            }
             $customId = $post['customId'] ?? 0;
             $custom = CustomClass::getLockById($customId);
             if (empty($custom)) {
@@ -69,6 +72,7 @@ class SettleController extends BaseController
                 'orderSn' => $orderSn,
                 'modPrice' => 1,
                 'payWay' => $payWay,
+                'style' => 1,
                 'shopId' => $shopId,
                 'mainId' => $mainId,
                 'hdId' => $hdId,
@@ -87,38 +91,25 @@ class SettleController extends BaseController
             $respond = RechargeClass::addRecharge($rechargeData);
             $retId = $respond->id;
             $recharge = RechargeClass::getLockById($retId);
-            $params = [
-                'onlinePay' => 1,
-                'side' => 0,
-            ];
+            $params = ['onlinePay' => 1, 'side' => 0];
             RechargeClass::complete($recharge, $payWay, $params);
 
             //2、再销账
-            if (is_numeric($id)) {
-                $order = OrderClass::getById($id, true);
-                if (empty($order)) {
-                    util::fail('没有找到订单哦');
-                }
-                if ($order->mainId != $this->mainId) {
-                    util::fail('不是你的订单');
-                }
-                SettleClass::confirmSettle($order, $payWay, $staff);
-            } else {
-                $idArr = json_decode($id, true);
-                $ids = array_column($idArr, 'id');
-                $orderList = OrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
-                if (!empty($orderList)) {
-                    foreach ($orderList as $order) {
-                        if (empty($order)) {
-                            util::fail('没有找到订单呢');
-                        }
-                        if ($order->mainId != $this->mainId) {
-                            util::fail('不是你的订单');
-                        }
-                        SettleClass::confirmSettle($order, $payWay, $staff);
+            $idArr = json_decode($idData, true);
+            $ids = array_column($idArr, 'id');
+            $orderList = OrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
+            if (!empty($orderList)) {
+                foreach ($orderList as $order) {
+                    if (empty($order)) {
+                        util::fail('没有找到订单呢');
+                    }
+                    if ($order->mainId != $this->mainId) {
+                        util::fail('不是你的订单');
                     }
+                    SettleClass::confirmSettle($order, $payWay, $staff);
                 }
             }
+
             $transaction->commit();
             util::complete();
         } catch (\Exception $exception) {