Procházet zdrojové kódy

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

czh před 2 roky
rodič
revize
4ff06afd8e

+ 3 - 3
sckw-modules/sckw-message/src/main/java/com/sckw/message/dao/KwmMessageUserMapper.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.message.model.KwmMessageUser;
 import com.sckw.message.model.dto.UserMsgCenterLatestMsgDTO;
 import com.sckw.message.model.dto.UserMsgCenterReqDTO;
-import com.sckw.message.model.vo.res.UserMsgCenterResVO;
+import com.sckw.message.model.vo.res.UserCenterMsgVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -32,9 +32,9 @@ public interface KwmMessageUserMapper extends BaseMapper<KwmMessageUser> {
      * @author: yzc
      * @date: 2023-09-07 15:38
      * @Param item:
-     * @return: java.util.List<com.sckw.message.model.vo.res.UserMsgCenterResVO>
+     * @return: java.util.List<com.sckw.message.model.vo.res.UserCenterMsgVO>
      */
-    List<UserMsgCenterResVO> userMsgCenter(@Param(value = "item") UserMsgCenterReqDTO item);
+    List<UserCenterMsgVO> userMsgCenter(@Param(value = "item") UserMsgCenterReqDTO item);
 
     /**
      * @desc: 获取用户最新消息

+ 65 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/res/UserCenterMsgVO.java

@@ -0,0 +1,65 @@
+package com.sckw.message.model.vo.res;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @desc: 用户中心消息vo
+ * @author: yzc
+ * @date: 2023-09-07 14:53
+ */
+@Getter
+@Setter
+@ToString
+@Accessors(chain = true)
+public class UserCenterMsgVO implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1158795911479984678L;
+
+    private Long id;
+
+    /**
+     * 状态:0未读/1已读
+     */
+    private Integer status;
+
+    /**
+     * 消息分类
+     */
+    private String type;
+
+    /**
+     * 消息标题
+     */
+    private String title;
+
+    /**
+     * 未读数量
+     */
+    private Integer num;
+
+    /**
+     * 消息内容
+     */
+    private String content;
+
+    /**
+     * 消息跳转url
+     */
+    private String url;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern="HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+}

+ 5 - 35
sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/res/UserMsgCenterResVO.java

@@ -1,6 +1,5 @@
 package com.sckw.message.model.vo.res;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
@@ -8,7 +7,7 @@ import lombok.experimental.Accessors;
 
 import java.io.Serial;
 import java.io.Serializable;
-import java.util.Date;
+import java.util.List;
 
 /**
  * @desc: 用户消息中心响应vo
@@ -25,43 +24,14 @@ public class UserMsgCenterResVO implements Serializable {
     @Serial
     private static final long serialVersionUID = -3285612805457269859L;
 
-
-    private Long id;
-
-    /**
-     * 状态:0未读/1已读
-     */
-    private Integer status;
-
-    /**
-     * 消息分类
-     */
-    private String type;
-
-    /**
-     * 消息标题
-     */
-    private String title;
-
-    /**
-     * 未读数量
-     */
-    private Integer num;
-
-    /**
-     * 消息内容
-     */
-    private String content;
-
     /**
-     * 消息跳转url
+     * 总未读数据
      */
-    private String url;
+    private Long totalUnReadNum;
 
     /**
-     * 创建时间
+     * 消息列表
      */
-    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    private Date createTime;
+    private List<UserCenterMsgVO> msgList;
 
 }

+ 23 - 5
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/KwmMessageUserService.java

@@ -9,7 +9,7 @@ import com.sckw.message.dao.KwmMessageUserMapper;
 import com.sckw.message.model.KwmMessageUser;
 import com.sckw.message.model.dto.UserMsgCenterLatestMsgDTO;
 import com.sckw.message.model.dto.UserMsgCenterReqDTO;
