作者 何书鹏
1 个管道 的构建 失败 耗费 0 秒

测试代码部署

@@ -3,19 +3,19 @@ stages: @@ -3,19 +3,19 @@ stages:
3 - pull 3 - pull
4 4
5 # job 华为测试服务添加自动部署 5 # job 华为测试服务添加自动部署
6 -#job1:  
7 -# stage: pull  
8 -# tags:  
9 -# - huawei8  
10 -# script:  
11 -# - cd /home/wwwroot/t/enterprise  
12 -# - git pull  
13 -  
14 -# job 华为正式服务器添加自动部署 两个job同时存在为同时向两个服务器推送  
15 -job2: 6 +job1:
16 stage: pull 7 stage: pull
17 tags: 8 tags:
18 - - huawei9 9 + - huawei8
19 script: 10 script:
20 - - cd /home/wwwroot/fast/enterprise  
21 - - git pull  
  11 + - cd /home/wwwroot/t/enterprise
  12 + - git pull
  13 +
  14 +# job 华为正式服务器添加自动部署 两个job同时存在为同时向两个服务器推送
  15 +#job2:
  16 +# stage: pull
  17 +# tags:
  18 +# - huawei9
  19 +# script:
  20 +# - cd /home/wwwroot/fast/enterprise
  21 +# - git pull
