shish 5 lat temu
rodzic
commit
4526b24416

+ 16 - 2
app/shop/controllers/PurchaseController.php

@@ -3,6 +3,7 @@
 namespace shop\controllers;
 
 use biz\purchase\classes\PurchaseClass;
+use biz\purchase\services\PurchaseService;
 use bizGhs\product\classes\ProductClass;
 use common\components\orderSn;
 use Yii;
@@ -15,12 +16,12 @@ class PurchaseController extends BaseController
     public function actionCreateOrder()
     {
         $post = Yii::$app->request->post();
-        $ghsShopId = $post['ghsShopId'] ?? 0;
+        $upShopId = $post['upShopId'] ?? 0;
         $post['shopId'] = $this->shopId;
         $product = $post['product'] ?? '';
         $productList = json_decode($product, true);
         //判断product数据是不是同个供货商的
-        ProductClass::valid($productList, $ghsShopId);
+        ProductClass::valid($productList, $upShopId);
         $post['product'] = $productList;
         $respond = PurchaseClass::addPurchase($post);
         $orderSn = $respond['orderSn'] ?? '';
@@ -58,4 +59,17 @@ class PurchaseController extends BaseController
         util::complete();
     }
 
+    //采购记录 shish 2021.1.24
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $where = ['merchantId' => $this->merchantId];
+        $status = $get['status'] ?? 0;
+        if (!empty($status)) {
+            $where['status'] = $status;
+        }
+        $list = PurchaseService::getPurchaseList($where);
+        util::success($list);
+    }
+
 }

+ 3 - 3
biz/purchase/classes/PurchaseClass.php

@@ -39,9 +39,9 @@ class PurchaseClass extends BaseClass
         PurchaseItemClass::batchAdd($productList);
 
         //供货商增加订单
-        $ghsShopId = $data['ghsShopId'] ?? 0;
-        $ghsShop = \bizGhs\merchant\classes\ShopClass::getById($ghsShopId);
-        $ghsId = $ghsShop['merchantId'] ?? 0;
+        $upShopId = $data['upShopId'] ?? 0;
+        $upShop = \bizGhs\merchant\classes\ShopClass::getById($upShopId);
+        $ghsId = $upShop['merchantId'] ?? 0;
         if (empty($ghsId)) {
             util::fail('没有找到供货商');
         }

+ 8 - 0
biz/purchase/services/PurchaseService.php

@@ -3,6 +3,7 @@
 namespace biz\purchase\services;
 
 use biz\base\services\BaseService;
+use biz\purchase\classes\PurchaseClass;
 use Yii;
 
 class PurchaseService extends BaseService
@@ -10,4 +11,11 @@ class PurchaseService extends BaseService
 
     public static $baseFile = '\biz\purchase\classes\PurchaseClass';
 
+    //采购记录 shish 2021.1.24
+    public static function getPurchaseList($where)
+    {
+        $data = PurchaseClass::getList('*', $where, 'addTime DESC');
+        return $data;
+    }
+
 }

+ 4 - 1
sql.sql

@@ -902,4 +902,7 @@ ALTER TABLE `xhAdmin` ADD payPassword VARCHAR(500) NOT NULL DEFAULT '' COMMENT '
 ALTER TABLE `xhSupplier` DROP COLUMN `addTime`;
 ALTER TABLE `xhSupplier` DROP COLUMN `updateTime`;
 ALTER TABLE `xhSupplier` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `merchantId`;
-ALTER TABLE `xhSupplier` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;
+ALTER TABLE `xhSupplier` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;
+ALTER TABLE xhPurchase ADD merchantId INT NOT NULL DEFAULT 0 COMMENT '商家id' AFTER `shopId`;
+ALTER TABLE `xhPurchase` CHANGE `ghsId` `upId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '供货商id,上游id';
+ALTER TABLE `xhPurchase` CHANGE `ghsShopId` `upShopId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '供货商门店id,上游门店id';