-import com.sckw.message.model.vo.res.UserMsgCenterResVO;
+import com.sckw.message.model.vo.res.UserCenterMsgVO;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -160,10 +160,10 @@ public class KwmMessageUserService {
      * @author: yzc
      * @date: 2023-09-07 15:40
      * @Param dto:
-     * @return: java.util.List<com.sckw.message.model.vo.res.UserMsgCenterResVO>
+     * @return: java.util.List<com.sckw.message.model.vo.res.UserCenterMsgVO>
      */
-    public List<UserMsgCenterResVO> userMsgCenter(UserMsgCenterReqDTO dto) {
-        List<UserMsgCenterResVO> list = kwmMessageUserMapper.userMsgCenter(dto);
+    public List<UserCenterMsgVO> userMsgCenter(UserMsgCenterReqDTO dto) {
+        List<UserCenterMsgVO> list = kwmMessageUserMapper.userMsgCenter(dto);
         return CollectionUtils.emptyIfNull(list);
     }
 
@@ -175,6 +175,24 @@ public class KwmMessageUserService {
      * @return: com.sckw.message.model.dto.UserMsgCenterLatestMsgDTO
      */
     public UserMsgCenterLatestMsgDTO getLatestMsg(UserMsgCenterReqDTO dto) {
-        return  kwmMessageUserMapper.getLatestMsg(dto);
+        return kwmMessageUserMapper.getLatestMsg(dto);
+    }
+
+    /**
+     * @desc: 统计消息数量
+     * @author: yzc
+     * @date: 2023-09-21 15:18
+     * @Param entId:
+     * @Param userId:
+     * @Param status:
+     * @return: java.lang.Long
+     */
+    public Long count(Long entId, Long userId, Integer status) {
+        LambdaUpdateWrapper<KwmMessageUser> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(Objects.nonNull(entId), KwmMessageUser::getEntId, entId)
+                .eq(Objects.nonNull(userId), KwmMessageUser::getUserId, userId)
+                .eq(Objects.nonNull(status), KwmMessageUser::getStatus, status)
+                .eq(KwmMessageUser::getDelFlag, Global.NO);
+        return kwmMessageUserMapper.selectCount(wrapper);
     }
 }

+ 14 - 7
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/MessageService.java

@@ -24,6 +24,7 @@ import com.sckw.message.model.vo.req.SelectMessagesReqVO;
 import com.sckw.message.model.vo.req.StatisticsMessagesReqVO;
 import com.sckw.message.model.vo.res.KwmMessageListResVO;
 import com.sckw.message.model.vo.res.MessagesStatisticsResVO;
+import com.sckw.message.model.vo.res.UserCenterMsgVO;
 import com.sckw.message.model.vo.res.UserMsgCenterResVO;
 import com.sckw.stream.enums.MessageEnum;
 import com.sckw.system.api.RemoteSystemService;
@@ -276,19 +277,20 @@ public class MessageService {
      * @desc: 用户消息中心获取
      * @author: yzc
      * @date: 2023-09-07 17:41
-     * @return: java.util.List<com.sckw.message.model.vo.res.UserMsgCenterResVO>
+     * @return: com.sckw.message.model.vo.res.UserMsgCenterResVO
      */
-    public List<UserMsgCenterResVO> userMsgCenter() {
+    public UserMsgCenterResVO userMsgCenter() {
         UserMsgCenterReqDTO dto = new UserMsgCenterReqDTO();
         boolean isMain = Objects.equals(LoginUserHolder.getIsMain(), 1);
         dto.setEntId(isMain ? LoginUserHolder.getEntId() : null);
         dto.setUserId(isMain ? null : LoginUserHolder.getUserId());
-        List<UserMsgCenterResVO> result = kwmMessageUserService.userMsgCenter(dto);
-        int size = result.size();
+        //获取消息列表
+        List<UserCenterMsgVO> msgList = kwmMessageUserService.userMsgCenter(dto);
+        int size = msgList.size();
         boolean flag = size < 5;
         Set<MessageEnum> excludeEnums = new HashSet<>();
         String clientType = LoginUserHolder.getClientType();
-        result.forEach(e -> {
+        msgList.forEach(e -> {
             dto.setStatus(e.getStatus()).setType(e.getType());
             UserMsgCenterLatestMsgDTO msg = kwmMessageUserService.getLatestMsg(dto);
             if (Objects.nonNull(msg.getUrl())) {
@@ -305,14 +307,19 @@ public class MessageService {
                 }
             }
         });
+        //补齐默认消息
         if (flag) {
             List<MessageEnum> enums = MessageEnum.getEnums(isMain, 5 - size, excludeEnums);
             enums.forEach(e -> {
-                UserMsgCenterResVO vo = new UserMsgCenterResVO();
+                UserCenterMsgVO vo = new UserCenterMsgVO();
                 vo.setTitle(e.getTitle()).setContent("暂无" + e.getTitle());
-                result.add(vo);
+                msgList.add(vo);
             });
         }
+        //统计总未读消息条数
+        Long unReadNum = kwmMessageUserService.count(dto.getEntId(), dto.getUserId(), 0);
+        UserMsgCenterResVO result = new UserMsgCenterResVO();
+        result.setMsgList(msgList).setTotalUnReadNum(unReadNum);
         return result;
     }
 }

+ 1 - 1
sckw-modules/sckw-message/src/main/resources/mapper/KwmMessageUserMapper.xml

@@ -34,7 +34,7 @@
             </trim>
         </foreach>
     </insert>
-    <select id="userMsgCenter" resultType="com.sckw.message.model.vo.res.UserMsgCenterResVO">
+    <select id="userMsgCenter" resultType="com.sckw.message.model.vo.res.UserCenterMsgVO">
         SELECT
         mu.status as status,
         m.type as type,

+ 4 - 0
sckw-modules/sckw-operation/src/main/java/com/sckw/operation/service/BannerService.java

@@ -76,6 +76,10 @@ public class BannerService {
      */
     private List<KwoBanner> findList(BannerQueryReqVo reqVo) {
         LambdaQueryWrapper<KwoBanner> wrapper = new LambdaQueryWrapper<>();
+        if(Objects.isNull(reqVo.getStatus()))
+        {
+            reqVo.setStatus(1);
+        }
         wrapper.eq(Objects.nonNull(reqVo.getStatus()), KwoBanner::getStatus, reqVo.getStatus()).
                 eq(KwoBanner::getDelFlag, Global.NO).
                 and(StringUtils.isNotBlank(reqVo.getKeywords()),

+ 13 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpWalletTransferMapper.java

@@ -3,16 +3,26 @@ package com.sckw.payment.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpWalletTransfer;
 import com.sckw.payment.model.vo.req.page.MoneyPage;
+import com.sckw.payment.model.vo.res.FundVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
-* @date 2023-09-06 16:42:08
-* @author xucaiqin
-*/
+ * @author xucaiqin
+ * @date 2023-09-06 16:42:08
+ */
 @Mapper
 public interface KwpWalletTransferMapper extends BaseMapper<KwpWalletTransfer> {
     List<KwpWalletTransfer> pageList(@Param("moneyPage") MoneyPage moneyPage);
+
+    /**
+     * 统计转账中金额
+     *
+     * @param fundVo
+     * @return
+     */
+    BigDecimal sumMoney(@Param("fundVo")FundVo fundVo);
 }

+ 0 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerCountSumVo.java

@@ -1,8 +1,6 @@
 package com.sckw.payment.model.vo.res;
 
-import lombok.AllArgsConstructor;
 import lombok.Getter;
-import lombok.NoArgsConstructor;
 import lombok.Setter;
 
 /**
@@ -11,8 +9,6 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-@AllArgsConstructor
-@NoArgsConstructor
 public class LedgerCountSumVo {
     private String totalPrice;
     private String ledgerCount;

+ 8 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java

@@ -148,7 +148,10 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         }};
         LedgerCountSumVo ledgerCountSumVo = logisticsMapper.countSum(logisticsReq, status);
         LedgerCountSumVo ledgerCountSumVo2 = logisticsMapper.countSumMoney(logisticsReq, status);
-        return new LedgerCountSumVo(ledgerCountSumVo2.getTotalPrice(), ledgerCountSumVo.getLedgerCount());
+        LedgerCountSumVo ledgerCountSumVo1 = new LedgerCountSumVo();
+        ledgerCountSumVo1.setTotalPrice(ledgerCountSumVo.getLedgerCount());
+        ledgerCountSumVo1.setLedgerCount(ledgerCountSumVo2.getTotalPrice());
+        return ledgerCountSumVo1;
     }
 
     public PageRes<ILedger> carrierList(LogisticsReq logisticsReq) {
@@ -173,7 +176,10 @@ public class KwpLedgerLogisticsService extends AbsLedger {
         List<Integer> status = new ArrayList<>();
         LedgerCountSumVo ledgerCountSumVo = logisticsMapper.countSum(logisticsReq, status);
         LedgerCountSumVo ledgerCountSumVo2 = logisticsMapper.countSumMoney(logisticsReq, status);
-        return new LedgerCountSumVo(ledgerCountSumVo2.getTotalPrice(), ledgerCountSumVo.getLedgerCount());
+        LedgerCountSumVo ledgerCountSumVo1 = new LedgerCountSumVo();
+        ledgerCountSumVo1.setTotalPrice(ledgerCountSumVo.getLedgerCount());
+        ledgerCountSumVo1.setLedgerCount(ledgerCountSumVo2.getTotalPrice());
+        return ledgerCountSumVo1;
     }
 
     /**

+ 6 - 9
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -1,7 +1,6 @@
 package com.sckw.payment.service;
 
 import com.alibaba.fastjson2.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.NumberConstant;
@@ -237,16 +236,14 @@ public class WalletService {
         }
     }
 
+    /**
+     * 计算转账中金额
+     * @param fundVo
+     */
     private void transferMoney(FundVo fundVo) {
         DecimalFormat df = new DecimalFormat("0.00");
-        LambdaQueryWrapper<KwpWalletTransfer> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwpWalletTransfer::getUid, fundVo.getUid()).eq(KwpWalletTransfer::getFilter, fundVo.getFilter()).eq(KwpWalletTransfer::getChannel, fundVo.getChannel()).eq(KwpWalletTransfer::getStatus, TransferEnum.TRANSFERRING.getStatus()).last("limit 1");
-        KwpWalletTransfer kwpWalletTransfer = kwpWalletTransferMapper.selectOne(wrapper);
-        if (Objects.nonNull(kwpWalletTransfer)) {
-            fundVo.setTransferMoney(df.format(kwpWalletTransfer.getMoney()));
-        } else {
-            fundVo.setTransferMoney("0.00");
-        }
+        BigDecimal bigDecimal = kwpWalletTransferMapper.sumMoney(fundVo);
+        fundVo.setTransferMoney(df.format(bigDecimal));
     }
 
     /**

+ 35 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/task/RefundTask.java

@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.dto.common.R;
 import com.sckw.payment.dao.KwpWalletRefundMapper;
+import com.sckw.payment.dao.KwpWalletTransferMapper;
 import com.sckw.payment.model.KwpWalletRefund;
+import com.sckw.payment.model.KwpWalletTransfer;
 import com.sckw.payment.model.constant.RefundEnum;
+import com.sckw.payment.model.constant.TransferEnum;
 import com.sckw.payment.model.dto.wallet.SplitDto;
 import com.sckw.payment.service.PayCenterService;
 import jakarta.annotation.Resource;
@@ -30,6 +33,8 @@ public class RefundTask {
     private PayCenterService payCenterService;
     @Resource
     private KwpWalletRefundMapper kwpWalletRefundMapper;
+    @Resource
+    private KwpWalletTransferMapper kwpWalletTransferMapper;
 
     @Scheduled(cron = "0 0/1 * * * ? ")
     public void task() {
@@ -37,7 +42,7 @@ public class RefundTask {
         wrapper.eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus());
         List<KwpWalletRefund> kwpWalletRefunds = kwpWalletRefundMapper.selectList(wrapper);
         if (CollectionUtils.isEmpty(kwpWalletRefunds)) {
-//            log.warn("无数据");
+            log.warn("退款定时任务无数据");
             return;
         }
         try {
@@ -59,4 +64,33 @@ public class RefundTask {
             log.error("定时任务异常:{}", ex, ex);
         }
     }
+
+    @Scheduled(cron = "0 0/1 * * * ? ")
+    public void transferTask() {
+        LambdaQueryWrapper<KwpWalletTransfer> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwpWalletTransfer::getStatus, TransferEnum.TRANSFERRING.getStatus());
+        List<KwpWalletTransfer> kwpWalletTransferList = kwpWalletTransferMapper.selectList(wrapper);
+        if (CollectionUtils.isEmpty(kwpWalletTransferList)) {
+            log.warn("转账定时任务无数据");
+            return;
+        }
+        try {
+            for (KwpWalletTransfer kwpWalletTransfer : kwpWalletTransferList) {
+                //查询清分状态,修改退款单状态
+                R<List<SplitDto>> listR = payCenterService.agentPayQuery(kwpWalletTransfer.getUid(), ChannelEnum.getByChannel(kwpWalletTransfer.getChannel()), kwpWalletTransfer.getOrderNo());
+                if (listR.getStatus()) {
+                    List<SplitDto> data = listR.getData();
+                    if (!CollectionUtils.isEmpty(data)) {
+                        if (data.stream().allMatch(a -> a.getStatus() == 1)) {
+                            kwpWalletTransfer.setUpdateTime(LocalDateTime.now());
+                            kwpWalletTransfer.setStatus(TransferEnum.SUCCESS.getStatus());
+                            kwpWalletTransferMapper.updateById(kwpWalletTransfer);
+                        }
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            log.error("转账定时任务异常:{}", ex, ex);
+        }
+    }
 }

+ 17 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpWalletTransferMapper.xml

@@ -55,4 +55,21 @@
             </if>
         </where>
     </select>
+    <select id="sumMoney" resultType="java.math.BigDecimal">
+        select ifnull(sum(kwt.money), 0)
+        from kwp_wallet_transfer kwt
+        <where>
+            kwt.del_flag = 0
+              and kwt.status = 2
+            <if test="fundVo.channel != null and fundVo.channel != ''">
+                and kwt.channel = #{fundVo.channel,jdbcType=VARCHAR}
+            </if>
+            <if test="fundVo.uid != null and fundVo.uid != ''">
+                and kwt.uid = #{fundVo.uid,jdbcType=VARCHAR}
+            </if>
+            <if test="fundVo.filter != null and fundVo.filter != ''">
+                and kwt.filter = #{fundVo.filter,jdbcType=VARCHAR}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 9 - 7
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

@@ -3,7 +3,6 @@ package com.sckw.transport.service;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.core.common.enums.NumberConstant;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
-import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.enums.CarWaybillEnum;
 import com.sckw.core.model.enums.CarWaybillQueryEnum;
@@ -193,10 +192,13 @@ public class WaybillManagementService {
             waybillTicketVO.setDeficitAmount(String.valueOf(info.getDeficitAmount()));
             BigDecimal deficitLoss = info.getLoss() == null ? BigDecimal.valueOf(0) : info.getLoss();
             BigDecimal deficitAmount = info.getDeficitAmount() == null ? BigDecimal.valueOf(0) : info.getDeficitAmount();
-            BigDecimal deficitRealAmount = BigDecimal.valueOf(0);
-            if (deficitAmount.compareTo(BigDecimal.valueOf(0)) > 0) {
-                deficitRealAmount = deficitLoss.subtract(deficitAmount);
-            }
+//            BigDecimal deficitRealAmount = BigDecimal.valueOf(0);
+//            if (deficitAmount.compareTo(BigDecimal.valueOf(0)) > 0) {
+//                deficitRealAmount = deficitLoss.subtract(deficitAmount);
+//            }
+            BigDecimal loadAmount = info.getLoadAmount() == null ? new BigDecimal("0.00") : info.getLoadAmount();
+            BigDecimal unloadAmount = info.getUnloadAmount() == null ? new BigDecimal("0.00") : info.getUnloadAmount();
+            BigDecimal deficitRealAmount = commonService.deficitPrice(info.getLoadAmount(), loadAmount.subtract(unloadAmount), deficitLoss, info.getLossUnit());
             waybillTicketVO.setDeficitRealAmount(deficitRealAmount.toString());
         }
 
@@ -819,10 +821,10 @@ public class WaybillManagementService {
      */
     public HttpResult waybillDataStatisticApp(String keyword, String startDate, String endDate) {
         Long entId = LoginUserHolder.getEntId();
-        if(StringUtils.isNotBlank(startDate)) {
+        if (StringUtils.isNotBlank(startDate)) {
             startDate = startDate.concat(" 00:00:00");
         }
-        if(StringUtils.isNotBlank(endDate)) {
+        if (StringUtils.isNotBlank(endDate)) {
             endDate = endDate.concat(" 00:00:00");
         }
         // 运输途中