|
@@ -69,7 +69,7 @@ class Refund
|
|
|
}
|
|
|
|
|
|
# 更新退款记录
|
|
|
- public function up($order_id, $order_goods_id, $status, $price, $p_price, $num = false, $desc = '', $pic = '', $process = 1, $order = array())
|
|
|
+ public function up($order_id, $order_goods_id, $status, $price, $p_price, $num = false, $desc = '', $pic = '', $process = 1, $order = array(), $re_cash = 0)
|
|
|
{
|
|
|
$data['order_id'] = $order_id;
|
|
|
if (!$order_goods_id) {
|
|
@@ -90,6 +90,7 @@ class Refund
|
|
|
if ($p_price) {
|
|
|
$data['p_cash'] = $p_price;
|
|
|
}
|
|
|
+ $data['re_cash'] = $re_cash;
|
|
|
|
|
|
if ($num) {
|
|
|
$data['num'] = $num;
|
|
@@ -143,12 +144,13 @@ class Refund
|
|
|
}
|
|
|
}
|
|
|
if ($auth) {
|
|
|
+ $re_cash = 0;
|
|
|
if ($order_goods_id) {
|
|
|
$info = Dever::db($this->goods_table)->find(array('id' => $order_goods_id, 'order_id' => $data['id'], 'status' => 1));
|
|
|
if ($info) {
|
|
|
|
|
|
Dever::db($this->goods_table)->update(array('where_id' => $info['id'], 'status' => 2));
|
|
|
-
|
|
|
+
|
|
|
if (!$num) {
|
|
|
$num = $info['num'];
|
|
|
}
|
|
@@ -159,6 +161,7 @@ class Refund
|
|
|
if ($info['total_price'] >= $kou) {
|
|
|
$info['total_price'] = $info['total_price'] - $kou;
|
|
|
} else {
|
|
|
+ $re_cash = $info['total_price'];
|
|
|
$info['total_price'] = 0;
|
|
|
}
|
|
|
}
|
|
@@ -202,7 +205,7 @@ class Refund
|
|
|
$cash = round($cash, 2);
|
|
|
|
|
|
if ($cash >= 0) {
|
|
|
- $log = $this->up($data['id'], $order_goods_id, $status, $cash, $p_cash, $num, $desc, $pic, $process, $data);
|
|
|
+ $log = $this->up($data['id'], $order_goods_id, $status, $cash, $p_cash, $num, $desc, $pic, $process, $data, $re_cash);
|
|
|
|
|
|
if (!$log) {
|
|
|
Dever::alert('退款失败');
|
|
@@ -413,8 +416,15 @@ class Refund
|
|
|
Dever::db('shop/user_coupon')->update(array('where_id' => $order['user_coupon_id'], 'status' => 1));
|
|
|
}
|
|
|
|
|
|
+ $re_cash = $info['re_cash'];
|
|
|
if (isset($order['card_code_id']) && $order['card_code_id'] && $order['card_code_cash'] > 0) {
|
|
|
# 还原礼品卡
|
|
|
+ if ($re_cash > 0) {
|
|
|
+ $card_code_cash = $order['card_code_cash'] - $re_cash;
|
|
|
+ $order['card_code_cash'] = $re_cash;
|
|
|
+
|
|
|
+ Dever::db($this->order_table)->update(array('where_id' => $order['id'], 'card_code_cash' => $card_code_cash));
|
|
|
+ }
|
|
|
Dever::db('card/code')->decUseCash(array('where_id' => $order['card_code_id'], 'set_use_cash' => $order['card_code_cash']));
|
|
|
} elseif (isset($order['wallet_cash']) && $order['wallet_cash'] && $order['wallet_cash'] > 0) {
|
|
|
# 还原钱包
|