|
|
@@ -563,24 +563,30 @@ class StoreOrder extends AuthController
|
|
|
if (!$id) return $this->failed('数据不存在');
|
|
|
$product = StoreOrderModel::get($id);
|
|
|
if (!$product) return Json::fail('数据不存在!');
|
|
|
- if ($product['pay_price'] == $product['refund_price']) return Json::fail('已退完支付金额!不能再退款了');
|
|
|
+ if ($product['pay_price'] <= $product['refund_price']) return Json::fail('已退完支付金额!不能再退款了');
|
|
|
if (!$data['refund_price']) return Json::fail('请输入退款金额');
|
|
|
$refund_price = $data['refund_price'];
|
|
|
+ // 已經退款的部分和當前請求金額
|
|
|
$data['refund_price'] = bcadd($data['refund_price'], $product['refund_price'], 2);
|
|
|
$bj = bccomp((float)$product['pay_price'], (float)$data['refund_price'], 2);
|
|
|
if ($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额');
|
|
|
- if ($data['type'] == 1) {
|
|
|
- $data['refund_status'] = 2;
|
|
|
- } else if ($data['type'] == 2) {
|
|
|
- $data['refund_status'] = 0;
|
|
|
+ if ($data['type'] == 1) { // 直接退款
|
|
|
+ $data['refund_status'] = REFUNDED;
|
|
|
+ } else if ($data['type'] == 2) { // 退款后,返回原状态
|
|
|
+ $data['refund_status'] = REFUND_NO;
|
|
|
}
|
|
|
$type = $data['type'];
|
|
|
unset($data['type']);
|
|
|
$refund_data['pay_price'] = $product['pay_price'];
|
|
|
$refund_data['refund_price'] = $refund_price;
|
|
|
+
|
|
|
+ return Json::fail('目前系統版本暫不支持在線退款; 如果需要,請聯系工程技術部門升級系統');
|
|
|
+
|
|
|
if ($product['pay_type'] == 'weixin') {
|
|
|
if ($product['is_channel'] == 1) {//小程序
|
|
|
try {
|
|
|
+ // TODO: 批量支付後,這個訂單號應該爲總訂單號,退款只支持批量購買最多貨品爲 1 種的訂單。
|
|
|
+ throw new \Exception("目前系統部分訂單不支持退款,請聯系工程技術部門升級");
|
|
|
MiniProgramService::payOrderRefund($product['order_id'], $refund_data);//2.5.36
|
|
|
} catch (\Exception $e) {
|
|
|
return Json::fail($e->getMessage());
|
|
|
@@ -801,12 +807,12 @@ class StoreOrder extends AuthController
|
|
|
'refund_reason',
|
|
|
]);
|
|
|
if (!$id) return $this->failed('数据不存在');
|
|
|
- $product = StoreOrderModel::get($id);
|
|
|
- if (!$product) return Json::fail('数据不存在!');
|
|
|
+ $order = StoreOrderModel::get($id);
|
|
|
+ if (!$order) return Json::fail('数据不存在!');
|
|
|
if (!$data['refund_reason']) return Json::fail('请输入不退款原因');
|
|
|
- $data['refund_status'] = 0;
|
|
|
+ $data['refund_status'] = REFUND_NO;
|
|
|
StoreOrderModel::edit($data, $id);
|
|
|
- event('StoreProductOrderRefundNAfter', [$data['refund_reason'], $id]);
|
|
|
+ event('StoreProductOrderRefundNAfter', [$data['refund_reason'], $order]);
|
|
|
StoreOrderStatus::setStatus($id, 'refund_n', '不退款原因:' . $data['refund_reason']);
|
|
|
return Json::successful('修改成功!');
|
|
|
}
|