Authored by qinchao

入驻接口

package com.yohoufo.dal.user;
import com.yohoufo.dal.user.model.StoredSeller;
import org.apache.ibatis.annotations.Param;
public interface IStoredSellerDao {
//获取生效的信息
StoredSeller selectValidByUid(int uid);
int insert(StoredSeller storedSeller);
int updateStatusByPrimaryKey(@Param("id")int id,@Param("validStatus") int validStatus);
}
... ...
... ... @@ -11,9 +11,28 @@ public class StoredSeller {
//uid ,索引
private Integer uid;
//生效状态:1 生效 ; 0 不生效
//生效状态:1 入驻 ; 0 已退驻
private Integer validStatus;
//证件姓名
private String certName;
//证件号码:身份证号码
private String certNo;
//操作员uid
private Integer operatorUid;
private Integer operatorName;
//入驻时间
private long enterTime;
//退驻时间
private long quitTime;
private long createTime;
private long updateTime;
... ...
... ... @@ -5,12 +5,18 @@
<id column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="valid_status" property="validStatus" jdbcType="INTEGER" />
<result column="cert_no" property="certNo" jdbcType="VARCHAR" />
<result column="cert_name" property="certName" jdbcType="VARCHAR" />
<result column="operator_uid" property="operatorUid" jdbcType="INTEGER" />
<result column="operator_name" property="operatorName" jdbcType="VARCHAR" />
<result column="enter_time" property="enterTime" jdbcType="INTEGER" />
<result column="quit_time" property="quitTime" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, uid, valid_status, create_time, update_time
id, uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time ,create_time, update_time
</sql>
<select id="selectValidByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
... ... @@ -22,10 +28,17 @@
</select>
<insert id="insert" parameterType="com.yohoufo.dal.user.model.StoredSeller" >
insert into stored_seller (uid, valid_status, create_time, update_time)
insert into stored_seller (uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time, create_time, update_time)
values (#{uid},#{validStatus},
#{certNo},#{certName},#{operatorUid},#{operatorName},
#{enterTime},#{quitTime}
#{createTime},#{updateTime})
</insert>
<update id="updateStatusByPrimaryKey">
update stored_seller
set valid_status = #{validStatus}
where id = #{id}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -214,6 +214,10 @@ public class CacheService {
set(getStoredSellerRedisKeyBuilder(storedSeller.getUid()),storedSeller,CacheKeyEnum.STORED_SELLER_KEY.getDefaultExpireTime(),CacheKeyEnum.STORED_SELLER_KEY.getTimeUnit());
}
public void removeStoredSeller(Integer uid) {
yhRedisTemplate.delete(getStoredSellerRedisKeyBuilder(uid));
}
/**************************************************************************
* 通用
... ...
... ... @@ -51,4 +51,21 @@ public class StoredSellerController {
storedSellerService.addUserAsStoredSeller(reqVO.getUid());
return new ApiResponse();
}
/**
* 申请退驻
*/
@RequestMapping(params = "method=ufo.user.applyQuitStoredSeller")
public ApiResponse applyQuitStoredSeller(RealNameAuthorizeReqVO reqVO) throws GatewayException {
logger.info("enter StoredSellerController applyQuitStoredSeller param reqVO is {}", reqVO);
//(1) 优先校验请求的参数
if (reqVO == null || reqVO.getUid() <=0 ){
throw new GatewayException(400, "参数错误,uid不存在!");
}
storedSellerService.applyQuitStoredSeller(reqVO.getUid());
return new ApiResponse();
}
}
... ...
... ... @@ -5,4 +5,6 @@ public interface IStoredSellerService {
boolean isStoredSeller(Integer uid);
void addUserAsStoredSeller(Integer uid);
void applyQuitStoredSeller(Integer uid);
}
... ...
package com.yohoufo.user.service.impl;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
import com.yohoufo.dal.user.IStoredSellerDao;
import com.yohoufo.dal.user.model.StoredSeller;
import com.yohoufo.dal.user.model.ZhiMaCert;
import com.yohoufo.user.cache.CacheService;
import com.yohoufo.user.service.IRealNameAuthorizeService;
import com.yohoufo.user.service.IStoredSellerService;
... ... @@ -28,7 +30,29 @@ public class StoredSellerServiceImpl implements IStoredSellerService {
@Autowired
private IStoredSellerDao storedSellerDao;
@Override
public void applyQuitStoredSeller(Integer uid){
logger.info("StoredSellerServiceImpl applyQuitStoredSeller uid is {} ",uid);
StoredSeller storedSeller = getValidStoredSeller(uid);
if(null==storedSeller){
logger.error("StoredSellerServiceImpl applyQuitStoredSeller store seller is null,uid is {} ",uid);
throw new ServiceException(400,"未找到入驻信息");
}
if(!StoredSellerStatusEnum.entered.getId().equals(storedSeller.getValidStatus())){
throw new ServiceException(400,"商户入驻状态变化,不允许申请退出!");
}
int num = storedSellerDao.updateStatusByPrimaryKey(storedSeller.getId(),StoredSellerStatusEnum.apply_quit.getId());
//清掉缓存
cacheService.removeStoredSeller(uid);
logger.info("StoredSellerServiceImpl applyQuitStoredSeller end ,uid is {} ,update num ",uid,num);
}
@Override
public boolean isStoredSeller(Integer uid){
logger.info("StoredSellerServiceImpl isStoredSeller uid is {} ",uid);
StoredSeller storedSeller = getValidStoredSeller(uid);
if(storedSeller!=null&&storedSeller.getUid()!=null){
return true;
... ... @@ -38,7 +62,7 @@ public class StoredSellerServiceImpl implements IStoredSellerService {
private StoredSeller getValidStoredSeller(Integer uid){
//从缓存中获取
logger.info("StoredSellerServiceImpl isStoredSeller uid is {} ",uid);
logger.info("StoredSellerServiceImpl getValidStoredSeller uid is {} ",uid);
StoredSeller storedSeller = cacheService.getStoredSeller(uid);
logger.info("StoredSellerServiceImpl valid store seller uid is {} ,redis info is {} ",uid,storedSeller);
if(null != storedSeller){
... ... @@ -60,7 +84,8 @@ public class StoredSellerServiceImpl implements IStoredSellerService {
public void addUserAsStoredSeller(Integer uid){
logger.info("StoredSellerServiceImpl addUserAsStoredSeller enter uid is {} ",uid);
//检查是否已经实名认证
if(null==realNameAuthorizeService.getValidZhiMaCert(uid)){
ZhiMaCert zhiMaCert=realNameAuthorizeService.getValidZhiMaCert(uid);
if(null==zhiMaCert){
logger.error("StoredSellerServiceImpl get zhi ma cert info is null , uid is {} ",uid);
throw new ServiceException(400,"商户没有实名认证,不允许更新为入驻商户");
}
... ... @@ -73,7 +98,10 @@ public class StoredSellerServiceImpl implements IStoredSellerService {
long ts=now.toEpochSecond(ZoneOffset.of("+8"));
StoredSeller storedSeller=new StoredSeller();
storedSeller.setUid(uid);
storedSeller.setValidStatus(1);
storedSeller.setValidStatus(StoredSellerStatusEnum.entered.getId());
storedSeller.setEnterTime(ts);
storedSeller.setCertNo(zhiMaCert.getCertNo());
storedSeller.setCertName(zhiMaCert.getCertName());
storedSeller.setCreateTime(ts);
storedSeller.setUpdateTime(ts);
logger.info("StoredSellerServiceImpl addUserAsStoredSeller insert uid is {} , storedSeller {} ",uid,storedSeller);
... ...
... ... @@ -9,6 +9,7 @@ datasources:
- com.yohoufo.dal.user.IUserAuthorizeHistoryDao
- com.yohoufo.dal.user.IUserAuthorizeInfoDao
- com.yohoufo.dal.user.IZhiMaCertDao
- com.yohoufo.dal.user.IStoredSellerDao
ufo_product:
servers:
... ...
... ... @@ -9,6 +9,7 @@ datasources:
- com.yohoufo.dal.user.IUserAuthorizeHistoryDao
- com.yohoufo.dal.user.IUserAuthorizeInfoDao
- com.yohoufo.dal.user.IZhiMaCertDao
- com.yohoufo.dal.user.IStoredSellerDao
ufo_product:
servers:
... ...