Parcourir la source

Merge remote-tracking branch 'origin/master'

caozj il y a 1 an
Parent
commit
c793f2457c

+ 8 - 3
hx-sale/src/main/java/com/fjhx/sale/entity/claim/po/ClaimContract.java

@@ -1,13 +1,13 @@
 package com.fjhx.sale.entity.claim.po;
 
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.ruoyi.common.core.domain.BasePo;
 import com.baomidou.mybatisplus.annotation.TableName;
-import java.math.BigDecimal;
-
+import com.ruoyi.common.core.domain.BasePo;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
+
 /**
  * <p>
  * 到账认领-合同关联表
@@ -56,6 +56,11 @@ public class ClaimContract extends BasePo {
     private Integer dataType;
 
     /**
+     * 换算CNY金额
+     */
+    private BigDecimal moneyCny;
+
+    /**
      * 业务ID
      */
     @TableField(exist = false)

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

@@ -46,7 +46,6 @@ import com.fjhx.purchase.entity.arrival.po.ArrivalDetail;
 import com.fjhx.purchase.entity.pay.po.Pay;
 import com.fjhx.purchase.entity.purchase.po.Purchase;
 import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
-import com.fjhx.purchase.entity.purchase.vo.PurchaseDetailVo;
 import com.fjhx.purchase.entity.quality.po.QualityDetail;
 import com.fjhx.purchase.service.arrival.ArrivalDetailService;
 import com.fjhx.purchase.service.pay.PayDetailService;
@@ -66,7 +65,6 @@ import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
 import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProduct;
 import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseProductVo;
 import com.fjhx.sale.entity.sale.vo.SaleQuotationVo;
-import com.fjhx.sale.entity.statement.vo.ProfitSettlementVo;
 import com.fjhx.sale.mapper.contract.ContractMapper;
 import com.fjhx.sale.service.claim.ClaimContractService;
 import com.fjhx.sale.service.contract.*;
@@ -430,6 +428,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
 
     /**
      * 利润预算表头部统计
+     *
      * @param dto
      * @return
      */
@@ -459,9 +458,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
 
     /**
      * 利润预算表统计公共方法
+     *
      * @param list
      */
