Commit 12c9d33a by 吕明尚

增加枚举类

parent ed350316
package share.common.enums;
public enum AvailableEnum {
//(0:可用,1:不可以)
AVAILABLE(0, "可用"),
UNAVAILABLE(1, "不可用");
private Integer code;
private String name;
AvailableEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
AvailableEnum() {
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package share.common.enums;
public enum CleaningStatusEnum {
UNCLEAN(0, "未保洁"),
CLEANING(1, "保洁中"),
CLEANED(2, "已保洁");
private Integer code;
private String name;
CleaningStatusEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
CleaningStatusEnum() {
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package share.common.enums;
public enum ConsumerCouponUseStatusEnum {
//0:待使用,1:已使用,2:已失效
WAIT_USE(0, "待使用"),
USED(1, "已使用"),
INVALID(2, "已失效");
private Integer code;
private String name;
ConsumerCouponUseStatusEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
ConsumerCouponUseStatusEnum() {
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package share.common.enums;
public enum RoleTypeEnum {
MEMBRO(0, "会员"),
CLEANER(1, "保洁人员"),
ADMIN(2, "后台管理人员");;
private Integer code;
private String name;
RoleTypeEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
RoleTypeEnum() {
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -185,7 +185,7 @@ public class OrderTask {
logger.info("=================" + sOrder.getCouponId() + "=================");
logger.info("=================================================");
// 退优惠券
if (Objects.nonNull(sOrder) && sOrder.getCouponId() > 0) {
if (sOrder.getCouponId() > 0) {
SConsumerCoupon couponUser = consumerCouponService.getById(sOrder.getCouponId());
couponUser.setUseStatus(CouponStatusEnum.NORMAL.getValue());
consumerCouponService.updateById(couponUser);
......@@ -225,12 +225,12 @@ public class OrderTask {
});
}
});
boolean execute = transactionTemplate.execute( e -> {
Boolean execute = transactionTemplate.execute(e -> {
orderService.updateBatchById(sOrders,sOrders.size());
roomService.updateBatchById(roomList,roomList.size());
return true;
});
if(!execute){
if (Boolean.FALSE.equals(execute)) {
logger.error("预约订单到期自动更新订单状态失败!");
throw new BaseException("预约订单到期自动更新订单状态失败!");
}
......
......@@ -51,7 +51,7 @@ public class SConsumer
/** 会员角色类型(0:会员,1:保洁人员,2:后台管理人员) */
@ApiModelProperty(value = "会员角色类型", example = "0=:会员,1:保洁人员,2:后台管理人员")
private String roleType;
private Integer roleType;
/** 会员性别(0:未知,1:男,2:女) */
@ApiModelProperty(value = "会员性别", example = "0=:未知,1:男,2:女")
......
......@@ -58,7 +58,7 @@ public class SConsumerCoupon extends BaseEntity
/** 优惠券类型(1:折扣券,2,满减券,3:时长券) */
@Excel(name = "优惠券类型(1:折扣券,2,满减券,3:时长券)")
private String couponType;
private Integer couponType;
/** 门槛时长 */
@Excel(name = "门槛时长")
......
......@@ -3,6 +3,8 @@ package share.system.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import share.common.enums.CleaningStatusEnum;
import share.common.enums.RoleTypeEnum;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -148,12 +150,12 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
@Override
public SCleanRecords getByCleanerId() {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if(!user.getRoleType().equals("1")){
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是保洁人员");
}
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper();
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SCleanRecords::getConsumerId,user.getId());
queryWrapper.in(SCleanRecords::getStatus,1);
queryWrapper.in(SCleanRecords::getStatus, CleaningStatusEnum.CLEANING.getCode());
SCleanRecords sCleanRecords = sCleanRecordsMapper.selectOne(queryWrapper);
if(sCleanRecords == null){
throw new RuntimeException("当前用户没有保洁任务");
......
package share.system.service.impl;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -8,9 +8,7 @@ import java.util.*;
import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.CollectionUtils;
import share.common.enums.RoomStatusEnum;
import share.common.enums.RoomType;
import share.common.enums.StoreType;
import share.common.enums.*;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -18,7 +16,6 @@ import share.system.domain.SConsumer;
import share.system.domain.SRoom;
import share.system.domain.SStore;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SRoomVo;
import share.system.mapper.SConsumerCouponMapper;
import share.system.domain.SConsumerCoupon;
import share.system.request.CouponRequest;
......@@ -129,7 +126,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
public List<SConsumerCoupon> availableCouponList(CouponRequest couponRequest) {
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sConsumerCoupon.setUseStatus(0);
sConsumerCoupon.setUseStatus(ConsumerCouponUseStatusEnum.WAIT_USE.getCode());
sConsumerCoupon.setConsumerId(user.getId());
//查询用户未使用的优惠券
List<SConsumerCoupon> sConsumerCoupons = sConsumerCouponMapper.selectSConsumerCouponList(sConsumerCoupon);
......@@ -147,46 +144,13 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
SStore sStore = sStoreService.getById(couponRequest.getStoreId());
SRoom byId = sRoomService.getById(couponRequest.getRoomId());
BigDecimal subtract = new BigDecimal(item.getMinDuration());
if (item.getCouponType().equals("3")) {
if (item.getCouponType().equals(CouponTypeEnum.DURATION.getCode())) {
//判断门槛时长
if (bigDecimal.compareTo(subtract) >= 0) {
//判断门店类型
if (item.getStoreType().contains(sStore.getStoreType())) {
//判断房间类型
if (item.getRoomType().contains(byId.getRoomType())) {
item.setIsAvailable(0);
isStoreType(item, sStore, byId);
} else {
item.setIsAvailable(1);
final List<String> list = new JSONArray(item.getRoomType()).toList(String.class);
Map<String, String> colorMap = new HashMap<>();
EnumSet<RoomType> colors = EnumSet.allOf(RoomType.class);
for (RoomType color : colors) {
colorMap.put(color.getCode(), color.getName());
}
StringBuilder roomType = new StringBuilder();
for (String type : list) {
roomType.append(colorMap.get(type)).append(",");
}
item.setReason("房间类型不支持,支持的房间类型为:" + roomType);
}
} else {
item.setIsAvailable(1);
final List<String> list = new JSONArray(item.getStoreType()).toList(String.class);
Map<String, String> colorMap = new HashMap<>();
EnumSet<StoreType> colors = EnumSet.allOf(StoreType.class);
for (StoreType color : colors) {
colorMap.put(color.getCode(), color.getName());
}
StringBuilder storeType = new StringBuilder();
for (String type : list) {
storeType.append(colorMap.get(type)).append(",");
}
item.setReason("门店类型不支持,支持的门店类型为:" + storeType);
}
} else {
item.setIsAvailable(1);
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("下单时长等于" + bigDecimal + "小时,不满足优惠券门槛时长");
}
} else {
......@@ -197,13 +161,35 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
//判断门槛时长
if (bigDecimal.compareTo(subtract) >= 0) {
//判断门店类型
isStoreType(item, sStore, byId);
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("下单时长低于" + item.getMinDuration() + "小时 ");
}
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("消费金额低于" + item.getMinPrice() + "元");
}
}
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("优惠卷未生效,优惠卷有效时段为每天" + item.getCouponTimeStart() + "-" + item.getCouponTimeEnd());
}
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("优惠卷未生效,优惠卷有效时间为" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, item.getStartDate()) + "-" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, item.getEndDate()));
}
});
return sConsumerCoupons;
}
private void isStoreType(SConsumerCoupon item, SStore sStore, SRoom byId) {
if (item.getStoreType().contains(sStore.getStoreType())) {
//判断房间类型
if (item.getRoomType().contains(byId.getRoomType())) {
item.setIsAvailable(0);
item.setIsAvailable(AvailableEnum.AVAILABLE.getCode());
} else {
item.setIsAvailable(1);
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
final List<String> list = new JSONArray(item.getRoomType()).toList(String.class);
Map<String, String> colorMap = new HashMap<>();
EnumSet<RoomType> colors = EnumSet.allOf(RoomType.class);
......@@ -218,7 +204,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
item.setReason("房间类型不支持,支持的房间类型为:" + roomType);
}
} else {
item.setIsAvailable(1);
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
final List<String> list = new JSONArray(item.getStoreType()).toList(String.class);
Map<String, String> colorMap = new HashMap<>();
EnumSet<StoreType> colors = EnumSet.allOf(StoreType.class);
......@@ -232,24 +218,5 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
}
item.setReason("门店类型不支持,支持的门店类型为:" + storeType);
}
} else {
item.setIsAvailable(1);
item.setReason("下单时长低于" + item.getMinDuration() + "小时 ");
}
} else {
item.setIsAvailable(1);
item.setReason("消费金额低于" + item.getMinPrice() + "元");
}
}
} else {
item.setIsAvailable(1);
item.setReason("优惠卷未生效,优惠卷有效时段为每天" + item.getCouponTimeStart() + "-" + item.getCouponTimeEnd());
}
} else {
item.setIsAvailable(1);
item.setReason("优惠卷未生效,优惠卷有效时间为" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, item.getStartDate()) + "-" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, item.getEndDate()));
}
});
return sConsumerCoupons;
}
}
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