|
@@ -10,6 +10,7 @@ use think\Exception;
|
|
|
use think\exception\PDOException;
|
|
|
use think\exception\ValidateException;
|
|
|
use think\Hook;
|
|
|
+use addons\epay\library\Service;
|
|
|
|
|
|
/**
|
|
|
* 订单管理
|
|
@@ -429,22 +430,25 @@ class Order extends Backend
|
|
|
// 退款
|
|
|
$params = [
|
|
|
'refund_status' => $refund_status,
|
|
|
+ 'updatetime' => time(),
|
|
|
];
|
|
|
if($refund_status == 3) {
|
|
|
$params['had_refund'] = time();
|
|
|
}
|
|
|
// 乐观锁
|
|
|
$result = Db::name('unishop_order')->where(['id' => $ids, 'updatetime' => $updatetime])->update($params);
|
|
|
+ if (!$result) {
|
|
|
+ throw new Exception(__('Data had been update before saved, close windows and do it again'));
|
|
|
+ }
|
|
|
|
|
|
//修改退款金额
|
|
|
$rs2 = Db::name('unishop_order_refund')->where('order_id',$ids)->update(['amount'=>$refund_amount]);
|
|
|
-
|
|
|
- if (!$result || !$rs2) {
|
|
|
- throw new Exception(__('Data had been update before saved, close windows and do it again'));
|
|
|
+ if ($rs2 === false) {
|
|
|
+ throw new Exception('操作失败');
|
|
|
}
|
|
|
|
|
|
- //执行退款
|
|
|
- if($refund_amount > 0){
|
|
|
+ //同意并执行退款
|
|
|
+ if($refund_status == 3 && $refund_amount > 0){
|
|
|
$order = Db::name('unishop_order')->where('id',$ids)->find();
|
|
|
|
|
|
if($order['pay_type'] == 2){
|
|
@@ -515,16 +519,16 @@ class Order extends Backend
|
|
|
$remark = '订单退款';
|
|
|
|
|
|
if($order['pay_type'] == 3){
|
|
|
- $order['pay_type'] == 'wechat';
|
|
|
+ $order['pay_type'] = 'wechat';
|
|
|
}
|
|
|
if($order['pay_type'] == 4){
|
|
|
- $order['pay_type'] == 'alipay';
|
|
|
+ $order['pay_type'] = 'alipay';
|
|
|
}
|
|
|
|
|
|
// 生成退款单
|
|
|
$refund_data = [
|
|
|
'order_id' => $order['id'],
|
|
|
- 'out_refund_no'=> createUniqueNo('R',$order['id']),
|
|
|
+ 'out_refund_no'=> createUniqueNo('R'),
|
|
|
'pay_fee' => $order['total_price'],
|
|
|
'refund_price' => $refund_price,
|
|
|
'pay_type' => $order['pay_type'],
|