feat:无用户支付
This commit is contained in:
1 parent
d695a2c63b
commit
fe79a9069e
2 files changed
+29
-13
No files matched your search
+25
-9
@@ -196,17 +196,24 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
public Long createOrder(HardCreateOrderDto dto) {
|
||||
MchManageVo mch = validateCreateOrderDto(dto);
|
||||
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("机器绑定的商户不存在");
|
||||
// 查询用户
|
||||
UserInfo userDetail = userService.getInnerByUserId(dto.getUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
|
||||
// 是否需要支付
|
||||
boolean isPay = isPay(dto.getOrderType(), dto.getOrderPayType());
|
||||
// 是否需要核销
|
||||
boolean isVerify = isVerify(dto.getOrderPayType());
|
||||
// 查询用户
|
||||
UserInfo userDetail = null;
|
||||
SysUser sysUser = null;
|
||||
if (isPay) {
|
||||
userDetail = userService.getInnerByUserId(dto.getUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
|
||||
sysUser = userDetail.getSysUser();
|
||||
}
|
||||
// 是否需要支付额外金额
|
||||
boolean isExtraPrice = isExtraPrice(dto.getSysType());
|
||||
// 默认使用该商户的钱包如果没有就用饭卡钱包
|
||||
WalletManageEntity wallet = null;
|
||||
if (isPay) {
|
||||
if (ObjectUtil.isNotEmpty(mch.getDefaultWalletTypeId())) {
|
||||
if (ObjectUtil.isEmpty(mch.getDefaultWalletTypeId())) {
|
||||
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.EAT);
|
||||
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
|
||||
} else {
|
||||
@@ -216,14 +223,14 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (ObjectUtil.isEmpty(wallet)) {
|
||||
throw new RuntimeException("用户钱包不存在");
|
||||
}
|
||||
} else {
|
||||
} else if (isVerify) {
|
||||
// 判断该二维码有没有被核销
|
||||
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());
|
||||
if (isExtraPrice) extraPrice = computeExtraPrice(totalPrice, mch, userDetail.getSysUser());
|
||||
if (isExtraPrice) extraPrice = computeExtraPrice(totalPrice, mch, sysUser);
|
||||
payPrice = totalPrice + extraPrice;
|
||||
if (isPay) {
|
||||
// 如果是支付的话,不能小于等于0
|
||||
@@ -238,8 +245,6 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
// 添加硬件订单
|
||||
HardOrderEntity orderObj = HardOrderEntity.builder()
|
||||
.androidOrderCode(dto.getAndroidOrderCode())
|
||||
.userId(dto.getUserId())
|
||||
.userDeptId(userDetail.getSysUser().getDeptId())
|
||||
.sysType(dto.getSysType().getType())
|
||||
.hourType(String.valueOf(dto.getHourType()))
|
||||
.parentCarId(parentCarId)
|
||||
@@ -258,6 +263,12 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
.isOfflineOrder(YesNoEnum.NO.getCode())
|
||||
.productDesc(subject)
|
||||
.build();
|
||||
if (ObjectUtil.isNotEmpty(sysUser)) {
|
||||
orderObj.setUserId(sysUser.getUserId());
|
||||
orderObj.setUserDeptId(sysUser.getDeptId());
|
||||
} else {
|
||||
orderObj.setUserId(-1L);
|
||||
}
|
||||
if (isPay) {
|
||||
orderObj.setWalletId(wallet.getId());
|
||||
}
|
||||
@@ -266,7 +277,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
|
||||
// 钱包扣款
|
||||
getSelf().fastReduceBalance(orderObj);
|
||||
if (!isPay) {
|
||||
if (isVerify) {
|
||||
// 核销二维码
|
||||
getSelf().cancelCode(orderObj, userDetail);
|
||||
}
|
||||
@@ -837,6 +848,11 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
return true;
|
||||
}
|
||||
|
||||
// 是否需要核销
|
||||
private boolean isVerify(HardPayTypeEnum payType) {
|
||||
return HardPayTypeEnum.isNotPay.contains(payType);
|
||||
}
|
||||
|
||||
// 是否需要额外支付(目前只有食堂需要)
|
||||
private boolean isExtraPrice(HardTypeEnum hardType) {
|
||||
return ObjectUtil.equals(hardType, HardTypeEnum.CANTEEN);
|
||||
|
||||
+4
-4
@@ -29,8 +29,8 @@ import java.util.Map;
|
||||
@SpringBootTest(classes = ThirdPartyApp.class)
|
||||
public class PayTest {
|
||||
|
||||
// private final String baseUrl = "http://123.156.230.15:8089/api";
|
||||
private final String baseUrl = "http://127.0.0.1:9999";
|
||||
private final String baseUrl = "http://123.156.230.15:8089/api";
|
||||
// private final String baseUrl = "http://127.0.0.1:9999";
|
||||
|
||||
private final String walletInfoUrl = "/third/third-pay-api/user-wallet";
|
||||
|
||||
@@ -80,7 +80,7 @@ public class PayTest {
|
||||
Map<String, Object> paramsMap = new HashMap<>();
|
||||
paramsMap.put("userId", 1875049673022279681L);
|
||||
paramsMap.put("thirdOrderId", System.currentTimeMillis());
|
||||
paramsMap.put("price", 1000);
|
||||
paramsMap.put("price", 800);
|
||||
paramsMap.put("products", null);
|
||||
String body = JSONUtil.toJsonStr(paramsMap);
|
||||
// 发送请求
|
||||
@@ -119,7 +119,7 @@ public class PayTest {
|
||||
public void walletRefund() throws Exception {
|
||||
ThirdKeyManageEntity config = getLbConfig();
|
||||
Map<String, Object> paramsMap = new HashMap<>();
|
||||
paramsMap.put("platformOrderId", "1928019909587054593");
|
||||
paramsMap.put("platformOrderId", "1928048358927982594");
|
||||
paramsMap.put("thirdRefundId", System.currentTimeMillis());
|
||||
paramsMap.put("price", "300");
|
||||
String body = JSONUtil.toJsonStr(paramsMap);
|
||||
|
||||
Reference in new issue
Block a user