Răsfoiți Sursa

物流对账列表接口和统计接口数据权限

xucaiqin 2 ani în urmă
părinte
comite
429158e849

+ 19 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerLogisticsMapper.java

@@ -30,7 +30,7 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      * @param logisticsReq
      * @return
      */
-    List<LedgerShipperDto> shipperSelect(@Param("logisticsReq") LogisticsReq logisticsReq,@Param("authList")List<Long> authList);
+    List<LedgerShipperDto> shipperSelect(@Param("logisticsReq") LogisticsReq logisticsReq, @Param("authList") List<Long> authList);
 
     /**
      * 运营端
@@ -46,7 +46,7 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      * @param logisticsReq
      * @return
      */
-    List<LedgerCarrierDto> carrierSelect(@Param("logisticsReq") LogisticsReq logisticsReq,@Param("authList")List<Long> authList);
+    List<LedgerCarrierDto> carrierSelect(@Param("logisticsReq") LogisticsReq logisticsReq, @Param("authList") List<Long> authList);
 
     /**
      * 统计订单数量
@@ -56,6 +56,23 @@ public interface KwpLedgerLogisticsMapper extends BaseMapper<KwpLedgerLogistics>
      */
     Map<String, Long> countOrder(@Param("logisticsReq") LogisticsReq logisticsReq);
 
+    /**
+     * 承运方统计订单数量
+     *
+     * @param logisticsReq
+     * @return
+     */
+    Map<String, Long> countSendOrder(@Param("logisticsReq") LogisticsReq logisticsReq, @Param("authList") List<Long> authList);
+
+    /**
+     * 托运方统计订单数量
+     *
+     * @param logisticsReq
+     * @param authList
+     * @return
+     */
+    Map<String, Long> countAuditOrder(@Param("logisticsReq") LogisticsReq logisticsReq, @Param("authList") List<Long> authList);
+
     /**
      * 运营端统计
      *

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

@@ -650,7 +650,14 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      */
     public List<TableTop> orderCount(LogisticsReq logisticsReq) {
         logisticsReq.setEntId(LoginUserHolder.getEntId());
-        Map<String, Long> map = logisticsMapper.countOrder(logisticsReq);
+        Map<String, Long> map;
+        List<Long> authUserIdList = LoginUserHolder.getAuthUserIdList();
+        if (Objects.equals(logisticsReq.getUnitType(), LogisticsUnitType.SHIPPER)) {
+            map = logisticsMapper.countSendOrder(logisticsReq, authUserIdList);
+        } else {
+            map = logisticsMapper.countSendOrder(logisticsReq, authUserIdList);
+
+        }
         TableTop ledgerCountVo;
         /*统计数据转换*/
         List<TableTop> res = new ArrayList<>();

+ 133 - 7
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -116,7 +116,6 @@
                kllu.firm_name    firmName,
                kll.order_count   orderCount
         from kwp_ledger_logistics kll
-                 inner join kwp_ledger_logistics_track kllt on kll.id = kllt.l_ledger_id and kllt.del_flag = 0
                  inner join kwp_ledger_logistics_unit kllu
                             on kll.id = kllu.l_ledger_id and kllu.del_flag = 0 and
                                kllu.unit_type = #{logisticsReq.unitType,jdbcType=INTEGER}
@@ -149,18 +148,30 @@
                     )
             </if>
             and (
+            case
+                when kll.status = 2 then
+                    true
+            when kll.status in (3, 4, 5) then
             (
-                    kllt.status = 1 and
-                kllt.create_by in
+            (
+                kllu2.contacts_id in
             <foreach collection="authList" item="item" open="(" close=")" separator=",">
                 #{item,jdbcType=BIGINT}
-            </foreach>
-            )
-                or kllu2.contacts_id in
+            </foreach>)
+            or
+        (
+        select kllt.id
+        from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
+                                               and kllt.l_ledger_id = kll.id
+                                               and kllt.status in (3, 5)
+                                               and kllt.create_by in
             <foreach collection="authList" item="item" open="(" close=")" separator=",">
                 #{item,jdbcType=BIGINT}
             </foreach>
             )
+                )
+                end
+                )
         </where>
         order by kll.generate_time desc
     </select>
@@ -396,7 +407,122 @@
         </where>
         order by kll.generate_time desc
     </select>
