Commit 64dce82a by 陶光胜

观云台小程序

parent f567309b
package com.gic.cloud.dto;
import java.io.Serializable;
import java.util.Date;
/**
* tab_attention_store
*/
public class AttentionStoreDTO implements Serializable {
/**
*
*/
private Integer attentionId;
/**
*
*/
private Integer storeId;
/**
*
*/
private Integer userId;
/**
*
*/
private Integer enterpriseId;
/**
*
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getAttentionId() {
return attentionId;
}
public void setAttentionId(Integer attentionId) {
this.attentionId = attentionId;
}
public Integer getStoreId() {
return storeId;
}
public void setStoreId(Integer storeId) {
this.storeId = storeId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.cloud.dto;
public class TestDTO {
}
package com.gic.cloud.service;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.dto.AttentionStoreDTO;
public interface StoreAttentionApiService {
ServiceResponse addStoreAttenttion(Integer userId, Integer enterpriseId, Integer storeId);
ServiceResponse removeStoreAttenttion(Integer attentionId);
ServiceResponse<Page<AttentionStoreDTO>> pageStoreAttention(Integer userId, Integer enterpriseId, Integer pageNum, Integer pageSize);
}
package com.gic.cloud.dao.mapper;
import com.gic.cloud.entity.TabAttentionStore;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
public interface TabAttentionStoreMapper {
/**
* 根据主键删除
*
* @param attentionId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer attentionId);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabAttentionStore record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabAttentionStore record);
/**
* 根据主键查询
*
* @param attentionId 主键
* @return 实体对象
*/
TabAttentionStore selectByPrimaryKey(Integer attentionId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabAttentionStore record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabAttentionStore record);
Page<TabAttentionStore> pageStoreAttention(@Param("userId") Integer userId, @Param("enterpriseId") Integer enterpriseId);
}
\ No newline at end of file
package com.gic.cloud.dao.mapper;
public class TestMapper {
}
package com.gic.cloud.entity;
import java.util.Date;
/**
* tab_attention_store
*/
public class TabAttentionStore {
/**
*
*/
private Integer attentionId;
/**
*
*/
private Integer storeId;
/**
*
*/
private Integer userId;
/**
*
*/
private Integer enterpriseId;
/**
*
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getAttentionId() {
return attentionId;
}
public void setAttentionId(Integer attentionId) {
this.attentionId = attentionId;
}
public Integer getStoreId() {
return storeId;
}
public void setStoreId(Integer storeId) {
this.storeId = storeId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.cloud.service;
import com.gic.cloud.entity.TabAttentionStore;
import com.github.pagehelper.Page;
public interface StoreAttenttionService {
int addStoreAttenttion(TabAttentionStore tabAttentionStore);
int removeStoreAttenttion(Integer attentionId);
Page<TabAttentionStore> pageStoreAttention(Integer userId, Integer enterpriseId);
}
package com.gic.cloud.service.impl;
import com.gic.cloud.dao.mapper.TabAttentionStoreMapper;
import com.gic.cloud.entity.TabAttentionStore;
import com.gic.cloud.service.StoreAttenttionService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service("storeAttenttionService")
public class StoreAttentionServiceImpl implements StoreAttenttionService {
@Autowired
private TabAttentionStoreMapper tabAttentionStoreMapper;
@Override
public int addStoreAttenttion(TabAttentionStore tabAttentionStore) {
tabAttentionStore.setCreateTime(new Date());
tabAttentionStore.setUpdateTime(new Date());
tabAttentionStore.setStatus(1);
int i = this.tabAttentionStoreMapper.insertSelective(tabAttentionStore);
return i;
}
@Override
public int removeStoreAttenttion(Integer attentionId) {
TabAttentionStore tabAttentionStore = this.tabAttentionStoreMapper.selectByPrimaryKey(attentionId);
tabAttentionStore.setStatus(0);
int i = this.tabAttentionStoreMapper.updateByPrimaryKey(tabAttentionStore);
return i;
}
@Override
public Page<TabAttentionStore> pageStoreAttention(Integer userId, Integer enterpriseId) {
return this.tabAttentionStoreMapper.pageStoreAttention(userId, enterpriseId);
}
}
package com.gic.cloud.service.outer.impl;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.dto.AttentionStoreDTO;
import com.gic.cloud.entity.TabAttentionStore;
import com.gic.cloud.service.StoreAttentionApiService;
import com.gic.cloud.service.StoreAttenttionService;
import com.gic.commons.util.PageHelperUtils;
import com.github.pagehelper.PageHelper;
import com.google.inject.internal.asm.$AnnotationVisitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("storeAttentionApiService")
public class StoreAttentionApiServiceImpl implements StoreAttentionApiService {
@Autowired
private StoreAttenttionService storeAttenttionService;
@Override
public ServiceResponse addStoreAttenttion(Integer userId, Integer enterpriseId, Integer storeId) {
TabAttentionStore store = new TabAttentionStore();
store.setUserId(userId);
store.setEnterpriseId(enterpriseId);
store.setStoreId(storeId);
this.storeAttenttionService.addStoreAttenttion(store);
return ServiceResponse.success();
}
@Override
public ServiceResponse removeStoreAttenttion(Integer attentionId) {
this.storeAttenttionService.removeStoreAttenttion(attentionId);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Page<AttentionStoreDTO>> pageStoreAttention(Integer userId, Integer enterpriseId, Integer pageNum, Integer pageSize) {
PageHelper.startPage(pageNum, pageSize);
com.github.pagehelper.Page<TabAttentionStore> storePage = this.storeAttenttionService.pageStoreAttention(userId, enterpriseId);
return ServiceResponse.success(PageHelperUtils.changePageHelperToCurrentPage(storePage, AttentionStoreDTO.class));
}
}
...@@ -25,4 +25,5 @@ ...@@ -25,4 +25,5 @@
<dubbo:service interface="com.gic.cloud.service.IndexLogApiService" ref="indexLogApiService" timeout="6000" /> <dubbo:service interface="com.gic.cloud.service.IndexLogApiService" ref="indexLogApiService" timeout="6000" />
<dubbo:service interface="com.gic.cloud.service.TempStoreConditionApiService" ref="tempStoreConditionApiService" timeout="6000" /> <dubbo:service interface="com.gic.cloud.service.TempStoreConditionApiService" ref="tempStoreConditionApiService" timeout="6000" />
<dubbo:service interface="com.gic.cloud.service.IndexGroupApiService" ref="indexGroupApiService" timeout="6000" /> <dubbo:service interface="com.gic.cloud.service.IndexGroupApiService" ref="indexGroupApiService" timeout="6000" />
<dubbo:service interface="com.gic.cloud.service.StoreAttentionApiService" ref="storeAttentionApiService" timeout="6000" />
</beans> </beans>
<?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.cloud.dao.mapper.TabAttentionStoreMapper">
<resultMap id="BaseResultMap" type="com.gic.cloud.entity.TabAttentionStore">
<id column="attention_id" jdbcType="INTEGER" property="attentionId" />
<result column="store_id" jdbcType="INTEGER" property="storeId" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<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">
attention_id, store_id, user_id, enterprise_id, status, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_attention_store
where attention_id = #{attentionId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_attention_store
where attention_id = #{attentionId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.cloud.entity.TabAttentionStore">
insert into tab_attention_store (attention_id, store_id, user_id,
enterprise_id, status, create_time,
update_time)
values (#{attentionId,jdbcType=INTEGER}, #{storeId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER},
#{enterpriseId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.cloud.entity.TabAttentionStore">
insert into tab_attention_store
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="attentionId != null">
attention_id,
</if>
<if test="storeId != null">
store_id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="enterpriseId != null">
enterprise_id,
</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="attentionId != null">
#{attentionId,jdbcType=INTEGER},
</if>
<if test="storeId != null">
#{storeId,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=INTEGER},
</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.cloud.entity.TabAttentionStore">
update tab_attention_store
<set>
<if test="storeId != null">
store_id = #{storeId,jdbcType=INTEGER},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</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 attention_id = #{attentionId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.cloud.entity.TabAttentionStore">
update tab_attention_store
set store_id = #{storeId,jdbcType=INTEGER},
user_id = #{userId,jdbcType=INTEGER},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where attention_id = #{attentionId,jdbcType=INTEGER}
</update>
<select id="pageStoreAttention" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_attention_store
where status = 1 and user_id = #{userId} and enterprise_id = #{enterpriseId} order by create_time desc
</select>
</mapper>
\ No newline at end of file
package com.gic.cloud.web.auth; package com.gic.cloud.web.auth;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.dto.DataAuthDTO; import com.gic.cloud.dto.DataAuthDTO;
import com.gic.cloud.service.DataAuthApiService; import com.gic.cloud.service.DataAuthApiService;
import com.gic.store.service.StoreWidgetApiService;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component @Component
public class DataAuthUtils { public class DataAuthUtils {
private static final Logger log = LogManager.getLogger(DataAuthUtils.class); private static final Logger log = LogManager.getLogger(DataAuthUtils.class);
@Autowired @Autowired
private DataAuthApiService dataAuthApiService; private DataAuthApiService dataAuthApiService;
@Autowired
private StoreWidgetApiService storeWidgetApiService;
public void getUserAuth(Integer userId, Integer enterpriseId){ public StoreAuth getStoreAuth(Integer userId, Integer enterpriseId){
ServiceResponse<DataAuthDTO> response = this.dataAuthApiService.ggetDataAuthByUserId(enterpriseId, userId); ServiceResponse<DataAuthDTO> response = this.dataAuthApiService.ggetDataAuthByUserId(enterpriseId, userId);
StoreAuth storeAuth = new StoreAuth();
if(response.isSuccess()){ if(response.isSuccess()){
storeAuth.setHasAuth(true);
DataAuthDTO dataAuthDTO = response.getResult(); DataAuthDTO dataAuthDTO = response.getResult();
Integer storeWidgetId = dataAuthDTO.getStoreWidgetId();
if(storeWidgetId != null){
List<Integer> storeInfoIdList = this.storeWidgetApiService.listStoreInfoIdByStoreWidgetId(enterpriseId, storeWidgetId).getResult();
storeAuth.setStoreInfoIdList(storeInfoIdList);
storeAuth.setStoreWidgetId(storeWidgetId);
}else {
storeAuth.setStoreInfoIdList(new ArrayList<>());
}
} }
return storeAuth;
} }
public OnLineAuth getOnlineStore(Integer userId, Integer enterpriseId){
ServiceResponse<DataAuthDTO> response = this.dataAuthApiService.ggetDataAuthByUserId(enterpriseId, userId);
OnLineAuth onLineAuth = new OnLineAuth();
if(response.isSuccess()){
DataAuthDTO dataAuthDTO = response.getResult();
String onlinePerformance = dataAuthDTO.getOnlinePerformance();
if(StringUtils.isNotBlank(onlinePerformance)){
onLineAuth.setHasAuth(true);
JSONArray array = JSON.parseArray(onlinePerformance);
List<OnLineStore> list = new ArrayList<>();
for(int i=0; i<array.size(); i++){
JSONObject jsonObject = array.getJSONObject(i);
OnLineStore onLineStore = new OnLineStore();
onLineStore.setChannel(jsonObject.getInteger("channel"));
onLineStore.setStoreIdList(JSONArray.parseArray(jsonObject.getJSONArray("storeContent").toJSONString(), String.class));
list.add(onLineStore);
}
onLineAuth.setList(list);
}
}
return onLineAuth;
}
} }
package com.gic.cloud.web.auth;
import java.util.List;
public class OnLineAuth {
private boolean hasAuth = false;
private List<OnLineStore> list ;
public boolean isHasAuth() {
return hasAuth;
}
public void setHasAuth(boolean hasAuth) {
this.hasAuth = hasAuth;
}
public List<OnLineStore> getList() {
return list;
}
public void setList(List<OnLineStore> list) {
this.list = list;
}
}
package com.gic.cloud.web.auth;
import java.util.List;
public class OnLineStore {
private Integer channel;
private List<String> storeIdList;
public Integer getChannel() {
return channel;
}
public void setChannel(Integer channel) {
this.channel = channel;
}
public List<String> getStoreIdList() {
return storeIdList;
}
public void setStoreIdList(List<String> storeIdList) {
this.storeIdList = storeIdList;
}
}
package com.gic.cloud.web.auth;
import java.util.List;
public class StoreAuth {
private boolean hasAuth = false;
private List<Integer> storeInfoIdList;
private Integer storeWidgetId;
public boolean isHasAuth() {
return hasAuth;
}
public void setHasAuth(boolean hasAuth) {
this.hasAuth = hasAuth;
}
public List<Integer> getStoreInfoIdList() {
return storeInfoIdList;
}
public void setStoreInfoIdList(List<Integer> storeInfoIdList) {
this.storeInfoIdList = storeInfoIdList;
}
public Integer getStoreWidgetId() {
return storeWidgetId;
}
public void setStoreWidgetId(Integer storeWidgetId) {
this.storeWidgetId = storeWidgetId;
}
}
package com.gic.cloud.web.constant;
public enum StoreChannelEnum {
OFFLINE(1, "线下"),
GICMALL(2, "达摩微商城"),
WMMALL(3, "微盟微商城"),
TIANMAO(4, "天猫");
private Integer channel;
private String message;
StoreChannelEnum(Integer channel, String message){
this.channel = channel;
this.message = message;
}
public Integer getChannel() {
return channel;
}
public void setChannel(Integer channel) {
this.channel = channel;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package com.gic.cloud.web.controller; package com.gic.cloud.web.controller;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.dto.AttentionStoreDTO;
import com.gic.cloud.service.StoreAttentionApiService;
import com.gic.cloud.web.vo.StoreAttenttionVo;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.store.dto.StoreDTO;
import com.gic.store.service.StoreApiService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController @RestController
public class StoreAttentionController { public class StoreAttentionController {
@Autowired
private StoreAttentionApiService storeAttentionApiService;
@Autowired
private StoreApiService storeApiService;
@RequestMapping("add-attention")
public RestResponse addAttenttion(Integer userId, Integer enterpriseId, Integer storeId){
ServiceResponse serviceResponse = this.storeAttentionApiService.addStoreAttenttion(userId, enterpriseId, storeId);
return RestResponse.success();
}
@RequestMapping("remove-attention")
public RestResponse removeAttentiton(Integer attentionId){
this.storeAttentionApiService.removeStoreAttenttion(attentionId);
return RestResponse.success();
}
@RequestMapping("attention-list")
public RestResponse attenttionList(Integer userId, Integer enterpriseId, Integer pageNum, Integer pageSize){
ServiceResponse<Page<AttentionStoreDTO>> response = this.storeAttentionApiService.pageStoreAttention(userId, enterpriseId, pageNum, pageSize);
Page<AttentionStoreDTO> result = response.getResult();
List<StoreAttenttionVo> list = new ArrayList<>();
Page<StoreAttenttionVo> page = new Page<>(pageNum, pageSize);
if(CollectionUtils.isNotEmpty(result.getResult())){
for(AttentionStoreDTO storeDTO : result.getResult()){
StoreAttenttionVo storeAttenttionVo = new StoreAttenttionVo();
storeAttenttionVo.setStoreId(storeDTO.getStoreId());
storeAttenttionVo.setStoreAttentionId(storeDTO.getAttentionId());
StoreDTO store = this.storeApiService.getStoreByStoreInfoId(enterpriseId, storeDTO.getStoreId()).getResult();
if(store != null){
storeAttenttionVo.setStoreName(store.getStoreName());
list.add(storeAttenttionVo);
}
}
}
page.setResult(list);
page.setTotalPage(result.getTotalPage());
page.setTotalCount(result.getTotalCount());
return RestResponse.success(page);
}
} }
package com.gic.cloud.web.controller; package com.gic.cloud.web.controller;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.web.auth.DataAuthUtils;
import com.gic.cloud.web.auth.OnLineAuth;
import com.gic.cloud.web.auth.OnLineStore;
import com.gic.cloud.web.auth.StoreAuth;
import com.gic.cloud.web.constant.StoreChannelEnum;
import com.gic.cloud.web.vo.*;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.dto.WmStoreDTO;
import com.gic.enterprise.service.WmStoreApiService;
import com.gic.mall.share.api.dto.shop.ShopDTO;
import com.gic.mall.share.api.enums.ShopTypeEnum;
import com.gic.mall.share.api.service.ShopApiService;
import com.gic.store.dto.*;
import com.gic.store.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@RestController @RestController
public class StoreWidgetController { public class StoreWidgetController {
private static final Logger log = LogManager.getLogger(StoreWidgetController.class);
@Autowired
private DataAuthUtils dataAuthUtils;
@Autowired
private StoreWidgetApiService storeWidgetApiService;
@Autowired
private StoreGroupApiService storeGroupApiService;
@Autowired
private StoreApiService storeApiService;
@Autowired
private StoreDictApiService storeDictApiService;
@Autowired
private StoreRegionApiService storeRegionApiService;
@Autowired
private StoreTagApiService storeTagApiService;
@Autowired
private ShopApiService shopApiService;
@Autowired
private WmStoreApiService wmStoreApiService;
@RequestMapping("store-widget-index") @RequestMapping("store-widget-index")
public RestResponse storeWidgetIndex(Integer userId, Integer enterpriseId){ public RestResponse storeWidgetIndex(Integer userId, Integer enterpriseId){
return null; StoreWidgetIndexVo vo = new StoreWidgetIndexVo();
StoreAuth storeAuth = dataAuthUtils.getStoreAuth(userId, enterpriseId);
OnLineAuth onlineStoreAuth = dataAuthUtils.getOnlineStore(userId, enterpriseId);
List<IndexItemVo> items = new ArrayList<>();
if(storeAuth.isHasAuth() && onlineStoreAuth.isHasAuth()){ //线上线下多渠道
IndexItemVo offLine = new IndexItemVo();
offLine.setId("1");
offLine.setName("线下零售");
offLine.setType(1);
items.add(offLine);
this.getOnlineItems(onlineStoreAuth, items);
vo.setType(1);
} else if(storeAuth.isHasAuth() && !onlineStoreAuth.isHasAuth()){ //线下单渠道
vo.setType(2);
} else if(onlineStoreAuth.getList().size() == 1){ //线上单渠道
vo.setType(3);
List<OnLineStore> list = onlineStoreAuth.getList();
OnLineStore onLineStore = list.get(0);
List<OnLineStoreVo> onLineStoreVos = this.listOnLineStore(onLineStore.getStoreIdList(), onLineStore.getChannel(), enterpriseId);
if(CollectionUtils.isNotEmpty(onLineStoreVos)){
for(OnLineStoreVo onLineStoreVo : onLineStoreVos){
IndexItemVo indexItemVo = new IndexItemVo();
indexItemVo.setId(onLineStoreVo.getOnStoreId());
indexItemVo.setName(onLineStoreVo.getOnStoreName());
indexItemVo.setType(2);
items.add(indexItemVo);
}
}
} else { //线上多渠道
vo.setType(1);
this.getOnlineItems(onlineStoreAuth, items);
}
vo.setItems(items);
return RestResponse.success(vo);
}
@RequestMapping("store-group")
public RestResponse storeGroup(Integer userId, Integer enterpriseId, Integer parentId,
Integer pageNum, Integer pageSize){
StoreAuth storeAuth = dataAuthUtils.getStoreAuth(userId, enterpriseId);
List<Integer> storeGroupIdList = new ArrayList<>();
if(storeAuth.getStoreWidgetId() != null) {
StoreColumnSet storeColumnSet = this.storeWidgetApiService.getStoreColumnSet(enterpriseId, storeAuth.getStoreWidgetId()).getResult();
Set<Integer> storeGroupId = storeColumnSet.getStoreGroupId();
storeGroupIdList = new ArrayList<>(storeGroupId);
}
Page<StoreGroupDTO> page = this.storeGroupApiService.pageStoreGroupByIds(storeGroupIdList, enterpriseId, parentId, null, pageSize, pageNum).getResult();
StoreGroupVo vo = new StoreGroupVo();
List<StoreGroupItemsVo> items = new ArrayList<>();
if(CollectionUtils.isNotEmpty(page.getResult())){
for(StoreGroupDTO storeGroupDTO : page.getResult()){
StoreGroupItemsVo itemsVo = new StoreGroupItemsVo();
itemsVo.setId(storeGroupDTO.getStoreGroupId());
itemsVo.setName(storeGroupDTO.getStoreGroupName());
List<StoreGroupDTO> result = this.storeGroupApiService.pageStoreGroupByIds(storeGroupIdList, enterpriseId, parentId,null, pageSize, pageNum).getResult().getResult();
itemsVo.setHasChildren(CollectionUtils.isEmpty(result) ? 0 : 1);
items.add(itemsVo);
}
}else {
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseId(enterpriseId);
storeSearchDTO.setStoreGroupId(parentId);
storeSearchDTO.setStoreResource(Long.valueOf(storeAuth.getStoreWidgetId()));
ServiceResponse<Page<StoreDTO>> response = this.storeApiService.listStore(storeSearchDTO, pageNum, pageSize);
if(CollectionUtils.isNotEmpty(response.getResult().getResult())){
for(StoreDTO dto : response.getResult().getResult()){
StoreGroupItemsVo itemsVo = new StoreGroupItemsVo();
itemsVo.setId(dto.getStoreInfoId());
itemsVo.setName(dto.getStoreName());
itemsVo.setIsStore(1);
items.add(itemsVo);
}
}
}
vo.setItems(items);
return RestResponse.success(vo);
} }
@RequestMapping("store-type")
public RestResponse storeType(Integer userId, Integer enterpriseId, Integer type){
StoreAuth storeAuth = dataAuthUtils.getStoreAuth(userId, enterpriseId);
StoreColumnSet storeColumnSet = null;
if(storeAuth.getStoreWidgetId() != null){
storeColumnSet = this.storeWidgetApiService.getStoreColumnSet(enterpriseId, storeAuth.getStoreWidgetId()).getResult();
}
if(type == 1){ //门店类型
if(storeColumnSet != null){
Set<Integer> storeType = storeColumnSet.getStoreType();
if(CollectionUtils.isEmpty(storeType)){
return RestResponse.success();
}else {
List<StoreTypeVo> storeTypeVos = this.listStoreTypeOrStatus(enterpriseId, new ArrayList<>(storeType), 1);
return RestResponse.success(storeTypeVos);
}
}else {
List<StoreTypeVo> storeTypeVos = this.listStoreTypeOrStatus(enterpriseId, null, 1);
return RestResponse.success(storeTypeVos);
}
} else if(type == 2){ //门店状态
if(storeColumnSet != null){
Set<Integer> storeType = storeColumnSet.getErpStatus();
if(CollectionUtils.isEmpty(storeType)){
return RestResponse.success();
}else {
List<StoreTypeVo> storeTypeVos = this.listStoreTypeOrStatus(enterpriseId, new ArrayList<>(storeType), 2);
return RestResponse.success(storeTypeVos);
}
}else {
List<StoreTypeVo> storeTypeVos = this.listStoreTypeOrStatus(enterpriseId, null, 2);
return RestResponse.success(storeTypeVos);
}
} else if(type == 3){ //门店域
if(storeColumnSet != null){
Set<Integer> region = storeColumnSet.getRegion();
if(CollectionUtils.isEmpty(region)){
return RestResponse.success();
}else {
List<StoreTypeVo> storeTypeVos = this.listRegion(enterpriseId, new ArrayList<>(region));
return RestResponse.success(storeTypeVos);
}
}else {
List<StoreTypeVo> storeTypeVos = this.listRegion(enterpriseId, null);
return RestResponse.success(storeTypeVos);
}
}else { //门店标签
List<StoreTagDTO> result = this.storeTagApiService.listByEnterprise(enterpriseId).getResult();
List<StoreTypeVo> list = new ArrayList<>();
if(CollectionUtils.isNotEmpty(result)){
for(StoreTagDTO storeTagDTO : result){
StoreTypeVo storeTypeVo = new StoreTypeVo();
storeTypeVo.setId(storeTagDTO.getStoreTagId()+"");
storeTypeVo.setName(storeTagDTO.getStoreTagName());
list.add(storeTypeVo);
}
}
return RestResponse.success(list);
}
}
@RequestMapping("on-store-list")
public RestResponse onStoreList(Integer userId, Integer enterrpiseId, Integer type){
OnLineAuth onlineStore = this.dataAuthUtils.getOnlineStore(userId, enterrpiseId);
if(onlineStore.isHasAuth()){
List<OnLineStore> list = onlineStore.getList();
for(OnLineStore store : list){
if(type == store.getChannel()){
List<OnLineStoreVo> onLineStoreVos = this.listOnLineStore(store.getStoreIdList(), type, enterrpiseId);
return RestResponse.success(onLineStoreVos);
}
}
}
return RestResponse.success();
}
@RequestMapping("store-search")
public RestResponse storeSearch(Integer userId, Integer enterpriseId, Integer type, String search,
Integer pageNum, Integer pageSize){
Page<StoreSearchVo> page = new Page<>(pageNum, pageSize);
if(type == 1){ //门店分组
Page<StoreGroupDTO> result = this.storeGroupApiService.pageStoreGroupByIds(null, enterpriseId, null, search, pageSize, pageNum).getResult();
page.setTotalPage(result.getTotalPage());
page.setTotalCount(result.getTotalCount());
if(CollectionUtils.isNotEmpty(result.getResult())){
List<StoreSearchVo> storeSearchVoList = new ArrayList<>();
for(StoreGroupDTO storeGroupDTO : result.getResult()){
StoreSearchVo searchVo = new StoreSearchVo();
searchVo.setId(storeGroupDTO.getStoreGroupId());
searchVo.setName(storeGroupDTO.getStoreGroupName());
storeSearchVoList.add(searchVo);
}
page.setResult(storeSearchVoList);
}
}else if(type == 2){ //线下门店
StoreAuth storeAuth = this.dataAuthUtils.getStoreAuth(userId, enterpriseId);
if(storeAuth.isHasAuth()){
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseId(enterpriseId);
storeSearchDTO.setStoreInfoIds(StringUtils.join(storeAuth.getStoreInfoIdList(), ","));
Page<StoreDTO> result = this.storeApiService.listStore(storeSearchDTO, pageNum, pageSize).getResult();
page.setTotalCount(result.getTotalCount());
page.setTotalPage(result.getTotalPage());
if(CollectionUtils.isNotEmpty(result.getResult())){
List<StoreSearchVo> storeSearchVoList = new ArrayList<>();
for(StoreDTO storeDTO : result.getResult()){
StoreSearchVo searchVo = new StoreSearchVo();
searchVo.setId(storeDTO.getStoreInfoId());
searchVo.setName(storeDTO.getStoreName());
storeSearchVoList.add(searchVo);
}
page.setResult(storeSearchVoList);
}
}
}else{ //线上店铺
List<StoreSearchVo> list = new ArrayList<>();
List<ShopDTO> result = shopApiService.getAllShopByEnterpriseIdAndName(enterpriseId, search, ShopTypeEnum.MALL_SHOP.getCode()).getResult();
if(CollectionUtils.isNotEmpty(result)){
for(ShopDTO dto : result){
StoreSearchVo storeSearchVo = new StoreSearchVo();
storeSearchVo.setId(dto.getId().intValue());
storeSearchVo.setName(dto.getName());
storeSearchVo.setDesc(StoreChannelEnum.GICMALL.getMessage());
list.add(storeSearchVo);
}
}
List<WmStoreDTO> result1 = wmStoreApiService.listWmStore(enterpriseId, search).getResult();
if(CollectionUtils.isNotEmpty(result1)){
for(WmStoreDTO wmStoreDTO : result1){
StoreSearchVo storeSearchVo = new StoreSearchVo();
storeSearchVo.setId(Integer.valueOf(wmStoreDTO.getWmStoreId()));
storeSearchVo.setName(wmStoreDTO.getWmMainAccount());
storeSearchVo.setDesc(StoreChannelEnum.WMMALL.getMessage());
list.add(storeSearchVo);
}
}
page.setResult(list);
page.setTotalCount(list.size());
page.setTotalPage(1);
}
return RestResponse.success(page);
}
private List<OnLineStoreVo> listOnLineStore(List<String> storeIdList, Integer type, Integer enterpriseId){
List<OnLineStoreVo> list = new ArrayList<>();
if(type == StoreChannelEnum.GICMALL.getChannel()){
List<ShopDTO> result = shopApiService.getAllShopByEnterpriseIdAndName(enterpriseId, null, ShopTypeEnum.MALL_SHOP.getCode()).getResult();
if(CollectionUtils.isNotEmpty(result)){
for(ShopDTO dto : result){
if(storeIdList.contains(dto.getId())){
OnLineStoreVo onLineStoreVo = new OnLineStoreVo();
onLineStoreVo.setOnStoreId(dto.getId()+"");
onLineStoreVo.setOnStoreName(dto.getName());
list.add(onLineStoreVo);
}
}
}
}else if(type == StoreChannelEnum.WMMALL.getChannel()){
List<WmStoreDTO> result = wmStoreApiService.listWmStore(enterpriseId).getResult();
if(CollectionUtils.isNotEmpty(result)){
for(WmStoreDTO wmStoreDTO : result){
if(storeIdList.contains(wmStoreDTO.getWmStoreId())){
OnLineStoreVo onLineStoreVo = new OnLineStoreVo();
onLineStoreVo.setOnStoreId(wmStoreDTO.getWmStoreId()+"");
onLineStoreVo.setOnStoreName(wmStoreDTO.getWmMainAccount());
list.add(onLineStoreVo);
}
}
}
}
return list;
}
private List<StoreTypeVo> listRegion(Integer enterpriseId, List<Integer> exists){
List<StoreTypeVo> list = new ArrayList<>();
List<StoreRegionDTO> result = this.storeRegionApiService.listStoreRegion(enterpriseId, null).getResult();
for(StoreRegionDTO dto : result){
StoreTypeVo storeTypeVo = new StoreTypeVo();
if(CollectionUtils.isNotEmpty(exists)){
if(exists.contains(dto.getRegionId())){
storeTypeVo.setId(dto.getRegionId()+"");
storeTypeVo.setName(dto.getRegionName());
list.add(storeTypeVo);
}
}else {
storeTypeVo.setId(dto.getRegionId()+"");
storeTypeVo.setName(dto.getRegionName());
list.add(storeTypeVo);
}
}
return list;
}
private List<StoreTypeVo> listStoreTypeOrStatus(Integer enterpriseId, List<Integer> exists, int type){
List<StoreDictDTO> result = null;
if(type == 1){
result = this.storeDictApiService.listStoreType(enterpriseId).getResult();
}else {
result = this.storeDictApiService.listStoreStatus(enterpriseId).getResult();
}
List<StoreTypeVo> list = new ArrayList<>();
for(StoreDictDTO dictDTO : result){
StoreTypeVo storeTypeVo = new StoreTypeVo();
if(CollectionUtils.isNotEmpty(exists)){
if(exists.contains(dictDTO.getValue())){
storeTypeVo.setId(dictDTO.getValue());
storeTypeVo.setName(dictDTO.getKey());
list.add(storeTypeVo);
}
}else {
storeTypeVo.setId(dictDTO.getValue());
storeTypeVo.setName(dictDTO.getKey());
list.add(storeTypeVo);
}
}
return list;
}
private String getChannelName(Integer channel){
StoreChannelEnum[] values = StoreChannelEnum.values();
for(StoreChannelEnum storeChannelEnum : values){
if(channel == storeChannelEnum.getChannel()){
return storeChannelEnum.getMessage();
}
}
return "";
}
private void getOnlineItems(OnLineAuth onlineStoreAuth, List<IndexItemVo> items){
for(OnLineStore onLineStore : onlineStoreAuth.getList()){
IndexItemVo onLine = new IndexItemVo();
onLine.setId(onLineStore.getChannel()+"");
onLine.setName(this.getChannelName(onLineStore.getChannel()));
onLine.setType(2);
items.add(onLine);
}
}
} }
...@@ -5,6 +5,7 @@ import java.io.Serializable; ...@@ -5,6 +5,7 @@ import java.io.Serializable;
public class IndexItemVo implements Serializable { public class IndexItemVo implements Serializable {
private String id; private String id;
private String name; private String name;
private Integer type;
public String getId() { public String getId() {
return id; return id;
...@@ -21,4 +22,12 @@ public class IndexItemVo implements Serializable { ...@@ -21,4 +22,12 @@ public class IndexItemVo implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
} }
package com.gic.cloud.web.vo;
public class OnLineStoreVo {
private String onStoreId;
private String onStoreName;
public String getOnStoreId() {
return onStoreId;
}
public void setOnStoreId(String onStoreId) {
this.onStoreId = onStoreId;
}
public String getOnStoreName() {
return onStoreName;
}
public void setOnStoreName(String onStoreName) {
this.onStoreName = onStoreName;
}
}
package com.gic.cloud.web.vo;
public class StoreAttenttionVo {
private Integer storeId;
private String storeName;
private Integer storeAttentionId;
public Integer getStoreId() {
return storeId;
}
public void setStoreId(Integer storeId) {
this.storeId = storeId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public Integer getStoreAttentionId() {
return storeAttentionId;
}
public void setStoreAttentionId(Integer storeAttentionId) {
this.storeAttentionId = storeAttentionId;
}
}
package com.gic.cloud.web.vo;
public class StoreGroupItemsVo {
private Integer id;
private String name;
private Integer isStore = 0;
private Integer hasChildren = 0;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getIsStore() {
return isStore;
}
public void setIsStore(Integer isStore) {
this.isStore = isStore;
}
public Integer getHasChildren() {
return hasChildren;
}
public void setHasChildren(Integer hasChildren) {
this.hasChildren = hasChildren;
}
}
package com.gic.cloud.web.vo;
import java.util.List;
public class StoreGroupVo {
private List<StoreGroupItemsVo> items;
public List<StoreGroupItemsVo> getItems() {
return items;
}
public void setItems(List<StoreGroupItemsVo> items) {
this.items = items;
}
}
package com.gic.cloud.web.vo;
public class StoreSearchVo {
private Integer id;
private String name;
private String desc;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package com.gic.cloud.web.vo;
public class StoreTypeVo {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
...@@ -6,7 +6,8 @@ public class StoreWidgetIndexVo { ...@@ -6,7 +6,8 @@ public class StoreWidgetIndexVo {
/****1多渠道首页 2单渠道线下首页 3单渠道线上首页****/ /****1多渠道首页 2单渠道线下首页 3单渠道线上首页****/
private Integer type; private Integer type;
private List<IndexItemVo> items; private List<IndexItemVo> items;
private Integer attentionCount; private Integer attentionCount = 0;
private Integer singleRegion = 0;
public Integer getType() { public Integer getType() {
return type; return type;
...@@ -31,4 +32,12 @@ public class StoreWidgetIndexVo { ...@@ -31,4 +32,12 @@ public class StoreWidgetIndexVo {
public void setItems(List<IndexItemVo> items) { public void setItems(List<IndexItemVo> items) {
this.items = items; this.items = items;
} }
public Integer getSingleRegion() {
return singleRegion;
}
public void setSingleRegion(Integer singleRegion) {
this.singleRegion = singleRegion;
}
} }
package com.gic.cloud.web.vo;
public class StoreWidgetItemVo {
private String id;
private String name;
private Integer type;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
}
...@@ -140,4 +140,6 @@ ...@@ -140,4 +140,6 @@
<dubbo:reference interface="com.gic.cloud.service.DataAuthApiService" id="dataAuthApiService" timeout="6000" retries="0"/> <dubbo:reference interface="com.gic.cloud.service.DataAuthApiService" id="dataAuthApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.cloud.service.UserApiService" id="userApiService" timeout="6000" retries="0"/> <dubbo:reference interface="com.gic.cloud.service.UserApiService" id="userApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.marketing.process.api.service.sms.SmsSendApiService" id="smsSendApiService" timeout="6000" retries="0"/> <dubbo:reference interface="com.gic.marketing.process.api.service.sms.SmsSendApiService" id="smsSendApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.store.service.StoreTagApiService" id="storeTagApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.cloud.service.StoreAttentionApiService" id="storeAttentionApiService" timeout="6000" retries="0"/>
</beans> </beans>
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