作者 郭盛
1 个管道 的构建 通过 耗费 9 秒

修改退单退款功能

... ... @@ -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
... ...
此 diff 太大无法显示。
... ... @@ -31,7 +31,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'territory_id', title: __('Territory_id'), operate:false},
{field: 'is_use', title: __('Is_use'), operate:false,formatter: Table.api.formatter.label,searchList:{'0': '不使用','1':'使用'}},
{field: 'money', title: __('Money'), operate:'BETWEEN'},
{field: 'status', title: __('Status'),formatter: Table.api.formatter.status,custom: {2:'success', 1:'error'},searchList:{'1': '待支付','2':'已支付'}},
{field: 'status', title: __('Status'),formatter: Table.api.formatter.status,custom: {2:'success', 1:'error',3:'error'},searchList:{'1': '待支付','2':'已支付','3':'已退款'}},
{field: 'num', title: __('Num'), operate:false},
{field: 'business', title: __('Business'), operate:false},
{field: 'address', title: __('Address'), operate:false},
... ...