Explorar el Código

供货商与支付密码

shish hace 5 años
padre
commit
0ea041e5f6

+ 18 - 0
app/shop/controllers/AdminController.php

@@ -189,4 +189,22 @@ class AdminController extends BaseController
         util::success(['mobile' => $mobile]);
     }
 
+    //设置支付密码 shish 2021.1.24
+    public function actionSetPayPassword()
+    {
+        $get = Yii::$app->request->get();
+        $adminId = $this->adminId;
+        $info = AdminClass::getAdminById($adminId, false);
+        if (isset($info['payPassword']) && !empty($info['payPassword'])) {
+            util::fail('您已经设置了支付密码');
+        }
+        $password = $get['password'] ?? '';
+        if (empty($password)) {
+            util::fail('请输入支付密码');
+        }
+        $string = password_hash($password, PASSWORD_BCRYPT);
+        AdminClass::updateById($adminId, ['payPassword' => $string]);
+        util::complete();
+    }
+
 }

+ 55 - 54
app/shop/controllers/BaseController.php

@@ -2,6 +2,7 @@
 
 namespace shop\controllers;
 
+use biz\admin\classes\AdminClass;
 use biz\admin\services\ShopAdminService;
 use biz\merchant\services\AdminService;
 use biz\merchant\services\MerchantExtendService;
@@ -14,62 +15,62 @@ use common\components\util;
 
 class BaseController extends PublicController
 {
-	public $admin, $adminId, $adminAvatar, $account;
-	public $merchantId = 0, $merchantName, $merchant, $merchantExtend, $merchantLogo, $signPackage, $shopId = 0;
-	public $appId;
-	public $isWx = false;
-	public $isLogin = false;
-	public $withoutLogin = [];//不需要登陆的方法名
-	public $validate = true;
+    public $admin, $adminId, $adminAvatar, $account;
+    public $merchantId = 0, $merchantName, $merchant, $merchantExtend, $merchantLogo, $signPackage, $shopId = 0;
+    public $appId;
+    public $isWx = false;
+    public $isLogin = false;
+    public $withoutLogin = [];//不需要登陆的方法名
+    public $validate = true;
 
-	//shish 2020.3.8
-	public function beforeAction($action)
-	{
-		//token验证
-		//$adminId = jwt::getLoginId();
+    //shish 2020.3.8
+    public function beforeAction($action)
+    {
+        //token验证
+        //$adminId = jwt::getLoginId();
         $adminId = 18569;
-		$merchantId = 0;
-		$merchant = [];
-		$merchantExtend = [];
-		$admin = [];
-		if (empty($adminId)) {
-			$this->validate = false;
-		} else {
-			$admin = AdminService::getById($adminId);
-			if (empty($admin)) {
-				util::fail('帐号无效');
-			}
-			$adminId = $admin['id'];
-			$shopId = Yii::$app->redis->executeCommand('GET', ['LOGIN_ADMIN_SHOP' . $adminId]);
-			//取不到门店id可能被清缓存,需要重新登陆,$shopId = 0 则表示非管理员,没有关联的门店,只可以访问官网
-			if (is_numeric($shopId) == false) {
-				util::notLogin('登陆已失效,请重新登陆');
-			}
-			if (!empty($shopId)) {
-				$shop = ShopService::getById($shopId);
-				if (empty($shop)) {
-					util::fail('您所管理的门店已经跑到月球上去了');
-				}
-				$merchantId = $shop['merchantId'];
-				$merchant = MerchantService::getMerchantById($merchantId);
-				$merchantExtend = MerchantExtendService::getByMerchantId($merchantId);
-			}
-			$this->shopId = $shopId;
-		}
-		//游客可以访问的方法
-		if (in_array($action->id, $this->withoutLogin)) {
-			$this->validate = true;
-		}
-		if ($this->validate == false) {
-			util::notLogin('您还没有登陆哦');
-		}
-		$this->admin = $admin;
-		$this->adminId = $adminId;
-		$this->merchantId = $merchantId;
-		$this->merchant = $merchant;
-		$this->merchantExtend = $merchantExtend;
-		return parent::beforeAction($action);
-	}
+        $merchantId = 0;
+        $merchant = [];
+        $merchantExtend = [];
+        $admin = [];
+        if (empty($adminId)) {
+            $this->validate = false;
+        } else {
+            $admin = AdminClass::getAdminById($adminId, true);
+            if (empty($admin)) {
+                util::fail('帐号无效');
+            }
+            $adminId = $admin['id'];
+            $shopId = Yii::$app->redis->executeCommand('GET', ['LOGIN_ADMIN_SHOP' . $adminId]);
+            //取不到门店id可能被清缓存,需要重新登陆,$shopId = 0 则表示非管理员,没有关联的门店,只可以访问官网
+            if (is_numeric($shopId) == false) {
+                util::notLogin('登陆已失效,请重新登陆');
+            }
+            if (!empty($shopId)) {
+                $shop = ShopService::getById($shopId);
+                if (empty($shop)) {
+                    util::fail('您所管理的门店已经跑到月球上去了');
+                }
+                $merchantId = $shop['merchantId'];
+                $merchant = MerchantService::getMerchantById($merchantId);
+                $merchantExtend = MerchantExtendService::getByMerchantId($merchantId);
+            }
+            $this->shopId = $shopId;
+        }
+        //游客可以访问的方法
+        if (in_array($action->id, $this->withoutLogin)) {
+            $this->validate = true;
+        }
+        if ($this->validate == false) {
+            util::notLogin('您还没有登陆哦');
+        }
+        $this->admin = $admin;
+        $this->adminId = $adminId;
+        $this->merchantId = $merchantId;
+        $this->merchant = $merchant;
+        $this->merchantExtend = $merchantExtend;
+        return parent::beforeAction($action);
+    }
 
 }
 

