feat:适配跨单位和外来人员
This commit is contained in:
1 parent
8314f51dc5
commit
60bc959653
4 files changed
+55
-10
No files matched your search
+5
@@ -36,6 +36,11 @@ public enum HardPayTypeEnum {
|
||||
CASH
|
||||
);
|
||||
|
||||
public static final List<HardPayTypeEnum> isNotPay = List.of(
|
||||
STRIDE_DEPT_QR_CODE,
|
||||
FOREIGN_TICKET_QR_CODE
|
||||
);
|
||||
|
||||
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();
|
||||
|
||||
+3
-4
@@ -142,8 +142,8 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
case CANTEEN -> {
|
||||
// 查询食堂商品
|
||||
AtomicInteger canteenTotalPrice = new AtomicInteger();
|
||||
// 线上
|
||||
if (ObjectUtil.equals(HardOrderTypeEnum.RESERVE, orderType)) {
|
||||
// 线上
|
||||
List<CanteenOnlineSpuAppVO> supList = onlineCanteenSpuService.getSpuListByIds(productIds).getData();
|
||||
for (HardCreateCarDto v : list) {
|
||||
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
|
||||
@@ -151,9 +151,8 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
canteenTotalPrice.addAndGet(itemTotalPrice);
|
||||
});
|
||||
}
|
||||
}
|
||||
// 线下
|
||||
if (ObjectUtil.equals(HardOrderTypeEnum.BELOW, orderType)) {
|
||||
} else {
|
||||
// 线下
|
||||
List<CanteenSpuEntity> supList = canteenSpuService.getSpuListByIds(productIds).getData();
|
||||
for (HardCreateCarDto v : list) {
|
||||
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
|
||||
|
||||
+23
-3
@@ -216,6 +216,10 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (ObjectUtil.isEmpty(wallet)) {
|
||||
throw new RuntimeException("用户钱包不存在");
|
||||
}
|
||||
} else {
|
||||
// 判断该二维码有没有被核销
|
||||
boolean isCancel = validateCodeIsCancel(dto.getOrderType(), dto.getOrderSourceTypeId());
|
||||
if (isCancel) throw new RuntimeException("该二维码已被核销");
|
||||
}
|
||||
int totalPrice = 0, extraPrice = 0, payPrice = 0;
|
||||
totalPrice = hardCarService.computerCarTotalPrice(dto.getSysType(), dto.getOrderType(), dto.getList());
|
||||
@@ -254,12 +258,21 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
.isOfflineOrder(YesNoEnum.NO.getCode())
|
||||
.productDesc(subject)
|
||||
.build();
|
||||
if (isPay) orderObj.setWalletId(wallet.getId());
|
||||
if (isPay) {
|
||||
orderObj.setWalletId(wallet.getId());
|
||||
} else {
|
||||
orderObj.setPayPrice(0);
|
||||
}
|
||||
baseMapper.insert(orderObj);
|
||||
// 扣减库存
|
||||
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
|
||||
// 钱包扣款
|
||||
if (isPay) getSelf().fastReduceBalance(orderObj);
|
||||
if (isPay) {
|
||||
getSelf().fastReduceBalance(orderObj);
|
||||
} else {
|
||||
// 核销二维码
|
||||
getSelf().cancelCode(orderObj, userDetail);
|
||||
}
|
||||
// 发送mq消息
|
||||
getSelf().createOrderAfterSendMqMsg(orderObj.getId(), userDetail);
|
||||
return orderObj.getId();
|
||||
@@ -625,8 +638,12 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancelCode(HardOrderEntity order, UserInfo userInfo) {
|
||||
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
|
||||
if (!ObjectUtil.isAllNotEmpty(orderTypeEnum)) return;
|
||||
HardPayTypeEnum payType = HardPayTypeEnum.valueOfByType(order.getPayType());
|
||||
if (!ObjectUtil.isAllNotEmpty(orderTypeEnum, payType)) return;
|
||||
Long id = order.getId();
|
||||
if (HardPayTypeEnum.isNotPay.contains(payType) && ObjectUtil.isNotEmpty(order.getOrderSourceTypeId())) {
|
||||
id = order.getOrderSourceTypeId();
|
||||
}
|
||||
switch (orderTypeEnum) {
|
||||
// 线下购买
|
||||
case BELOW -> {
|
||||
@@ -818,6 +835,9 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (!HardOrderTypeEnum.isPay(type)) {
|
||||
return false;
|
||||
}
|
||||
if (HardPayTypeEnum.isNotPay.contains(payType)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user