Bladeren bron

商户转账

igl 3 maanden geleden
bovenliggende
commit
30d11eec82

+ 25 - 18
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/AssetServiceImpl.java

@@ -303,24 +303,31 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset> implements
                 //失败解冻金额
                 baseMapper.backFrozen(amount, withdraw.getUserId(), withdraw.getType(), LocalDateTime.now());
             } else {
-                //用户提现
-                Long withdrawId = withdrawService.createWithdraw(withdraw.getUserId(), 1, amount, 1, 0);
-                //商户提现操作
-                String sxyMerchantId = param.getReceiverId();
-                //生成提现参数
-                HashMap<String, Object> map = new HashMap<>();
-                map.put("merchantId", sxyMerchantId);
-                map.put("requestId", withdrawId);
-                map.put("withdrawAmount", amount.multiply(new BigDecimal("100")));
-                map.put("notifyUrl", TradeConstant.WITHDRAW_NOTIFY_URL);
-                map.put("remark", "");
-                Gson gson = new Gson();
-                JSONObject json = TradeHandle.handle(gson.toJson(map),
-                        TradeConstant.WITHDRAW_URL, sxyMerchantId, TradeConstant.PARTNER_ID);
-                String result = json.getString("status");
-                if(!"SUCCESS".equals(result)){
-                    //提现申请失败
-                    withdrawService.updateStatusById(withdrawId, 2);
+                Integer type = withdraw.getType();
+                if(type == 2){
+                    //商家转账-更新余额
+                    baseMapper.deductFrozen(amount, withdraw.getUserId(), withdraw.getType(), LocalDateTime.now());
+                } else {
+                    //用户转账-继续提现操作
+                    //用户提现
+                    Long withdrawId = withdrawService.createWithdraw(withdraw.getUserId(), 1, amount, 1, 0);
+                    //商户提现操作
+                    String sxyMerchantId = param.getReceiverId();
+                    //生成提现参数
+                    HashMap<String, Object> map = new HashMap<>();
+                    map.put("merchantId", sxyMerchantId);
+                    map.put("requestId", withdrawId);
+                    map.put("withdrawAmount", amount.multiply(new BigDecimal("100")));
+                    map.put("notifyUrl", TradeConstant.WITHDRAW_NOTIFY_URL);
+                    map.put("remark", "");
+                    Gson gson = new Gson();
+                    JSONObject json = TradeHandle.handle(gson.toJson(map),
+                            TradeConstant.WITHDRAW_URL, sxyMerchantId, TradeConstant.PARTNER_ID);
+                    String result = json.getString("status");
+                    if(!"SUCCESS".equals(result)){
+                        //提现申请失败
+                        withdrawService.updateStatusById(withdrawId, 2);
+                    }
                 }
             }
         }