feat:扫一扫的退款(没有购物车的退款)
This commit is contained in:
1 parent
1ba68a0763
commit
c2d52f9c03
5 files changed
+49
-29
No files matched your search
@@ -233,6 +233,7 @@ CREATE TABLE hard_after_sale_car
|
||||
product_name varchar(128) NOT NULL COMMENT '商品名',
|
||||
product_pic varchar(256) NOT NULL COMMENT '商品图片',
|
||||
product_price bigint NOT NULL COMMENT '商品价格',
|
||||
product_nature varchar(64) DEFAULT NULL COMMENT '商品性质',
|
||||
product_count int NOT NULL COMMENT '数量',
|
||||
product_weight decimal(10, 2) COMMENT '重量',
|
||||
total_price bigint COMMENT '总价(分)',
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public enum HardOrderStatusEnum {
|
||||
);
|
||||
}
|
||||
|
||||
public static HardOrderStatusEnum valueOfByType(Integer type) {
|
||||
public static HardOrderStatusEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
|
||||
+5
@@ -68,6 +68,11 @@ public enum HardPayTypeEnum {
|
||||
CSXFK
|
||||
);
|
||||
|
||||
// 简单支付(没有购物车)
|
||||
public static final List<HardPayTypeEnum> isSimplePayList = List.of(
|
||||
WALLET_QR_CODE_SCAN
|
||||
);
|
||||
|
||||
public static HardPayTypeEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
|
||||
+2
-4
@@ -81,11 +81,9 @@ public class HardCarController {
|
||||
@GetMapping("/order-id")
|
||||
@Operation(summary = "根据订单id查询购物车")
|
||||
public R<Page<HardCarVo>> orderId(@ParameterObject Page page, @RequestParam Long orderId) {
|
||||
if (ObjectUtil.isEmpty(orderId)) {
|
||||
R.ok(null);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(orderId)) R.ok(null);
|
||||
HardOrderEntity order = hardOrderService.getById(orderId);
|
||||
if (ObjectUtil.isEmpty(order) || ObjectUtil.isEmpty(order.getParentCarId())) return null;
|
||||
if (ObjectUtil.isEmpty(order) || ObjectUtil.isEmpty(order.getParentCarId())) return R.ok(null);
|
||||
HardCarDto dto = new HardCarDto();
|
||||
dto.setParentCarId(order.getParentCarId());
|
||||
return R.ok(hardCarService.pageJoin(page, dto));
|
||||
|
||||
+40
-24
@@ -528,26 +528,38 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean adminReinforceRefund(HardAdminRefundReinforceDto dto, PjcloudUser user) {
|
||||
if (ObjectUtil.isEmpty(dto.getCarList())) throw new RuntimeException("退款商品列表不能为空");
|
||||
// 校验订单是否可以退款
|
||||
HardOrderVo order = validateOrderCanRefund(dto.getOrderId());
|
||||
// 校验订单购物车是否支持退款
|
||||
validateOrderCarCanRefund(order, dto.getCarList());
|
||||
|
||||
// 判断是否快速支付
|
||||
HardPayTypeEnum hardPayType = HardPayTypeEnum.valueOfByType(order.getPayType());
|
||||
if (ObjectUtil.isEmpty(hardPayType)) throw new RuntimeException("订单类型错误");
|
||||
// 如果是简单支付(没有购物车)的支付方式就直接返回
|
||||
boolean isSimplePayList = HardPayTypeEnum.isSimplePayList.contains(hardPayType);
|
||||
if (!isSimplePayList) {
|
||||
if (ObjectUtil.isEmpty(dto.getCarList())) throw new RuntimeException("退款商品列表不能为空");
|
||||
// 校验订单购物车是否支持退款
|
||||
validateOrderCarCanRefund(order, dto.getCarList());
|
||||
}
|
||||
|
||||
// 添加售后订单
|
||||
HardAfterSaleEntity saveObj = BeanUtils.toBean(dto, HardAfterSaleEntity.class);
|
||||
String refundCode = "hard_" + order.getId();
|
||||
|
||||
// 计算退款金额
|
||||
List<HardCreateCarDto> computerCarList = dto.getCarList().stream().map((item) -> {
|
||||
HardCreateCarDto entity = new HardCreateCarDto();
|
||||
entity.setParentCarId(item.getParentCarId());
|
||||
entity.setProductId(item.getProductId());
|
||||
entity.setProductNature(HardProductNatureEnum.valueOfByType(item.getProductNature()));
|
||||
entity.setProductCount(item.getProductCount());
|
||||
entity.setProductWeight(item.getProductWeight());
|
||||
return entity;
|
||||
}).toList();
|
||||
int refundPrice = hardCarService.computerCarTotalPrice(HardTypeEnum.valueOfByType(order.getSysType()), HardOrderTypeEnum.valueOfByType(order.getOrderType()), computerCarList);
|
||||
int refundPrice = order.getPayPrice();
|
||||
if (!isSimplePayList) {
|
||||
List<HardCreateCarDto> computerCarList = dto.getCarList().stream().map((item) -> {
|
||||
HardCreateCarDto entity = new HardCreateCarDto();
|
||||
entity.setParentCarId(item.getParentCarId());
|
||||
entity.setProductId(item.getProductId());
|
||||
entity.setProductNature(HardProductNatureEnum.valueOfByType(item.getProductNature()));
|
||||
entity.setProductCount(item.getProductCount());
|
||||
entity.setProductWeight(item.getProductWeight());
|
||||
return entity;
|
||||
}).toList();
|
||||
refundPrice = hardCarService.computerCarTotalPrice(HardTypeEnum.valueOfByType(order.getSysType()), HardOrderTypeEnum.valueOfByType(order.getOrderType()), computerCarList);
|
||||
}
|
||||
|
||||
saveObj.setType(HardSaleTypeEnum.AFTER_SALE.getType());
|
||||
saveObj.setStatus(HardSaleStatusEnum.COMPLETE.getStatus());
|
||||
@@ -560,7 +572,9 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
saveObj.setAuditReason("后台退款");
|
||||
baseMapper.insert(saveObj);
|
||||
// 添加退款购物车
|
||||
hardAfterSaleCarService.create(dto.getCarList(), order, saveObj);
|
||||
if (!isSimplePayList) {
|
||||
hardAfterSaleCarService.create(dto.getCarList(), order, saveObj);
|
||||
}
|
||||
// 添加售后进度
|
||||
HardAfterSaleLogEntity saveLogObj = HardAfterSaleLogEntity.builder()
|
||||
.afterSaleId(saveObj.getId())
|
||||
@@ -571,18 +585,20 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
.content(HardSaleStatusEnum.COMPLETE.getContent())
|
||||
.build();
|
||||
hardAfterSaleLogMapper.insert(saveLogObj);
|
||||
// 退库存
|
||||
if (!isSimplePayList) {
|
||||
List<HardCarEntity> carList = dto.getCarList().stream().map((item) ->
|
||||
HardCarEntity.builder()
|
||||
.productId(item.getProductId())
|
||||
.productCount(item.getProductCount())
|
||||
.productWeight(item.getProductWeight())
|
||||
.productNature(item.getProductName())
|
||||
.build()
|
||||
).toList();
|
||||
hardOrderService.fastenerInventory(order, carList, YesNoEnum.NO);
|
||||
}
|
||||
// 执行退款
|
||||
getSelf().refund(saveObj.getId());
|
||||
// 退库存
|
||||
List<HardCarEntity> carList = dto.getCarList().stream().map((item) ->
|
||||
HardCarEntity.builder()
|
||||
.productId(item.getProductId())
|
||||
.productCount(item.getProductCount())
|
||||
.productWeight(item.getProductWeight())
|
||||
.productNature(item.getProductName())
|
||||
.build()
|
||||
).toList();
|
||||
hardOrderService.fastenerInventory(order, carList, YesNoEnum.NO);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user