ソースを参照

Merge remote-tracking branch 'origin/dev' into dev

zk 1 年間 前
コミット
0c85603b10

+ 36 - 2
sckw-common/sckw-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java

@@ -132,7 +132,7 @@ public class DateUtil {
 
 
     /**
-     * yyyy-MM-dd 转换成 LocalDateTime
+     * yyyy-MM-dd 转换成 LocalDateTime-添加00:00:00
      *
      * @param str
      * @return
@@ -395,6 +395,40 @@ public class DateUtil {
         return null;
     }
 
+    /**
+     * 日期字符串转换为LocalDateTime方法-添加00:00:00
+     *
+     * @param dateString 日期字符串,格式:yyyy-MM-dd
+     * @return
+     */
+    public static LocalDateTime strToLocalDateTimeStart(String dateString) {
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDateTime localDateTime = LocalDate.parse(dateString, formatter).atStartOfDay();
+//        LocalDateTime localDateTime1 = strToLocalDateTime(dateString);
+        return localDateTime;
+    }
+
+
+    /**
+     * 日期字符串转换为LocalDateTime方法-添加00:00:00
+     *
+     * @param dateString 日期字符串,格式:yyyy-MM-dd
+     * @return
+     */
+    public static LocalDateTime strToLocalDateTimeEnd(String dateString) {
+        String timeString = " 23:59:59";
+        String dateTimeString = timeString + timeString;
+        DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LocalDateTime localDateTime = LocalDateTime.now();
+        try {
+            localDateTime = LocalDateTime.parse(dateTimeString, formatter1);
+            return localDateTime;
+        } catch (java.time.format.DateTimeParseException e) {
+            throw new RuntimeException("Invalid date strToLocalDateTimeEnd error" + e.getMessage());
+        }
+    }
+
+
     public static String date() {
         return LocalDate.now().format(YYYY_MM_DD);
     }
@@ -584,7 +618,7 @@ public class DateUtil {
 //        //结束时间
 //        String beforeMonthDateAndDaysEndToString1 = getBeforeMonthDateAndDaysEndToString(1, 0);
 //        System.out.println(beforeMonthDateAndDaysEndToString1);
-       String SS= cn.hutool.core.date.DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd")+" 00:00:00";
+        String SS = cn.hutool.core.date.DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd") + " 00:00:00";
         //月
         //开始时间
         String monthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 1, -1);

+ 15 - 4
sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/dubbo/TransportRemoteService.java

@@ -6,6 +6,7 @@ import com.sckw.transport.api.model.dto.AccountCheckingBindDTO;
 import com.sckw.transport.api.model.dto.RWaybillOrderDto;
 import com.sckw.transport.api.model.param.ContractSignLogisticsParam;
 import com.sckw.transport.api.model.param.LogisticsOrderParam;
+import com.sckw.transport.api.model.param.UpdateOrderStatusDto;
 import com.sckw.transport.api.model.vo.KwtLogisticsOrderVO;
 import com.sckw.transport.api.model.vo.RTruckMonitorVo;
 import com.sckw.transport.api.model.vo.RWaybillOrderVo;
@@ -44,6 +45,7 @@ public interface TransportRemoteService {
      * @return
      */
     List<Integer> getLogisticsOrderAddressList();
+
     /**
      * 贸易订单验证物流订单是否已完成
      *
@@ -72,21 +74,22 @@ public interface TransportRemoteService {
      * 根据企业id 判断是否存在未完成完结的物流订单
      *
      * @param entId 企业id
-     * @return  ture 代表还有未完结的  false代表没有未完结的
+     * @return ture 代表还有未完结的  false代表没有未完结的
      */
     boolean checkLogisticsOrderFinishByEntId(Long entId);
 
     /**
      * 根据企业id 判断是否存在未完成完结的物流订单
      *
-     * @param consignEntId 托运企业id
+     * @param consignEntId        托运企业id
      * @param acceptCarriageEntId 承运企业id
-     * @return   根据data是否为空判断 是否存在未完结订单  空  不存在  不为空  存在
+     * @return 根据data是否为空判断 是否存在未完结订单  空  不存在  不为空  存在
      */
-    HttpResult checkLogisticsOrderIsFinishByEntId(Long consignEntId,Long acceptCarriageEntId);
+    HttpResult checkLogisticsOrderIsFinishByEntId(Long consignEntId, Long acceptCarriageEntId);
 
     /**
      * 合同变更,修改物流订单状态【仅仅支持待签约变更为已签约】  0 已签约 1待签约
+     *
      * @param param
      */
     void contractSignLogisticsCompleted(ContractSignLogisticsParam param);
@@ -106,4 +109,12 @@ public interface TransportRemoteService {
      * @date 2023/10/8
      **/
     List<RTruckMonitorVo> truckInTask(Long checkEntId);
+
+
+    /**
+     * 物流订单发起对账状态变更
+     *
+     * @param params 请求参数
+     */
+    HttpResult logisticsOrderInitiateReconciliationUpdateStatus(UpdateOrderStatusDto params);
 }

+ 49 - 0
sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/model/param/UpdateOrderStatusDto.java

@@ -0,0 +1,49 @@
+package com.sckw.transport.api.model.param;
+
+import com.sckw.core.model.enums.LogisticsOrderEnum;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @author lfdc
+ * @description 修改物流订单状态dto
+ * @date 2024-05-27 11:05:33
+ */
+@Data
+public class UpdateOrderStatusDto implements Serializable {
+
+    /**
+     * 物流订单id
+     */
+    @NotNull(message = "物流订单id不能为空")
+    private List<Long> orderIds;
+
+    /**
+     * 物流订单状态
+     */
+    @NotNull(message = "物流订单状态不能为空")
+    private LogisticsOrderEnum logisticsOrderStatus;
+
+    /**
+     * 修改人
+     */
+    @NotNull(message = "修改人不能为空")
+    private Long updateById;
+
+
+    /**
+     * 修改人
+     */
+    @NotNull(message = "修改人不能为空")
+    private Long updateBy;
+
+    /**
+     * 修改时间
+     */
+    @NotNull(message = "修改时间不能为空")
+    private LocalDateTime updateTime;
+}

+ 0 - 1
sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/TestController.java

@@ -2,7 +2,6 @@ package com.sckw.example.controller;
 
 import com.sckw.payment.api.dubbo.PayCenterDubboService;
 import com.sckw.payment.api.dubbo.PaymentDubboService;
-import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.dto.MemberDetail;
 import com.sckw.payment.api.model.dto.WalletDto;
 import com.sckw.payment.api.model.dto.common.R;

+ 22 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java

@@ -1,5 +1,7 @@
 package com.sckw.payment.service;
 
+import com.sckw.core.model.enums.LogisticsOrderEnum;
+
 import com.alibaba.fastjson2.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -15,6 +17,7 @@ import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.OrderGenerateSeqNoUtils;
 import com.sckw.core.utils.StringTimeUtil;
+import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.payment.dao.KwpLedgerLogisticsMapper;
@@ -35,6 +38,7 @@ import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.transport.api.dubbo.TransportRemoteService;
 import com.sckw.transport.api.model.dto.AcceptCarriageLogisticsOrderDto;
 import com.sckw.transport.api.model.dto.AccountCheckingBindDTO;
+import com.sckw.transport.api.model.param.UpdateOrderStatusDto;
 import io.seata.spring.annotation.GlobalTransactional;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
@@ -66,7 +70,6 @@ public class KwpLedgerLogisticsService extends AbsLedger {
     private KwpLedgerLogisticsOrderService logisticsOrderService;
     @Resource
     private MessageSender messageSender;
-
     @Resource
     private KwpLedgerLogisticsMapper logisticsMapper;
     @DubboReference(version = "1.0.0", group = "design", check = false)
@@ -543,6 +546,22 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         KwpLedgerLogisticsUnit logisticsUnit = logisticsUnitService.queryCustomerEnt(confirmReq.getIdLong(), LogisticsUnitType.SHIPPER);
         //承运方
         KwpLedgerLogisticsUnit logisticsUnit2 = logisticsUnitService.queryCustomerEnt(confirmReq.getIdLong(), LogisticsUnitType.CARRIER);
+
+        //5.27 修改物流单状态
+        List<KwpLedgerLogisticsOrder> kwpLedgerLogisticsOrders = logisticsOrderService.queryList(confirmReq.getIdLong());
+        if (CollectionUtils.isNotEmpty(kwpLedgerLogisticsOrders)) {
+            UpdateOrderStatusDto updateOrderStatusDto = new UpdateOrderStatusDto();
+            updateOrderStatusDto.setOrderIds(kwpLedgerLogisticsOrders.stream().map(KwpLedgerLogisticsOrder::getLOrderId).toList());
+            updateOrderStatusDto.setLogisticsOrderStatus(LogisticsOrderEnum.HAVE_RECONCILED);
+            updateOrderStatusDto.setUpdateById(LoginUserHolder.getUserId());
+            updateOrderStatusDto.setUpdateBy(LoginUserHolder.getUserId());
+            updateOrderStatusDto.setUpdateTime(LocalDateTime.now());
+            HttpResult httpResult = transportRemoteService.logisticsOrderInitiateReconciliationUpdateStatus(updateOrderStatusDto);
+            if (!Objects.equals(httpResult.getCode(), HttpStatus.SUCCESS_CODE)) {
+                throw new BusinessException(httpResult.getMsg());
+            }
+        }
+
         //推送创建人
         messageSender.sendCreate(LoginUserHolder.getUserId(), new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
             put("company", logisticsUnit.getFirmName());
@@ -814,8 +833,8 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         return logisticsMapper.selectJoin(entId, entTarget);
     }
 
-    public LedgerSize count(Long entId,List<Long> enterpriseIds) {
-        return logisticsMapper.countSize(entId,enterpriseIds);
+    public LedgerSize count(Long entId, List<Long> enterpriseIds) {
+        return logisticsMapper.countSize(entId, enterpriseIds);
     }
 
     public List<LedgerLogisticsDto> exportList(LogisticsReq logisticsReq, List<Long> idList) {

+ 55 - 3
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dubbo/TransportServiceImpl.java

@@ -13,6 +13,7 @@ import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.CarWaybillEnum;
 import com.sckw.core.model.enums.LogisticsOrderEnum;
 import com.sckw.core.utils.CollectionUtils;
+import com.sckw.core.utils.DateUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
@@ -31,11 +32,13 @@ import com.sckw.stream.model.SckwBusSum;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.transport.api.dubbo.TransportRemoteService;
-import com.sckw.transport.api.model.dto.*;
+import com.sckw.transport.api.model.dto.AcceptCarriageLogisticsOrderDto;
+import com.sckw.transport.api.model.dto.AccountCheckingBindDTO;
+import com.sckw.transport.api.model.dto.RWaybillOrderDto;
 import com.sckw.transport.api.model.param.ContractSignLogisticsParam;
 import com.sckw.transport.api.model.param.LogisticsOrderParam;
+import com.sckw.transport.api.model.param.UpdateOrderStatusDto;
 import com.sckw.transport.api.model.vo.KwtLogisticsOrderVO;
-import com.sckw.transport.api.model.vo.LogisticsOrderVO;
 import com.sckw.transport.api.model.vo.RTruckMonitorVo;
 import com.sckw.transport.api.model.vo.RWaybillOrderVo;
 import com.sckw.transport.dao.*;
@@ -54,7 +57,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -750,4 +752,54 @@ public class TransportServiceImpl implements TransportRemoteService {
             findLogisticsOrderChild(orderIds, StringUtil.join(idList, Global.COMMA));
         }
     }
+
+    /**
+     * 物流订单发起对账状态变更
+     *
+     * @param params 请求参数
+     */
+    @Transactional
+    public HttpResult logisticsOrderInitiateReconciliationUpdateStatus(UpdateOrderStatusDto params) {
+        List<Long> orderIds = params.getOrderIds();
+        for (Long orderId : orderIds) {
+            KwtLogisticsOrder kwtLogisticsOrder = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
+                    .eq(KwtLogisticsOrder::getId, orderId));
+            Integer code = params.getLogisticsOrderStatus().getCode();
+            if (LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getCode() == kwtLogisticsOrder.getStatus()) {
+                return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, "已结算,不能进行对账");
+            }
+            if (LogisticsOrderEnum.HAVE_FINISHED.getCode() != kwtLogisticsOrder.getStatus()) {
+                return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, "订单并未完成,不能进行对账");
+            }
+            if (LogisticsOrderEnum.HAVE_RECONCILED.getCode() != code) {
+                return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, "订单状态错误");
+            }
+            logisticsOrderMapper.update(null, new LambdaUpdateWrapper<KwtLogisticsOrder>()
+                    .eq(KwtLogisticsOrder::getId, orderId)
+                    .set(KwtLogisticsOrder::getStatus, code)
+            );
+            KwtLogisticsOrderTrack orderTrack = logisticsOrderTrackMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderTrack>()
+                    .eq(KwtLogisticsOrderTrack::getLOrderId, orderId)
+                    .eq(KwtLogisticsOrderTrack::getStatus, code)
+                    .eq(KwtLogisticsOrderTrack::getDelFlag, 0)
+            );
+            if (orderTrack != null) {
+                orderTrack.setStatus(code);
+                orderTrack.setUpdateBy(params.getUpdateBy());
+                orderTrack.setUpdateTime(DateUtils.formatDate(params.getUpdateTime()));
+            } else {
+                KwtLogisticsOrderTrack track = new KwtLogisticsOrderTrack();
+                track.setId(new IdWorker(NumberConstant.ONE).nextId());
+                track.setLOrderId(orderId);
+                track.setStatus(code);
+                track.setCreateBy(params.getUpdateById());
+                track.setCreateTime(DateUtils.formatDate(params.getUpdateTime()));
+                track.setUpdateBy(params.getUpdateById());
+                track.setUpdateTime(DateUtils.formatDate(params.getUpdateTime()));
+                track.setDelFlag(0);
+                logisticsOrderTrackMapper.insert(track);
+            }
+        }
+        return HttpResult.ok();
+    }
 }