Showing
9 changed files
with
94 additions
and
7 deletions
1 | package com.yohoufo.dal.user; | 1 | package com.yohoufo.dal.user; |
2 | 2 | ||
3 | import com.yohoufo.dal.user.model.StoredSeller; | 3 | import com.yohoufo.dal.user.model.StoredSeller; |
4 | +import org.apache.ibatis.annotations.Param; | ||
4 | 5 | ||
5 | public interface IStoredSellerDao { | 6 | public interface IStoredSellerDao { |
6 | - | ||
7 | //获取生效的信息 | 7 | //获取生效的信息 |
8 | StoredSeller selectValidByUid(int uid); | 8 | StoredSeller selectValidByUid(int uid); |
9 | 9 | ||
10 | int insert(StoredSeller storedSeller); | 10 | int insert(StoredSeller storedSeller); |
11 | 11 | ||
12 | + int updateStatusByPrimaryKey(@Param("id")int id,@Param("validStatus") int validStatus); | ||
13 | + | ||
12 | } | 14 | } |
@@ -11,9 +11,28 @@ public class StoredSeller { | @@ -11,9 +11,28 @@ public class StoredSeller { | ||
11 | //uid ,索引 | 11 | //uid ,索引 |
12 | private Integer uid; | 12 | private Integer uid; |
13 | 13 | ||
14 | - //生效状态:1 生效 ; 0 不生效 | 14 | + //生效状态:1 入驻 ; 0 已退驻 |
15 | private Integer validStatus; | 15 | private Integer validStatus; |
16 | 16 | ||
17 | + //证件姓名 | ||
18 | + private String certName; | ||
19 | + | ||
20 | + //证件号码:身份证号码 | ||
21 | + private String certNo; | ||
22 | + | ||
23 | + //操作员uid | ||
24 | + private Integer operatorUid; | ||
25 | + | ||
26 | + private Integer operatorName; | ||
27 | + | ||
28 | + //入驻时间 | ||
29 | + private long enterTime; | ||
30 | + | ||
31 | + //退驻时间 | ||
32 | + private long quitTime; | ||
33 | + | ||
34 | + | ||
35 | + | ||
17 | private long createTime; | 36 | private long createTime; |
18 | 37 | ||
19 | private long updateTime; | 38 | private long updateTime; |
@@ -5,12 +5,18 @@ | @@ -5,12 +5,18 @@ | ||
5 | <id column="id" property="id" jdbcType="INTEGER" /> | 5 | <id column="id" property="id" jdbcType="INTEGER" /> |
6 | <result column="uid" property="uid" jdbcType="INTEGER" /> | 6 | <result column="uid" property="uid" jdbcType="INTEGER" /> |
7 | <result column="valid_status" property="validStatus" jdbcType="INTEGER" /> | 7 | <result column="valid_status" property="validStatus" jdbcType="INTEGER" /> |
8 | + <result column="cert_no" property="certNo" jdbcType="VARCHAR" /> | ||
9 | + <result column="cert_name" property="certName" jdbcType="VARCHAR" /> | ||
10 | + <result column="operator_uid" property="operatorUid" jdbcType="INTEGER" /> | ||
11 | + <result column="operator_name" property="operatorName" jdbcType="VARCHAR" /> | ||
12 | + <result column="enter_time" property="enterTime" jdbcType="INTEGER" /> | ||
13 | + <result column="quit_time" property="quitTime" jdbcType="INTEGER" /> | ||
8 | <result column="create_time" property="createTime" jdbcType="INTEGER" /> | 14 | <result column="create_time" property="createTime" jdbcType="INTEGER" /> |
9 | <result column="update_time" property="updateTime" jdbcType="INTEGER" /> | 15 | <result column="update_time" property="updateTime" jdbcType="INTEGER" /> |
10 | </resultMap> | 16 | </resultMap> |
11 | 17 | ||
12 | <sql id="Base_Column_List" > | 18 | <sql id="Base_Column_List" > |
13 | - id, uid, valid_status, create_time, update_time | 19 | + id, uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time ,create_time, update_time |
14 | </sql> | 20 | </sql> |
15 | 21 | ||
16 | <select id="selectValidByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" > | 22 | <select id="selectValidByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" > |
@@ -22,10 +28,17 @@ | @@ -22,10 +28,17 @@ | ||
22 | </select> | 28 | </select> |
23 | 29 | ||
24 | <insert id="insert" parameterType="com.yohoufo.dal.user.model.StoredSeller" > | 30 | <insert id="insert" parameterType="com.yohoufo.dal.user.model.StoredSeller" > |
25 | - insert into stored_seller (uid, valid_status, create_time, update_time) | 31 | + insert into stored_seller (uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time, create_time, update_time) |
26 | values (#{uid},#{validStatus}, | 32 | values (#{uid},#{validStatus}, |
33 | + #{certNo},#{certName},#{operatorUid},#{operatorName}, | ||
34 | + #{enterTime},#{quitTime} | ||
27 | #{createTime},#{updateTime}) | 35 | #{createTime},#{updateTime}) |
28 | </insert> | 36 | </insert> |
29 | 37 | ||
38 | + <update id="updateStatusByPrimaryKey"> | ||
39 | + update stored_seller | ||
40 | + set valid_status = #{validStatus} | ||
41 | + where id = #{id} | ||
42 | + </update> | ||
30 | 43 | ||
31 | </mapper> | 44 | </mapper> |
@@ -214,6 +214,10 @@ public class CacheService { | @@ -214,6 +214,10 @@ public class CacheService { | ||
214 | set(getStoredSellerRedisKeyBuilder(storedSeller.getUid()),storedSeller,CacheKeyEnum.STORED_SELLER_KEY.getDefaultExpireTime(),CacheKeyEnum.STORED_SELLER_KEY.getTimeUnit()); | 214 | set(getStoredSellerRedisKeyBuilder(storedSeller.getUid()),storedSeller,CacheKeyEnum.STORED_SELLER_KEY.getDefaultExpireTime(),CacheKeyEnum.STORED_SELLER_KEY.getTimeUnit()); |
215 | } | 215 | } |
216 | 216 | ||
217 | + public void removeStoredSeller(Integer uid) { | ||
218 | + yhRedisTemplate.delete(getStoredSellerRedisKeyBuilder(uid)); | ||
219 | + } | ||
220 | + | ||
217 | 221 | ||
218 | /************************************************************************** | 222 | /************************************************************************** |
219 | * 通用 | 223 | * 通用 |
@@ -51,4 +51,21 @@ public class StoredSellerController { | @@ -51,4 +51,21 @@ public class StoredSellerController { | ||
51 | storedSellerService.addUserAsStoredSeller(reqVO.getUid()); | 51 | storedSellerService.addUserAsStoredSeller(reqVO.getUid()); |
52 | return new ApiResponse(); | 52 | return new ApiResponse(); |
53 | } | 53 | } |
54 | + | ||
55 | + | ||
56 | + /** | ||
57 | + * 申请退驻 | ||
58 | + */ | ||
59 | + @RequestMapping(params = "method=ufo.user.applyQuitStoredSeller") | ||
60 | + public ApiResponse applyQuitStoredSeller(RealNameAuthorizeReqVO reqVO) throws GatewayException { | ||
61 | + logger.info("enter StoredSellerController applyQuitStoredSeller param reqVO is {}", reqVO); | ||
62 | + //(1) 优先校验请求的参数 | ||
63 | + if (reqVO == null || reqVO.getUid() <=0 ){ | ||
64 | + throw new GatewayException(400, "参数错误,uid不存在!"); | ||
65 | + } | ||
66 | + | ||
67 | + storedSellerService.applyQuitStoredSeller(reqVO.getUid()); | ||
68 | + return new ApiResponse(); | ||
69 | + } | ||
70 | + | ||
54 | } | 71 | } |
@@ -5,4 +5,6 @@ public interface IStoredSellerService { | @@ -5,4 +5,6 @@ public interface IStoredSellerService { | ||
5 | boolean isStoredSeller(Integer uid); | 5 | boolean isStoredSeller(Integer uid); |
6 | 6 | ||
7 | void addUserAsStoredSeller(Integer uid); | 7 | void addUserAsStoredSeller(Integer uid); |
8 | + | ||
9 | + void applyQuitStoredSeller(Integer uid); | ||
8 | } | 10 | } |
1 | package com.yohoufo.user.service.impl; | 1 | package com.yohoufo.user.service.impl; |
2 | 2 | ||
3 | import com.yoho.error.exception.ServiceException; | 3 | import com.yoho.error.exception.ServiceException; |
4 | +import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum; | ||
4 | import com.yohoufo.dal.user.IStoredSellerDao; | 5 | import com.yohoufo.dal.user.IStoredSellerDao; |
5 | import com.yohoufo.dal.user.model.StoredSeller; | 6 | import com.yohoufo.dal.user.model.StoredSeller; |
7 | +import com.yohoufo.dal.user.model.ZhiMaCert; | ||
6 | import com.yohoufo.user.cache.CacheService; | 8 | import com.yohoufo.user.cache.CacheService; |
7 | import com.yohoufo.user.service.IRealNameAuthorizeService; | 9 | import com.yohoufo.user.service.IRealNameAuthorizeService; |
8 | import com.yohoufo.user.service.IStoredSellerService; | 10 | import com.yohoufo.user.service.IStoredSellerService; |
@@ -28,7 +30,29 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | @@ -28,7 +30,29 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | ||
28 | @Autowired | 30 | @Autowired |
29 | private IStoredSellerDao storedSellerDao; | 31 | private IStoredSellerDao storedSellerDao; |
30 | 32 | ||
33 | + @Override | ||
34 | + public void applyQuitStoredSeller(Integer uid){ | ||
35 | + logger.info("StoredSellerServiceImpl applyQuitStoredSeller uid is {} ",uid); | ||
36 | + StoredSeller storedSeller = getValidStoredSeller(uid); | ||
37 | + if(null==storedSeller){ | ||
38 | + logger.error("StoredSellerServiceImpl applyQuitStoredSeller store seller is null,uid is {} ",uid); | ||
39 | + throw new ServiceException(400,"未找到入驻信息"); | ||
40 | + } | ||
41 | + | ||
42 | + if(!StoredSellerStatusEnum.entered.getId().equals(storedSeller.getValidStatus())){ | ||
43 | + throw new ServiceException(400,"商户入驻状态变化,不允许申请退出!"); | ||
44 | + } | ||
45 | + | ||
46 | + int num = storedSellerDao.updateStatusByPrimaryKey(storedSeller.getId(),StoredSellerStatusEnum.apply_quit.getId()); | ||
47 | + //清掉缓存 | ||
48 | + cacheService.removeStoredSeller(uid); | ||
49 | + | ||
50 | + logger.info("StoredSellerServiceImpl applyQuitStoredSeller end ,uid is {} ,update num ",uid,num); | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
31 | public boolean isStoredSeller(Integer uid){ | 54 | public boolean isStoredSeller(Integer uid){ |
55 | + logger.info("StoredSellerServiceImpl isStoredSeller uid is {} ",uid); | ||
32 | StoredSeller storedSeller = getValidStoredSeller(uid); | 56 | StoredSeller storedSeller = getValidStoredSeller(uid); |
33 | if(storedSeller!=null&&storedSeller.getUid()!=null){ | 57 | if(storedSeller!=null&&storedSeller.getUid()!=null){ |
34 | return true; | 58 | return true; |
@@ -38,7 +62,7 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | @@ -38,7 +62,7 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | ||
38 | 62 | ||
39 | private StoredSeller getValidStoredSeller(Integer uid){ | 63 | private StoredSeller getValidStoredSeller(Integer uid){ |
40 | //从缓存中获取 | 64 | //从缓存中获取 |
41 | - logger.info("StoredSellerServiceImpl isStoredSeller uid is {} ",uid); | 65 | + logger.info("StoredSellerServiceImpl getValidStoredSeller uid is {} ",uid); |
42 | StoredSeller storedSeller = cacheService.getStoredSeller(uid); | 66 | StoredSeller storedSeller = cacheService.getStoredSeller(uid); |
43 | logger.info("StoredSellerServiceImpl valid store seller uid is {} ,redis info is {} ",uid,storedSeller); | 67 | logger.info("StoredSellerServiceImpl valid store seller uid is {} ,redis info is {} ",uid,storedSeller); |
44 | if(null != storedSeller){ | 68 | if(null != storedSeller){ |
@@ -60,7 +84,8 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | @@ -60,7 +84,8 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | ||
60 | public void addUserAsStoredSeller(Integer uid){ | 84 | public void addUserAsStoredSeller(Integer uid){ |
61 | logger.info("StoredSellerServiceImpl addUserAsStoredSeller enter uid is {} ",uid); | 85 | logger.info("StoredSellerServiceImpl addUserAsStoredSeller enter uid is {} ",uid); |
62 | //检查是否已经实名认证 | 86 | //检查是否已经实名认证 |
63 | - if(null==realNameAuthorizeService.getValidZhiMaCert(uid)){ | 87 | + ZhiMaCert zhiMaCert=realNameAuthorizeService.getValidZhiMaCert(uid); |
88 | + if(null==zhiMaCert){ | ||
64 | logger.error("StoredSellerServiceImpl get zhi ma cert info is null , uid is {} ",uid); | 89 | logger.error("StoredSellerServiceImpl get zhi ma cert info is null , uid is {} ",uid); |
65 | throw new ServiceException(400,"商户没有实名认证,不允许更新为入驻商户"); | 90 | throw new ServiceException(400,"商户没有实名认证,不允许更新为入驻商户"); |
66 | } | 91 | } |
@@ -73,7 +98,10 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | @@ -73,7 +98,10 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | ||
73 | long ts=now.toEpochSecond(ZoneOffset.of("+8")); | 98 | long ts=now.toEpochSecond(ZoneOffset.of("+8")); |
74 | StoredSeller storedSeller=new StoredSeller(); | 99 | StoredSeller storedSeller=new StoredSeller(); |
75 | storedSeller.setUid(uid); | 100 | storedSeller.setUid(uid); |
76 | - storedSeller.setValidStatus(1); | 101 | + storedSeller.setValidStatus(StoredSellerStatusEnum.entered.getId()); |
102 | + storedSeller.setEnterTime(ts); | ||
103 | + storedSeller.setCertNo(zhiMaCert.getCertNo()); | ||
104 | + storedSeller.setCertName(zhiMaCert.getCertName()); | ||
77 | storedSeller.setCreateTime(ts); | 105 | storedSeller.setCreateTime(ts); |
78 | storedSeller.setUpdateTime(ts); | 106 | storedSeller.setUpdateTime(ts); |
79 | logger.info("StoredSellerServiceImpl addUserAsStoredSeller insert uid is {} , storedSeller {} ",uid,storedSeller); | 107 | logger.info("StoredSellerServiceImpl addUserAsStoredSeller insert uid is {} , storedSeller {} ",uid,storedSeller); |
@@ -9,6 +9,7 @@ datasources: | @@ -9,6 +9,7 @@ datasources: | ||
9 | - com.yohoufo.dal.user.IUserAuthorizeHistoryDao | 9 | - com.yohoufo.dal.user.IUserAuthorizeHistoryDao |
10 | - com.yohoufo.dal.user.IUserAuthorizeInfoDao | 10 | - com.yohoufo.dal.user.IUserAuthorizeInfoDao |
11 | - com.yohoufo.dal.user.IZhiMaCertDao | 11 | - com.yohoufo.dal.user.IZhiMaCertDao |
12 | + - com.yohoufo.dal.user.IStoredSellerDao | ||
12 | 13 | ||
13 | ufo_product: | 14 | ufo_product: |
14 | servers: | 15 | servers: |
@@ -9,6 +9,7 @@ datasources: | @@ -9,6 +9,7 @@ datasources: | ||
9 | - com.yohoufo.dal.user.IUserAuthorizeHistoryDao | 9 | - com.yohoufo.dal.user.IUserAuthorizeHistoryDao |
10 | - com.yohoufo.dal.user.IUserAuthorizeInfoDao | 10 | - com.yohoufo.dal.user.IUserAuthorizeInfoDao |
11 | - com.yohoufo.dal.user.IZhiMaCertDao | 11 | - com.yohoufo.dal.user.IZhiMaCertDao |
12 | + - com.yohoufo.dal.user.IStoredSellerDao | ||
12 | 13 | ||
13 | ufo_product: | 14 | ufo_product: |
14 | servers: | 15 | servers: |
-
Please register or login to post a comment