Commit 3ab2df47 by zhiwj

添加region的fromEnterpriseId

parent f528f59f
......@@ -45,7 +45,10 @@ public class StoreRegionDTO implements Serializable {
*/
private Integer enterpriseId;
private Integer fromEnterpriseId;
private Integer ownType;
private String shareEnterpriseName;
public Integer getRegionId() {
return regionId;
......@@ -103,6 +106,14 @@ public class StoreRegionDTO implements Serializable {
this.enterpriseId = enterpriseId;
}
public Integer getFromEnterpriseId() {
return fromEnterpriseId;
}
public void setFromEnterpriseId(Integer fromEnterpriseId) {
this.fromEnterpriseId = fromEnterpriseId;
}
public Integer getOwnType() {
return ownType;
}
......@@ -110,4 +121,12 @@ public class StoreRegionDTO implements Serializable {
public void setOwnType(Integer ownType) {
this.ownType = ownType;
}
public void setShareEnterpriseName(String shareEnterpriseName) {
this.shareEnterpriseName = shareEnterpriseName;
}
public String getShareEnterpriseName() {
return shareEnterpriseName;
}
}
......@@ -19,6 +19,11 @@ public class TabStoreRegionRel {
/**
*
*/
private Integer fromEnterpriseId;
/**
*
*/
private Integer enterpriseId;
/**
......@@ -57,6 +62,14 @@ public class TabStoreRegionRel {
this.regionId = regionId;
}
public Integer getFromEnterpriseId() {
return fromEnterpriseId;
}
public void setFromEnterpriseId(Integer fromEnterpriseId) {
this.fromEnterpriseId = fromEnterpriseId;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
......
......@@ -13,7 +13,7 @@ import java.util.List;
public interface StoreRegionRelService {
Integer saveByOwner(Integer enterpriseId, Integer regionId);
Integer saveByOther(Integer enterpriseId, Integer regionId);
Integer saveByOther(Integer fromEnterpriseId, Integer enterpriseId, Integer regionId);
boolean validIsOwn(Integer enterpriseId, Integer regionId);
......
......@@ -28,6 +28,7 @@ public class StoreRegionRelServiceImpl implements StoreRegionRelService {
TabStoreRegionRel storeRegionRel = new TabStoreRegionRel();
storeRegionRel.setRegionId(regionId);
storeRegionRel.setEnterpriseId(enterpriseId);
storeRegionRel.setFromEnterpriseId(enterpriseId);
storeRegionRel.setOwnType(StoreOwnTypeEnum.OWNER.getCode());
storeRegionRel.setStatus(GlobalInfo.DATA_STATUS_NORMAL);
storeRegionRel.setCreateTime(new Date());
......@@ -35,9 +36,10 @@ public class StoreRegionRelServiceImpl implements StoreRegionRelService {
}
@Override
public Integer saveByOther(Integer enterpriseId, Integer regionId) {
public Integer saveByOther(Integer fromEnterpriseId, Integer enterpriseId, Integer regionId) {
TabStoreRegionRel storeRegionRel = new TabStoreRegionRel();
storeRegionRel.setRegionId(regionId);
storeRegionRel.setFromEnterpriseId(fromEnterpriseId);
storeRegionRel.setEnterpriseId(enterpriseId);
storeRegionRel.setOwnType(StoreOwnTypeEnum.OTHER.getCode());
storeRegionRel.setStatus(GlobalInfo.DATA_STATUS_NORMAL);
......
......@@ -2,11 +2,14 @@ package com.gic.store.service.outer.impl;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.CollectionUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.dto.EnterpriseDTO;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.response.EnterpriseServiceResponse;
import com.gic.enterprise.service.EnterpriseApiService;
import com.gic.store.constant.StoreOwnTypeEnum;
import com.gic.store.dto.StoreRegionDTO;
import com.gic.store.entity.TabStoreRegionRel;
......@@ -19,10 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -39,6 +39,8 @@ public class StoreRegionApiServiceImpl implements StoreRegionApiService {
private StoreRegionRelService storeRegionRelService;
@Autowired
private StoreFieldApiService storeFieldApiService;
@Autowired
private EnterpriseApiService enterpriseApiService;
@Override
@Transactional(rollbackFor = Exception.class)
......@@ -82,8 +84,20 @@ public class StoreRegionApiServiceImpl implements StoreRegionApiService {
@Override
public ServiceResponse<Page<StoreRegionDTO>> listStoreRegion(Integer enterpriseId, String search, Integer pageNum, Integer pageSize) {
com.github.pagehelper.Page storeRegionList = storeRegionService.listStoreRegion(enterpriseId, search, pageNum, pageSize);
Page<StoreRegionDTO> page = PageHelperUtils.changePageHelperToCurrentPage(storeRegionList, StoreRegionDTO.class);
com.github.pagehelper.Page<StoreRegionDTO> list = storeRegionService.listStoreRegion(enterpriseId, search, pageNum, pageSize);
if (CollectionUtils.isNotEmpty(list)) {
List<Integer> fromEnterpriseIds = list.stream().map(StoreRegionDTO::getFromEnterpriseId).collect(Collectors.toList());
ServiceResponse<List<EnterpriseDTO>> serviceResponse = enterpriseApiService.listEnterpriseByIds(fromEnterpriseIds);
if (serviceResponse.isSuccess()) {
List<EnterpriseDTO> enterpriseList = serviceResponse.getResult();
Map<Integer, EnterpriseDTO> dtoMap = CollectionUtil.toMap(enterpriseList, "enterpriseId");
for (StoreRegionDTO storeRegionDTO : list) {
EnterpriseDTO dto = dtoMap.get(storeRegionDTO.getFromEnterpriseId());
storeRegionDTO.setShareEnterpriseName(dto.getEnterpriseName());
}
}
}
Page<StoreRegionDTO> page = PageHelperUtils.changePageHelperToCurrentPage(list, StoreRegionDTO.class);
return ServiceResponse.success(page);
}
......@@ -134,7 +148,7 @@ public class StoreRegionApiServiceImpl implements StoreRegionApiService {
TabStoreRegionRel storeRegionRel = storeRegionRelService.getByRegionIdAndEnterpriseId(regionId, toEnterpriseId, StoreOwnTypeEnum.OTHER.getCode());
if (storeRegionRel == null) {
// 插入
storeRegionRelService.saveByOther(toEnterpriseId, regionId);
storeRegionRelService.saveByOther(fromEnterpriseId, toEnterpriseId, regionId);
} else if (storeRegionRel.getStatus() == 0) {
// 状态更新为1
storeRegionRelService.updateStatusByOther(toEnterpriseId, regionId, GlobalInfo.DATA_STATUS_NORMAL);
......
......@@ -49,4 +49,5 @@
<dubbo:service interface="com.gic.store.service.StoreWidgetApiService" ref="storeWidgetApiService" timeout="6000" />
<dubbo:reference interface="com.gic.enterprise.service.PlatformBrandApiService" id="platformBrandApiService" timeout="6000" />
<dubbo:reference interface="com.gic.auth.service.UnionEnterpriseApiService" id="unionEnterpriseApiService" timeout="6000" />
<dubbo:reference interface="com.gic.enterprise.service.EnterpriseApiService" id="enterpriseApiService" timeout="6000" />
</beans>
......@@ -17,6 +17,7 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="from_enterprise_id" jdbcType="INTEGER" property="fromEnterpriseId" />
<result column="own_type" jdbcType="INTEGER" property="ownType" />
</resultMap>
<sql id="Base_Column_List">
......@@ -26,7 +27,7 @@
${alias}.region_id, ${alias}.region_code, ${alias}.region_name, ${alias}.status, ${alias}.create_time, ${alias}.update_time
</sql>
<sql id="Base_Column_List2">
${alias}.enterprise_id, ${alias}.own_Type
${alias}.enterprise_id from_enterprise_id, ${alias}.own_Type
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
......@@ -169,7 +170,7 @@
and re.region_id &lt;&gt; #{regionId}
</if>
</select>
<select id="listStoreRegionByIds" resultType="com.gic.store.dto.StoreRegionDTO">
<select id="listStoreRegionByIds" resultMap="DTOResultMap">
select
<include refid="Base_Column_List1" >
<property name="alias" value="re" />
......
......@@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="com.gic.store.entity.TabStoreRegionRel">
<id column="store_region_rel_id" jdbcType="INTEGER" property="storeRegionRelId" />
<result column="region_id" jdbcType="INTEGER" property="regionId" />
<result column="from_enterprise_id" jdbcType="INTEGER" property="fromEnterpriseId" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="own_type" jdbcType="INTEGER" property="ownType" />
<result column="status" jdbcType="INTEGER" property="status" />
......@@ -11,7 +12,8 @@
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
store_region_rel_id, region_id, enterprise_id, own_type, status, create_time, update_time
store_region_rel_id, region_id, from_enterprise_id, enterprise_id, own_type, status,
create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
......@@ -24,12 +26,12 @@
where store_region_rel_id = #{storeRegionRelId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.store.entity.TabStoreRegionRel">
insert into tab_store_region_rel (store_region_rel_id, region_id, enterprise_id,
own_type, status, create_time,
update_time)
values (#{storeRegionRelId,jdbcType=INTEGER}, #{regionId,jdbcType=INTEGER}, #{enterpriseId,jdbcType=INTEGER},
#{ownType,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
insert into tab_store_region_rel (store_region_rel_id, region_id, from_enterprise_id,
enterprise_id, own_type, status,
create_time, update_time)
values (#{storeRegionRelId,jdbcType=INTEGER}, #{regionId,jdbcType=INTEGER}, #{fromEnterpriseId,jdbcType=INTEGER},
#{enterpriseId,jdbcType=INTEGER}, #{ownType,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.store.entity.TabStoreRegionRel">
insert into tab_store_region_rel
......@@ -40,6 +42,9 @@
<if test="regionId != null">
region_id,
</if>
<if test="fromEnterpriseId != null">
from_enterprise_id,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
......@@ -63,6 +68,9 @@
<if test="regionId != null">
#{regionId,jdbcType=INTEGER},
</if>
<if test="fromEnterpriseId != null">
#{fromEnterpriseId,jdbcType=INTEGER},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=INTEGER},
</if>
......@@ -86,6 +94,9 @@
<if test="regionId != null">
region_id = #{regionId,jdbcType=INTEGER},
</if>
<if test="fromEnterpriseId != null">
from_enterprise_id = #{fromEnterpriseId,jdbcType=INTEGER},
</if>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
......@@ -107,6 +118,7 @@
<update id="updateByPrimaryKey" parameterType="com.gic.store.entity.TabStoreRegionRel">
update tab_store_region_rel
set region_id = #{regionId,jdbcType=INTEGER},
from_enterprise_id = #{fromEnterpriseId,jdbcType=INTEGER},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
own_type = #{ownType,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
......@@ -137,7 +149,7 @@
update tab_store_region_rel set status = 0
where enterprise_id = #{enterpriseId}
and region_id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
<foreach close=")" collection="ids" index="index" item="item" open="(" separator=",">
#{item}
</foreach>
and own_type = #{ownType}
......
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