Commit b0dd8389 by 陶光胜

门店品牌变更

parent 4e636fe9
......@@ -81,6 +81,18 @@ public interface TabStoreBrandRefMapper {
TabStoreBrandRef selectByEidAndBrandId(@Param("enterpriseId") Integer enterpriseId, @Param("storeBrandId") Integer storeBrandId);
/**
* selectByEidAndBrandIdList
* @Title: selectByEidAndBrandIdList
* @Description:
* @author taogs
* @param enterpriseId
* @param storeBrandIdList
* @return java.util.List<com.gic.store.entity.TabStoreBrandRef>
* @throws
*/
List<TabStoreBrandRef> selectByEidAndBrandIdList(@Param("enterpriseId") Integer enterpriseId, @Param("storeBrandIdList") List<Integer> storeBrandIdList);
/**
* updateSort
* @Title: updateSort
* @Description: 更新排序
......
......@@ -17,10 +17,7 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -62,6 +59,10 @@ public class StoreBrandServiceImpl implements StoreBrandService {
@Override
public void saveStoreBrandRef(Integer enterpriseId, Integer storeBrandId, Integer type){
TabStoreBrandRef existTab = tabStoreBrandRefMapper.selectByEidAndBrandId(enterpriseId, storeBrandId);
if(existTab != null){
return;
}
Date date = new Date();
TabStoreBrandRef tabStoreBrandRef = new TabStoreBrandRef();
Double sort = tabStoreBrandRefMapper.getMinSort(enterpriseId);
......@@ -82,7 +83,12 @@ public class StoreBrandServiceImpl implements StoreBrandService {
Double sort = tabStoreBrandRefMapper.getMinSort(enterpriseId);
sort = sort == null ? 1d : sort - 1d;
Date date = new Date();
List<TabStoreBrandRef> existList = tabStoreBrandRefMapper.selectByEidAndBrandIdList(enterpriseId, storeBrandIdList);
Map<String, Integer> existMap = existList.stream().collect(Collectors.toMap(ref -> ref.getEnterpriseId() + "-" + ref.getStoreBrandId(), TabStoreBrandRef::getId));
for(Integer storeBrandId : storeBrandIdList){
if(!existMap.containsKey(enterpriseId + "-" + storeBrandId)){
continue;
}
TabStoreBrandRef tabStoreBrandRef = new TabStoreBrandRef();
tabStoreBrandRef.setSort(sort);
tabStoreBrandRef.setEnterpriseId(enterpriseId);
......
......@@ -143,6 +143,7 @@ public class StoreAuthorizationApiServiceImpl implements StoreAuthorizationApiSe
}
storeDTO.setIsEditStoreGroup(0);
storeDTO.setOwnType(StoreOwnTypeEnum.OTHER.getCode());
log.info("授权门店信息:{}", JSON.toJSONString(storeDTO));
int i = this.storeService.authAddStore(storeDTO);
log.info("{},门店授权结果:{}", storeDTO.getStoreInfoId(), i);
if(i == 0 && logId != 0){
......@@ -173,7 +174,7 @@ public class StoreAuthorizationApiServiceImpl implements StoreAuthorizationApiSe
return ServiceResponse.success();
}
private void queryStoreByPage(Long count, StoreSearchDTO storeSearchDTO, Integer toEnterpriseId, Integer enterpriseId, String key){
private void queryStoreByPage(Long count, StoreSearchDTO storeSearchDTO, Integer unionEnterpriseId, Integer ownEnterpriseId, String key){
int pages = count/ PAGE_SIZE + count % PAGE_SIZE >0 ? 1 : 0;
/**需要共享的域*/
Set<Integer> regionSet = new HashSet<>();
......@@ -184,7 +185,7 @@ public class StoreAuthorizationApiServiceImpl implements StoreAuthorizationApiSe
/**需要共享的门店品牌****/
Set<Integer> storeBrandIdSet = new HashSet<>();
/**获取当前商户下的共享门店**/
List<Integer> existStoreInfoIdList = this.storeService.listShareStoreId(enterpriseId);
List<Integer> existStoreInfoIdList = this.storeService.listShareStoreId(ownEnterpriseId);
Set<Integer> storeInfoIdSet = new HashSet<>(existStoreInfoIdList);
int total = 0;
for(int page = 1; page <= pages; page++){
......@@ -207,7 +208,7 @@ public class StoreAuthorizationApiServiceImpl implements StoreAuthorizationApiSe
isEnd = 1;
}
total++;
this.sendDataToMq(storeDTO, toEnterpriseId, isEnd, key, total);
this.sendDataToMq(storeDTO, unionEnterpriseId, isEnd, key, total);
/**共享门店不能再共享 所以需要剔除***/
if(storeInfoIdSet.contains(storeDTO.getStoreInfoId())){
storeInfoIdSet.remove(storeDTO.getStoreInfoId());
......
......@@ -140,6 +140,20 @@
where enterprise_id= #{enterpriseId} and store_brand_id=#{storeBrandId} and delete_flag = 0
</select>
<select id="selectByEidAndBrandIdList" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_store_brand_ref
where enterprise_id= #{enterpriseId} and delete_flag = 0
<if test="storeBrandIdList.size()>0">
and store_brand_id in
<foreach close=")" collection="storeBrandIdList" index="index" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
</select>
<update id="updateSort">
update tab_store_brand_ref set sort = #{sort}
where enterprise_id=#{enterpriseId} and store_brand_id = #{storeBrandId} and delete_flag = 0
......
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