作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

个人中心接口

@@ -20,7 +20,7 @@ class GoodsController extends RestBaseController @@ -20,7 +20,7 @@ class GoodsController extends RestBaseController
20 */ 20 */
21 public function index() 21 public function index()
22 { 22 {
23 - $data=Db::name('goods')->where('status',1)->field('id,goods_name,before_price,now_price,vip_price,content')->select()->each(function ($item) { 23 + $data=Db::name('goods')->where('status',1)->field('id,goods_name,before_price,now_price,vip_price,content,image')->select()->each(function ($item) {
24 $item['image'] =cmf_get_image_preview_url($item['image']); 24 $item['image'] =cmf_get_image_preview_url($item['image']);
25 return $item; 25 return $item;
26 })->toArray(); 26 })->toArray();
@@ -40,14 +40,14 @@ class GoodsController extends RestBaseController @@ -40,14 +40,14 @@ class GoodsController extends RestBaseController
40 public function goodsOrder() 40 public function goodsOrder()
41 { 41 {
42 $param=$this->request->param(); 42 $param=$this->request->param();
43 - $data=Db::name('goods')->where('id',$param['id'])->field('id,goods_name,before_price,now_price,vip_price,content')->find(); 43 + $data=Db::name('goods')->where('id',$param['id'])->field('id,goods_name,before_price,now_price,vip_price,content,image')->find();
44 $status=Db::name('user')->where('id',$this->getUserId())->find()['status']; 44 $status=Db::name('user')->where('id',$this->getUserId())->find()['status'];
45 if ($status==1){ 45 if ($status==1){
46 $data['price']=$data['now_price']; 46 $data['price']=$data['now_price'];
47 }else if ($status==2){ 47 }else if ($status==2){
48 $data['price']=$data['vip_price']; 48 $data['price']=$data['vip_price'];
49 } 49 }
50 - $data['image']=mf_get_image_preview_url($data['image']); 50 + $data['image']=cmf_get_image_preview_url($data['image']);
51 $data['address']=Db::name('address')->where(['user_id'=>$this->getUserId(),'status'=>1])->field('id,address')->find(); 51 $data['address']=Db::name('address')->where(['user_id'=>$this->getUserId(),'status'=>1])->field('id,address')->find();
52 $this->success('订单详情信息',$data); 52 $this->success('订单详情信息',$data);
53 } 53 }
@@ -84,6 +84,7 @@ class GoodsController extends RestBaseController @@ -84,6 +84,7 @@ class GoodsController extends RestBaseController
84 ]); 84 ]);
85 if ($re) { 85 if ($re) {
86 Db::name('user')->where('id',$this->getUserId())->setDec('score',$param['score']); 86 Db::name('user')->where('id',$this->getUserId())->setDec('score',$param['score']);
  87 + Db::name('user_score_log')->insert(['user_id'=>$this->getUserId(),'score'=>$param['score'],'action'=>'消费','now_score'=>$user_score-$param]);
87 $this->success('兑换成功',1); 88 $this->success('兑换成功',1);
88 }else{ 89 }else{
89 $this->error('兑换失败',3); 90 $this->error('兑换失败',3);
@@ -17,7 +17,7 @@ class SignController extends RestBaseController @@ -17,7 +17,7 @@ class SignController extends RestBaseController
17 * @url /portal/Sign/index 17 * @url /portal/Sign/index
18 * @method POST 18 * @method POST
19 * @header name:XX-Token require:1 default: desc:token 19 * @header name:XX-Token require:1 default: desc:token
20 - * @return sign:1是早打卡,2是午打卡,3是晚打卡,4是睡前打卡,0是当前不在打卡时间 20 + * @return sign:1是早打卡,2是午打卡,3是晚打卡,4是睡前打卡,0不能打卡
21 * @return slogan:口号 21 * @return slogan:口号
22 */ 22 */
23 public function index() 23 public function index()
@@ -137,14 +137,18 @@ class SignController extends RestBaseController @@ -137,14 +137,18 @@ class SignController extends RestBaseController
137 */ 137 */
138 public function daySignPost(){ 138 public function daySignPost(){
139 $param=$this->request->param(); 139 $param=$this->request->param();
140 - //根据星期判断music,image 140 + $user=Db::name('user')->where('id',$this->getUserId())->find();
  141 + $config=[];
  142 + $music=[];
  143 + //根据签到种类判断增加积分数
  144 + $score=Db::name('config')->where('id',1)->find();
  145 + if ($param['status']==1){
  146 + //根据星期判断music,image(只有早签到)
141 $date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日 147 $date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日
142 $config=Db::name('sign_image')->where('date',$date)->find(); 148 $config=Db::name('sign_image')->where('date',$date)->find();
143 $music=json_decode($config['music'],true); 149 $music=json_decode($config['music'],true);
144 $music=$music[rand(0,count($music,0)-1)]; 150 $music=$music[rand(0,count($music,0)-1)];
145 - //根据签到种类判断增加积分数  
146 - $score=Db::name('config')->where('id',1)->find();  
147 - if ($param['status']==1){ 151 + //早签到积分
148 $score=$score['morning_sign_score']; 152 $score=$score['morning_sign_score'];
149 $type='morning'; 153 $type='morning';
150 }elseif ($param['status']==2){ 154 }elseif ($param['status']==2){
@@ -172,7 +176,7 @@ class SignController extends RestBaseController @@ -172,7 +176,7 @@ class SignController extends RestBaseController
172 Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1); 176 Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
173 //判断是否为连续打卡 177 //判断是否为连续打卡
174 $last=Db::name('user_sign')->where(['user_id'=>$this->getUserId(),'status'=>1,'create_time'=>[ 'between time', [$yesterday,$beginToday]]])->find(); 178 $last=Db::name('user_sign')->where(['user_id'=>$this->getUserId(),'status'=>1,'create_time'=>[ 'between time', [$yesterday,$beginToday]]])->find();
175 - $user=Db::name('user')->where('id',$this->getUserId())->find(); 179 +
176 if ($user['stay_sign_day']==0||$last) 180 if ($user['stay_sign_day']==0||$last)
177 { 181 {
178 Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1); 182 Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
@@ -189,12 +193,10 @@ class SignController extends RestBaseController @@ -189,12 +193,10 @@ class SignController extends RestBaseController
189 } 193 }
190 //记录打卡积分 194 //记录打卡积分
191 Db::name('user')->where('id',$this->getUserId())->setInc('score',$score); 195 Db::name('user')->where('id',$this->getUserId())->setInc('score',$score);
192 - Db::name('user_score_log')->insert(['score'=>$score,'create_time'=>time(),'action'=>'打卡','user_id'=>$this->getUserId(),'now_score'=>Db::name('user')->where('id',$this->getUserId())->find()['score']]); 196 + Db::name('user_score_log')->insert(['score'=>$score,'create_time'=>time(),'action'=>'打卡','user_id'=>$this->getUserId(),'now_score'=>$user['score']+$score]);
193 197
194 //判断是否需要进行周打卡 198 //判断是否需要进行周打卡
195 - if (!Db::name('user_week_sign')->where('user_id',$this->getUserId())->find()){  
196 - $is_week=1;  
197 - }elseif (Db::name('user_week_sign')->where(['user_id'=>$this->getUserId(),'create_time'=>[ '<', $beginToday-($score['week_sign']*24*60*60)]])->find()){ 199 + if (Db::name('user_week_sign')->where(['user_id'=>$this->getUserId(),'create_time'=>[ '<', $beginToday-($score['week_sign']*24*60*60)]])->find()){
198 $is_week=1; 200 $is_week=1;
199 }else{ 201 }else{
200 $is_week=0; 202 $is_week=0;
@@ -8,10 +8,9 @@ class Doc @@ -8,10 +8,9 @@ class Doc
8 'version'=>'1.0.0', 8 'version'=>'1.0.0',
9 'copyright'=>'银河百荣科技', 9 'copyright'=>'银河百荣科技',
10 'controller' => [ 10 'controller' => [
11 - 'api\\home\\controller\\IndexController',  
12 'api\\portal\\controller\\GoodsController', 11 'api\\portal\\controller\\GoodsController',
13 - 'api\\portal\\controller\\SignController'  
14 - 12 + 'api\\portal\\controller\\SignController',
  13 + 'api\\portal\\controller\\UserController',
15 ], 14 ],
16 'password'=>'', 15 'password'=>'',
17 'static_path'=>'', 16 'static_path'=>'',