shish 3 rokov pred
rodič
commit
cdf71c6055
1 zmenil súbory, kde vykonal 19 pridanie a 3 odobranie
  1. 19 3
      app-hd/controllers/PurchaseController.php

+ 19 - 3
app-hd/controllers/PurchaseController.php

@@ -22,6 +22,7 @@ use common\components\noticeUtil;
 use Yii;
 use common\components\util;
 use biz\wx\classes\WxMessageClass;
+use bizGhs\order\services\OrderService;
 
 class PurchaseController extends BaseController
 {
@@ -33,6 +34,8 @@ class PurchaseController extends BaseController
     {
         $post = Yii::$app->request->post();
         $ghsId = $post['ghsId'] ?? 0;
+        $payMode = $post['payMode'] ?? 0;
+        $payWay = $post['payWay'] ?? 0;
         $ghsInfo = GhsClass::getById($ghsId);
         if (empty($ghsInfo)) {
             util::fail('没有找到供货商');
@@ -41,7 +44,7 @@ class PurchaseController extends BaseController
             util::fail('这个是你自己的批发店');
         }
 
-        $connection = Yii::$app->db;//事务处理
+        $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
             $post['book'] = $post['book'] ?? 0;
@@ -80,11 +83,24 @@ class PurchaseController extends BaseController
             $ghsInfo['kiloFee'] = 0;
             $ghsInfo['miniKilo'] = 0;
             $post['product'] = $productList;
-            $sendCost = 0;
-            $post['sendCost'] = $sendCost;
             $packCost = 0;
             $post['packCost'] = $packCost;
             $respond = PurchaseService::createPurchase($post, $ghsInfo);
+
+            if ($payMode == 0) {
+                //欠款
+                PurchaseService::debt($respond);
+            } else {
+                //线下支付
+                PurchaseService::payAfter($respond, $payWay);
+                $saleId = $respond->saleId ?? 0;
+                $order = OrderClass::getById($saleId, true);
+                if (empty($order)) {
+                    util::fail('没有找到订单');
+                }
+                OrderService::payAfter($order, $payWay, true);
+            }
+
             $transaction->commit();
             util::success($respond);
         } catch (Exception $e) {