|
|
@@ -36,13 +36,12 @@ public class WalletFeignServiceImpl implements WalletFeignService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public WalletModel getWallet(String oid, WalletType walletType, String shopId, String userId) {
|
|
|
+ public ResultContent<WalletModel> getWallet(String oid, WalletType walletType, String shopId, String userId) {
|
|
|
|
|
|
- return toModel(findWallet(oid, walletType, shopId, userId));
|
|
|
+ return ResultContent.buildContent(toModel(findWallet(oid, walletType, shopId, userId)));
|
|
|
}
|
|
|
|
|
|
@NotNull
|
|
|
- @Transactional
|
|
|
private Wallet findWallet(String oid, @NotNull WalletType walletType, String shopId, String userId){
|
|
|
Wallet wallet = null;
|
|
|
if (walletType.equals(WalletType.User)){
|
|
|
@@ -104,47 +103,47 @@ public class WalletFeignServiceImpl implements WalletFeignService {
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
- /** 发起退款 */
|
|
|
- @Transactional
|
|
|
- public ResultContent frozen(AmountUpdateParam param){
|
|
|
- Wallet shopWallet = findWallet(param.getOid(), WalletType.Shop, param.getShopId(), param.getUserId());
|
|
|
-
|
|
|
-// if (shopWallet.getAmount().compareTo(param.getTotal()) < 0 ){
|
|
|
-// return ResultContent.buildFail("可用余额不足");
|
|
|
-// }
|
|
|
-// if (shopWallet.getTotalAmount().compareTo(param.getTotal()) < 0 ){
|
|
|
-// return ResultContent.buildFail("总额不足");
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- shopWallet.setAmount(shopWallet.getAmount().subtract(param.getTotal()));
|
|
|
- walletDao.save(shopWallet);
|
|
|
- createWalletFlow(shopWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.Frozen, param.getAttach(), param.getSchoolId());
|
|
|
- return ResultContent.buildSuccess();
|
|
|
- }
|
|
|
-
|
|
|
- /** 退款(审批失败) */
|
|
|
- @Transactional
|
|
|
- public ResultContent cancelFrozen(AmountUpdateParam param){
|
|
|
- Wallet shopWallet = findWallet(param.getOid(), WalletType.Shop, param.getShopId(), param.getUserId());
|
|
|
- shopWallet.setAmount(shopWallet.getAmount().add(param.getTotal()));
|
|
|
- walletDao.save(shopWallet);
|
|
|
- createWalletFlow(shopWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.CancelFrozen, param.getAttach(), param.getSchoolId());
|
|
|
- return ResultContent.buildSuccess();
|
|
|
- }
|
|
|
+// /** 发起退款 */
|
|
|
+// @Transactional
|
|
|
+// public ResultContent frozen(AmountUpdateParam param){
|
|
|
+// Wallet shopWallet = findWallet(param.getOid(), WalletType.Shop, param.getShopId(), param.getUserId());
|
|
|
+//
|
|
|
+//// if (shopWallet.getAmount().compareTo(param.getTotal()) < 0 ){
|
|
|
+//// return ResultContent.buildFail("可用余额不足");
|
|
|
+//// }
|
|
|
+//// if (shopWallet.getTotalAmount().compareTo(param.getTotal()) < 0 ){
|
|
|
+//// return ResultContent.buildFail("总额不足");
|
|
|
+//// }
|
|
|
+//
|
|
|
+//
|
|
|
+// shopWallet.setAmount(shopWallet.getAmount().subtract(param.getTotal()));
|
|
|
+// walletDao.save(shopWallet);
|
|
|
+// createWalletFlow(shopWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.Frozen, param.getAttach(), param.getSchoolId());
|
|
|
+// return ResultContent.buildSuccess();
|
|
|
+// }
|
|
|
+//
|
|
|
+// /** 退款(审批失败) */
|
|
|
+// @Transactional
|
|
|
+// public ResultContent cancelFrozen(AmountUpdateParam param){
|
|
|
+// Wallet shopWallet = findWallet(param.getOid(), WalletType.Shop, param.getShopId(), param.getUserId());
|
|
|
+// shopWallet.setAmount(shopWallet.getAmount().add(param.getTotal()));
|
|
|
+// walletDao.save(shopWallet);
|
|
|
+// createWalletFlow(shopWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.CancelFrozen, param.getAttach(), param.getSchoolId());
|
|
|
+// return ResultContent.buildSuccess();
|
|
|
+// }
|
|
|
|
|
|
- /** 退款(审批通过) */
|
|
|
+ /** 退款 */
|
|
|
@Transactional
|
|
|
public ResultContent refund(AmountUpdateParam param){
|
|
|
Wallet shopWallet = findWallet(param.getOid(), WalletType.Shop, param.getShopId(), param.getUserId());
|
|
|
|
|
|
BigDecimal amount = shopWallet.getAmount();
|
|
|
- //加上冻结金额
|
|
|
- BigDecimal _amount = amount.add(param.getTotal());
|
|
|
- if (_amount.compareTo(param.getTotal()) < 0 ){
|
|
|
+// //加上冻结金额
|
|
|
+// BigDecimal _amount = amount.add(param.getTotal());
|
|
|
+ if (amount.compareTo(param.getTotal()) < 0 ){
|
|
|
return ResultContent.buildFail("可用余额不足");
|
|
|
}
|
|
|
-// shopWallet.setAmount(shopWallet.getAmount().add(param.getTotal()));
|
|
|
+ shopWallet.setAmount(shopWallet.getAmount().subtract(param.getTotal()));
|
|
|
shopWallet.setTotalAmount(shopWallet.getTotalAmount().subtract(param.getTotal()));
|
|
|
walletDao.save(shopWallet);
|
|
|
createWalletFlow(shopWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.Refund, param.getAttach(), param.getSchoolId());
|