Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-06-17 17:59:48 +08:00
commit 7aba505038
6 files changed
+102 -4

No files matched your search

@@ -161,7 +161,7 @@ public class HardOrderController {
return R.ok(hardwareOrderService.join(id));
}
@Operation(summary = "app创建订单", description = "app创建订单")
@Operation(summary = "app创建食堂预定订单", description = "app创建食堂预定订单")
@GetMapping("/app/create-order")
@Idempotent(expireTime = 3, info = "正在创建订单中,请勿重复操作")
public R appCreateOrder(@RequestParam Long carParentId, @RequestParam Long apptId, @RequestParam HardTypeEnum hardType) {
@@ -170,6 +170,23 @@ public class HardOrderController {
return R.ok(hardwareOrderService.appCreateOrder(dto));
}
@Operation(summary = "app创建线上超市预定订单", description = "app创建线上超市预定订单")
@GetMapping("/app/create-supermarket-order")
@Idempotent(expireTime = 3, info = "正在创建订单中,请勿重复操作")
public R appCreateSupermarketReserveOrder(@RequestParam Long carParentId, @RequestParam HardTypeEnum hardType) {
PjcloudUser user = SecurityUtils.getUser();
HardAppCreateOrderDto dto = HardAppCreateOrderDto.builder()
.carParentId(carParentId).walletType(WalletTypeEnum.EAT)
.hardType(hardType)
.userId(user.getId())
.walletType(WalletTypeEnum.PAY)
.orderType(HardOrderTypeEnum.RESERVE)
.payType(HardPayTypeEnum.WALLET_DEFAULT)
.hardType(HardTypeEnum.SUPERMARKET)
.build();
return R.ok(hardwareOrderService.appCreateSupermarketReserveOrder(dto));
}
@Operation(summary = "app创建订单扫一扫", description = "app创建订单扫一扫")
@PostMapping("/app/create-order-scan-qrcode")
@Idempotent(expireTime = 5, info = "正在创建订单中,请勿重复操作")
@@ -43,10 +43,15 @@ public interface HardOrderService extends IService<HardOrderEntity> {
Long createOrder(HardCreateOrderDto dto);
/**
* 创建app订单
* app创建食堂预定订单
*/
Long appCreateOrder(@Valid HardAppCreateOrderDto dto);
/**
* app创建线上超市预定订单
*/
Long appCreateSupermarketReserveOrder(HardAppCreateOrderDto dto);
/**
* 创建app订单
*/
@@ -412,6 +412,75 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
return orderObj.getId();
}
/**
* app创建线上超市预定订单
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Long appCreateSupermarketReserveOrder(HardAppCreateOrderDto dto) {
// 查询用户
UserInfo userDetail = userService.getInnerByUserId(dto.getUserId()).getData();
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
// 钱包
WalletManageEntity wallet = remoteWalletService.getWallet(dto.getUserId(), dto.getWalletType()).getData();
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
// 查询父订单
HardParentCarEntity parentCar = hardCarService.getParentCarById(dto.getCarParentId());
if (ObjectUtil.isEmpty(parentCar)) throw new RuntimeException("购物车不存在");
// 查询商户
MchManageVo hardManager = remoteMchService.getById(parentCar.getMerchantId()).getData();
if (ObjectUtil.isEmpty(hardManager)) throw new RuntimeException("商户不存在");
// 查询父购物车
List<HardCarEntity> carList = hardCarService.getByParentCarId(dto.getCarParentId());
if (ObjectUtil.isEmpty(carList)) throw new RuntimeException("购物车不存在");
Integer balance = wallet.getBalance();
int totalPrice = (int) carList.stream().mapToLong(HardCarEntity::getTotalPrice).sum();
if (balance < totalPrice) {
throw new RuntimeException("钱包余额不足");
}
// 获取商品描述
List<HardCreateCarDto> carListDto = carList.stream().map(v -> {
HardCreateCarDto entity = new HardCreateCarDto();
entity.setParentCarId(dto.getCarParentId());
entity.setProductId(v.getProductId());
entity.setProductWeight(v.getProductWeight());
entity.setProductCount(v.getProductCount());
return entity;
}).toList();
HardTypeEnum hardType = ObjectUtil.equals(dto.getWalletType(), WalletTypeEnum.EAT) ? HardTypeEnum.CANTEEN : HardTypeEnum.SUPERMARKET;
String subject = hardCarService.computerCarSubject(hardType, dto.getOrderType(), carListDto);
// 添加硬件订单
HardOrderEntity orderObj = HardOrderEntity.builder()
.userId(dto.getUserId())
.userDeptId(userDetail.getSysUser().getDeptId())
.parentCarId(dto.getCarParentId())
.sysType(dto.getHardType().getType())
.orderStatus(HardOrderStatusEnum.CREATE.getType())
.merchantId(parentCar.getMerchantId())
.merchantType(hardManager.getTypes())
.merchantDeptId(hardManager.getDeptId())
.orderType(dto.getOrderType().getType())
.payType(dto.getPayType().getType())
.orderSourceTypeId(dto.getOrderSourceTypeId())
.totalPrice(totalPrice)
.extraPrice(0)
.payPrice(totalPrice)
.isOfflineOrder(YesNoEnum.NO.getCode())
.productDesc(subject)
.walletId(wallet.getId())
.build();
baseMapper.insert(orderObj);
// 钱包扣款
getSelf().fastReduceBalance(orderObj);
// 创建二维码
getSelf().generateCode(orderObj);
// 发送mq消息
getSelf().createOrderAfterSendMqMsg(orderObj.getId(), userDetail);
// 扣减库存
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
return orderObj.getId();
}
@Override
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
@@ -62,9 +62,9 @@ public class PayTest {
public void walletInfo() throws Exception {
ThirdKeyManageEntity config = getLbConfig();
Map<String, Object> paramsMap = new HashMap<>();
// paramsMap.put("signPhone", LbRetailSignUtils.sm4Encrypt("17683843141", config.getFieldKey()));
paramsMap.put("signPhone", LbRetailSignUtils.sm4Encrypt("17683843141", config.getFieldKey()));
// paramsMap.put("signPhone", "8KKubCKESDN5TlUl3i0HaQ==");
// paramsMap.put("userId", 1875049673022279681L);
paramsMap.put("userId", 1875049673022279681L);
String body = JSONUtil.toJsonStr(paramsMap);
// 发送请求
String res = HttpRequest.post(baseUrl + walletInfoUrl).contentType("application/json").header(apiCountersign(body)).body(body).execute().body();
@@ -83,6 +83,12 @@ public class WalletRechargeApplyEntity extends Model<WalletRechargeApplyEntity>
@JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
private LocalDate importTime;
/**
* 申请时间
*/
@Schema(description = "申请时间")
private LocalDateTime applyTime;
/**
* 备注
*/
@@ -228,6 +228,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
updateObj.setId(detail.getId());
updateObj.setProcessId(processId);
updateObj.setProcessStatus(TaskCheckStatusEnum.PADDING.getCode());
updateObj.setApplyTime(LocalDateTime.now());
baseMapper.updateById(updateObj);
// 更新之前的总金额
getSelf().updateBeforePrice(detail);