Преглед изворни кода

Merge remote-tracking branch 'origin/master'

hanchaolong пре 1 месец
родитељ
комит
56282b5164
14 измењених фајлова са 268 додато и 17 уклоњено
  1. 27 0
      jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/controller/RptFinancialMonthSummaryController.java
  2. 10 0
      jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/domain/BizFinancialAdjustmentRecord.java
  3. 2 0
      jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/mapper/BizFinancialAdjustmentRecordMapper.java
  4. 4 0
      jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/mapper/BizWaybillOrderMapper.java
  5. 2 0
      jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/mapper/RptFinancialMonthSummaryMapper.java
  6. 6 0
      jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/mapper/SysDeptRateMapper.java
  7. 2 0
      jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/service/IRptFinancialMonthSummaryService.java
  8. 1 0
      jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/service/impl/BizWaybillCostDetailsServiceImpl.java
  9. 134 15
      jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/service/impl/RptFinancialMonthSummaryServiceImpl.java
  10. 14 0
      jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/BizFinancialAdjustmentRecordMapper.xml
  11. 3 1
      jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/BizWaybillCostDetailsMapper.xml
  12. 18 0
      jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/BizWaybillOrderMapper.xml
  13. 26 1
      jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/RptFinancialMonthSummaryMapper.xml
  14. 19 0
      jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/SysDeptRateMapper.xml

+ 27 - 0
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/controller/RptFinancialMonthSummaryController.java

@@ -6,6 +6,7 @@ import java.util.Map;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.logistics.annotation.SimpleDictExportUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -98,6 +99,32 @@ public class RptFinancialMonthSummaryController extends BaseController
     }
 
 
+
+
+    /**
+     * 月度账单汇总生成  定时任务定时生成
+     */
+
+    @PostMapping("/recalculateMontSummary")
+    public AjaxResult recalculateMontSummary(@RequestBody Map param)
+    {
+        Object deptIdObj = param.get("deptId");
+        String deptId = (deptIdObj == null) ? null : deptIdObj.toString();
+        Object monthCodeObj = param.get("monthCode");
+        String monthCode = (monthCodeObj == null) ? null : monthCodeObj.toString();
+        if(StringUtils.isBlank(deptId)||StringUtils.isBlank(monthCode)){
+         return    AjaxResult.error("供应商id或账单月份不能为空!");
+        }
+        boolean result=rptFinancialMonthSummaryService.verification( monthCode, deptId );
+        if(result){
+            rptFinancialMonthSummaryService.creatMontSummary(param);
+            return  AjaxResult.success("重新计算成功!");
+        }
+        return AjaxResult.error(" 该供应商在重新计算月份内 存在调账或月度账单状态非待对账状态,无法重新计算!");
+
+
+    }
+
     /**
      * 修改财务月度汇总
      */

+ 10 - 0
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/domain/BizFinancialAdjustmentRecord.java

@@ -63,6 +63,16 @@ public class BizFinancialAdjustmentRecord extends BaseEntity
     private String userName;
 
 
+    @Excel(name = "账单月份")//
+    private String summaryMonth;
+
+    public void setSummaryMonth(String summaryMonth) {
+        this.summaryMonth = summaryMonth;
+    }
+
+    public String getSummaryMonth() {
+        return summaryMonth;
+    }
 
     public void setUserName(String userName) {
         this.userName = userName;

+ 2 - 0
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/mapper/BizFinancialAdjustmentRecordMapper.java

@@ -58,4 +58,6 @@ public interface BizFinancialAdjustmentRecordMapper
      * @return 结果
      */
     public int deleteBizFinancialAdjustmentRecordByFinancialAdjustIds(Long[] financialAdjustIds);
+
+    public List<BizFinancialAdjustmentRecord> selectBizFinancialAdjustmentRecordListNoPermission(BizFinancialAdjustmentRecord bizFinancialAdjustmentRecord);
 }

