Authored by gemingdan

银行卡身份证唯一,加开户城市

... ... @@ -16,6 +16,8 @@ public interface UnionShareUserBankMapper {
UnionShareUserBank selectByPrimaryKey(Integer id);
List<UnionShareUserBank> selectByUid(UnionShareUserBank bo);
int selectCountByIdCardNo(String idCardNo);
List<UnionShareUserBank> selectListByIdCardNo(String idCardNo);
int updateByPrimaryKeySelective(UnionShareUserBank record);
... ...
... ... @@ -32,6 +32,7 @@ public class UnionShareSettlement extends BaseBO {
private String bankName;
private String bankBranch;
private String bankCity;
private Byte status;
... ... @@ -199,6 +200,14 @@ public class UnionShareSettlement extends BaseBO {
this.idCardId = idCardId;
}
public String getBankCity() {
return bankCity;
}
public void setBankCity(String bankCity) {
this.bankCity = bankCity;
}
@Override
public String toString() {
return "UnionShareSettlement{" +
... ... @@ -219,6 +228,7 @@ public class UnionShareSettlement extends BaseBO {
", bankCardNo=" + bankCardNo +
", bankName=" + bankName +
", bankBranch=" + bankBranch +
", bankCity=" + bankCity +
", status=" + status +
", settlementStatus='" + settlementStatus + '\'' +
", updateTime=" + updateTime +
... ...
... ... @@ -11,6 +11,7 @@ public class UnionShareUserBank extends BaseBO{
private String bankName;
private String bankBranch;
private String bankCode;
private String bankCity;
private Byte status;
private Byte source;
... ... @@ -114,4 +115,12 @@ public class UnionShareUserBank extends BaseBO{
public void setBankBranch(String bankBranch) {
this.bankBranch = bankBranch;
}
public String getBankCity() {
return bankCity;
}
public void setBankCity(String bankCity) {
this.bankCity = bankCity;
}
}
\ No newline at end of file
... ...
... ... @@ -15,11 +15,12 @@
<result column="bank_card_no" property="bankCardNo" jdbcType="VARCHAR" />
<result column="bank_name" property="bankName" jdbcType="VARCHAR" />
<result column="bank_branch" property="bankBranch" jdbcType="VARCHAR" />
<result column="bank_city" property="bankCity" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, settlement_code, settlement_amount,tax_mount,after_tax_amount, id_card_id, settlement_time, promote_uid, name,id_card_no,bank_card_no,bank_name,bank_branch, status, update_time
id, settlement_code, settlement_amount,tax_mount,after_tax_amount, id_card_id, settlement_time, promote_uid, name,id_card_no,bank_card_no,bank_name,bank_branch,bank_city, status, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -51,12 +52,12 @@
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareSettlement" >
insert into union_share_settlement (id, settlement_code, settlement_amount, tax_mount, after_tax_amount,id_card_id,
settlement_time, promote_uid, name,id_card_no,bank_card_no,bank_name,bank_branch, status,
settlement_time, promote_uid, name,id_card_no,bank_card_no,bank_name,bank_branch,bank_city, status,
update_time)
values (#{id,jdbcType=INTEGER}, #{settlementCode,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL}, #{taxAmount,jdbcType=DECIMAL},
#{afterTaxAmount,jdbcType=DECIMAL},#{idCardId,jdbcType=INTEGER},
#{settlementTime,jdbcType=INTEGER}, #{promoteUid,jdbcType=INTEGER},#{name,jdbcType=VARCHAR},#{idCardNo,jdbcType=VARCHAR},
#{bankCardNo,jdbcType=VARCHAR},#{bankName,jdbcType=VARCHAR},#{bankBranch,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{bankCardNo,jdbcType=VARCHAR},#{bankName,jdbcType=VARCHAR},#{bankBranch,jdbcType=VARCHAR},#{bankCity,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareSettlement" >
... ... @@ -101,6 +102,9 @@
<if test="bankBranch != null" >
bank_branch,
</if>
<if test="bankCity != null" >
bank_city,
</if>
<if test="status != null" >
status,
</if>
... ... @@ -148,6 +152,9 @@
<if test="bankBranch != null" >
#{bankBranch,jdbcType=VARCHAR},
</if>
<if test="bankCity != null" >
#{bankCity,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
... ...
... ... @@ -10,13 +10,14 @@
<result column="bank_name" property="bankName" jdbcType="VARCHAR" />
<result column="bank_code" property="bankCode" jdbcType="VARCHAR" />
<result column="bank_branch" property="bankBranch" jdbcType="VARCHAR" />
<result column="bank_city" property="bankCity" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="source" property="source" jdbcType="TINYINT" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, uid, id_card_no, name, bank_card_no, bank_name,bank_code,bank_branch, status, create_time, update_time
id, uid, id_card_no, name, bank_card_no, bank_name,bank_code,bank_branch,bank_city, status, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -33,11 +34,22 @@
and status = #{status,jdbcType=INTEGER}
</if>
</select>
<select id="selectListByIdCardNo" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from union_share_user_bank
where id_card_no = #{idCardNo,jdbcType=VARCHAR} and status=1
</select>
<select id="selectCountByIdCardNo" resultType="java.lang.Integer" parameterType="java.lang.String">
select count(1)
from union_share_user_bank
where id_card_no = #{idCardNo,jdbcType=VARCHAR} and status=1
</select>
<select id="selectByCondition"
resultType="com.yoho.service.model.union.response.UnionShareUserBankListBO"
parameterType="com.yoho.service.model.union.request.UnionShareUserBankListReqBo">
select id, uid, id_card_no idCardNo, name, bank_card_no bankCardNo, bank_name bankName,
bank_code bankCode, status,source, create_time createTime, update_time updateTime,bank_branch bankBranch
bank_code bankCode, status,source, create_time createTime, update_time updateTime,bank_branch bankBranch,bank_city bankCity
from union_share_user_bank
where 1=1
<if test="uid != null">
... ... @@ -102,11 +114,11 @@
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareUserBank" >
insert into union_share_user_bank (id, uid, id_card_no,
name, bank_card_no, bank_name, bank_code, bank_branch,
name, bank_card_no, bank_name, bank_code, bank_branch,bank_city,
status,source, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{idCardNo,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{bankCardNo,jdbcType=VARCHAR}, #{bankName,jdbcType=VARCHAR}, #{bankCode,jdbcType=VARCHAR}, #{bankBranch,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{bankCardNo,jdbcType=VARCHAR}, #{bankName,jdbcType=VARCHAR}, #{bankCode,jdbcType=VARCHAR}, #{bankBranch,jdbcType=VARCHAR},#{bankCity,jdbcType=VARCHAR},
#{status,jdbcType=TINYINT}, #{source,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}
)
</insert>
... ... @@ -137,6 +149,9 @@
<if test="bankBranch != null" >
bank_branch,
</if>
<if test="bankCity != null" >
bank_city,
</if>
<if test="status != null" >
status,
</if>
... ... @@ -175,6 +190,9 @@
<if test="bankBranch != null" >
#{bankBranch,jdbcType=VARCHAR},
</if>
<if test="bankCity != null" >
#{bankCity,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
... ... @@ -213,6 +231,9 @@
<if test="bankBranch != null" >
bank_branch = #{bankBranch,jdbcType=VARCHAR},
</if>
<if test="bankCity != null" >
bank_city = #{bankCity,jdbcType=VARCHAR},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
... ... @@ -234,6 +255,7 @@
bank_name = #{bankName,jdbcType=VARCHAR},
bank_code = #{bankCode,jdbcType=VARCHAR},
bank_branch = #{bankBranch,jdbcType=VARCHAR},
bank_city = #{bankCity,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
... ...
... ... @@ -5,7 +5,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.6.2-SNAPSHOT</version>
<version>1.6.3-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
<artifactId>yoho-unions</artifactId>
... ...
... ... @@ -19,6 +19,9 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.service.model.request.AreaReqBO;
import com.yoho.service.model.response.AreaRspBo;
import com.yoho.service.model.union.bo.*;
import com.yoho.service.model.union.request.*;
import com.yoho.service.model.union.response.*;
... ... @@ -154,6 +157,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Autowired
private UserServiceHelper userServiceHelper;
@Resource
ServiceCaller serviceCaller;
@Autowired
private RedisHashCache redisHashCache;
... ... @@ -403,6 +409,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
UnionShareUserBank updateReq = new UnionShareUserBank();
updateReq.setId(req.getId());
updateReq.setBankBranch(req.getBankBranch());
updateReq.setBankCity(req.getBankCity());
updateReq.setUpdateTime(DateUtil.getCurrentTimeSecond());
int result = unionShareUserBankMapper.updateByPrimaryKeySelective(updateReq);
if (result > 0) {
... ... @@ -1420,14 +1427,19 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
//信息格式校验
checkAndBuildBankCard(bo);
//查询该用户是否为特邀用户,checkAndBuildBankCard中已经检查过了
// int count = unionShareUserMapper.selectCountByUid(bo.getUid());
// if (count == 0) {
// //不是特邀用户
// logger.info("bindBankCard end,can not find unionType,bo is {}",bo);
// throw new ServiceException(ServiceError.UNION_UID_ERROR);
// }
UnionShareUserBank insertReq = new UnionShareUserBank();
//查询银行城市
AreaReqBO areaReqBO = new AreaReqBO();
areaReqBO.setCode(bo.getBankCityId()*100);
AreaRspBo area = serviceCaller.call("users.getAreaByCode", areaReqBO, AreaRspBo.class);
logger.info("bindBankCard,bo is {},area is {}",bo,JSONObject.toJSONString(area));
if (area != null && area.getParent() != null) {
insertReq.setBankCity(area.getCaption());
}else {
throw new ServiceException(ServiceError.UNION_VERSION_UPGRADE_ERROR);
}
logger.info("bindBankCard,bo is {},area is {},city is {}",bo,JSONObject.toJSONString(area),insertReq.getBankCity());
BeanUtils.copyProperties(bo, insertReq);
insertReq.setStatus((byte)1);
if (bo.getSource()!=null&&1 == bo.getSource()) {
... ... @@ -1511,6 +1523,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
if (!checkIdCard(bo.getIdCardNo())) {
throw new ServiceException(ServiceError.UNION_IDCARD_ERROR);
}
if ((bo.getSource()==null||1 != bo.getSource())&&(idCardPass(bo.getIdCardNo(),bo.getUid()))) {
//不是ufo的请求,需要校验银行卡身份证是否有重复
throw new ServiceException(ServiceError.UNION_IDCARD_REPEAT_ERROR);
}
// 校验银行卡
if (!checkBankCard(bo.getBankCardNo())) {
throw new ServiceException(ServiceError.UNION_BANK_CARD_ERROR);
... ... @@ -1519,6 +1535,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
if (StringUtils.isBlank(bo.getBankBranch())) {
throw new ServiceException(ServiceError.UNION_BANK_BRANCH_ERROR);
}
// 校验银行卡支行地区
if (bo.getBankCityId()<1) {
throw new ServiceException(ServiceError.UNION_VERSION_UPGRADE_ERROR);
}
// 获取银行名
bo.setBankName(getBankName(bo.getBankCode()));
if (null == bo.getBankName()) {
... ... @@ -1538,6 +1558,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return bo;
}
private boolean idCardPass(String idcard, int uid) {
List<UnionShareUserBank> banks = unionShareUserBankMapper.selectListByIdCardNo(idcard);
if (CollectionUtils.isEmpty(banks) || (banks.size() == 1 && banks.get(0).getUid() == uid)) {
return true;
}
return false;
}
public void checkUserIdentityCard(UnionShareUserIdentityCardBo bo) {
// 校验身份证图片
if (StringUtils.isEmpty(bo.getCardFrontUrl())) {
... ... @@ -3265,6 +3293,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
// 是否绑定了有效银行卡
//1、校验是否绑了卡
UnionShareUserBank req = new UnionShareUserBank();
req.setUid(uid);
req.setStatus((byte)1);
... ... @@ -3273,6 +3302,12 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
settlementLog.info("canSettlement end,can not find available bank card,uid is {}",uid);
throw new ServiceException(ServiceError.UNION_HASNOT_AVAILABLE_CARD);
}
//2、校验身份证是否唯一
int idCardNoCount = unionShareUserBankMapper.selectCountByIdCardNo(bankCardList.get(0).getIdCardNo());
if (idCardNoCount > 1) {
settlementLog.info("canSettlement end,idCardNoCount is {},uid is {}",idCardNoCount,uid);
throw new ServiceException(ServiceError.UNION_IDCARD_CONFLICT_ERROR);
}
//查询是否有处理中的提现
if (hasSettlement(uid)) {
... ... @@ -3438,6 +3473,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
insertReq.setBankCardNo(unionShareUserBank.getBankCardNo());
insertReq.setBankName(unionShareUserBank.getBankName());
insertReq.setBankBranch(unionShareUserBank.getBankBranch());
insertReq.setBankCity(unionShareUserBank.getBankCity());
insertReq.setSettlementCode(settlementCode);
insertReq.setSettlementAmount(totalAmount);
insertReq.setSettlementTime(updateTime);
... ... @@ -3509,6 +3545,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
mqLog.info("sendSettlementMqToErp start,send mq {} to erp,uid is {},settlementCode is {}", SETTLEMENT_TOPIC, uid, settlementCode);
UnionShareSettlement unionShareSettlement=unionShareSettlementMapper.selectByCode(settlementCode);
if (unionShareSettlement == null) {
mqLog.info("sendSettlementMqToErp end,send mq {} to erp,uid is {},settlementCode is {},selectByCode null", SETTLEMENT_TOPIC, uid, settlementCode);
return 0;
}
if (unionShareSettlement.getPromoteUid().intValue()!=uid) {
... ...