Просмотр исходного кода

Merge branch 'master' of http://git.huaml.com/zhh/huahuibao

# Conflicts:
#	sql.sql
林琦海 5 лет назад
Родитель
Сommit
69ff48b5aa

+ 54 - 0
app-hd/controllers/MainController.php

@@ -103,4 +103,58 @@ class MainController extends BaseController
         util::success($data);
     }
 
+    //经营概况 ssh 2021.1.27
+    public function actionProfile()
+    {
+        $base = [
+            'balance' => 5020.00,
+            'mayGathering' => 10,
+            'mayPay' => 20,
+            'stockCost' => 2000,
+            'stockNum' => 100,
+            'stockWarning' => 5,
+            'today' => 90,
+            'todayCompareYesterday' => -5,
+            'latestSeven' => 9000,
+            'latestSevenSameTerm' => 10,
+            'latestThirty' => 8000,
+            'latestThirtySameTerm' => -9,
+        ];
+        $more = [
+            'today' => [
+                'income' => 10,
+                'expend' => 2,
+                'saleNum' => 1,
+                'saleAmount' => 100,
+                'purchaseNum' => 2,
+                'purchaseAmount' => 3,
+            ],
+            'yesterday' => [
+                'income' => 10,
+                'expend' => 2,
+                'saleNum' => 1,
+                'saleAmount' => 100,
+                'purchaseNum' => 2,
+                'purchaseAmount' => 3,
+            ],
+            'latestSeven' => [
+                'income' => 10,
+                'expend' => 2,
+                'saleNum' => 1,
+                'saleAmount' => 100,
+                'purchaseNum' => 2,
+                'purchaseAmount' => 3,
+            ],
+            'latestThirty' => [
+                'income' => 10,
+                'expend' => 2,
+                'saleNum' => 1,
+                'saleAmount' => 100,
+                'purchaseNum' => 2,
+                'purchaseAmount' => 3,
+            ],
+        ];
+        util::success(['base' => $base, 'more' => $more]);
+    }
+
 }

+ 5 - 0
biz-ghs/shop/services/ShopAdminService.php

@@ -69,6 +69,9 @@ class ShopAdminService extends BaseService
         if (empty($admin)) {
             util::fail('员工信息无效');
         }
+        if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
+            util::fail("请关注公众号");
+        }
         $roleId = $source['roleId'];
         $remind = isset($source['remind']) ? $source['remind'] : 0;
         $status = isset($source['status']) ? $source['status'] : 0;
@@ -83,6 +86,8 @@ class ShopAdminService extends BaseService
             'remind' => $remind,
             'status' => $status,
             'merchantId' => $merchantId,
+            'adminName' => $adminName,
+            'mobile'=>$mobile,
         ];
         ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
         return ShopAdminClass::add($addData);

+ 122 - 117
biz-hd/admin/services/ShopAdminService.php