+ 24 - 0
app/shop/controllers/SupplierController.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace shop\controllers;
+
+use biz\merchant\services\ShopService;
+use bizGhs\merchant\services\SupplierService;
+use common\components\dirUtil;
+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->merchantId;
+        $respond = SupplierService::getSupplierList($where);
+        util::success($respond);
+    }
+
+}

+ 4 - 1
biz-ghs/merchant/classes/SupplierClass.php

@@ -24,10 +24,13 @@ class SupplierClass extends BaseClass
 
     public static function groupBaseInfo($list)
     {
+        if (empty($list)) {
+            return $list;
+        }
         foreach ($list as $key => $val) {
             //头像大图
             $list[$key]['logoUrl'] = Yii::$app->params['imgHost'] . '/hhb_small.png';
-            //头像小图,列表页使用
+            //头像小图
             $list[$key]['smallLogoUrl'] = Yii::$app->params['imgHost'] . '/hhb_small.png';
         }
         return $list;

+ 11 - 10
biz-ghs/merchant/services/SupplierService.php

@@ -8,14 +8,15 @@ use Yii;
 
 class SupplierService extends BaseService
 {
-	
-	public static $baseFile = '\bizGhs\merchant\classes\SupplierClass';
-	
-	public static function getSupplierList()
-	{
-		$data = SupplierClass::getList('*', $where, 'addTime DESC');
-		$list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
-		return $data;
-	}
-	
+
+    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;
+    }
+
 }

+ 5 - 5
biz/admin/classes/AdminClass.php

@@ -21,14 +21,13 @@ class AdminClass extends BaseClass
         'wx84d95afcb7b594eb' => ['oTFbYvsjwgVwXggwtlM2ESAKwuN8', 'oTFbYvqP6qwdCCkdFB9GYnlzDIUg'],
     ];
 