@@ -306,6 +306,24 @@ class Course extends Api @@ -306,6 +306,24 @@ class Course extends Api
306 } 306 }
307 307
308 /** 308 /**
  309 + * @ApiTitle (套餐说明)
  310 + * @ApiSummary (套餐说明)
  311 + * @ApiMethod (POST)
  312 + *
  313 + * @ApiReturn({
  314 + "code": 1,
  315 + "msg": "成功",
  316 + "time": "1599017563",
  317 + "data": "套餐说明" //套餐说明内容
  318 + })
  319 + */
  320 + public function spec_intro()
  321 + {
  322 + $content = Db::name('mobile_config')->where('id',1)->value('course_spec_intro');
  323 + $this->success('成功', $content);
  324 + }
  325 +
  326 + /**
309 * @ApiTitle (购买预览) 327 * @ApiTitle (购买预览)
310 * @ApiSummary (购买预览) 328 * @ApiSummary (购买预览)
311 * @ApiMethod (POST) 329 * @ApiMethod (POST)
@@ -138,6 +138,24 @@ class Secret extends Api @@ -138,6 +138,24 @@ class Secret extends Api
138 } 138 }
139 139
140 /** 140 /**
  141 + * @ApiTitle (套餐说明)
  142 + * @ApiSummary (套餐说明)
  143 + * @ApiMethod (POST)
  144 + *
  145 + * @ApiReturn({
  146 + "code": 1,
  147 + "msg": "成功",
  148 + "time": "1599017563",
  149 + "data": "套餐说明" //套餐说明内容
  150 + })
  151 + */
  152 + public function spec_intro()
  153 + {
  154 + $content = Db::name('mobile_config')->where('id',1)->value('secret_spec_intro');
  155 + $this->success('成功', $content);
  156 + }
  157 +
  158 + /**
141 * @ApiTitle (购买预览) 159 * @ApiTitle (购买预览)
142 * @ApiSummary (购买预览) 160 * @ApiSummary (购买预览)
143 * @ApiMethod (POST) 161 * @ApiMethod (POST)
@@ -14,6 +14,8 @@ use app\mobile\model\Agreement; @@ -14,6 +14,8 @@ use app\mobile\model\Agreement;
14 use app\mobile\model\Exam; 14 use app\mobile\model\Exam;
15 use app\mobile\model\CourseOrder; 15 use app\mobile\model\CourseOrder;
16 use app\mobile\model\CourseAppraise; 16 use app\mobile\model\CourseAppraise;
  17 +use app\mobile\model\SecretOrder;
  18 +use app\mobile\model\ScoreSpec;
17 19
18 /** 20 /**
19 * 我的接口 21 * 我的接口
@@ -272,7 +274,7 @@ class User extends Api @@ -272,7 +274,7 @@ class User extends Api
272 public function index() 274 public function index()
273 { 275 {
274 $user = $this->auth->getUser(); 276 $user = $this->auth->getUser();
275 - $this->success('成功', $content); 277 + $this->success('成功', $user);
276 } 278 }
277 279
278 /** 280 /**
@@ -543,4 +545,192 @@ class User extends Api @@ -543,4 +545,192 @@ class User extends Api
543 ]); 545 ]);
544 $this->success('评价成功'); 546 $this->success('评价成功');
545 } 547 }
  548 +
  549 + /**
  550 + * @ApiTitle (我的密卷)
  551 + * @ApiSummary (我的密卷)
  552 + * @ApiMethod (POST)
  553 + *
  554 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  555 + *
  556 + * @ApiReturn({
  557 + "code": 1,
  558 + "msg": "成功",
  559 + "time": "1600081718",
  560 + "data": [{
  561 + "id": 9, //密卷订单ID
  562 + "pay_price": "50.00", //实际支付金额
  563 + "secret": { //密卷信息
  564 + "title": "测试密卷", //密卷标题
  565 + "do_num": "" //做过人数
  566 + },
  567 + "is_have_qi": 0 //是否有企字:0=否,1=是
  568 + }]
  569 + })
  570 + */
  571 + public function mySecret(){
  572 + // 我加入的企业购买的密卷
  573 + $company_secret_list = SecretOrder::alias('a')
  574 + ->join('mobile_company_user b','b.company_id = a.company_id')
  575 + ->where('b.user_id',$this->auth->id)
  576 + ->where('b.status','1')
  577 + ->field('a.id,a.company_id,a.people_num')
  578 + ->select();
  579 + // 查询我是否可以享受企业密卷(按企业审核时间排队,没在队伍里就无法享受企业密卷)
  580 + $secret_id_arr = [];
  581 + foreach ($company_secret_list as $v) {
  582 + $user_id_arr = CompanyUser::where('company_id',$v['company_id'])
  583 + ->where('status','1')
  584 + ->order('updatetime asc')
  585 + ->limit($v['people_num'])
  586 + ->column('user_id');
  587 + if(in_array($this->auth->id,$user_id_arr)){
  588 + $secret_id_arr[] = $v['id'];
  589 + }
  590 + }
  591 + // 查找所有密卷
  592 + $list = SecretOrder::with(['secret'])
  593 + ->where(function($query)use($secret_id_arr){
  594 + $query->where('user_id', $this->auth->id)->whereor('id', 'in', $secret_id_arr);
  595 + })
  596 + ->where('pay_status','1')
  597 + ->select();
  598 + foreach ($list as $v) {
  599 + $v['is_have_qi'] = in_array($v['id'], $secret_id_arr) ? 1 : 0;
  600 + $v->visible(['id','pay_price','secret'])->append(['is_have_qi']);
  601 + $v->getRelation('secret')->visible(['cover','title']);
  602 + }
  603 + $this->success('成功',$list);
  604 + }
  605 +
  606 + /**
  607 + * @ApiTitle (我的积分)
  608 + * @ApiSummary (我的积分)
  609 + * @ApiMethod (POST)
  610 + *
  611 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  612 + *
  613 + * @ApiReturn({
  614 + "code": 1,
  615 + "msg": "成功",
  616 + "time": "1600135095",
  617 + "data": {
  618 + "id": 16, //用户ID
  619 + "score": 0, //当前积分
  620 + "url": "/u/16",
  621 + "max_score": 0 //累计积分
  622 + }
  623 + })
  624 + */
  625 + public function myScore(){
  626 + $user = $this->auth->getUser();
  627 + $user['max_score'] = db('user_score_log')->where('user_id',$user['id'])->max('after');
  628 + $user = $user->visible(['id','score'])->append(['max_score'])->toArray();
  629 + $this->success('成功',$user);
  630 + }
  631 +
  632 + /**
  633 + * @ApiTitle (积分说明)
  634 + * @ApiSummary (积分说明)
  635 + * @ApiMethod (POST)
  636 + *
  637 + * @ApiReturn({
  638 + "code": 1,
  639 + "msg": "成功",
  640 + "time": "1599017563",
  641 + "data": "积分说明" //积分说明内容
  642 + })
  643 + */
  644 + public function scoreIntro()
  645 + {
  646 + $content = Db::name('mobile_config')->where('id',1)->value('user_score_intro');
  647 + $this->success('成功', $content);
  648 + }
  649 +
  650 + /**
  651 + * @ApiTitle (积分记录)
  652 + * @ApiSummary (积分记录)
  653 + * @ApiMethod (POST)
  654 + *
  655 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  656 + * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
  657 + * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
  658 + *
  659 + * @ApiReturn({
  660 + "code": 1,
  661 + "msg": "成功",
  662 + "time": "1599017563",
  663 + "data": "积分说明" //积分说明内容
  664 + })
  665 + */
  666 + public function scoreLog()
  667 + {
  668 + $list = \app\common\model\ScoreLog::where('user_id',$this->auth->id)
  669 + ->order('createtime desc')
  670 + ->paginate($page_num,false,['page'=>$page])
  671 + ->each(function($v){
  672 + $v['createtime'] = date('Y.m.d H:i',$v['createtime']);
  673 + })->toArray();
  674 + $this->success('成功', $content);
  675 + }
  676 +
  677 + /**
  678 + * @ApiTitle (海报分享)
  679 + * @ApiSummary (海报分享)
  680 + * @ApiMethod (POST)
  681 + *
  682 + * @ApiReturn({
  683 + "code": 1,
  684 + "msg": "成功",
  685 + "time": "1599017563",
  686 + "data": "积分说明" //积分说明内容
  687 + })
  688 + */
  689 + public function share()
  690 + {
  691 + $content = Db::name('mobile_config')->where('id',1)->value('user_score_intro');
  692 + $this->success('成功', $content);
  693 + }
  694 +
  695 + /**
  696 + * @ApiTitle (充值积分-套餐)
  697 + * @ApiSummary (充值积分-套餐)
  698 + * @ApiMethod (POST)
  699 + *
  700 + * @ApiReturn({
  701 + "code": 1,
  702 + "msg": "成功",
  703 + "time": "1599017563",
  704 + "data": "积分说明" //积分说明内容
  705 + })
  706 + */
  707 + public function scoreSpec()
  708 + {
  709 + $list = ScoreSpec::select();
  710 + $score_recharge_price = Db::name('mobile_config')->where('id',1)->value('score_recharge_price');
  711 + $this->success('成功', compact('list','score_recharge_price'));
  712 + }
  713 +
  714 + /**
  715 + * @ApiTitle (充值积分)
  716 + * @ApiSummary (充值积分)
  717 + * @ApiMethod (POST)
  718 + *
  719 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  720 + * @ApiParams (name="score_spec_id", type="int", required=false, description="积分套餐ID")
  721 + * @ApiParams (name="score", type="int", required=true, description="评价星数")
  722 + *
  723 + * @ApiReturn({
  724 + "code": 1,
  725 + "msg": "成功",
  726 + "time": "1599017563",
  727 + "data": "积分说明" //积分说明内容
  728 + })
  729 + */
  730 + public function scoreRecharge()
  731 + {
  732 +
  733 + $content = Db::name('mobile_config')->where('id',1)->value('user_score_intro');
  734 + $this->success('成功', $content);
  735 + }
