he2802 2 years ago
parent
commit
e2de9bf451

+ 9 - 0
zhongzheng-admin-saas/src/main/java/com/zhongzheng/controller/financial/TopDivideLogController.java

@@ -2,6 +2,7 @@ package com.zhongzheng.controller.financial;
 
 import java.util.List;
 import java.util.Arrays;
+import java.util.Map;
 
 import com.zhongzheng.common.constant.UserConstants;
 import com.zhongzheng.common.utils.SecurityUtils;
@@ -116,6 +117,14 @@ public class TopDivideLogController extends BaseController {
         return getDataTable(list);
     }
 
+    @ApiOperation("查询月份订单统计")
+    @PreAuthorize("@ss.hasPermi('system:log:list')")
+    @GetMapping("/monthOrderCount")
+    public AjaxResult<Map<String,Object>> getMonthOrderCount(TopDivideOrderQueryBo bo) {
+        Map<String,Object> map = iTopDivideOrderService.getMonthOrderCount(bo);
+        return AjaxResult.success(map);
+    }
+
     @ApiOperation("查询打印月份订单列表")
     @PreAuthorize("@ss.hasPermi('system:log:list')")
     @GetMapping("/monthOrderListWithPrint")

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/financial/mapper/TopDivideOrderMapper.java

@@ -22,8 +22,12 @@ import java.util.List;
 public interface TopDivideOrderMapper extends BaseMapper<TopDivideOrder> {
     List<TopDivideOrderVo> getFinishList(TopDivideOrderQueryBo bo);
 
+    TopDivideOrderVo getFinishCount(TopDivideOrderQueryBo bo);
+
     List<TopDivideOrderVo> getRefundList(TopDivideOrderQueryBo bo);
 
+    TopDivideOrderVo getRefundCount(TopDivideOrderQueryBo bo);
+
     List<String> getBusinessList(String orderSn);
 
     List<TopDivideOrderVo> getMonthFinishList(TopDivideOrderQueryBo bo);

+ 61 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/financial/service/impl/TopDivideOrderServiceImpl.java

@@ -3,6 +3,7 @@ package com.zhongzheng.modules.top.financial.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo;
 import com.zhongzheng.modules.top.financial.bo.TopDivideOrderAddBo;
@@ -136,12 +137,70 @@ public class TopDivideOrderServiceImpl extends ServiceImpl<TopDivideOrderMapper,
             allList.addAll(fList);
             allList.addAll(rList);
         }
-        return fList;
+        return allList;
     }
 
     @Override
     public Map<String, Object> getMonthOrderCount(TopDivideOrderQueryBo bo) {
-        return null;
+        if(Validator.isEmpty(bo.getDivideModel())||Validator.isEmpty(bo.getDivideLogId())){
+            throw new CustomException("参数错误");
+        }
+        Map<String, Object> map = new HashMap<>();
+        List<TopDivideOrderVo> allList = new ArrayList<>();
+        List<TopDivideOrderVo> fList = baseMapper.getFinishList(bo);
+
+
+        List<TopDivideOrderVo> rList;
+        if(Validator.isEmpty(bo.getRoleId())){
+            rList = baseMapper.getRefundList(bo);
+        }else{
+            rList = new ArrayList<>();
+        }
+
+        for(TopDivideOrderVo vo : rList){
+            if(vo.getPayStatus()==1){
+                vo.setCheckStatus(3);
+            }
+            if(vo.getPayStatus()==0||vo.getPayStatus()==2){
+                vo.setCheckStatus(2);
+            }
+        }
+        if(Validator.isNotEmpty(bo.getOrderType())&&bo.getOrderType()==1){
+            allList.addAll(fList);
+        }
+        else if(Validator.isNotEmpty(bo.getOrderType())&&bo.getOrderType()==2){
+            allList.addAll(rList);
+        }
+        if(Validator.isEmpty(bo.getOrderType())){
+            allList.addAll(fList);
+            allList.addAll(rList);
+        }
+        BigDecimal divideTotalMoney = new BigDecimal(0);
+        BigDecimal orderTotalPrice = new BigDecimal(0);
+        BigDecimal pretaxTotalBrokerage = new BigDecimal(0);
+        BigDecimal accomplishTotalMoney = new BigDecimal(0);
+        for(TopDivideOrderVo vo :allList){
+            if(vo.getOrderType()==1){
+                if(bo.getDivideModel()==1){
+                    divideTotalMoney = divideTotalMoney.add(vo.getDivideCompanyMoney());
+                    accomplishTotalMoney = accomplishTotalMoney.add(vo.getDivideCompanyMoney());
+                }
+                else if(bo.getDivideModel()==2){
+                    divideTotalMoney =divideTotalMoney.add(vo.getDivideSellerMoney());
+                    accomplishTotalMoney = accomplishTotalMoney.add(vo.getDivideSellerMoney());
+                }
+            }else{
+                divideTotalMoney = divideTotalMoney.subtract(vo.getDivideMoney());
+            }
+            orderTotalPrice = orderTotalPrice.add(vo.getOrderPrice());
+            pretaxTotalBrokerage = pretaxTotalBrokerage.add(vo.getPretaxBrokerage());
+
+        }
+        map.put("divideTotalMoney",divideTotalMoney);//应付
+        map.put("orderTotalPrice",orderTotalPrice);  //订单金额
+        map.put("accomplishTotalMoney",accomplishTotalMoney); //完单
+        map.put("pretaxTotalBrokerage",pretaxTotalBrokerage);//税前佣金
+        return map;
     }
 
     @Override

+ 15 - 4
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionMapper.xml

@@ -179,10 +179,21 @@
     </resultMap>
 
     <select id="selectListByBo" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="QuestionResultVo">
