瀏覽代碼

零售下单改成supplierId

shish 5 年之前
父節點
當前提交
963be7455f

+ 69 - 60
app/shop/controllers/PurchaseController.php

@@ -4,6 +4,7 @@ namespace shop\controllers;
 
 use biz\purchase\classes\PurchaseClass;
 use biz\purchase\services\PurchaseService;
+use bizGhs\merchant\classes\SupplierClass;
 use bizGhs\product\classes\ProductClass;
 use common\components\orderSn;
 use Yii;
@@ -11,65 +12,73 @@ use common\components\util;
 
 class PurchaseController extends BaseController
 {
+	
+	//生成采购单 shish 2021.1.17
+	public function actionCreateOrder()
+	{
+		$post = Yii::$app->request->post();
+		$supplierId = $post['supplierId'] ?? 0;
+		//供货商
+		$supplier = SupplierClass::getById($supplierId);
+		if (empty($supplier)) {
+			util::fail('没有找到供货商');
+		}
+		$upShopId = $supplier['upShopId'] ?? 0;
+		$upId = $supplier['upId'] ?? 0;
 
-    //生成采购单 shish 2021.1.17
-    public function actionCreateOrder()
-    {
-        $post = Yii::$app->request->post();
-        $upShopId = $post['upShopId'] ?? 0;
-        $post['shopId'] = $this->shopId;
-        $product = $post['product'] ?? '';
-        $productList = json_decode($product, true);
-        //判断product数据是不是同个供货商的
-        ProductClass::valid($productList, $upShopId);
-        $post['product'] = $productList;
-        $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();
-    }
-
-    //采购记录 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);
-    }
-
+		$post['shopId'] = $this->shopId;
+		$product = $post['product'] ?? '';
+		$productList = json_decode($product, true);
+		//判断product数据是不是同个供货商的
+		ProductClass::valid($productList, $upShopId);
+		$post['product'] = $productList;
+		$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();
+	}
+	
+	//采购记录 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);
+	}
+	
 }

+ 0 - 8
biz/purchase/classes/PurchaseClass.php

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

+ 18 - 9
biz/purchase/services/PurchaseService.php

@@ -8,14 +8,23 @@ use Yii;
 
 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');
+		$data['list'] = self::groupInfo($data['list']);
+		return $data;
+	}
 
-    public static $baseFile = '\biz\purchase\classes\PurchaseClass';
-
-    //采购记录 shish 2021.1.24
-    public static function getPurchaseList($where)
-    {
-        $data = PurchaseClass::getList('*', $where, 'addTime DESC');
-        return $data;
-    }
-
+	//组合信息 shish 2021.1.25
+	public static function groupInfo($list)
+	{
+		if (empty($list)) {
+			return $list;
+		}
+	}
+	
 }

+ 4 - 1
sql.sql

@@ -908,8 +908,11 @@ ALTER TABLE `xhPurchase` CHANGE `ghsId` `upId` INT(11) UNSIGNED NOT NULL DEFAULT
 ALTER TABLE `xhPurchase` CHANGE `ghsShopId` `upShopId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '供货商门店id,上游门店id';
 
 =====
-== linqh 2021.1.24
+== linqh 20210124
 ALTER TABLE `xhGhsProduct`
 MODIFY COLUMN `addTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `adminId`,
 MODIFY COLUMN `updateTime`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间' AFTER `addTime`;
 
+=====
+== shish 20210125
+ALTER TABLE `xhPurchase` ADD `supplierId` INT NOT NULL DEFAULT 0 COMMENT '供货商id' AFTER `shopId`;