Authored by 胡古飞

Merge branch 'wn_shops_add_field' into gray

package com.yoho.search.dal;
import com.yoho.search.dal.model.ShopDecoratorBO;
import com.yoho.search.dal.model.ShopsDecorator;
import java.util.List;
public interface ShopsDecoratorMapper {
int deleteByPrimaryKey(Integer id);
int insert(ShopsDecorator record);
int insertSelective(ShopsDecorator record);
ShopsDecorator selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(ShopsDecorator record);
int updateByPrimaryKey(ShopsDecorator record);
List<ShopDecoratorBO> selectForDecoratorId();
}
\ No newline at end of file
... ...
package com.yoho.search.dal;
import com.yoho.search.dal.model.ShopsDecoratorTemplate;
import java.util.List;
public interface ShopsDecoratorTemplateMapper {
int deleteByPrimaryKey(Integer id);
int insert(ShopsDecoratorTemplate record);
int insertSelective(ShopsDecoratorTemplate record);
ShopsDecoratorTemplate selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(ShopsDecoratorTemplate record);
int updateByPrimaryKey(ShopsDecoratorTemplate record);
List<ShopsDecoratorTemplate> getByShopsDecoratorIds(List<Integer> ids);
}
\ No newline at end of file
... ...
package com.yoho.search.dal.model;
/**
* Created by wangnan on 2017/3/9.
*/
public class ShopDecoratorBO {
private Integer shopsId;
private Integer shopsDecoratorId;
public Integer getShopsId() {
return shopsId;
}
public void setShopsId(Integer shopsId) {
this.shopsId = shopsId;
}
public Integer getShopsDecoratorId() {
return shopsDecoratorId;
}
public void setShopsDecoratorId(Integer shopsDecoratorId) {
this.shopsDecoratorId = shopsDecoratorId;
}
}
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.ShopsDecoratorMapper">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ShopsDecorator">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="shops_id" property="shopsId" jdbcType="INTEGER"/>
<result column="check_status" property="checkStatus" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="INTEGER"/>
<result column="update_time" property="updateTime" jdbcType="INTEGER"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="app_type" property="appType" jdbcType="INTEGER"/>
<result column="blk_check_status" property="blkCheckStatus" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, shops_id, check_status, create_time, update_time, status, app_type, blk_check_status
</sql>
<resultMap id="SelectForDecoratorIdResultMap" type="com.yoho.search.dal.model.ShopDecoratorBO">
<id column="shops_id" property="shopsId" jdbcType="INTEGER"/>
<result column="shops_decorator_id" property="shopsDecoratorId" jdbcType="INTEGER"/>
</resultMap>
<select id="selectForDecoratorId" resultMap="SelectForDecoratorIdResultMap">
SELECT
shops_id,
max(id) shops_decorator_id
FROM
shops_decorator
WHERE
(shops_id, update_time) IN (
SELECT
shops_id,
max(update_time)
FROM
shops_decorator
GROUP BY
shops_id
)
AND check_status = 300
GROUP BY
shops_id;
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List"/>
from shops_decorator
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from shops_decorator
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.search.dal.model.ShopsDecorator">
insert into shops_decorator (id, shops_id, check_status,
create_time, update_time, status,
app_type, blk_check_status)
values (#{id,jdbcType=INTEGER}, #{shopsId,jdbcType=INTEGER}, #{checkStatus,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{appType,jdbcType=INTEGER}, #{blkCheckStatus,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.ShopsDecorator">
insert into shops_decorator
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="shopsId != null">
shops_id,
</if>
<if test="checkStatus != null">
check_status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="status != null">
status,
</if>
<if test="appType != null">
app_type,
</if>
<if test="blkCheckStatus != null">
blk_check_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="shopsId != null">
#{shopsId,jdbcType=INTEGER},
</if>
<if test="checkStatus != null">
#{checkStatus,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="appType != null">
#{appType,jdbcType=INTEGER},
</if>
<if test="blkCheckStatus != null">
#{blkCheckStatus,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ShopsDecorator">
update shops_decorator
<set>
<if test="shopsId != null">
shops_id = #{shopsId,jdbcType=INTEGER},
</if>
<if test="checkStatus != null">
check_status = #{checkStatus,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="appType != null">
app_type = #{appType,jdbcType=INTEGER},
</if>
<if test="blkCheckStatus != null">
blk_check_status = #{blkCheckStatus,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.ShopsDecorator">
update shops_decorator
set shops_id = #{shopsId,jdbcType=INTEGER},
check_status = #{checkStatus,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
app_type = #{appType,jdbcType=INTEGER},
blk_check_status = #{blkCheckStatus,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.ShopsDecoratorTemplateMapper" >
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ShopsDecoratorTemplate" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="shops_decorator_id" property="shopsDecoratorId" jdbcType="INTEGER" />
<result column="platform" property="platform" jdbcType="VARCHAR" />
<result column="template_type" property="templateType" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="is_enable" property="isEnable" jdbcType="CHAR" />
<result column="app_type" property="appType" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, shops_decorator_id, platform, template_type, create_time, update_time, is_enable,
app_type
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from shops_decorator_template
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from shops_decorator_template
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.search.dal.model.ShopsDecoratorTemplate" >
insert into shops_decorator_template (id, shops_decorator_id, platform,
template_type, create_time, update_time,
is_enable, app_type)
values (#{id,jdbcType=INTEGER}, #{shopsDecoratorId,jdbcType=INTEGER}, #{platform,jdbcType=VARCHAR},
#{templateType,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
#{isEnable,jdbcType=CHAR}, #{appType,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.ShopsDecoratorTemplate" >
insert into shops_decorator_template
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="shopsDecoratorId != null" >
shops_decorator_id,
</if>
<if test="platform != null" >
platform,
</if>
<if test="templateType != null" >
template_type,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="isEnable != null" >
is_enable,
</if>
<if test="appType != null" >
app_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="shopsDecoratorId != null" >
#{shopsDecoratorId,jdbcType=INTEGER},
</if>
<if test="platform != null" >
#{platform,jdbcType=VARCHAR},
</if>
<if test="templateType != null" >
#{templateType,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
<if test="isEnable != null" >
#{isEnable,jdbcType=CHAR},
</if>
<if test="appType != null" >
#{appType,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ShopsDecoratorTemplate" >
update shops_decorator_template
<set >
<if test="shopsDecoratorId != null" >
shops_decorator_id = #{shopsDecoratorId,jdbcType=INTEGER},
</if>
<if test="platform != null" >
platform = #{platform,jdbcType=VARCHAR},
</if>
<if test="templateType != null" >
template_type = #{templateType,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
<if test="isEnable != null" >
is_enable = #{isEnable,jdbcType=CHAR},
</if>
<if test="appType != null" >
app_type = #{appType,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.ShopsDecoratorTemplate" >
update shops_decorator_template
set shops_decorator_id = #{shopsDecoratorId,jdbcType=INTEGER},
platform = #{platform,jdbcType=VARCHAR},
template_type = #{templateType,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
is_enable = #{isEnable,jdbcType=CHAR},
app_type = #{appType,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getByShopsDecoratorIds" resultMap="BaseResultMap">
Select
<include refid="Base_Column_List" />
from shops_decorator_template
where
shops_decorator_id
in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -131,6 +131,29 @@
},
"decoratorTemplateType": {
"type": "integer"
},
"shopsDecorators": {
"type": "nested",
"properties": {
"id": {
"type": "integer"
},
"shopsDecoratorId": {
"type": "integer"
},
"platform": {
"type": "string"
},
"templateType": {
"type": "string"
},
"isEnable": {
"type": "string"
},
"appType": {
"type": "integer"
}
}
}
}
}
... ...
package com.yoho.search.consumer.service.bo;
import com.alibaba.fastjson.JSONArray;
import com.yoho.search.dal.model.Shops;
/**
... ... @@ -17,6 +18,8 @@ public class ShopsBO extends Shops {
private String isGlobal = "N";
private JSONArray shopsDecorators;
public String getBrandName() {
return brandName;
}
... ... @@ -33,7 +36,6 @@ public class ShopsBO extends Shops {
this.brandDomain = brandDomain == null ? null : brandDomain.trim();
}
public String getBrandNameCn() {
return brandNameCn;
}
... ... @@ -57,4 +59,12 @@ public class ShopsBO extends Shops {
public void setIsGlobal(String isGlobal) {
this.isGlobal = isGlobal;
}
public JSONArray getShopsDecorators() {
return shopsDecorators;
}
public void setShopsDecorators(JSONArray shopsDecorators) {
this.shopsDecorators = shopsDecorators;
}
}
... ...
package com.yoho.search.consumer.service.logic;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.consumer.service.bo.ShopsBO;
import com.yoho.search.dal.BrandMapper;
import com.yoho.search.dal.ShopMapper;
import com.yoho.search.dal.ShopsBrandsMapper;
import com.yoho.search.dal.model.Brand;
import com.yoho.search.dal.model.Shops;
import com.yoho.search.dal.model.ShopsBrands;
import com.yoho.search.dal.*;
import com.yoho.search.dal.model.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -33,6 +32,10 @@ public class ShopsLogicService {
private ShopsBrandsMapper shopsBrandsMapper;
@Autowired
private BrandMapper brandMapper;
@Autowired
private ShopsDecoratorMapper shopsDecoratorMapper;
@Autowired
private ShopsDecoratorTemplateMapper shopsDecoratorTemplateMapper;
/**
* 增量
... ... @@ -68,6 +71,26 @@ public class ShopsLogicService {
List<Brand> brands = brandMapper.getAll();
Map<Integer, Brand> brandMap = brands.stream().collect(Collectors.toMap(Brand::getId, (p) -> p));
Map<Integer, List<ShopsBrands>> shopsBrandsMap = getShopsBrandsMap(shops);
//获取店铺装修信息
List<ShopDecoratorBO> shopDecoratorBOList = shopsDecoratorMapper.selectForDecoratorId();
HashMap<Integer, Integer> shopsIdShopsDecoratorIdMap = new HashMap<>();
List<Integer> decoratorIds = new ArrayList<>();
shopDecoratorBOList.stream().collect(Collectors.toList()).forEach(ShopDecoratorBO -> shopsIdShopsDecoratorIdMap.put(ShopDecoratorBO.getShopsId(), ShopDecoratorBO.getShopsDecoratorId()));
shopDecoratorBOList.stream().collect(Collectors.toList()).forEach(ShopDecoratorBO -> decoratorIds.add(ShopDecoratorBO.getShopsDecoratorId()));
List<ShopsDecoratorTemplate> shopsDecoratorTemplateList = shopsDecoratorTemplateMapper.getByShopsDecoratorIds(decoratorIds);
HashMap<Integer, List<ShopsDecoratorTemplate>> shopDecoratorListHashMap = new HashMap<>();
for (ShopsDecoratorTemplate shopsDecoratorTemplate : shopsDecoratorTemplateList) {
if (shopDecoratorListHashMap.containsKey(shopsDecoratorTemplate.getShopsDecoratorId())) {
List<ShopsDecoratorTemplate> shopsDecoratorTemplates = shopDecoratorListHashMap.get(shopsDecoratorTemplate.getShopsDecoratorId());
shopsDecoratorTemplates.add(shopsDecoratorTemplate);
}
List<ShopsDecoratorTemplate> shopsDecoratorTemplates = new ArrayList<>();
shopsDecoratorTemplates.add(shopsDecoratorTemplate);
shopDecoratorListHashMap.put(shopsDecoratorTemplate.getShopsDecoratorId(), shopsDecoratorTemplates);
}
for (Shops shop : shops) {
List<ShopsBrands> sbs = shopsBrandsMap.get(shop.getShopsId());
ShopsBO shopsBO = new ShopsBO();
... ... @@ -90,12 +113,38 @@ public class ShopsLogicService {
shopsBO.setUpdateTime(shop.getUpdateTime());
shopsBO.setBlkStatus(shop.getBlkStatus());
shopsBO.setDecoratorTemplateType(shop.getDecoratorTemplateType());
//构建店铺装修信息
buildDecoratorInfo(shopsIdShopsDecoratorIdMap, shopDecoratorListHashMap, shopsBO);
shopsBOs.add(shopsBO);
}
return shopsBOs;
}
/**
* 构建装修信息
*/
private void buildDecoratorInfo(HashMap<Integer, Integer> shopsIdShopsDecoratorIdMap, HashMap<Integer, List<ShopsDecoratorTemplate>> shopDecoratorListHashMap, ShopsBO shopsBO) {
Integer decoratorId = shopsIdShopsDecoratorIdMap.get(shopsBO.getShopsId());
List<ShopsDecoratorTemplate> shopsDecoratorTemplateList = shopDecoratorListHashMap.get(decoratorId);
if(CollectionUtils.isEmpty(shopsDecoratorTemplateList)){
return;
}
JSONArray jsonArray = new JSONArray();
for (ShopsDecoratorTemplate shopsDecoratorTemplate : shopsDecoratorTemplateList) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", shopsDecoratorTemplate.getId() == null ? "" : shopsDecoratorTemplate.getId());
jsonObject.put("shopsDecoratorId", shopsDecoratorTemplate.getShopsDecoratorId() == null ? "" : shopsDecoratorTemplate.getShopsDecoratorId());
jsonObject.put("platform", StringUtils.isBlank(shopsDecoratorTemplate.getPlatform()) ? "" : shopsDecoratorTemplate.getPlatform());
jsonObject.put("templateType", StringUtils.isBlank(shopsDecoratorTemplate.getTemplateType()) ? "" : shopsDecoratorTemplate.getTemplateType());
jsonObject.put("isEnable", StringUtils.isBlank(shopsDecoratorTemplate.getIsEnable()) ? "" : shopsDecoratorTemplate.getIsEnable());
jsonObject.put("appType", shopsDecoratorTemplate.getAppType() == null ? "" : shopsDecoratorTemplate.getAppType());
jsonArray.add(jsonObject);
}
shopsBO.setShopsDecorators(jsonArray);
}
/**
* 处理品牌名
*/
private void buildBrandName(List<ShopsBrands> sbs, Map<Integer, Brand> brandMap, ShopsBO shopsBO) {
... ...
... ... @@ -49,7 +49,7 @@ public class TblShopsLogicService {
shopsBO.setBrandNameCn(tblBrand.getBrandNameCn());
shopsBO.setBrandNameEn(tblBrand.getBrandNameEn());
shopsBO.setBrandDomain("");
shopsBO.setShopsId(tblBrand.getBrandId() * (-1));
shopsBO.setShopsId(0);
shopsBO.setShopName(tblBrand.getBrandNameEn());
shopsBO.setShopDomain("");
shopsBO.setShopNature(0);
... ...