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;
|
||||
}
|
||||
|
||||
|
||||
+24
-3
@@ -21,17 +21,17 @@ import com.bsd.pjcloud.hard.api.dto.code.QRCodeExtraDto;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletCodeUseDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletForeignEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletStrideEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletCodeUseVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletCodeUseMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
|
||||
import com.bsd.pjcloud.wallet.service.*;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.code.QRCodeDto;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletSettingService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
@@ -67,6 +67,10 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
|
||||
@Lazy
|
||||
private final WalletManageService walletManageService;
|
||||
private final WalletSettingService walletSettingService;
|
||||
@Lazy
|
||||
private final WalletStrideService walletStrideService;
|
||||
@Lazy
|
||||
private final WalletForeignService walletForeignService;
|
||||
|
||||
private final RemoteUserService userService;
|
||||
private final RemoteFileService remoteFileService;
|
||||
@@ -200,6 +204,23 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
|
||||
if (ObjectUtil.isEmpty(codeUse)) return null;
|
||||
if (ObjectUtil.equals(codeUse.getStatus(), YesNoEnum.YES.getCode())) return false;
|
||||
WalletCodeUseEntity updateObj = WalletCodeUseEntity.builder().id(codeUse.getId()).status(YesNoEnum.YES.getCode()).useTime(LocalDateTime.now()).build();
|
||||
// 如果是跨单位或者外来人员增加使用数量
|
||||
// 跨单位
|
||||
if (ObjectUtil.equals(codeUse.getBizType(), WalletCodeBizEnum.STRIDE.getCode())) {
|
||||
WalletStrideEntity strideDetail = walletStrideService.getById(codeUse.getBizId());
|
||||
if (ObjectUtil.isNotEmpty(strideDetail)) {
|
||||
WalletStrideEntity useUpdateObj = WalletStrideEntity.builder().id(strideDetail.getId()).useCount(strideDetail.getUseCount() + 1).build();
|
||||
walletStrideService.updateById(useUpdateObj);
|
||||
}
|
||||
}
|
||||
// 外来人员
|
||||
if (ObjectUtil.equals(codeUse.getBizType(), WalletCodeBizEnum.FOREIGN.getCode())) {
|
||||
WalletForeignEntity foreignDetail = walletForeignService.getById(codeUse.getBizId());
|
||||
if (ObjectUtil.isNotEmpty(foreignDetail)) {
|
||||
WalletForeignEntity useUpdateObj = WalletForeignEntity.builder().id(foreignDetail.getId()).useCount(foreignDetail.getUseCount() + 1).build();
|
||||
walletForeignService.updateById(useUpdateObj);
|
||||
}
|
||||
}
|
||||
return baseMapper.updateById(updateObj) > 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user