-        SELECT
+       SELECT
         q.*
         FROM
         question q
+        LEFT JOIN (SELECT
+        major_id,
+        any_value ( education_type_id ) as  education_type_id,
+        any_value ( business_id ) as  business_id,
+        any_value ( project_id )as  project_id,
+        any_value ( subject_id ) as subject_id
+        FROM
+        question_business
+        where type = 1
+        GROUP BY
+        major_id) qb ON q.question_id = qb.major_id
         WHERE
         1 = 1 AND q.status !=-1
         <if test="status != null and status.size()!=0 ">
@@ -193,16 +204,16 @@
         </if>
 
         <if test="educationTypeId != null and educationTypeId != ''">
-            AND (select count(*) from question_business qb  where qb.type = 1 and qb.major_id = q.question_id and qb.education_type_id = #{educationTypeId}) >0
+            AND qb.education_type_id = #{educationTypeId}
         </if>
         <if test="subjectId != null and subjectId != ''">
-            AND (select count(*) from question_business qb  where qb.type = 1 and qb.major_id = q.question_id and qb.subject_id = #{subjectId}) >0
+            AND qb.subject_id = #{subjectId}
         </if>
         <if test="type != null and type != ''">
             AND q.type = #{type}
         </if>
         <if test="businessId != null and businessId != ''">
-            AND (select count(*) from question_business qb  where qb.type = 1 and qb.major_id = q.question_id and qb.business_id = #{businessId}) >0
+            AND qb.business_id = #{businessId}
         </if>
         <if test="publishStatus != null ">
             AND q.publish_status = #{publishStatus}

+ 75 - 3
zhongzheng-system/src/main/resources/mapper/modules/top/TopDivideOrderMapper.xml

@@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             cl.check_status,
             dl.pay_status,
             dl.divide_type,
-            oo.buy_time as order_time,
+            oo.accomplish_time as order_time,
             oo.remark,
             oo.divide_company_money,
             oo.divide_seller_money,
@@ -59,10 +59,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND oo.accomplish_time <![CDATA[ <= ]]> #{accomplishEndTime}
         </if>
         <if test="checkStatus != null and checkStatus == 0">
-            AND ocl.check_status <![CDATA[ <= ]]> 0
+            AND cl.check_status <![CDATA[ <= ]]> 0
         </if>
         <if test="checkStatus != null and checkStatus == 1">
-            AND ocl.check_status <![CDATA[ >= ]]> 1
+            AND cl.check_status <![CDATA[ >= ]]> 1
+        </if>
+    </select>
+
+    <select id="getFinishCount" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo"  resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
+        SELECT
+        SUM(oo.order_price) as order_price,
+        SUM(oo.divide_company_money) as divide_company_money,
+        SUM(oo.divide_seller_money) as divide_seller_money,
+        SUM(oo.pretax_brokerage) as pretax_brokerage
+        FROM
+        top_divide_order tdo
+        LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
+        LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
+        LEFT JOIN v_top_order oo ON tdo.order_sn =  oo.order_sn
+        LEFT JOIN
+        top_old_order_check_log cl ON (dl.divide_type+1) = cl.check_from AND  cl.check_sign = 1  AND  tdo.order_sn = cl.order_sn
+        LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
+        WHERE
+        tdo.order_type = 1
+        AND tdo.divide_log_id = #{divideLogId}
+        <if test="startPrice != null and startPrice != ''">
+            AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ >= ]]> #{startPrice}
+        </if>
+        <if test="endPrice != null and endPrice != ''">
+            AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ <= ]]> #{endPrice}
+        </if>
+        <if test="orderSn != null and orderSn != ''">
+            AND oo.order_sn = #{orderSn}
+        </if>
+        <if test="accomplishStartTime != null ">
+            AND oo.accomplish_time <![CDATA[ >= ]]> #{accomplishStartTime}
+        </if>
+        <if test="accomplishEndTime != null ">
+            AND oo.accomplish_time <![CDATA[ <= ]]> #{accomplishEndTime}
+        </if>
+        <if test="checkStatus != null and checkStatus == 0">
+            AND cl.check_status <![CDATA[ <= ]]> 0
+        </if>
+        <if test="checkStatus != null and checkStatus == 1">
+            AND cl.check_status <![CDATA[ >= ]]> 1
         </if>
     </select>
 
@@ -108,6 +148,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
     </select>
 
+    <select id="getRefundCount" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo"  resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
+        SELECT
+        SUM(tor.divide_money) as divide_money
+        FROM
+        top_divide_order tdo
+        LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
+        LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
+        LEFT JOIN v_top_order oo ON tdo.order_sn =  oo.order_sn
+        LEFT JOIN top_old_order_refund tor ON tdo.order_sn =  tor.order_sn
+        WHERE
+        tdo.order_type = 2
+        AND tdo.divide_log_id = #{divideLogId}
+        <if test="startPrice != null and startPrice != ''">
+            AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ >= ]]> #{startPrice}
+        </if>
+        <if test="endPrice != null and endPrice != ''">
+            AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ <= ]]> #{endPrice}
+        </if>
+        <if test="orderSn != null and orderSn != ''">
+            AND oo.order_sn = #{orderSn}
+        </if>
+        <if test="accomplishStartTime != null ">
+            AND tor.refund_time <![CDATA[ >= ]]> #{accomplishStartTime}
+        </if>
+        <if test="accomplishEndTime != null ">
+            AND tor.refund_time <![CDATA[ <= ]]> #{accomplishEndTime}
+        </if>
+        <if test="checkStatus != null and checkStatus == 0">
+            AND 1=0
+        </if>
+    </select>
+
     <select id="getBusinessList" parameterType="String"  resultType="String">
         SELECT
             business_name