| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?php
- namespace hd\controllers;
- use biz\ghs\classes\GhsClass;
- use biz\recharge\classes\RechargeHbClass;
- use biz\shop\classes\ShopClass;
- use bizGhs\custom\classes\CustomClass;
- use bizGhs\custom\classes\CustomLevelClass;
- use bizHd\stat\classes\StatVisitClass;
- use common\components\imgUtil;
- use common\components\util;
- use Yii;
- class GhsController extends BaseController
- {
- public $guestAccess = ['info'];
- public static $levelMap = [
- 'pt' => ['name' => '普店', 'num' => 0, 'amount' => 0, 'key' => ''],
- 'hj' => ['name' => '银店', 'num' => 0, 'amount' => 0, 'key' => 'hj'],
- 'zs' => ['name' => '金店', 'num' => 0, 'amount' => 0, 'key' => 'zs'],
- ];
- //采购选分类有变化通知
- public function actionGetClassRemind()
- {
- $cacheKey = 'class_change_remind_' . $this->shopAdminId;
- $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $hasStatus = !empty($has) ? 1 : 0;
- util::success(['hasRemind' => $hasStatus]);
- }
- //采购选分类有变化通知
- public function actionHasClassRemind()
- {
- $cacheKey = 'class_change_remind_' . $this->shopAdminId;
- Yii::$app->redis->executeCommand('SET', [$cacheKey, 'has']);
- util::complete();
- }
- //供货商列表 ssh 2021.1.24
- public function actionList()
- {
- $where = [];
- $where['ownShopId'] = $this->shopId;
- $respond = GhsClass::getGhsList($where);
- util::success($respond);
- }
- //详情 ssh 2021.4.11
- public function actionDetail()
- {
- $id = Yii::$app->request->get('id');
- $info = GhsClass::getGhsInfo($id);
- $giveLevel = $info['giveLevel'] ?? 0;
- $levelMap = CustomClass::$nickNameMap;
- $giveLevelName = $levelMap[$giveLevel] ?? '散客';
- $info['giveLevelName'] = $giveLevelName;
- GhsClass::valid($info, $this->shopId);
- //是否有充值送红包活动
- $ghsShopId = $info['shopId'] ?? 0;
- $ghsShop = ShopClass::getById($ghsShopId, true);
- $info['hasRechargeHb'] = $ghsShop->recharge ?? 0;
- $hb = RechargeHbClass::getByCondition(['shopId' => $ghsShopId, 'delStatus' => 0], true, 'totalHb DESC');
- $info['hasRechargeHbAmount'] = $hb->totalHb ?? 0;
- $info['xrFl'] = $ghsShop->xrFl ?? 0;
- $info['xrFlAmount'] = $ghsShop->xrFlAmount ?? 0;
- $info['tjFl'] = $ghsShop->tjFl ?? 0;
- $info['tjFlAmount'] = $ghsShop->tjFlAmount ?? 0;
- //预订单的最低公斤数和每公斤服务费
- $info['kiloFee'] = $ghsShop->kiloFee ?? 0;
- $info['miniKilo'] = $ghsShop->miniKilo ?? 0;
- util::success($info);
- }
- //根据门店获取供货商信息 ssh 2021.4.14
- public function actionInfo()
- {
- $shopId = Yii::$app->request->get('shopId');
- if (isset($this->shopId) && !empty($this->shopId)) {
- $ghs = GhsClass::build($shopId, $this->shopId);
- //是否有充值送红包活动
- $ghsShopId = $ghs['shopId'] ?? 0;
- $ghsShop = ShopClass::getById($ghsShopId, true);
- $ghs['hasRechargeHb'] = $ghsShop->recharge ?? 0;
- $hb = RechargeHbClass::getByCondition(['shopId' => $ghsShopId, 'delStatus' => 0], true, 'totalHb DESC');
- $ghs['hasRechargeHbAmount'] = $hb->totalHb ?? 0;
- $avatar = $ghs['avatar'] ?? '';
- $ghs['avatar'] = imgUtil::groupImg($avatar);
- $map = CustomClass::$nickNameMap;
- $giveLevel = $ghs['giveLevel'] ?? 0;
- $ghs['giveLevelName'] = $map[$giveLevel] ?? '';
- $ghs['xrFl'] = $ghsShop->xrFl ?? 0;
- $ghs['xrFlAmount'] = $ghsShop->xrFlAmount ?? 0;
- $ghs['tjFl'] = $ghsShop->tjFl ?? 0;
- $ghs['tjFlAmount'] = $ghsShop->tjFlAmount ?? 0;
- } else {
- //没有开店也给显示供货商信息
- $shop = ShopClass::getShopInfo($shopId);
- $shopName = $shop['shopName'] ?? '';
- $sjName = $shop['merchantName'] ?? '';
- $avatar = $shop['avatar'] ?? '';
- $default = $shop['default'] ?? 0;
- $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
- $ghs = [
- 'id' => 0,
- 'name' => $name,
- 'debtAmount' => 0.00,
- 'expendAmount' => 0.00,
- 'giveLevel' => 0,
- 'giveLevelName' => '普通',
- 'xrFl' => 0,
- 'xrFlAmount' => 0,
- 'tjFl' => 0,
- 'tjFlAmount' => 0,
- 'avatar' => $avatar,
- ];
- }
- util::success($ghs);
- }
- //获取客户等级 ssh 20211016
- public function actionGetCustomLevel()
- {
- $id = Yii::$app->request->get('id');
- $info = GhsClass::getById($id, true);
- GhsClass::valid($info, $this->shopId);
- $ghsShopId = $info->shopId ?? 0;
- $info = CustomLevelClass::getByCondition(['shopId' => $ghsShopId]);
- $map = self::$levelMap;
- foreach ($map as $key => $val) {
- $flag = $val['key'] ?? '';
- if (empty($flag)) {
- $map[$key]['num'] = $info["num"] ?? 0;
- $map[$key]['amount'] = $info["amount"] ?? 0;
- } else {
- $map[$key]['num'] = $info[$flag . "Num"] ?? 0;
- $map[$key]['amount'] = $info[$flag . "Amount"] ?? 0;
- }
- }
- util::success(['list' => $map]);
- }
- //访问供货商的商城 ssh 20211022
- public function actionVisitMall()
- {
- $id = Yii::$app->request->get('id');
- $info = GhsClass::getById($id, true);
- GhsClass::valid($info, $this->shopId);
- $customId = $info->customId ?? 0;
- $custom = CustomClass::getById($customId, true);
- if (empty($custom)) {
- util::fail('没有找到客户');
- }
- StatVisitClass::addGhsCustomVisit($info, $custom);
- util::complete();
- }
- //补充缺失的供货商 ssh 20211027
- public function actionBcGhs()
- {
- util::fail('过几天再试');
- GhsClass::bcGhs($this->shopId);
- util::complete('载入成功');
- }
- }
|