Commit e1557ee0 by 吕明尚

修改门店更新优惠卷配置

parent 31647cea
package share.system.mapper; package share.system.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SCoupon; import share.system.domain.SCoupon;
import share.system.domain.SmsLog;
/** /**
* 优惠券Mapper接口 * 优惠券Mapper接口
...@@ -9,7 +12,7 @@ import share.system.domain.SCoupon; ...@@ -9,7 +12,7 @@ import share.system.domain.SCoupon;
* @author ruoyi * @author ruoyi
* @date 2023-09-27 * @date 2023-09-27
*/ */
public interface SCouponMapper public interface SCouponMapper extends BaseMapper<SCoupon>
{ {
/** /**
* 查询优惠券 * 查询优惠券
...@@ -68,4 +71,5 @@ public interface SCouponMapper ...@@ -68,4 +71,5 @@ public interface SCouponMapper
List<SCoupon> selectSCouponByDealgroupId(Long dealgroupId); List<SCoupon> selectSCouponByDealgroupId(Long dealgroupId);
SCoupon selectByDealgroupId(Long dealgroupId); SCoupon selectByDealgroupId(Long dealgroupId);
} }
package share.system.service; package share.system.service;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.DeviceLog;
import share.system.domain.SCoupon; import share.system.domain.SCoupon;
/** /**
...@@ -9,7 +12,7 @@ import share.system.domain.SCoupon; ...@@ -9,7 +12,7 @@ import share.system.domain.SCoupon;
* @author ruoyi * @author ruoyi
* @date 2023-09-27 * @date 2023-09-27
*/ */
public interface ISCouponService public interface ISCouponService extends IService<SCoupon>
{ {
/** /**
* 查询优惠券 * 查询优惠券
......
...@@ -7,9 +7,11 @@ import java.util.stream.Collectors; ...@@ -7,9 +7,11 @@ import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.system.domain.SRoom;
import share.system.mapper.RoomPackMapper; import share.system.mapper.RoomPackMapper;
import share.system.domain.SRoomPack; import share.system.domain.SRoomPack;
import share.system.mapper.SRoomMapper; import share.system.mapper.SRoomMapper;
...@@ -111,8 +113,15 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> ...@@ -111,8 +113,15 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
LambdaQueryWrapper<SRoomPack> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SRoomPack> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SRoomPack::getPackId, id); queryWrapper.eq(SRoomPack::getPackId, id);
List<SRoomPack> sRoomPackList = baseMapper.selectList(queryWrapper); List<SRoomPack> sRoomPackList = baseMapper.selectList(queryWrapper);
List<Long> roomIds = sRoomPackList.stream().map(SRoomPack::getRoomId).collect(Collectors.toList());
List<SRoom> sRoomList = sRoomMapper.selectList(new LambdaQueryWrapper<SRoom>().in(SRoom::getId, roomIds));
sRoomPackList.forEach(item -> { sRoomPackList.forEach(item -> {
item.setRoomName(sRoomMapper.selectById(item.getRoomId()).getName()); if (ObjectUtils.isNotEmpty(item.getRoomId())) {
Optional<SRoom> first = sRoomList.stream().filter(sRoom -> sRoom.getId().equals(item.getRoomId())).findFirst();
if (first.isPresent()) {
item.setRoomName(first.get().getName());
}
}
}); });
return sRoomPackList; return sRoomPackList;
} }
......
...@@ -7,6 +7,7 @@ import java.util.*; ...@@ -7,6 +7,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouDealQueryShopDealResponseEntity; import com.dianping.openapi.sdk.api.tuangou.entity.TuangouDealQueryShopDealResponseEntity;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -18,11 +19,14 @@ import share.common.utils.DateUtils; ...@@ -18,11 +19,14 @@ import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.system.domain.SStore; import share.system.domain.SStore;
import share.system.domain.SmsLog;
import share.system.mapper.SCouponMapper; import share.system.mapper.SCouponMapper;
import share.system.domain.SCoupon; import share.system.domain.SCoupon;
import share.system.mapper.SmsLogMapper;
import share.system.service.ISCouponService; import share.system.service.ISCouponService;
import share.system.service.ISStoreService; import share.system.service.ISStoreService;
import share.system.service.QPService; import share.system.service.QPService;
import share.system.service.SmsLogService;
/** /**
* 优惠券Service业务层处理 * 优惠券Service业务层处理
...@@ -31,7 +35,7 @@ import share.system.service.QPService; ...@@ -31,7 +35,7 @@ import share.system.service.QPService;
* @date 2023-09-27 * @date 2023-09-27
*/ */
@Service @Service
public class SCouponServiceImpl implements ISCouponService { public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> implements ISCouponService {
@Autowired @Autowired
private SCouponMapper sCouponMapper; private SCouponMapper sCouponMapper;
@Autowired @Autowired
......
...@@ -58,6 +58,8 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme ...@@ -58,6 +58,8 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
private ISOrderService orderService; private ISOrderService orderService;
@Autowired @Autowired
private DeviceService deviceService; private DeviceService deviceService;
@Autowired
private ISCouponService sCouponService;
/** /**
* 查询门店 * 查询门店
...@@ -89,6 +91,12 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme ...@@ -89,6 +91,12 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
*/ */
@Override @Override
public int insertSStore(SStore sStore) { public int insertSStore(SStore sStore) {
LambdaQueryWrapper<SStore> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SStore::getOpenShopUuid, sStore.getOpenShopUuid());
List<SStore> sStoreList = baseMapper.selectList(queryWrapper);
if (CollectionUtils.isNotEmpty(sStoreList)) {
throw new BaseException("该门店已存在!");
}
sStore.setCreateTime(DateUtils.getNowDate()); sStore.setCreateTime(DateUtils.getNowDate());
// 获取最新设备分组 // 获取最新设备分组
SStore store = baseMapper.selectByMaxDeviceGroup(); SStore store = baseMapper.selectByMaxDeviceGroup();
...@@ -105,7 +113,44 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme ...@@ -105,7 +113,44 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
} else { } else {
sStore.setDeviceGroup("FFFA10000001"); sStore.setDeviceGroup("FFFA10000001");
} }
return baseMapper.insertSStore(sStore); int i = baseMapper.insertSStore(sStore);
//过滤掉没有dealgroupId的优惠券
extracted();
return i;
}
private void extracted() {
List<SCoupon> sCouponList1 = sCouponService.selectSCouponList(new SCoupon()).stream().filter(item -> item.getDealgroupId() != null).collect(Collectors.toList());
List<SCoupon> sCouponList = sCouponService.queryShopDeal();
List<SCoupon> sCouponList2 = new ArrayList<>();
if (CollectionUtils.isNotEmpty(sCouponList1)) {
sCouponList1.stream().forEach(item -> {
if (CollectionUtils.isNotEmpty(sCouponList)) {
sCouponList.stream().forEach(item1 -> {
if (item.getDealgroupId().equals(item1.getDealgroupId())) {
if (StringUtils.isNotEmpty(item.getStoreIds())) {
if (item1.getStoreIds().contains(item.getStoreIds())) {
return;
} else {
SCoupon sCoupon = new SCoupon();
sCoupon.setId(item.getId());
sCoupon.setStoreIds(item1.getStoreIds());
sCouponList2.add(sCoupon);
}
} else {
SCoupon sCoupon = new SCoupon();
sCoupon.setId(item.getId());
sCoupon.setStoreIds(item1.getStoreIds());
sCouponList2.add(sCoupon);
}
}
});
}
});
}
if (CollectionUtils.isNotEmpty(sCouponList2)) {
sCouponService.updateBatchById(sCouponList2);
}
} }
/** /**
...@@ -148,7 +193,9 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme ...@@ -148,7 +193,9 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
if (CollectionUtils.isNotEmpty(sRooms)) { if (CollectionUtils.isNotEmpty(sRooms)) {
throw new BaseException("当前门店下存在房间,不能删除!"); throw new BaseException("当前门店下存在房间,不能删除!");
} }
return baseMapper.deleteSStoreByIds(ids); int i = baseMapper.deleteSStoreByIds(ids);
extracted();
return i;
} }
/** /**
......
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