Commit f95e8668 by 吕明尚

房间管理增加套餐逻辑

parent 4695f84b
package share.common.enums;
public enum PlatformTypeEnum {
//1:自营,2:美团
SELF("1", "自营"),
MEITUAN("2", "美团");
private String code;
private String name;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
PlatformTypeEnum(String code, String name) {
this.code = code;
this.name = name;
}
PlatformTypeEnum() {
}
}
package share.common.enums;
public enum SourceTypeEnum {
//1:领取,2:赠送,3:验券
RECEIVE("1", "领取"),
GIVE("2", "赠送"),
CHECK("3", "验券");
private String code;
private String name;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
SourceTypeEnum(String code, String name) {
this.code = code;
this.name = name;
}
SourceTypeEnum() {
}
}
...@@ -57,7 +57,7 @@ public class SConsumerCoupon extends BaseEntity ...@@ -57,7 +57,7 @@ public class SConsumerCoupon extends BaseEntity
private String couponTimeEnd; private String couponTimeEnd;
/** 优惠券类型(1:折扣券,2,满减券,3:时长券) */ /** 优惠券类型(1:折扣券,2,满减券,3:时长券) */
@Excel(name = "优惠券类型(1:折扣券,2,满减券,3:时长券)") @Excel(name = "优惠券类型(1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额,6:套餐劵)")
private Integer couponType; private Integer couponType;
/** 门槛时长 */ /** 门槛时长 */
......
package share.system.domain; package share.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
...@@ -74,4 +75,10 @@ public class SRoom extends BaseEntity ...@@ -74,4 +75,10 @@ public class SRoom extends BaseEntity
@Excel(name = "其他可能硬件接入参数(备用2)") @Excel(name = "其他可能硬件接入参数(备用2)")
private String params2; private String params2;
/**
* 套餐ID数组
*/
@TableField(exist = false)
private Long[] packIds;
} }
...@@ -61,4 +61,6 @@ public interface IRoomPackService extends IService<RoomPack> { ...@@ -61,4 +61,6 @@ public interface IRoomPackService extends IService<RoomPack> {
public int deleteRoomPackById(Long id); public int deleteRoomPackById(Long id);
List<Long> selectPackListByRoomId(Long id); List<Long> selectPackListByRoomId(Long id);
int deleteRoomPackByRoomId(Long id);
} }
...@@ -11,10 +11,14 @@ import com.dianping.openapi.sdk.api.tuangou.TuangouReceiptPrepare; ...@@ -11,10 +11,14 @@ import com.dianping.openapi.sdk.api.tuangou.TuangouReceiptPrepare;
import com.dianping.openapi.sdk.api.tuangou.TuangouReceiptReverseConsume; import com.dianping.openapi.sdk.api.tuangou.TuangouReceiptReverseConsume;
import com.dianping.openapi.sdk.api.tuangou.entity.*; import com.dianping.openapi.sdk.api.tuangou.entity.*;
import com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient; import com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient;
import com.sun.deploy.services.PlatformType;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.common.enums.DataSourceType;
import share.common.enums.PlatformTypeEnum;
import share.common.enums.SourceTypeEnum;
import share.common.utils.uuid.UUID; import share.common.utils.uuid.UUID;
import share.system.domain.SConsumer; import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon; import share.system.domain.SConsumerCoupon;
...@@ -74,8 +78,8 @@ public class QPServiceImpl implements QPService { ...@@ -74,8 +78,8 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setDuration(sCoupon.getDuration()); sConsumerCoupon.setDuration(sCoupon.getDuration());
sConsumerCoupon.setMinPrice(sCoupon.getMinPrice()); sConsumerCoupon.setMinPrice(sCoupon.getMinPrice());
sConsumerCoupon.setSubPrice(sCoupon.getSubPrice()); sConsumerCoupon.setSubPrice(sCoupon.getSubPrice());
sConsumerCoupon.setSourceType("3"); sConsumerCoupon.setSourceType(SourceTypeEnum.CHECK.getCode());
sConsumerCoupon.setPlatformType("2"); sConsumerCoupon.setPlatformType(PlatformTypeEnum.MEITUAN.getCode());
sConsumerCoupon.setStartDate(sCoupon.getStartDate()); sConsumerCoupon.setStartDate(sCoupon.getStartDate());
sConsumerCoupon.setEndDate(item.getReceiptEndDate()); sConsumerCoupon.setEndDate(item.getReceiptEndDate());
sConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime()); sConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime());
......
package share.system.service.impl; package share.system.service.impl;
import java.sql.Wrapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.SCleanRecords;
import share.system.mapper.RoomPackMapper; import share.system.mapper.RoomPackMapper;
import share.system.domain.RoomPack; import share.system.domain.RoomPack;
import share.system.service.IRoomPackService; import share.system.service.IRoomPackService;
...@@ -93,4 +97,11 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, RoomPack> i ...@@ -93,4 +97,11 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, RoomPack> i
public List<Long> selectPackListByRoomId(Long id) { public List<Long> selectPackListByRoomId(Long id) {
return roomPackMapper.selectPackListByRoomId(id); return roomPackMapper.selectPackListByRoomId(id);
} }
@Override
public int deleteRoomPackByRoomId(Long id) {
LambdaQueryWrapper<RoomPack> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RoomPack::getRoomId, id);
return roomPackMapper.delete(queryWrapper);
}
} }
...@@ -12,6 +12,7 @@ import share.common.utils.DateUtils; ...@@ -12,6 +12,7 @@ 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.Pack; import share.system.domain.Pack;
import share.system.domain.RoomPack;
import share.system.domain.SConsumer; import share.system.domain.SConsumer;
import share.system.domain.vo.FrontTokenComponent; import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SRoomVo; import share.system.domain.vo.SRoomVo;
...@@ -100,6 +101,23 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper,SRoom> implements ...@@ -100,6 +101,23 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper,SRoom> implements
@Override @Override
public int insertSRoom(SRoom sRoom) public int insertSRoom(SRoom sRoom)
{ {
//判断套餐ID
if (sRoom.getPackIds().length > 0) {
List<Pack> packList = packService.selectPackListByIds(Arrays.asList(sRoom.getPackIds()));
if (CollectionUtils.isEmpty(packList)) {
throw new RuntimeException("套餐不存在");
}
List<Long> list = Arrays.asList(sRoom.getPackIds());
List<RoomPack> roomPackList = new ArrayList<>();
list.stream().forEach(o -> {
RoomPack roomPack = new RoomPack();
roomPack.setPackId(o);
roomPack.setRoomId(sRoom.getId());
roomPack.setCreateTime(DateUtils.getNowDate());
roomPackList.add(roomPack);
});
roomPackService.saveBatch(roomPackList);
}
sRoom.setCreateTime(DateUtils.getNowDate()); sRoom.setCreateTime(DateUtils.getNowDate());
return sRoomMapper.insertSRoom(sRoom); return sRoomMapper.insertSRoom(sRoom);
} }
...@@ -113,6 +131,26 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper,SRoom> implements ...@@ -113,6 +131,26 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper,SRoom> implements
@Override @Override
public int updateSRoom(SRoom sRoom) public int updateSRoom(SRoom sRoom)
{ {
//判断套餐ID
if (sRoom.getPackIds().length > 0) {
//判断套餐ID
List<Pack> packList = packService.selectPackListByIds(Arrays.asList(sRoom.getPackIds()));
if (CollectionUtils.isEmpty(packList)) {
throw new RuntimeException("套餐不存在");
}
//删除原有套餐
roomPackService.deleteRoomPackByRoomId(sRoom.getId());
List<Long> list = Arrays.asList(sRoom.getPackIds());
List<RoomPack> roomPackList = new ArrayList<>();
list.stream().forEach(o -> {
RoomPack roomPack = new RoomPack();
roomPack.setPackId(o);
roomPack.setRoomId(sRoom.getId());
roomPack.setCreateTime(DateUtils.getNowDate());
roomPackList.add(roomPack);
});
roomPackService.saveBatch(roomPackList);
}
sRoom.setUpdateTime(DateUtils.getNowDate()); sRoom.setUpdateTime(DateUtils.getNowDate());
return sRoomMapper.updateSRoom(sRoom); return sRoomMapper.updateSRoom(sRoom);
} }
...@@ -126,6 +164,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper,SRoom> implements ...@@ -126,6 +164,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper,SRoom> implements
@Override @Override
public int deleteSRoomByIds(Long[] ids) public int deleteSRoomByIds(Long[] ids)
{ {
roomPackService.deleteRoomPackByIds(ids);
return sRoomMapper.deleteSRoomByIds(ids); return sRoomMapper.deleteSRoomByIds(ids);
} }
......
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