...
|
...
|
@@ -11,6 +11,7 @@ use app\mobile\model\CompanyUser; |
|
|
use addons\epay\library\Service;
|
|
|
use app\mobile\model\Question;
|
|
|
use app\mobile\model\QuestionAnswer;
|
|
|
use app\mobile\model\User;
|
|
|
|
|
|
/**
|
|
|
* 密卷接口
|
...
|
...
|
@@ -42,15 +43,62 @@ class Secret extends Api |
|
|
"title": "测试密卷", //密卷标题
|
|
|
"do_num": 20, //做过人数
|
|
|
"current_price": "10.00", //现价
|
|
|
"original_price": "10000.00" //原价
|
|
|
"original_price": "10000.00", //原价
|
|
|
"is_buy": 0 //是否已购买:0=否,1=是
|
|
|
}]
|
|
|
})
|
|
|
*/
|
|
|
public function index()
|
|
|
{
|
|
|
$list = $this->model->order('createtime desc')->select();
|
|
|
// 我加入的企业购买的密卷
|
|
|
$company_secret_list = SecretOrder::alias('a')
|
|
|
->join('mobile_company_user b','b.company_id = a.company_id')
|
|
|
->where('b.user_id',$this->auth->id)
|
|
|
->where('b.status','1')
|
|
|
->field('a.id,a.company_id,a.people_num,a.is_top')
|
|
|
->select();
|
|
|
// 查询我是否可以享受企业密卷(按企业审核时间排队,没在队伍里就无法享受企业密卷)
|
|
|
$secret_id_arr = [];
|
|
|
foreach ($company_secret_list as $v) {
|
|
|
if($v['is_top'] == '1'){
|
|
|
$secret_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)){
|
|
|
$secret_id_arr[] = $v['id'];
|
|
|
}
|
|
|
}
|
|
|
// 查找所有我购买的和企业购买的密卷
|
|
|
$secret_order = SecretOrder::where(function($query)use($secret_id_arr){
|
|
|
$query->where('user_id', $this->auth->id)->whereor('id', 'in', $secret_id_arr);
|
|
|
})
|
|
|
->where('pay_status','1')
|
|
|
->limit(1)
|
|
|
->buildSql();
|
|
|
$list = $this->model
|
|
|
->alias('s')
|
|
|
->join([$secret_order => 'so'],'so.secret_id = s.id','left')
|
|
|
->field("
|
|
|
s.*,
|
|
|
if(so.id > 0,1,0) is_buy
|
|
|
")
|
|
|
->order('createtime desc')
|
|
|
->select();
|
|
|
foreach ($list as $v) {
|
|
|
$v->visible(['id','title','do_num','current_price','original_price']);
|
|
|
$v->visible([
|
|
|
'id',
|
|
|
'title',
|
|
|
'do_num',
|
|
|
'current_price',
|
|
|
'original_price'
|
|
|
])->append([
|
|
|
'is_buy'
|
|
|
]);
|
|
|
}
|
|
|
$this->success('成功',$list);
|
|
|
}
|
...
|
...
|
@@ -87,6 +135,28 @@ class Secret extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (获取用户身份)
|
|
|
* @ApiSummary (获取用户身份)
|
|
|
* @ApiMethod (POST)
|
|
|
*
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1599739316",
|
|
|
"data": {
|
|
|
"group_id": 1, //0=普通用户,1=企业用户
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function getUserIdentity()
|
|
|
{
|
|
|
$group_id = User::where('id',$this->auth->id)->value('group_id');
|
|
|
$this->success('成功',compact('group_id'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (选择规格)
|
|
|
* @ApiSummary (选择规格)
|
|
|
* @ApiMethod (POST)
|
...
|
...
|
|