Commit 3d84b592 by guojuxing

微盟同步日志接口

parent 7c689f6a
package com.gic.enterprise.dto.wm;
import java.io.Serializable;
import java.util.Date;
/**
* @ClassName: WmStoreSyncLogDTO

* @Description: 

* @author guojuxing

* @date 2020/5/15 10:05 AM

*/
public class WmStoreSyncLogDTO implements Serializable{
private static final long serialVersionUID = 2365626532131284536L;
/**
*
*/
private Integer id;
/**
*
*/
private Integer enterpriseId;
/**
* 店铺主键ID,用于关联配置
*/
private Integer wmMallStoreId;
/**
*
*/
private String storeId;
/**
* 1:总店 2:门店同步(实体)
*/
private Integer type;
/**
* 门店名称
*/
private String storeName;
/**
* 门店code
*/
private String storeCode;
/**
* 1:已同步微盟 0:微盟侧已删除
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getId() {
return id;
}
public WmStoreSyncLogDTO setId(Integer id) {
this.id = id;
return this;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public WmStoreSyncLogDTO setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
return this;
}
public Integer getWmMallStoreId() {
return wmMallStoreId;
}
public WmStoreSyncLogDTO setWmMallStoreId(Integer wmMallStoreId) {
this.wmMallStoreId = wmMallStoreId;
return this;
}
public String getStoreId() {
return storeId;
}
public WmStoreSyncLogDTO setStoreId(String storeId) {
this.storeId = storeId;
return this;
}
public Integer getType() {
return type;
}
public WmStoreSyncLogDTO setType(Integer type) {
this.type = type;
return this;
}
public String getStoreName() {
return storeName;
}
public WmStoreSyncLogDTO setStoreName(String storeName) {
this.storeName = storeName;
return this;
}
public String getStoreCode() {
return storeCode;
}
public WmStoreSyncLogDTO setStoreCode(String storeCode) {
this.storeCode = storeCode;
return this;
}
public Integer getStatus() {
return status;
}
public WmStoreSyncLogDTO setStatus(Integer status) {
this.status = status;
return this;
}
public Date getCreateTime() {
return createTime;
}
public WmStoreSyncLogDTO setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
public Date getUpdateTime() {
return updateTime;
}
public WmStoreSyncLogDTO setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
return this;
}
}
package com.gic.enterprise.service;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.dto.wm.WmStoreSyncLogDTO;
import java.util.List;
public interface WmStoreSyncLogApiService {
/**
* 新增微盟同步日志
* @Title: saveWmStoreSyncLog

* @Description:

* @author guojuxing
* @param storeIdList 门店
* @param wmMallStoreId 微盟店铺ID
* @param type 1:总店 2:门店同步(一对一)
* @param enterpriseId
商户ID
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


*/
ServiceResponse<Void> saveWmStoreSyncLog(List<Integer> storeIdList, Integer wmMallStoreId,
Integer type, Integer enterpriseId);
/**
* 分页查询门店同步日志
* @Title: pageWmStoreSyncLog

* @Description:

* @author guojuxing
* @param search 门店code/名称
* @param type 1:总店 2:门店同步(一对一)
* @param wmMallStoreId 店铺ID
* @param pageNum 第几页
* @param pageSize
每页多少条
* @return com.gic.api.base.commons.ServiceResponse<com.gic.api.base.commons.Page<com.gic.enterprise.dto.wm.WmStoreSyncLogDTO>>


*/
ServiceResponse<Page<WmStoreSyncLogDTO>> pageWmStoreSyncLog(String search, Integer type, Integer wmMallStoreId,
Integer pageNum, Integer pageSize);
/**
* 已经同步过的门店
* @Title: getStoreList

* @Description:

* @author guojuxing
* @param type
* @param wmMallStoreId

* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.enterprise.dto.wm.WmStoreSyncLogDTO>>


*/
ServiceResponse<List<WmStoreSyncLogDTO>> getStoreList(List<Integer> type, Integer wmMallStoreId);
}
package com.gic.enterprise.dao.mapper;
import com.gic.enterprise.entity.TabWmStoreSyncLog;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabWmStoreSyncLogMapper {
/**
* 根据主键删除
*
* @param id 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer id);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabWmStoreSyncLog record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabWmStoreSyncLog record);
/**
* 根据主键查询
*
* @param id 主键
* @return 实体对象
*/
TabWmStoreSyncLog selectByPrimaryKey(Integer id);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabWmStoreSyncLog record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabWmStoreSyncLog record);
List<TabWmStoreSyncLog> pageWmStoreSyncLog(@Param("search") String search, @Param("type") Integer type,
@Param("wmMallStoreId") Integer wmMallStoreId);
List<TabWmStoreSyncLog> getStoreList(@Param("typeList") List<Integer> type, @Param("wmMallStoreId") Integer wmMallStoreId);
}
\ No newline at end of file
package com.gic.enterprise.entity;
import java.util.Date;
/**
* tab_wm_store_sync_log
*/
public class TabWmStoreSyncLog {
/**
*
*/
private Integer id;
/**
*
*/
private Integer enterpriseId;
/**
* 店铺主键ID,用于关联配置
*/
private Integer wmMallStoreId;
/**
*
*/
private Integer storeId;
/**
* 1:总店 2:门店同步(实体)
*/
private Integer storeType;
/**
* 门店名称
*/
private String storeName;
/**
* 门店code
*/
private String storeCode;
/**
* 1:已同步微盟 0:微盟侧已删除
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getId() {
return id;
}
public TabWmStoreSyncLog setId(Integer id) {
this.id = id;
return this;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public TabWmStoreSyncLog setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
return this;
}
public Integer getWmMallStoreId() {
return wmMallStoreId;
}
public TabWmStoreSyncLog setWmMallStoreId(Integer wmMallStoreId) {
this.wmMallStoreId = wmMallStoreId;
return this;
}
public Integer getStoreId() {
return storeId;
}
public TabWmStoreSyncLog setStoreId(Integer storeId) {
this.storeId = storeId;
return this;
}
public Integer getStoreType() {
return storeType;
}
public TabWmStoreSyncLog setStoreType(Integer storeType) {
this.storeType = storeType;
return this;
}
public String getStoreName() {
return storeName;
}
public TabWmStoreSyncLog setStoreName(String storeName) {
this.storeName = storeName;
return this;
}
public String getStoreCode() {
return storeCode;
}
public TabWmStoreSyncLog setStoreCode(String storeCode) {
this.storeCode = storeCode;
return this;
}
public Integer getStatus() {
return status;
}
public TabWmStoreSyncLog setStatus(Integer status) {
this.status = status;
return this;
}
public Date getCreateTime() {
return createTime;
}
public TabWmStoreSyncLog setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
public Date getUpdateTime() {
return updateTime;
}
public TabWmStoreSyncLog setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
return this;
}
}
\ No newline at end of file
package com.gic.enterprise.service;
import com.gic.enterprise.entity.TabWmStoreSyncLog;
import com.github.pagehelper.Page;
import java.util.List;
public interface WmStoreSyncLogService {
void saveWmStoreSyncLog(Integer storeId, Integer wmMallStoreId,
Integer type, Integer enterpriseId, String storeCode, String storeName);
Page<TabWmStoreSyncLog> pageWmStoreSyncLog(String search, Integer type, Integer wmMallStoreId,
Integer pageNum, Integer pageSize);
List<TabWmStoreSyncLog> getStoreList(List<Integer> type, Integer wmMallStoreId);
}
package com.gic.enterprise.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.enterprise.dao.mapper.TabWmStoreSyncLogMapper;
import com.gic.enterprise.entity.TabWmStoreSyncLog;
import com.gic.enterprise.service.WmStoreSyncLogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
@Service("wmStoreSyncLogService")
public class WmStoreSyncLogServiceImpl implements WmStoreSyncLogService {
@Autowired
private TabWmStoreSyncLogMapper tabWmStoreSyncLogMapper;
@Override
public void saveWmStoreSyncLog(Integer storeId, Integer wmMallStoreId, Integer type,
Integer enterpriseId, String storeCode, String storeName) {
Date now = new Date();
TabWmStoreSyncLog record = new TabWmStoreSyncLog()
.setStoreId(storeId)
.setEnterpriseId(enterpriseId)
.setStatus(1)
.setStoreCode(storeCode)
.setWmMallStoreId(wmMallStoreId)
.setStoreName(storeName)
.setStoreType(type)
.setCreateTime(now)
.setUpdateTime(now);
tabWmStoreSyncLogMapper.insert(record);
}
@Override
public Page<TabWmStoreSyncLog> pageWmStoreSyncLog(String search, Integer type,
Integer wmMallStoreId, Integer pageNum, Integer pageSize) {
PageHelper.startPage(pageNum, pageSize);
List<TabWmStoreSyncLog> list = tabWmStoreSyncLogMapper.pageWmStoreSyncLog(search, type, wmMallStoreId);
return (Page<TabWmStoreSyncLog>) list;
}
@Override
public List<TabWmStoreSyncLog> getStoreList(List<Integer> type, Integer wmMallStoreId) {
return tabWmStoreSyncLogMapper.getStoreList(type, wmMallStoreId);
}
}
package com.gic.enterprise.service.outer.impl;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.dto.wm.WmStoreSyncLogDTO;
import com.gic.enterprise.entity.TabWmStoreSyncLog;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.service.WmStoreSyncLogApiService;
import com.gic.enterprise.service.WmStoreSyncLogService;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreSearchDTO;
import com.gic.store.service.StoreApiService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@Service("wmStoreSyncLogApiService")
public class WmStoreSyncLogApiServiceImpl implements WmStoreSyncLogApiService {
@Autowired
private WmStoreSyncLogService wmStoreSyncLogService;
@Autowired
private StoreApiService storeApiService;
@Override
public ServiceResponse<Void> saveWmStoreSyncLog(List<Integer> storeIdList, Integer wmMallStoreId, Integer type,
Integer enterpriseId) {
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
StringBuilder storeIds = new StringBuilder();
storeIdList.forEach(storeId -> storeIds.append(storeId).append(","));
storeSearchDTO.setStoreIds(storeIds.toString());
ServiceResponse<Page<StoreDTO>> storeResponse = storeApiService.listStore(storeSearchDTO, 0, storeIdList.size());
if (storeResponse.isSuccess()) {
Page<StoreDTO> page = storeResponse.getResult();
if (page != null) {
List<StoreDTO> storeList = page.getResult();
if (CollectionUtils.isNotEmpty(storeList)) {
storeList.forEach(temp -> wmStoreSyncLogService
.saveWmStoreSyncLog(temp.getStoreId(), enterpriseId, wmMallStoreId, type, temp.getStoreCode(), temp.getStoreName()));
}
return ServiceResponse.success();
}
}
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "ES没有门店数据");
}
@Override
public ServiceResponse<Page<WmStoreSyncLogDTO>> pageWmStoreSyncLog(String search, Integer type,
Integer wmMallStoreId, Integer pageNum, Integer pageSize) {
com.github.pagehelper.Page page = wmStoreSyncLogService.pageWmStoreSyncLog(search, type, wmMallStoreId, pageNum, pageSize);
Page<WmStoreSyncLogDTO> resultPage = PageHelperUtils.changePageHelperToCurrentPage(page, WmStoreSyncLogDTO.class);
return ServiceResponse.success(resultPage);
}
@Override
public ServiceResponse<List<WmStoreSyncLogDTO>> getStoreList(List<Integer> type, Integer wmMallStoreId) {
List<TabWmStoreSyncLog> list = wmStoreSyncLogService.getStoreList(type, wmMallStoreId);
if (CollectionUtils.isNotEmpty(list)) {
return ServiceResponse.success(EntityUtil.changeEntityListNew(WmStoreSyncLogDTO.class, list));
}
return ServiceResponse.success(Collections.emptyList());
}
}
......@@ -128,6 +128,7 @@
<dubbo:service interface="com.gic.enterprise.service.DataConfigApiService" ref="dataConfigApiService" timeout="6000" />
<dubbo:service interface="com.gic.enterprise.service.AppletQrcodeApiService" ref="appletQrcodeApiService" timeout="6000" />
<dubbo:service interface="com.gic.enterprise.service.WmStoreSyncLogApiService" ref="wmStoreSyncLogApiService" timeout="6000" />
<dubbo:reference interface="com.gic.mall.share.api.service.ShopApiService" id="shopApiService" timeout="6000" />
......
<?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.gic.enterprise.dao.mapper.TabWmStoreSyncLogMapper">
<resultMap id="BaseResultMap" type="com.gic.enterprise.entity.TabWmStoreSyncLog">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="wm_mall_store_id" jdbcType="INTEGER" property="wmMallStoreId" />
<result column="store_id" jdbcType="INTEGER" property="storeId" />
<result column="store_type" jdbcType="INTEGER" property="storeType" />
<result column="store_name" jdbcType="VARCHAR" property="storeName" />
<result column="store_code" jdbcType="VARCHAR" property="storeCode" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
id, enterprise_id, wm_mall_store_id, store_id, store_type, store_name, store_code, status,
create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_wm_store_sync_log
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_wm_store_sync_log
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.enterprise.entity.TabWmStoreSyncLog">
insert into tab_wm_store_sync_log (id, enterprise_id, wm_mall_store_id,
store_id, store_type, store_name,
store_code, status, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{enterpriseId,jdbcType=INTEGER}, #{wmMallStoreId,jdbcType=INTEGER},
#{storeId,jdbcType=INTEGER}, #{storeType,jdbcType=INTEGER}, #{storeName,jdbcType=VARCHAR},
#{storeCode,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.enterprise.entity.TabWmStoreSyncLog">
insert into tab_wm_store_sync_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="wmMallStoreId != null">
wm_mall_store_id,
</if>
<if test="storeId != null">
store_id,
</if>
<if test="storeType != null">
store_type,
</if>
<if test="storeName != null">
store_name,
</if>
<if test="storeCode != null">
store_code,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=INTEGER},
</if>
<if test="wmMallStoreId != null">
#{wmMallStoreId,jdbcType=INTEGER},
</if>
<if test="storeId != null">
#{storeId,jdbcType=INTEGER},
</if>
<if test="storeType != null">
#{storeType,jdbcType=INTEGER},
</if>
<if test="storeName != null">
#{storeName,jdbcType=VARCHAR},
</if>
<if test="storeCode != null">
#{storeCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.enterprise.entity.TabWmStoreSyncLog">
update tab_wm_store_sync_log
<set>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
<if test="wmMallStoreId != null">
wm_mall_store_id = #{wmMallStoreId,jdbcType=INTEGER},
</if>
<if test="storeId != null">
store_id = #{storeId,jdbcType=INTEGER},
</if>
<if test="type != null">
store_type = #{storeType,jdbcType=INTEGER},
</if>
<if test="storeName != null">
store_name = #{storeName,jdbcType=VARCHAR},
</if>
<if test="storeCode != null">
store_code = #{storeCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.enterprise.entity.TabWmStoreSyncLog">
update tab_wm_store_sync_log
set enterprise_id = #{enterpriseId,jdbcType=INTEGER},
wm_mall_store_id = #{wmMallStoreId,jdbcType=INTEGER},
store_id = #{storeId,jdbcType=INTEGER},
store_type = #{storeType,jdbcType=INTEGER},
store_name = #{storeName,jdbcType=VARCHAR},
store_code = #{storeCode,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="pageWmStoreSyncLog" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from tab_wm_store_sync_log
where status = 1
<if test="type != null">
and store_type = #{type}
</if>
and wm_mall_store_id = #{wmMallStoreId}
<if test="search != null and search != '' ">
and (store_name like concat('%', #{search}, '%') or store_code like concat('%', #{search}, '%') )
</if>
</select>
<select id="getStoreList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from tab_wm_store_sync_log
where status = 1
and wm_mall_store_id = #{wmMallStoreId}
<if test="typeList != null and typeList.size() > 0">
and store_type in
<foreach collection="typeList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -78,12 +78,21 @@ public class WmMallStoreController {
OperationResultUtils.LOG_EDIT + "微盟商城店铺", dto.getWmPidName());
}
/**
* 店铺详情
* @param wmMallStoreId
* @return
*/
@RequestMapping("/get-wm-store-detail")
public RestResponse getDetail(Integer wmMallStoreId) {
return ResultControllerUtils.commonResultOne(wmStoreApiService.getWmStoreByWmMallStoreId(wmMallStoreId),
WmStoreDetailVO.class);
}
/**
* 店铺列表
* @return
*/
@RequestMapping("/list-wm-store")
public RestResponse listWmStore() {
ServiceResponse<List<WmStoreDTO>> listResponse = wmStoreApiService.listWmStore(UserDetailUtils.getUserDetail().getEnterpriseId());
......
......@@ -3,15 +3,40 @@ package com.gic.enterprise.web.controller.wm;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.service.UserApiService;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.constant.MallModeEnum;
import com.gic.enterprise.dto.WmStoreDTO;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.service.WmStoreApiService;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.store.dto.StoreBusinessTimeDTO;
import com.gic.store.dto.StoreDTO;
import com.gic.store.service.StoreApiService;
import com.gic.weimob.api.dto.WeimobPhysicalStoreDTO;
import com.gic.weimob.api.dto.WeimobStoreAccountDTO;
import com.gic.weimob.api.service.WeimobStoreSiteService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
......@@ -26,6 +51,15 @@ import org.springframework.web.bind.annotation.RestController;
public class WmStoreSyncController {
private static final Logger LOGGER = LogManager.getLogger(WmStoreSyncController.class);
@Autowired
private WmStoreApiService wmStoreApiService;
@Autowired
private WeimobStoreSiteService weimobStoreSiteService;
@Autowired
private StoreApiService storeApiService;
@Autowired
private UserApiService userApiService;
/**
*
......@@ -58,4 +92,102 @@ public class WmStoreSyncController {
out.close();
is.close();
}
/**
* 总店-分店同步
* @Title: syncHeadStore

* @Description:

* @author guojuxing
* @param wmMallStoreId 店铺逐渐ID
* @param headStoreId 总店ID
* @param storeIds
 分店IDs
* @return com.gic.commons.webapi.reponse.RestResponse


*/
@RequestMapping("sync-head-store")
public RestResponse syncHeadStore(Integer wmMallStoreId, Integer headStoreId, String storeIds) {
ServiceResponse<WmStoreDTO> wmStoreResponse = wmStoreApiService.getWmStoreByWmMallStoreId(wmMallStoreId);
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
if (wmStoreResponse.isSuccess()) {
WmStoreDTO wmStoreDTO = wmStoreResponse.getResult();
//是否智慧零售模式
Integer mode = wmStoreDTO.getMallMode();
if (mode.intValue() != MallModeEnum.SMART_RETAIL.getCode()) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "非" + MallModeEnum.SMART_RETAIL.getMsg() + "不能同步门店");
}
ServiceResponse<StoreDTO> storeResponse = storeApiService.getStoreById(enterpriseId, headStoreId);
if (!storeResponse.isSuccess()) {
return RestResponse.failure(storeResponse.getCode(), storeResponse.getMessage());
}
StoreDTO storeDTO = storeResponse.getResult();
WeimobPhysicalStoreDTO weimobPhysicalStoreDTO = getWeimobPhsicalStore(storeDTO);
if (weimobPhysicalStoreDTO == null) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "总店不存在或者未启用");
}
//分店
List<WeimobPhysicalStoreDTO> subStoreList = new ArrayList<>();
if (StringUtils.isNotBlank(storeIds)) {
String[] subStoreIdArr = storeIds.split(",");
subStoreList = Stream.of(subStoreIdArr).map(e -> {
ServiceResponse<StoreDTO> storeTempResponse = storeApiService.getStoreById(enterpriseId, headStoreId);
if (storeTempResponse.isSuccess()) {
return getWeimobPhsicalStore(storeTempResponse.getResult());
}
return null;
}).collect(Collectors.toList());
}
ServiceResponse<Void> wmResult = weimobStoreSiteService
.addWeimobVirtualStore(wmMallStoreId, enterpriseId, weimobPhysicalStoreDTO, subStoreList);
if (wmResult.isSuccess()) {
//todo 同步导购
return RestResponse.success();
}
return RestResponse.failure(wmResult.getCode(), wmResult.getMessage());
}
return RestResponse.failure(wmStoreResponse.getCode(), wmStoreResponse.getMessage());
}
private WeimobPhysicalStoreDTO getWeimobPhsicalStore(StoreDTO storeDTO) {
if (storeDTO.getStatus().intValue() == 1) {
WeimobPhysicalStoreDTO weimobPhysicalStoreDTO = new WeimobPhysicalStoreDTO();
weimobPhysicalStoreDTO.setStoreId(storeDTO.getStoreId());
weimobPhysicalStoreDTO.setStoreNumber(storeDTO.getStoreCode());
weimobPhysicalStoreDTO.setStoreName(storeDTO.getStoreName());
//经纬度
if (StringUtils.isNotBlank(storeDTO.getLongitude())) {
weimobPhysicalStoreDTO.setLongitude(new BigDecimal(storeDTO.getLongitude()));
}
if (StringUtils.isNotBlank(storeDTO.getLatitude())) {
weimobPhysicalStoreDTO.setLatitude(new BigDecimal(storeDTO.getLatitude()));
}
//省市区名称
String fullArea = StringUtils.isNotBlank(storeDTO.getProvinces()) ?
storeDTO.getProvinces().replaceAll("//", "") : "";
weimobPhysicalStoreDTO.setAddress(fullArea + storeDTO.getAddress());
StringBuilder businessTime = new StringBuilder();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
List<StoreBusinessTimeDTO> businessTimeList = storeDTO.getBusinessTimeList();
if (CollectionUtils.isNotEmpty(businessTimeList)) {
businessTimeList.stream().map(e -> {
String businessHours = simpleDateFormat.format(e.getOpenTime()) + "-" + simpleDateFormat.format(e.getCloseTime());
return e.getWeekdayShow() + businessHours;
}).forEach(businessTime::append);
}
weimobPhysicalStoreDTO.setBussinessHours(businessTime.toString());
WeimobStoreAccountDTO accountDTO = new WeimobStoreAccountDTO();
ServiceResponse<UserDTO> userResponse = userApiService.getUserByEnterpriseId(storeDTO.getEnterpriseId());
if (userResponse.isSuccess()) {
UserDTO userDTO = userResponse.getResult();
}
if (StringUtils.isNotBlank(storeDTO.getConactsPhone())) {
weimobPhysicalStoreDTO.setStoreTel(storeDTO.getConactsPhone());
} else {
//
}
weimobPhysicalStoreDTO.setAccountVo(accountDTO);
return weimobPhysicalStoreDTO;
}
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment