Просмотр исходного кода

修改子商户的新增或修改接口

release_toaliyun_real
lrh 2 лет назад
Родитель
Сommit
5228d8eef5
3 измененных файлов: 17 добавлений и 27 удалений
  1. +1
    -3
      mallinkService/src/main/java/com/iformall/mapper/WxMerchantRelationMapper.java
  2. +15
    -13
      mallinkService/src/main/java/com/iformall/service/impl/WxMerchantRelationServiceImpl.java
  3. +1
    -11
      mallinkService/src/main/resources/mapper/WxMerchantRelationMapper.xml

+ 1
- 3
mallinkService/src/main/java/com/iformall/mapper/WxMerchantRelationMapper.java Просмотреть файл

@@ -10,15 +10,13 @@ import java.util.List;

public interface WxMerchantRelationMapper extends CommonMapper<WxMerchantRelation, Long> {

Integer selectByIds(@Param("ids") List<Long> ids);

void updateByReginId(@Param("regionId") Long regionId);

void insertBatch(List<WxMerchantRelation> list);

List<WxMerchantRelation> selectByReginId(@Param("regionId") Long regionId, @Param("ids") List<Long> ids);

void updateByMerchantIds(@Param("merchantIds") List<Long> merchantIds);
void updateByMerchantIds(@Param("merchantIds") List<Long> merchantIds,@Param("regionId") Long regionId);

void deleteByMerchantId(@Param("merchantId") Long merchantId);



+ 15
- 13
mallinkService/src/main/java/com/iformall/service/impl/WxMerchantRelationServiceImpl.java Просмотреть файл

@@ -43,25 +43,27 @@ public class WxMerchantRelationServiceImpl implements WxMerchantRelationService

//先去查询是否存在,如果存在再去排除这个id去进行查询是否存在
List<WxMerchantRelation> infByIds = wxMerchantRelationMapper.getInfByIds(ids);
List<Long> list = new ArrayList<>();
List<Long> updateList = new ArrayList<>();
if (!CollectionUtils.isEmpty(infByIds)) {
list = infByIds.parallelStream().map(WxMerchantRelation::getMerchantId).collect(Collectors.toList());
//判断子商户是否已经被选了
Integer integer = wxMerchantRelationMapper.selectByIds(list);
if (integer > 0) {
List<Long> alreadyList = infByIds.parallelStream().filter(x -> x.getIsDel() == 0).map(WxMerchantRelation::getMerchantId).collect(Collectors.toList());
//如果已经存在就返回
if (!CollectionUtils.isEmpty(alreadyList)){
return new ResultData(Result.ERROR, "存在子商户在其他区域商户下");
}
//如果存在且是同一个区域商户下就 修改 是否删除字段
List<Long> delList = infByIds.parallelStream().filter(x -> x.getIsDel() == 1 && x.getRegionMerchantId().equals(regionId)).map(WxMerchantRelation::getMerchantId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(delList)){
updateList = delList;
}
}

List<Long> finalList = list;
List<Long> collected = ids.parallelStream().filter(x -> !finalList.contains(x)).collect(Collectors.toList());

if (!CollectionUtils.isEmpty(list)) {
wxMerchantRelationMapper.updateByMerchantIds(list);
List<Long> finalList = updateList;
List<Long> insertList = ids.parallelStream().filter(x -> !finalList.contains(x)).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(updateList)) {
wxMerchantRelationMapper.updateByMerchantIds(updateList,regionId);
}

if (!CollectionUtils.isEmpty(collected)) {
insertInfo(regionId, collected, tenantId);
if (!CollectionUtils.isEmpty(insertList)) {
insertInfo(regionId, insertList, tenantId);
}
return new ResultData(Result.SUCCESS, "编辑成功", null);
}


+ 1
- 11
mallinkService/src/main/resources/mapper/WxMerchantRelationMapper.xml Просмотреть файл

@@ -17,16 +17,6 @@
`id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`region_merchant_id`,`is_del`,`create_date`,`update_date`
</sql>

<select id="selectByIds" resultType="java.lang.Integer">
select
count(1)
from wx_merchant_relation
where is_del = 0 and merchant_id not in
<foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>

<update id="updateByReginId">
update wx_merchant_relation
set is_del = 1, update_date = now()
@@ -58,7 +48,7 @@
update wx_merchant_relation
set is_del = 0,
update_date = now()
where merchant_id in
where region_merchant_id = #{regionId} and merchant_id in
<foreach collection="merchantIds" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>


Загрузка…
Отмена
Сохранить