...
|
...
|
@@ -98,6 +98,94 @@ class Order extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (续约订单)
|
|
|
* @ApiSummary (续约订单)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/order/sonorder)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
*
|
|
|
* @ApiParams (name="order_id", type="int", required=true, description="订单ID")
|
|
|
* @ApiParams (name="is_use", type="int", required=true, description="是否适用优惠劵(0不使用,1使用)")
|
|
|
* @ApiParams (name="coupon_id", type="int", required=false, description="优惠劵ID")
|
|
|
* @ApiParams (name="money", type="string", required=false, description="金额")
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "SUCCESS",
|
|
|
"time": "1553839125",
|
|
|
"data": {
|
|
|
"order_id":"order_id",//子订单id
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function sonorder()
|
|
|
{
|
|
|
$user_id = $this->getUserId();
|
|
|
$param = $this->request->param();
|
|
|
$validate = new Validate([
|
|
|
'order_id' => 'require',
|
|
|
'is_use' => 'require',
|
|
|
'money'=>'require',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
if($param['is_use'] == 1){
|
|
|
if(empty($param['coupon_id'])){
|
|
|
$this->error('优惠劵ID错误');
|
|
|
}
|
|
|
$youhui = Db::name('coupon')->where('id',$param['coupon_id'])->find();
|
|
|
if($youhui['is_use'] != 0){
|
|
|
$this->error('优惠劵已过期或者已使用');
|
|
|
}
|
|
|
$param['createtime'] = time();
|
|
|
$param['num'] = get_order_sn();
|
|
|
$data = Db::name('sonorder')->insertGetId($param);
|
|
|
if(empty($data)){
|
|
|
$this->error('失败');
|
|
|
}else{
|
|
|
//修改优惠劵为已使用
|
|
|
Db::name('coupon')->where('id',$param['coupon_id'])->update(['is_use'=>1]);
|
|
|
$this->success('success',['order_id'=>$data]);
|
|
|
}
|
|
|
}else{
|
|
|
$param['createtime'] = time();
|
|
|
$param['num'] = get_order_sn();
|
|
|
$data = Db::name('sonorder')->insertGetId($param);
|
|
|
$this->success('success',['order_id'=>$data]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (续约订单支付)
|
|
|
* @ApiSummary (续约订单支付)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/order/sonpay)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
*
|
|
|
* @ApiParams (name="order_id", type="inter", required=true, description="续约订单id")
|
|
|
*
|
|
|
*/
|
|
|
public function sonpay()
|
|
|
{
|
|
|
$user_id = $this->getUserId();
|
|
|
$order_id = $this->request->param('order_id');
|
|
|
if(empty($order_id)){
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
$order = Db::name('sonorder')->where('id',$order_id)->find();
|
|
|
if(empty($order)){
|
|
|
$this->error('查询为空');
|
|
|
}
|
|
|
if($order['status'] != 1){
|
|
|
$this->error('订单状态不合法');
|
|
|
}
|
|
|
//微信支付
|
|
|
$openid = $this->getOpenId();
|
|
|
$pay = new WeixinPay();
|
|
|
$this->success('SUCCESS',$pay->pay($openid,$order['num'],"小微问问",$order['money'],url('api/pay/sonnotify','','',true)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (支付)
|
|
|
* @ApiSummary (支付)
|
|
|
* @ApiMethod (POST)
|
...
|
...
|
|