shish 5 жил өмнө
parent
commit
bc6f303547

+ 34 - 3
app/shop/controllers/PurchaseController.php

@@ -15,15 +15,46 @@ class PurchaseController extends BaseController
     public function actionCreateOrder()
     {
         $post = Yii::$app->request->post();
-        $ghsShopId = $post['shopId'] ?? 0;
+        $ghsShopId = $post['ghsShopId'] ?? 0;
         $post['shopId'] = $this->shopId;
         $product = $post['product'] ?? '';
         $productList = json_decode($product, true);
         //判断product数据是不是同个供货商的
         ProductClass::valid($productList, $ghsShopId);
-
         $post['product'] = $productList;
-        PurchaseClass::addPurchase($post);
+        $respond = PurchaseClass::addPurchase($post);
+        $orderSn = $respond['orderSn'] ?? '';
+        $actPrice = $respond['actPrice'] ?? '';
+        $data = [
+            'orderSn' => $orderSn,
+            'actPrice' => $actPrice,
+            'hasBalancePay' => 1,
+            'hasPayPassword' => 0,
+            'hasDebtPay' => 1,
+        ];
+        util::success($data);
+    }
+
+    //延期支付 shish 2021.1.24
+    public function actionDebtPay()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $info = PurchaseClass::getInfo($id);
+        PurchaseClass::valid($info, $this->shopId);
+        PurchaseClass::debt($info);
+        util::complete();
+    }
+
+    //余额支付 shish 2021.1.24
+    public function actionBalancePay()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $password = $get['password'] ?? '';
+        $info = PurchaseClass::getInfo($id);
+        PurchaseClass::valid($info, $this->shopId);
+        purchaseClass::balancePay($info);
         util::complete();
     }
 

+ 36 - 2
biz/purchase/classes/PurchaseClass.php

@@ -15,12 +15,20 @@ class PurchaseClass extends BaseClass
 
     public static $baseFile = '\biz\purchase\models\Purchase';
 
+    //订单状态 1待付款,待确认,2待配送,3配送中,4已完成
+    const STATUS_UN_PAY = 1;
+    const STATUS_UN_SEND = 2;
+    const STATUS_SENDING = 3;
+    const STATUS_COMPLETE = 4;
+
     //添加采购 shish 2021.1.18
     public static function addPurchase($data)
     {
         $orderSn = orderSn::getPurchaseSn();
         $data['orderSn'] = $orderSn;
-        self::add($data);
+        $data['prePrice'] = 0.01;
+        $data['actPrice'] = 0.01;
+        $respond = self::add($data);
         if (isset($data['product']) == false || empty($data['product'])) {
             util::fail('请选择花材');
         }
@@ -34,16 +42,42 @@ class PurchaseClass extends BaseClass
         $ghsShopId = $data['ghsShopId'] ?? 0;
         $ghsShop = \bizGhs\merchant\classes\ShopClass::getById($ghsShopId);
         $ghsId = $ghsShop['merchantId'] ?? 0;
+        if (empty($ghsId)) {
+            util::fail('没有找到供货商');
+        }
 
+        //供货商增加订单
         $orderData = [
             'prePrice' => 0.01,
             'actPrice' => 0.01,
             'num' => 1,
             'smallNum' => 3,
-            'product' => $productList
+            'product' => $productList,
+            'merchantId' => $ghsId,
         ];
         \bizGhs\order\classes\OrderClass::addOrder($orderData);
 
+        return $respond;
+    }
+
+    //获取采购单信息 shish 2021.1.24
+    public static function getInfo($id)
+    {
+        return self::getById($id);
+    }
+
+    //订单延期支付 shish 2021.1.24
+    public static function debt($info)
+    {
+        if (isset($info['status']) == false || $info['status'] != self::STATUS_UN_PAY) {
+            util::fail('请确认订单状态');
+        }
+    }
+
+    //余额支付 shish 2021.1.24
+    public static function balancePay($info)
+    {
+
     }
 
 }

+ 2 - 1
sql.sql

@@ -897,4 +897,5 @@ ADD COLUMN `outTime`  timestamp NULL DEFAULT NULL COMMENT '出库时间' AFTER `
 == shish 2021-1-24
 ALTER TABLE `xhGhsOrderSend` MODIFY `finishTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '完成时间';
 ALTER TABLE xhGhsOrderSend ADD `status` TINYINT NOT NULL DEFAULT 0 COMMENT '0待完成 1已完成' AFTER `finishTime`;
-ALTER TABLE `xhGhsOrderSend` ADD actionName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '动作名称' AFTER `actionId`;
+ALTER TABLE `xhGhsOrderSend` ADD actionName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '动作名称' AFTER `actionId`;
+ALTER TABLE `xhAdmin` ADD payPassword VARCHAR(500) NOT NULL DEFAULT '' COMMENT '支付密码' AFTER `confirmPassword`;