提交 0967f299 作者: zhenjie

Merge branch 'develop' of ssh://git.mmcuav.cn:8222/iuav/cms into develop

...@@ -42,22 +42,12 @@ public class PayWalletController extends BaseController { ...@@ -42,22 +42,12 @@ public class PayWalletController extends BaseController {
return ResultBody.success(payWalletService.getPayWalletInfo(userAccountId)); return ResultBody.success(payWalletService.getPayWalletInfo(userAccountId));
} }
// @ApiOperation(value = "feign-初始化钱包")
// @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
// @ApiIgnore
// @GetMapping("feignInitPayWallet")
// public ResultBody feignInitPayWallet(@RequestParam Integer userAccountId) {
// return payWalletService.initPayWallet(userAccountId);
// }
@ApiOperation(value = "feign-云享金充值增加金额") @ApiOperation(value = "feign-云享金充值增加金额")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("feignTopUpCash") @PostMapping("feignTopUpCash")
public ResultBody feignTopUpCash(@RequestBody TopUpOrderVO topUpOrderVO) { public ResultBody feignTopUpCash(@RequestBody TopUpOrderVO topUpOrderVO) {
return payWalletService.feignTopUpCash(topUpOrderVO); return payWalletService.feignTopUpCash(topUpOrderVO);
} }
@ApiOperation(value = "feign-钱包流水记录") @ApiOperation(value = "feign-钱包流水记录")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
......
...@@ -46,5 +46,5 @@ public interface PayWalletDao { ...@@ -46,5 +46,5 @@ public interface PayWalletDao {
List<XzWithdrawalApplyDO> listPageWithdrawalApply(WithdrawalApplyQO param); List<XzWithdrawalApplyDO> listPageWithdrawalApply(WithdrawalApplyQO param);
void updateWithdrawalApply(XzWithdrawalApplyDO apply); int updateWithdrawalApply(XzWithdrawalApplyDO apply);
} }
...@@ -39,6 +39,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -39,6 +39,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.crypto.Cipher; import javax.crypto.Cipher;
...@@ -273,6 +274,7 @@ public class XzServiceImpl implements XzService { ...@@ -273,6 +274,7 @@ public class XzServiceImpl implements XzService {
} }
@Override @Override
@Transactional
public String xzWithdrawNotify(JSONObject notify) { public String xzWithdrawNotify(JSONObject notify) {
log.info("xzWithdrawNotify获取到的推送结果:{}", notify.toString()); log.info("xzWithdrawNotify获取到的推送结果:{}", notify.toString());
if (XzEnums.T.getCode().equals(notify.get(XzEnums.is_success.getCode()).toString())) { if (XzEnums.T.getCode().equals(notify.get(XzEnums.is_success.getCode()).toString())) {
...@@ -303,40 +305,59 @@ public class XzServiceImpl implements XzService { ...@@ -303,40 +305,59 @@ public class XzServiceImpl implements XzService {
xzWithdrawalApplyDO.setTradeResult(data.getTradeResult()); xzWithdrawalApplyDO.setTradeResult(data.getTradeResult());
xzWithdrawalApplyDO.setTradeStatus(data.getTradeStatus()); xzWithdrawalApplyDO.setTradeStatus(data.getTradeStatus());
payWalletDao.updateWithdrawalApply(xzWithdrawalApplyDO); payWalletDao.updateWithdrawalApply(xzWithdrawalApplyDO);
// 并且回滚用户钱包信息 // 提现失败回滚用户金额
// 生成提现流水编号 callbackUserPayWallet(data, withdrawCashApplyDetails, wallet);
String payNo = "T" + TDateUtil.getDateStr(new Date(), TDateUtil.TYPE) + withdrawCashApplyDetails.getUserAccountId() + CodeUtil.getRandomNum(4);
// 记录流水记录
WithdrawalLogDO withdrawalLogDO = new WithdrawalLogDO();
withdrawalLogDO.setPayNo(payNo);
withdrawalLogDO.setXzWithdrawalApplyId(withdrawCashApplyDetails.getId());
withdrawalLogDO.setPayTime(new Date());
withdrawalLogDO.setUserAccountId(withdrawCashApplyDetails.getUserAccountId());
withdrawalLogDO.setSalaryPaid(data.getPayAmount());
withdrawalLogDO.setPayMethod(WithdrawalMethod.TXSB.getCode());
withdrawalLogDO.setSalaryFreeze(new BigDecimal(0));
payWalletDao.insertWithdrawalLog(withdrawalLogDO);
// 修改钱包信息,钱包冻结金额
PayWalletDO payWalletDO = new PayWalletDO();
payWalletDO.setPid(wallet.getPid());
payWalletDO.setUserAccountId(withdrawCashApplyDetails.getUserAccountId());
payWalletDO.setSalaryAmt(wallet.getSalaryAmt().add(data.getPayAmount()));
payWalletDO.setSalaryFreeze(wallet.getSalaryFreeze().subtract(data.getPayAmount()));
int updateCount = payWalletDao.updatePayWallet(payWalletDO);
if (updateCount != 1) {
log.error("回调返回提现失败时,修改钱包信息失败,信息是:{}", JSON.toJSONString(payWalletDO));
}
} }
} else if (XzEnums.trade_result.getCode().equals(data.getNotifyType())) { } else if (XzEnums.trade_result.getCode().equals(data.getNotifyType())) {
// 根据回调信息返回数据更新提现申请 // 根据回调信息返回数据更新提现申请
if (withdrawCashApplyDetails.getTradeStatus() != null && withdrawCashApplyDetails.getTradeStatus().equals(XzEnums.success.getCode())) { if (withdrawCashApplyDetails.getTradeStatus() != null && withdrawCashApplyDetails.getTradeStatus().equals(XzEnums.success.getCode())) {
return "success"; return "success";
} }
XzWithdrawalApplyDO xzWithdrawalApplyDO = new XzWithdrawalApplyDO();
int updateCount;
// 判断返回的是成功还是失败 // 判断返回的是成功还是失败
if (XzEnums.success.getCode().equals(data.getTradeStatus())) { if (XzEnums.success.getCode().equals(data.getTradeStatus())) {
// 修改提现申请状态
xzWithdrawalApplyDO.setTradeStatus(XzEnums.success.getCode());
xzWithdrawalApplyDO.setTradeTime(data.getTradeTime());
xzWithdrawalApplyDO.setOuterTradeNo(data.getOuterTradeNo());
xzWithdrawalApplyDO.setFrontLogNo(data.getFrontLogNo());
xzWithdrawalApplyDO.setTradeResult(data.getTradeResult());
updateCount = payWalletDao.updateWithdrawalApply(xzWithdrawalApplyDO);
if (updateCount != 1) {
log.error("回调返回提现成功时,修改提现申请信息失败,信息是:{}", JSON.toJSONString(xzWithdrawalApplyDO));
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "error";
}
} else if (XzEnums.handle.getCode().equals(data.getTradeStatus())) {
// 修改提现申请状态
xzWithdrawalApplyDO.setTradeStatus(XzEnums.handle.getCode());
xzWithdrawalApplyDO.setTradeTime(data.getTradeTime());
xzWithdrawalApplyDO.setOuterTradeNo(data.getOuterTradeNo());
xzWithdrawalApplyDO.setFrontLogNo(data.getFrontLogNo());
xzWithdrawalApplyDO.setTradeResult(data.getTradeResult());
updateCount = payWalletDao.updateWithdrawalApply(xzWithdrawalApplyDO);
if (updateCount != 1) {
log.error("回调返回提现交易中时,修改提现申请信息失败,信息是:{}", JSON.toJSONString(xzWithdrawalApplyDO));
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "error";
}
} else {
// 修改提现申请状态
xzWithdrawalApplyDO.setTradeStatus(XzEnums.failure.getCode());
xzWithdrawalApplyDO.setErrorMessage(data.getTradeFailCode());
xzWithdrawalApplyDO.setTradeTime(data.getTradeTime());
xzWithdrawalApplyDO.setOuterTradeNo(data.getOuterTradeNo());
xzWithdrawalApplyDO.setTradeResult(data.getTradeResult());
updateCount = payWalletDao.updateWithdrawalApply(xzWithdrawalApplyDO);
if (updateCount != 1) {
log.error("回调返回提现交易中时,修改提现申请信息失败,信息是:{}", JSON.toJSONString(xzWithdrawalApplyDO));
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "error";
}
// 提现失败回滚用户金额
callbackUserPayWallet(data, withdrawCashApplyDetails, wallet);
} }
} }
} else { } else {
log.info("xzWithdrawNotify fail:{}", notify); log.info("xzWithdrawNotify fail:{}", notify);
...@@ -345,6 +366,32 @@ public class XzServiceImpl implements XzService { ...@@ -345,6 +366,32 @@ public class XzServiceImpl implements XzService {
return "success"; return "success";
} }
@Transactional(rollbackFor = Exception.class)
public void callbackUserPayWallet(WithdrawalResp.Data data, XzWithdrawalApplyDO withdrawCashApplyDetails, PayWalletDO wallet) {
String payNo = "T" + TDateUtil.getDateStr(new Date(), TDateUtil.TYPE) + withdrawCashApplyDetails.getUserAccountId() + CodeUtil.getRandomNum(4);
// 记录流水记录
WithdrawalLogDO withdrawalLogDO = new WithdrawalLogDO();
withdrawalLogDO.setPayNo(payNo);
withdrawalLogDO.setXzWithdrawalApplyId(withdrawCashApplyDetails.getId());
withdrawalLogDO.setPayTime(new Date());
withdrawalLogDO.setUserAccountId(withdrawCashApplyDetails.getUserAccountId());
withdrawalLogDO.setSalaryPaid(data.getPayAmount());
withdrawalLogDO.setPayMethod(WithdrawalMethod.TXSB.getCode());
withdrawalLogDO.setSalaryFreeze(new BigDecimal(0));
payWalletDao.insertWithdrawalLog(withdrawalLogDO);
// 修改钱包信息,钱包冻结金额
PayWalletDO payWalletDO = new PayWalletDO();
payWalletDO.setPid(wallet.getPid());
payWalletDO.setUserAccountId(withdrawCashApplyDetails.getUserAccountId());
payWalletDO.setSalaryAmt(wallet.getSalaryAmt().add(data.getPayAmount()));
payWalletDO.setSalaryFreeze(wallet.getSalaryFreeze().subtract(data.getPayAmount()));
int updatePayWalletCount = payWalletDao.updatePayWallet(payWalletDO);
if (updatePayWalletCount != 1) {
log.error("回调返回提现失败时,修改钱包信息失败,信息是:{}", JSON.toJSONString(payWalletDO));
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
}
public String decrypt(String aesData) { public String decrypt(String aesData) {
try { try {
byte[] raw = userSystemConstant.getXzAppSecret().getBytes("ASCII"); byte[] raw = userSystemConstant.getXzAppSecret().getBytes("ASCII");
......
...@@ -18,4 +18,4 @@ patches: ...@@ -18,4 +18,4 @@ patches:
images: images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG - name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms
newTag: c691a3e53ee0c171aea036abdb27532a8056f41e newTag: c888e97c2d1b188e9513246df4b49c156c243aec
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论