提交 f48623c7 authored 作者: huyufan's avatar huyufan

Merge remote-tracking branch 'origin/v4.9_create_goods_child_20230918' into…

Merge remote-tracking branch 'origin/v4.9_create_goods_child_20230918' into v4.9_create_goods_child_20230918
package com.clx.performance.controller.system;
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.cloud.nacos.registry.NacosRegistration;
import com.alibaba.cloud.nacos.registry.NacosServiceRegistry;
import com.msl.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 应用服务器控制
*
* @author wanglq
* Date 2022/11/28
* Time 15:43
*/
@RestController
@RequestMapping("/appServer")
@Slf4j
public class AppServerController {
@Autowired
private NacosRegistration registration;
@Autowired
private NacosServiceRegistry registry;
/**
* 下线服务
*
* @return
*/
@GetMapping("/deregister")
public Result<Void> deregister() {
NacosDiscoveryProperties properties = registration.getNacosDiscoveryProperties();
String service = properties.getService();
String group = properties.getGroup();
String clusterName = properties.getClusterName();
String ip = properties.getIp();
int port = properties.getPort();
log.info("deregister from nacos, serviceName:{}, groupName:{}, clusterName:{}, ip:{}, port:{}", service, group, clusterName, ip, port);
registry.deregister(registration);
return Result.ok();
}
/**
* 应用状态
*
* @return
*/
@GetMapping("/status")
public Result<String> status() {
return Result.ok("up");
}
}
......@@ -131,7 +131,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
@Override
public long countOfCancel(Long userNo, LocalDateTime startTime, LocalDateTime endTime) {
return count(lQrWrapper()
.eq(OrderChild::getChildNo, userNo)
.eq(OrderChild::getUserNo, userNo)
.eq(OrderChild::getStatus, OrderChildEnum.Status.DRIVER_CANCEL.getCode())
.ge(OrderChild::getCreateTime, startTime)
.le(OrderChild::getCreateTime, endTime)
......
......@@ -2,12 +2,15 @@ package com.clx.performance.service.impl;
import com.clx.performance.dao.*;
import com.clx.performance.enums.*;
import com.clx.performance.enums.OrderChildLogEnum;
import com.clx.performance.enums.OrderChildPoundAuditEnum;
import com.clx.performance.enums.OrderGoodsStatusEnum;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.model.*;
import com.clx.performance.param.pc.OrderChildCarrierCancelParam;
import com.clx.performance.param.pc.PoundAuditParam;
import com.clx.performance.service.OrderChildLogService;
import com.clx.performance.service.OrderChildPoundAuditService;
import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.vo.pc.OrderChildPoundAuditDetailVO;
import com.msl.common.exception.ServiceSystemException;
import com.msl.user.data.UserSessionData;
......@@ -17,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
......@@ -43,6 +46,8 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
private final OrderGoodsDao orderGoodsDao;
private final OrderGoodsService orderGoodsService;
private final OrderChildLogService orderChildLogService;
......@@ -77,6 +82,8 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_STATUS_CHANGED);
}
OrderGoods orderGoods = orderGoodsDao.getByOrderGoodsNo(orderChild.getOrderGoodsNo()).orElseThrow(PerformanceResultEnum.ORDER_INVALID);
//磅单审核对象赋值
poundAuditDetail.setStatus(param.getStatus());
poundAuditDetail.setRejectType(param.getRejectType());
......@@ -98,6 +105,17 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
}
}
BigDecimal dif = orderChild.getLoadNet().subtract(orderChild.getWeight());
orderChild.setWeight(orderChildWeightCalc(orderChild));
orderChild.setFreight(orderChildFreightCalc(orderChild));
// 更新装车净重
updateOrderGoodsAmountLoad(orderGoods, dif);
//更新运单数据
orderChild.setPoundStatus(param.getStatus());
orderChildDao.updatePoundAuditStatus(orderChild);
//保存磅单审核数据
orderChildPoundAuditDao.saveEntity(poundAuditDetail);
......@@ -108,14 +126,52 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
//保存磅单审核日志数据
orderChildPoundLogDao.saveEntity(poundLog);
//更新运单数据
orderChild.setPoundStatus(param.getStatus());
orderChildDao.updatePoundAuditStatus(orderChild);
//保存运单日志数据
orderChildLogService.saveOrderChildLog(param.getChildNo(),type,OrderChildLogEnum.Type.getByCode(type).get().getMsg(),
OrderChildLogEnum.CreateType.PLATFORM.getCode(), loginUserInfo.getUserNo(),loginUserInfo.getUserName());
}
/**
* 装车补偿
*/
private void updateOrderGoodsAmountLoad(OrderGoods orderGoods, BigDecimal dif){
if (dif.compareTo(BigDecimal.ZERO) == 0){return;}
int count = orderChildDao.countValidByOrderGoodsNo(orderGoods.getOrderGoodsNo())-1;
Integer status = orderGoods.getOrderGoodsStatus();
if (count == 0){
status = OrderGoodsStatusEnum.Status.PAYING.getCode();
}
else {
status = OrderGoodsStatusEnum.Status.GO_TO_SEND.getCode();
}
orderGoodsService.updateOrderGoodsReduceWeightAndStatus(orderGoods.getId(), dif, status);
}
/**
* 运单拉运吨数计算
*/
public BigDecimal orderChildWeightCalc(OrderChild orderChild){
if (orderChild.getLoadNet() == null) {return orderChild.getTruckLoad();}
else {return orderChild.getLoadNet();}
}
/**
* 运费计算
*/
public BigDecimal orderChildFreightCalc(OrderChild orderChild){
BigDecimal totalFreight = orderChild.getFreightPrice().multiply(orderChild.getWeight());
if (orderChild.getUnloadNet() != null){
BigDecimal dif = orderChild.getUnloadNet().subtract(orderChild.getWeight());
if (dif.compareTo(BigDecimal.ZERO) < 0){
totalFreight.subtract(orderChild.getLossPrice().multiply(dif));
}
}
return totalFreight.setScale(0, BigDecimal.ROUND_HALF_UP);
}
}
......@@ -953,6 +953,8 @@ public class OrderChildServiceImpl implements OrderChildService {
* 装车补偿
*/
private void updateOrderGoodsAmountLoad(OrderGoods orderGoods, BigDecimal dif){
if (dif.compareTo(BigDecimal.ZERO) == 0){return;}
int count = orderChildDao.countValidByOrderGoodsNo(orderGoods.getOrderGoodsNo())-1;
Integer status = orderGoods.getOrderGoodsStatus();
......@@ -1007,7 +1009,7 @@ public class OrderChildServiceImpl implements OrderChildService {
*/
private boolean cancelCountCheck(Long userNo){
LocalDateTime startTime = DateUtils.parseDateTime(DateUtils.formatDateTime(LocalDateTime.now(), "yyyy-MM-dd").get() + " 00:00:00").get();
LocalDateTime endTime = DateUtils.parseDateTime(DateUtils.formatDateTime(LocalDateTime.now(), "yyyy-MM-dd").get() + " 00:00:00").get();
LocalDateTime endTime = DateUtils.parseDateTime(DateUtils.formatDateTime(LocalDateTime.now(), "yyyy-MM-dd").get() + " 23:59:59").get();
long count = orderChildDao.countOfCancel(userNo, startTime, endTime);
......@@ -1018,7 +1020,7 @@ public class OrderChildServiceImpl implements OrderChildService {
* 运单拉运吨数计算
*/
private BigDecimal orderChildWeightCalc(OrderChild orderChild){
if (orderChild.getUnloadNet() == null) {return orderChild.getTruckLoad();}
if (orderChild.getLoadNet() == null) {return orderChild.getTruckLoad();}
else {return orderChild.getLoadNet();}
}
......
......@@ -98,7 +98,7 @@ public class OrderChildSqlProvider {
if (StringUtils.isNotBlank(param.getReceiveAddress())) {WHERE("receive_address= #{param.receiveAddress}");}
if (Objects.nonNull(param.getStatus())) {WHERE("pound_status = #{param.status}");}
ORDER_BY("unload_time desc,pound_status");
ORDER_BY("pound_status,unload_time");
}}.toString();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论