-
+    <!--对账发起方-->
+    <select id="countSendOrder" resultType="java.util.Map">
+        SELECT count(1)                           "0",
+               count(IF(kll.status = 1, 1, NULL)) "1",
+               count(IF(kll.status = 2, 1, NULL)) "2",
+               count(IF(kll.status = 3, 1, NULL)) "3",
+               count(IF(kll.status = 4, 1, NULL)) "4",
+               count(IF(kll.status = 5, 1, NULL)) "5",
+               count(IF(kll.status = 6, 1, NULL)) "6"
+        FROM kwp_ledger_logistics kll
+                 inner join kwp_ledger_logistics_unit kllu
+                            on kll.id = kllu.l_ledger_id and kllu.del_flag = 0 and
+                               kllu.unit_type = #{logisticsReq.unitType,jdbcType=INTEGER}
+                 inner join kwp_ledger_logistics_unit kllu2
+                            on kll.id = kllu2.l_ledger_id and kllu2.del_flag = 0 and
+                               kllu2.unit_type = #{logisticsReq.unitTypeTwo,jdbcType=INTEGER}
+        <where>
+            kll.del_flag = 0
+              and kllu2.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
+            <if test="logisticsReq.trading != null">
+                and kll.trading = #{logisticsReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="logisticsReq.startCreateTime != null and logisticsReq.startCreateTime != '' and logisticsReq.endCreateTime != null and logisticsReq.endCreateTime != ''">
+                and kll.generate_time between #{logisticsReq.startCreateTime,jdbcType=TIMESTAMP}
+                    and #{logisticsReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="logisticsReq.keywords != null and logisticsReq.keywords != ''">
+                and (
+                            kll.l_ledger_no like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kllu.firm_name like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                    )
+            </if>
+            and (
+            case when kll.status in (1, 6)
+                then
+                kll.create_by in
+            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                #{item,jdbcType=BIGINT}
+            </foreach>
+            when kll.status in (2, 3, 4, 5) then
+            (
+                kll.create_by in
+            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                #{item,jdbcType=BIGINT}
+            </foreach>
+            or kllu2.contacts_id in
+            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                #{item,jdbcType=BIGINT}
+            </foreach>
+            )
+                end
+                )
+        </where>
+    </select>
+    <!--对账审核方-->
+    <select id="countAuditOrder" resultType="java.util.Map">
+        SELECT count(1)                           "0",
+               count(IF(kll.status = 1, 1, NULL)) "1",
+               count(IF(kll.status = 2, 1, NULL)) "2",
+               count(IF(kll.status = 3, 1, NULL)) "3",
+               count(IF(kll.status = 4, 1, NULL)) "4",
+               count(IF(kll.status = 5, 1, NULL)) "5",
+               count(IF(kll.status = 6, 1, NULL)) "6"
+        FROM kwp_ledger_logistics kll
+                 inner join kwp_ledger_logistics_unit kllu
+                            on kll.id = kllu.l_ledger_id and kllu.del_flag = 0 and
+                               kllu.unit_type = #{logisticsReq.unitType,jdbcType=INTEGER}
+                 inner join kwp_ledger_logistics_unit kllu2
+                            on kll.id = kllu2.l_ledger_id and kllu2.del_flag = 0 and
+                               kllu2.unit_type = #{logisticsReq.unitTypeTwo,jdbcType=INTEGER}
+        <where>
+            kll.del_flag = 0
+              and kllu2.top_ent_id = #{logisticsReq.entId,jdbcType=BIGINT}
+              and kll.status not in (1, 6)
+            <if test="logisticsReq.trading != null">
+                and kll.trading = #{logisticsReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="logisticsReq.startCreateTime != null and logisticsReq.startCreateTime != '' and logisticsReq.endCreateTime != null and logisticsReq.endCreateTime != ''">
+                and kll.generate_time between #{logisticsReq.startCreateTime,jdbcType=TIMESTAMP}
+                    and #{logisticsReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="logisticsReq.keywords != null and logisticsReq.keywords != ''">
+                and (
+                            kll.l_ledger_no like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kllu.firm_name like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
+                    )
+            </if>
+            and (
+            case
+                when kll.status = 2 then
+                    true
+            when kll.status in (3, 4, 5) then
+            (
+            (
+                kllu2.contacts_id in
+            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                #{item,jdbcType=BIGINT}
+            </foreach>)
+            or
+        (
+        select kllt.id
+        from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
+                                               and kllt.l_ledger_id = kll.id
+                                               and kllt.status in (3, 5)
+                                               and kllt.create_by in
+            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                #{item,jdbcType=BIGINT}
+            </foreach>
+            )
+                )
+                end
+                )
+        </where>
+    </select>
     <select id="countOrder" resultType="java.util.Map">
         SELECT count(1)                           "0",
                count(IF(kll.status = 1, 1, NULL)) "1",