mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 汇付会员账户表实体类
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
package com.jsowell.adapay.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||
import com.huifu.adapay.model.Member;
|
||||
@@ -13,13 +10,14 @@ import com.jsowell.adapay.response.QueryMemberResponse;
|
||||
import com.jsowell.adapay.vo.AdapayAccountBalanceVO;
|
||||
import com.jsowell.adapay.vo.AdapayMemberVO;
|
||||
import com.jsowell.adapay.vo.AdapaySettleAccountVO;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.pile.domain.AdapayMemberAccount;
|
||||
import com.jsowell.pile.domain.AdapayMemberInfo;
|
||||
import com.jsowell.pile.domain.AdapaySettleAccount;
|
||||
import com.jsowell.pile.service.AdapayMemberInfoService;
|
||||
import com.jsowell.pile.service.IAdapayMemberAccountService;
|
||||
import com.jsowell.pile.service.IAdapaySettleAccountService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -45,6 +43,9 @@ public class AdapayMemberService {
|
||||
@Autowired
|
||||
private IAdapaySettleAccountService adapaySettleAccountService;
|
||||
|
||||
@Autowired
|
||||
private IAdapayMemberAccountService adapayMemberAccountService;
|
||||
|
||||
/**
|
||||
* 创建汇付会员
|
||||
* @param dto
|
||||
@@ -52,13 +53,14 @@ public class AdapayMemberService {
|
||||
*/
|
||||
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
|
||||
public void createMember(AdapayMemberInfoDTO dto) throws Exception {
|
||||
AdapayMemberInfo adapayMemberInfo = adapayMemberInfoService.selectByMerchantId(dto.getMerchantId());
|
||||
if (adapayMemberInfo != null) {
|
||||
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(dto.getMerchantId());
|
||||
if (adapayMemberAccount != null) {
|
||||
return;
|
||||
}
|
||||
log.info("=======execute CreateMember begin=======");
|
||||
Map<String, Object> memberParams = Maps.newHashMap();
|
||||
memberParams.put("member_id", "AM" + IdUtils.getMemberId());
|
||||
String adapayMemberId = "AM" + IdUtils.getMemberId();
|
||||
memberParams.put("member_id", adapayMemberId);
|
||||
memberParams.put("app_id", ADAPAY_APP_ID);
|
||||
memberParams.put("location", dto.getLocation());
|
||||
memberParams.put("email", dto.getEmail());
|
||||
@@ -73,17 +75,8 @@ public class AdapayMemberService {
|
||||
String errorMsg = member == null ? "创建汇付用户失败" : (String) member.get("error_msg");
|
||||
throw new BusinessException("00500001", errorMsg);
|
||||
}
|
||||
// 创建成功保存到数据库
|
||||
JSONObject jsonObject = JSON.parseObject(String.valueOf(member));
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
|
||||
adapayMemberInfo = mapper.readValue(jsonObject.toJSONString(), AdapayMemberInfo.class);
|
||||
adapayMemberInfo.setMerchantId(dto.getMerchantId());
|
||||
adapayMemberInfoService.insert(adapayMemberInfo);
|
||||
|
||||
dto.setAdapayMemberId(adapayMemberInfo.getMemberId());
|
||||
// 创建结算账户
|
||||
// createSettleAccount(dto);
|
||||
Map<String, Object> accountInfo = Maps.newHashMap();
|
||||
// 银行卡号
|
||||
accountInfo.put("card_id", dto.getCardId());
|
||||
@@ -105,7 +98,7 @@ public class AdapayMemberService {
|
||||
accountInfo.put("area_code", dto.getAreaCode());
|
||||
|
||||
Map<String, Object> settleCountParams = Maps.newHashMap();
|
||||
settleCountParams.put("member_id", dto.getAdapayMemberId());
|
||||
settleCountParams.put("member_id", adapayMemberId);
|
||||
settleCountParams.put("app_id", ADAPAY_APP_ID);
|
||||
// channel String Y 目前仅支持:bank_account(银行卡)
|
||||
settleCountParams.put("channel", "bank_account");
|
||||
@@ -117,22 +110,14 @@ public class AdapayMemberService {
|
||||
String errorMsg = settleCount == null ? "创建汇付结算账户失败" : (String) settleCount.get("error_msg");
|
||||
throw new BusinessException("00500001", errorMsg);
|
||||
}
|
||||
JSONObject account_info = JSON.parseObject((String) settleCount.get("account_info"));
|
||||
|
||||
AdapaySettleAccount adapaySettleAccount = new AdapaySettleAccount();
|
||||
adapaySettleAccount.setSettleAccountId((String) settleCount.get("id"));
|
||||
adapaySettleAccount.setMerchantId(dto.getMerchantId());
|
||||
adapaySettleAccount.setAdapayMemberId(dto.getAdapayMemberId());
|
||||
adapaySettleAccount.setCardId(dto.getCardId());
|
||||
adapaySettleAccount.setCardName(dto.getCardName());
|
||||
adapaySettleAccount.setCertId(dto.getCertId());
|
||||
adapaySettleAccount.setCertType(Constants.DOUBLE_ZERO);
|
||||
adapaySettleAccount.setTelNo(dto.getTelNo());
|
||||
adapaySettleAccount.setBankAcctType(dto.getBankAcctType());
|
||||
adapaySettleAccount.setBankCode(account_info.getString("bank_code"));
|
||||
adapaySettleAccount.setProvCode(account_info.getString("prov_code"));
|
||||
adapaySettleAccount.setAreaCode(account_info.getString("area_code"));
|
||||
adapaySettleAccountService.insertAdapaySettleAccount(adapaySettleAccount);
|
||||
String settleAccountId = (String) settleCount.get("id");
|
||||
// 保存到数据库
|
||||
adapayMemberAccount = new AdapayMemberAccount();
|
||||
adapayMemberAccount.setMerchantId(dto.getMerchantId());
|
||||
adapayMemberAccount.setAdapayMemberId(adapayMemberId);
|
||||
adapayMemberAccount.setSettleAccountId(settleAccountId);
|
||||
adapayMemberAccountService.insertAdapayMemberAccount(adapayMemberAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,4 +60,6 @@ public interface AdapayMemberAccountMapper {
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAdapayMemberAccountByIds(Long[] ids);
|
||||
|
||||
AdapayMemberAccount selectByMerchantId(String merchantId);
|
||||
}
|
||||
|
||||
@@ -58,4 +58,6 @@ public interface IAdapayMemberAccountService {
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAdapayMemberAccountById(Long id);
|
||||
|
||||
AdapayMemberAccount selectByMerchantId(String merchantId);
|
||||
}
|
||||
|
||||
@@ -87,4 +87,9 @@ public class AdapayMemberAccountServiceImpl implements IAdapayMemberAccountServi
|
||||
public int deleteAdapayMemberAccountById(Long id) {
|
||||
return adapayMemberAccountMapper.deleteAdapayMemberAccountById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdapayMemberAccount selectByMerchantId(String merchantId) {
|
||||
return adapayMemberAccountMapper.selectByMerchantId(merchantId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jsowell.pile.mapper.AdapayMemberAccountMapper">
|
||||
|
||||
<resultMap type="AdapayMemberAccount" id="AdapayMemberAccountResult">
|
||||
<resultMap type="com.jsowell.pile.domain.AdapayMemberAccount" id="AdapayMemberAccountResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="merchantId" column="merchant_id" />
|
||||
<result property="adapayMemberId" column="adapay_member_id" />
|
||||
@@ -16,11 +16,17 @@
|
||||
<result property="delFlag" column="del_flag" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAdapayMemberAccountVo">
|
||||
select id, merchant_id, adapay_member_id, settle_account_id, create_time, create_by, update_time, update_by, del_flag from adapay_member_account
|
||||
<sql id="Base_Column_List">
|
||||
id, merchant_id, adapay_member_id, settle_account_id, create_time, create_by, update_time, update_by, del_flag
|
||||
</sql>
|
||||
|
||||
<select id="selectAdapayMemberAccountList" parameterType="AdapayMemberAccount" resultMap="AdapayMemberAccountResult">
|
||||
<sql id="selectAdapayMemberAccountVo">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from adapay_member_account
|
||||
</sql>
|
||||
|
||||
<select id="selectAdapayMemberAccountList" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" resultMap="AdapayMemberAccountResult">
|
||||
<include refid="selectAdapayMemberAccountVo"/>
|
||||
<where>
|
||||
<if test="merchantId != null and merchantId != ''"> and merchant_id = #{merchantId}</if>
|
||||
@@ -34,7 +40,7 @@
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertAdapayMemberAccount" parameterType="AdapayMemberAccount" useGeneratedKeys="true" keyProperty="id">
|
||||
<insert id="insertAdapayMemberAccount" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into adapay_member_account
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="merchantId != null">merchant_id,</if>
|
||||
@@ -58,7 +64,7 @@
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAdapayMemberAccount" parameterType="AdapayMemberAccount">
|
||||
<update id="updateAdapayMemberAccount" parameterType="com.jsowell.pile.domain.AdapayMemberAccount">
|
||||
update adapay_member_account
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="merchantId != null">merchant_id = #{merchantId},</if>
|
||||
@@ -83,4 +89,12 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectByMerchantId" resultType="com.jsowell.pile.domain.AdapayMemberAccount">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from adapay_member_account
|
||||
where del_flag = '0'
|
||||
and merchant_id = #{merchantId,jdbcType=VARCHAR}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user