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

+ 9 - 7
app/ghs/controllers/BaseController.php

@@ -17,7 +17,7 @@ use common\components\util;
 class BaseController extends PublicController
 {
 	public $admin, $adminId, $adminAvatar, $account;
-	public $merchantId = 0, $merchantName, $merchant, $merchantExtend, $merchantLogo, $signPackage, $shopId = 0;
+	public $ghsId = 0, $merchantName, $merchant, $merchantExtend, $merchantLogo, $signPackage, $shopId = 0;
 	public $appId;
 	public $isWx = false;
 	public $isLogin = false;
@@ -28,8 +28,10 @@ class BaseController extends PublicController
 	public function beforeAction($action)
 	{
 		//token验证
-		$adminId = jwt::getLoginId();
-		$merchantId = 0;
+		//$adminId = jwt::getLoginId();
+		//模拟用户
+        $adminId = 1;
+		$ghsId = 0;
 		$merchant = [];
 		$merchantExtend = [];
 		$admin = [];
@@ -53,9 +55,9 @@ class BaseController extends PublicController
 				if (empty($shop)) {
 					util::fail('没有找到门店');
 				}
-				$merchantId = $shop['merchantId'];
-				$merchant = MerchantService::getMerchantById($merchantId);
-				$merchantExtend = MerchantExtendService::getByMerchantId($merchantId);
+				$ghsId = $shop['ghsId'];
+				$merchant = MerchantService::getMerchantById($ghsId);
+				$merchantExtend = MerchantExtendService::getByMerchantId($ghsId);
 			}
 			$this->shopId = $shopId;
 		}
@@ -68,7 +70,7 @@ class BaseController extends PublicController
 		}
 		$this->admin = $admin;
 		$this->adminId = $adminId;
-		$this->merchantId = $merchantId;
+		$this->ghsId = $ghsId;
 		$this->merchant = $merchant;
 		$this->merchantExtend = $merchantExtend;
 		return parent::beforeAction($action);

+ 39 - 0
app/ghs/controllers/CustomController.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace ghs\controllers;
+
+use bizGhs\custom\services\CustomService;
+use common\components\stringUtil;
+use common\components\util;
+use Yii;
+use yii\web\Controller;
+
+class CustomController extends BaseController
+{
+
+    //客户列表 shish 2021.7.8
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $type = isset($get['type']) ? $get['type'] : -1;
+        $name = isset($get['name']) ? $get['name'] : '';
+        $where = ['ghsId' => $this->ghsId];
+        switch ($type) {
+            case 1:
+                //已开店
+                $where['isOpen'] = 1;
+                break;
+            default:
+        }
+        if (!empty($name)) {
+            if (stringUtil::isMobile($name)) {
+                $where['mobile'] = $name;
+            } else {
+                $where['shopName'] = ['like', $name];
+            }
+        }
+        $list = CustomService::getCustomList($where);
+        util::success($list);
+    }
+
+}

+ 37 - 0
biz-ghs/custom/classes/CustomClass.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace bizGhs\custom\classes;
+
+use bizGhs\merchant\classes\MerchantClass;
+use common\components\business;
+use Yii;
+use biz\base\classes\BaseClass;
+
+class CustomClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\custom\models\Custom';
+
+    //组合信息 shish 2021.1.8
+    public static function groupUserBaseInfo($list)
+    {
+        if (empty($list)) {
+            return $list;
+        }
+        //获取零售商信息
+        $retailIdList = array_unique(array_filter(array_column($list, 'retailId')));
+        $retailInfo = MerchantClass::getByIds($retailIdList, null, 'id');
+        foreach ($list as $key => $val) {
+            $retailId = $val['retailId'];
+            $currentInfo = isset($retailInfo[$retailId]) ? $retailInfo[$retailId] : [];
+            //组合头像
+            $currentInfo = business::formatMerchantLogo($currentInfo);
+            $list[$key]['smallAvatar'] = isset($currentInfo['smallLogoUrl']) ? $currentInfo['smallLogoUrl'] : '';
+            $list[$key]['avatar'] = isset($currentInfo['logoUrl']) ? $currentInfo['logoUrl'] : '';
+            $list[$key]['visitTime'] = '06-11 12:50';
+            $list[$key]['level'] = 0;
+        }
+        return $list;
+    }
+
+}

+ 13 - 0
biz-ghs/custom/models/Custom.php

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

+ 25 - 0
biz-ghs/custom/services/CustomService.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace bizGhs\custom\services;
+
+use biz\base\services\BaseService;
+use bizGhs\custom\classes\CustomClass;
+use Yii;
+
+class CustomService extends BaseService
+{
+
+    public static $baseFile = '\bizGhs\custom\classes\CustomClass';
+
+    public static function getCustomList($where)
+    {
+        $data = CustomClass::getList('*', $where, 'addTime DESC');
+        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+        if (empty($list)) {
+            return $data;
+        }
+        $data['list'] = CustomClass::groupUserBaseInfo($list);
+        return $data;
+    }
+
+}

+ 1 - 1
biz-ghs/merchant/models/Admin.php

@@ -7,7 +7,7 @@ class Admin extends Base
 
 	public static function tableName()
 	{
-		return 'xhAdmin';
+		return 'xhGhsAdmin';
 	}
 
 }

+ 1 - 1
biz-ghs/merchant/models/Express.php

@@ -7,7 +7,7 @@ class Express extends Base
 
 	public static function tableName()
 	{
-		return 'xhExpress';
+		return 'xhGhsExpress';
 	}
 
 }

+ 14 - 1
sql.sql

@@ -190,4 +190,17 @@ ALTER TABLE xhGhsAdmin MODIFY `identity` TINYINT(4) NOT NULL DEFAULT '0' COMMENT
 ALTER TABLE xhGhsShop CHANGE createTime `addTime` INT NOT NULL DEFAULT 0 COMMENT '添加时间';
 ALTER TABLE xhGhsShop MODIFY updateTime INT NOT NULL DEFAULT 0 COMMENT '修改时间';
 ALTER TABLE xhGhsShopAdmin ADD updateTime INT NOT NULL DEFAULT 0 COMMENT '修改时间';
-ALTER TABLE xhGhsShop DROP COLUMN `createTime`;
+ALTER TABLE xhGhsShop DROP COLUMN `createTime`;
+CREATE TABLE IF NOT EXISTS `xhGhsCustom`(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ghsId INT NOT NULL DEFAULT 0 COMMENT '供货商id merchantId',
+shopId INT NOT NULL DEFAULT 0 COMMENT '零售门店id',
+shopName VARCHAR(100) NOT NULL DEFAULT '' COMMENT '门店名称',
+`mobile` VARCHAR(15) NOT NULL DEFAULT '0' COMMENT '店长手机号',
+isOpen TINYINT NOT NULL DEFAULT 0 COMMENT '是否开店 0没有 1已开',
+`addTime` INT NOT NULL DEFAULT 0 COMMENT '添加时间',
+`updateTime` INT NOT NULL DEFAULT 0 COMMENT '修改时间'
+)COMMENT='供货商客户';
+
+ALTER TABLE xhGhsShop CHANGE `merchantId` ghsId INT NOT NULL DEFAULT 0 COMMENT '供货商id';
+ALTER TABLE xhGhsShop CHANGE `merchantName` ghsName VARCHAR(100) NOT NULL DEFAULT '' COMMENT '供货商名称';