-    private void statisticCommon(List<ContractBudgetVo> list){
+    private void statisticCommon(List<ContractBudgetVo> list) {
         //取出EHSD采购所有金额和货币-通过合同ID分组
         List<Long> contractIds = list.stream().map(ContractBudgetVo::getContractId).collect(Collectors.toList());
         List<EhsdPurchaseProductVo> ehsdAmountList = ehsdPurchaseProductService.getPurchaseByContractId(contractIds);
@@ -478,7 +478,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
                  */
                 List<EhsdPurchaseProductVo> pList = ehsdAmountMap.getOrDefault(v.getContractId(), null);
                 if (CollectionUtils.isNotEmpty(pList)) {
-                    for(EhsdPurchaseProductVo e : pList){
+                    for (EhsdPurchaseProductVo e : pList) {
                         //获取汇率
                         BigDecimal rate = map.getOrDefault(e.getCurrency(), BigDecimal.ONE);
                         // 获取认领金额
@@ -486,11 +486,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
                         //总金额
                         BigDecimal amount = rate.multiply(money);
                         purchaseAmount = purchaseAmount.add(amount);
-                        if(ObjectUtil.isNotEmpty(e.getProductCategoryIds())){
-                            if(e.getProductCategoryIds().contains("1685534140512616449")||e.getProductCategoryId()==1685534140512616449L){//包材
+                        if (ObjectUtil.isNotEmpty(e.getProductCategoryIds())) {
+                            if (e.getProductCategoryIds().contains("1685534140512616449") || e.getProductCategoryId() == 1685534140512616449L) {//包材
                                 peritectoidAmount = peritectoidAmount.add(amount);
                             }
-                            if(e.getProductCategoryIds().contains("1685534141821239297")||e.getProductCategoryId()==1685534141821239297L){//配件
+                            if (e.getProductCategoryIds().contains("1685534141821239297") || e.getProductCategoryId() == 1685534141821239297L) {//配件
                                 accessoriesAmount = accessoriesAmount.add(amount);
                             }
                         }
@@ -520,7 +520,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
                  */
                 List<EhsdPurchaseProductVo> pList = ehsdAmountMap.getOrDefault(v.getContractId(), null);
                 if (CollectionUtils.isNotEmpty(pList)) {
-                    for(EhsdPurchaseProductVo e : pList){
+                    for (EhsdPurchaseProductVo e : pList) {
                         //获取汇率
                         BigDecimal rate = e.getRate();
                         // 获取认领金额
@@ -528,11 +528,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
                         //总金额
                         BigDecimal amount = rate.multiply(money);
                         purchaseAmount = purchaseAmount.add(amount);
-                        if(ObjectUtil.isNotEmpty(e.getProductCategoryIds())){
-                            if(e.getProductCategoryIds().contains("1685534140512616449")||e.getProductCategoryId()==1685534140512616449L){//包材
+                        if (ObjectUtil.isNotEmpty(e.getProductCategoryIds())) {
+                            if (e.getProductCategoryIds().contains("1685534140512616449") || e.getProductCategoryId() == 1685534140512616449L) {//包材
                                 peritectoidAmount = peritectoidAmount.add(amount);
                             }
-                            if(e.getProductCategoryIds().contains("1685534141821239297")||e.getProductCategoryId()==1685534141821239297L){//配件
+                            if (e.getProductCategoryIds().contains("1685534141821239297") || e.getProductCategoryId() == 1685534141821239297L) {//配件
                                 accessoriesAmount = accessoriesAmount.add(amount);
                             }
                         }
@@ -566,12 +566,14 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
             v.setGrossRate(v.getGross().divide(v.getIncomeAmount(), RoundingMode.CEILING).multiply(new BigDecimal("100")));
         }
     }
+
     /**
      * 统计金额
+     *
      * @return
      */
-    private Map<String,Object> sumStatistic(List<ContractBudgetVo> list){
-        Map<String,Object> map = new HashMap<>();
+    private Map<String, Object> sumStatistic(List<ContractBudgetVo> list) {
+        Map<String, Object> map = new HashMap<>();
         BigDecimal contractSumAmount = BigDecimal.ZERO;
         BigDecimal taxReturnMoneySumAmount = BigDecimal.ZERO;
         BigDecimal purchaseSumAmount = BigDecimal.ZERO;
@@ -588,44 +590,45 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         BigDecimal totalExpensesSumAmount = BigDecimal.ZERO;
         BigDecimal grossProfitMargin = BigDecimal.ZERO;
         for (ContractBudgetVo p : list) {
-            contractSumAmount = contractSumAmount.add(ObjectUtil.isEmpty(p.getRmbContractAmount())?BigDecimal.ZERO:p.getRmbContractAmount());//合同金额
-            taxReturnMoneySumAmount = taxReturnMoneySumAmount.add(ObjectUtil.isEmpty(p.getRefundableAmount())?BigDecimal.ZERO:p.getRefundableAmount());//退税
-            purchaseSumAmount = purchaseSumAmount.add(ObjectUtil.isEmpty(p.getEhsdSumAmount())?BigDecimal.ZERO:p.getEhsdSumAmount());//采购金额
-            peritectoidSumAmount = peritectoidSumAmount.add(ObjectUtil.isEmpty(p.getPeritectoidAmount())?BigDecimal.ZERO:p.getPeritectoidAmount());//包材
-            accessoriesSumAmount = accessoriesSumAmount.add(ObjectUtil.isEmpty(p.getAccessoriesAmount())?BigDecimal.ZERO:p.getAccessoriesAmount());//配件
-            trailerFeeSumAmount = trailerFeeSumAmount.add(ObjectUtil.isEmpty(p.getTrailerFee())?BigDecimal.ZERO:p.getTrailerFee());//拖车费
-            customsFeeSumAmount = customsFeeSumAmount.add(ObjectUtil.isEmpty(p.getCustomsFee())?BigDecimal.ZERO:p.getCustomsFee());//报关费
-            agencyFeeSumAmount = agencyFeeSumAmount.add(ObjectUtil.isEmpty(p.getAgencyFee())?BigDecimal.ZERO:p.getAgencyFee());//代理费
-            portMixedFeeSumAmount = portMixedFeeSumAmount.add(ObjectUtil.isEmpty(p.getProfitAgencyFee())?BigDecimal.ZERO:p.getProfitAgencyFee());//港杂费
-            inspectionRedPackSumAmount = inspectionRedPackSumAmount.add(ObjectUtil.isEmpty(p.getInspectionRedPack())?BigDecimal.ZERO:p.getInspectionRedPack());//验货红包
-            commissionSumAmount = commissionSumAmount.add(ObjectUtil.isEmpty(p.getCommission())?BigDecimal.ZERO:p.getCommission());//佣金
-            otherSumAmount = otherSumAmount.add(ObjectUtil.isEmpty(p.getOther())?BigDecimal.ZERO:p.getOther());//其他
-            totalIncomeSumAmount = totalIncomeSumAmount.add(ObjectUtil.isEmpty(p.getIncomeAmount())?BigDecimal.ZERO:p.getIncomeAmount());//总收入
-            totalExpensesSumAmount = totalExpensesSumAmount.add(ObjectUtil.isEmpty(p.getExpenditureAmount())?BigDecimal.ZERO:p.getExpenditureAmount());//总支出
+            contractSumAmount = contractSumAmount.add(ObjectUtil.isEmpty(p.getRmbContractAmount()) ? BigDecimal.ZERO : p.getRmbContractAmount());//合同金额
+            taxReturnMoneySumAmount = taxReturnMoneySumAmount.add(ObjectUtil.isEmpty(p.getRefundableAmount()) ? BigDecimal.ZERO : p.getRefundableAmount());//退税
+            purchaseSumAmount = purchaseSumAmount.add(ObjectUtil.isEmpty(p.getEhsdSumAmount()) ? BigDecimal.ZERO : p.getEhsdSumAmount());//采购金额
+            peritectoidSumAmount = peritectoidSumAmount.add(ObjectUtil.isEmpty(p.getPeritectoidAmount()) ? BigDecimal.ZERO : p.getPeritectoidAmount());//包材
+            accessoriesSumAmount = accessoriesSumAmount.add(ObjectUtil.isEmpty(p.getAccessoriesAmount()) ? BigDecimal.ZERO : p.getAccessoriesAmount());//配件
+            trailerFeeSumAmount = trailerFeeSumAmount.add(ObjectUtil.isEmpty(p.getTrailerFee()) ? BigDecimal.ZERO : p.getTrailerFee());//拖车费
+            customsFeeSumAmount = customsFeeSumAmount.add(ObjectUtil.isEmpty(p.getCustomsFee()) ? BigDecimal.ZERO : p.getCustomsFee());//报关费
+            agencyFeeSumAmount = agencyFeeSumAmount.add(ObjectUtil.isEmpty(p.getAgencyFee()) ? BigDecimal.ZERO : p.getAgencyFee());//代理费
+            portMixedFeeSumAmount = portMixedFeeSumAmount.add(ObjectUtil.isEmpty(p.getProfitAgencyFee()) ? BigDecimal.ZERO : p.getProfitAgencyFee());//港杂费
+            inspectionRedPackSumAmount = inspectionRedPackSumAmount.add(ObjectUtil.isEmpty(p.getInspectionRedPack()) ? BigDecimal.ZERO : p.getInspectionRedPack());//验货红包
+            commissionSumAmount = commissionSumAmount.add(ObjectUtil.isEmpty(p.getCommission()) ? BigDecimal.ZERO : p.getCommission());//佣金
+            otherSumAmount = otherSumAmount.add(ObjectUtil.isEmpty(p.getOther()) ? BigDecimal.ZERO : p.getOther());//其他
+            totalIncomeSumAmount = totalIncomeSumAmount.add(ObjectUtil.isEmpty(p.getIncomeAmount()) ? BigDecimal.ZERO : p.getIncomeAmount());//总收入
+            totalExpensesSumAmount = totalExpensesSumAmount.add(ObjectUtil.isEmpty(p.getExpenditureAmount()) ? BigDecimal.ZERO : p.getExpenditureAmount());//总支出
         }
         //计算总毛利和总毛利率
         BigDecimal grossProfitSum = totalIncomeSumAmount.subtract(totalExpensesSumAmount);//毛利
-        if (totalIncomeSumAmount.compareTo(BigDecimal.ZERO)>0) {
+        if (totalIncomeSumAmount.compareTo(BigDecimal.ZERO) > 0) {
             grossProfitMargin = new BigDecimal("100").multiply(grossProfitSum).divide(totalIncomeSumAmount, 2, RoundingMode.HALF_UP);//毛利率
         }
-        map.put("contractSumAmount",contractSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("taxReturnMoneySumAmount",taxReturnMoneySumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("purchaseSumAmount",purchaseSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("peritectoidSumAmount",peritectoidSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("accessoriesSumAmount",accessoriesSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("trailerFeeSumAmount",trailerFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("customsFeeSumAmount",customsFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("agencyFeeSumAmount",agencyFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("portMixedFeeSumAmount",portMixedFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("inspectionRedPackSumAmount",inspectionRedPackSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("commissionSumAmount",commissionSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("otherSumAmount",otherSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("totalIncomeSumAmount",totalIncomeSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("totalExpensesSumAmount",totalExpensesSumAmount.setScale(2, RoundingMode.HALF_UP));
-        map.put("grossProfitMargin",grossProfitMargin.setScale(2, RoundingMode.HALF_UP));
-        map.put("grossProfitSum",grossProfitSum.setScale(2, RoundingMode.HALF_UP));
+        map.put("contractSumAmount", contractSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("taxReturnMoneySumAmount", taxReturnMoneySumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("purchaseSumAmount", purchaseSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("peritectoidSumAmount", peritectoidSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("accessoriesSumAmount", accessoriesSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("trailerFeeSumAmount", trailerFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("customsFeeSumAmount", customsFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("agencyFeeSumAmount", agencyFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("portMixedFeeSumAmount", portMixedFeeSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("inspectionRedPackSumAmount", inspectionRedPackSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("commissionSumAmount", commissionSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("otherSumAmount", otherSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("totalIncomeSumAmount", totalIncomeSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("totalExpensesSumAmount", totalExpensesSumAmount.setScale(2, RoundingMode.HALF_UP));
+        map.put("grossProfitMargin", grossProfitMargin.setScale(2, RoundingMode.HALF_UP));
+        map.put("grossProfitSum", grossProfitSum.setScale(2, RoundingMode.HALF_UP));
         return map;
     }
+
     /**
      * 利润结算表分页
      *
@@ -1748,17 +1751,16 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
      */
     private BigDecimal getSumClaimMoney(List<ClaimContract> claimContractList, Map<String, BigDecimal> assignCurrencyRatesMap) {
         BigDecimal sumClaimMoney = BigDecimal.ZERO;
-        if (CollectionUtils.isEmpty(claimContractList)) {
-            return BigDecimal.ZERO;
-        }
-        if (MapUtils.isNotEmpty(assignCurrencyRatesMap)) {
-            for (ClaimContract c : claimContractList) {
-                sumClaimMoney = sumClaimMoney.add(c.getMoney().multiply(assignCurrencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
+        for (ClaimContract c : claimContractList) {
+            BigDecimal rate = c.getRate();
+            if (MapUtils.isNotEmpty(assignCurrencyRatesMap)) {
+                rate = assignCurrencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE);
             }
-        } else {
-            for (ClaimContract c : claimContractList) {
-                sumClaimMoney = sumClaimMoney.add(c.getMoney().multiply(c.getRate()));
+            BigDecimal moneyCny = c.getMoneyCny();
+            if (ObjectUtil.isEmpty(moneyCny)) {
+                moneyCny = c.getMoney().multiply(rate);
             }
+            sumClaimMoney = sumClaimMoney.add(moneyCny);
         }
         return sumClaimMoney;
     }
@@ -2026,9 +2028,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
     public Page<ContractVo> getExportCopyList(ContractSelectDto dto) {
         IWrapper<Contract> wrapper = getWrapper();
         SysUser sysUser = UserUtil.getUserInfo();
-        if (StringUtils.isEmpty(sysUser.getUserCode())) {//不是业务员看所有
-            return pageCommon(dto, wrapper);
-        } else {//是业务员
+        if (StringUtils.isNotEmpty(sysUser.getUserCode())) {//是业务员 过滤权限
             List<Long> authIdList = customerService.getAuthIdList();
             if (authIdList.size() == 0) {
                 return new Page<>();

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

@@ -3,18 +3,17 @@
 <mapper namespace="com.fjhx.sale.mapper.contract.ContractMapper">
     <select id="getPage" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
         SELECT *
-        FROM
-             (SELECT t1.*,
+        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
+                         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)
+                           (SELECT IFNULL(SUM(IFNULL(cc.money_cny, 0)), 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

+ 16 - 17
hx-sale/src/main/resources/mapper/sample/SampleMapper.xml

@@ -3,23 +3,22 @@
 <mapper namespace="com.fjhx.sale.mapper.sample.SampleMapper">
     <select id="getPage" resultType="com.fjhx.sale.entity.sample.vo.SampleVo">
         SELECT *
-        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 sample t1) t1) t1
+        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_cny, 0)), 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 sample t1) t1) t1
             ${ew.customSqlSegment}
     </select>