瀏覽代碼

供货商关系链 与 表名变更

shish 5 年之前
父節點
當前提交
0e3513ac0b

+ 5 - 5
app-ghs/controllers/SupplierController.php → app-ghs/controllers/GhsController.php

@@ -2,13 +2,12 @@
 
 namespace ghs\controllers;
 
-use bizGhs\merchant\classes\SupplierClass;
-use bizGhs\merchant\services\SupplierService;
+use biz\ghs\classes\GhsClass;
 use common\components\stringUtil;
 use Yii;
 use common\components\util;
 
-class SupplierController extends BaseController
+class GhsController extends BaseController
 {
 
     //供货商列表 shish 2021.1.18
@@ -16,7 +15,7 @@ class SupplierController extends BaseController
     {
         $get = Yii::$app->request->get();
         $name = isset($get['name']) ? $get['name'] : '';
-        $where = ['merchantId' => $this->sjId];
+        $where = ['sjId' => $this->sjId];
         if (!empty($name)) {
             if (stringUtil::isLetter($name)) {
                 $where['py'] = ['like', $name];
@@ -24,7 +23,8 @@ class SupplierController extends BaseController
                 $where['name'] = ['like', $name];
             }
         }
-        $list = SupplierService::getSupplierList($where);
+
+        $list = GhsClass::getSupplierList($where);
         util::success($list);
     }
 

+ 7 - 7
app-hd/controllers/PurchaseController.php

@@ -2,9 +2,9 @@
 
 namespace hd\controllers;
 
+use biz\ghs\classes\GhsClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\services\PurchaseService;
-use bizGhs\merchant\classes\SupplierClass;
 use bizGhs\product\classes\ProductClass;
 use Yii;
 use common\components\util;
@@ -18,20 +18,20 @@ class PurchaseController extends BaseController
 		$post = Yii::$app->request->post();
 		$supplierId = $post['supplierId'] ?? 0;
 		//供货商
-		$supplier = SupplierClass::getById($supplierId);
+		$supplier = GhsClass::getById($supplierId);
 		if (empty($supplier)) {
 			util::fail('没有找到供货商');
 		}
-		$upShopId = $supplier['upShopId'] ?? 0;
-		$upId = $supplier['upId'] ?? 0;
-		$post['upShopId'] = $upShopId;
-		$post['upId'] = $upId;
+		$ghsShopId = $supplier['ghsShopId'] ?? 0;
+		$ghsSjId = $supplier['ghsSjId'] ?? 0;
+		$post['ghsShopId'] = $ghsShopId;
+		$post['ghsSjId'] = $ghsSjId;
 		
 		$post['shopId'] = $this->shopId;
 		$product = $post['product'] ?? '';
 		$productList = json_decode($product, true);
 		//判断product数据是不是同个供货商的
-		ProductClass::valid($productList, $upShopId);
+		ProductClass::valid($productList, $ghsShopId);
 		$post['product'] = $productList;
 		$respond = PurchaseClass::addPurchase($post);
 		$orderSn = $respond['orderSn'] ?? '';

+ 24 - 27
app-hd/controllers/SupplierController.php

@@ -2,36 +2,33 @@
 
 namespace hd\controllers;
 
-use bizHd\merchant\services\ShopService;
-use bizGhs\merchant\services\SupplierService;
-use common\components\dirUtil;
+use biz\ghs\classes\GhsClass;
 use common\components\util;
-use common\components\wxUtil;
 use Yii;
 
 class SupplierController extends BaseController
 {
-	
-	//供货商列表 shish 2021.1.24
-	public function actionList()
-	{
-		$where = [];
-		$where['merchantId'] = $this->sjId;
-		$respond = SupplierService::getSupplierList($where);
-		util::success($respond);
-	}
-	
-	//待结款供货商列表 shish 2021.1.26
-	public function actionDebtList()
-	{
-		$get = Yii::$app->request->get();
-		$where = ['merchantId' => $this->sjId];
-		$status = $get['status'] ?? 0;
-		if (!empty($status)) {
-			$where['status'] = $status;
-		}
-		$list = SupplierService::getDebtList($where);
-		util::success($list);
-	}
-	
+
+    //供货商列表 shish 2021.1.24
+    public function actionList()
+    {
+        $where = [];
+        $where['sjId'] = $this->sjId;
+        $respond = GhsClass::getSupplierList($where);
+        util::success($respond);
+    }
+
+    //待结款供货商列表 shish 2021.1.26
+    public function actionDebtList()
+    {
+        $get = Yii::$app->request->get();
+        $where = ['merchantId' => $this->sjId];
+        $status = $get['status'] ?? 0;
+        if (!empty($status)) {
+            $where['status'] = $status;
+        }
+        $list = GhsClass::getDebtList($where);
+        util::success($list);
+    }
+
 }

+ 2 - 1
biz-ghs/admin/classes/AdminClass.php

@@ -80,7 +80,8 @@ class AdminClass extends BaseClass
                 $adminData = [
                     'password' => password_hash($mobile, PASSWORD_BCRYPT),
                     'confirmPassword' => password_hash($mobile, PASSWORD_BCRYPT),
-                    'mobile' => $mobile
+                    'mobile' => $mobile,
+                    'currentShopId'=>$shopId,
                 ];
                 self::updateById($adminId, $adminData);
                 $shopData = [

+ 0 - 50
biz-ghs/merchant/classes/SupplierClass.php

@@ -1,50 +0,0 @@
-<?php
-
-namespace bizGhs\merchant\classes;
-
-use common\components\business;
-use common\components\imgUtil;
-use Yii;
-use bizGhs\base\classes\BaseClass;
-
-class SupplierClass extends BaseClass
-{
-	
-	public static $baseFile = '\bizGhs\merchant\models\Supplier';
-	
-	//根据xhSupplier的id数组 取供货商信息 shish 2021.1.18
-	public static function getSupplierByIds($ids)
-	{
-		$list = self::getByIds($ids, null, 'id');
-		if (empty($list)) {
-			return [];
-		}
-		$list = self::groupBaseInfo($list);
-		return $list;
-	}
-	
-	public static function groupBaseInfo($list)
-	{
-		if (empty($list)) {
-			return $list;
-		}
-		foreach ($list as $key => $val) {
-			//头像大图
-			$list[$key]['logoUrl'] = imgUtil::getPrefix() . '/hhb_small.png';
-			//头像小图
-			$list[$key]['smallLogoUrl'] = imgUtil::getPrefix() . '/hhb_small.png';
-			$list[$key]['mobile'] = 15280215347;
-			$list[$key]['address'] = '厦门市集美区印斗北路与乐海路交叉路口西北侧';
-		}
-		return $list;
-	}
-	
-	//根据供货商信息 shish 2021.1.18
-	public static function getSupplierInfo($id)
-	{
-		$info = self::getById($id);
-		$list = self::groupBaseInfo([$info]);
-		return current($list);
-	}
-	
-}

+ 0 - 15
biz-ghs/merchant/models/Supplier.php

@@ -1,15 +0,0 @@
-<?php
-
-namespace bizGhs\merchant\models;
-
-use bizGhs\base\models\Base;
-
-class Supplier extends Base
-{
-	
-	public static function tableName()
-	{
-		return 'xhSupplier';
-	}
-	
-}

+ 0 - 39
biz-ghs/merchant/services/SupplierService.php

@@ -1,39 +0,0 @@
-<?php
-
-namespace bizGhs\merchant\services;
-
-use bizGhs\base\services\BaseService;
-use bizGhs\merchant\classes\MerchantAssetClass;
-use bizGhs\merchant\classes\SupplierClass;
-use common\components\util;
-use Yii;
-
-class SupplierService extends BaseService
-{
-
-	public static $baseFile = '\bizGhs\merchant\classes\SupplierClass';
-
-	//供货商列表 shish 2021.1.24
-	public static function getSupplierList($where)
-	{
-		$data = SupplierClass::getList('*', $where, 'addTime DESC');
-		$data['list'] = SupplierClass::groupBaseInfo($data['list']);
-		return $data;
-	}
-
-	//待结款列表 shish 2021.126
-	public static function getDebtList($where)
-	{
-		$merchantId = $where['merchantId'] ?? 0;
-		if (empty($merchantId)) {
-			util::fail('没有找到商家');
-		}
-		$data = SupplierClass::getList('*', $where, 'debtAmount DESC');
-		$data['list'] = SupplierClass::groupBaseInfo($data['list']);
-		$asset = MerchantAssetClass::getByMerchantId($merchantId);
-		$data['debtAmount'] = $asset['cgDebtAmount'] ?? 0.00;
-		$data['debtNum'] = $asset['cgDebtNum'] ?? 0;
-		return $data;
-	}
-
-}

+ 2 - 3
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -2,10 +2,9 @@
 
 namespace bizGhs\order\classes;
 
-use bizGhs\admin\classes\AdminClass;
+use biz\ghs\classes\GhsClass;
 use bizGhs\base\classes\BaseClass;
 use bizGhs\item\classes\ItemClass;
-use bizGhs\merchant\classes\SupplierClass;
 use bizGhs\order\traits\OrderTrait;
 use bizGhs\stock\services\StockRecordService;
 use bizGhs\product\classes\ProductClass;
@@ -181,7 +180,7 @@ class PurchaseOrderClass extends BaseClass
 
 		//供货商信息
         $supplierId = $orderData['supplierId'] ?? 0;
-        $supplierInfo = SupplierClass::getSupplierInfo($supplierId);
+        $supplierInfo = GhsClass::getSupplierInfo($supplierId);
         $orderData['supplierName'] = $supplierInfo['name'] ?? '';
         $orderData['supplierMobile'] = $supplierInfo['mobile'] ?? '';
 	    $orderData['supplierAddress'] = $supplierInfo['address'] ?? '';

+ 2 - 4
biz-ghs/order/traits/OrderTrait.php

@@ -6,11 +6,9 @@
 
 namespace bizGhs\order\traits;
 
-
+use biz\ghs\classes\GhsClass;
 use bizGhs\admin\classes\AdminClass;
-use bizGhs\merchant\classes\SupplierClass;
 use bizGhs\product\classes\ProductClass;
-use common\services\xhItemService;
 
 trait OrderTrait
 {
@@ -50,7 +48,7 @@ trait OrderTrait
 			return $list;
 		}
 		$supplierIds = array_unique(array_filter(array_column($list, 'supplierId')));
-		$supplierInfo = SupplierClass::getSupplierByIds($supplierIds);
+		$supplierInfo = GhsClass::getSupplierByIds($supplierIds);
 
 		foreach ($list as $k => $val) {
 			$supplierId = $val['supplierId'] ?? 0;

+ 13 - 15
biz-hd/purchase/classes/PurchaseClass.php

@@ -2,11 +2,9 @@
 
 namespace bizHd\purchase\classes;
 
-use bizHd\merchant\classes\ShopClass;
-use bizHd\order\classes\OrderClass;
+use biz\ghs\classes\GhsClass;
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\custom\classes\CustomClass;
-use bizGhs\merchant\classes\SupplierClass;
 use biz\sj\classes\MerchantClass;
 use common\components\orderSn;
 use common\components\stringUtil;
@@ -50,14 +48,14 @@ class PurchaseClass extends BaseClass
         PurchaseItemClass::batchAdd($productList);
 
         //供货商增加订单
-        $upId = $data['upId'] ?? 0;
+        $ghsSjId = $data['ghsSjId'] ?? 0;
         $orderData = [
             'prePrice' => 0.01,
             'actPrice' => 0.01,
             'num' => 1,
             'smallNum' => 3,
             'product' => $productList,
-            'merchantId' => $upId,
+            'merchantId' => $ghsSjId,
         ];
         \bizGhs\order\classes\OrderClass::addOrder($orderData);
 
@@ -78,7 +76,7 @@ class PurchaseClass extends BaseClass
     {
 
         $supplierIds = array_unique(array_filter(array_column($list, 'supplierId')));
-        $supplierInfo = SupplierClass::getSupplierByIds($supplierIds);
+        $supplierInfo = GhsClass::getSupplierByIds($supplierIds);
 
         $adminIds = array_unique(array_filter(array_column($list, 'adminId')));
         $adminInfo = AdminClass::getAdminByIds($adminIds, null, 'id');
@@ -147,35 +145,35 @@ class PurchaseClass extends BaseClass
         if (empty($supplierId)) {
 
             //补充供货商关系
-            $upId = $purchase->upId;
-            $supplierSj = MerchantClass::getMerchantById($upId);
+            $ghsSjId = $purchase->ghsSjId;
+            $supplierSj = MerchantClass::getMerchantById($ghsSjId);
             $upName = $supplierSj['merchantName'] ?? '';
-            $upShopId = $purchase->upShopId;
+            $ghsShopId = $purchase->ghsShopId;
             $shopId = $purchase->shopId;
             $merchantId = $purchase->merchantId;
             $py = !empty($upName) ? stringUtil::getSpelling($upName) : '';
-            $has = SupplierClass::getByCondition(['merchantId' => $merchantId, 'upId' => $upId, 'upShopId' => $upShopId]);
+            $has = GhsClass::getByCondition(['merchantId' => $merchantId, 'ghsSjId' => $ghsSjId, 'ghsShopId' => $ghsShopId]);
             if (empty($has)) {
                 $supplierData = [
-                    'upId' => $upId,
+                    'ghsSjId' => $ghsSjId,
                     'name' => $upName,
                     'py' => $py,
-                    'upShopId' => $upShopId,
+                    'ghsShopId' => $ghsShopId,
                     'merchantId' => $merchantId,
                 ];
-                SupplierClass::add($supplierData);
+                GhsClass::add($supplierData);
             }
 
             //补充客户关系
             $customSj = MerchantClass::getMerchantById($merchantId);
             $customSjName = $customSj['merchantName'] ?? '';
             $py = !empty($customSjName) ? stringUtil::getSpelling($customSjName) : '';
-            $has = CustomClass::getByCondition(['sjId' => $upId, 'customSjId' => $merchantId, 'customShopId' => $shopId]);
+            $has = CustomClass::getByCondition(['sjId' => $ghsSjId, 'customSjId' => $merchantId, 'customShopId' => $shopId]);
             if (empty($has)) {
                 $customData = [
                     'customSjId' => $merchantId,
                     'customShopId' => $shopId,
-                    'sjId' => $upId,
+                    'sjId' => $ghsSjId,
                     'name' => $customSjName,
                     'mobile' => 0,
                     'isOpen' => 0,

+ 0 - 8
biz-hd/purchase/classes/PurchaseClearClass.php

@@ -2,14 +2,6 @@
 
 namespace bizHd\purchase\classes;
 
-use bizHd\merchant\classes\ShopClass;
-use bizHd\order\classes\OrderClass;
-use bizGhs\admin\classes\AdminClass;
-use bizGhs\merchant\classes\SupplierClass;
-use common\components\orderSn;
-use common\components\stringUtil;
-use common\components\util;
-use Yii;
 use bizHd\base\classes\BaseClass;
 
 class PurchaseClearClass extends BaseClass

+ 0 - 4
biz-hd/purchase/services/PurchaseClearService.php

@@ -3,10 +3,6 @@
 namespace bizHd\purchase\services;
 
 use bizHd\base\services\BaseService;
-use bizHd\purchase\classes\PurchaseClass;
-use bizGhs\admin\classes\AdminClass;
-use bizGhs\merchant\classes\SupplierClass;
-use Yii;
 
 class PurchaseClearService extends BaseService
 {

+ 3 - 3
biz-hd/purchase/services/PurchaseService.php

@@ -2,10 +2,10 @@
 
 namespace bizHd\purchase\services;
 
+use biz\ghs\classes\GhsClass;
 use bizHd\base\services\BaseService;
 use bizHd\purchase\classes\PurchaseClass;
 use bizGhs\admin\classes\AdminClass;
-use bizGhs\merchant\classes\SupplierClass;
 use common\components\imgUtil;
 use Yii;
 
@@ -36,8 +36,8 @@ class PurchaseService extends BaseService
 		}
 		
 		$supplierIds = array_unique(array_filter(array_column($list, 'supplierId')));
-		$supplierInfo = SupplierClass::getSupplierByIds($supplierIds);
-		
+		$supplierInfo = GhsClass::getSupplierByIds($supplierIds);
+
 		$adminIds = array_unique(array_filter(array_column($list, 'adminId')));
 		$adminInfo = AdminClass::getAdminByIds($adminIds);
 		

+ 73 - 0
biz/ghs/classses/GhsClass.php

@@ -0,0 +1,73 @@
+<?php
+
+namespace biz\ghs\classes;
+
+use biz\sj\classes\MerchantAssetClass;
+use common\components\imgUtil;
+use common\components\util;
+use biz\base\classes\BaseClass;
+
+class GhsClass extends BaseClass
+{
+
+    public static $baseFile = '\biz\ghs\models\Ghs';
+
+    //供货商列表 shish 2021.1.24
+    public static function getSupplierList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC');
+        $data['list'] = self::groupBaseInfo($data['list']);
+        return $data;
+    }
+
+    //根据xhSupplier的id数组 取供货商信息 shish 2021.1.18
+    public static function getSupplierByIds($ids)
+    {
+        $list = self::getByIds($ids, null, 'id');
+        if (empty($list)) {
+            return [];
+        }
+        $list = self::groupBaseInfo($list);
+        return $list;
+    }
+
+    public static function groupBaseInfo($list)
+    {
+        if (empty($list)) {
+            return $list;
+        }
+        foreach ($list as $key => $val) {
+            //头像大图
+            $list[$key]['logoUrl'] = imgUtil::getPrefix() . '/hhb_small.png';
+            //头像小图
+            $list[$key]['smallLogoUrl'] = imgUtil::getPrefix() . '/hhb_small.png';
+            $list[$key]['mobile'] = 15280215347;
+            $list[$key]['address'] = '厦门市集美区印斗北路与乐海路交叉路口西北侧';
+        }
+        return $list;
+    }
+
+    //根据供货商信息 shish 2021.1.18
+    public static function getSupplierInfo($id)
+    {
+        $info = self::getById($id);
+        $list = self::groupBaseInfo([$info]);
+        return current($list);
+    }
+
+    //待结款列表 shish 2021.126
+    public static function getDebtList($where)
+    {
+        $sjId = $where['sjId'] ?? 0;
+        if (empty($sjId)) {
+            util::fail('没有找到商家');
+        }
+        $data = self::getList('*', $where, 'debtAmount DESC');
+        $data['list'] = self::groupBaseInfo($data['list']);
+        $asset = MerchantAssetClass::getByMerchantId($sjId);
+        $data['debtAmount'] = $asset['cgDebtAmount'] ?? 0.00;
+        $data['debtNum'] = $asset['cgDebtNum'] ?? 0;
+        return $data;
+    }
+
+}

+ 13 - 0
biz/ghs/models/Ghs.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace biz\ghs\models;
+
+use biz\base\models\Base;
+
+class Ghs extends Base
+{
+    public static function tableName()
+    {
+        return 'xhGhs';
+    }
+}

+ 9 - 0
biz/ghs/services/GhsService.php

@@ -0,0 +1,9 @@
+<?php
+namespace biz\ghs\services;
+
+use biz\base\services\BaseService;
+
+class GhsService extends BaseService
+{
+    public static $baseFile = '\biz\ghs\classes\GhsClass';
+}

+ 0 - 1
biz/sj/services/MerchantService.php

@@ -142,7 +142,6 @@ class MerchantService extends BaseService
             'province' => isset($applyData['province']) ? $applyData['province'] : '',
             'city' => isset($applyData['city']) ? $applyData['city'] : '',
             'dist' => isset($applyData['dist']) ? $applyData['dist'] : '',
-            'default' => 1,
             'address' => isset($applyData['address']) ? $applyData['address'] : '',
             'fullAddress' => isset($applyData['fullAddress']) ? $applyData['fullAddress'] : '',
         ];

+ 10 - 2
sql.sql

@@ -114,7 +114,7 @@ unitNum int not null default 0 comment '每扎多少支',
 
 ALTER TABLE xhItem ADD cover VARCHAR(500) NOT NULL DEFAULT '' COMMENT '封面图片' AFTER `name`;
 
-ALTER TABLE xhMerchantAccount RENAME TO xhMerchantApply
+ALTER TABLE xhMerchantAccount RENAME TO xhMerchantApply;
 
 
 == shish 2021-1-3
@@ -1837,4 +1837,12 @@ ALTER TABLE xhRecharge ADD `status` TINYINT NOT NULL DEFAULT 1 COMMENT '1待充
 ALTER TABLE xhRecharge CHANGE `payCode` `returnCode` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '支付返回数据';
 ALTER TABLE xhShopAdmin DROP COLUMN `default`;
 ALTER TABLE xhShopAdmin ADD mobile CHAR(15) NOT NULL DEFAULT '' COMMENT '手机号' AFTER `adminName`;
-ALTER TABLE xhShopAdmin AUTO_INCREMENT=125631;
+ALTER TABLE xhShopAdmin AUTO_INCREMENT=125631;
+ALTER TABLE xhSupplier RENAME TO xhGhs;
+ALTER TABLE xhGhs ADD avatar VARCHAR(800) NOT NULL DEFAULT '' COMMENT '头像' AFTER `id`;
+ALTER TABLE xhGhs CHANGE `upId` `ghsSjId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商的商家id';
+ALTER TABLE xhGhs CHANGE `upShopId` `ghsShopId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商的门店id';
+ALTER TABLE xhGhs MODIFY `ghsShopId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商的门店id' AFTER ghsSjId;
+ALTER TABLE xhGhs ADD shopId INT NOT NULL DEFAULT 0 COMMENT '门店id' AFTER `ghsShopId`;
+ALTER TABLE xhGhs ADD sjId INT NOT NULL DEFAULT 0 COMMENT '商家id' AFTER `ghsShopId`;
+ALTER TABLE xhGhs DROP COLUMN `merchantId`;