提交 4e15a56e authored 作者: liuhaiquan's avatar liuhaiquan

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

# Conflicts: # performance-web/src/main/java/com/clx/performance/strategy/impl/TwoGoodsOrderStrategy.java
......@@ -47,7 +47,6 @@ public class OrderChildVO {
@ApiModelProperty(value = "货物名称", example = "煤")
private String goodsName;
@ApiModelProperty(value = "运费单价(元)", example = "1.23")
@MoneyOutConvert
private BigDecimal freightPrice;
@ApiModelProperty(value = "发货地址id", example = "1")
private Integer sendAddressId;
......
......@@ -35,12 +35,15 @@ public class CarrierOrderChildDetailVO {
private BigDecimal freightPrice;
@ApiModelProperty(value = "应付运费(元)", example = "1.23")
@MoneyOutConvert
private BigDecimal payableFreight;
@ApiModelProperty(value = "亏吨扣款(元)", example = "1.23")
@MoneyOutConvert
private BigDecimal lossDeduction;
@ApiModelProperty(value = "实付运费(元)", example = "1.23")
@MoneyOutConvert
private BigDecimal realFreight;
......
......@@ -13,6 +13,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
......@@ -30,7 +31,7 @@ import java.util.Set;
public class OrderGoodsStatusLazyComponent implements InitializingBean {
@Autowired
private StringRedisTemplate stringRedisTemplate;
private RedisTemplate<String,String> redisTemplate;
@Autowired
private OrderGoodsDao orderGoodsDao;
......@@ -39,7 +40,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
private OrderFeign orderFeign;
public void expireProduce(LocalDateTime localDateTime, String orderGoodsNo) {
stringRedisTemplate.opsForZSet().add(RedisConstants.ORDER_GOODS_STATUS_LAZY, orderGoodsNo, localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli());
redisTemplate.opsForZSet().add(RedisConstants.ORDER_GOODS_STATUS_LAZY, orderGoodsNo, localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli());
}
......@@ -49,7 +50,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
log.info("货单已完结定时器启动");
long nowTimeMillis = System.currentTimeMillis();
LocalDateTime nowDateTime = new Date(nowTimeMillis).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime();
Set<ZSetOperations.TypedTuple<String>> orderGoodsIds = stringRedisTemplate.opsForZSet().rangeByScoreWithScores(
Set<ZSetOperations.TypedTuple<String>> orderGoodsIds = redisTemplate.opsForZSet().rangeByScoreWithScores(
RedisConstants.ORDER_GOODS_STATUS_LAZY,
0, nowTimeMillis //延时任务score最小值
//延时任务score最大值(当前时间)
......@@ -58,6 +59,10 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
log.info("货单已完结定时器查询redis条数为null");
return;
}
if (orderGoodsIds.isEmpty()) {
log.info("货单已完结定时器查询redis条数为空");
return;
}
if (!CollectionUtil.isEmpty(orderGoodsIds)) {
log.info("货单已完结定时器查询redis条数:{}", orderGoodsIds.size());
......@@ -95,7 +100,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
//返还订单剩余吨数
orderFeign.updateOrderInfo(updateOrderInfoParam);
}
stringRedisTemplate.opsForZSet().remove(RedisConstants.ORDER_GOODS_STATUS_LAZY, orderGoodsId.getValue());
redisTemplate.opsForZSet().remove(RedisConstants.ORDER_GOODS_STATUS_LAZY, orderGoodsId.getValue());
log.info("删除redis ORDER_GOODS_STATUS_LAZY id: {}", orderGoodsId.getValue());
}
......@@ -107,7 +112,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
Optional<List<OrderGoods>> optional = orderGoodsDao.getOrderGoodsList();
if (optional.isPresent()) {
for (OrderGoods orderGoods : optional.get()) {
stringRedisTemplate.opsForZSet().add(RedisConstants.ORDER_GOODS_STATUS_LAZY, orderGoods.getOrderGoodsNo(), orderGoods.getLastArriveSendTime().toInstant(ZoneOffset.of("+8")).toEpochMilli());
redisTemplate.opsForZSet().add(RedisConstants.ORDER_GOODS_STATUS_LAZY, orderGoods.getOrderGoodsNo(), orderGoods.getLastArriveSendTime().toInstant(ZoneOffset.of("+8")).toEpochMilli());
}
}
}
......
......@@ -16,7 +16,7 @@ public class RedisConstants {
public static final String TRUCK_LOCATION_KEY = "performance:truck_location_key:";
public static final String CARRIER_ORDER_NUM_POOL_KEY = "carrier:order:orderNumPool:{date}";
public static final String CARRIER_ORDER_NUM_POOL_KEY = "clx-performance:order:orderNumPool:{date}";
public static final String ORDER_GOODS_STATUS_LAZY = "clx:order:goods:status:lazy:";
......
......@@ -8,6 +8,7 @@ import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.performance.component.GoodsOrderStrategyContext;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.constant.RedisConstants;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.mapper.OrderGoodsMapper;
import com.clx.performance.service.OrderChildService;
import com.clx.performance.service.OrderGoodsService;
......@@ -15,6 +16,7 @@ import com.clx.performance.vo.pc.OrderChildPCVO;
import com.clx.performance.vo.pc.OrderGoodsVO;
import com.msl.common.base.PageData;
import com.msl.common.convertor.aspect.UnitCovert;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -89,7 +91,9 @@ public class GoodsOrderController {
sendLazyTime = goodsOrderStrategyContext.strategyContext.get(truckDemand).goodsOrderProcess(orderGoodsParams, orderInfo, now);
} catch (Exception e) {
throw new RuntimeException(e);
// throw new ServiceSystemException(e);
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, e.getMessage());
} finally {
try {
if (rLock != null && rLock.isLocked()) {
......
......@@ -70,7 +70,7 @@ public class OrderGoodsTruckBindDaoImpl extends BaseDaoImpl<OrderGoodsTruckBindM
@Override
public Optional<List<OrderGoodsTruckBind>> selectListByTruckNo(List<String> truckList) {
return Optional.ofNullable(baseMapper.selectList(new QueryWrapper<OrderGoodsTruckBind>().lambda()
.ne(OrderGoodsTruckBind::getStatus, OrderGoodsTruckBindEnum.Status.CANCEL.getCode())
.eq(OrderGoodsTruckBind::getStatus, OrderGoodsTruckBindEnum.Status.SUCCESS.getCode())
.in(OrderGoodsTruckBind::getTruckNo,truckList).select(OrderGoodsTruckBind::getOrderGoodsNo)));
}
}
......@@ -1127,17 +1127,17 @@ public class OrderChildServiceImpl implements OrderChildService {
BigDecimal payableFreight=BigDecimal.ZERO;
if(Objects.nonNull(orderChild.getLoadNet())){
payableFreight = orderChild.getLoadNet()
.multiply(orderChild.getFreightPrice().movePointLeft(2))
.setScale(2,BigDecimal.ROUND_HALF_UP);
.multiply(orderChild.getFreightPrice())
.setScale(0,BigDecimal.ROUND_HALF_UP);
}
//亏吨扣款(元)
BigDecimal lossDeduction=BigDecimal.ZERO;
if(Objects.nonNull(orderChild.getLoadNet()) && Objects.nonNull(orderChild.getUnloadNet())){
if(orderChild.getLoadNet().compareTo(orderChild.getUnloadNet()) >0){
lossDeduction = carrierOrderChildDetailVO.getLossPrice().movePointLeft(2)
lossDeduction = carrierOrderChildDetailVO.getLossPrice()
.multiply(orderChild.getLoadNet().subtract(orderChild.getUnloadNet()))
.setScale(2,BigDecimal.ROUND_HALF_UP);
.setScale(0,BigDecimal.ROUND_HALF_UP);
}
}
......
......@@ -17,15 +17,15 @@ import com.clx.performance.struct.OrderGoodsStruct;
import com.clx.performance.vo.app.OrderGoodsAPPVO;
import com.clx.performance.vo.feign.OrderGoodsFeignVO;
import com.clx.performance.vo.pc.OrderGoodsVO;
import com.msl.common.base.Optional;
import com.clx.user.feign.UserClxFeign;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.result.Result;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
......@@ -52,6 +52,9 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
@Autowired
private OrderGoodsDriverTruckDao orderGoodsDriverTruckDao;
@Autowired
private UserClxFeign userClxFeign;
@Override
public OrderGoodsVO getOrderGoodsInfoByOrderGoodsNoForPC(String orderGoodsNo) {
OrderGoodsVO orderGoodsVO = orderGoodsDao.getOrderGoodsInfoByOrderGoodsNoForPC(orderGoodsNo).map(orderGoodsStruct::convert).get();
......@@ -69,6 +72,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
FeignOrderVO orderInfoFeign = orderFeign.getOrderInfoFeign(orderNo);
orderGoodsVO.setReveiveAddressAll(orderInfoFeign.getReveiveAddressAll());
orderGoodsVO.setSendAddressAll(orderInfoFeign.getSendAddressAll());
orderGoodsVO.setResidueTransportWeight(BigDecimal.ZERO.compareTo(orderGoodsVO.getResidueTransportWeight()) > 0?BigDecimal.ZERO:orderGoodsVO.getResidueTransportWeight());
return orderGoodsVO;
}
......@@ -84,16 +88,26 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
@Override
public IPage<OrderGoodsAPPVO> indexOrderGoodsList(OrderGoodsListPageParam orderGoodsListParam) {
if (StringUtils.equals(orderGoodsListParam.getOrderGoodsType(),"1")){
if (StringUtils.equals(orderGoodsListParam.getOrderGoodsType(), "1")) {
return orderGoodsDao.openOrderPageGoodsList(orderGoodsListParam);
}else {
} else {
List<OrderGoodsDriverTruck> truckList = orderGoodsDriverTruckDao.
selectListByDriverUserNo(orderGoodsListParam.getDriverUserNo())
.orElseThrow(PerformanceResultEnum.DATA_NOT_FIND, "当前用户未绑定车辆");
List<String> truckNoList = null;
if (truckList.isEmpty()) {
throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND, "当前用户未绑定车辆");
//查询当前用户是否是货主
Long driverUserNo = orderGoodsListParam.getDriverUserNo();
Result<List<String>> ownTruckByUserNo = userClxFeign.getOwnTruckByUserNo(driverUserNo);
if (ownTruckByUserNo.getCode() == 200) {
if (ownTruckByUserNo.getData().isEmpty()) {
throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND, "当前用户未绑定车辆");
}
truckNoList = ownTruckByUserNo.getData();
}
} else {
truckNoList = truckList.stream().map(OrderGoodsDriverTruck::getTruckNo).collect(Collectors.toList());
}
List<String> truckNoList = truckList.stream().map(OrderGoodsDriverTruck::getTruckNo).collect(Collectors.toList());
List<OrderGoodsTruckBind> orderGoodsDriverTrucks = orderGoodsTruckBindDao.selectListByTruckNo(truckNoList)
.orElseThrow(PerformanceResultEnum.DATA_NOT_FIND, "当前用户没有专属单");
if (orderGoodsDriverTrucks.isEmpty()) {
......@@ -101,7 +115,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
}
List<String> orderGoodsNoList = orderGoodsDriverTrucks.stream().map(OrderGoodsTruckBind::getOrderGoodsNo).collect(Collectors.toList());
return orderGoodsDao.exclusiveOrderPageGoodsList(orderGoodsListParam,orderGoodsNoList);
return orderGoodsDao.exclusiveOrderPageGoodsList(orderGoodsListParam, orderGoodsNoList);
}
}
......
......@@ -12,7 +12,10 @@ import com.clx.performance.component.OrderGoodsStatusLazyComponent;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.OrderGoodsTruckBindDao;
import com.clx.performance.enums.*;
import com.clx.performance.enums.OrderGoodsStatusEnum;
import com.clx.performance.enums.OrderGoodsTypeEnum;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.enums.TruckDemandEnum;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.strategy.GoodsOrderStrategy;
......@@ -21,7 +24,6 @@ import com.msl.common.utils.DateUtils;
import com.msl.user.data.UserSessionData;
import com.msl.user.utils.TokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
......@@ -146,7 +148,7 @@ public class ThreeGoodsOrderStrategy implements GoodsOrderStrategy, Initializing
orderGoods.setModifiedTime(now);
orderGoods.setUserName(loginUserInfo.getUserName());
orderGoods.setUserNo(loginUserInfo.getUserNo());
if (StringUtils.equals(child.getVehicleUsage(), OrderGoodsPendingVehicleUsageEnum.Status.OWN_TRUCK.getCode()) && CollectionUtil.isNotEmpty(child.getTruckList())) {
if (CollectionUtil.isNotEmpty(child.getTruckList())) {
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
}
mqMap.put(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, postedTime);
......
......@@ -81,11 +81,11 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
BigDecimal.ZERO, BigDecimal::add);
BigDecimal ownSum = childParamsList.stream().filter(i -> !"1".equals(i.getVehicleUsage())).map(OrderGoodsChildParams::getExtractWeight).reduce(
BigDecimal.ZERO, BigDecimal::add);
BigDecimal platformCarryWeight = new BigDecimal(orderInfo.getPlatformCarryWeight());
BigDecimal platformCarryWeight = new BigDecimal(orderInfo.getPlatformResidueCarryWeight());
if (platformCarryWeight.compareTo(platSum) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前平台承运货单总吨数已超平台承运订单总吨数");
}
BigDecimal ownCarryWeight = new BigDecimal(orderInfo.getOwnCarryWeight());
BigDecimal ownCarryWeight = new BigDecimal(orderInfo.getOwnResidueCarryWeight());
if (ownCarryWeight.compareTo(ownSum) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前自有承运货单总吨数已超自有承运订单总吨数");
}
......@@ -158,12 +158,14 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoods.setModifiedTime(now);
orderGoods.setUserName(loginUserInfo.getUserName());
orderGoods.setUserNo(loginUserInfo.getUserNo());
orderGoods.setUserName(loginUserInfo.getUserName());
orderGoods.setUserNo(loginUserInfo.getUserNo());
if (StringUtils.equals(child.getVehicleUsage(), OrderGoodsPendingVehicleUsageEnum.Status.OWN_TRUCK.getCode()) && CollectionUtil.isNotEmpty(child.getTruckList())) {
if (CollectionUtil.isNotEmpty(child.getTruckList())) {
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
}
mqMap.put(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, postedTime);
orderGoodsStatusLazyComponent.expireProduce(orderGoods.getLastArriveSendTime(),OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
orderGoodsStatusLazyComponent.expireProduce(orderGoods.getLastArriveSendTime(), OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId);
beginOrderGoodsId = beginOrderGoodsId + 1;
orderGoodsList.add(orderGoods);
......@@ -171,26 +173,33 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoodsDao.saveBatchEntity(orderGoodsList);
BigDecimal residueWeight = new BigDecimal(orderInfo.getResidueWeight());
if (platSum.compareTo(BigDecimal.ZERO) != 0 && ownSum.compareTo(BigDecimal.ZERO) != 0) {
BigDecimal residuePlatSum = new BigDecimal(orderInfo.getPlatformResidueCarryWeight());
BigDecimal residueOwnSum = new BigDecimal(orderInfo.getOwnResidueCarryWeight());
UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(orderInfo.getId());
param.setUpdateType("4");
param.setResidueWeight(residueWeight.subtract(platSum).subtract(ownSum));
param.setOwnWeight(ownSum);
param.setPlatWeight(platSum);
param.setOwnWeight(residueOwnSum.subtract(ownSum));
param.setPlatWeight(residuePlatSum.subtract(platSum));
orderFeign.updateOrderInfoResidueWeight(param);
} else if (platSum.compareTo(BigDecimal.ZERO) != 0 && ownSum.compareTo(BigDecimal.ZERO) == 0) {
BigDecimal residuePlatSum = new BigDecimal(orderInfo.getPlatformResidueCarryWeight());
UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(orderInfo.getId());
param.setUpdateType("2");
param.setResidueWeight(residueWeight.subtract(platSum));
param.setPlatWeight(platSum);
param.setPlatWeight(residuePlatSum.subtract(platSum));
orderFeign.updateOrderInfoResidueWeight(param);
} else if (platSum.compareTo(BigDecimal.ZERO) == 0 && ownSum.compareTo(BigDecimal.ZERO) != 0) {
BigDecimal residueOwnSum = new BigDecimal(orderInfo.getOwnResidueCarryWeight());
UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(orderInfo.getId());
param.setUpdateType("3");
param.setResidueWeight(residueWeight.subtract(ownSum));
param.setOwnWeight(ownSum);
param.setOwnWeight(residueOwnSum.subtract(ownSum));
orderFeign.updateOrderInfoResidueWeight(param);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论