master
wangxinglong 2021-12-22 15:45:48 +08:00
parent 5027b94738
commit 766829c406
1 changed files with 10 additions and 7 deletions

View File

@ -5,8 +5,8 @@ namespace app\controller\manager;
use app\exception\RepositoryException;
use app\model\CouponMain;
use app\model\Member;
use app\model\Business as BusinessModel;
use app\model\Member as MemberModel;
use app\repository\BusinessRepository;
use app\repository\CouponRepository;
use app\validate\CouponRelease;
@ -71,31 +71,32 @@ class Coupon extends Base
return $q::hasWhere('business', function ($q) use ($keyword) {
$q->where('business_name', 'like', "%" . $keyword . "%")
//如果是渠道商或者工作人员 只查看自己的下级商家
->when(Member::is_agency($this->auth['roles']), function ($q) {
->when(MemberModel::is_agency($this->auth['roles']), function ($q) {
$q->where('agency_code', '=', $this->auth['business_code']);
})
->field("code,business_name,business_subtitle,type");
->field("code,business_name,business_subtitle,type,agency_code");
//->with('category');
});
}
if (Member::is_agency($this->auth['roles'])) {
if (MemberModel::is_agency($this->auth['roles'])) {
return $q::hasWhere('business', function ($q) {
$q//如果是渠道商或者工作人员 只查看自己的下级商家
->where('agency_code', '=', $this->auth['business_code'])
->field("code,business_name,business_subtitle,type");
->field("code,business_name,business_subtitle,type,agency_code");
//->with('category');
});
} else {
return $q->with(["business" => function ($query) {
$query->field("code,business_name,business_subtitle,type");
$query->field("code,business_name,business_subtitle,type,agency_code");
//->with('category');
}]);
}
}, $orders);
$time = time();
$list['list']->each(function ($item) use ($time) {
if (strtotime($item->start_time) > $time) {
$item->state_text = '<span >未开始</span>';
@ -105,8 +106,10 @@ class Coupon extends Base
$item->state_text = '<span class="f_red">已过期</span>';
}
//渠道商名称
if(isset($item->business) && $item->business && !empty($item->business->agency_code)){
$item->agency_text = BusinessModel::where("code",$time->item->business->agency_code)->value("business_name",'');
$item->agency_text = MemberModel::whereRaw("FIND_IN_SET('".MemberModel::ANENT_ROLE_ID."',roles)" )
->where("business_code",$item->business->agency_code)->value("nickname","");
}else{
$item->agency_text = '';
}