setter
parent
492f2b9a13
commit
f9642ea6cd
|
@ -4,6 +4,7 @@ namespace app\controller\manager;
|
||||||
|
|
||||||
use app\model\Business as BusinessModel;
|
use app\model\Business as BusinessModel;
|
||||||
use app\model\Log;
|
use app\model\Log;
|
||||||
|
use app\model\Member;
|
||||||
use app\model\Member as MemberModel;
|
use app\model\Member as MemberModel;
|
||||||
use app\repository\BusinessRepository;
|
use app\repository\BusinessRepository;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
@ -30,6 +31,11 @@ class Agency extends Base
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
if ($this->request->isPost()) {
|
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.');
|
$item = input('post.');
|
||||||
|
|
||||||
$validate = $this->validateByApi($item, [
|
$validate = $this->validateByApi($item, [
|
||||||
|
@ -71,8 +77,6 @@ class Agency extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->data['roleJson'] = $this->roleJson();
|
$this->data['roleJson'] = $this->roleJson();
|
||||||
$this->data['business'] = BusinessRepository::getInstance()->getBusinessAll();
|
|
||||||
|
|
||||||
return $this->view();
|
return $this->view();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +131,7 @@ class Agency extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->data['roleJson'] = $this->roleJson();
|
$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();
|
return $this->view();
|
||||||
}
|
}
|
||||||
|
@ -256,7 +260,7 @@ class Agency extends Base
|
||||||
|
|
||||||
$this->data['item'] = $info;
|
$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();
|
return $this->view();
|
||||||
}
|
}
|
||||||
|
@ -287,7 +291,7 @@ class Agency extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渠道商列表
|
* 代理商列表
|
||||||
*
|
*
|
||||||
* @return Json|View
|
* @return Json|View
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
|
@ -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();
|
$this->data['type'] = CouponRepository::getInstance()->getCouponTypeAll();
|
||||||
return $this->view('add');
|
return $this->view('add');
|
||||||
|
|
||||||
|
@ -537,7 +539,7 @@ class Coupon extends Base
|
||||||
if (empty($couponMain)) {
|
if (empty($couponMain)) {
|
||||||
return $this->error("签到券不存在");
|
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['type'] = CouponRepository::getInstance()->getCouponTypeAll();
|
||||||
$this->data['item'] = $couponMain;
|
$this->data['item'] = $couponMain;
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ class Member extends Base
|
||||||
$this->data['item'] = $info;
|
$this->data['item'] = $info;
|
||||||
$this->data['roleJson'] = $this->roleJson(explode(',', $info['roles']));
|
$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();
|
return $this->view();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ use app\model\Account;
|
||||||
use app\model\Business;
|
use app\model\Business;
|
||||||
use app\model\CouponMain;
|
use app\model\CouponMain;
|
||||||
use app\model\Deduction;
|
use app\model\Deduction;
|
||||||
|
use app\model\Member;
|
||||||
use app\model\Recharge;
|
use app\model\Recharge;
|
||||||
use app\service\Repository;
|
use app\service\Repository;
|
||||||
use app\traits\account\ApplyStaffTrait;
|
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")
|
return Business::alias("a")
|
||||||
->join("account b", "a.code = b.business_code")
|
->join("account b", "a.code = b.business_code")
|
||||||
->field("a.code , a.business_name , a.contact_name")
|
->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")
|
->order("a.id desc")
|
||||||
->group("a.id")
|
->group("a.id")
|
||||||
->select();
|
->select();
|
||||||
|
|
|
@ -35,8 +35,7 @@
|
||||||
<select name="business_code" lay-search="" >
|
<select name="business_code" lay-search="" >
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
{foreach $business as $bitem}
|
{foreach $business as $bitem}
|
||||||
<option value="{$bitem['code']}" {if $bitem['code']== $item['business_code']} selected {/if} >
|
<option value="{$bitem['code']}" {if $bitem['code']== $item['business_code']} selected {/if} >{$bitem['contact_name']}_{$bitem['business_name']}</option>
|
||||||
{$bitem['contact_name']}_{$bitem['business_name']}</option>
|
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue