|
|
package com.yoho.unions.server.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONException;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.core.config.ConfigReader;
|
...
|
...
|
@@ -85,6 +86,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
private String OLD_USER_REBATES_RATIO_KEY = "union.oldUserRebatesRatio";
|
|
|
private String UNION_SHAREID = "union.shareId";
|
|
|
private String UNION_CPS_IMAGEURL = "union.cps.ImageUrl";
|
|
|
private String UNION_CPS_APPLY_IMAGEURL = "union.cps.applyImageUrl";
|
|
|
|
|
|
//USER_SETTLEMENT下hashkey
|
|
|
private String USER_SETTLEMENT_SETTLEAMOUNT = "settleAmount";
|
...
|
...
|
@@ -250,7 +252,34 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
result.setTotal(total);
|
|
|
return result;
|
|
|
}
|
|
|
/**
|
|
|
* 作废用户绑定的银行卡
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int cancelUserBanks(IdOrIdsBo req){
|
|
|
logger.info("cancelUserBanks.req is {}",req);
|
|
|
UnionShareUserBank unionShareUserBank = unionShareUserBankMapper.selectByPrimaryKey(req.getId());
|
|
|
if (unionShareUserBank == null) {
|
|
|
logger.info("cancelUserBanks end.id do not exist.req is {}",req);
|
|
|
return 0;
|
|
|
}
|
|
|
UnionShareUserBank updateReq = new UnionShareUserBank();
|
|
|
updateReq.setId(req.getId());
|
|
|
updateReq.setStatus((byte) 0);
|
|
|
updateReq.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
int result = unionShareUserBankMapper.updateByPrimaryKeySelective(updateReq);
|
|
|
redisHashCache.delete(ShareOrdersKeyEnum.USER_SETTLEMENT.getPreKey(),unionShareUserBank.getUid());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询申请记录
|
|
|
* @param parm
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public PageResponseBO<UnionShareUserApplyListBo> queryUnionShareUserApplys(UnionShareUserApplyListReqBo parm) {
|
|
|
int total=this.unionShareUserApplyMapper.selectTotalByCondition(parm);
|
...
|
...
|
@@ -269,6 +298,122 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
result.setTotal(total);
|
|
|
return result;
|
|
|
}
|
|
|
/**
|
|
|
* 拒绝用户申请
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int refuseApply(IdOrIdsBo req){
|
|
|
if (req.getId() != null) {
|
|
|
//单个操作
|
|
|
UnionShareUserApply unionShareUserApply = unionShareUserApplyMapper.selectByPrimaryKey(req.getId());
|
|
|
if (unionShareUserApply == null || unionShareUserApply.getStatus() > 1) {
|
|
|
return 0;
|
|
|
}
|
|
|
UnionShareUserApply updateReq = new UnionShareUserApply();
|
|
|
updateReq.setId(req.getId());
|
|
|
updateReq.setStatus((byte) 3);//状态:1-申请中,2-通过,3-拒绝
|
|
|
updateReq.setCheckTime(DateUtil.getCurrentTimeSecond());
|
|
|
int result=unionShareUserApplyMapper.updateByPrimaryKeySelective(updateReq);
|
|
|
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),unionShareUserApply.getUid());
|
|
|
return result;
|
|
|
} else {
|
|
|
//批量操作
|
|
|
List<UnionShareUserApply> unionShareUserApplies = unionShareUserApplyMapper.selectByIds(Arrays.asList(req.getIdArray()));
|
|
|
if (CollectionUtils.isEmpty(unionShareUserApplies)) {
|
|
|
return 0;
|
|
|
}
|
|
|
List<Integer> ids = new ArrayList<>();
|
|
|
unionShareUserApplies.forEach(u->{
|
|
|
ids.add(u.getId());
|
|
|
});
|
|
|
int result=unionShareUserApplyMapper.updateStatus(ids,1,3,DateUtil.getCurrentTimeSecond());
|
|
|
unionShareUserApplies.forEach(u->{
|
|
|
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),u.getUid());
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
* 通过用户申请
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int agreeApply(IdOrIdsBo req){
|
|
|
|
|
|
if (req.getId() != null) {
|
|
|
//单个操作
|
|
|
UnionShareUserApply unionShareUserApply = unionShareUserApplyMapper.selectByPrimaryKey(req.getId());
|
|
|
if (unionShareUserApply == null || unionShareUserApply.getStatus() > 1) {
|
|
|
return 0;
|
|
|
}
|
|
|
UnionShareUserApply updateReq = new UnionShareUserApply();
|
|
|
updateReq.setId(req.getId());
|
|
|
updateReq.setStatus((byte) 2);//状态:1-申请中,2-通过,3-拒绝
|
|
|
updateReq.setCheckTime(DateUtil.getCurrentTimeSecond());
|
|
|
int result=unionShareUserApplyMapper.updateByPrimaryKeySelective(updateReq);
|
|
|
if (result > 0) {
|
|
|
//todo 绑定unionType
|
|
|
relateUnionType(unionShareUserApply.getUid());
|
|
|
}
|
|
|
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),unionShareUserApply.getUid());
|
|
|
return result;
|
|
|
} else {
|
|
|
//批量操作
|
|
|
List<UnionShareUserApply> unionShareUserApplies = unionShareUserApplyMapper.selectByIds(Arrays.asList(req.getIdArray()));
|
|
|
if (CollectionUtils.isEmpty(unionShareUserApplies)) {
|
|
|
return 0;
|
|
|
}
|
|
|
List<Integer> ids = new ArrayList<>();
|
|
|
unionShareUserApplies.forEach(u->{
|
|
|
ids.add(u.getId());
|
|
|
});
|
|
|
int result=unionShareUserApplyMapper.updateStatus(ids,1,2,DateUtil.getCurrentTimeSecond());
|
|
|
unionShareUserApplies.forEach(u->{
|
|
|
relateUnionType(u.getUid());
|
|
|
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),u.getUid());
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void relateUnionType(int uid) {
|
|
|
//生成unionType
|
|
|
MktMarketingUrl unionDepartmentUrl = buildMktMarketingUrl(uid);
|
|
|
mktMarketingUrlDAO.insertSelective(unionDepartmentUrl);
|
|
|
//绑定uid和unionType
|
|
|
UnionShareUser unionShareUser = new UnionShareUser();
|
|
|
unionShareUser.setUid(uid);
|
|
|
unionShareUser.setUnionType(unionDepartmentUrl.getUnionType().toString());
|
|
|
unionShareUser.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
unionShareUser.setUpdateTime(unionShareUser.getCreateTime());
|
|
|
unionShareUserMapper.insertSelective(unionShareUser);
|
|
|
}
|
|
|
|
|
|
public MktMarketingUrl buildMktMarketingUrl(int uid) {
|
|
|
MktMarketingUrl mktMarketingUrl = new MktMarketingUrl();
|
|
|
mktMarketingUrl.setChannelType(1);//渠道类型:0-机构 1-个人
|
|
|
mktMarketingUrl.setPayChannel(1);
|
|
|
mktMarketingUrl.setMarketingUrlType(1);
|
|
|
mktMarketingUrl.setLandingPageTypeCode(1000);
|
|
|
mktMarketingUrl.setRealtimeShow(0);
|
|
|
mktMarketingUrl.setDivisionCode(11);
|
|
|
mktMarketingUrl.setClassCode(1121);
|
|
|
mktMarketingUrl.setChannelCode(1462);
|
|
|
mktMarketingUrl.setBusinessCode(1033);
|
|
|
mktMarketingUrl.setCreateId("0");
|
|
|
mktMarketingUrl.setName("cps" + uid);
|
|
|
mktMarketingUrl.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
//对于渠道类型是个人的话,则uniontType手动赋值,最小值从10000开始 -- platform的逻辑copy过来
|
|
|
Long maxUnionType = this.mktMarketingUrlDAO.selectMaxPersonalUnionType();
|
|
|
maxUnionType = (null == maxUnionType) ? 10000 : maxUnionType+1;
|
|
|
mktMarketingUrl.setUnionType(maxUnionType);
|
|
|
return mktMarketingUrl;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 用户登录时获取对应的渠道号
|
...
|
...
|
@@ -296,6 +441,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
//设置返回文案
|
|
|
bo.setShareId(configReader.getString(UNION_SHAREID, ""));
|
|
|
bo.setImageUrl(configReader.getString(UNION_CPS_IMAGEURL, ""));
|
|
|
bo.setApplyImageUrl(configReader.getString(UNION_CPS_APPLY_IMAGEURL, ""));
|
|
|
|
|
|
//设置缓存
|
|
|
addToRedis(ShareOrdersKeyEnum.UNION_TYPE, uid, bo, key);
|
...
|
...
|
@@ -330,6 +476,20 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
logger.info("getBankList");
|
|
|
return BankEnum.getAllBank();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取银行列表
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public Map<String,JSONArray> getSocialMediaBasicParams(){
|
|
|
logger.info("getBankList");
|
|
|
Map<String, JSONArray> result = new HashMap<>();
|
|
|
result.put("section", SocialMediaSectionEnum.getAllSectionArray("-"));
|
|
|
result.put("mediaType", SocialMediaTypeEnum.getAllTypeArray());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 绑定银行卡
|
|
|
* @param bo
|
...
|
...
|
|