| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace bizMall\merchant\classes;
- use common\components\dirUtil;
- use common\components\httpUtil;
- use common\components\qrCodeUtil;
- use common\components\util;
- use common\components\wxUtil;
- use Yii;
- use bizMall\base\classes\BaseClass;
- class ShopClass extends BaseClass
- {
-
- public static $baseFile = '\bizMall\merchant\models\Shop';
-
- public static function getShopList($where)
- {
- $list = self::getList('*', $where, 'addTime DESC');
- return $list;
- }
-
- //获取商家默认的门店ID ssh 2020.1.19
- public static function getDefaultShopId($merchant)
- {
- return isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
- }
-
- //创建门店 ssh 2020.2.8
- public static function addShop($data)
- {
- $data['createTime'] = date("Y-m-d H:i:s");
- $shopName = isset($data['shopName']) ? $data['shopName'] : '';
- if (empty($shopName)) {
- util::fail('请填写门店名称');
- }
- $exists = self::getByCondition(['sjId' => $data['sjId'], 'shopName' => $shopName]);
- if (!empty($exists)) {
- util::fail('门店名称已经存在');
- }
- $shop = self::add($data);
-
- return $shop;
- }
-
- //更新门店 ssh 2020.2.29
- public static function updateShop($id, $data)
- {
- $shopName = isset($data['shopName']) ? $data['shopName'] : '';
- $sjId = $data['sjId'];
- $findShop = self::getByCondition(['sjId' => $sjId, 'shopName' => $shopName]);
- if (!empty($findShop) && $findShop['id'] != $id) {
- util::fail('门店名称已经存在');
- }
- return self::updateById($id, $data);
- }
-
- //取商家所有门店 ssh 2020.2.29
- public static function getAllShop($sjId)
- {
- return self::getAllByCondition(['sjId' => $sjId]);
- }
-
- //验证所属权限 ssh 2020.2.29
- public static function valid($shop, $sjId)
- {
- if (empty($shop)) {
- util::fail('门店无效');
- }
- if (isset($shop['sjId']) == false || $shop['sjId'] != $sjId) {
- util::fail('您无法访问');
- }
- }
-
- //删除门店 ssh 2020.3.1
- public static function deleteShop($shop)
- {
- if (isset($shop['default']) && $shop['default'] == 1) {
- util::fail('默认门店不允许删除');
- }
- $id = $shop['id'];
- self::updateById($id, ['delStatus' => 1]);
- }
-
- //生成收款码 ssh 2020.3.9
- public static function generateGatheringCode($sjId, $shopId)
- {
- $url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account={$sjId}&shopId=" . $shopId;
- //强制转成https
- $url = httpUtil::becomeHttps($url);
- $gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $sjId, $shopId, '', 10);
- return $gatheringCode;
- }
- }
|