feat:退款完成
This commit is contained in:
1 parent
d153ce27c1
commit
9e21323493
8 files changed
+110
-16
No files matched your search
+6
@@ -63,6 +63,12 @@ public class HardAfterSaleCarEntity extends Model<HardAfterSaleCarEntity> {
|
||||
@Schema(description = "商品价格")
|
||||
private Long productPrice;
|
||||
|
||||
/**
|
||||
* 商品性质(字典)
|
||||
*/
|
||||
@Schema(description = "商品性质(字典)")
|
||||
private String productNature;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
|
||||
+14
@@ -3,12 +3,14 @@ package com.bsd.pjcloud.hard.controller.hard;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardProductNatureEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.async.SyncOfflineReqVo;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.HandCancelCodeDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.HardBindDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardChartLatitudeVo;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardInvoiceVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.manager.HardManagerVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.android.HardAdUserVo;
|
||||
@@ -23,6 +25,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -68,6 +71,17 @@ public class HardApiController {
|
||||
@Operation(summary = "创建订单")
|
||||
@Idempotent(expireTime = 10, info = "正在创建订单中,请勿重复操作")
|
||||
public R<Long> createOrder(@Valid @RequestBody HardCreateOrderDto dto) {
|
||||
// 处理商品类型
|
||||
if (ObjectUtil.isNotEmpty(dto.getList())) {
|
||||
for (HardCreateCarDto item : dto.getList()) {
|
||||
if (ObjectUtil.isEmpty(item.getProductNature())) continue;
|
||||
if (ObjectUtil.isNotEmpty(item.getProductWeight()) && item.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) {
|
||||
item.setProductNature(HardProductNatureEnum.WEIGHT);
|
||||
} else if (ObjectUtil.isNotEmpty(item.getProductCount())) {
|
||||
item.setProductNature(HardProductNatureEnum.DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok(hardwareOrderService.createOrder(dto));
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -14,6 +14,7 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
|
||||
import com.bsd.pjcloud.thirdparty.dto.ks.KsRecognitionCallbackDto;
|
||||
@@ -104,6 +105,8 @@ public interface HardOrderService extends IService<HardOrderEntity> {
|
||||
*/
|
||||
void fastenerInventory(HardOrderEntity order, YesNoEnum isReduce);
|
||||
|
||||
void fastenerInventory(HardOrderEntity order, List<HardCarEntity> refundCarList, YesNoEnum isReduce);
|
||||
|
||||
/**
|
||||
* 核销硬件二维码
|
||||
*/
|
||||
|
||||
+6
-1
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -48,6 +49,10 @@ public class HardAfterSaleCarServiceImpl extends ServiceImpl<HardAfterSaleCarMap
|
||||
item.setRefundId(afterSale.getId());
|
||||
return item;
|
||||
}).toList();
|
||||
saveBatch(carList);
|
||||
List<HardAfterSaleCarEntity> saveList = new ArrayList<>(carList).stream().map(item -> {
|
||||
item.setId(null);
|
||||
return item;
|
||||
}).toList();
|
||||
saveBatch(saveList);
|
||||
}
|
||||
}
|
||||
+27
-7
@@ -20,6 +20,8 @@ import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardProductNatureEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
@@ -30,10 +32,7 @@ import com.bsd.pjcloud.hard.api.constant.refund.HardSaleTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.ali.AliRefundDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.*;
|
||||
import com.bsd.pjcloud.hard.api.dto.wechat.WechatRefundDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleCarEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleLogEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.*;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardAfterSaleVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
|
||||
@@ -230,7 +229,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
// 生成退款单号
|
||||
if (ObjectUtil.isEmpty(prefixStr)) prefixStr = "hard";
|
||||
String refundCode = prefixStr + "_" + order.getId();
|
||||
// 创建退款单
|
||||
// 查询总的退款金额
|
||||
Integer refundPrice = afterSale.getRefundPrice();
|
||||
if (ObjectUtil.isEmpty(refundPrice)) {
|
||||
refundPrice = order.getPayPrice();
|
||||
@@ -537,11 +536,24 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
// 添加售后订单
|
||||
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);
|
||||
|
||||
saveObj.setType(HardSaleTypeEnum.AFTER_SALE.getType());
|
||||
saveObj.setStatus(HardSaleStatusEnum.COMPLETE.getStatus());
|
||||
saveObj.setNo(refundCode);
|
||||
saveObj.setOrderId(order.getId());
|
||||
saveObj.setRefundPrice(order.getPayPrice());
|
||||
saveObj.setRefundPrice(refundPrice);
|
||||
saveObj.setUserId(order.getUserId());
|
||||
saveObj.setAuditUserId(user.getId());
|
||||
saveObj.setAuditTime(LocalDateTime.now());
|
||||
@@ -562,7 +574,15 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
// 执行退款
|
||||
getSelf().refund(saveObj.getId());
|
||||
// 退库存
|
||||
// hardOrderService.fastenerInventory(order, YesNoEnum.NO);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -259,7 +259,9 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
item.setProductPrice(spu.getPrice());
|
||||
item.setProductPic(spu.getPicUrl());
|
||||
item.setTotalPrice((long) totalPrice);
|
||||
// item.setProductNature(v.getProductNature().getType());
|
||||
if (ObjectUtil.isNotEmpty(v.getProductNature())) {
|
||||
item.setProductNature(v.getProductNature().getType());
|
||||
}
|
||||
item.setProductCount(v.getProductCount());
|
||||
item.setProductWeight(new BigDecimal(0));
|
||||
carObjectList.add(item);
|
||||
@@ -278,7 +280,9 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
item.setProductPrice(spu.getPrice());
|
||||
item.setProductPic(spu.getPicUrl());
|
||||
item.setTotalPrice((long) totalPrice);
|
||||
// item.setProductNature(v.getProductNature().getType());
|
||||
if (ObjectUtil.isNotEmpty(v.getProductNature())) {
|
||||
item.setProductNature(v.getProductNature().getType());
|
||||
}
|
||||
item.setProductCount(v.getProductCount());
|
||||
item.setProductWeight(new BigDecimal(0));
|
||||
carObjectList.add(item);
|
||||
@@ -310,7 +314,9 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
item.setProductPrice(price);
|
||||
item.setProductPic(spu.getPicUrl());
|
||||
item.setTotalPrice((long) totalPrice);
|
||||
// item.setProductNature(v.getProductNature().getType());
|
||||
if (ObjectUtil.isNotEmpty(v.getProductNature())) {
|
||||
item.setProductNature(v.getProductNature().getType());
|
||||
}
|
||||
item.setProductCount(v.getProductCount());
|
||||
item.setProductWeight(v.getProductWeight());
|
||||
carObjectList.add(item);
|
||||
@@ -341,7 +347,9 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
item.setProductPrice(price);
|
||||
item.setProductPic(spu.getCover());
|
||||
item.setTotalPrice((long) totalPrice);
|
||||
// item.setProductNature(v.getProductNature().getType());
|
||||
if (ObjectUtil.isNotEmpty(v.getProductNature())) {
|
||||
item.setProductNature(v.getProductNature().getType());
|
||||
}
|
||||
item.setProductCount(v.getProductCount());
|
||||
item.setProductWeight(v.getProductWeight());
|
||||
carObjectList.add(item);
|
||||
|
||||
+39
-3
@@ -852,6 +852,12 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void fastenerInventory(HardOrderEntity order, YesNoEnum isReduce) {
|
||||
getSelf().fastenerInventory(order, null, isReduce);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void fastenerInventory(HardOrderEntity order, List<HardCarEntity> refundCarList, YesNoEnum isReduce) {
|
||||
HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(order.getSysType());
|
||||
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
|
||||
if (!ObjectUtil.isAllNotEmpty(hardTypeEnum, orderTypeEnum)) return;
|
||||
@@ -867,6 +873,13 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
CanteenSpuUpdateStockReqDTO.Item item = new CanteenSpuUpdateStockReqDTO.Item();
|
||||
item.setId(v.getProductId());
|
||||
item.setIncrCount(v.getProductCount() * base);
|
||||
// 如果退款购物车数组里有,就用退款购物车的数量
|
||||
if (ObjectUtil.isNotEmpty(refundCarList)) {
|
||||
HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) {
|
||||
item.setIncrCount(refundCarTarget.getProductCount() * base);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}).toList();
|
||||
dto.setItems(list);
|
||||
@@ -889,15 +902,31 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
item.setId(v.getProductId());
|
||||
if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) {
|
||||
// 按数量
|
||||
double count = BigDecimal.valueOf(v.getProductCount()).multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
int prouctCount = v.getProductCount();
|
||||
// 如果退款购物车数组里有,就用退款购物车的数量
|
||||
if (ObjectUtil.isNotEmpty(refundCarList)) {
|
||||
HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) {
|
||||
prouctCount = refundCarTarget.getProductCount();
|
||||
}
|
||||
}
|
||||
double count = BigDecimal.valueOf(prouctCount).multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
item.setIncrCount(count);
|
||||
} else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) {
|
||||
// 按重量
|
||||
double weight = v.getProductWeight().multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
BigDecimal productWeight = v.getProductWeight();
|
||||
// 如果退款购物车数组里有,就用退款购物车的数量
|
||||
if (ObjectUtil.isNotEmpty(refundCarList)) {
|
||||
HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) {
|
||||
productWeight = refundCarTarget.getProductWeight();
|
||||
}
|
||||
}
|
||||
double weight = productWeight.multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
item.setIncrCount(weight);
|
||||
}
|
||||
return item;
|
||||
}).toList();
|
||||
}).filter(v -> ObjectUtil.isNotEmpty(v.getIncrCount()) && v.getIncrCount() > 0).toList();
|
||||
dto.setItems(list);
|
||||
R updateSkuStockRes = supermarketSpuService.updateSpuStock(dto);
|
||||
if (updateSkuStockRes.getCode() != 0) {
|
||||
@@ -916,6 +945,13 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
DeductionSpuStockDto entity = new DeductionSpuStockDto();
|
||||
entity.setHardSpuId(v.getProductId());
|
||||
entity.setIncrCount(v.getProductCount());
|
||||
// 如果退款购物车数组里有,就用退款购物车的数量
|
||||
if (ObjectUtil.isNotEmpty(refundCarList)) {
|
||||
HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) {
|
||||
entity.setIncrCount(refundCarTarget.getProductCount());
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
}).toList();
|
||||
// 查询订单流程
|
||||
|
||||
+3
-1
@@ -9,6 +9,7 @@
|
||||
a.product_id,
|
||||
a.product_name,
|
||||
a.product_pic,
|
||||
a.product_nature,
|
||||
a.product_price,
|
||||
a.product_count,
|
||||
a.product_weight,
|
||||
@@ -41,7 +42,8 @@
|
||||
a.product_id,
|
||||
a.product_name,
|
||||
a.product_pic,
|
||||
sum(a.product_price) as productPrice,
|
||||
a.product_nature,
|
||||
a.product_price,
|
||||
sum(a.product_count) as productCount,
|
||||
sum(a.product_weight) as productWeight,
|
||||
sum(a.total_price) as totalPrice,
|
||||
|
||||
Reference in new issue
Block a user