|
|
@@ -1,17 +1,27 @@
|
|
|
package com.yami.shop.api.controller;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.yami.shop.bean.model.OrderRefund;
|
|
|
+import com.yami.shop.bean.model.OrderRefundRecord;
|
|
|
import com.yami.shop.bean.model.RefundDelivery;
|
|
|
+import com.yami.shop.bean.model.ShopDetail;
|
|
|
+import com.yami.shop.common.exception.GlobalException;
|
|
|
import com.yami.shop.common.util.PageParam;
|
|
|
+import com.yami.shop.dao.OrderRefundRecordMapper;
|
|
|
+import com.yami.shop.dao.ShopDetailMapper;
|
|
|
+import com.yami.shop.service.OrderRefundService;
|
|
|
import com.yami.shop.service.RefundDeliveryService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* 退货物流信息接口
|
|
|
@@ -23,6 +33,9 @@ import javax.validation.Valid;
|
|
|
public class RefundDeliveryController {
|
|
|
|
|
|
private final RefundDeliveryService refundDeliveryService;
|
|
|
+ private final OrderRefundService orderRefundService;
|
|
|
+ private final OrderRefundRecordMapper orderRefundRecordMapper;
|
|
|
+ private final ShopDetailMapper shopDetailMapper;
|
|
|
|
|
|
/**
|
|
|
* 分页获取退货物流信息列表
|
|
|
@@ -59,8 +72,37 @@ public class RefundDeliveryController {
|
|
|
*/
|
|
|
@PostMapping("/save")
|
|
|
@ApiOperation("保存退货物流信息")
|
|
|
- public ResponseEntity<Void> save(@Valid @RequestBody RefundDelivery refundDelivery) {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public ResponseEntity<?> save(@Valid @RequestBody RefundDelivery refundDelivery) {
|
|
|
+
|
|
|
+
|
|
|
+ //获取门店信息
|
|
|
+ ShopDetail shopDetail = shopDetailMapper.selectById(refundDelivery.getShopId());
|
|
|
+ if (ObjectUtil.isEmpty(shopDetail)){
|
|
|
+ throw new GlobalException("门店信息不存在");
|
|
|
+ }
|
|
|
+ //门店信息获取地址
|
|
|
+ String shopAddress = shopDetail.getProvince() + shopDetail.getCity() + shopDetail.getArea() + shopDetail.getShopAddress();
|
|
|
+ refundDelivery.setReceiverAddr(shopAddress);
|
|
|
+ refundDelivery.setReceiverName(shopDetail.getTel());
|
|
|
+ refundDelivery.setReceiverMobile(shopDetail.getShopOwner());
|
|
|
+ refundDelivery.setReceiverTelephone(shopDetail.getMobile());
|
|
|
refundDeliveryService.save(refundDelivery);
|
|
|
+ //添加填写物流信息轨迹
|
|
|
+ OrderRefund one = orderRefundService.getOne(new LambdaQueryWrapper<OrderRefund>().eq(OrderRefund::getRefundSn, refundDelivery.getRefundSn()));
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty( one)){
|
|
|
+ throw new GlobalException("该退款单不存在");
|
|
|
+ }
|
|
|
+ OrderRefundRecord orderRefundRecord = new OrderRefundRecord();
|
|
|
+ orderRefundRecord.setOrderRefundId(one.getRefundId());
|
|
|
+ orderRefundRecord.setInstructions("商家收到商品井确认不影响二次销售后,将会为您处理退款");
|
|
|
+ Date date = new Date();
|
|
|
+ orderRefundRecord.setCreateTime(date);
|
|
|
+ orderRefundRecord.setUpdateTime(date);
|
|
|
+ orderRefundRecord.setAuditStatus(7);
|
|
|
+ orderRefundRecord.setSort(5);
|
|
|
+ orderRefundRecordMapper.insert(orderRefundRecord);
|
|
|
return ResponseEntity.ok().build();
|
|
|
}
|
|
|
|