|
@@ -12,6 +12,7 @@
|
|
|
*/
|
|
|
package vip.xiaonuo.biz.modular.bizappointmentrecord.service.impl;
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollStreamUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
@@ -27,16 +28,21 @@ import org.apache.commons.compress.utils.Lists;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
import vip.xiaonuo.biz.modular.bizappointmentrecord.param.*;
|
|
|
import vip.xiaonuo.biz.modular.bizappointmenttime.entity.BizAppointmentTime;
|
|
|
import vip.xiaonuo.biz.modular.bizappointmenttime.service.BizAppointmentTimeService;
|
|
|
import vip.xiaonuo.biz.modular.bizconfig.entity.BizConfig;
|
|
|
import vip.xiaonuo.biz.modular.bizconfig.service.BizConfigService;
|
|
|
+import vip.xiaonuo.biz.modular.bizexcessconfig.entity.BizExcessConfig;
|
|
|
+import vip.xiaonuo.biz.modular.bizexcessconfig.service.BizExcessConfigService;
|
|
|
import vip.xiaonuo.biz.modular.bizorder.entity.BizOrder;
|
|
|
import vip.xiaonuo.biz.modular.bizorder.param.BizOrderExportResult;
|
|
|
import vip.xiaonuo.biz.modular.bizorder.service.BizOrderService;
|
|
|
import vip.xiaonuo.biz.modular.goods.entity.BizGoods;
|
|
|
import vip.xiaonuo.biz.modular.goods.service.BizGoodsService;
|
|
|
+import vip.xiaonuo.biz.modular.goodsConf.entity.BizGoodsConf;
|
|
|
+import vip.xiaonuo.biz.modular.goodsConf.service.BizGoodsConfService;
|
|
|
import vip.xiaonuo.biz.modular.record.entity.BizRecord;
|
|
|
import vip.xiaonuo.biz.modular.record.service.BizRecordService;
|
|
|
import vip.xiaonuo.biz.modular.utils.CommonExportUtil;
|
|
@@ -48,6 +54,7 @@ import vip.xiaonuo.biz.modular.bizappointmentrecord.mapper.BizAppointmentRecordM
|
|
|
import vip.xiaonuo.biz.modular.bizappointmentrecord.service.BizAppointmentRecordService;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
@@ -72,6 +79,10 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
private BizGoodsService bizGoodsService;
|
|
|
@Resource
|
|
|
private BizRecordService bizRecordService;
|
|
|
+ @Resource
|
|
|
+ private BizExcessConfigService bizExcessConfigService;
|
|
|
+ @Resource
|
|
|
+ private BizGoodsConfService bizGoodsConfService;
|
|
|
|
|
|
@Override
|
|
|
public Page<BizAppointmentRecord> page(BizAppointmentRecordPageParam bizAppointmentRecordPageParam) {
|
|
@@ -109,6 +120,11 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
if(ObjectUtil.isNotEmpty(bizAppointmentRecordPageParam.getAppointmentFlag())){
|
|
|
queryWrapper.notIn("bar.status","1","2");
|
|
|
}
|
|
|
+ // 校验数据范围
|
|
|
+ List<String> loginUserDataScope = StpLoginUserUtil.getLoginUserDataScope();
|
|
|
+ if(ObjectUtil.isEmpty(loginUserDataScope)) {
|
|
|
+ queryWrapper.eq("bar.create_user", StpUtil.getLoginIdAsString());
|
|
|
+ }
|
|
|
queryWrapper.eq("bar.delete_flag","NOT_DELETE");
|
|
|
queryWrapper.orderByDesc("bar.create_time");
|
|
|
return queryWrapper;
|
|
@@ -121,6 +137,7 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
//获取流程配置判断预约是否需要审核
|
|
|
BizConfig bizConfig = bizConfigService.getOne(new QueryWrapper<BizConfig>().lambda().last("limit 1"));
|
|
|
BizAppointmentRecord bizAppointmentRecord = BeanUtil.toBean(bizAppointmentRecordAddParam, BizAppointmentRecord.class);
|
|
|
+ bizAppointmentRecord.setTimeId(bizOrderService.queryEntity(bizAppointmentRecordAddParam.getOrderId()).getDeliveryTimeId());
|
|
|
if(ObjectUtil.isNotNull(bizConfig)){
|
|
|
if(StringUtils.equals(bizConfig.getAuditSwitch(),"1")){
|
|
|
//开启审核,设置待审核状态
|
|
@@ -132,12 +149,16 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
}
|
|
|
this.save(bizAppointmentRecord);
|
|
|
|
|
|
+ BizOrder bizOrder = bizOrderService.getById(bizAppointmentRecordAddParam.getOrderId());
|
|
|
+ bizOrder.setOrderStatus("4");
|
|
|
+ bizOrderService.updateById(bizOrder);
|
|
|
+
|
|
|
//更新时间段内已预约数
|
|
|
- BizAppointmentTime bizAppointmentTime = bizAppointmentTimeService.getById(bizAppointmentRecordAddParam.getTimeId());
|
|
|
+ /*BizAppointmentTime bizAppointmentTime = bizAppointmentTimeService.getById(bizAppointmentRecordAddParam.getTimeId());
|
|
|
if(ObjectUtil.isNotNull(bizAppointmentTime)){
|
|
|
bizAppointmentTime.setApplyNumberAlready(bizAppointmentTime.getApplyNumberAlready()+1);
|
|
|
bizAppointmentTimeService.updateById(bizAppointmentTime);
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
public void checkParam(BizAppointmentRecordAddParam bizAppointmentRecordAddParam){
|
|
@@ -149,7 +170,7 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
//校验车牌号是否添加过预约,排除11:已签收、 13:销售已审核 、 14:已取消
|
|
|
long count = this.count(new QueryWrapper<BizAppointmentRecord>().lambda().
|
|
|
eq(BizAppointmentRecord::getLicenseNumber,bizAppointmentRecordAddParam.getLicenseNumber().toUpperCase().trim()).
|
|
|
- notIn(BizAppointmentRecord::getStatus, "11", "13", "14"));
|
|
|
+ notIn(BizAppointmentRecord::getStatus, "11", "13", "14","15"));
|
|
|
if(count>0){
|
|
|
throw new CommonException("车牌号:{}已经添加过预约!",bizAppointmentRecordAddParam.getLicenseNumber().toUpperCase().trim());
|
|
|
}
|
|
@@ -160,7 +181,22 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
throw new CommonException("手机号码:{}格式错误", bizAppointmentRecordAddParam.getDriverMobile());
|
|
|
}
|
|
|
}
|
|
|
- if(ObjectUtil.isNotEmpty(bizAppointmentRecordAddParam.getTimeId())){
|
|
|
+ //校验订单
|
|
|
+ if(ObjectUtil.isNotEmpty(bizAppointmentRecordAddParam.getOrderId())){
|
|
|
+ BizOrder bizOrder = bizOrderService.getById(bizAppointmentRecordAddParam.getOrderId());
|
|
|
+ if(ObjectUtil.isNotNull(bizOrder)){
|
|
|
+ if(!StringUtils.equals(bizOrder.getOrderStatus(),"3") && !StringUtils.equals(bizOrder.getOrderStatus(),"4")){
|
|
|
+ throw new CommonException("当前订单不可预约!");
|
|
|
+ }
|
|
|
+ BizGoodsConf bizGoodsConf = bizGoodsConfService.getById(bizOrder.getDeliveryTimeId());
|
|
|
+ if(ObjectUtil.isNotNull(bizGoodsConf)){
|
|
|
+ if(new Date().getTime() > bizGoodsConf.getConfEndTime().getTime()){
|
|
|
+ throw new CommonException("提货时间段已过,不可预约!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*if(ObjectUtil.isNotEmpty(bizAppointmentRecordAddParam.getTimeId())){
|
|
|
//校验预约时间段是否预约满
|
|
|
//查询预约时间段内的预约记录,10:已出场 11:已签收 12:自动审核 13:销售已审核 14:已取消这些状态都占用预约名额
|
|
|
long count = this.count(new QueryWrapper<BizAppointmentRecord>().lambda().
|
|
@@ -171,7 +207,7 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
if(count>=bizAppointmentTime.getApplyNumber()){
|
|
|
throw new CommonException("该时间段已经预约满!");
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
}
|
|
|
|
|
@@ -186,7 +222,7 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
//校验车牌号是否添加过预约,排除11:已签收、 13:销售已审核 、 14:已取消
|
|
|
long count = this.count(new QueryWrapper<BizAppointmentRecord>().lambda().
|
|
|
eq(BizAppointmentRecord::getLicenseNumber,bizAppointmentRecordEditParam.getLicenseNumber().toUpperCase().trim()).
|
|
|
- notIn(BizAppointmentRecord::getStatus, "11", "13", "14"));
|
|
|
+ notIn(BizAppointmentRecord::getStatus, "11", "13", "14","15"));
|
|
|
if(count>0){
|
|
|
throw new CommonException("车牌号:{}已经添加过预约!",bizAppointmentRecordEditParam.getLicenseNumber().toUpperCase().trim());
|
|
|
}
|
|
@@ -198,7 +234,22 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
throw new CommonException("手机号码:{}格式错误", bizAppointmentRecordEditParam.getDriverMobile());
|
|
|
}
|
|
|
}
|
|
|
- if(ObjectUtil.isNotEmpty(bizAppointmentRecordEditParam.getTimeId())){
|
|
|
+ //校验订单
|
|
|
+ if(ObjectUtil.isNotEmpty(bizAppointmentRecordEditParam.getOrderId())){
|
|
|
+ BizOrder bizOrder = bizOrderService.getById(bizAppointmentRecordEditParam.getOrderId());
|
|
|
+ if(ObjectUtil.isNotNull(bizOrder)){
|
|
|
+ if(!StringUtils.equals(bizOrder.getOrderStatus(),"3") && !StringUtils.equals(bizOrder.getOrderStatus(),"4")){
|
|
|
+ throw new CommonException("当前订单不可预约!");
|
|
|
+ }
|
|
|
+ BizGoodsConf bizGoodsConf = bizGoodsConfService.getById(bizOrder.getDeliveryTimeId());
|
|
|
+ if(ObjectUtil.isNotNull(bizGoodsConf)){
|
|
|
+ if(new Date().getTime() > bizGoodsConf.getConfEndTime().getTime()){
|
|
|
+ throw new CommonException("提货时间段已过,不可预约!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*if(ObjectUtil.isNotEmpty(bizAppointmentRecordEditParam.getTimeId())){
|
|
|
if(!StringUtils.equals(bizAppointmentRecord.getTimeId(),bizAppointmentRecordEditParam.getTimeId())){
|
|
|
//校验预约时间段是否预约满
|
|
|
//查询预约时间段内的预约记录,10:已出场 11:已签收 12:自动审核 13:销售已审核 14:已取消这些状态都占用预约名额
|
|
@@ -212,7 +263,7 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
}
|
|
|
|
|
@@ -221,7 +272,7 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
public void edit(BizAppointmentRecordEditParam bizAppointmentRecordEditParam) {
|
|
|
BizAppointmentRecord bizAppointmentRecord = this.queryEntity(bizAppointmentRecordEditParam.getId());
|
|
|
checkParam(bizAppointmentRecordEditParam,bizAppointmentRecord);
|
|
|
- if(!StringUtils.equals(bizAppointmentRecord.getTimeId(),bizAppointmentRecordEditParam.getTimeId())){
|
|
|
+ /*if(!StringUtils.equals(bizAppointmentRecord.getTimeId(),bizAppointmentRecordEditParam.getTimeId())){
|
|
|
//调整了预约时段,释放之前预约时段的预约次数
|
|
|
BizAppointmentTime bizAppointmentTime = bizAppointmentTimeService.getById(bizAppointmentRecord.getTimeId());
|
|
|
bizAppointmentTime.setApplyNumberAlready(bizAppointmentTime.getApplyNumberAlready()-1);
|
|
@@ -231,6 +282,9 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
BizAppointmentTime time = bizAppointmentTimeService.getById(bizAppointmentRecordEditParam.getTimeId());
|
|
|
time.setApplyNumberAlready(time.getApplyNumberAlready()+1);
|
|
|
bizAppointmentTimeService.updateById(time);
|
|
|
+ }*/
|
|
|
+ if(!StringUtils.equals(bizAppointmentRecord.getOrderId(),bizAppointmentRecordEditParam.getOrderId())){
|
|
|
+ bizAppointmentRecordEditParam.setTimeId(bizOrderService.queryEntity(bizAppointmentRecordEditParam.getOrderId()).getDeliveryTimeId());
|
|
|
}
|
|
|
BeanUtil.copyProperties(bizAppointmentRecordEditParam, bizAppointmentRecord);
|
|
|
if(StringUtils.equals(bizAppointmentRecord.getStatus(),"2")){
|
|
@@ -244,14 +298,14 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
@Override
|
|
|
public void delete(List<BizAppointmentRecordIdParam> bizAppointmentRecordIdParamList) {
|
|
|
//释放预约数
|
|
|
- for(BizAppointmentRecordIdParam bizAppointmentRecordIdParam : bizAppointmentRecordIdParamList){
|
|
|
+ /*for(BizAppointmentRecordIdParam bizAppointmentRecordIdParam : bizAppointmentRecordIdParamList){
|
|
|
BizAppointmentRecord bizAppointmentRecord = this.queryEntity(bizAppointmentRecordIdParam.getId());
|
|
|
BizAppointmentTime bizAppointmentTime = bizAppointmentTimeService.getById(bizAppointmentRecord.getTimeId());
|
|
|
if(ObjectUtil.isNotNull(bizAppointmentTime)){
|
|
|
bizAppointmentTime.setApplyNumberAlready(bizAppointmentTime.getApplyNumberAlready()-1);
|
|
|
bizAppointmentTimeService.updateById(bizAppointmentTime);
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
// 执行删除
|
|
|
this.removeByIds(CollStreamUtil.toList(bizAppointmentRecordIdParamList, BizAppointmentRecordIdParam::getId));
|
|
|
}
|
|
@@ -353,11 +407,11 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
this.updateById(bizAppointmentRecord);
|
|
|
|
|
|
//释放预约数
|
|
|
- BizAppointmentTime bizAppointmentTime = bizAppointmentTimeService.getById(bizAppointmentRecord.getTimeId());
|
|
|
+ /*BizAppointmentTime bizAppointmentTime = bizAppointmentTimeService.getById(bizAppointmentRecord.getTimeId());
|
|
|
if(ObjectUtil.isNotNull(bizAppointmentTime)){
|
|
|
bizAppointmentTime.setApplyNumberAlready(bizAppointmentTime.getApplyNumberAlready()-1);
|
|
|
bizAppointmentTimeService.updateById(bizAppointmentTime);
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
@@ -393,11 +447,26 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public BizAppointmentRecord getAppointmentRecord(BizAppointmentRecordPageParam bizAppointmentRecordPageParam) {
|
|
|
+ QueryWrapper<BizAppointmentRecord> queryWrapper = new QueryWrapper<>();
|
|
|
+ if(ObjectUtil.isNotEmpty(bizAppointmentRecordPageParam.getDateNow())){
|
|
|
+ queryWrapper.ge("bgc.CONF_START_TIME",bizAppointmentRecordPageParam.getDateNow());
|
|
|
+ queryWrapper.lt("bgc.CONF_END_TIME",bizAppointmentRecordPageParam.getDateNow());
|
|
|
+ }
|
|
|
+ queryWrapper.eq("bar.delete_flag","NOT_DELETE");
|
|
|
+ queryWrapper.orderByAsc("bar.create_time");
|
|
|
+ queryWrapper.last("limit 1");
|
|
|
+ //BizAppointmentRecord record = this.getBaseMapper().getRecord(queryWrapper);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
public BizAppointmentRecord setBizAppointmentRecord(BizAppointmentRecord bizAppointmentRecord){
|
|
|
bizAppointmentRecord.setIsFlag("1");
|
|
|
if(ObjectUtil.isNotEmpty(bizAppointmentRecord.getOrderId())){
|
|
|
BizOrder bizOrder = bizOrderService.getById(bizAppointmentRecord.getOrderId());
|
|
|
if(ObjectUtil.isNotNull(bizOrder)){
|
|
|
+ bizAppointmentRecord.setOrderBalance(bizOrder.getOrderWeight().subtract(bizOrder.getNetWeight()));
|
|
|
if(ObjectUtil.isNotEmpty(bizOrder.getGoodId())){
|
|
|
BizGoods bizGoods = bizGoodsService.getById(bizOrder.getGoodId());
|
|
|
if(ObjectUtil.isNotNull(bizGoods)){
|
|
@@ -407,6 +476,16 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if(ObjectUtil.isNotEmpty(bizAppointmentRecord.getOverId())){
|
|
|
+ BizExcessConfig excessConfig = bizExcessConfigService.getById(bizAppointmentRecord.getOverId());
|
|
|
+ if(ObjectUtil.isNotNull(excessConfig)){
|
|
|
+ bizAppointmentRecord.setOverWeight(excessConfig.getExcessWeight());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BizConfig bizConfig = bizConfigService.getOne(new QueryWrapper<BizConfig>().lambda().last("limit 1"));
|
|
|
+ if(ObjectUtil.isNotNull(bizConfig)){
|
|
|
+ bizAppointmentRecord.setOrderWeightSwitch(bizConfig.getOrderWeightSwitch());
|
|
|
+ }
|
|
|
return bizAppointmentRecord;
|
|
|
}
|
|
|
|