546 } 736 }
  1 +<?php
  2 +namespace app\mobile\model;
  3 +
  4 +use think\Model;
  5 +use think\Db;
  6 +
  7 +class ScoreOrder extends Model
  8 +{
  9 + // 表名
  10 + protected $name = 'mobile_score_order';
  11 + // 开启自动写入时间戳字段
  12 + protected $autoWriteTimestamp = 'int';
  13 + // 定义时间戳字段名
  14 + protected $createTime = 'createtime';
  15 + protected $updateTime = 'updatetime';
  16 +
  17 + /**
  18 + * 新增订单
  19 + */
  20 + public function add($user, $order, $pay_type)
  21 + {
  22 + Db::startTrans();
  23 + $save_data = [
  24 + 'user_id' => $user['id'],
  25 + 'score_spec_id' => $order['info']['id'],
  26 + 'order_sn' => get_order_sn(),
  27 + 'pay_price' => $order['pay_price'],
  28 + 'pay_type' => $pay_type,
  29 + 'score' => $order['score']
  30 + ];
  31 + $this->save([
  32 + 'user_id' => $user['id'],
  33 + 'score_spec_id' => $order['info']['id'],
  34 + 'order_sn' => get_order_sn(),
  35 + 'pay_price' => $order['pay_price'],
  36 + 'pay_type' => $pay_type,
  37 + 'score' => $order['score']
  38 + ]);
  39 + // 用掉积分
  40 + \app\common\model\User::score($order['score'],$user['id'],'充值积分');
  41 + Db::commit();
  42 + return true;
  43 + }
  44 +}
  1 +<?php
  2 +namespace app\mobile\model;
  3 +
  4 +use think\Model;
  5 +
  6 +class ScoreSpec extends Model
  7 +{
  8 + // 表名
  9 + protected $name = 'mobile_score_spec';
  10 + // 开启自动写入时间戳字段
  11 + protected $autoWriteTimestamp = 'int';
  12 + // 定义时间戳字段名
  13 + protected $createTime = 'createtime';
  14 + protected $updateTime = 'updatetime';
  15 +
  16 + // 追加属性
  17 + protected $append = [
  18 + 'score'
  19 + ];
  20 +
  21 + public function getScoreAttr($value,$data){
  22 + return $data['spec_score'] + $data['give_score'];
  23 + }
  24 +}
此 diff 太大无法显示。