From 9f636241961871b63321ae793162198a898f4154 Mon Sep 17 00:00:00 2001 From: bai <1643359946@qq.com> Date: Sat, 15 Jun 2024 20:59:00 +0800 Subject: [PATCH] =?UTF-8?q?2024=E5=B9=B46=E6=9C=8815=E6=97=A5=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=AE=8C=E5=96=84=E6=8A=80?= =?UTF-8?q?=E5=B8=88=E7=89=A9=E6=96=99=E5=8C=85=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlArtificerSelfGoodsController.java | 73 +++++----- ...erSelfGoodsEntryExitRecordsController.java | 18 +-- .../entity/BlArtificerSelfGoods.java | 7 + .../service/BlArtificerSelfGoodsService.java | 17 ++- .../impl/BlArtificerSelfGoodsServiceImpl.java | 110 ++++++++++++-- .../sqx/modules/common/enums/CommonEnum.java | 8 +- .../common/service/CommonInfoService.java | 8 +- .../service/impl/CommonInfoServiceImpl.java | 86 ++++++++++- .../common/utils/CommonConfigUtil.java | 2 +- .../shopping/controller/GoodsController.java | 3 +- .../shopping/service/GoodsService.java | 2 + .../service/impl/SelfGoodsServiceImpl.java | 137 +++++++++++------- .../service/impl/TravelConfServiceImpl.java | 2 +- 13 files changed, 348 insertions(+), 125 deletions(-) diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsController.java b/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsController.java index 4f41643..dd141ab 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsController.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsController.java @@ -10,16 +10,19 @@ import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService; import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Arrays; +import java.util.List; /** * @author bai * @date 2024/06/08 */ +@Slf4j @RestController @Api(value = "v3-技师与物料关系表", tags = { "v3-技师与物料关系表" }) @RequestMapping(value = "/blArtificerSelfGoods") @@ -33,35 +36,39 @@ public class BlArtificerSelfGoodsController { public Result list(BlArtificerSelfGoods entity, Integer page,Integer limit){ QueryWrapper qw = new QueryWrapper<>(); -// if(entity != null) { - //价格类型 -// qw.lambda().eq(entity.getPricingType() != null, BlArtificerSelfGoods::getPricingType, entity.getPricingType()); -// //出行方式 -// qw.lambda().eq(entity.getTravelType() != null, BlArtificerSelfGoods::getTravelType, entity.getTravelType()); -// //时令 -// qw.lambda().eq(entity.getSeasonsType() != null, BlArtificerSelfGoods::getSeasonsType, entity.getSeasonsType()); -// //时段 -// qw.lambda().eq(entity.getTimeIntervalType() != null, BlArtificerSelfGoods::getTimeIntervalType, entity.getTimeIntervalType()); -// } + if(entity != null) { + //技师 + qw.lambda().eq(entity.getArtificerId() != null, BlArtificerSelfGoods::getArtificerId, entity.getArtificerId()); + } -// qw.orderByAsc("sort"); + qw.orderByAsc("create_time", "update_time"); IPage pageList = service.page(new Page<>(page,limit),qw); return Result.success().put("data",pageList); } - @PostMapping(value = "/add") + @PostMapping(value = "/addList") @ApiOperation("新增") - public Result add(@RequestBody BlArtificerSelfGoods entity){ - entity.setCreateTime(DateUtil.now()); - entity.setUpdateTime(DateUtil.now()); - return Result.success().put("data",service.save(entity)); + public Result add(@RequestBody List list){ + try { + service.editWarehouse(list); + return Result.success(); + } catch (Exception e) { + log.error(e.getMessage(),e); + return Result.error(e.getMessage()); + } } @PostMapping(value = "/update") @ApiOperation("修改") public Result update(@RequestBody BlArtificerSelfGoods entity){ entity.setUpdateTime(DateUtil.now()); - return Result.success().put("data",service.updateById(entity)); + try { + service.editWarehouseById(entity.getId(), entity.getChangeNum(), entity.getRemark()); + return Result.success(); + } catch (Exception e) { + log.error(e.getMessage(),e); + return Result.error(e.getMessage()); + } } @RequestMapping("/info/{id}") @@ -70,22 +77,22 @@ public class BlArtificerSelfGoodsController { return Result.success().put("data", data); } - @DeleteMapping(value = "/deleteById") - @ApiOperation("删除") - public Result deleteById(Long id){ - service.removeById(id); - return Result.success(); - } - - @DeleteMapping(value = "/deleteByIds") - @ApiOperation("批量删除") - public Result deleteByIds(String id){ - if(StringUtils.isNotBlank(id)){ - String[] ids = StringUtils.split(id,","); - service.removeByIds(Arrays.asList(ids)); - } - return Result.success(); - } +// @DeleteMapping(value = "/deleteById") +// @ApiOperation("删除") +// public Result deleteById(Long id){ +// service.removeById(id); +// return Result.success(); +// } +// +// @DeleteMapping(value = "/deleteByIds") +// @ApiOperation("批量删除") +// public Result deleteByIds(String id){ +// if(StringUtils.isNotBlank(id)){ +// String[] ids = StringUtils.split(id,","); +// service.removeByIds(Arrays.asList(ids)); +// } +// return Result.success(); +// } } \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsEntryExitRecordsController.java b/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsEntryExitRecordsController.java index c6f4311..8e0c75b 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsEntryExitRecordsController.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/controller/BlArtificerSelfGoodsEntryExitRecordsController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.sqx.common.utils.Result; +import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoods; import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoodsEntryExitRecords; import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsEntryExitRecordsService; import io.swagger.annotations.Api; @@ -32,18 +33,13 @@ public class BlArtificerSelfGoodsEntryExitRecordsController { public Result list(BlArtificerSelfGoodsEntryExitRecords entity, Integer page,Integer limit){ QueryWrapper qw = new QueryWrapper<>(); -// if(entity != null) { - //价格类型 -// qw.lambda().eq(entity.getPricingType() != null, BlArtificerSelfGoodsEntryExitRecords::getPricingType, entity.getPricingType()); -// //出行方式 -// qw.lambda().eq(entity.getTravelType() != null, BlArtificerSelfGoodsEntryExitRecords::getTravelType, entity.getTravelType()); -// //时令 -// qw.lambda().eq(entity.getSeasonsType() != null, BlArtificerSelfGoodsEntryExitRecords::getSeasonsType, entity.getSeasonsType()); -// //时段 -// qw.lambda().eq(entity.getTimeIntervalType() != null, BlArtificerSelfGoodsEntryExitRecords::getTimeIntervalType, entity.getTimeIntervalType()); -// } + if(entity != null) { + //技师 + qw.lambda().eq(entity.getArtificerId() != null, BlArtificerSelfGoodsEntryExitRecords::getArtificerId, entity.getArtificerId()); + qw.lambda().eq(entity.getSelfGoodsId() != null, BlArtificerSelfGoodsEntryExitRecords::getSelfGoodsId, entity.getSelfGoodsId()); + } -// qw.orderByAsc("sort"); + qw.orderByAsc("create_time"); IPage pageList = service.page(new Page<>(page,limit),qw); return Result.success().put("data",pageList); } diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/entity/BlArtificerSelfGoods.java b/src/main/java/com/sqx/modules/artificerselfgoods/entity/BlArtificerSelfGoods.java index e0c4b63..a40cd9d 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/entity/BlArtificerSelfGoods.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/entity/BlArtificerSelfGoods.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.sqx.modules.shopping.entity.SelfGoods; import lombok.Data; import java.io.Serializable; @@ -108,4 +109,10 @@ public class BlArtificerSelfGoods implements Serializable { @TableField(exist = false) private String remark; + /** + * 商品对象 + */ + @TableField(exist = false) + private SelfGoods goods; + } \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsService.java b/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsService.java index 239fa50..1123966 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsService.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/service/BlArtificerSelfGoodsService.java @@ -95,7 +95,21 @@ public interface BlArtificerSelfGoodsService extends IService artificerSelfGoodsList); + + /** + * 修改库 + * @param artificerSelfGoods + * @return + */ + boolean editWarehouse(BlArtificerSelfGoods artificerSelfGoods); /** * 批量修改库 @@ -104,5 +118,4 @@ public interface BlArtificerSelfGoodsService extends IService artificerSelfGoodsList); - } diff --git a/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsServiceImpl.java b/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsServiceImpl.java index 563cf36..4203b01 100644 --- a/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsServiceImpl.java +++ b/src/main/java/com/sqx/modules/artificerselfgoods/service/impl/BlArtificerSelfGoodsServiceImpl.java @@ -1,16 +1,21 @@ package com.sqx.modules.artificerselfgoods.service.impl; +import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sqx.common.exception.SqxException; import com.sqx.modules.artificerselfgoods.dao.BlArtificerSelfGoodsDao; import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoods; import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsEntryExitRecordsService; import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService; +import com.sqx.modules.shopping.dao.GoodsTypeJpaRepository; +import com.sqx.modules.shopping.entity.GoodsType; import com.sqx.modules.sys.entity.SysUserEntity; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.List; @@ -25,6 +30,10 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl artificerSelfGoodsList) { artificerSelfGoodsList.forEach(this::addOrInWarehouse); return true; } - + @Transactional( rollbackFor = {Exception.class} ) @Override public boolean addWarehouse(BlArtificerSelfGoods artificerSelfGoods) { save(artificerSelfGoods); return true; } + @Transactional( rollbackFor = {Exception.class} ) @Override public boolean addWarehouse(List artificerSelfGoodsList) { artificerSelfGoodsService.saveBatch(artificerSelfGoodsList); return true; } + @Transactional( rollbackFor = {Exception.class} ) @Override public boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int changeNum) { BlArtificerSelfGoods e = getById(artificerSelfGoodsId); @@ -92,7 +105,10 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl artificerSelfGoodsList) { - artificerSelfGoodsList.forEach(x -> inWarehouse(x.getId(), x.getPurchasePrice(), x.getChangeNum())); + artificerSelfGoodsList.forEach(x -> artificerSelfGoodsService.inWarehouse(x.getId(), x.getPurchasePrice(), x.getChangeNum())); return true; } + @Transactional( rollbackFor = {Exception.class} ) @Override public boolean outWarehouse(Long artificerSelfGoodsId, int changeNum, String userId) { BlArtificerSelfGoods e = getById(artificerSelfGoodsId); @@ -114,6 +132,9 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl artificerSelfGoodsList) { - artificerSelfGoodsList.forEach(x -> outWarehouse(x.getId(), x.getChangeNum(), x.getUserId())); + artificerSelfGoodsList.forEach(x -> artificerSelfGoodsService.outWarehouse(x.getId(), x.getChangeNum(), x.getUserId())); return true; } + @Transactional( rollbackFor = {Exception.class} ) @Override - public boolean editWarehouse(Long artificerSelfGoodsId, int changeNum, String remark) { + public boolean editWarehouse(BlArtificerSelfGoods artificerSelfGoods) { + Integer changeNum = artificerSelfGoods.getChangeNum(); + String remark = artificerSelfGoods.getRemark(); + + BlArtificerSelfGoods e = findArtificerSelfGoodsByArtificerIdAndGoodsId(artificerSelfGoods.getArtificerId(), String.valueOf(artificerSelfGoods.getSelfGoodsId())); + if(e == null) { + //新增 + //查询type的pid +// Specification goodsTypeQc = (root, criteriaQuery, criteriaBuilder) -> { +// List predicateList = new ArrayList<>(); +// predicateList.add(criteriaBuilder.equal(root.get("parentId"), "56"),criteriaBuilder.equal(root.get("id"), "56"))); +// return criteriaBuilder.and(predicateList.toArray(new Predicate[0])); +// }; + GoodsType materialTypes = goodsJpaTypeRepository.getById(Long.valueOf(artificerSelfGoods.getGoods().getTypeId())); + + + BlArtificerSelfGoods addData = new BlArtificerSelfGoods(); + + addData.setCreateTime(DateUtil.now()); + addData.setUpdateTime(DateUtil.now()); + addData.setCreateAt(getUser().getUsername()); + addData.setUpdateAt(getUser().getUsername()); + + addData.setSelfGoodsId(artificerSelfGoods.getGoods().getId()); + addData.setSelfGoodsTitle(artificerSelfGoods.getGoods().getTitle()); + addData.setSelfGoodsTypeId(artificerSelfGoods.getGoods().getTypeId()); + addData.setSelfGoodsTypeParentId(String.valueOf(materialTypes.getParentId())); + addData.setArtificerId(artificerSelfGoods.getArtificerId()); + addData.setNum(artificerSelfGoods.getChangeNum()); + addData.setChangeNum(artificerSelfGoods.getChangeNum()); + addData.setRemark(artificerSelfGoods.getRemark()); + + save(addData); + artificerSelfGoodsEntryExitRecordsService.editLog(addData, getUser().getUsername(), null, null, changeNum, remark); + } else { + e.setUpdateTime(DateUtil.now()); + e.setUpdateAt(getUser().getUsername()); + //修改 + Integer afterTheChangeNum = e.getNum(); + e.setLastTimeChangeNum(changeNum); + e.setLastTimeNum(e.getNum()); + Integer beforeTheChangeNum = afterTheChangeNum + changeNum; + if(beforeTheChangeNum < 0){ + throw new SqxException("不可修改为负库存!"); + } + e.setNum(beforeTheChangeNum); + updateById(e); + //记录日志 + artificerSelfGoodsEntryExitRecordsService.editLog(e, getUser().getUsername(), afterTheChangeNum, beforeTheChangeNum, changeNum, remark); + } + return true; + } + + @Transactional( rollbackFor = {Exception.class} ) + @Override + public boolean editWarehouse(List artificerSelfGoodsList) { + artificerSelfGoodsList.forEach(this::editWarehouse); + return true; + } + + @Transactional( rollbackFor = {Exception.class} ) + @Override + public boolean editWarehouseById(Long artificerSelfGoodsId, int changeNum, String remark) { BlArtificerSelfGoods e = getById(artificerSelfGoodsId); if(e == null) return false; Integer afterTheChangeNum = e.getNum(); e.setLastTimeChangeNum(changeNum); e.setLastTimeNum(e.getNum()); - Integer beforeTheChangeNum = afterTheChangeNum - changeNum; + Integer beforeTheChangeNum = afterTheChangeNum + changeNum; + if(beforeTheChangeNum < 0){ + throw new SqxException("不可修改为负库存!"); + } e.setNum(beforeTheChangeNum); updateById(e); //记录日志 @@ -142,9 +230,11 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl artificerSelfGoodsList) { - artificerSelfGoodsList.forEach(x -> editWarehouse(x.getId(), x.getChangeNum(), x.getRemark())); + public boolean editWarehouseById(List artificerSelfGoodsList) { + artificerSelfGoodsList.forEach(x -> artificerSelfGoodsService.editWarehouseById(x.getId(), x.getChangeNum(), x.getRemark())); return true; } + } diff --git a/src/main/java/com/sqx/modules/common/enums/CommonEnum.java b/src/main/java/com/sqx/modules/common/enums/CommonEnum.java index 06a3db9..0c31ca3 100644 --- a/src/main/java/com/sqx/modules/common/enums/CommonEnum.java +++ b/src/main/java/com/sqx/modules/common/enums/CommonEnum.java @@ -49,9 +49,9 @@ public enum CommonEnum { this.defValue = defValue; } - private boolean defValueIsEmpty() { - return CommonConfigUtil.defValueIsEmpty(this.defValue); - } +// private boolean defValueIsEmpty() { +// return CommonConfigUtil.defValueIsEmpty(this.defValue); +// } public Integer getIntValue() { @@ -148,7 +148,7 @@ public enum CommonEnum { V3_TRAVEL_CONF("v3_travel_conf"); - private String value; + private final String value; GroupConditionEnum(String value){ this.value = value; } diff --git a/src/main/java/com/sqx/modules/common/service/CommonInfoService.java b/src/main/java/com/sqx/modules/common/service/CommonInfoService.java index 8665793..9e4f9b0 100644 --- a/src/main/java/com/sqx/modules/common/service/CommonInfoService.java +++ b/src/main/java/com/sqx/modules/common/service/CommonInfoService.java @@ -5,6 +5,7 @@ import com.sqx.modules.common.entity.ArtificerPartitioningDetails; import com.sqx.modules.common.entity.CommonInfo; import com.sqx.modules.common.enums.CommonEnum; +import java.util.Date; import java.util.List; import java.util.Map; @@ -77,19 +78,20 @@ public interface CommonInfoService { boolean updateGroup(List infos); + Map getMapByCondition(String condition); + /** * 是否可以修改订单 * @return */ - boolean isCheckChangeOrder(); + CommonInfo isCheckChangeOrder(Date businessTime, Date nowTime); /** * 是否可以编辑订单 * @return */ - boolean isCheckEditOrder(); + boolean isCheckEditOrder(Date businessTime, Date nowTime); List getV3OrderForm(); - Map getMaoByCondition(String condition); } \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/common/service/impl/CommonInfoServiceImpl.java b/src/main/java/com/sqx/modules/common/service/impl/CommonInfoServiceImpl.java index bacefd3..f0db449 100644 --- a/src/main/java/com/sqx/modules/common/service/impl/CommonInfoServiceImpl.java +++ b/src/main/java/com/sqx/modules/common/service/impl/CommonInfoServiceImpl.java @@ -1,5 +1,7 @@ package com.sqx.modules.common.service.impl; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -12,6 +14,7 @@ import com.sqx.modules.common.entity.ArtificerPartitioningDetails; import com.sqx.modules.common.entity.CommonInfo; import com.sqx.modules.common.enums.CommonEnum; import com.sqx.modules.common.service.CommonInfoService; +import com.sqx.modules.common.utils.CommonConfigUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -130,7 +133,7 @@ public class CommonInfoServiceImpl extends ServiceImpl getMaoByCondition(String condition) { + public Map getMapByCondition(String condition) { List commonInfoList = commonInfoDao.findByCondition(condition); Map commonInfoMap = Maps.newHashMap(); commonInfoList.forEach(x -> commonInfoMap.put(x.getType(), x)); @@ -138,13 +141,86 @@ public class CommonInfoServiceImpl extends ServiceImpl configMap = getMapByCondition(CommonEnum.GroupConditionEnum.V3_ORDER_FORM.getValue()); + + CommonInfo defCommonInfo = new CommonInfo(); + + if(bnDiffDay >= 0) { + //正数 开始前 + //距离服务开始n个小时以上免费取消 - 4 + CommonInfo v3OrderFormCancelNotStart01 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_NOT_START_01.getKey(), defCommonInfo); + Double v3OrderFormCancelNotStart01D = CommonConfigUtil.getDoubleValue(v3OrderFormCancelNotStart01.getValue()); + if(v3OrderFormCancelNotStart01D == null) v3OrderFormCancelNotStart01D = -1D; + //距离服务开始前取消n-n个小时内,收取n元 - 1.5,4,10 + CommonInfo v3OrderFormCancelNotStart02 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_NOT_START_02.getKey(), defCommonInfo); + String[] v3OrderFormCancelNotStart02A = CommonConfigUtil.getArrayValue(v3OrderFormCancelNotStart01.getValue()); + if(v3OrderFormCancelNotStart02A == null) v3OrderFormCancelNotStart02A = new String[]{ "-1","4","10" }; + double v3OrderFormCancelNotStart02D = Double.parseDouble(v3OrderFormCancelNotStart02A[0]); + //距离服务开始前取消少于n个小时内,收取n元 -1.5,30 + CommonInfo v3OrderFormCancelNotStart03 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_NOT_START_03.getKey(), defCommonInfo); + String[] v3OrderFormCancelNotStart03A = CommonConfigUtil.getArrayValue(v3OrderFormCancelNotStart01.getValue()); + if(v3OrderFormCancelNotStart03A == null) v3OrderFormCancelNotStart03A = new String[]{ "-1","30" }; + double v3OrderFormCancelNotStart03D = Double.parseDouble(v3OrderFormCancelNotStart03A[0]); + + if(bnDiffDay > v3OrderFormCancelNotStart01D && v3OrderFormCancelNotStart01D != -1){ + //外面的 + return v3OrderFormCancelNotStart01; + } else if(bnDiffDay <= v3OrderFormCancelNotStart01D && bnDiffDay >= v3OrderFormCancelNotStart02D && v3OrderFormCancelNotStart02D != -1){ + return v3OrderFormCancelNotStart02; + } else if(bnDiffDay < v3OrderFormCancelNotStart02D && bnDiffDay >= v3OrderFormCancelNotStart03D && v3OrderFormCancelNotStart03D != -1){ + return v3OrderFormCancelNotStart03; + } else if(v3OrderFormCancelNotStart03D > bnDiffDay){ + return v3OrderFormCancelNotStart03; + } + } else { + //负数,开始后 + long bnDiffMinute = DateUtil.between(businessTime, nowTime, DateUnit.MINUTE, false); + //服务开始n分钟内取消订单,扣项目费用n%,车费全扣n%; - 15,50,100 + CommonInfo v3OrderFormCancelStart01 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_START_01.getKey(), defCommonInfo); + String[] v3OrderFormCancelStart01A = CommonConfigUtil.getArrayValue(v3OrderFormCancelStart01.getValue()); + if(v3OrderFormCancelStart01A == null) v3OrderFormCancelStart01A = new String[]{ "-1","0","0" }; + double v3OrderFormCancelStart01I = Double.parseDouble(v3OrderFormCancelStart01A[0]); + //服务开始n分钟后不可以取消订单 - 15 + CommonInfo v3OrderFormCancelStart02 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_START_02.getKey(), defCommonInfo); + Double v3OrderFormCancelStart02I = CommonConfigUtil.getDoubleValue(v3OrderFormCancelStart02.getValue()); + if(v3OrderFormCancelStart02I == null) v3OrderFormCancelStart02I = -1D; + + if(bnDiffMinute <= v3OrderFormCancelStart01I) { + return v3OrderFormCancelStart01; + } else if(bnDiffMinute >= v3OrderFormCancelStart02I){ + return v3OrderFormCancelStart02; + } + } + return defCommonInfo; } @Override - public boolean isCheckEditOrder() { - return false; + public boolean isCheckEditOrder(Date businessTime, Date nowTime) { + long bnDiffDay = DateUtil.between(businessTime, nowTime, DateUnit.DAY, false); + Map configMap = getMapByCondition(CommonEnum.GroupConditionEnum.V3_ORDER_FORM.getValue()); + + //距离服务开始前n个小时可修改 - 2 + CommonInfo v3OrderFormEditNotStart01 = configMap.get(CommonEnum.V3_ORDER_FORM_EDIT_NOT_START_01.getKey()); + //距离服务开始n个小时内不可修改 - 2 + CommonInfo v3OrderFormEditNotStart02 = configMap.get(CommonEnum.V3_ORDER_FORM_EDIT_NOT_START_02.getKey()); + + Double v3OrderFormEditNotStart01I = CommonConfigUtil.getDoubleValue(v3OrderFormEditNotStart01.getValue()); + if(v3OrderFormEditNotStart01I == null) v3OrderFormEditNotStart01I = -1D; + Double v3OrderFormEditNotStart02I = CommonConfigUtil.getDoubleValue(v3OrderFormEditNotStart02.getValue()); + if(v3OrderFormEditNotStart02I == null) v3OrderFormEditNotStart02I = -1D; + + if(bnDiffDay >= 0) { + //正数,服务开始前 + if(v3OrderFormEditNotStart01I == -1) return true; + return bnDiffDay >= v3OrderFormEditNotStart01I; + } else { + //负数,服务开始后 + if(v3OrderFormEditNotStart02I == -1) return true; + double burdenV3OrderFormEditNotStart02I = - v3OrderFormEditNotStart02I; + return burdenV3OrderFormEditNotStart02I >= bnDiffDay; + } } diff --git a/src/main/java/com/sqx/modules/common/utils/CommonConfigUtil.java b/src/main/java/com/sqx/modules/common/utils/CommonConfigUtil.java index bba3f5c..7d21cfc 100644 --- a/src/main/java/com/sqx/modules/common/utils/CommonConfigUtil.java +++ b/src/main/java/com/sqx/modules/common/utils/CommonConfigUtil.java @@ -27,7 +27,7 @@ public class CommonConfigUtil { /** - * 转为Long类型 + * 转为Integer类型 * @param value 转换的值 * @return 转换后的值 */ diff --git a/src/main/java/com/sqx/modules/shopping/controller/GoodsController.java b/src/main/java/com/sqx/modules/shopping/controller/GoodsController.java index f626031..8783732 100644 --- a/src/main/java/com/sqx/modules/shopping/controller/GoodsController.java +++ b/src/main/java/com/sqx/modules/shopping/controller/GoodsController.java @@ -27,9 +27,10 @@ public class GoodsController { public Result findAll(Integer page, Integer size, @ApiParam("商品标题:可搜索")@RequestParam(required = false) String title, @ApiParam("商品类型:类型名称")@RequestParam(required = false) String type, + @ApiParam("商品类型:一级类型类型id")@RequestParam(required = false) String pTypeId, @ApiParam("商品状态:0全部 1上架 2下架")@RequestParam(required = false) Integer status, @ApiParam("是否积分商品:1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) { - return service.findAll(page, size, title, type, status, isJiFenGoods); + return service.findAll(page, size, title, type, pTypeId, status, isJiFenGoods); } @GetMapping("/selectListByType") diff --git a/src/main/java/com/sqx/modules/shopping/service/GoodsService.java b/src/main/java/com/sqx/modules/shopping/service/GoodsService.java index 9ca0b32..923bb39 100644 --- a/src/main/java/com/sqx/modules/shopping/service/GoodsService.java +++ b/src/main/java/com/sqx/modules/shopping/service/GoodsService.java @@ -8,6 +8,8 @@ public interface GoodsService { //后台管理商品列表 Result findAll(Integer page, Integer size, String title, String type, Integer status, Integer isJiFenGoods); + Result findAll(Integer page, Integer size, String title, String type, String pTypeId, Integer status, Integer isJiFenGoods); + //虚拟商品列表 Result goodsVirtualList(Integer page, Integer size, String title, String type, Integer status, Integer isExpress, Integer isJiFenGoods); diff --git a/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsServiceImpl.java b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsServiceImpl.java index 7ff653a..979f90b 100644 --- a/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsServiceImpl.java +++ b/src/main/java/com/sqx/modules/shopping/service/impl/SelfGoodsServiceImpl.java @@ -48,7 +48,6 @@ public class SelfGoodsServiceImpl implements GoodsService { @Autowired private SelfGoodsBrandJpaRepository selfGoodsBrandJpaRepository; - /** * 后台管理商品列表、创建时间排序 * @param page 页数 @@ -58,32 +57,68 @@ public class SelfGoodsServiceImpl implements GoodsService { * @param status 状态 * @return */ - @Override public Result findAll(Integer page, Integer size, String title, String type, Integer status, Integer isJiFenGoods) { - //按照时间排序 - Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt"))); - //构造自定义查询条件 - Specification queryCondition = new Specification() { - @Override - public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + return findAll(page, size, title, type, null, status, isJiFenGoods); + } + + /** + * 后台管理商品列表、创建时间排序 + * @param page 页数 + * @param size 条数 + * @param title 标题:模糊查询 + * @param type 类型 + * @param pTypeId 一级类型 + * @param status 状态 + * @return + */ + @Override + public Result findAll(Integer page, Integer size, String title, String type, String pTypeId, Integer status, Integer isJiFenGoods) { + //先查询类型 + List goodsTypeList; + if(StringUtils.isNotBlank(pTypeId)){ + Specification goodsTypeQc = (root, criteriaQuery, criteriaBuilder) -> { List predicateList = new ArrayList<>(); - if (StringUtils.isNotEmpty(title)) { - predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + predicateList.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("parentId"), pTypeId),criteriaBuilder.equal(root.get("id"), pTypeId))); + return criteriaBuilder.and(predicateList.toArray(new Predicate[0])); + }; + goodsTypeList = goodsJpaTypeRepository.findAll(goodsTypeQc); + } else { + goodsTypeList = null; + } + //按照时间排序 + Pageable pageable; + if(size == -1){ + pageable = PageRequest.of(page, Integer.MAX_VALUE, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt"))); + } else { + pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt"))); + } + //构造自定义查询条件 + Specification queryCondition = (root, criteriaQuery, criteriaBuilder) -> { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(title)) { + predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + } + if (StringUtils.isNotEmpty(type)) { + predicateList.add(criteriaBuilder.equal(root.get("typeId"), type)); + } + if(StringUtils.isNotBlank(pTypeId)) { + //goodsTypeList + CriteriaBuilder.In in = criteriaBuilder.in(root.get("typeId")); + if(goodsTypeList != null && !goodsTypeList.isEmpty()) { + goodsTypeList.forEach(x -> in.value(x.getId())); } - if (StringUtils.isNotEmpty(type)) { - predicateList.add(criteriaBuilder.equal(root.get("typeId"), type)); - } - if (status != 0) { - predicateList.add(criteriaBuilder.equal(root.get("status"), status)); - } - if (isJiFenGoods != null) { - predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods)); - }else { - predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); - } - return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); + predicateList.add(in); } - }; + if (status != 0) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + if (isJiFenGoods != null) { + predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods)); + }else { + predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[0])); + }; //处理数据:商品分类 Page all = jpaRepository.findAll(queryCondition, pageable); List list = all.getContent(); @@ -102,38 +137,32 @@ public class SelfGoodsServiceImpl implements GoodsService { @Override public Result selectListByType(String title, String type, Integer status, Integer isJiFenGoods) { //构造自定义查询条件 - Specification queryCondition1 = new Specification() { - @Override - public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { - List predicateList = new ArrayList<>(); - predicateList.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("parentId"), "56"),criteriaBuilder.equal(root.get("id"), "56"))); - return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); - } - }; + Specification queryCondition1 = (root, criteriaQuery, criteriaBuilder) -> { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("parentId"), "56"),criteriaBuilder.equal(root.get("id"), "56"))); + return criteriaBuilder.and(predicateList.toArray(new Predicate[0])); + }; List materialTypes = goodsJpaTypeRepository.findAll(queryCondition1); - Specification queryCondition = new Specification() { - @Override - public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { - List predicateList = new ArrayList<>(); - if (StringUtils.isNotEmpty(title)) { - predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); - } - CriteriaBuilder.In in = criteriaBuilder.in(root.get("typeId")); - for(GoodsType goodsType:materialTypes) { - in.value(goodsType.getId()); - } - predicateList.add(in); - if (ObjectUtil.isNotEmpty(status)) { - predicateList.add(criteriaBuilder.equal(root.get("status"), status)); - } - if (ObjectUtil.isNotEmpty(isJiFenGoods)) { - predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods)); - }else { - predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); - } - return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); - } - }; + Specification queryCondition = (root, criteriaQuery, criteriaBuilder) -> { + List predicateList = new ArrayList<>(); + if (StringUtils.isNotEmpty(title)) { + predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%")); + } + CriteriaBuilder.In in = criteriaBuilder.in(root.get("typeId")); + for(GoodsType goodsType:materialTypes) { + in.value(goodsType.getId()); + } + predicateList.add(in); + if (ObjectUtil.isNotEmpty(status)) { + predicateList.add(criteriaBuilder.equal(root.get("status"), status)); + } + if (ObjectUtil.isNotEmpty(isJiFenGoods)) { + predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods)); + }else { + predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods"))); + } + return criteriaBuilder.and(predicateList.toArray(new Predicate[0])); + }; //处理数据:商品分类 List all = jpaRepository.findAll(queryCondition); for (SelfGoods g : all) { diff --git a/src/main/java/com/sqx/modules/travelconf/service/impl/TravelConfServiceImpl.java b/src/main/java/com/sqx/modules/travelconf/service/impl/TravelConfServiceImpl.java index bc43735..12ed011 100644 --- a/src/main/java/com/sqx/modules/travelconf/service/impl/TravelConfServiceImpl.java +++ b/src/main/java/com/sqx/modules/travelconf/service/impl/TravelConfServiceImpl.java @@ -40,7 +40,7 @@ public class TravelConfServiceImpl extends ServiceImpl commonInfoMap = commonInfoService.getMaoByCondition(CommonEnum.GroupConditionEnum.V3_TRAVEL_CONF.getValue()); + Map commonInfoMap = commonInfoService.getMapByCondition(CommonEnum.GroupConditionEnum.V3_TRAVEL_CONF.getValue()); //夏令时段 CommonInfo daylightSavingTime = commonInfoMap.get(CommonEnum.V3_TRAVEL_CONF_DAYLIGHT_SAVING_TIME.getKey());