Kaynağa Gözat

问题处理

yzc 1 yıl önce
ebeveyn
işleme
09f6026aca

+ 8 - 4
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -244,13 +244,19 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         IWrapper<Contract> wrapper = getWrapper();
         setContractParam(dto, wrapper);
         SysUser sysUser = UserUtil.getUserInfo();
+
         Map<String, Object> map = new HashMap<>();
+        map.put("customerList", "");
+        map.put("count", BigDecimal.ZERO);
+        map.put("customerCount", BigDecimal.ZERO);
+        map.put("sumAmount", BigDecimal.ZERO);
+        map.put("sumClaimMoney", BigDecimal.ZERO);
+
         if (StringUtils.isEmpty(sysUser.getUserCode())) {//不是业务员看所有
             map = baseMapper.getHeadStatistic(wrapper);
         } else {//是业务员
             List<Long> authIdList = customerService.getAuthIdList();
             if (authIdList.size() == 0) {
-                map.put("sumAmount", map.getOrDefault("sumAmount", BigDecimal.ZERO));
                 return map;
             }
             wrapper.in("t1", Contract::getBuyCorporationId, authIdList);
@@ -261,8 +267,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
             int customerCount = customers.split(",").length;
             map.put("customerCount", customerCount);
         }
-        map.put("customerList", "");
-        map.put("sumAmount", map.getOrDefault("sumAmount", BigDecimal.ZERO));
         return map;
     }
 
@@ -305,7 +309,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
             wrapper.between("t1", Contract::getStatus, FlowStatusEnum1.DRAFT.getKey(), FlowStatusEnum1.CANCELLATION.getKey() - 1);
         }
         if (StringUtils.isNotEmpty(dto.getUserId())) {
-            wrapper.eq("t1", Contract::getCreateUser, dto.getUserId());
+            wrapper.eq("t1.salesmanId", dto.getUserId());
         }
         if (StringUtils.isNotEmpty(dto.getSellCorporationId())) {
             wrapper.eq("t1", Contract::getSellCorporationId, dto.getSellCorporationId());

+ 26 - 26
hx-sale/src/main/resources/mapper/contract/ContractMapper.xml

@@ -16,6 +16,7 @@
               FROM (SELECT t1.*,
                            c.name                            customerName,
                            us.nick_name                      salesmanName,
+                           us.user_id                        salesmanId,
                            (SELECT IFNULL(SUM(IFNULL(cc.money_cny, IFNULL(cc.money, 0) * IFNULL(arw.rate, 1))), 0)
                             FROM claim_contract cc
                                      left join claim c on cc.claim_id = c.id
@@ -30,32 +31,31 @@
     </select>
 
     <select id="getHeadStatistic" resultType="java.util.Map">
-        SELECT
-            IFNULL( SUM( t1.amountCNY ), 0 ) AS sumAmount,
-            IFNULL( SUM( sumClaimMoney ), 0 ) AS sumClaimMoney,
-            count( 1 ) AS `count`,
-	        GROUP_CONCAT( DISTINCT t1.buy_corporation_id ) AS customerList
-        FROM
-            (SELECT t1.*,
-                    IFNULL(t1.amount, 0) * IFNULL(t1.rate, 0) AS amountCNY,
-                    CASE
-                        WHEN ( IFNULL( t1.amount, 0 ) * IFNULL( t1.rate, 0 ) - t1.sumClaimMoney ) &lt;=  0 THEN
-                            20
-                        WHEN t1.sumClaimMoney = 0 THEN
-                            0
-                        ELSE 10
-                        END                                   AS refundStatusNew
-             FROM (SELECT t1.*,
-                          (SELECT IFNULL(SUM(IFNULL(cc.money, 0) * IFNULL(arw.rate, 1)), 0)
-                           FROM claim_contract cc
-                                    left join claim c on cc.claim_id = c.id
-                                    LEFT JOIN bytesailing_account.account_running_water arw on c.business_id = arw.id
-                           WHERE cc.contract_id = t1.id) AS sumClaimMoney,
-                          c.name                            customerName,
-                          us.nick_name                      salesmanName
-                   FROM contract t1
-                            left join bytesailing_customer.customer c on t1.buy_corporation_id = c.id
-                            left join bytesailing_base.sys_user us on c.user_id = us.user_id) t1) t1
+        SELECT IFNULL(SUM(t1.amountCNY), 0)                              AS sumAmount,
+               IFNULL(SUM(sumClaimMoney), 0)                             AS sumClaimMoney,
+               count(1)                                                  AS `count`,
+               IFNULL(GROUP_CONCAT(DISTINCT t1.buy_corporation_id ), "") AS customerList
+        FROM (SELECT t1.*,
+                     IFNULL(t1.amount, 0) * IFNULL(t1.rate, 0) AS amountCNY,
+                     CASE
+                         WHEN (IFNULL(t1.amount, 0) * IFNULL(t1.rate, 0) - t1.sumClaimMoney) &lt;= 0 THEN
+                             20
+                         WHEN t1.sumClaimMoney = 0 THEN
+                             0
+                         ELSE 10
+                         END                                   AS refundStatusNew
+              FROM (SELECT t1.*,
+                           (SELECT IFNULL(SUM(IFNULL(cc.money, 0) * IFNULL(arw.rate, 1)), 0)
+                            FROM claim_contract cc
+                                     left join claim c on cc.claim_id = c.id
+                                     LEFT JOIN bytesailing_account.account_running_water arw on c.business_id = arw.id
+                            WHERE cc.contract_id = t1.id) AS sumClaimMoney,
+                           c.name                            customerName,
+                           us.nick_name                      salesmanName,
+                           us.user_id                        salesmanId
+                    FROM contract t1
+                             left join bytesailing_customer.customer c on t1.buy_corporation_id = c.id
+                             left join bytesailing_base.sys_user us on c.user_id = us.user_id) t1) t1
             ${ew.customSqlSegment}
     </select>