+ 4 - 0
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/mapper/BizWaybillOrderMapper.java

@@ -2,6 +2,8 @@ package com.ruoyi.logistics.mapper;
 
 import java.time.LocalDate;
 import java.util.List;
+import java.util.Map;
+
 import com.ruoyi.logistics.domain.BizWaybillOrder;
 import com.ruoyi.logistics.domain.dto.OrderStatisticsDto;
 import com.ruoyi.logistics.domain.dto.DailyOrderStatisticsDto;
@@ -88,4 +90,6 @@ public interface BizWaybillOrderMapper
      * @return 订单统计结果列表
      */
     List<DailyOrderStatisticsDto> selectLast7DaysOrderStatisticsByDateRange(BizWaybillOrder bizWaybillOrder);
+
+    void updateRateByMonthAndDept(Map rateParam);
 }

+ 2 - 0
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/mapper/RptFinancialMonthSummaryMapper.java

@@ -69,4 +69,6 @@ public interface RptFinancialMonthSummaryMapper
     List<RptFinancialMonthSummary> selectRptFinancialMonthSummaryListToCheck(RptFinancialMonthSummary rptFinancialMonthSummary);
 
     int updateRptFinancialMonthSummaryByInvoice(RptFinancialMonthSummary rptFinancialMonthSummary);
+
+    List<Map<String, Object>> selectMonthSummaryGroupProductList(Map param);
 }

+ 6 - 0
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/mapper/SysDeptRateMapper.java

@@ -1,6 +1,8 @@
 package com.ruoyi.logistics.mapper;
 
 import java.util.List;
+import java.util.Map;
+
 import com.ruoyi.logistics.domain.SysDeptRate;
 
 /**
@@ -58,4 +60,8 @@ public interface SysDeptRateMapper
      * @return 结果
      */
     public int deleteSysDeptRateByRateIds(Long[] rateIds);
+
+    List<Map<String, Object>> findSysDeptRateList(Map rateParam);
+
+    List<Map<String, Object>> findSysDeptRateListByDept(Map rateParam);
 }

+ 2 - 0
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/service/IRptFinancialMonthSummaryService.java

@@ -72,4 +72,6 @@ public interface IRptFinancialMonthSummaryService
     public int updateRptFinancialMonthSummaryByInvoice(RptFinancialMonthSummary rptFinancialMonthSummary);
 
     int creatMontSummaryAccountAdjustment(Map param);
+
+    boolean verification(String monthCode, String deptId);
 }

+ 1 - 0
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/service/impl/BizWaybillCostDetailsServiceImpl.java

@@ -147,6 +147,7 @@ public class BizWaybillCostDetailsServiceImpl implements IBizWaybillCostDetailsS
     bizFinancialAdjustmentRecord.setUserId(loginUser.getUserid());
     bizFinancialAdjustmentRecord.setDeptId(bizWaybillCostDetails.getDeptId());
         bizFinancialAdjustmentRecord.setAdjustmentReason(bizWaybillCostDetails.getAdjustmentReason());
+        bizFinancialAdjustmentRecord.setSummaryMonth(bizWaybillCostDetails.getSummaryMonth());
     bizFinancialAdjustmentRecordMapper.insertBizFinancialAdjustmentRecord(bizFinancialAdjustmentRecord);
     bizWaybillCostDetails.setUpdateTime(DateUtils.getNowDate());
     bizWaybillCostDetails.setUpdateBy(loginUser.getSysUser().getNickName());

+ 134 - 15
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/service/impl/RptFinancialMonthSummaryServiceImpl.java

