Explorar el Código

add ADApay member api

周箭河 hace 5 años
padre
commit
8f071e51d8

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/HfMemberService.java

@@ -10,5 +10,5 @@ public interface HfMemberService extends BaseService<Integer, HfMember> {
 
     Map<String,Object> createMember(HfMember member, File file) throws Exception;
 
-    Map<String,Object> createSettleAccount(String memberId) throws Exception;
+    Map<String,Object> createSettleAccount(String memberId, String cardNo, String bankCode) throws Exception;
 }

+ 16 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/HfMemberSserviceImpl.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.entity.HfMember;
 import com.ym.mec.biz.service.HfMemberService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.adapay.CorpMember;
 import com.ym.mec.thirdparty.adapay.SettleAccount;
@@ -68,27 +69,32 @@ public class HfMemberSserviceImpl extends BaseServiceImpl<Integer, HfMember> imp
     }
 
     @Override
-    public Map<String, Object> createSettleAccount(String memberId) throws Exception {
+    public Map<String, Object> createSettleAccount(String memberId, String cardNo, String bankCode) throws Exception {
         String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
         if (!baseUrl.equals("https://mstuonline.dayaedu.com")) {
             Adapay.prodMode = false;
         }
         HfMember hfMember = hfMemberDao.getByMemberId(memberId);
+        hfMember.setCardNo(cardNo);
+        hfMember.setBankCode(bankCode);
+        if (hfMemberDao.update(hfMember) <= 0) {
+            throw new BizException("绑卡失败");
+        }
 
         //删除结算账户
-        new SettleAccount().executeDeleteSettleAccount(hfMember.getSettleAccountId(),memberId);
+        SettleAccount.executeDeleteSettleAccount(hfMember.getSettleAccountId(), memberId);
 
         Map<String, Object> accountInfo = new HashMap<String, Object>();
-        accountInfo.put("card_id", "8110601012601166984");
-        accountInfo.put("card_name", "烟台乐谷文化艺术咨询有限公司");
-        accountInfo.put("tel_no", "17826031203");
-        accountInfo.put("bank_code", "03020000");
+        accountInfo.put("card_id", cardNo);
+        accountInfo.put("card_name", hfMember.getName());
+        accountInfo.put("tel_no", hfMember.getLegalMp());
+        accountInfo.put("bank_code", bankCode);
         accountInfo.put("bank_acct_type", "1");
-        accountInfo.put("prov_code", "0037");
-        accountInfo.put("area_code", "3715");
+        accountInfo.put("prov_code", hfMember.getProvCode());
+        accountInfo.put("area_code", hfMember.getAreaCode());
 
         //创建结算账户
-        //new SettleAccount().executeCreateSettleAccount(memberId,accountInfo);
-        return null;
+        Map<String, Object> objectMap = SettleAccount.executeCreateSettleAccount(memberId, accountInfo);
+        return objectMap;
     }
 }

+ 33 - 10
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/SettleAccount.java

@@ -4,6 +4,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import com.alibaba.fastjson.JSON;
+import com.huifu.adapay.core.exception.BaseAdaPayException;
 
 /**
  * @author yingyong.wang
@@ -365,7 +366,7 @@ public class SettleAccount extends ConfigInit {
         settleCountParams.put("notify_url", "");
 
         System.out.println("取现接口,请求参数:" + JSON.toJSONString(settleCountParams));
-        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.drawCash(settleCountParams,merchantKey);
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.drawCash(settleCountParams, merchantKey);
         System.out.println("取现接口返回参数" + JSON.toJSONString(settleCount));
         System.out.println("=======execute modify SettleAccount end=======");
 
@@ -392,16 +393,16 @@ public class SettleAccount extends ConfigInit {
 
 
         System.out.println("查询余额账户,请求参数:" + JSON.toJSONString(settleCountParams));
-        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.queryBalance(settleCountParams,merchantKey);
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.queryBalance(settleCountParams, merchantKey);
         System.out.println("查询余额账户,返回参数:" + JSON.toJSONString(settleCount));
         System.out.println("=======execute modify SettleAccount end=======");
 
         return settleCount;
     }
+
     /**
      * 取现
      *
-
      * @param app_id
      * @param member_id
      * @return
@@ -430,14 +431,13 @@ public class SettleAccount extends ConfigInit {
     /**
      * 查询余额
      *
-
      * @param app_id
      * @param member_id
      * @param settleCount_id
      * @return
      * @throws Exception
      */
