Authored by mingdan.ge

no message

... ... @@ -8,5 +8,5 @@ import java.io.File;
*/
public interface IQNUploadService {
String upload(File file, String bucket, String fileName) throws Exception;
String getSignPrivateUrl(String imgUrl, long expireTime);
}
... ...
... ... @@ -29,6 +29,12 @@ public class QNUploadServiceImpl implements IQNUploadService {
private Auth auth;
@Value("${qiniu.private.accesskey}")
private String privateAccessKey;
@Value("${qiniu.private.secretkey}")
private String privateSecretKey;
private Auth privateAuth;
private static final Logger logger = LoggerFactory.getLogger(QNUploadServiceImpl.class);
// 用于七牛云上传的bucket
... ... @@ -75,5 +81,14 @@ public class QNUploadServiceImpl implements IQNUploadService {
// 生成完整可用的URL
return ImagesHelper.getImageAbsoluteUrl(fileName, bucket);
}
/**
* 获取七牛私有bucket的url
**/
public String getSignPrivateUrl(String imgUrl, long expireTime){
//获取加载凭证后的url
privateAuth = Auth.create(privateAccessKey, privateSecretKey);
String downloadUrl = privateAuth.privateDownloadUrl(imgUrl, expireTime);
return downloadUrl;
}
}
... ...
... ... @@ -12,8 +12,11 @@ public interface UnionShareUserIdentityCardMapper {
UnionShareUserIdentityCard selectByPrimaryKey(Integer id);
UnionShareUserIdentityCard selectActiveByUid(@Param("uid") Integer uid);
UnionShareUserIdentityCard selectByUid(@Param("uid") Integer uid);
List<UnionShareUserIdentityCard> selectByUids(@Param("uids") List<Integer> uids);
int updateByPrimaryKeySelective(UnionShareUserIdentityCard record);
int updateByPrimaryKey(UnionShareUserIdentityCard record);
... ...
... ... @@ -20,7 +20,7 @@
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer">
<select id="selectActiveByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from union_share_user_identity_card
... ... @@ -29,6 +29,25 @@
limit 1
</select>
<select id="selectByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from union_share_user_identity_card
where uid = #{uid,jdbcType=INTEGER}
limit 1
</select>
<select id="selectByUids" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from union_share_user_identity_card
where uid in
<foreach collection="uids" open="(" close=")" item="uid" separator=",">
#{uid}
</foreach>
and status=1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_user_identity_card
where id = #{id,jdbcType=INTEGER}
... ...
... ... @@ -846,7 +846,6 @@ public class UnionShareRest {
/**
* 查询绑定的身份证
* @param uid
* @return
*/
@RequestMapping("/getIdentityCard")
... ... @@ -854,7 +853,19 @@ public class UnionShareRest {
public UnionResponse getIdentityCard(@RequestBody int uid){
log.info("UnionShareRest.getIdentityCard uid is {}", uid);
UnionShareUserIdentityCardBo result = unionShareService.getUserIdentityCard(uid);
return new UnionResponse(200, "getBankCard success",result);
return new UnionResponse(200, "getIdentityCard success",result);
}
/**
* 批量查询绑定的身份证
* @return
*/
@RequestMapping("/batchGetIdentityCard")
@ResponseBody
public UnionResponse batchGetIdentityCard(@RequestBody List<Integer> uids){
log.info("UnionShareRest.batchGetIdentityCard uid is {}", uids);
List<UnionShareUserIdentityCardBo> result = unionShareService.batchGetIdentityCard(uids);
return new UnionResponse(200, "batchGetIdentityCard success",result);
}
private UserInfoBO getFromredis(String pid) {
... ...
... ... @@ -324,5 +324,7 @@ public interface IUnionShareService {
*/
UnionShareUserIdentityCardBo getUserIdentityCard(Integer uid);
List<UnionShareUserIdentityCardBo> batchGetIdentityCard(List<Integer> uids);
void reject(int uid);
}
... ...
... ... @@ -19,9 +19,11 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.qiniu.util.Auth;
import com.yoho.service.model.union.bo.*;
import com.yoho.service.model.union.request.*;
import com.yoho.service.model.union.response.*;
import com.yoho.unions.common.service.IQNUploadService;
import com.yoho.unions.dal.*;
import com.yoho.unions.dal.model.*;
import com.yoho.unions.helper.SendMessageHelper;
... ... @@ -33,6 +35,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONArray;
... ... @@ -145,6 +148,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Autowired
private ISendSmsService sendSmsService;
@Autowired
private IQNUploadService qNUploadService;
private AtomicInteger atomicInt = new AtomicInteger(0);
... ... @@ -188,6 +193,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
private static final String UNION_SHARE_USER_APPLY_REJECT_SMS_CONTENT = "真抱歉,您填写信息有误未能通过审核!关注“有货有赚”公众号,重新提交申请";
private final String yohoCardUrlPre = "http://yhgidcard.static.yhbimg.com/yohocard";
private long EXPIRE_TIME = 3 * 24 * 3600;
/**
* 获取用户可提现金额、已提现金额、是否可以提现
* */
... ... @@ -3734,19 +3742,29 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
//信息格式校验
checkUserIdentityCard(bo);
// 设置身份证照片完整url
bo.setCardFrontUrl(yohoCardUrlPre + bo.getCardFrontUrl());
bo.setCardBackUrl(yohoCardUrlPre + bo.getCardBackUrl());
UnionShareUserIdentityCard identityCard = new UnionShareUserIdentityCard();
BeanUtils.copyProperties(bo, identityCard);
identityCard.setStatus((byte)1);
identityCard.setCreateTime(DateUtil.getCurrentTimeSecond());
identityCard.setUpdateTime(identityCard.getCreateTime());
int result = unionShareUserIdentityCardMapper.insert(identityCard);
// 查询是否存在
UnionShareUserIdentityCard identityCardDb = unionShareUserIdentityCardMapper.selectByUid(bo.getUid());
int result = 0;
if(identityCardDb==null){
result = unionShareUserIdentityCardMapper.insert(identityCard);
}else{
identityCard.setId(identityCardDb.getId());
result = unionShareUserIdentityCardMapper.updateByPrimaryKey(identityCard);
}
redisHashCache.delete(ShareOrdersKeyEnum.USER_SETTLEMENT.getPreKey(), bo.getUid());
return result;
}
@Override
public UnionShareUserIdentityCardBo getUserIdentityCard(Integer uid){
logger.info("getUserIdentityCard, uid is {}", uid);
public UnionShareUserIdentityCardBo getUserIdentityCard(Integer uid){
if (uid==null || uid < 1) {
return null;
}
... ... @@ -3756,10 +3774,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
logger.info("getUserIdentityCard end, get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
return cacheResult;
}
UnionShareUserBank req = new UnionShareUserBank();
req.setUid(uid);
req.setStatus((byte)1);
UnionShareUserIdentityCard identityCard = unionShareUserIdentityCardMapper.selectByUid(uid);
UnionShareUserIdentityCard identityCard = unionShareUserIdentityCardMapper.selectActiveByUid(uid);
if (identityCard==null) {
return null;
}
... ... @@ -3773,8 +3788,32 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
@Override
public List<UnionShareUserIdentityCardBo> batchGetIdentityCard(List<Integer> uids) {
List<UnionShareUserIdentityCard> identityCards = unionShareUserIdentityCardMapper.selectByUids(uids);
if (CollectionUtils.isEmpty(identityCards)) {
return Lists.newArrayList();
}
List<UnionShareUserIdentityCardBo> boList = Lists.newArrayList();
for (UnionShareUserIdentityCard item : identityCards) {
UnionShareUserIdentityCardBo bo = new UnionShareUserIdentityCardBo();
bo.setId(item.getId());
bo.setUid(item.getUid());
// http://img02.static.yohobuy.com/goodsimg/2016/09/14/13/024d16b0106473e0f114cd1aa8e0a0a6d4.jpg?watermark/2/text/5pyJ6LSn/gravity/SouthWest/dx/300/dy/500/fontsize/1000
bo.setCardFrontUrl(qNUploadService.getSignPrivateUrl(item.getCardFrontUrl(), EXPIRE_TIME));
bo.setCardBackUrl(qNUploadService.getSignPrivateUrl(item.getCardBackUrl(), EXPIRE_TIME));
boList.add(bo);
}
return boList;
}
public void reject(int uid) {
unionShareUserIdentityCardMapper.updateStatusByUid(uid);
redisHashCache.delete(ShareOrdersKeyEnum.USER_SETTLEMENT.getPreKey(), uid);
}
}
... ...
... ... @@ -16,6 +16,12 @@ qiniu.secretkey=pyoJzPygXIkFWrc1BAsH6tAJ0yweTchpJwGKEwhm
qiniu.domain = test
qiniu.bucket = test
#-------------七牛云私有空间配置-------------------#
qiniu.private.accesskey=atSf7xxIl8alEnsXbhC1bOD1GWVW3qYffz8SlB4m
qiniu.private.secretkey=pyoJzPygXIkFWrc1BAsH6tAJ0yweTchpJwGKEwhm
qiniu.private.domain=yhfair
#zkAddress=192.168.102.211:2181
#zkAddress=127.0.0.1:2181
zkAddress=192.168.102.45:2181
... ...
... ... @@ -84,6 +84,10 @@ qiniu.secretkey = ${qiniu.secretkey}
qiniu.domain = ${qiniu.domain}
qiniu.bucket = ${qiniu.bucket}
qiniu.private.accesskey=${qiniu.private.accesskey}
qiniu.private.secretkey=${qiniu.private.secretkey}
qiniu.private.domain=${qiniu.private.domain}
cloud=${cloud}
yoho.message.controller.url=${yoho.message.controller.url}
... ...