@@ -20,121 +20,126 @@ use Yii;
 
 class ShopAdminService extends BaseService
 {
-	
-	public static $baseFile = '\bizHd\admin\classes\ShopAdminClass';
-	
-	///创建管理员生成小程序 ssh 2020.4.17
-	public static function prepareBindAdmin($data)
-	{
-		ShopAdminClass::prepareBindAdmin($data);
-		$page = 'admin/shopAdmin/bind';
-		$isOpen = 1;
-		$adminId = $data['adminId'];
-		$shopId = $data['shopId'];
-		$scene = 'adminId=' . $adminId . '&shopId=' . $shopId;
-		$merchant = $data['merchant'];
-		$imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $isOpen);
-		return ['miniCode' => $imgUrl];
-	}
-	
-	public static function generateAdmin($data)
-	{
-		$recommendAdminId = isset($data['recommendAdminId']) ? $data['recommendAdminId'] : 0;
-		$mobile = isset($data['mobile']) ? $data['mobile'] : '';
-		$shopId = isset($data['shopId']) ? $data['shopId'] : 0;
-		$adminId = isset($data['adminId']) ? $data['adminId'] : 0;
-		$bindData = ShopAdminClass::getBindAdminData($shopId, $recommendAdminId);
-		$shop = ShopClass::getById($shopId);
-		if (empty($shop)) {
-			util::fail('没有找到门店');
-		}
-		$merchantId = isset($shop['merchantId']) ? $shop['merchantId'] : 0;
-		if (empty($bindData)) {
-			util::fail('小程序码已经失效,请重新创建员工');
-		}
-		$shopAdmin = ShopAdminClass::getByCondition(['adminId' => $adminId, 'shopId' => $shopId]);
-		if (!empty($shopAdmin)) {
-			util::fail('您已经是管理员了');
-		}
-		$adminName = isset($bindData['adminName']) ? $bindData['adminName'] : '';
-		if (isset($bindData['roleId']) == false || empty($bindData['roleId'])) {
-			util::fail('添加管理员时请选择角色');
-		}
-		$admin = AdminClass::getById($adminId);
-		if (empty($admin)) {
-			util::fail('没有找到管理员信息');
-		}
-		$roleId = $bindData['roleId'];
-		$remind = isset($bindData['remind']) ? $bindData['remind'] : 0;
-		$status = isset($bindData['status']) ? $bindData['status'] : 0;
-		$password = isset($bindData['password']) ? password_hash($bindData['password'], PASSWORD_BCRYPT) : '';
-		$remark = isset($bindData['remark']) ? $bindData['remark'] : '';
-		$update = ['adminName' => $adminName, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark];
-		AdminClass::updateById($adminId, $update);
-		$addData = [
-			'adminId' => $adminId,
-			'shopId' => $shopId,
-			'roleId' => $roleId,
-			'remind' => $remind,
-			'status' => $status,
-			'merchantId' => $merchantId,
-		];
-		ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
-		return ShopAdminClass::add($addData);
-	}
-	
-	//获取管理员 ssh 2020.4.21
-	// $sensitive true 密码等敏感信息不显示
-	public static function getAdminList($where, $sensitive = true)
-	{
-		$data = ShopAdminClass::getList('*', $where, 'addTime DESC');
-		$list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
-		if (empty($list)) {
-			return $data;
-		}
-		
-		//管理员基础信息
-		$ids = array_column($list, 'adminId');
-		$adminInfo = AdminClass::getByIds($ids, null, 'id');
-		$adminBaseInfo = AdminClass::groupAdminBaseInfo($adminInfo, $sensitive);
-		
-		$roleIds = array_column($list, 'roleId');
-		$roleIds = array_filter(array_unique($roleIds));
-		$roleList = AdminRoleClass::getByIds($roleIds, null, 'id');
-		
-		foreach ($list as $key => $val) {
-			$adminId = $val['adminId'];
-			$current = isset($adminBaseInfo[$adminId]) ? $adminBaseInfo[$adminId] : [];
-			$list[$key]['adminBaseInfo'] = $current;
-			$roleId = $val['roleId'];
-			$roleName = isset($roleList[$roleId]['roleName']) ? $roleList[$roleId]['roleName'] : '';
-			$list[$key]['roleName'] = $roleName;
-		}
-		$data['list'] = $list;
-		return $data;
-	}
-	
-	//获取要通知的管理员 ssh 2020.4.28
-	public static function getNoticeAdminList($shopId)
-	{
-		$where = ['shopId' => $shopId];
-		$respond = self::getAdminList($where, false);
-		$list = isset($respond['list']) ? $respond['list'] : [];
-		if (!empty($list)) {
-			foreach ($list as $key => $val) {
-				if (isset($val['remind']) && $val['remind'] == 0) {
-					unset($list[$key]);
-				}
-			}
-		}
-		return $list;
-	}
-	
-	public static function valid($shopAdmin, $shopId)
-	{
-		if (isset($shopAdmin['shopId']) == false || $shopAdmin['shopId'] != $shopId) {
-			util::fail('不是您的员工');
-		}
-	}
-	
+
+    public static $baseFile = '\bizHd\admin\classes\ShopAdminClass';
+
+    ///创建管理员生成小程序 ssh 2020.4.17
+    public static function prepareBindAdmin($data)
+    {
+        ShopAdminClass::prepareBindAdmin($data);
+        $page = 'admin/shopAdmin/bind';
+        $isOpen = 1;
+        $adminId = $data['adminId'];
+        $shopId = $data['shopId'];
+        $scene = 'adminId=' . $adminId . '&shopId=' . $shopId;
+        $merchant = $data['merchant'];
+        $imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $isOpen);
+        return ['miniCode' => $imgUrl];
+    }
+
+    public static function generateAdmin($data)
+    {
+        $recommendAdminId = isset($data['recommendAdminId']) ? $data['recommendAdminId'] : 0;
+        $mobile = isset($data['mobile']) ? $data['mobile'] : '';
+        $shopId = isset($data['shopId']) ? $data['shopId'] : 0;
+        $adminId = isset($data['adminId']) ? $data['adminId'] : 0;
+        $bindData = ShopAdminClass::getBindAdminData($shopId, $recommendAdminId);
+        $shop = ShopClass::getById($shopId);
+        if (empty($shop)) {
+            util::fail('没有找到门店');
+        }
+        $merchantId = isset($shop['merchantId']) ? $shop['merchantId'] : 0;
+        if (empty($bindData)) {
+            util::fail('小程序码已经失效,请重新创建员工');
+        }
+        $shopAdmin = ShopAdminClass::getByCondition(['adminId' => $adminId, 'shopId' => $shopId]);
+        if (!empty($shopAdmin)) {
+            util::fail('您已经是管理员了');
+        }
+        $adminName = isset($bindData['adminName']) ? $bindData['adminName'] : '';
+        if (isset($bindData['roleId']) == false || empty($bindData['roleId'])) {
+            util::fail('添加管理员时请选择角色');
+        }
+        $admin = AdminClass::getById($adminId);
+        if (empty($admin)) {
+            util::fail('没有找到管理员信息');
+        }
+        if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
+            util::fail("请关注公众号({$admin['id']})");
+        }
+        $roleId = $bindData['roleId'];
+        $remind = isset($bindData['remind']) ? $bindData['remind'] : 0;
+        $status = isset($bindData['status']) ? $bindData['status'] : 0;
+        $password = isset($bindData['password']) ? password_hash($bindData['password'], PASSWORD_BCRYPT) : '';
+        $remark = isset($bindData['remark']) ? $bindData['remark'] : '';
+        $update = ['adminName' => $adminName, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark, 'currentShopId' => $shopId];
+        AdminClass::updateById($adminId, $update);
+        $addData = [
+            'adminId' => $adminId,
+            'shopId' => $shopId,
+            'roleId' => $roleId,
+            'remind' => $remind,
+            'status' => $status,
+            'merchantId' => $merchantId,
+            'adminName' => $adminName,
+            'mobile' => $mobile,
+        ];
+        ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
+        return ShopAdminClass::add($addData);
+    }
+
+    //获取管理员 ssh 2020.4.21
+    // $sensitive true 密码等敏感信息不显示
+    public static function getAdminList($where, $sensitive = true)
+    {
+        $data = ShopAdminClass::getList('*', $where, 'addTime DESC');
+        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+        if (empty($list)) {
+            return $data;
+        }
+
+        //管理员基础信息
+        $ids = array_column($list, 'adminId');
+        $adminInfo = AdminClass::getByIds($ids, null, 'id');
+        $adminBaseInfo = AdminClass::groupAdminBaseInfo($adminInfo, $sensitive);
+
+        $roleIds = array_column($list, 'roleId');
+        $roleIds = array_filter(array_unique($roleIds));
+        $roleList = AdminRoleClass::getByIds($roleIds, null, 'id');
+
+        foreach ($list as $key => $val) {
+            $adminId = $val['adminId'];
+            $current = isset($adminBaseInfo[$adminId]) ? $adminBaseInfo[$adminId] : [];
+            $list[$key]['adminBaseInfo'] = $current;
+            $roleId = $val['roleId'];
+            $roleName = isset($roleList[$roleId]['roleName']) ? $roleList[$roleId]['roleName'] : '';
+            $list[$key]['roleName'] = $roleName;
+        }
+        $data['list'] = $list;
+        return $data;
+    }
+
+    //获取要通知的管理员 ssh 2020.4.28
+    public static function getNoticeAdminList($shopId)
+    {
+        $where = ['shopId' => $shopId];
+        $respond = self::getAdminList($where, false);
+        $list = isset($respond['list']) ? $respond['list'] : [];
+        if (!empty($list)) {
+            foreach ($list as $key => $val) {
+                if (isset($val['remind']) && $val['remind'] == 0) {
+                    unset($list[$key]);
+                }
+            }
+        }
+        return $list;
+    }
+
+    public static function valid($shopAdmin, $shopId)
+    {
+        if (isset($shopAdmin['shopId']) == false || $shopAdmin['shopId'] != $shopId) {
+            util::fail('不是您的员工');
+        }
+    }
+
 }

+ 6 - 0
sql.sql

@@ -2090,6 +2090,9 @@ ALTER TABLE xhAdmin DROP COLUMN `identity`;
 国兰原有的商品拼音需要补回去
 
 
+ALTER TABLE xhShopAdmin ADD VARCHAR(500) NOT NULL DEFAULT '' COMMENT '添加员工时的备注' AFTER `super`;
+ALTER TABLE xhShopAdmin ADD founder TINYINT NOT NULL DEFAULT 1 COMMENT '创始人 1不是 2是' AFTER `super`;
+
 ======linqh 2021-04-14
 ==
 ALTER TABLE `xhShop`
@@ -2098,3 +2101,6 @@ ADD COLUMN `totalExpend`  decimal(9,2) NOT NULL DEFAULT 0 COMMENT '总支出' AF
 ADD COLUMN `totalView`  int(11) NOT NULL DEFAULT 0 COMMENT '累计访问次数' AFTER `status`,
 ADD COLUMN `totalUser`  int(11) NOT NULL DEFAULT 0 COMMENT '总用户;总客户数' AFTER `totalView`,
 ADD COLUMN `totalPurchaseOrder`  int(11) NOT NULL DEFAULT 0 COMMENT '总采购订单' AFTER `totalUser`;
+
+
+