-    //组合员工基本信息 shish 2019.12.9
+    //组合员工基本信息 $sensitive = true 表示敏感的,不要输出密码信息 shish 2019.12.9
     public static function groupAdminBaseInfo($list, $sensitive = true)
     {
         $prefix = Yii::$app->params['imgHost'];
         foreach ($list as $key => $val) {
-            $roleId = 0;
             $list[$key]['roleName'] = '';
-            $list[$key]['avatarUrl'] = Yii::$app->params['imgHost'] . '/retail/default-avatar.png';
+            $list[$key]['avatarUrl'] = $prefix . '/retail/default-avatar.png';
             $list[$key]['addDate'] = date("Y-m-d H:i", $val['addTime']);
             $list[$key]['lastLoginTime'] = date("Y-m-d H:i", $val['loginTime']);
             //敏感信息
@@ -54,13 +53,14 @@ class AdminClass extends BaseClass
     }
 
     //获取员工详情 shish 2019.12.9
-    public static function getAdminById($id)
+    // $sensitive = true 表示敏感的,不要输出密码等信息
+    public static function getAdminById($id, $sensitive = true)
     {
         $detail = AdminClass::getById($id);
         if (empty($detail)) {
             util::fail('没有找到员工信息!');
         }
-        $list = self::groupAdminBaseInfo([$detail]);
+        $list = self::groupAdminBaseInfo([$detail], $sensitive);
         return current($list);
     }
 

+ 16 - 15
biz/merchant/classes/AdminClass.php

@@ -8,20 +8,21 @@ use biz\base\classes\BaseClass;
 class AdminClass extends BaseClass
 {
 
-	public static $baseFile = '\biz\merchant\models\Admin';
-
-	//收益通知人
-	public static $noticeAdmin = [
-		//国兰
-		'wx193341a4a80f6ea3' => ['o4c8Vs54PQh32nkgG8R3m4VuGTvw', 'o4c8VszacQJyrzu651CAu0sCsfPc'],
-		//花美灵
-		'wx84d95afcb7b594eb' => ['oTFbYvsjwgVwXggwtlM2ESAKwuN8', 'oTFbYvqP6qwdCCkdFB9GYnlzDIUg'],
-	];
-
-	//创建管理员 shish
-	public static function addAdmin($data)
-	{
-		return self::add($data);
-	}
+    public static $baseFile = '\biz\merchant\models\Admin';
+
+    //收益通知人
+    public static $noticeAdmin = [
+        //国兰
+        'wx193341a4a80f6ea3' => ['o4c8Vs54PQh32nkgG8R3m4VuGTvw', 'o4c8VszacQJyrzu651CAu0sCsfPc'],
+        //花美灵
+        'wx84d95afcb7b594eb' => ['oTFbYvsjwgVwXggwtlM2ESAKwuN8', 'oTFbYvqP6qwdCCkdFB9GYnlzDIUg'],
+    ];
+
+    //创建管理员 shish
+    public static function addAdmin($data)
+    {
+        return self::add($data);
+    }
+
 
 }

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

@@ -80,4 +80,16 @@ class PurchaseClass extends BaseClass
 
     }
 
+    //检查采购单
+    public static function valid($info, $shopId)
+    {
+        if (empty($info)) {
+            util::fail('没有找到采购单');
+        }
+        if (isset($info['shopId']) && $info['shopId'] == $shopId) {
+            return true;
+        }
+        util::fail('没有权限操作');
+    }
+
 }

+ 5 - 1
sql.sql

@@ -898,4 +898,8 @@ ADD COLUMN `outTime`  timestamp NULL DEFAULT NULL COMMENT '出库时间' AFTER `
 ALTER TABLE `xhGhsOrderSend` MODIFY `finishTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '完成时间';
 ALTER TABLE xhGhsOrderSend ADD `status` TINYINT NOT NULL DEFAULT 0 COMMENT '0待完成 1已完成' AFTER `finishTime`;
 ALTER TABLE `xhGhsOrderSend` ADD actionName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '动作名称' AFTER `actionId`;
-ALTER TABLE `xhAdmin` ADD payPassword VARCHAR(500) NOT NULL DEFAULT '' COMMENT '支付密码' AFTER `confirmPassword`;
+ALTER TABLE `xhAdmin` ADD payPassword VARCHAR(500) NOT NULL DEFAULT '' COMMENT '支付密码' AFTER `confirmPassword`;
+ALTER TABLE `xhSupplier` DROP COLUMN `addTime`;
+ALTER TABLE `xhSupplier` DROP COLUMN `updateTime`;
+ALTER TABLE `xhSupplier` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `merchantId`;
+ALTER TABLE `xhSupplier` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;