Authored by chenchao

judge seller type

@@ -15,8 +15,11 @@ public interface StoredSellerMapper { @@ -15,8 +15,11 @@ public interface StoredSellerMapper {
15 15
16 int updateStatusByUid(@Param("uid") int uid, @Param("validStatus") int validStatus, @Param("expectStatus") int expectStatus, @Param("updateTime") long updateTime); 16 int updateStatusByUid(@Param("uid") int uid, @Param("validStatus") int validStatus, @Param("expectStatus") int expectStatus, @Param("updateTime") long updateTime);
17 17
18 - /*int updateToQuitByPrimaryKey(@Param("id")int id,@Param("validStatus") int validStatus ,@Param("expectStatus") int expectStatus  
19 - ,@Param("operatorUid") int operatorUid,@Param("operatorName") String operatorName  
20 - ,@Param("quitTime") long quitTime,@Param("updateTime") long updateTime);*/ 18 + int insertSelective(StoredSeller record);
21 19
  20 +
  21 + int updateByUidSelective(StoredSeller record);
  22 +
  23 +
  24 + StoredSeller selectByUid(int uid);
22 } 25 }
@@ -31,8 +31,6 @@ public class StoredSeller { @@ -31,8 +31,6 @@ public class StoredSeller {
31 //退驻时间 31 //退驻时间
32 private long quitTime; 32 private long quitTime;
33 33
34 -  
35 -  
36 private long createTime; 34 private long createTime;
37 35
38 private long updateTime; 36 private long updateTime;
@@ -40,4 +38,5 @@ public class StoredSeller { @@ -40,4 +38,5 @@ public class StoredSeller {
40 //是否跳过了芝麻认证,1: 跳过 ,default 0 38 //是否跳过了芝麻认证,1: 跳过 ,default 0
41 private Integer breakZhiMaCert; 39 private Integer breakZhiMaCert;
42 40
  41 + private Integer entryType;
43 } 42 }
@@ -14,10 +14,12 @@ @@ -14,10 +14,12 @@
14 <result column="create_time" property="createTime" jdbcType="INTEGER" /> 14 <result column="create_time" property="createTime" jdbcType="INTEGER" />
15 <result column="update_time" property="updateTime" jdbcType="INTEGER" /> 15 <result column="update_time" property="updateTime" jdbcType="INTEGER" />
16 <result column="break_zhi_ma_cert" property="breakZhiMaCert" jdbcType="TINYINT" /> 16 <result column="break_zhi_ma_cert" property="breakZhiMaCert" jdbcType="TINYINT" />
  17 + <result column="entry_type" property="entryType" jdbcType="INTEGER" />
17 </resultMap> 18 </resultMap>
18 19
19 <sql id="Base_Column_List" > 20 <sql id="Base_Column_List" >
20 - id, uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time ,create_time, update_time,break_zhi_ma_cert 21 + id, uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time ,
  22 + create_time, update_time,break_zhi_ma_cert,entry_type
21 </sql> 23 </sql>
22 24
23 <select id="selectValidByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" > 25 <select id="selectValidByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
@@ -36,12 +38,19 @@ @@ -36,12 +38,19 @@
36 order by id desc limit 1 38 order by id desc limit 1
37 </select> 39 </select>
38 40
  41 +
  42 + <select id="selectByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  43 + select <include refid="Base_Column_List" />
  44 + from stored_seller where uid = #{uid}
  45 + </select>
  46 +
39 <insert id="insert" parameterType="com.yohoufo.dal.order.model.StoredSeller" > 47 <insert id="insert" parameterType="com.yohoufo.dal.order.model.StoredSeller" >
40 - insert into stored_seller (uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time, create_time, update_time,break_zhi_ma_cert) 48 + insert into stored_seller (uid, valid_status,cert_no,cert_name,operator_uid,operator_name,
  49 + enter_time,quit_time, create_time, update_time,break_zhi_ma_cert,entry_type)
41 values (#{uid},#{validStatus}, 50 values (#{uid},#{validStatus},
42 #{certNo},#{certName},#{operatorUid},#{operatorName}, 51 #{certNo},#{certName},#{operatorUid},#{operatorName},
43 #{enterTime},#{quitTime}, 52 #{enterTime},#{quitTime},
44 - #{createTime},#{updateTime},#{breakZhiMaCert}) 53 + #{createTime},#{updateTime},#{breakZhiMaCert},#{entryType})
45 </insert> 54 </insert>
46 55
47 <update id="updateStatusByUid"> 56 <update id="updateStatusByUid">
@@ -50,11 +59,122 @@ @@ -50,11 +59,122 @@
50 where uid = #{uid} and valid_status = #{expectStatus} 59 where uid = #{uid} and valid_status = #{expectStatus}
51 </update> 60 </update>
52 61
53 - <!-- <update id="updateToQuitByPrimaryKey"> 62 +
  63 + <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.StoredSeller" useGeneratedKeys="true">
  64 + insert into stored_seller
  65 + <trim prefix="(" suffix=")" suffixOverrides=",">
  66 + <if test="uid != null">
  67 + uid,
  68 + </if>
  69 + <if test="validStatus != null">
  70 + valid_status,
  71 + </if>
  72 + <if test="certName != null">
  73 + cert_name,
  74 + </if>
  75 + <if test="certNo != null">
  76 + cert_no,
  77 + </if>
  78 + <if test="enterTime != null">
  79 + enter_time,
  80 + </if>
  81 + <if test="quitTime != null">
  82 + quit_time,
  83 + </if>
  84 + <if test="operatorUid != null">
  85 + operator_uid,
  86 + </if>
  87 + <if test="operatorName != null">
  88 + operator_name,
  89 + </if>
  90 + <if test="createTime != null">
  91 + create_time,
  92 + </if>
  93 + <if test="updateTime != null">
  94 + update_time,
  95 + </if>
  96 + <if test="breakZhiMaCert != null">
  97 + break_zhi_ma_cert,
  98 + </if>
  99 + <if test="entryType != null">
  100 + entry_type,
  101 + </if>
  102 + </trim>
  103 + <trim prefix="values (" suffix=")" suffixOverrides=",">
  104 + <if test="uid != null">
  105 + #{uid,jdbcType=INTEGER},
  106 + </if>
  107 + <if test="validStatus != null">
  108 + #{validStatus,jdbcType=TINYINT},
  109 + </if>
  110 + <if test="certName != null">
  111 + #{certName,jdbcType=VARCHAR},
  112 + </if>
  113 + <if test="certNo != null">
  114 + #{certNo,jdbcType=VARCHAR},
  115 + </if>
  116 + <if test="enterTime != null">
  117 + #{enterTime,jdbcType=INTEGER},
  118 + </if>
  119 + <if test="quitTime != null">
  120 + #{quitTime,jdbcType=INTEGER},
  121 + </if>
  122 + <if test="operatorUid != null">
  123 + #{operatorUid,jdbcType=INTEGER},
  124 + </if>
  125 + <if test="operatorName != null">
  126 + #{operatorName,jdbcType=VARCHAR},
  127 + </if>
  128 + <if test="createTime != null">
  129 + #{createTime,jdbcType=INTEGER},
  130 + </if>
  131 + <if test="updateTime != null">
  132 + #{updateTime,jdbcType=INTEGER},
  133 + </if>
  134 + <if test="breakZhiMaCert != null">
  135 + #{breakZhiMaCert,jdbcType=TINYINT},
  136 + </if>
  137 + <if test="entryType != null">
  138 + #{entryType,jdbcType=INTEGER},
  139 + </if>
  140 + </trim>
  141 + </insert>
  142 +
  143 + <update id="updateByUidSelective" parameterType="com.yohoufo.dal.order.model.StoredSeller">
54 update stored_seller 144 update stored_seller
55 - set valid_status = #{validStatus},operator_uid = #{operatorUid},operator_name=#{operatorName},  
56 - quit_time = #{quitTime} ,update_time = #{updateTime}  
57 - where id = #{id} and valid_status = #{expectStatus}  
58 - </update>--> 145 + <set>
  146 + <if test="validStatus != null">
  147 + valid_status = #{validStatus,jdbcType=TINYINT},
  148 + </if>
  149 + <if test="certName != null">
  150 + cert_name = #{certName,jdbcType=VARCHAR},
  151 + </if>
  152 + <if test="certNo != null">
  153 + cert_no = #{certNo,jdbcType=VARCHAR},
  154 + </if>
  155 + <if test="enterTime != null">
  156 + enter_time = #{enterTime,jdbcType=INTEGER},
  157 + </if>
  158 + <if test="quitTime != null">
  159 + quit_time = #{quitTime,jdbcType=INTEGER},
  160 + </if>
  161 + <if test="operatorUid != null">
  162 + operator_uid = #{operatorUid,jdbcType=INTEGER},
  163 + </if>
  164 + <if test="operatorName != null">
  165 + operator_name = #{operatorName,jdbcType=VARCHAR},
  166 + </if>
59 167
  168 + <if test="updateTime != null">
  169 + update_time = #{updateTime,jdbcType=INTEGER},
  170 + </if>
  171 + <if test="breakZhiMaCert != null">
  172 + break_zhi_ma_cert = #{breakZhiMaCert,jdbcType=TINYINT},
  173 + </if>
  174 + <if test="entryType != null">
  175 + entry_type = #{entryType,jdbcType=INTEGER},
  176 + </if>
  177 + </set>
  178 + where uid = #{uid,jdbcType=INTEGER}
  179 + </update>
60 </mapper> 180 </mapper>
1 package com.yohoufo.order.service.impl; 1 package com.yohoufo.order.service.impl;
2 2
  3 +import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
3 import com.yohobuy.ufo.model.order.common.EntrySellerType; 4 import com.yohobuy.ufo.model.order.common.EntrySellerType;
  5 +import com.yohoufo.common.exception.UfoServiceException;
  6 +import com.yohoufo.dal.order.StoredSellerMapper;
4 import com.yohoufo.dal.order.SuperEntrySellerMapper; 7 import com.yohoufo.dal.order.SuperEntrySellerMapper;
  8 +import com.yohoufo.dal.order.model.StoredSeller;
5 import com.yohoufo.dal.order.model.SuperEntrySeller; 9 import com.yohoufo.dal.order.model.SuperEntrySeller;
6 import com.yohoufo.order.common.SurperEntrySellerStatus; 10 import com.yohoufo.order.common.SurperEntrySellerStatus;
7 import com.yohoufo.order.service.IStoredSellerService; 11 import com.yohoufo.order.service.IStoredSellerService;
@@ -15,6 +19,7 @@ import org.springframework.stereotype.Service; @@ -15,6 +19,7 @@ import org.springframework.stereotype.Service;
15 19
16 import java.math.BigDecimal; 20 import java.math.BigDecimal;
17 import java.util.List; 21 import java.util.List;
  22 +import java.util.Objects;
18 import java.util.stream.Collectors; 23 import java.util.stream.Collectors;
19 24
20 /** 25 /**
@@ -36,6 +41,9 @@ public class SellerService { @@ -36,6 +41,9 @@ public class SellerService {
36 41
37 @Autowired 42 @Autowired
38 private SuperEntrySellerMapper superEntrySellerMapper; 43 private SuperEntrySellerMapper superEntrySellerMapper;
  44 +
  45 + @Autowired
  46 + private StoredSellerMapper storedSellerMapper;
39 /**更低出价提醒 47 /**更低出价提醒
40 * 1)当有新卖家出价成功或调价成功时,给所有正在出售该sku(尺码)的其他卖家推送一条消息(push+消息盒子) 48 * 1)当有新卖家出价成功或调价成功时,给所有正在出售该sku(尺码)的其他卖家推送一条消息(push+消息盒子)
41 *2)同一卖家的同一SKU 1小时内仅推送一条提醒(最先推送的那条) 49 *2)同一卖家的同一SKU 1小时内仅推送一条提醒(最先推送的那条)
@@ -84,24 +92,59 @@ public class SellerService { @@ -84,24 +92,59 @@ public class SellerService {
84 92
85 93
86 public boolean isSuperEntrySeller(int uid){ 94 public boolean isSuperEntrySeller(int uid){
87 -  
88 if(storedSellerService.isStoredSeller(uid)){ 95 if(storedSellerService.isStoredSeller(uid)){
89 -  
90 - List<Integer> uidList = getSuperEntrySellerUids();  
91 - logger.info("isSuperEntrySeller check uid {} uidList {}", uid, uidList);  
92 - if (CollectionUtils.isNotEmpty(uidList)){  
93 - //hit or not  
94 - return uidList.contains(uid);  
95 - } 96 + return isSpecialSuper(uid);
96 } 97 }
  98 + return false;
  99 + }
97 100
  101 + private boolean isSpecialSuper(int uid){
  102 + List<Integer> uidList = getSuperEntrySellerUids();
  103 + logger.info("isSuperEntrySeller check uid {} uidList {}", uid, uidList);
  104 + if (CollectionUtils.isNotEmpty(uidList)){
  105 + //hit or not
  106 + return uidList.contains(uid);
  107 + }
98 return false; 108 return false;
99 } 109 }
100 110
101 111
  112 + /**
  113 + * 获取入驻商家类型
  114 + * @param uid
  115 + * @return
  116 + */
102 public EntrySellerType getEntrySellerType(int uid){ 117 public EntrySellerType getEntrySellerType(int uid){
103 logger.info("getEntrySellerType uid {}", uid); 118 logger.info("getEntrySellerType uid {}", uid);
104 - return EntrySellerType.getEntrySellerType(null); 119 + if (uid<=0){
  120 + logger.warn("getEntrySellerType illegal uid {}", uid);
  121 + throw new UfoServiceException(401, "uid is not legal");
  122 + }
  123 + EntrySellerType est = null;
  124 + //case 1 : not entry
  125 + StoredSeller storedSeller = storedSellerMapper.selectByUid(uid);
  126 + if (Objects.isNull(storedSeller)){
  127 + est = EntrySellerType.NOT_ENTRY;
  128 + logger.info("getEntrySellerType storedSeller is null uid {} entryType {}",
  129 + uid, est);
  130 + return est;
  131 + }
  132 + //case 2:exit entry
  133 + Integer validStatus = storedSeller.getValidStatus();
  134 + Integer entryType = storedSeller.getEntryType();
  135 + logger.info("getEntrySellerType uid {} validStatus {} entryType {}",
  136 + uid, validStatus, entryType);
  137 + if (Objects.equals(StoredSellerStatusEnum.quit.getId(), validStatus)){
  138 + est = EntrySellerType.NOT_ENTRY;
  139 + }else if(isSpecialSuper(uid)){
  140 + //case 3:valid ok and in white list
  141 + est = EntrySellerType.SPECIAL_SUPER;
  142 + }else if (Objects.equals(StoredSellerStatusEnum.entered.getId(), validStatus)){
  143 + //case 4: left common or super
  144 + est = EntrySellerType.getEntrySellerType(entryType);
  145 + }
  146 + logger.info("getEntrySellerType uid {} EntrySellerType {}", uid, est);
  147 + return est;
105 } 148 }
106 149
107 } 150 }
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl; @@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl;
3 import com.yoho.error.exception.ServiceException; 3 import com.yoho.error.exception.ServiceException;
4 import com.yoho.tools.common.beans.ApiResponse; 4 import com.yoho.tools.common.beans.ApiResponse;
5 import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum; 5 import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
  6 +import com.yohobuy.ufo.model.order.common.EntrySellerType;
6 import com.yohoufo.common.caller.UfoServiceCaller; 7 import com.yohoufo.common.caller.UfoServiceCaller;
7 import com.yohoufo.dal.order.StoredSellerMapper; 8 import com.yohoufo.dal.order.StoredSellerMapper;
8 import com.yohoufo.dal.order.model.StoredSeller; 9 import com.yohoufo.dal.order.model.StoredSeller;
@@ -148,8 +149,9 @@ public class StoreSellerServiceImpl implements IStoredSellerService { @@ -148,8 +149,9 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
148 storedSeller.setCreateTime(ts); 149 storedSeller.setCreateTime(ts);
149 storedSeller.setUpdateTime(ts); 150 storedSeller.setUpdateTime(ts);
150 storedSeller.setBreakZhiMaCert(breakZhiMaCert); 151 storedSeller.setBreakZhiMaCert(breakZhiMaCert);
  152 + storedSeller.setEntryType(EntrySellerType.COMMON.getCode());
151 logger.info("StoredSellerServiceImpl addUserAsStoredSeller insert uid is {} , storedSeller {} ",uid,storedSeller); 153 logger.info("StoredSellerServiceImpl addUserAsStoredSeller insert uid is {} , storedSeller {} ",uid,storedSeller);
152 - int num=storedSellerMapper.insert(storedSeller); 154 + int num = storedSellerMapper.insert(storedSeller);
153 if(num<0){ 155 if(num<0){
154 logger.error("StoredSellerServiceImpl addUserAsStoredSeller error uid is {} , storedSeller {} ,insert num {} ",uid,storedSeller,num); 156 logger.error("StoredSellerServiceImpl addUserAsStoredSeller error uid is {} , storedSeller {} ,insert num {} ",uid,storedSeller,num);
155 throw new ServiceException(400,"新增入驻商户信息错误"); 157 throw new ServiceException(400,"新增入驻商户信息错误");
@@ -160,7 +162,6 @@ public class StoreSellerServiceImpl implements IStoredSellerService { @@ -160,7 +162,6 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
160 162
161 //发送消息 163 //发送消息
162 inBoxFacade.sendMsg4EntySeller(uid); 164 inBoxFacade.sendMsg4EntySeller(uid);
163 -  
164 } 165 }
165 166
166 private ZhiMaCert getZhiMaCertInfo(int targetUid) { 167 private ZhiMaCert getZhiMaCertInfo(int targetUid) {