master
wangxinglong 2022-04-07 14:31:17 +08:00
parent 492f2b9a13
commit f9642ea6cd
5 changed files with 32 additions and 11 deletions

View File

@ -4,6 +4,7 @@ namespace app\controller\manager;
use app\model\Business as BusinessModel;
use app\model\Log;
use app\model\Member;
use app\model\Member as MemberModel;
use app\repository\BusinessRepository;
use Exception;
@ -30,6 +31,11 @@ class Agency extends Base
public function add()
{
if ($this->request->isPost()) {
$roles = array_filter( explode(",",$this->auth["roles"]));
//如果是 渠道商或者工作人员
if(!in_array(Member::ANENT_ROLE_ID,$roles)){
return $this->json(4001,"您不是是代理商,不能添加工作人员");
}
$item = input('post.');
$validate = $this->validateByApi($item, [
@ -71,8 +77,6 @@ class Agency extends Base
}
$this->data['roleJson'] = $this->roleJson();
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll();
return $this->view();
}
@ -127,7 +131,7 @@ class Agency extends Base
}
$this->data['roleJson'] = $this->roleJson();
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll();
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll($this->auth["roles"],$this->auth["business_code"]);
return $this->view();
}
@ -256,7 +260,7 @@ class Agency extends Base
$this->data['item'] = $info;
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll();
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll($this->auth["roles"],$this->auth["business_code"]);
return $this->view();
}
@ -287,7 +291,7 @@ class Agency extends Base
}
/**
* 渠道商列表
* 代理商列表
*
* @return Json|View
* @throws Exception

View File

@ -380,7 +380,9 @@ class Coupon extends Base
}
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll();
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll($this->auth["roles"],$this->auth["business_code"]);
$this->data['type'] = CouponRepository::getInstance()->getCouponTypeAll();
return $this->view('add');
@ -537,7 +539,7 @@ class Coupon extends Base
if (empty($couponMain)) {
return $this->error("签到券不存在");
}
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll();
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll($this->auth["roles"],$this->auth["business_code"]);
$this->data['type'] = CouponRepository::getInstance()->getCouponTypeAll();
$this->data['item'] = $couponMain;

View File

@ -178,7 +178,7 @@ class Member extends Base
$this->data['item'] = $info;
$this->data['roleJson'] = $this->roleJson(explode(',', $info['roles']));
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll();
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll($this->auth["roles"],$this->auth["business_code"]);
return $this->view();
}

View File

@ -7,6 +7,7 @@ use app\model\Account;
use app\model\Business;
use app\model\CouponMain;
use app\model\Deduction;
use app\model\Member;
use app\model\Recharge;
use app\service\Repository;
use app\traits\account\ApplyStaffTrait;
@ -136,11 +137,26 @@ class BusinessRepository extends Repository
}
/* 获取所有的商家*/
public function getBusinessAll()
public function getBusinessAll($roles = "",$businessCode ="")
{
$roles = array_filter( explode(",",$roles));
$isAdmin = true;
//如果是 渠道商或者工作人员
if(
in_array(Member::ANENT_ROLE_ID,$roles)
||
in_array(Member::STAFF_ROLE_ID,$roles)
){
$isAdmin=false;
}
return Business::alias("a")
->join("account b", "a.code = b.business_code")
->field("a.code , a.business_name , a.contact_name")
->when(!$isAdmin,function ($q)use($businessCode){
$q->where("a.agency_code",$businessCode);
})
->order("a.id desc")
->group("a.id")
->select();

View File

@ -35,8 +35,7 @@
<select name="business_code" lay-search="" >
<option value=""></option>
{foreach $business as $bitem}
<option value="{$bitem['code']}" {if $bitem['code']== $item['business_code']} selected {/if} >
{$bitem['contact_name']}_{$bitem['business_name']}</option>
<option value="{$bitem['code']}" {if $bitem['code']== $item['business_code']} selected {/if} >{$bitem['contact_name']}_{$bitem['business_name']}</option>
{/foreach}
</select>
</div>