作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

bug修改

... ... @@ -527,25 +527,32 @@ class User extends Api
* @ApiMethod (POST)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
* @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1600081718",
"data": [{
"id": 9, //课程订单ID
"pay_price": "50.00", //实际支付金额
"course": { //课程信息
"id": 1, //课程ID
"title": "测试课程", //课程标题
"cover": "" //课程封面图
},
"is_have_qi": 0 //是否有企字:0=否,1=是
"is_have_appraise": 0 //是否已评价:0=否,1=是
}]
"data": {
"total": 1, // 数据总数
"list": [{
"id": 9, //课程订单ID
"pay_price": "50.00", //实际支付金额
"course": { //课程信息
"id": 1, //课程ID
"title": "测试课程", //课程标题
"cover": "" //课程封面图
},
"is_have_qi": 0 //是否有企字:0=否,1=是
"is_have_appraise": 0 //是否已评价:0=否,1=是
}]
}
})
*/
public function myCourse(){
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
// 我加入的企业购买的课程
$company_course_list = CourseOrder::alias('co')
->join('mobile_company_user cu','cu.company_id = co.company_id')
... ... @@ -570,26 +577,27 @@ class User extends Api
}
}
// 查找所有课程
$list = CourseOrder::with(['course'])
$data = CourseOrder::with(['course'])
->where(function($query)use($course_id_arr){
$query->where('user_id', $this->auth->id)->whereor('id', 'in', $course_id_arr);
})
->where('pay_status','1')
->select();
foreach ($list as $v) {
// 是否有企字
$v['is_have_qi'] = in_array($v['id'], $course_id_arr) ? 1 : 0;
// 是否已评价
$have_appraise = CourseAppraise::where('user_id',$this->auth->id)
->where('course_id',$v['course_id'])
->where('course_order_id',$v['id'])
->field('id')
->find();
$v['is_have_appraise'] = !empty($have_appraise) ? 1 : 0;
$v->visible(['id','pay_price','course'])->append(['is_have_qi','is_have_appraise']);
$v->getRelation('course')->visible(['id','cover','title']);
}
$this->success('成功',$list);
->order('createtime desc')
->paginate($page_num,false,['page'=>$page])
->each(function($v)use($course_id_arr){
// 是否有企字
$v['is_have_qi'] = in_array($v['id'], $course_id_arr) ? 1 : 0;
// 是否已评价
$have_appraise = CourseAppraise::where('user_id',$this->auth->id)
->where('course_id',$v['course_id'])
->where('course_order_id',$v['id'])
->field('id')
->find();
$v['is_have_appraise'] = !empty($have_appraise) ? 1 : 0;
$v->visible(['id','pay_price','course'])->append(['is_have_qi','is_have_appraise']);
$v->getRelation('course')->visible(['id','cover','title']);
})->toArray();
$this->success('成功',['total'=>$data['total'],'list'=>$data['data']]);
}
/**
... ... @@ -676,24 +684,31 @@ class User extends Api
* @ApiMethod (POST)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
* @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1600081718",
"data": [{
"id": 9, //密卷订单ID
"pay_price": "50.00", //实际支付金额
"secret": { //密卷信息
"id": 1, //密卷ID
"title": "测试密卷", //密卷标题
"do_num": "" //做过人数
},
"is_have_qi": 0 //是否有企字:0=否,1=是
}]
"data": {
"total": 1, // 数据总数
"list": [{
"id": 9, //密卷订单ID
"pay_price": "50.00", //实际支付金额
"secret": { //密卷信息
"id": 1, //密卷ID
"title": "测试密卷", //密卷标题
"do_num": "" //做过人数
},
"is_have_qi": 0 //是否有企字:0=否,1=是
}]
}
})
*/
public function mySecret(){
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
// 我加入的企业购买的密卷
$company_secret_list = SecretOrder::alias('a')
->join('mobile_company_user b','b.company_id = a.company_id')
... ... @@ -718,18 +733,20 @@ class User extends Api
}
}
// 查找所有密卷
$list = SecretOrder::with(['secret'])
$data = SecretOrder::with(['secret'])
->where(function($query)use($secret_id_arr){
$query->where('user_id', $this->auth->id)->whereor('id', 'in', $secret_id_arr);
})
->where('pay_status','1')
->select();
foreach ($list as $v) {
$v['is_have_qi'] = in_array($v['id'], $secret_id_arr) ? 1 : 0;
$v->visible(['id','pay_price','secret'])->append(['is_have_qi']);
$v->getRelation('secret')->visible(['id','title']);
}
$this->success('成功',$list);
->order('createtime desc')
->paginate($page_num,false,['page'=>$page])
->each(function($v)use($secret_id_arr){
// 是否有企字
$v['is_have_qi'] = in_array($v['id'], $secret_id_arr) ? 1 : 0;
$v->visible(['id','pay_price','secret'])->append(['is_have_qi']);
$v->getRelation('secret')->visible(['id','title']);
})->toArray();
$this->success('成功',['total'=>$data['total'],'list'=>$data['data']]);
}
/**
... ...
... ... @@ -12420,7 +12420,30 @@
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>page</td>
<td>inter</td>
<td></td>
<td>当前页(默认1</td>
</tr>
<tr>
<td>page_num</td>
<td>inter</td>
<td></td>
<td>每页显示数据个数(默认10)</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default">
... ... @@ -12449,7 +12472,12 @@
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/mobile/user/myCourse" method="POST" name="form106" id="form106">
<div class="form-group">
<label class="control-label" for="page">page</label>
<input type="inter" class="form-control input-sm" id="page" placeholder="当前页(默认1" name="page">
</div>
<div class="form-group">
<label class="control-label" for="page_num">page_num</label>
<input type="inter" class="form-control input-sm" id="page_num" placeholder="每页显示数据个数(默认10)" name="page_num">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="106">提交</button>
... ... @@ -12486,17 +12514,20 @@
"code": 1,
"msg": "成功",
"time": "1600081718",
"data": [{
"id": 9, //课程订单ID
"pay_price": "50.00", //实际支付金额
"course": { //课程信息
"id": 1, //课程ID
"title": "测试课程", //课程标题
"cover": "" //课程封面图
},
"is_have_qi": 0 //是否有企字:0=否,1=是
"is_have_appraise": 0 //是否已评价:0=否,1=是
}]
"data": {
"total": 1, // 数据总数
"list": [{
"id": 9, //课程订单ID
"pay_price": "50.00", //实际支付金额
"course": { //课程信息
"id": 1, //课程ID
"title": "测试课程", //课程标题
"cover": "" //课程封面图
},
"is_have_qi": 0 //是否有企字:0=否,1=是
"is_have_appraise": 0 //是否已评价:0=否,1=是
}]
}
}</pre>
</div>
</div>
... ... @@ -12869,7 +12900,30 @@
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>page</td>
<td>inter</td>
<td></td>
<td>当前页(默认1</td>
</tr>
<tr>
<td>page_num</td>
<td>inter</td>
<td></td>
<td>每页显示数据个数(默认10)</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default">
... ... @@ -12898,7 +12952,12 @@
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/mobile/user/mySecret" method="POST" name="form109" id="form109">
<div class="form-group">
<label class="control-label" for="page">page</label>
<input type="inter" class="form-control input-sm" id="page" placeholder="当前页(默认1" name="page">
</div>
<div class="form-group">
<label class="control-label" for="page_num">page_num</label>
<input type="inter" class="form-control input-sm" id="page_num" placeholder="每页显示数据个数(默认10)" name="page_num">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="109">提交</button>
... ... @@ -12935,16 +12994,19 @@
"code": 1,
"msg": "成功",
"time": "1600081718",
"data": [{
"id": 9, //密卷订单ID
"pay_price": "50.00", //实际支付金额
"secret": { //密卷信息
"id": 1, //密卷ID
"title": "测试密卷", //密卷标题
"do_num": "" //做过人数
},
"is_have_qi": 0 //是否有企字:0=否,1=是
}]
"data": {
"total": 1, // 数据总数
"list": [{
"id": 9, //密卷订单ID
"pay_price": "50.00", //实际支付金额
"secret": { //密卷信息
"id": 1, //密卷ID
"title": "测试密卷", //密卷标题
"do_num": "" //做过人数
},
"is_have_qi": 0 //是否有企字:0=否,1=是
}]
}
}</pre>
</div>
</div>
... ... @@ -20823,7 +20885,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2020-10-30 16:51:42 </div>
Generated on 2020-10-31 10:01:05 </div>
<div class="col-md-6" align="right">
<a href="./" target="_blank">企智帮</a>
</div>
... ...