Authored by mali

Merge branch 'hotfix_vedio' into test6.9.1

package com.yoho.ufo.util;
import org.apache.commons.lang3.StringUtils;
/**
* Created by li.ma on 2019/4/19.
*/
public class KeyWordHiddenUtil {
/**
* 隐晦敏感词
* @param keyWord
* @param startlength 显示开始的几个字符
* @param endLength 显示结束的几个字符
* @return 隐晦后的敏感词
*/
public static String hiddenKeyWord(String keyWord, int startlength, int endLength) {
if (StringUtils.isEmpty(keyWord)) {
return keyWord;
}
int length = keyWord.length();
if (length <= startlength + endLength) {
return keyWord;
}
StringBuffer sb = new StringBuffer(length - startlength - endLength);
for (int i = length - startlength - endLength; i > 0; i--) {
sb.append('*');
}
return keyWord.substring(0, startlength) + sb.toString() + keyWord.substring(length - endLength);
}
}
... ...
... ... @@ -20,7 +20,7 @@ public interface ProductLimitSaleMapper {
List<ProductLimitSale> selectByProductId(Integer productId);
int softDeleteByProductId(Integer productId);
int softDeleteByProductId(@Param("productId")Integer productId, @Param("editUid")Integer editUid);
List<Integer> selectHasDataProductIds(@Param("productIdList")List<Integer> productIdList);
... ...
... ... @@ -20,4 +20,6 @@ public class ProductLimitSale {
private Integer delStatus;
private Integer editUid;
}
\ No newline at end of file
... ...
... ... @@ -8,9 +8,10 @@
<result column="profit_rate" property="profitRate" jdbcType="DECIMAL" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="del_status" property="delStatus" jdbcType="INTEGER" />
<result column="edit_uid" property="editUid" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, product_id, uid, profit_rate, create_time, del_status
id, product_id, uid, profit_rate, create_time, del_status,edit_uid
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -48,10 +49,10 @@
<insert id="insert" parameterType="com.yoho.ufo.dal.model.ProductLimitSale" >
insert into product_limit_sale (id, product_id, uid,
profit_rate, create_time, del_status
profit_rate, create_time, del_status,edit_uid
)
values (#{id,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER},
#{profitRate,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER}, #{delStatus,jdbcType=INTEGER}
#{profitRate,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER}, #{delStatus,jdbcType=INTEGER}, #{editUid,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yoho.ufo.dal.model.ProductLimitSale" >
... ... @@ -129,7 +130,7 @@
</update>
<update id="softDeleteByProductId" parameterType="com.yoho.ufo.dal.model.ProductLimitSale" >
update product_limit_sale set del_status = 1 where product_id = #{productId,jdbcType=INTEGER} and del_status=0
update product_limit_sale set del_status = 1,editUid=#{editUid} where product_id = #{productId,jdbcType=INTEGER} and del_status=0
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -22,6 +22,7 @@ import com.yoho.ufo.order.response.StoredSellerRespVo;
import com.yoho.ufo.order.service.ITradeBillsService;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yoho.ufo.util.CollectionUtil;
import com.yoho.ufo.util.KeyWordHiddenUtil;
import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
import com.yohobuy.ufo.model.order.resp.TradeBillsResp;
import com.yohobuy.ufo.model.user.req.AuthorizeInfoReq;
... ... @@ -116,7 +117,7 @@ public class TradeBillsServiceImpl implements ITradeBillsService {
StoredSellerRespVo resp=new StoredSellerRespVo();
resp.setUid(item.getUid());
resp.setCertName(item.getCertName());
resp.setCertNo(item.getCertNo());
resp.setCertNo(KeyWordHiddenUtil.hiddenKeyWord(item.getCertNo(), 2, 2));
resp.setValidStatus(item.getValidStatus());
resp.setValidStatusDesc(StoredSellerStatusEnum.getDescriptionByCode(item.getValidStatus()));
resp.setMobile(getMobileByUidFromCache(item.getUid()));
... ...
... ... @@ -116,6 +116,12 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
@Override
public ApiResponse<Void> addOrUpdate(ProductRequestBo bo, boolean isCheckUrl) {
Integer uid = new UserHelper().getUserId();
if (uid == null || uid < 1) {
return new ApiResponse<>(400, "请先登录!", null);
}
checkProductInfo(bo, isCheckUrl);
Product product = getProductFromBo(bo);
Goods goods = getGoodsFromBo(bo);
... ... @@ -167,12 +173,12 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
}
}
updateLimitSaleInfo(bo.getLimitSaleInfo(), productId);
updateLimitSaleInfo(bo.getLimitSaleInfo(), productId, uid);
productIntroService.insertProductDesc(productId, bo.getProductIntro());
return new ApiResponse<Void>(null);
}
private void updateLimitSaleInfo(List<String> limitSaleInfo, Integer productId) {
private void updateLimitSaleInfo(List<String> limitSaleInfo, Integer productId, Integer editUid) {
Map<Integer, BigDecimal> map = new HashMap<>();
if (CollectionUtils.isNotEmpty(limitSaleInfo)) {
for (int i = 0; i < limitSaleInfo.size(); i++) {
... ... @@ -235,7 +241,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
}
LOGGER.info("商品:{} 限制出售包含关系,删除之后为:{}", productId, map);
} else {
int num = productLimitSaleMapper.softDeleteByProductId(productId);
int num = productLimitSaleMapper.softDeleteByProductId(productId, editUid);
LOGGER.info("商品:{} 限制出售清空模式!软删除结果:{}", productId, num);
}
int now = (int) (System.currentTimeMillis() / 1000);
... ... @@ -246,6 +252,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
s.setProfitRate(percent);
s.setDelStatus(0);
s.setCreateTime(now);
s.setEditUid(editUid);
productLimitSaleMapper.insert(s);
LOGGER.info("商品:{} 限制出售,新增条目:{}", productId, s);
});
... ...