Browse Source

增加回显字段

xucaiqin 2 years ago
parent
commit
a3cf2573d2

+ 14 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java

@@ -33,6 +33,16 @@ public class WalletController {
         return HttpResult.ok(walletService.walletOverview(queryChannel));
     }
 
+    /**
+     * 渠道开通情况
+     *
+     * @return
+     */
+    @GetMapping("channel")
+    public HttpResult channel() {
+        return HttpResult.ok(walletService.channel());
+    }
+
     /**
      * 查询资金明细
      *
@@ -140,6 +150,7 @@ public class WalletController {
     public HttpResult prePayList(PrePayPage prePayPage) {
         return HttpResult.ok(walletService.prePayList(prePayPage));
     }
+
     /**
      * 预付列表-按渠道统计数量
      *
@@ -149,6 +160,7 @@ public class WalletController {
     public HttpResult prePayCount(String entName) {
         return HttpResult.ok(walletService.walletCount(entName));
     }
+
     /**
      * 预收列表
      *
@@ -159,6 +171,7 @@ public class WalletController {
     public HttpResult preReceiveList(PrePayPage prePayPage) {
         return HttpResult.ok(walletService.preReceiveList(prePayPage));
     }
+
     /**
      * 预收列表-按渠道统计数量
      *
@@ -168,6 +181,7 @@ public class WalletController {
     public HttpResult preReceiveCount(String entName) {
         return HttpResult.ok(walletService.walletCount(entName));
     }
+
     /**
      * 预付校验
      *

+ 2 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java

@@ -14,6 +14,7 @@ import org.apache.ibatis.annotations.Param;
 
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author Aick Spt
@@ -45,6 +46,7 @@ public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLo
      * @date 2023-07-24 16:23
      */
     Long getCountList(@Param("settlementReq") SettlementReq settlementReq);
