|
|
|
@ -82,6 +82,9 @@ public class CashCollectionServiceImpl implements CashCollectionService { |
|
|
|
if (cashCollection.getPermanentGold() == 0 && cashCollection.getFreeGold() == 0) { |
|
|
|
throw new IllegalArgumentException("金币数量不能为空"); |
|
|
|
} |
|
|
|
if (cashCollection.getWalletId() == null || cashCollection.getWalletId() < 0 || cashCollection.getWalletId() > 10) { |
|
|
|
throw new IllegalArgumentException("钱包ID不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!cashCollection.getGoodsName().equals("金币充值")) { |
|
|
|
if (cashCollection.getGoodNum() == 0) { |
|
|
|
@ -119,6 +122,9 @@ public class CashCollectionServiceImpl implements CashCollectionService { |
|
|
|
cashRecord.setNumUnit(cashCollection.getNumUnit()); //数量单位 |
|
|
|
cashRecord.setPermanentGold(cashCollection.getPermanentGold()); //永久金币 |
|
|
|
cashRecord.setFreeGold(cashCollection.getFreeGold()); //免费金币 |
|
|
|
cashRecord.setWalletId(cashCollection.getWalletId()); // 钱包 ID |
|
|
|
// 打印钱包 ID |
|
|
|
log.info("钱包ID:{}", cashRecord.getWalletId()); |
|
|
|
cashRecord.setPaymentCurrency(cashCollection.getPaymentCurrency()); //付款币种 |
|
|
|
cashRecord.setPaymentAmount(cashCollection.getPaymentAmount()); //付款金额 |
|
|
|
cashRecord.setReceivedMarket(cashCollection.getReceivedMarket()); //到账地区 |
|
|
|
@ -127,7 +133,7 @@ public class CashCollectionServiceImpl implements CashCollectionService { |
|
|
|
cashRecord.setVoucher(cashCollection.getVoucher()); //转账凭证 |
|
|
|
cashRecord.setRemark(cashCollection.getRemark()); //备注 |
|
|
|
cashRecord.setStatus(0); //订单状态:付款线下财务待审核 |
|
|
|
cashRecord.setSubmitterId(cashCollection.getSubmitterId()); //提交人ID |
|
|
|
cashRecord.setSubmitterId(cashCollection.getSubmitterId()); //提交人 ID |
|
|
|
cashRecord.setSubmitterMarket(cashCollection.getSubmitterMarket()); |
|
|
|
cashRecord.setOrderType(1); //订单类型:1-收款 |
|
|
|
cashRecord.setMarket(cashCollection.getMarket()); |
|
|
|
@ -371,6 +377,7 @@ public class CashCollectionServiceImpl implements CashCollectionService { |
|
|
|
|
|
|
|
//补全手续费等内容 |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public String complete(CashRecord cashRecord) { |
|
|
|
|
|
|
|
|
|
|
|
@ -381,11 +388,47 @@ public class CashCollectionServiceImpl implements CashCollectionService { |
|
|
|
|
|
|
|
int rows = cashCollectionMapper.complete(cashRecord); |
|
|
|
String goodsName = cashCollectionMapper.selectGoodsNameByCode(cashRecord.getOrderCode()); |
|
|
|
if (goodsName .equals("金币充值")) { |
|
|
|
if (goodsName != null && goodsName.equals("金币充值")) { |
|
|
|
|
|
|
|
// 先从数据库中获取订单的 walletId , permanentGold 和 jwcode |
|
|
|
CashRecord dbRecord = cashCollectionMapper.selectByOrderCode(cashRecord.getOrderCode()); |
|
|
|
Integer walletId = dbRecord != null ? dbRecord.getWalletId() : null; |
|
|
|
Integer permanentGold = dbRecord != null ? dbRecord.getPermanentGold() : null; |
|
|
|
Integer jwcode = dbRecord != null ? dbRecord.getJwcode() : null; |
|
|
|
|
|
|
|
cashRecord.setOrderCode(cashRecord.getOrderCode().replace("XJ_", "XJCZ_")); |
|
|
|
//修改金币订单 |
|
|
|
cashCollectionMapper.updateGoldOrder(cashRecord); |
|
|
|
|
|
|
|
// 充值成功,增加用户钱包金币 |
|
|
|
if (walletId != null && permanentGold > 0) { |
|
|
|
try { |
|
|
|
// 尝试更新用户钱包余额 |
|
|
|
int updateRows = cashCollectionMapper.addUserWalletPermanentGold( |
|
|
|
jwcode, |
|
|
|
walletId, |
|
|
|
permanentGold |
|
|
|
); |
|
|
|
|
|
|
|
// 如果没有更新任何行,说明记录不存在,需要插入新记录 |
|
|
|
if (updateRows == 0) { |
|
|
|
UserRegionWallet wallet = new UserRegionWallet(); |
|
|
|
wallet.setJwcode(jwcode); |
|
|
|
wallet.setWalletId(walletId); |
|
|
|
wallet.setCurrentPermanentGold(new BigDecimal(permanentGold)); |
|
|
|
cashCollectionMapper.insertUserWallet(wallet); |
|
|
|
log.info("创建新的钱包记录:jwcode={}, walletId={}, permanentGold={}", |
|
|
|
jwcode, walletId, permanentGold); |
|
|
|
} else { |
|
|
|
log.info("充值成功:jwcode={}, walletId={}, 增加金币={}", |
|
|
|
jwcode, walletId, permanentGold); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("充值钱包失败:jwcode={}, walletId={}, error={}", |
|
|
|
jwcode, walletId, e.getMessage(), e); |
|
|
|
throw new RuntimeException("充值钱包失败:" + e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return rows > 0 ? "编辑成功" : "编辑失败"; |
|
|
|
} |
|
|
|
|