修改一下 Adapay member_id 的生成方式
This commit is contained in:
parent
604e7bc703
commit
7e03b61ab1
|
|
@ -3,6 +3,7 @@ package com.ghy.web.controller.customer;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.ghy.common.adapay.AdapayConfig;
|
||||
import com.ghy.common.adapay.AdapayService;
|
||||
import com.ghy.common.adapay.MemberType;
|
||||
import com.ghy.common.adapay.model.AdapayStatusEnum;
|
||||
import com.ghy.common.adapay.model.Merchant;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
|
|
@ -40,7 +41,7 @@ public class CustomerBankController {
|
|||
private AjaxResult bindBankCard(BindBankCardRequest request) throws BaseAdaPayException {
|
||||
Set<Merchant> merchants = AdapayConfig.getMerchants();
|
||||
for (Merchant merchant : merchants) {
|
||||
String memberId = AdapayUtils.getMemberId(request.getCustomerId(), merchant.getDeptId());
|
||||
String memberId = AdapayUtils.getMemberId(request.getCustomerId(), merchant.getDeptId(), MemberType.CUSTOMER);
|
||||
// 先在Adapay创建实名用户
|
||||
Map<String, Object> result1 = adapayService.createMember(merchant.getDeptId(), memberId, request.getPhone(),
|
||||
request.getName(), request.getCertId(), null, null, null, null);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.ghy.common.adapay;
|
||||
|
||||
public enum MemberType {
|
||||
WORKER("WK"),
|
||||
CUSTOMER("CS");
|
||||
|
||||
public final String code;
|
||||
|
||||
MemberType(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ghy.common.utils;
|
||||
|
||||
import com.ghy.common.adapay.MemberType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
|
@ -9,8 +10,19 @@ import org.springframework.util.Assert;
|
|||
@Slf4j
|
||||
public class AdapayUtils {
|
||||
|
||||
public static String getMemberId(Long memberId, Long deptId) {
|
||||
Assert.isTrue(Math.min(memberId, deptId) > 0, "Invalid [memberId] or [deptId]");
|
||||
return String.format("C%dD%d", memberId, deptId);
|
||||
/**
|
||||
* 生成 Adapay member_id
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* 当type=WORKER时用worker_id
|
||||
* 当type=CUSTOMER时用customer_id
|
||||
* @param deptId 所属公司
|
||||
* @param type 用户类型
|
||||
* @return member_id
|
||||
*/
|
||||
public static String getMemberId(Long userId, Long deptId, MemberType type) {
|
||||
Assert.isTrue(Math.min(userId, deptId) > 0, "Invalid [userId] or [deptId]");
|
||||
return String.format("%sU%dD%d", type.code, userId, deptId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ghy.customer.service.impl;
|
||||
|
||||
import com.ghy.common.adapay.MemberType;
|
||||
import com.ghy.common.utils.AdapayUtils;
|
||||
import com.ghy.customer.domain.CustomerBank;
|
||||
import com.ghy.customer.mapper.CustomerBankMapper;
|
||||
|
|
@ -45,7 +46,7 @@ public class CustomerBankServiceImpl implements CustomerBankService {
|
|||
|
||||
@Override
|
||||
public int insertCustomerBank(CustomerBank customerBank) {
|
||||
customerBank.setAdapayMemberId(AdapayUtils.getMemberId(customerBank.getCustomerId(), customerBank.getDeptId()));
|
||||
customerBank.setAdapayMemberId(AdapayUtils.getMemberId(customerBank.getCustomerId(), customerBank.getDeptId(), MemberType.CUSTOMER));
|
||||
return customerBankMapper.insertCustomerBank(customerBank);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue