...
|
...
|
@@ -16,8 +16,10 @@ use api\common\model\ClassQuestionModel; |
|
|
use api\common\model\GoodsModel;
|
|
|
use api\common\model\LevelModel;
|
|
|
use api\common\model\NewsTypeMode;
|
|
|
use api\common\model\OrderModel;
|
|
|
use api\common\model\TeamModel;
|
|
|
use api\common\model\UserPassModel;
|
|
|
use api\common\model\UserWorkLog;
|
|
|
use api\common\model\VolunteerModel;
|
|
|
use api\index\model\UserModel;
|
|
|
use cmf\controller\RestBaseController;
|
...
|
...
|
@@ -718,4 +720,216 @@ class SecondController extends RestBaseController |
|
|
$this->success('',$return);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 获取默认地址
|
|
|
* @description 获取默认地址
|
|
|
* @author sgj
|
|
|
* @url /index/second/getDefaultAddress
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*@param name:address_id type:int require:1 other: desc:地址id
|
|
|
*
|
|
|
* @return data:地址列表@
|
|
|
* @data name:姓名 province:省 city:市 district:区 address:地址 tel:电话 is_default:是否默认地址
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function getDefaultAddress(){
|
|
|
$userId=$this->getUserId();
|
|
|
$map['user_id']=$userId;
|
|
|
$map['is_default']=1;
|
|
|
$Address=new AddressModel();
|
|
|
$address=$Address->where($map)->find();
|
|
|
$this->success('',$address);
|
|
|
}
|
|
|
/**
|
|
|
* @title 修改地址
|
|
|
* @description 修改地址
|
|
|
* @author sgj
|
|
|
* @url /index/second/editAddress
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*@param name:name type:int require:1 other: desc:姓名
|
|
|
*@param name:province type:int require:1 other: desc:省
|
|
|
*@param name:city type:int require:1 other: desc:市
|
|
|
*@param name:district type:int require:1 other: desc:区
|
|
|
*@param name:address type:int require:1 other: desc:地址
|
|
|
*@param name:is_default type:int require:1 other: desc:是否为默认地址1,是0,否
|
|
|
*@param name:tel type:int require:1 other: desc:电话
|
|
|
*@param name:wx_id type:int require:1 other: desc:微信号
|
|
|
*@param name:mail type:int require:1 other: desc:邮箱
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function editAddress(){
|
|
|
$userId=$this->getUserId();
|
|
|
$param = $this->request->param();
|
|
|
$validate = new Validate([
|
|
|
'id'=>'require',
|
|
|
'name' => 'require',
|
|
|
'tel' => 'require',
|
|
|
'province' => 'require',
|
|
|
'city' => 'require',
|
|
|
'district' => 'require',
|
|
|
'address' => 'require',
|
|
|
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'id'=>'id不能为空',
|
|
|
'name' => '姓名不能为空',
|
|
|
'tel' => '电话不能为空',
|
|
|
'province' => '省市区不能为空',
|
|
|
'city' => '省市区不能为空',
|
|
|
'district' => '省市区不能为空',
|
|
|
'address' => '省市区不能为空',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$Address=new AddressModel();
|
|
|
if ($param['is_default']==1){
|
|
|
$Address->setDefaultBefore($userId);
|
|
|
}
|
|
|
$param['user_id']=$userId;
|
|
|
$result=$Address->save($param);
|
|
|
if ($result>0){
|
|
|
$this->success('修改成功');
|
|
|
}else{
|
|
|
$this->error('修改失败');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 提交订单
|
|
|
* @description 提交订单
|
|
|
* @author sgj
|
|
|
* @url /index/second/commitOrder
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*@param name:good_id type:int require:1 other: desc:商品id
|
|
|
*@param name:num type:int require:1 other: desc:数量
|
|
|
*@param name:address_id type:int require:1 other: desc:地址id
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function commitOrder(){
|
|
|
$userId=$this->getUserId();
|
|
|
$param = $this->request->param();
|
|
|
$validate = new Validate([
|
|
|
'address_id'=>'require',
|
|
|
'num'=>'require',
|
|
|
'good_id'=>'require',
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'address_id'=>'地址id不能为空',
|
|
|
'num'=>'数量不能为空',
|
|
|
'good_id'=>'商品id不能为空',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$goodModel=new GoodsModel();
|
|
|
$good=$goodModel->where('id',$param['good_id'])->find();
|
|
|
if (empty($good)||$good['is_online']!=1){
|
|
|
$this->error('商品错误');
|
|
|
}
|
|
|
/*检查是否有足够工时*/
|
|
|
$Volunter=new VolunteerModel();
|
|
|
$user=$Volunter->where('user_id',$userId)->find();
|
|
|
$user_time=$user['work_time']-$user['use_time'];
|
|
|
$good_time=$good['work_time']*$param['num'];
|
|
|
if ($user_time<$good_time){
|
|
|
$this->error('用户工时不足');
|
|
|
}
|
|
|
/*开始扣除*/
|
|
|
$Volunter->where('user_id',$userId)->setInc('use_time',$good_time);
|
|
|
$Log= new UserWorkLog();
|
|
|
$Log->addLog($userId,1,$good_time);
|
|
|
/*生成订单*/
|
|
|
$Order=new OrderModel();
|
|
|
$order_sn=$Order->setOrder($userId,$param['good_id'],$param['num'],$param['address_id']);
|
|
|
$return['order_sn']=$order_sn;
|
|
|
$return['datetime']=date('Y-m-d H:i');
|
|
|
$this->success('下单成功',$return);
|
|
|
}
|
|
|
/**
|
|
|
* @title 生成电子证件(暂无)
|
|
|
* @description 生成电子证件
|
|
|
* @author sgj
|
|
|
* @url /index/second/commitOrder
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function zhengJianPic(){
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
* @title 他人主页(暂无)
|
|
|
* @description 他人主页
|
|
|
* @author sgj
|
|
|
* @url /index/second/otherHome
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function otherHome(){
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 订单列表
|
|
|
* @description 订单列表
|
|
|
* @author sgj
|
|
|
* @url /index/second/orderList
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*@param name:type type:int require:1 other: desc:类型0,待审核1,已发放
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function orderList(){
|
|
|
$userId=$this->getUserId();
|
|
|
$map['o.user_id']=$userId;
|
|
|
$map['o.status']=input('type');
|
|
|
$Order=new OrderModel();
|
|
|
$data=$Order->alias('o')->field('g.pic,g.good_name,o.*')->join('goods g','g.id=o.good_id')
|
|
|
->where($map)
|
|
|
->order('id','DESC')
|
|
|
->paginate('10',true);
|
|
|
$list=$data->items();
|
|
|
if (!empty($list)){
|
|
|
foreach ($list as $k=>$v){
|
|
|
$list[$k]['pic']=cmf_get_image_url($v['pic']);
|
|
|
}
|
|
|
}
|
|
|
$this->success('',$data);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|