...
|
...
|
@@ -13,6 +13,7 @@ use app\common\controller\Api; |
|
|
use think\Db;
|
|
|
use think\Validate;
|
|
|
use wxapp\pay\WeixinPay;
|
|
|
use wxapp\pay\WeixinRefund;
|
|
|
|
|
|
/**
|
|
|
* 创建订单/支付接口
|
...
|
...
|
@@ -337,6 +338,7 @@ class Order extends Api |
|
|
"is_summarize"://是否总结过(1是2否)
|
|
|
"is_complaint"://是否被投诉(1是2否3已处理)
|
|
|
"is_comment"://是否评价过(1是2否)
|
|
|
* "is_chargeback"://是否退单(1已退款2没退款)
|
|
|
}
|
|
|
})
|
|
|
*/
|
...
|
...
|
@@ -531,4 +533,56 @@ class Order extends Api |
|
|
}
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (老师退单)
|
|
|
* @ApiSummary (老师退单)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/order/chargeback)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
*
|
|
|
* @ApiParams (name="order_id", type="int", required=true, description="订单金额ID")
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "SUCCESS",
|
|
|
"time": "1553839125",
|
|
|
"data": {
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function chargeback()
|
|
|
{
|
|
|
$user_id = $this->getUserId();
|
|
|
$param = $this->request->param();
|
|
|
$validate = new Validate([
|
|
|
'order_id' => 'require',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$order = Db::name('order')
|
|
|
->where('id',$param['order_id'])
|
|
|
->find();
|
|
|
if(empty($order)){
|
|
|
$this->error('查询为空');
|
|
|
}
|
|
|
if($order['status'] != 2 || $order['finish_status'] != 1){
|
|
|
$this->error('非法的订单状态');
|
|
|
}
|
|
|
|
|
|
$pay = new WeixinRefund();
|
|
|
$openid = Db::name('third')->where('user_id',$order['user_id'])->find();
|
|
|
$result = $pay->refund($openid['openid'],$order['num'],$order['money'],get_order_sn(),$order['money']);
|
|
|
if($result['return_code'] == 'FAIL'){
|
|
|
$this->error($result['return_msg']);
|
|
|
}else{
|
|
|
if($result['result_code'] == 'FAIL'){
|
|
|
$this->error($result['err_code_des']);
|
|
|
}else{
|
|
|
Db::name('order')->where('id',$param['order_id'])->update(['status'=>3,'finish_status'=>3,'is_chargeback'=>1]);
|
|
|
$this->success('success');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|