作者 宋国杰
1 个管道 的构建 失败 耗费 12 秒

在家接口开发

<?php
namespace api\common\model;
use think\Model;
class ActivityModel extends Model
{
}
\ No newline at end of file
... ...
<?php
namespace api\common\model;
use think\Model;
class ClockModel extends Model
{
protected $name = 'clock';
protected $append = [
'status_text',
'user_start_text',
'user_end_text',
];
public function getStatusTextAttr($value,$data)
{
$status = [0=>'未打卡',1=>'已开始',2=>'完成打卡',3=>'未完成'];
return $status[$data['status']];
}
public function getUserStartTextAttr($value,$data){
if (empty($data['user_start'])){
return;
}
return date('H:i',$data['user_start']);
}
public function getUserEndTextAttr($value,$data){
if (empty($data['user_end'])){
return;
}
return date('H:i',$data['user_end']);
}
public function activity()
{
return $this->belongsTo('ActivityModel', 'activity_id', 'id', [], 'LEFT')->setEagerlyType(1);
}
}
\ No newline at end of file
... ...
... ... @@ -13,6 +13,7 @@ use api\common\model\ActivityNews;
use api\common\model\AddressModel;
use api\common\model\ClassModel;
use api\common\model\ClassQuestionModel;
use api\common\model\ClockModel;
use api\common\model\GoodsModel;
use api\common\model\LevelModel;
use api\common\model\NewsTypeMode;
... ... @@ -947,9 +948,7 @@ class SecondController extends RestBaseController
*@return expend:消耗工时
*@return good:商品信息
*
*
*
* @throws
*@throws
*/
public function orderInfo(){
$userId=$this->getUserId();
... ... @@ -960,4 +959,98 @@ class SecondController extends RestBaseController
}
/**
* @title 活动列表
* @description 活动列表
* @author sgj
* @url /index/second/activityList
* @method POST
*
*
*@param name:id type:int require:1 other: desc:订单id
*@header name:XX-Token require:1 default: desc:token
*
*@return order_sn:订单号
*@return content_info:虚拟订单信息
*@return is_real:是否为虚拟订单
*@return expend:消耗工时
*@return good:商品信息
*
*@throws
*/
public function activityList(){
$userId=$this->getUserId();
$Clock=new ClockModel();
$map['user_id']=$userId;
$info=$Clock->where($map)->with(['activity'])->select();
$this->success('',$info);
}
/**
* @title 开始打卡
* @description 开始打卡
* @author sgj
* @url /index/second/startClock
* @method POST
*
*
*@param name:id type:int require:1 other: desc:订单id
*@header name:XX-Token require:1 default: desc:token
*
*
*@throws
*/
public function startClock(){
}
/**
* @title 结束打卡
* @description 结束打卡
* @author sgj
* @url /index/second/endClock
* @method POST
*
*
*@param name:id type:int require:1 other: desc:订单id
*@header name:XX-Token require:1 default: desc:token
*
*
*@throws
*/
public function endClock(){
}
/**
* @title 打卡详情
* @description 打卡详情
* @author sgj
* @url /index/second/clockInfo
* @method POST
*
*
*@param name:id type:int require:1 other: desc:id
*@header name:XX-Token require:1 default: desc:token
*
*@return activity_name:活动名称
*@return content_info:虚拟订单信息
*@return is_real:是否为虚拟订单
*@return expend:消耗工时
*@return good:商品信息
*
*@throws
*/
public function clockInfo(){
$id=input('id');
$Clock=new ClockModel();
$info=$Clock->where('id',$id)->with(['Activity'])->find();
$this->success('',$info);
}
}
\ No newline at end of file
... ...