...
|
...
|
@@ -132,7 +132,41 @@ class Secret extends Api |
|
|
empty($secret_id) && $this->error('缺少必要参数');
|
|
|
$info = $this->model->get($secret_id);
|
|
|
empty($info) && $this->error('密卷信息不存在');
|
|
|
$info = $info->visible(['id','title','current_price','original_price','do_num','description']);
|
|
|
// 是否已购买
|
|
|
// 我加入的企业购买的密卷
|
|
|
$company_secret_list = SecretOrder::alias('a')
|
|
|
->join('mobile_company_user b','b.company_id = a.company_id')
|
|
|
->join('user c','c.id = b.user_id')
|
|
|
->where('b.user_id',$this->auth->id)
|
|
|
->where('b.status','1')
|
|
|
->where('c.group_id',1)
|
|
|
->field('a.id,a.company_id,a.people_num,a.is_top')
|
|
|
->select();
|
|
|
// 查询我是否可以享受企业密卷(按企业审核时间排队,没在队伍里就无法享受企业密卷)
|
|
|
$order_id_arr = [];
|
|
|
foreach ($company_secret_list as $v) {
|
|
|
if($v['is_top'] == '1'){
|
|
|
$order_id_arr[] = $v['id'];
|
|
|
continue;
|
|
|
}
|
|
|
$user_id_arr = CompanyUser::where('company_id',$v['company_id'])
|
|
|
->where('status','1')
|
|
|
->order('updatetime asc')
|
|
|
->limit($v['people_num'])
|
|
|
->column('user_id');
|
|
|
if(in_array($this->auth->id,$user_id_arr)){
|
|
|
$order_id_arr[] = $v['id'];
|
|
|
}
|
|
|
}
|
|
|
$order = SecretOrder::where(function($query)use($order_id_arr){
|
|
|
$query->where('user_id', $this->auth->id)->whereor('id', 'in', $order_id_arr);
|
|
|
})
|
|
|
->where('secret_id',$secret_id)
|
|
|
->where('pay_status','1')
|
|
|
->field('id')
|
|
|
->find();
|
|
|
$info->is_buy = !empty($order) ? 1 : 0;
|
|
|
$info = $info->visible(['id','title','current_price','original_price','do_num','description'])->append(['is_buy']);
|
|
|
$this->success('成功',$info);
|
|
|
}
|
|
|
|
...
|
...
|
|