| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <?php
- namespace hd\controllers;
- use bizHd\auth\services\AuthService;
- use biz\sj\services\MerchantExtendService;
- use biz\sj\services\MerchantService;
- use bizHd\saas\services\SetAuthService;
- use Yii;
- use common\components\util;
- use bizHd\merchant\services\ShopService;
- use yii\web\Controller;
- class MerchantController extends BaseController
- {
- //运费设置 shish 2019.12.8
- public function actionFreightSetting()
- {
- $get = Yii::$app->request->get();
- $first = isset($get['first']) && is_numeric($get['first']) ? $get['first'] : 5;
- $add = isset($get['add']) && is_numeric($get['add']) ? $get['add'] : 5;
- MerchantExtendService::updateByCondition(['merchantId' => $this->sjId], ['freeDistance' => $first, 'freight' => $add]);
- util::complete();
- }
- //商家信息 shish 2019.12.8
- public function actionDetail()
- {
- $merchant = $this->sj;
- if (empty($merchant)) {
- util::success([]);
- }
- $merchant = MerchantService::getInfo($this->sj, $this->sjExtend);
- util::success($merchant);
- }
- //商家现有的会员等级 shish 2019.12.12
- public function actionMemberLevel()
- {
- $list = MerchantExtendService::getGradeList($this->sjExtend, false, false);
- $extend = $this->sjExtend;
- $gradeSwitch = isset($extend['gradeSwitch']) ? $extend['gradeSwitch'] : 1;
- util::success(['list' => $list, 'gradeSwitch' => $gradeSwitch]);
- }
- //会员等级更新 shish 2019.12.18
- public function actionMemberLevelUpdate()
- {
- $extend = $this->sjExtend;
- if ($extend['gradeSwitch'] == 0) {
- util::fail('会员等级已设置不能修改');
- }
- $list = Yii::$app->request->post('list');
- if (empty($list) || is_array($list) == false) {
- util::fail('请填写会员等级');
- }
- if (count($list) > 9) {
- util::fail('最多可以设置9个等级');
- }
- $data = [];
- foreach ($list as $key => $val) {
- if ($key > 0) {
- $currentGrowth = $val[1];
- $previousGrowth = $list[$key - 1][1];
- if ($currentGrowth <= $previousGrowth) {
- util::fail('等级越高成长值也要越高');
- }
- $currentDiscount = $val[2];
- $previousDiscount = $list[$key - 1][2];
- if ($currentDiscount >= $previousDiscount) {
- util::fail('等级越高折扣要越低');
- }
- }
- $data[] = $val[0] . '_' . $val[1] . '_' . $val[2];
- }
- if (empty($data)) {
- util::fail('请填写会员等级!');
- }
- $string = implode('I', $data);
- MerchantExtendService::updateByCondition(['merchantId' => $this->sjId], ['gradeList' => $string, 'gradeSwitch' => 0]);
- util::complete('提交成功');
- }
- //常用链接
- public function actionCommonUrl()
- {
- $list = MerchantService::getCommonUrlList();
- util::success($list);
- }
- //商家当前的权限id列表 shish 2020.1.23
- public function actionAuth()
- {
- $merchant = $this->sj;
- $setId = $merchant['setId'];
- $endId = 1;
- $ids = SetAuthService::getAuthIdList($setId, $endId);
- util::success(['ids' => $ids]);
- }
- //商家信息 shish 2020.1.11
- public function actionIntroduceShop()
- {
- $id = Yii::$app->request->get('id');
- $merchant = MerchantService::getMerchantById($id);
- if (empty($merchant)) {
- util::fail('没有找到介绍人');
- }
- $merchantName = isset($merchant['merchantName']) ? $merchant['merchantName'] : '';
- $smallLogoUrl = isset($merchant['smallLogoUrl']) ? $merchant['smallLogoUrl'] : '';
- $logoUrl = isset($merchant['logoUrl']) ? $merchant['logoUrl'] : '';
- $data = ['merchantName' => $merchantName, 'smallLogoUrl' => $smallLogoUrl, 'id' => $id, 'logoUrl' => $logoUrl, 'fullAddress' => '暂无'];
- util::success($data);
- }
-
- //当前用户获取门店信息
- public function actionGetShopInfo()
- {
- $merchant = $this->sj;
- $merchant['defaultShop'] = ShopService::getDefaultShopInfo($merchant);
- util::success($merchant);
- }
-
- //当前用户获取商家信息
- public function actionGetInfo()
- {
- $merchant = MerchantService::getInfo($this->sj, $this->sjExtend);
- util::success($merchant);
- }
-
- //客户的会员等级 shish 2020.1.2
- public function actionUserGrade()
- {
- $list = MerchantExtendService::getGradeList($this->sjExtend, 'asc', false);
- util::success($list);
- }
-
- //获取商家的到期时间 shish 2020.2.22
- public function actionGetDeadline()
- {
- $id = Yii::$app->request->get('merchantId');
- $merchant = MerchantService::getById($id);
- $deadline = $merchant['deadline'];
- util::success(['date' => $deadline]);
- }
- }
|