Răsfoiți Sursa

采购与订单

shish 5 ani în urmă
părinte
comite
6aaeb974c5

+ 4 - 4
app/shop/controllers/PurchaseController.php

@@ -10,21 +10,21 @@ use common\components\util;
 
 class PurchaseController extends BaseController
 {
-
+	
 	//生成采购单 shish 2021.1.17
 	public function actionCreateOrder()
 	{
 		$post = Yii::$app->request->post();
 		$ghsShopId = $post['ghsShopId'] ?? 0;
-		$product = $post['product'] ?? '';
-		$arr = json_decode($product, true);
 		$shopId = $this->shopId;
 		$post['shopId'] = $shopId;
 		//判断product数据是不是同个供货商的
 		ProductClass::valid($ids, $ghsShopId);
+		$product = $post['product'] ?? '';
+		$arr = json_decode($product, true);
 		$post['product'] = $arr;
 		PurchaseClass::addPurchase($post);
 		util::complete();
 	}
-
+	
 }

+ 24 - 14
biz/purchase/classes/PurchaseClass.php

@@ -2,6 +2,7 @@
 
 namespace biz\purchase\classes;
 
+use common\components\orderSn;
 use common\components\stringUtil;
 use Yii;
 use biz\base\classes\BaseClass;
@@ -9,18 +10,27 @@ use biz\base\classes\BaseClass;
 class PurchaseClass extends BaseClass
 {
 
-    public static $baseFile = '\biz\purchase\models\Purchase';
-
-    //添加采购 shish 2021.1.18
-    public static function addPurchase($data)
-    {
-
-    }
-    
-    //生成订单号 shish 2021.1.19
-    public static function generateOrderNo()
-    {
-
-    }
-
+	public static $baseFile = '\biz\purchase\models\Purchase';
+
+	//添加采购 shish 2021.1.18
+	public static function addPurchase($data)
+	{
+		$orderSn = orderSn::getPurchaseSn();
+		$data['orderSn'] = $orderSn;
+		self::add($data);
+		if (isset($data['product']) && !empty($data['product'])) {
+			$productList = $data['product'];
+			foreach ($productList as $key => $product) {
+				$productList[$key]['orderSn'] = $orderSn;
+			}
+			PurchaseItemClass::batchAdd($productList);
+		}
+	}
+
+	//生成订单号 shish 2021.1.19
+	public static function generateOrderNo()
+	{
+	
+	}
+	
 }

+ 15 - 0
biz/purchase/classes/PurchaseItemClass.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace biz\purchase\classes;
+
+use common\components\orderSn;
+use common\components\stringUtil;
+use Yii;
+use biz\base\classes\BaseClass;
+
+class PurchaseItemClass extends BaseClass
+{
+
+	public static $baseFile = '\biz\purchase\models\PurchaseItem';
+
+}

+ 15 - 0
biz/purchase/models/PurchaseItem.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace biz\purchase\models;
+
+use biz\base\models\Base;
+
+class PurchaseItem extends Base
+{
+	
+	public static function tableName()
+	{
+		return 'xhPurchaseItem';
+	}
+	
+}

+ 13 - 0
biz/purchase/services/PurchaseItemService.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace biz\purchase\services;
+
+use biz\base\services\BaseService;
+use Yii;
+
+class PurchaseItemService extends BaseService
+{
+	
+	public static $baseFile = '\biz\purchase\classes\PurchaseItemClass';
+	
+}

+ 7 - 7
common/components/orderSn.php

@@ -15,9 +15,9 @@ class orderSn
 	//供货商订单号生成 shish 2021.1.19
 	public static function getGhsOrderSn()
 	{
-		$prefix = 'KD_CS_';
+		$prefix = 'XSD_CS';
 		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'KD';
+			$prefix = 'XSD';
 		}
 		$respond = OrderSnClass::add(['id' => null]);
 		$id = $respond['id'] ?? 0;
@@ -30,9 +30,9 @@ class orderSn
 	//零售商订单号生成 shish 2021.1.19
 	public static function getOrderSn()
 	{
-		$prefix = 'D_CS_';
+		$prefix = 'KD_CS';
 		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'D';
+			$prefix = 'KD';
 		}
 		$respond = \biz\order\classes\OrderSnClass::add(['id' => null]);
 		$id = $respond['id'] ?? 0;
@@ -45,7 +45,7 @@ class orderSn
 	//供货商采购单号 shish 2021.1.19
 	public static function getGhsPurchaseSn()
 	{
-		$prefix = 'PH_CS_';
+		$prefix = 'PH_CS';
 		if (getenv('YII_ENV', 'local') == 'production') {
 			$prefix = 'PH';
 		}
@@ -60,7 +60,7 @@ class orderSn
 	//供货商盘点单号 shish 2021.1.19
 	public static function getGhsCheckSn()
 	{
-		$prefix = 'PD_CS_';
+		$prefix = 'PD_CS';
 		if (getenv('YII_ENV', 'local') == 'production') {
 			$prefix = 'PD';
 		}
@@ -75,7 +75,7 @@ class orderSn
 	//零售商采购单号 shish 2021.1.19
 	public static function getPurchaseSn()
 	{
-		$prefix = 'CG_CS_';
+		$prefix = 'CG_CS';
 		if (getenv('YII_ENV', 'local') == 'production') {
 			$prefix = 'CG';
 		}

+ 3 - 1
sql.sql

@@ -692,4 +692,6 @@ id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
 DROP TABLE IF EXISTS `xhOrderSn`;
 CREATE TABLE IF NOT EXISTS  xhOrderSn(
 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
-)AUTO_INCREMENT=26315618 COMMENT='零售商订单号';
+)AUTO_INCREMENT=26315618 COMMENT='零售商订单号';
+ALTER TABLE `xhPurchase` ADD orderSn CHAR(40) NOT NULL DEFAULT '' COMMENT '订单号' AFTER `id`;
+ALTER TABLE `xhPurchaseItem` DROP COLUMN `orderId`;