Эх сурвалжийг харах

提现代付慧算封装接口

mac 2 жил өмнө
parent
commit
345f2ad226

+ 8 - 1
kxs-common/kxs-common-cash/src/main/java/com/kxs/common/cash/service/hs/HsCashService.java

@@ -6,6 +6,7 @@ import cn.hutool.core.date.LocalDateTimeUtil;
 import cn.hutool.core.lang.TypeReference;
 import cn.hutool.core.map.MapBuilder;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
@@ -51,6 +52,10 @@ public class HsCashService implements CashService {
     @Override
     public Boolean cash(CashRequest cashReq) {
 
+        if(StrUtil.isBlank(cashReq.getIfCode())){
+            throw new GlobalCustomerException("ifCode不能为空");
+        }
+
         IsvParams isvParams = configContextService.getParams(cashReq.getIfCode());
         if (isvParams instanceof HsIsvParams hsIsvParams && cashReq instanceof HsCashRequest hsCashRequest) {
 
@@ -59,10 +64,12 @@ public class HsCashService implements CashService {
                 String response = send(hsIsvParams, hsCashRequest);
                 HsCashCommRes<HsCashPayRes> commRes = JSONUtil.toBean(response, new TypeReference<>() {}, true);
                 if(commRes.getCode() != 0){
-                    throw new RuntimeException(commRes.getErrorDesc());
+                    throw new GlobalCustomerException(hsCashRequest.getAcctName() + commRes.getErrorDesc());
                 }
                 return Boolean.TRUE;
 
+            } catch (GlobalCustomerException e){
+                throw new GlobalCustomerException(e.getMessage());
             } catch (Exception e) {
                 log.error("发起提现任务失败{}", JSON.toJSONString(hsCashRequest), e);
                 throw new GlobalCustomerException("发起提现任务失败,请联系管理员");