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

个人中心接口

... ... @@ -20,7 +20,7 @@ class GoodsController extends RestBaseController
*/
public function index()
{
$data=Db::name('goods')->where('status',1)->field('id,goods_name,before_price,now_price,vip_price,content')->select()->each(function ($item) {
$data=Db::name('goods')->where('status',1)->field('id,goods_name,before_price,now_price,vip_price,content,image')->select()->each(function ($item) {
$item['image'] =cmf_get_image_preview_url($item['image']);
return $item;
})->toArray();
... ... @@ -40,14 +40,14 @@ class GoodsController extends RestBaseController
public function goodsOrder()
{
$param=$this->request->param();
$data=Db::name('goods')->where('id',$param['id'])->field('id,goods_name,before_price,now_price,vip_price,content')->find();
$data=Db::name('goods')->where('id',$param['id'])->field('id,goods_name,before_price,now_price,vip_price,content,image')->find();
$status=Db::name('user')->where('id',$this->getUserId())->find()['status'];
if ($status==1){
$data['price']=$data['now_price'];
}else if ($status==2){
$data['price']=$data['vip_price'];
}
$data['image']=mf_get_image_preview_url($data['image']);
$data['image']=cmf_get_image_preview_url($data['image']);
$data['address']=Db::name('address')->where(['user_id'=>$this->getUserId(),'status'=>1])->field('id,address')->find();
$this->success('订单详情信息',$data);
}
... ... @@ -84,6 +84,7 @@ class GoodsController extends RestBaseController
]);
if ($re) {
Db::name('user')->where('id',$this->getUserId())->setDec('score',$param['score']);
Db::name('user_score_log')->insert(['user_id'=>$this->getUserId(),'score'=>$param['score'],'action'=>'消费','now_score'=>$user_score-$param]);
$this->success('兑换成功',1);
}else{
$this->error('兑换失败',3);
... ...
... ... @@ -17,7 +17,7 @@ class SignController extends RestBaseController
* @url /portal/Sign/index
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @return sign:1是早打卡,2是午打卡,3是晚打卡,4是睡前打卡,0是当前不在打卡时间
* @return sign:1是早打卡,2是午打卡,3是晚打卡,4是睡前打卡,0不能打卡
* @return slogan:口号
*/
public function index()
... ... @@ -137,14 +137,18 @@ class SignController extends RestBaseController
*/
public function daySignPost(){
$param=$this->request->param();
//根据星期判断music,image
$date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日
$config=Db::name('sign_image')->where('date',$date)->find();
$music=json_decode($config['music'],true);
$music=$music[rand(0,count($music,0)-1)];
$user=Db::name('user')->where('id',$this->getUserId())->find();
$config=[];
$music=[];
//根据签到种类判断增加积分数
$score=Db::name('config')->where('id',1)->find();
if ($param['status']==1){
//根据星期判断music,image(只有早签到)
$date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日
$config=Db::name('sign_image')->where('date',$date)->find();
$music=json_decode($config['music'],true);
$music=$music[rand(0,count($music,0)-1)];
//早签到积分
$score=$score['morning_sign_score'];
$type='morning';
}elseif ($param['status']==2){
... ... @@ -172,7 +176,7 @@ class SignController extends RestBaseController
Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
//判断是否为连续打卡
$last=Db::name('user_sign')->where(['user_id'=>$this->getUserId(),'status'=>1,'create_time'=>[ 'between time', [$yesterday,$beginToday]]])->find();
$user=Db::name('user')->where('id',$this->getUserId())->find();
if ($user['stay_sign_day']==0||$last)
{
Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
... ... @@ -189,12 +193,10 @@ class SignController extends RestBaseController
}
//记录打卡积分
Db::name('user')->where('id',$this->getUserId())->setInc('score',$score);
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']]);
Db::name('user_score_log')->insert(['score'=>$score,'create_time'=>time(),'action'=>'打卡','user_id'=>$this->getUserId(),'now_score'=>$user['score']+$score]);
//判断是否需要进行周打卡
if (!Db::name('user_week_sign')->where('user_id',$this->getUserId())->find()){
$is_week=1;
}elseif (Db::name('user_week_sign')->where(['user_id'=>$this->getUserId(),'create_time'=>[ '<', $beginToday-($score['week_sign']*24*60*60)]])->find()){
if (Db::name('user_week_sign')->where(['user_id'=>$this->getUserId(),'create_time'=>[ '<', $beginToday-($score['week_sign']*24*60*60)]])->find()){
$is_week=1;
}else{
$is_week=0;
... ...
... ... @@ -8,10 +8,9 @@ class Doc
'version'=>'1.0.0',
'copyright'=>'银河百荣科技',
'controller' => [
'api\\home\\controller\\IndexController',
'api\\portal\\controller\\GoodsController',
'api\\portal\\controller\\SignController'
'api\\portal\\controller\\SignController',
'api\\portal\\controller\\UserController',
],
'password'=>'',
'static_path'=>'',
... ...