瀏覽代碼

问题处理

yzc 1 年之前
父節點
當前提交
de9b42d1d0

+ 3 - 3
hx-sale/src/main/java/com/fjhx/sale/controller/contract/ContractController.java

@@ -258,9 +258,9 @@ public class ContractController {
     /**
      * 头部统计客户金额
      */
-    @GetMapping("/getHeadCustomerStatistics")
-    public Map<String,Object> getHeadCustomerStatistics() {
-        return contractService.getHeadCustomerStatistics();
+    @PostMapping("/getHeadCustomerStatistics")
+    public Map<String, Object> getHeadCustomerStatistics(@RequestBody ContractSelectDto dto) {
+        return contractService.getHeadCustomerStatistics(dto);
     }
 
     /**

+ 2 - 1
hx-sale/src/main/java/com/fjhx/sale/mapper/contract/ContractMapper.java

@@ -102,5 +102,6 @@ public interface ContractMapper extends BaseMapper<Contract> {
     List<AccountRunningWaterVo> getAccountRunningWaterByContractId(@Param("contractId") Long contractId);
 
     void updateContract(Contract contract);
-    List<ContractVo> getCustomerMoney(@Param("authIds")List<Long> authIds);
+
+    List<ContractVo> getCustomerMoney(@Param("ew") IWrapper<Contract> wrapper);
 }

+ 2 - 1
hx-sale/src/main/java/com/fjhx/sale/service/contract/ContractService.java

@@ -192,7 +192,8 @@ public interface ContractService extends BaseService<Contract> {
 
     /**
      * 统计头部客户金额
+     *
      * @return
      */
-    Map<String,Object> getHeadCustomerStatistics();
+    Map<String, Object> getHeadCustomerStatistics(ContractSelectDto dto);
 }

+ 43 - 19
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -1668,34 +1668,58 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
 
     /**
      * 头部统计客户金额
+     *
      * @return
      */
     @Override
-    public Map<String, Object> getHeadCustomerStatistics() {
-        Map<String,Object> map = new HashMap<>();
-        map.put("sumAmount",BigDecimal.ZERO);
-        map.put("sumArrivalAmount",BigDecimal.ZERO);
-        map.put("sumQuantity",BigDecimal.ZERO);
-        map.put("list",new ArrayList<>());
+    public Map<String, Object> getHeadCustomerStatistics(ContractSelectDto dto) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("sumAmount", BigDecimal.ZERO);
+        map.put("sumArrivalAmount", BigDecimal.ZERO);
+        map.put("sumQuantity", BigDecimal.ZERO);
+        map.put("list", new ArrayList<>());
+
         List<Long> authIdList = customerService.getAuthIdList();
-        List<ContractVo> list;
-        if(CollectionUtils.isNotEmpty(authIdList)){
-            list = baseMapper.getCustomerMoney(authIdList);
-        }else{
-            list = baseMapper.getCustomerMoney(null);
+        if (authIdList.size() == 0) {
+            return new HashMap<>();
+        }
+        IWrapper<Contract> wrapper = getWrapper();
+        wrapper.in("t1", Contract::getBuyCorporationId, authIdList);
+        wrapper.eq("t1", Contract::getIsChange, "0");//列表只展示未变更得数据
+        wrapper.ne("t1", Contract::getIsShow, 1);
+        wrapper.between("t1", Contract::getStatus, FlowStatusEnum1.DRAFT.getKey(), FlowStatusEnum1.CANCELLATION.getKey() - 1);
+        if (StringUtils.isNotEmpty(dto.getStatus())) {
+            wrapper.eq("t1", Contract::getStatus, dto.getStatus());
         }
-        if(CollectionUtils.isNotEmpty(list)){
-            BigDecimal sumAmount = list.stream().map(ContractVo::getSumAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
-            BigDecimal sumQuantity = list.stream().map(ContractVo::getSumQuantity).reduce(BigDecimal.ZERO,BigDecimal::add);
-            BigDecimal sumClaimMoney = list.stream().map(ContractVo::getSumClaimMoney).reduce(BigDecimal.ZERO,BigDecimal::add);
+        if (StringUtils.isNotEmpty(dto.getSellCorporationId())) {
+            wrapper.eq("t1", Contract::getSellCorporationId, dto.getSellCorporationId());
+        }
+        if (StringUtils.isNotEmpty(dto.getRefundStatusNew())) {
+            wrapper.in("t1.refundStatusNew", Arrays.asList(dto.getRefundStatusNew().split(",")));
+        }
+        if (StringUtils.isNotEmpty(dto.getKeyword())) {
+            wrapper.keyword(dto.getKeyword(), new SqlField("t1", Contract::getCode));
+        }
+        //根据客户id关联
+        wrapper.eq(ContractVo::getBuyCorporationId, dto.getCustomerId());
+        //过滤合同类型
+        wrapper.eq("t1.contract_type", dto.getContractType());
+        wrapper.groupBy("t1.sell_corporation_id");
+        List<ContractVo> list;
+        list = baseMapper.getCustomerMoney(wrapper);
+
+        if (CollectionUtils.isNotEmpty(list)) {
+            BigDecimal sumAmount = list.stream().map(ContractVo::getSumAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal sumQuantity = list.stream().map(ContractVo::getSumQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal sumClaimMoney = list.stream().map(ContractVo::getSumClaimMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
             //赋值原卖方公司名称 多公司
             corporationService.attributeAssign(list, ContractVo::getSellCorporationId, (item, corporation) -> {
                 item.setSellCorporationName(corporation.getName());
             });
-            map.put("sumAmount",sumAmount);
-            map.put("sumArrivalAmount",sumClaimMoney);
-            map.put("sumQuantity",sumQuantity);
-            map.put("list",list);
+            map.put("sumAmount", sumAmount);
+            map.put("sumArrivalAmount", sumClaimMoney);
+            map.put("sumQuantity", sumQuantity);
+            map.put("list", list);
         }
         return map;
     }

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

@@ -241,31 +241,30 @@
     </select>
 
     <select id="getCustomerMoney" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
-        SELECT
-            t1.sell_corporation_id AS sellCorporationId,
-            IFNULL( SUM( t1.amount * t1.rate ), 0 ) AS sumAmount,
-            IFNULL( count(1) ,0 ) AS sumQuantity,
-            (
-                SELECT
-                    IFNULL( SUM( IFNULL( cc.money, 0 ) * IFNULL( cc.rate, 1 )), 0 )
-                FROM
-                    claim_contract cc
-                WHERE
-                    FIND_IN_SET( cc.contract_id, GROUP_CONCAT( t1.id ) )
-            ) AS sumClaimMoney
-        FROM
-            contract t1
-        WHERE
-            t1.is_show != 1
-            AND t1.is_change = 0
-            AND t1.`status` >= 30
-            AND t1.`status` &lt; 88
-            <if test="authIds neq null and authIds.size() > 0">
-                <foreach collection="authIds" item="authId" open="AND t1.buy_corporation_id IN (" separator="," close=")">
-                    #{authId}
-                </foreach>
-            </if>
-        GROUP BY sell_corporation_id
+        SELECT t1.sell_corporation_id                                   AS sellCorporationId,
+               IFNULL(SUM(t1.amount * t1.rate), 0)                      AS sumAmount,
+               IFNULL(count(1), 0)                                      AS sumQuantity,
+               (SELECT IFNULL(SUM(IFNULL(cc.money, 0) * IFNULL(cc.rate, 1)), 0)
+                FROM claim_contract cc
+                WHERE FIND_IN_SET(cc.contract_id, GROUP_CONCAT(t1.id))) AS sumClaimMoney
+        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
+                    FROM contract t1) t1) t1
+            ${ew.customSqlSegment}
     </select>
     <update id="updateContract" parameterType="com.fjhx.sale.entity.contract.po.Contract">
         update contract