提交 9ed2706a authored 作者: liuhaiquan's avatar liuhaiquan

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 # Conflicts: # performance-web/src/main/java/com/clx/performance/strategy/impl/TwoGoodsOrderStrategy.java
...@@ -35,12 +35,15 @@ public class CarrierOrderChildDetailVO { ...@@ -35,12 +35,15 @@ public class CarrierOrderChildDetailVO {
private BigDecimal freightPrice; private BigDecimal freightPrice;
@ApiModelProperty(value = "应付运费(元)", example = "1.23") @ApiModelProperty(value = "应付运费(元)", example = "1.23")
@MoneyOutConvert
private BigDecimal payableFreight; private BigDecimal payableFreight;
@ApiModelProperty(value = "亏吨扣款(元)", example = "1.23") @ApiModelProperty(value = "亏吨扣款(元)", example = "1.23")
@MoneyOutConvert
private BigDecimal lossDeduction; private BigDecimal lossDeduction;
@ApiModelProperty(value = "实付运费(元)", example = "1.23") @ApiModelProperty(value = "实付运费(元)", example = "1.23")
@MoneyOutConvert
private BigDecimal realFreight; private BigDecimal realFreight;
......
...@@ -13,6 +13,7 @@ import com.xxl.job.core.handler.annotation.XxlJob; ...@@ -13,6 +13,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; 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.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations; import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -30,7 +31,7 @@ import java.util.Set; ...@@ -30,7 +31,7 @@ import java.util.Set;
public class OrderGoodsStatusLazyComponent implements InitializingBean { public class OrderGoodsStatusLazyComponent implements InitializingBean {
@Autowired @Autowired
private StringRedisTemplate stringRedisTemplate; private RedisTemplate<String,String> redisTemplate;
@Autowired @Autowired
private OrderGoodsDao orderGoodsDao; private OrderGoodsDao orderGoodsDao;
...@@ -39,7 +40,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean { ...@@ -39,7 +40,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
private OrderFeign orderFeign; private OrderFeign orderFeign;
public void expireProduce(LocalDateTime localDateTime, String orderGoodsNo) { 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 { ...@@ -49,7 +50,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
log.info("货单已完结定时器启动"); log.info("货单已完结定时器启动");
long nowTimeMillis = System.currentTimeMillis(); long nowTimeMillis = System.currentTimeMillis();
LocalDateTime nowDateTime = new Date(nowTimeMillis).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime(); 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, RedisConstants.ORDER_GOODS_STATUS_LAZY,
0, nowTimeMillis //延时任务score最小值 0, nowTimeMillis //延时任务score最小值
//延时任务score最大值(当前时间) //延时任务score最大值(当前时间)
...@@ -58,6 +59,10 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean { ...@@ -58,6 +59,10 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
log.info("货单已完结定时器查询redis条数为null"); log.info("货单已完结定时器查询redis条数为null");
return; return;
} }
if (orderGoodsIds.isEmpty()) {
log.info("货单已完结定时器查询redis条数为空");
return;
}
if (!CollectionUtil.isEmpty(orderGoodsIds)) { if (!CollectionUtil.isEmpty(orderGoodsIds)) {
log.info("货单已完结定时器查询redis条数:{}", orderGoodsIds.size()); log.info("货单已完结定时器查询redis条数:{}", orderGoodsIds.size());
...@@ -95,7 +100,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean { ...@@ -95,7 +100,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
//返还订单剩余吨数 //返还订单剩余吨数
orderFeign.updateOrderInfo(updateOrderInfoParam); 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()); log.info("删除redis ORDER_GOODS_STATUS_LAZY id: {}", orderGoodsId.getValue());
} }
...@@ -107,7 +112,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean { ...@@ -107,7 +112,7 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
Optional<List<OrderGoods>> optional = orderGoodsDao.getOrderGoodsList(); Optional<List<OrderGoods>> optional = orderGoodsDao.getOrderGoodsList();
if (optional.isPresent()) { if (optional.isPresent()) {
for (OrderGoods orderGoods : optional.get()) { 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 { ...@@ -16,7 +16,7 @@ public class RedisConstants {
public static final String TRUCK_LOCATION_KEY = "performance:truck_location_key:"; 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:"; public static final String ORDER_GOODS_STATUS_LAZY = "clx:order:goods:status:lazy:";
......
...@@ -1127,17 +1127,17 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -1127,17 +1127,17 @@ public class OrderChildServiceImpl implements OrderChildService {
BigDecimal payableFreight=BigDecimal.ZERO; BigDecimal payableFreight=BigDecimal.ZERO;
if(Objects.nonNull(orderChild.getLoadNet())){ if(Objects.nonNull(orderChild.getLoadNet())){
payableFreight = orderChild.getLoadNet() payableFreight = orderChild.getLoadNet()
.multiply(orderChild.getFreightPrice().movePointLeft(2)) .multiply(orderChild.getFreightPrice())
.setScale(2,BigDecimal.ROUND_HALF_UP); .setScale(0,BigDecimal.ROUND_HALF_UP);
} }
//亏吨扣款(元) //亏吨扣款(元)
BigDecimal lossDeduction=BigDecimal.ZERO; BigDecimal lossDeduction=BigDecimal.ZERO;
if(Objects.nonNull(orderChild.getLoadNet()) && Objects.nonNull(orderChild.getUnloadNet())){ if(Objects.nonNull(orderChild.getLoadNet()) && Objects.nonNull(orderChild.getUnloadNet())){
if(orderChild.getLoadNet().compareTo(orderChild.getUnloadNet()) >0){ if(orderChild.getLoadNet().compareTo(orderChild.getUnloadNet()) >0){
lossDeduction = carrierOrderChildDetailVO.getLossPrice().movePointLeft(2) lossDeduction = carrierOrderChildDetailVO.getLossPrice()
.multiply(orderChild.getLoadNet().subtract(orderChild.getUnloadNet())) .multiply(orderChild.getLoadNet().subtract(orderChild.getUnloadNet()))
.setScale(2,BigDecimal.ROUND_HALF_UP); .setScale(0,BigDecimal.ROUND_HALF_UP);
} }
} }
......
...@@ -17,8 +17,10 @@ import com.clx.performance.struct.OrderGoodsStruct; ...@@ -17,8 +17,10 @@ import com.clx.performance.struct.OrderGoodsStruct;
import com.clx.performance.vo.app.OrderGoodsAPPVO; import com.clx.performance.vo.app.OrderGoodsAPPVO;
import com.clx.performance.vo.feign.OrderGoodsFeignVO; import com.clx.performance.vo.feign.OrderGoodsFeignVO;
import com.clx.performance.vo.pc.OrderGoodsVO; import com.clx.performance.vo.pc.OrderGoodsVO;
import com.clx.user.feign.UserClxFeign;
import com.msl.common.base.Optional; import com.msl.common.base.Optional;
import com.msl.common.exception.ServiceSystemException; import com.msl.common.exception.ServiceSystemException;
import com.msl.common.result.Result;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -52,6 +54,9 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { ...@@ -52,6 +54,9 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
@Autowired @Autowired
private OrderGoodsDriverTruckDao orderGoodsDriverTruckDao; private OrderGoodsDriverTruckDao orderGoodsDriverTruckDao;
@Autowired
private UserClxFeign userClxFeign;
@Override @Override
public OrderGoodsVO getOrderGoodsInfoByOrderGoodsNoForPC(String orderGoodsNo) { public OrderGoodsVO getOrderGoodsInfoByOrderGoodsNoForPC(String orderGoodsNo) {
OrderGoodsVO orderGoodsVO = orderGoodsDao.getOrderGoodsInfoByOrderGoodsNoForPC(orderGoodsNo).map(orderGoodsStruct::convert).get(); OrderGoodsVO orderGoodsVO = orderGoodsDao.getOrderGoodsInfoByOrderGoodsNoForPC(orderGoodsNo).map(orderGoodsStruct::convert).get();
...@@ -84,16 +89,26 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { ...@@ -84,16 +89,26 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
@Override @Override
public IPage<OrderGoodsAPPVO> indexOrderGoodsList(OrderGoodsListPageParam orderGoodsListParam) { public IPage<OrderGoodsAPPVO> indexOrderGoodsList(OrderGoodsListPageParam orderGoodsListParam) {
if (StringUtils.equals(orderGoodsListParam.getOrderGoodsType(),"1")){ if (StringUtils.equals(orderGoodsListParam.getOrderGoodsType(), "1")) {
return orderGoodsDao.openOrderPageGoodsList(orderGoodsListParam); return orderGoodsDao.openOrderPageGoodsList(orderGoodsListParam);
}else { } else {
List<OrderGoodsDriverTruck> truckList = orderGoodsDriverTruckDao. List<OrderGoodsDriverTruck> truckList = orderGoodsDriverTruckDao.
selectListByDriverUserNo(orderGoodsListParam.getDriverUserNo()) selectListByDriverUserNo(orderGoodsListParam.getDriverUserNo())
.orElseThrow(PerformanceResultEnum.DATA_NOT_FIND, "当前用户未绑定车辆"); .orElseThrow(PerformanceResultEnum.DATA_NOT_FIND, "当前用户未绑定车辆");
List<String> truckNoList = null;
if (truckList.isEmpty()) { if (truckList.isEmpty()) {
//查询当前用户是否是货主
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, "当前用户未绑定车辆"); throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND, "当前用户未绑定车辆");
} }
List<String> truckNoList = truckList.stream().map(OrderGoodsDriverTruck::getTruckNo).collect(Collectors.toList()); truckNoList = ownTruckByUserNo.getData();
}
} else {
truckNoList = truckList.stream().map(OrderGoodsDriverTruck::getTruckNo).collect(Collectors.toList());
}
List<OrderGoodsTruckBind> orderGoodsDriverTrucks = orderGoodsTruckBindDao.selectListByTruckNo(truckNoList) List<OrderGoodsTruckBind> orderGoodsDriverTrucks = orderGoodsTruckBindDao.selectListByTruckNo(truckNoList)
.orElseThrow(PerformanceResultEnum.DATA_NOT_FIND, "当前用户没有专属单"); .orElseThrow(PerformanceResultEnum.DATA_NOT_FIND, "当前用户没有专属单");
if (orderGoodsDriverTrucks.isEmpty()) { if (orderGoodsDriverTrucks.isEmpty()) {
...@@ -101,7 +116,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { ...@@ -101,7 +116,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
} }
List<String> orderGoodsNoList = orderGoodsDriverTrucks.stream().map(OrderGoodsTruckBind::getOrderGoodsNo).collect(Collectors.toList()); List<String> orderGoodsNoList = orderGoodsDriverTrucks.stream().map(OrderGoodsTruckBind::getOrderGoodsNo).collect(Collectors.toList());
return orderGoodsDao.exclusiveOrderPageGoodsList(orderGoodsListParam,orderGoodsNoList); return orderGoodsDao.exclusiveOrderPageGoodsList(orderGoodsListParam, orderGoodsNoList);
} }
} }
......
...@@ -164,7 +164,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -164,7 +164,7 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now); orderGoodsTruckBindDao.saveBatchEntity(orderNo, OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, child.getTruckList(), now);
} }
mqMap.put(OrderGoodsTypeEnum.Status.PLATFORM.getCode() + beginOrderGoodsId, postedTime); 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; beginOrderGoodsId = beginOrderGoodsId + 1;
orderGoodsList.add(orderGoods); orderGoodsList.add(orderGoods);
...@@ -172,26 +172,33 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe ...@@ -172,26 +172,33 @@ public class TwoGoodsOrderStrategy implements GoodsOrderStrategy, InitializingBe
orderGoodsDao.saveBatchEntity(orderGoodsList); orderGoodsDao.saveBatchEntity(orderGoodsList);
BigDecimal residueWeight = new BigDecimal(orderInfo.getResidueWeight()); BigDecimal residueWeight = new BigDecimal(orderInfo.getResidueWeight());
if (platSum.compareTo(BigDecimal.ZERO) != 0 && ownSum.compareTo(BigDecimal.ZERO) != 0) { 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(); UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(orderInfo.getId()); param.setOrderId(orderInfo.getId());
param.setUpdateType("4"); param.setUpdateType("4");
param.setResidueWeight(residueWeight.subtract(platSum).subtract(ownSum)); param.setResidueWeight(residueWeight.subtract(platSum).subtract(ownSum));
param.setOwnWeight(ownSum); param.setOwnWeight(residueOwnSum.subtract(ownSum));
param.setPlatWeight(platSum); param.setPlatWeight(residuePlatSum.subtract(platSum));
orderFeign.updateOrderInfoResidueWeight(param); orderFeign.updateOrderInfoResidueWeight(param);
} else if (platSum.compareTo(BigDecimal.ZERO) != 0 && ownSum.compareTo(BigDecimal.ZERO) == 0) { } else if (platSum.compareTo(BigDecimal.ZERO) != 0 && ownSum.compareTo(BigDecimal.ZERO) == 0) {
BigDecimal residuePlatSum = new BigDecimal(orderInfo.getPlatformResidueCarryWeight());
UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam(); UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(orderInfo.getId()); param.setOrderId(orderInfo.getId());
param.setUpdateType("2"); param.setUpdateType("2");
param.setResidueWeight(residueWeight.subtract(platSum)); param.setResidueWeight(residueWeight.subtract(platSum));
param.setPlatWeight(platSum); param.setPlatWeight(residuePlatSum.subtract(platSum));
orderFeign.updateOrderInfoResidueWeight(param); orderFeign.updateOrderInfoResidueWeight(param);
} else if (platSum.compareTo(BigDecimal.ZERO) == 0 && ownSum.compareTo(BigDecimal.ZERO) != 0) { } else if (platSum.compareTo(BigDecimal.ZERO) == 0 && ownSum.compareTo(BigDecimal.ZERO) != 0) {
BigDecimal residueOwnSum = new BigDecimal(orderInfo.getOwnResidueCarryWeight());
UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam(); UpdateOrderInfoResidueWeightParam param = new UpdateOrderInfoResidueWeightParam();
param.setOrderId(orderInfo.getId()); param.setOrderId(orderInfo.getId());
param.setUpdateType("3"); param.setUpdateType("3");
param.setResidueWeight(residueWeight.subtract(ownSum)); param.setResidueWeight(residueWeight.subtract(ownSum));
param.setOwnWeight(ownSum); param.setOwnWeight(residueOwnSum.subtract(ownSum));
orderFeign.updateOrderInfoResidueWeight(param); orderFeign.updateOrderInfoResidueWeight(param);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论