@@ -2,20 +2,27 @@ package com.ruoyi.logistics.service.impl;
 
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import com.ruoyi.common.core.utils.DateUtils;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.datascope.annotation.DataScope;
+import com.ruoyi.logistics.callback.SfFeePushCallback;
+import com.ruoyi.logistics.domain.BizFinancialAdjustmentRecord;
+import com.ruoyi.logistics.domain.SysDeptRate;
+import com.ruoyi.logistics.mapper.BizFinancialAdjustmentRecordMapper;
+import com.ruoyi.logistics.mapper.BizWaybillOrderMapper;
+import com.ruoyi.logistics.mapper.SysDeptRateMapper;
+import org.apache.commons.collections4.CollectionUtils;
 import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.logistics.mapper.RptFinancialMonthSummaryMapper;
 import com.ruoyi.logistics.domain.RptFinancialMonthSummary;
 import com.ruoyi.logistics.service.IRptFinancialMonthSummaryService;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 财务月度汇总Service业务层处理
@@ -24,11 +31,15 @@ import com.ruoyi.logistics.service.IRptFinancialMonthSummaryService;
  * @date 2026-01-29
  */
 @Service
-public class RptFinancialMonthSummaryServiceImpl implements IRptFinancialMonthSummaryService 
+public class RptFinancialMonthSummaryServiceImpl implements IRptFinancialMonthSummaryService
 {
+    private static final Logger logger = LoggerFactory.getLogger(RptFinancialMonthSummaryServiceImpl.class);
     @Autowired
     private RptFinancialMonthSummaryMapper rptFinancialMonthSummaryMapper;
-
+    @Autowired
+    private SysDeptRateMapper sysDeptRateMapper;
+    @Autowired
+    private BizWaybillOrderMapper bizWaybillOrderMapper;
     /**
      * 查询财务月度汇总
      * 
@@ -103,29 +114,137 @@ public class RptFinancialMonthSummaryServiceImpl implements IRptFinancialMonthSu
 
 
     /**
-     * 新增财务月度汇总
+     * 新增财务月度汇总   这个方法针对  月度账单任务  和 重新计算
      * 1.定时任务执行所有供应商生成财务月度汇总    传值汇总月份  monthCode
-     * 2.每次调整流水后需要对供应商进行重新生成汇总覆盖   传值部门id    deptId
+     * 2.重新计算   传值部门id    deptId
      *  部门Id和 账单月份必传其一  分别代表以上两种情况
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int creatMontSummary( Map param) {
         LocalDate today = LocalDate.now();
         LocalDate lastMonth = today.minusMonths(1);
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM");
         // 格式化上个月日期为字符串
-        String formattedDate = lastMonth.format(formatter);
-        //按照传值条件查询统计账单情况
-        param.put("monthCode",StringUtils.isNotBlank(param.get("monthCode").toString())?param.get("monthCode").toString():formattedDate);
-        param.put("deptId", StringUtils.isNotBlank(param.get("deptId").toString())?param.get("deptId").toString():null);
+        String defaultMonth = lastMonth.format(formatter);
+
+        Object deptIdObj = param.get("deptId");
+        String deptId = (deptIdObj == null) ? null : deptIdObj.toString();
+        Object monthCodeObj = param.get("monthCode");
+        String monthCode = (monthCodeObj == null) ? null : monthCodeObj.toString();
+        if (monthCode == null) {
+            monthCode = defaultMonth;
+        }
+        //按照传值条件查询统计账单情况  默认给时间 是因为生成月份 供应商是要去生成哪个以及重新计算
+        param.put("monthCode",monthCode);
+        param.put("deptId",deptId);
+
+        if(StringUtils.isNotBlank(deptId)){
+            if(!verification(param.get("monthCode").toString(),deptId)){
+                logger.info("该供应商月份内已对账之后状态  无法重新计算或定时重新生成月度账单 - 供应商id: {}, 月度: {}",deptId,monthCode);
+                return 0;
+            }
+        }
+
+
+        /*计算区间金额
+        * 月份
+        * 供应商id
+        * */
+        List<Map<String,Object>> monthSummaryGroupProductList=rptFinancialMonthSummaryMapper.selectMonthSummaryGroupProductList(param);
+        for (Map<String, Object> map : monthSummaryGroupProductList) {
+             // 拿到当前供应商 配置的 物流公司  产品类型  ,以下四个参数不能为空  为空跳过循环 执行下一条数据
+            String payableAmount = Objects.toString(map.get("payable_amount"), "");
+            String orderType = Objects.toString(map.get("order_type"), "");
+            String productCode = Objects.toString(map.get("product_code"), "");
+            String currentDeptId = Objects.toString(map.get("dept_id"), "");
+            if (StringUtils.isAnyBlank(payableAmount, orderType, productCode, currentDeptId)) {
+                continue;
+            }
+
+            // 校验当前部门和月份是否已经存在账单且状态为已对账
+           if(!verification(monthCode,currentDeptId)){
+               logger.info("该供应商月份内已对账之后状态  或已调账    无法重新生成月度账单 - 供应商id: {}, 月度: {}",currentDeptId,monthCode);
+               continue;
+           }
+            //拿到当前供应商 配置的 物流公司  产品类型  区间内的 折扣值
+            Map rateParam= new HashMap();
+            rateParam.put("payableAmount",payableAmount);
+            rateParam.put("companyType",orderType);
+            rateParam.put("productCode",productCode);
+            rateParam.put("deptId",currentDeptId);
+            rateParam.put("monthCode",monthCode);
+            List<Map<String,Object>> list= sysDeptRateMapper.findSysDeptRateList(rateParam);
+            //还要查一下该供应商 物流公司  产品类型 下的配置  按照结束区间倒叙  或者只取一条
+            List<Map<String,Object>> listRate= sysDeptRateMapper.findSysDeptRateListByDept(rateParam);
+            //先看看这个供应商这个物流公司 这个产品类型 有没有配置折扣
+            if(listRate.size()!=0){
+                //再看区间内有没有
+                if(list.size()==1){
+                    rateParam.put("rate",list.get(0).get("rate"));
+                    bizWaybillOrderMapper.updateRateByMonthAndDept(rateParam);
+                }
+                //区间没有  那就拿查到的产品类型 最大的一条
+                else{
+                    rateParam.put("rate",listRate.get(0).get("rate"));
+                    bizWaybillOrderMapper.updateRateByMonthAndDept(rateParam);
+                }
+            }
+            else{
+             //这个供应商该产品下  没配置
+                logger.info("该供应商未配置该产品折扣信息 - 供应商id: {}, 物流公司: {}, 产品类型: {}",currentDeptId,orderType.equals("1")?"京东":"顺丰",productCode);
+                rateParam.put("rate",10);
+                bizWaybillOrderMapper.updateRateByMonthAndDept(rateParam);
+            }
+        }
         List<Map<String,Object>> monthSummaryList=rptFinancialMonthSummaryMapper.selectMonthSummaryList(param);
-        if(monthSummaryList.size()==0){
-            return 0;
+        if (CollectionUtils.isNotEmpty(monthSummaryList)) {
+            rptFinancialMonthSummaryMapper.insertBachRptFinancialMonthSummary(monthSummaryList);
+        }
+            return 1;
+
+    }
+
+
+
+    /*校验供应商该月份内是否可以重新计算
+    已对账 已开票 回传商城  不能重新计算 false
+    待对账    可以重新计算     true
+     */
+    @Autowired
+    private BizFinancialAdjustmentRecordMapper bizFinancialAdjustmentRecordMapper;
+    public boolean verification(String monthCode,String deptId){
+        if (StringUtils.isBlank(monthCode) || StringUtils.isBlank(deptId)) {
+            return false;
+        }
+        try {
+            RptFinancialMonthSummary summary = new RptFinancialMonthSummary();
+            summary.setDeptId(Long.valueOf(deptId));
+            summary.setSummaryMonth(monthCode);
+            List<RptFinancialMonthSummary> listMonth=rptFinancialMonthSummaryMapper.selectRptFinancialMonthSummaryList(summary);
+            //还要检查下   这个供应商  这个月份  有没有调账记录  去调账记录表中查询
+            if(listMonth.size()>=1){
+                if("1".equals(listMonth.get(0).getStatus())){
+                    BizFinancialAdjustmentRecord bizFinancialAdjustmentRecord= new BizFinancialAdjustmentRecord();
+                    bizFinancialAdjustmentRecord.setDeptId(Long.valueOf(deptId));
+                    bizFinancialAdjustmentRecord.setSummaryMonth(monthCode);
+                    int adjustmentTotal= bizFinancialAdjustmentRecordMapper.selectBizFinancialAdjustmentRecordListNoPermission(bizFinancialAdjustmentRecord).size();
+                    if (adjustmentTotal>0){
+                        return false;
+                    }
+                    return true;
+                }
+                return false;
+             }
+            return true;
+        } catch (Exception e) {
+            logger.error("校验状态异常", e);
+            return false;
         }
-        return rptFinancialMonthSummaryMapper.insertBachRptFinancialMonthSummary(monthSummaryList);
     }
 
 
+
     @Override
     public int creatMontSummaryAccountAdjustment( Map param) {
         LocalDate today = LocalDate.now();

+ 14 - 0
jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/BizFinancialAdjustmentRecordMapper.xml

@@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="update_by"    />
         <result property="userName"    column="user_name"    />
         <result property="deptName"    column="dept_name"    />
+        <result property="summaryMonth"    column="summary_month"    />
     </resultMap>
 
     <sql id="selectBizFinancialAdjustmentRecordVo">
@@ -52,6 +53,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
      order by a.create_time DESC
 
     </select>
+
+
+
+
+    <select id="selectBizFinancialAdjustmentRecordListNoPermission" parameterType="com.ruoyi.logistics.domain.BizFinancialAdjustmentRecord" resultMap="BizFinancialAdjustmentRecordResult">
+        <include refid="selectBizFinancialAdjustmentRecordVo"/>
+        where a.dept_id = #{deptId}  and  a.summary_month=#{summaryMonth}
+
+    </select>
+
+
     
     <select id="selectBizFinancialAdjustmentRecordByFinancialAdjustId" parameterType="Long" resultMap="BizFinancialAdjustmentRecordResult">
         <include refid="selectBizFinancialAdjustmentRecordVo"/>
@@ -76,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="delFlag != null">del_flag,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
+            <if test="summaryMonth != null">summary_month,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="waybillNo != null">#{waybillNo},</if>
@@ -93,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="delFlag != null">#{delFlag},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
+            <if test="summaryMonth != null">#{summaryMonth},</if>
          </trim>
     </insert>
 

+ 3 - 1
jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/BizWaybillCostDetailsMapper.xml

@@ -51,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.external_waybill_no,
             a.fee_item_code,
             a.fee_item_name,
+            a.amount,
             ifnull( a.adjust_amount, a.rate_amount ) rate_amount,
             DATE_FORMAT( b.sign_time, '%Y.%m' )  summaryMonth,
             a.remark,
@@ -72,7 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>
             b.order_status = 5
             <if test="summaryMonth != null "> AND DATE_FORMAT( b.sign_time, '%Y.%m' ) = #{summaryMonth}</if>
-            <if test="deptId != null "> AND a.dept_id = #{deptId}</if>
+            <if test="deptId != null "> AND b.dept_id = #{deptId}</if>
             <if test="externalWaybillNo != null  and externalWaybillNo != ''"> and a.external_waybill_no = #{externalWaybillNo}</if>
             ${params.dataScope}
 
@@ -134,6 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         a.external_waybill_no,
         a.fee_item_code,
         a.fee_item_name,
+        a.amount,
         ifnull( a.adjust_amount, a.rate_amount ) rate_amount,
         DATE_FORMAT( b.sign_time, '%Y.%m' )  summaryMonth,
         a.remark,

+ 18 - 0
jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/BizWaybillOrderMapper.xml

@@ -424,4 +424,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where waybill_id = #{waybillId}
     </update>
 
+
+
+
+
+
+    <update id="updateRateByMonthAndDept" parameterType="java.util.Map">
+        UPDATE biz_waybill_cost_details
+        SET
+            rate_amount = ROUND(amount * #{rate} / 10, 2)
+
+        WHERE
+            external_waybill_no in (
+              select   external_waybill_no from   biz_waybill_order where order_type= #{companyType}  and product_code= #{productCode}  and order_status=5
+               AND DATE_FORMAT( sign_time, '%Y.%m' )= #{monthCode} and dept_id= #{deptId}
+                )
+           and  fee_item_name='快递运费'
+
+    </update>
 </mapper>

+ 26 - 1
jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/RptFinancialMonthSummaryMapper.xml

@@ -189,7 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     ifnull(adjust_amount, rate_amount  )) payable_amount
         FROM
             ( SELECT * FROM biz_waybill_order WHERE order_status = 5 AND DATE_FORMAT( sign_time, '%Y.%m' )= #{monthCode}
-        <if test="deptId != null"> and  dept_id = #{deptId}</if>
+        <if test="deptId != null and deptId !='' "> and  dept_id = #{deptId}</if>
                                               ) a
                 INNER JOIN biz_waybill_cost_details b ON a.external_waybill_no = b.external_waybill_no
         WHERE
@@ -198,6 +198,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.dept_id
     </select>
 
+
+
+
+    <select id="selectMonthSummaryGroupProductList"  parameterType="java.util.Map" resultType="java.util.HashMap"  >
+        SELECT
+        #{monthCode} summary_month,
+        a.dept_id,
+        a.order_type,
+        a.product_code,
+        count( DISTINCT a.external_waybill_no ) transaction_count,
+        sum(amount) payable_amount
+        FROM
+        ( SELECT * FROM biz_waybill_order WHERE order_status = 5 AND DATE_FORMAT( sign_time, '%Y.%m' )= #{monthCode}
+        <if test="deptId != null and deptId != '' " > and  dept_id = #{deptId}</if>
+        ) a
+        INNER JOIN biz_waybill_cost_details b ON a.external_waybill_no = b.external_waybill_no
+        WHERE
+        b.fee_item_name='快递运费'
+        <if test="waybillNo != null"> and  a.external_waybill_no = #{waybillNo}</if>
+        GROUP BY
+        a.dept_id,a.order_type,a.product_code
+    </select>
+
+
+
     <insert id="insertBachRptFinancialMonthSummary" parameterType="java.util.List"  >
         INSERT INTO rpt_financial_month_summary (summary_month, payable_amount, transaction_count,dept_id,status,create_time) VALUES
         <foreach collection="list" item="item" separator=",">

+ 19 - 0
jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/SysDeptRateMapper.xml

@@ -99,4 +99,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{rateId}
         </foreach>
     </delete>
+
+
+
+
+    <select id="findSysDeptRateList"  parameterType="java.util.Map" resultType="java.util.HashMap"  >
+        select  rate from  sys_dept_rate where dept_id= #{deptId}
+        and  company_type= #{companyType}  and  product_type=  #{productCode}
+         and interval_begins <![CDATA[ < ]]> #{payableAmount}  and interval_ends>=#{payableAmount}
+
+    </select>
+
+
+
+    <select id="findSysDeptRateListByDept"  parameterType="java.util.Map" resultType="java.util.HashMap"  >
+        select  rate from  sys_dept_rate where dept_id= #{deptId}
+         and  company_type= #{companyType}  and  product_type=  #{productCode}
+          order by   interval_ends desc
+
+    </select>
 </mapper>