Commit e1557ee0 by 吕明尚

修改门店更新优惠卷配置

parent 31647cea
package share.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SCoupon;
import share.system.domain.SmsLog;
/**
* 优惠券Mapper接口
......@@ -9,7 +12,7 @@ import share.system.domain.SCoupon;
* @author ruoyi
* @date 2023-09-27
*/
public interface SCouponMapper
public interface SCouponMapper extends BaseMapper<SCoupon>
{
/**
* 查询优惠券
......@@ -68,4 +71,5 @@ public interface SCouponMapper
List<SCoupon> selectSCouponByDealgroupId(Long dealgroupId);
SCoupon selectByDealgroupId(Long dealgroupId);
}
package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.DeviceLog;
import share.system.domain.SCoupon;
/**
......@@ -9,7 +12,7 @@ import share.system.domain.SCoupon;
* @author ruoyi
* @date 2023-09-27
*/
public interface ISCouponService
public interface ISCouponService extends IService<SCoupon>
{
/**
* 查询优惠券
......
......@@ -7,9 +7,11 @@ import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.SRoom;
import share.system.mapper.RoomPackMapper;
import share.system.domain.SRoomPack;
import share.system.mapper.SRoomMapper;
......@@ -111,8 +113,15 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
LambdaQueryWrapper<SRoomPack> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SRoomPack::getPackId, id);
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 -> {
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;
}
......
......@@ -7,6 +7,7 @@ import java.util.*;
import java.util.stream.Collectors;
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 org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
......@@ -18,11 +19,14 @@ import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.SStore;
import share.system.domain.SmsLog;
import share.system.mapper.SCouponMapper;
import share.system.domain.SCoupon;
import share.system.mapper.SmsLogMapper;
import share.system.service.ISCouponService;
import share.system.service.ISStoreService;
import share.system.service.QPService;
import share.system.service.SmsLogService;
/**
* 优惠券Service业务层处理
......@@ -31,7 +35,7 @@ import share.system.service.QPService;
* @date 2023-09-27
*/
@Service
public class SCouponServiceImpl implements ISCouponService {
public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> implements ISCouponService {
@Autowired
private SCouponMapper sCouponMapper;
@Autowired
......
......@@ -58,6 +58,8 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
private ISOrderService orderService;
@Autowired
private DeviceService deviceService;
@Autowired
private ISCouponService sCouponService;
/**
* 查询门店
......@@ -89,6 +91,12 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
*/
@Override
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 store = baseMapper.selectByMaxDeviceGroup();
......@@ -105,7 +113,44 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
} else {
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
if (CollectionUtils.isNotEmpty(sRooms)) {
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