wanghousheng 10 months ago
parent 8f5c604529
commit 6fb6ef27e2
  1. 27
      app/api/model/OrderRefund.php

@ -153,8 +153,11 @@ class OrderRefund extends OrderRefundModel
{
$goods = OrderGoodsModel::detail($orderGoodsId);
if (isset($goods['refund']) && !empty($goods['refund'])) {
//是否已经同意
if (!empty($goods['refund']['audit_status']) == AuditStatusEnum::REVIEWED) {
throwError('当前商品已申请售后');
}
}
return $goods;
}
@ -200,6 +203,28 @@ class OrderRefund extends OrderRefundModel
{
// 订单商品详情
$goods = $this->getRefundGoods($orderGoodsId);
if (!empty($goods['refund']) && !empty($goods['refund']['audit_status']) != AuditStatusEnum::REVIEWED) {
if (empty($goods['refund']['order_refund_id'])) {
throwError('当前记录数据异常');
}
return $this->transaction(function () use ($orderGoodsId, $data, $goods) {
$order_refund_id = $goods['refund']['order_refund_id'];
// //更新售后单记录
$this->where(['order_refund_id' => $order_refund_id])->update([
'type' => $data['type'],
'apply_desc' => $data['content'],
'audit_status' => AuditStatusEnum::WAIT,
'status' => 0,
'store_id' => self::$storeId
]);
// 记录凭证图片关系
if (!empty($data['images'])) {
(new OrderRefundImage)->where(['order_refund_id' => $order_refund_id])->delete();
$this->saveImages((int)$this['order_refund_id'], explode(",", $data['images']));
}
return true;
});
}
return $this->transaction(function () use ($orderGoodsId, $data, $goods) {
// 新增售后单记录
$this->save([
@ -213,7 +238,7 @@ class OrderRefund extends OrderRefundModel
'store_id' => self::$storeId
]);
// 记录凭证图片关系
if (isset($data['images']) && !empty($data['images'])) {
if (!empty($data['images'])) {
$this->saveImages((int)$this['order_refund_id'], explode(",", $data['images']));
}
return true;

Loading…
Cancel
Save