+    Map<String, Long> count(@Param("settlementReq") SettlementReq settlementReq);
 
     /**
      * 运费-物流订单列表查询合计

+ 19 - 8
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/WalletChannelEnum.java

@@ -2,19 +2,22 @@ package com.sckw.payment.model.constant;
 
 import org.apache.commons.lang3.StringUtils;
 
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * @author Aick Spt
  * @date 2023-07-27 12:54
  */
 public enum WalletChannelEnum {
-    ALL(0, "1", "all", "全部"),
+    ALL(0, "0", "all", "全部"),
 
     //汇付
-    HF(1, "1", "huifu", "汇付"),
+    HF(1, "1", "huifu", "汇付天下"),
     //新生
     XS(2, "2", "newpay", "新生"),
     //中信
-    ZX(3, "3", "citic", "中信");
+    ZX(3, "3", "citic", "中信银行");
 
     private final int status;
     private final String value;
@@ -44,15 +47,13 @@ public enum WalletChannelEnum {
         return value;
     }
 
-    // 添加静态方法,根据 status 获取对应的 desc
-    public static String getStatusDesc(int status) {
+    public static String getDesc(String channel) {
         for (WalletChannelEnum walletChannelEnum : values()) {
-            if (walletChannelEnum.getStatus() == status) {
+            if (StringUtils.equals(walletChannelEnum.getChannel(), channel)) {
                 return walletChannelEnum.getDesc();
             }
         }
-        // 可根据实际需求返回默认值或其他处理
-        return null;
+        return "";
     }
 
     /**
@@ -75,4 +76,14 @@ public enum WalletChannelEnum {
         return null;
     }
 
+    /**
+     * 去除全部的渠道
+     *
+     * @return
+     */
+    public static List<WalletChannelEnum> channelEnumList() {
+        return Arrays.stream(values()).filter(a -> WalletChannelEnum.ALL.getStatus() == a.getStatus()).toList();
+    }
+
+
 }

+ 9 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/ChannelDetail.java

@@ -19,6 +19,11 @@ public class ChannelDetail implements Serializable {
      * 渠道
      */
     private String channel;
+    /**
+     * 渠道名称
+     */
+    private String name;
+
     /**
      * 可用金额统计
      */
@@ -27,4 +32,8 @@ public class ChannelDetail implements Serializable {
      * 总金额统计
      */
     private String totalMoney;
+    /**
+     * 渠道开通状态
+     */
+    private Boolean openFlag = false;
 }

+ 50 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -241,19 +241,25 @@ public class WalletService {
         if (StringUtils.isBlank(uid)) {
             throw new BusinessException("暂未开通电子钱包");
         }
+        //钱包总览信息
         R<WalletOverview> wallet = payCenterService.general(uid);
         if (wallet.getStatus()) {
             WalletOverview data = wallet.getData();
             List<ChannelDetail> channelDetails = new ArrayList<>();
+            //是否查询渠道详情 适配app端
             if (queryChannel) {
+                //查询钱包清单,统计个渠道金额数量等
                 R<List<WalletDto>> wallet1 = payCenterService.wallet(uid, null, "");
                 if (wallet1.getStatus()) {
                     List<WalletDto> data1 = wallet1.getData();
                     if (!CollectionUtils.isEmpty(data1)) {
+                        // 渠道,渠道下的钱包作为的map
                         Map<String, List<WalletDto>> map = data1.stream().collect(Collectors.groupingBy(WalletDto::getChannel));
                         ChannelDetail channelDetail;
                         for (Map.Entry<String, List<WalletDto>> one : map.entrySet()) {
+                            //channel
                             String key = one.getKey();
+                            //channel下的钱包
                             List<WalletDto> value = one.getValue();
                             Long money = 0L;
                             Long totalMoney = 0L;
@@ -265,8 +271,10 @@ public class WalletService {
                             }
                             channelDetail = new ChannelDetail();
                             channelDetail.setChannel(key);
+                            channelDetail.setName(WalletChannelEnum.getDesc(key));
                             channelDetail.setMoney(String.valueOf(money / 100D));
                             channelDetail.setTotalMoney(String.valueOf(totalMoney / 100D));
+                            channelDetail.setOpenFlag(true);
                             channelDetails.add(channelDetail);
                         }
                     }
@@ -278,8 +286,10 @@ public class WalletService {
                     for (String channel : channels) {
                         channelDetail = new ChannelDetail();
                         channelDetail.setChannel(channel);
+                        channelDetail.setName(WalletChannelEnum.getDesc(channel));
                         channelDetail.setMoney("-");
                         channelDetail.setTotalMoney("-");
+                        channelDetail.setOpenFlag(true);
                         channelDetails.add(channelDetail);
                     }
                 }
@@ -290,6 +300,46 @@ public class WalletService {
         return new WalletDetail(LoginUserHolder.getEntName(), "-", "-", "-", 0, new ArrayList<>());
     }
 
+    /**
+     * 渠道开通情况
+     *
+     * @return
+     */
+    public Object channel() {
+        Long entId = LoginUserHolder.getEntId();
+        String uid = walletRelationService.getRelation(entId);
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("暂未开通电子钱包");
+        }
+        R<WalletOverview> wallet = payCenterService.general(uid);
+        if (wallet.getStatus()) {
+            WalletOverview data = wallet.getData();
+            //已开通的渠道
+            List<String> channels = data.getChannels();
+
+            List<ChannelDetail> res = new ArrayList<>();
+            for (WalletChannelEnum value : WalletChannelEnum.channelEnumList()) {
+                ChannelDetail channelDetail = new ChannelDetail();
+                channelDetail.setChannel(value.getChannel());
+                channelDetail.setName(value.getDesc());
+                channelDetail.setMoney("-");
+                channelDetail.setTotalMoney("-");
+                channelDetail.setOpenFlag(channels.contains(value.getChannel()));
+                res.add(channelDetail);
+            }
+            return res;
+        }
+        return WalletChannelEnum.channelEnumList().stream().map(a -> {
+            ChannelDetail channelDetail = new ChannelDetail();
+            channelDetail.setChannel(a.getChannel());
+            channelDetail.setName(a.getDesc());
+            channelDetail.setMoney("-");
+            channelDetail.setTotalMoney("-");
+            channelDetail.setOpenFlag(false);
+            return channelDetail;
+        }).collect(Collectors.toList());
+    }
+
     /**
      * 查询资金明细
      *

+ 11 - 39
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/operate/SettlementLogisticsService.java

@@ -6,14 +6,12 @@ import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.StringTimeUtil;
-import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
 import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.vo.SettlementLogistics;
 import com.sckw.payment.model.vo.req.SettlementReq;
-import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
 import com.sckw.payment.model.vo.res.SettlementLogisticsSumVo;
 import com.sckw.payment.utils.CommonValidator;
 import com.sckw.payment.utils.PageMoreRes;
@@ -43,43 +41,17 @@ public class SettlementLogisticsService {
         settlementReq.setUnitType(LogisticsUnitType.SHIPPER);
         settlementReq.setUnitTypeTwo(LogisticsUnitType.CARRIER);
         validSettlementReq(settlementReq);
-        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
-
-        //加上当前登录者顶级企业id用于过滤数据
-        settlementReq.setEntId(LoginUserHolder.getEntId());
-
-        List<TableTop> tableTops = new ArrayList<>();
-        TableTop tableTop = new TableTop();
-        //总
-        settlementReq.setStatus(SettlementEnum.ALL.getStatus());
-        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.getCountList(settlementReq));
-        tableTop.setName("全部").setValue(settlementReq.getStatus()).setTotal(Math.toIntExact(settlementLogisticsStatusCountVos.getAllCount()));
-        tableTops.add(tableTop);
-
-        //待结算
-        settlementReq.setStatus(SettlementEnum.WAITING_PAYMENT.getStatus());
-//        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.getCountList(settlementReq));
-        Long a = settlementLogisticsMapper.getCountList(settlementReq);
-        settlementLogisticsStatusCountVos.setWaitingPaymentCount(a);
-        TableTop tableTop1 = new TableTop();
-        tableTop1.setName("待结算").setValue(SettlementEnum.WAITING_PAYMENT.getStatus()).setTotal(Math.toIntExact(a));
-        tableTops.add(tableTop1);
-
-        //部分结算
-        settlementReq.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.getCountList(settlementReq));
-        TableTop tableTop2 = new TableTop();
-        tableTop2.setName("部分结算").setValue(SettlementEnum.PARTIAL_PAYMENT.getStatus()).setTotal(Math.toIntExact(settlementLogisticsStatusCountVos.getPartialPaymentCount()));
-        tableTops.add(tableTop2);
-
-        //全部结算
-        settlementReq.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.getCountList(settlementReq));
-        TableTop tableTop3 = new TableTop();
-        tableTop3.setName("全部结算").setValue(SettlementEnum.ALL_PAYMENT.getStatus()).setTotal(Math.toIntExact(settlementLogisticsStatusCountVos.getAllPaymentCount()));
-        tableTops.add(tableTop3);
-
-        return tableTops;
+
+        Map<String, Long> count = settlementLogisticsMapper.count(settlementReq);
+        List<TableTop> res = new ArrayList<>(4);
+        for (SettlementEnum value : SettlementEnum.values()) {
+            TableTop tableTop = new TableTop();
+            tableTop.setName(value.getDesc());
+            tableTop.setValue(value.getStatus());
+            tableTop.setTotal(Math.toIntExact(count.get(value.getLabel())));
+            res.add(tableTop);
+        }
+        return res;
     }
 
     /**

+ 42 - 1
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml

@@ -273,7 +273,48 @@
             <include refid="settlementLogisticsSelectWhere"/>
         </where>
     </select>
-
+    <select id="count" resultType="java.util.Map">
+        select count(1)                           "0",
+               count(if(ksl.status = 3, 1, null)) "3",
+               count(if(ksl.status = 2, 1, null)) "2",
+               count(if(ksl.status = 1, 1, null)) "1"
+        from kwp_settlement_logistics ksl
+                 inner join kwp_ledger_logistics l on ksl.l_ledger_id = l.id and l.del_flag = 0
+                 inner join kwp_ledger_logistics_unit lu on ksl.l_ledger_id = lu.l_ledger_id and lu.del_flag = 0
+        and lu.unit_type = #{settlementReq.unitType,jdbcType=INTEGER}
+                 inner join kwp_ledger_logistics_unit lu2 on ksl.l_ledger_id = lu2.l_ledger_id and lu2.del_flag = 0
+        and lu2.unit_type = #{settlementReq.unitTypeTwo,jdbcType=INTEGER}
+        <where>
+            ksl.del_flag = 0
+            <if test="settlementReq.status != null and settlementReq.status != 0">
+                and ksl.status = #{settlementReq.status}
+            </if>
+            <if test="settlementReq.trading != null and settlementReq.trading != ''">
+                and l.trading = #{settlementReq.trading,jdbcType=VARCHAR}
+            </if>
+            <if test="settlementReq.startCreateTime != null and settlementReq.startCreateTime != ''  and settlementReq.endCreateTime != null  and settlementReq.endCreateTime != ''">
+                and ksl.create_time between #{settlementReq.startCreateTime,jdbcType=TIMESTAMP} and #{settlementReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="settlementReq.startReceiptTime != null and settlementReq.endReceiptTime != null">
+                and ksl.receipt_time between #{settlementReq.startReceiptTime,jdbcType=TIMESTAMP} and #{settlementReq.endReceiptTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="settlementReq.keywords != null and settlementReq.keywords != ''">
+                and (l.name like concat('%'
+                    , #{settlementReq.keywords,jdbcType=VARCHAR}
+                    , '%')
+                    or lu.firm_name like concat('%'
+                        , #{settlementReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                    or lu2.firm_name like concat('%'
+                        , #{settlementReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                    or ksl.sl_order_no like concat('%'
+                        , #{settlementReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                    )
+            </if>
+        </where>
+    </select>
     <!-- 根据结算物流订单id查详情   -->
     <select id="detail" parameterType="java.lang.Long"
             resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">