|
|
@@ -233,50 +233,12 @@ class RefundController extends BaseController
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
-
|
|
|
$post = Yii::$app->request->post();
|
|
|
$id = isset($post['id']) ? $post['id'] : 0;
|
|
|
- $order = OrderClass::getById($id, true);
|
|
|
- OrderClass::valid($order, $this->shopId);
|
|
|
- if ($order->status != OrderClass::ORDER_STATUS_COMPLETE) {
|
|
|
- util::fail("订单完成了才能发起退款");
|
|
|
- }
|
|
|
- $customId = $order->customId ?? 0;
|
|
|
- $clearList = PurchaseClearClass::getAllByCondition(['customId' => $customId, 'status' => 1], null, '*', null, true);
|
|
|
- $orderIds = [];
|
|
|
- if (!empty($clearList)) {
|
|
|
- foreach ($clearList as $clear) {
|
|
|
- $saleStr = $clear->saleIds ?? '';
|
|
|
- $deadline = $clear->deadline ?? '';
|
|
|
- if ($deadline < date("Y-m-d H:i:s")) {
|
|
|
- $clear->status = 3;
|
|
|
- $clear->save();
|
|
|
- } else {
|
|
|
- if (!empty($saleStr)) {
|
|
|
- $current = explode(',', $saleStr);
|
|
|
- $orderIds = array_merge($orderIds, $current);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!empty($orderIds) && in_array($id, $orderIds)) {
|
|
|
- util::fail('此客户有结账单未完成');
|
|
|
- }
|
|
|
- }
|
|
|
- $addTime = $order->addTime ?? '';
|
|
|
- $current = time();
|
|
|
- if ((strtotime($addTime) + 3 * 30 * 24 * 60 * 60) < $current) {
|
|
|
- util::fail('历史订单,不能再发起退款');
|
|
|
- }
|
|
|
- if (strtotime($addTime) <= strtotime('2022-03-30 00:00:00')) {
|
|
|
- util::fail('历史订单,不能发起退款哦');
|
|
|
- }
|
|
|
-
|
|
|
- //退款类型 1退货并退款 2 仅退款
|
|
|
$refundType = $post['refundType'] ?? 1;
|
|
|
-
|
|
|
if ($refundType == RefundOrderClass::REFUND_TYPE_MONEY_GOOD) {
|
|
|
//花材列表结构
|
|
|
- // [{productId:0,num:1,unitType:0,unitPrice:12,unitName:'扎'}] productId 花材id num 退货数 unitType 大小单位0大1小 unitPrice 售价 unitName单位名称
|
|
|
+ // [{productId:0,num:1,unitType:0,unitPrice:12,unitName:'扎'}]
|
|
|
$productJson = $post['product'] ?? '';
|
|
|
if (empty($productJson)) {
|
|
|
util::fail('请选择花材');
|
|
|
@@ -285,7 +247,6 @@ class RefundController extends BaseController
|
|
|
if (!is_array($productList)) {
|
|
|
util::fail('请选择花材哦');
|
|
|
}
|
|
|
-
|
|
|
$post['product'] = $productList;
|
|
|
} else {
|
|
|
//仅退款花材直接设置为空
|
|
|
@@ -295,9 +256,6 @@ class RefundController extends BaseController
|
|
|
if ($post['price'] <= 0) {
|
|
|
util::fail("退款金额不能小于0");
|
|
|
}
|
|
|
- if (bccomp($post['price'], $order['realPrice'], 2) == 1) {
|
|
|
- util::fail("退款金额超过订单金额");
|
|
|
- }
|
|
|
|
|
|
$post['shopId'] = $this->shopId;
|
|
|
$post['sjId'] = $this->sjId;
|