-    public static Map<String, Object> executeQueryBalance( String app_id, String member_id, String settleCount_id) throws Exception {
+    public static Map<String, Object> executeQueryBalance(String app_id, String member_id, String settleCount_id) throws Exception {
         System.out.println("=======execute modify SettleAccount begin=======");
         Map<String, Object> settleCountParams = new HashMap<String, Object>();
 
@@ -461,16 +461,39 @@ public class SettleAccount extends ConfigInit {
      * @return delete的settleCount 对象
      * @throws Exception 异常
      */
-    public Map<String, Object> executeDeleteSettleAccount(String settleCount_id, String member_id) throws Exception {
-        System.out.println("=======execute delete SettleAccount begin=======");
+    public static Map<String, Object> executeDeleteSettleAccount(String settleCount_id, String member_id) throws Exception {
         Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
         settleCountParams.put("settle_account_id", settleCount_id);
         settleCountParams.put("member_id", member_id);
         settleCountParams.put("app_id", ConfigInit.appId);
-        System.out.println("删除结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
         Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.delete(settleCountParams);
-        System.out.println("删除结算账户,返回参数:" + JSON.toJSONString(settleCount));
-        System.out.println("=======execute delete SettleAccount end=======");
+        String error_code = (String) settleCount.get("error_code");
+        if (null != error_code) {
+            String errorMsg = (String) settleCount.get("error_msg");
+            throw new BaseAdaPayException(errorMsg);
+        }
+        return settleCount;
+    }
+
+
+    /**
+     * 创建 settleCount
+     *
+     * @return 创建的settleCount 对象
+     * @throws Exception 异常
+     */
+    public static Map<String, Object> executeCreateSettleAccount(String member_id, Map<String, Object> accountInfo) throws Exception {
+        Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
+        settleCountParams.put("member_id", member_id);
+        settleCountParams.put("app_id", ConfigInit.appId);
+        settleCountParams.put("channel", "bank_account");
+        settleCountParams.put("account_info", accountInfo);
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.create(settleCountParams);
+        String error_code = (String) settleCount.get("error_code");
+        if (null != error_code) {
+            String errorMsg = (String) settleCount.get("error_msg");
+            throw new BaseAdaPayException(errorMsg);
+        }
         return settleCount;
     }
 

+ 8 - 8
mec-web/src/main/java/com/ym/mec/web/controller/AdapayController.java

@@ -17,6 +17,8 @@ import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.excel.POIUtil;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.io.IOUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -51,8 +53,8 @@ public class AdapayController extends BaseController {
     @ApiOperation("新建企业用户")
     @PostMapping(value = "createMember")
     @PreAuthorize("@pcs.hasPermissions('adapay/createMember')")
-    public HttpResponseResult createMember(HfMember member) throws Exception {
-        if(member.getMultipartFile().isEmpty()){
+    public HttpResponseResult<Map<String, Object>> createMember(HfMember member) throws Exception {
+        if (member.getMultipartFile().isEmpty()) {
             return failed("证件压缩文件必传");
         }
         File file = new File("/var/tmp/" + member.getMultipartFile().getOriginalFilename());
@@ -76,24 +78,22 @@ public class AdapayController extends BaseController {
     @ApiOperation("创建结算账户")
     @PostMapping(value = "createSettleAccount")
     @PreAuthorize("@pcs.hasPermissions('adapay/createSettleAccount')")
-    public HttpResponseResult createSettleAccount(String memberId) throws Exception {
-        hfMemberService.createSettleAccount(memberId);
-        return null;
+    public HttpResponseResult<Map<String, Object>> createSettleAccount(String memberId, String cardNo, String bankCode) throws Exception {
+        return succeed(hfMemberService.createSettleAccount(memberId, cardNo, bankCode));
     }
 
     @ApiOperation("查询企业用户信息")
     @GetMapping(value = "getMemberInfo")
     @PreAuthorize("@pcs.hasPermissions('adapay/getMemberInfo')")
-    public HttpResponseResult getMemberInfo(String memberId) throws Exception {
+    public HttpResponseResult<Map<String, Object>> getMemberInfo(String memberId) throws Exception {
         String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
-        if(!baseUrl.equals("https://mstuonline.dayaedu.com")){
+        if (!baseUrl.equals("https://mstuonline.dayaedu.com")) {
             Adapay.prodMode = false;
         }
         return succeed(CorpMember.executeQueryMember(memberId));
     }
 
 
-
     @ApiOperation("导出对账单")
     @GetMapping(value = "exportBill")
     @PreAuthorize("@pcs.hasPermissions('adapay/exportBill')")