调整订单退款
This commit is contained in:
parent
df13985929
commit
429e02120c
@ -21,6 +21,7 @@ use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\service\RefundOrderService;
|
||||
use app\common\service\xlsx\Beforehand;
|
||||
use app\common\service\xlsx\OrderDetail;
|
||||
use support\exception\BusinessException;
|
||||
@ -124,17 +125,16 @@ class StoreOrderController extends BaseAdminController
|
||||
* @return \support\Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function refund()
|
||||
public function refund(RefundOrderService $refundOrderService)
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$detail = StoreOrder::where('order_id', $params['order_id'])->findOrEmpty();
|
||||
if (empty($detail)) {
|
||||
return $this->fail('无该订单请检查');
|
||||
}
|
||||
$res = StoreOrderLogic::refund($detail, $params);
|
||||
if ($res == false) {
|
||||
return $this->fail('退款失败');
|
||||
}
|
||||
$params['id'] = $detail['id'];
|
||||
$params['old_cart_id'] = StoreOrderCartInfo::where('oid', $detail['id'])->column('id');
|
||||
$refundOrderService->refund($detail['uid'], $params);
|
||||
return $this->success('退款成功',[],1,1);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ class StoreOrder extends BaseModel
|
||||
|
||||
public function allowRefund(): bool
|
||||
{
|
||||
if (in_array($this->status, [0, 1]) && $this->paid == 1) {
|
||||
if (in_array($this->status, [0, 1, 2])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -31,6 +31,9 @@ class RefundOrderService
|
||||
if (empty($order)) {
|
||||
throw new BusinessException('订单不存在');
|
||||
}
|
||||
if (!$order->allowRefund()) {
|
||||
throw new BusinessException('订单不能退款');
|
||||
}
|
||||
$orderCartProducts = StoreOrderCartInfo::where('oid', $order['id'])->whereIn('id', $params['old_cart_id'])->select();
|
||||
if ($order->status == 2 && $order->is_writeoff == 1) {
|
||||
$this->refundStoreMoney($order);
|
||||
|
Loading…
x
Reference in New Issue
Block a user