Commit ffe09aab80d975bf67e41e174c2ed350e92a9a4a

Authored by zhangmeiyang
1 parent c2c975fa

新增保证金扣减业务

Showing 23 changed files with 274 additions and 423 deletions
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/component/BillTrans.java
... ... @@ -26,12 +26,12 @@ public class BillTrans {
26 26 /**
27 27 * 交易费项目
28 28 *
29   - * @param fEntityDetail F 实体详细信息
  29 + * @param fEntityDetail
30 30 */
31 31 public void transFeeItem(List<FEntityDetail> fEntityDetail) {
32 32 fEntityDetail.forEach(e -> {
33 33 if (!ObjectUtils.isEmpty(e.getFCOSTID())) {
34   - transferComponent.transFCOSTID(e.getFCOSTID());
  34 + transferComponent.transFCOSTID(e);
35 35 }
36 36 });
37 37 }
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/component/RecTrans.java
... ... @@ -33,7 +33,7 @@ public class RecTrans {
33 33 public void transFeeItem(List<FRECEIVEBILLENTRY> freceivebillentry) {
34 34 freceivebillentry.forEach(e -> {
35 35 if (!ObjectUtils.isEmpty(e.getFCOSTID())) {
36   - transferComponent.transFCOSTID(e.getFCOSTID());
  36 + transferComponent.transFCOSTID(e);
37 37 }
38 38 });
39 39 }
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/component/RefundTrans.java
... ... @@ -26,7 +26,7 @@ public class RefundTrans {
26 26 public void transFeeItem(List<FREFUNDBILLENTRY> frefundbillentry) {
27 27 frefundbillentry.forEach(e -> {
28 28 if (!ObjectUtils.isEmpty(e.getFCOSTID())) {
29   - transferComponent.transFCOSTID(e.getFCOSTID());
  29 + transferComponent.transFCOSTID(e);
30 30 }
31 31 });
32 32 }
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/component/TransferComponent.java
... ... @@ -2,12 +2,15 @@ package com.diligrp.etrade.thirdparty.component;
2 2  
3 3  
4 4 import com.diligrp.etrade.thirdparty.domain.co.basic.BaseSourceCo;
  5 +import com.diligrp.etrade.thirdparty.domain.dto.ChargeItemDto;
5 6 import com.diligrp.etrade.thirdparty.domain.model.*;
6 7 import com.diligrp.etrade.thirdparty.mapper.TransMapper;
7 8 import jakarta.annotation.Resource;
8 9 import org.springframework.stereotype.Component;
9 10 import org.springframework.util.ObjectUtils;
10 11  
  12 +import java.util.Optional;
  13 +
11 14 /**
12 15 * Transfer Component (传输组件)
13 16 *
... ... @@ -30,9 +33,16 @@ public class TransferComponent {
30 33 this.transFCreateOrgId(co.getFCreateOrgId(), marketId, systemCode);
31 34 }
32 35  
33   - public void transFCOSTID(FCOSTID fcostid) {
34   - if (!ObjectUtils.isEmpty(fcostid.getFNUMBER())) {
35   - fcostid.setFNUMBER(transMapper.getChargeItem(Long.valueOf(fcostid.getFNUMBER())).getChargeItemCode());
  36 + public <T extends FBase> void transFCOSTID(T t) {
  37 + if (!ObjectUtils.isEmpty(t.getFCOSTID().getFNUMBER())) {
  38 + var number = t.getFCOSTID().getFNUMBER();
  39 + ChargeItemDto chargeItem = transMapper.getChargeItem(Long.valueOf(number));
  40 + Optional.ofNullable(chargeItem).ifPresent(
  41 + e -> {
  42 + String chargeItemCode = e.getChargeItemCode();
  43 + t.setSystemChargeItemCode(chargeItemCode);
  44 + }
  45 + );
36 46 }
37 47 }
38 48  
... ... @@ -84,8 +94,8 @@ public class TransferComponent {
84 94 * Trans Main Book 货币
85 95 *
86 96 * @param fsettlemainbookid fsettlemainbookid
87   - * @param marketId 市场 ID
88   - * @param systemCode 系统代码
  97 + * @param marketId 市场 ID
  98 + * @param systemCode 系统代码
89 99 */
90 100 public void transSettleMainBookCurrency(FSETTLEMAINBOOKID fsettlemainbookid, Long marketId, String systemCode) {
91 101 fsettlemainbookid.setFNUMBER(transMapper.getBaseConfig(systemCode, marketId).getCurrency());
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/demarcate/AbstractBaseHandler.java
... ... @@ -4,6 +4,7 @@ import com.diligrp.etrade.thirdparty.domain.dto.BusinessDetailDto;
4 4 import com.diligrp.etrade.thirdparty.domain.dto.BusinessDto;
5 5 import com.diligrp.etrade.thirdparty.domain.dto.ClientDto;
6 6 import com.diligrp.etrade.thirdparty.domain.dto.FinancialDictMappingDto;
  7 +import com.diligrp.etrade.thirdparty.domain.model.FBase;
7 8 import com.diligrp.etrade.thirdparty.mapper.TransMapper;
8 9 import com.diligrp.etrade.thirdparty.type.*;
9 10 import com.kingdee.bos.webapi.entity.IdentifyInfo;
... ... @@ -30,6 +31,30 @@ public abstract class AbstractBaseHandler {
30 31 return Optional.ofNullable(mappingDict).map(FinancialDictMappingDto::getMapCategory).orElse("");
31 32 }
32 33  
  34 + protected static void createMultiMap(List<BusinessDetailDto> data, Map<String, String> relationMap, Map<String, String> codeMap) {
  35 + for (BusinessDetailDto dto : data) {
  36 + if (!ObjectUtils.isEmpty(dto.getItemRelationId())) {
  37 + relationMap.put(String.valueOf(dto.getItemRelationId()), dto.getItemValue());
  38 + }
  39 + if (!ObjectUtils.isEmpty(dto.getItemCode())) {
  40 + codeMap.put(dto.getItemCode(), dto.getItemValue());
  41 + }
  42 + }
  43 + }
  44 +
  45 + protected static <T extends FBase> void multiMapChose(T t, Map<String, String> relationMap, Map<String, String> codeMap) {
  46 + Optional.ofNullable(t.getFCOSTID()).ifPresent(f -> {
  47 + var number = f.getFNUMBER();
  48 + if (relationMap.containsKey(number)) {
  49 + t.setFixChargeItemCode(relationMap.get(number));
  50 + } else if (codeMap.containsKey(number)) {
  51 + t.setFixChargeItemCode(codeMap.get(number));
  52 + } else {
  53 + t.setFixChargeItemCode(t.getSystemChargeItemCode());
  54 + }
  55 + });
  56 + }
  57 +
33 58 /**
34 59 * 获取动态数据
35 60 *
... ... @@ -106,4 +131,10 @@ public abstract class AbstractBaseHandler {
106 131 return identifyInfo;
107 132 }
108 133  
  134 + protected static <T extends FBase> void setChargeItem(List<T> t) {
  135 + t.forEach(e -> Optional.ofNullable(e.getFixChargeItemCode()).ifPresentOrElse(
  136 + f -> e.getFCOSTID().setFNUMBER(f),
  137 + () -> e.getFCOSTID().setFNUMBER(e.getSystemChargeItemCode())
  138 + ));
  139 + }
109 140 }
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/demarcate/AbstractBillHandler.java
... ... @@ -12,10 +12,12 @@ import com.diligrp.etrade.thirdparty.utils.PurchaseOrderApiUtils;
12 12 import jakarta.annotation.Resource;
13 13 import org.springframework.util.ObjectUtils;
14 14  
15   -import java.math.BigDecimal;
16 15 import java.util.HashMap;
17 16 import java.util.List;
18 17 import java.util.Map;
  18 +import java.util.Optional;
  19 +import java.util.function.BiConsumer;
  20 +import java.util.function.Predicate;
19 21 import java.util.stream.Collectors;
20 22  
21 23 /**
... ... @@ -50,34 +52,19 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; extends Abstract
50 52 return BillType.RECEIVABLES;
51 53 }
52 54  
  55 +
53 56 /**
54   - * 转移动态结算类型
  57 + * 固定转换方法 动态获取需要转换的数据,进行kv匹配
55 58 *
56   - * @param t t
57   - * @param data 数据
58 59 */
59   - protected static <T extends BaseBillCo> void transferDynamicSettleType(T t, BusinessDetailDto data) {
  60 + private static <T extends BaseBillCo> void transferDynamicSettleType(T t, BusinessDetailDto data) {
60 61 t.getFEntityDetail().forEach(e -> e.getFSettleTypeID().setFNumber(data.getItemValue()));
61 62 }
62   -
63   - /**
64   - * 转换动态配置部门
65   - *
66   - * @param t t
67   - * @param data 数据
68   - */
69   - protected static <T extends BaseBillCo> void transferDynamicDept(T t, BusinessDetailDto data) {
  63 + private static <T extends BaseBillCo> void transferDynamicDept(T t, BusinessDetailDto data) {
70 64 t.getFSALEDEPTID().setFNumber(data.getItemValue());
71 65 t.getFEntityDetail().forEach(e -> e.getFCOSTDEPARTMENTID().setFNUMBER(data.getItemValue()));
72 66 }
73   -
74   - /**
75   - * Transfer Dynamic 客户
76   - *
77   - * @param t t
78   - * @param data 数据
79   - */
80   - protected static <T extends BaseBillCo> void transferDynamicCustomer(T t, BusinessDetailDto data) {
  67 + private static <T extends BaseBillCo> void transferDynamicCustomer(T t, BusinessDetailDto data) {
81 68 if (!ObjectUtils.isEmpty(t.getFORDERID())) {
82 69 t.getFORDERID().setFNumber(data.getItemValue());
83 70 }
... ... @@ -88,148 +75,72 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; extends Abstract
88 75 t.getFCUSTOMERID().setFNumber(data.getItemValue());
89 76 }
90 77 }
91   -
92   - /**
93   - * Transfer Dynamic Charge 项目
94   - *
95   - * @param data 数据
96   - * @param entity 实体
97   - */
98   - protected static <T extends BaseBillCo> void transferDynamicChargeItem(T entity, List<BusinessDetailDto> data) {
  78 + private static <T extends BaseBillCo> void transferDynamicChargeItem(T entity, List<BusinessDetailDto> data) {
99 79 Map<String, String> relationMap = new HashMap<>();
100 80 Map<String, String> codeMap = new HashMap<>();
101   - for (BusinessDetailDto dto : data) {
102   - if (!ObjectUtils.isEmpty(dto.getItemRelationId())) {
103   - relationMap.put(String.valueOf(dto.getItemRelationId()), dto.getItemValue());
104   - }
105   - if (!ObjectUtils.isEmpty(dto.getItemCode())) {
106   - codeMap.put(dto.getItemCode(), dto.getItemValue());
107   - }
108   - }
109   - entity.getFEntityDetail().forEach(e -> {
110   - if (!ObjectUtils.isEmpty(e.getFCOSTID())) {
111   - var costId = e.getFCOSTID().getFNUMBER();
112   - if (relationMap.containsKey(costId)) {
113   - e.getFCOSTID().setFNUMBER(relationMap.get(costId));
114   - } else if (codeMap.containsKey(costId)) {
115   - e.getFCOSTID().setFNUMBER(codeMap.get(costId));
116   - }
117   - }
118   - });
  81 + createMultiMap(data, relationMap, codeMap);
  82 + entity.getFEntityDetail().forEach(e-> multiMapChose(e, relationMap, codeMap));
119 83 }
120   -
121   - private static <T extends BaseBillCo> String getAllAmountFor(T e) {
122   - var allAmountFor = BigDecimal.ZERO;
123   - for (FEntityDetail f : e.getFEntityDetail()) {
124   - BigDecimal single = f.getFPrice().multiply(f.getFPriceQty());
125   - allAmountFor = allAmountFor.add(single);
126   - }
127   - return allAmountFor.toString();
128   - }
129   -
130   - /**
131   - * Transfer Dynamic 业务类型
132   - *
133   - * @param t t
134   - * @param data 数据
135   - */
136   - protected static <T extends BaseBillCo> void transferDynamicBusinessType(T t, BusinessDetailDto data) {
  84 + private static <T extends BaseBillCo> void transferDynamicBusinessType(T t, BusinessDetailDto data) {
137 85 t.setFixedBusinessType(data.getItemValue());
138 86 }
139   -
140   - /**
141   - * 有效数据同步
142   - *
143   - * @param ts 茨
144   - * @param marketId 市场 ID
145   - * @param systemCode 系统代码
146   - * @return {@link List}<{@link T}>
147   - */
148   - protected <T extends BaseBillCo> List<T> validDataSync(List<T> ts, Long marketId, String systemCode) {
149   - return ts.stream()
150   - .filter(
151   - t -> isSync(marketId, systemCode, DynamicType.fromCode(t.getSystemDynamicCode())
152   - )
153   - ).collect(Collectors.toList());
  87 + private static <T extends BaseBillCo> BiConsumer<String, List<BusinessDetailDto>> multiMapFilter(T e) {
  88 + return (k, v) -> TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v);
  89 + }
  90 + private static <T extends BaseBillCo> BiConsumer<String, BusinessDetailDto> singleMapFilter(T e) {
  91 + return (k, v) -> TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v);
154 92 }
155 93  
  94 + //------------------------------------------------------------------------------------------------------------------
  95 +
156 96 /**
157   - * 传输数据列表
158 97 *
159   - * @param ts 茨
160   - * @param marketId 市场 ID
161   - * @param systemCode 系统代码
  98 + * 同步方法
  99 + *
162 100 */
163   - protected void transferDataListWithFeeItem(List<T> ts, Long marketId, String systemCode) {
164   - ts.forEach(e -> transferDataListWithFeeItemSingle(marketId, systemCode, e));
  101 + private <T extends BaseBillCo> Predicate<T> syncJudge(Long marketId, String systemCode) {
  102 + return t -> isSync(marketId, systemCode, DynamicType.fromCode(t.getSystemDynamicCode()));
165 103 }
166   -
167   - protected void transferDataListWithFeeItemSingle(Long marketId, String systemCode, T e) {
168   - DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode());
169   - billTrans.transBillCo(e, marketId, systemCode);
170   - transferPayMethod(e.getFEntityDetail(), marketId, systemCode);
171   - billTrans.transFeeItem(e.getFEntityDetail());
172   - getFilteredDynamicDataSingle(dynamicType, marketId, systemCode)
173   - .forEach((k, v) ->
174   - TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v)
175   - );
176   - getFilteredDynamicDataMulti(dynamicType, marketId, systemCode)
177   - .forEach((k, v) ->
178   - TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v)
179   - );
  104 + protected <T extends BaseBillCo> List<T> validDataSync(List<T> ts, Long marketId, String systemCode) {
  105 + return ts.stream().filter(syncJudge(marketId, systemCode)).collect(Collectors.toList());
180 106 }
181 107  
  108 + //-------------------------------------------------------------------------------------------------------------------
  109 +
182 110 /**
183   - * 传输数据列表
  111 + * 批量转换方法
184 112 *
185   - * @param ts 茨
186   - * @param marketId 市场 ID
187   - * @param systemCode 系统代码
188 113 */
189   - protected void transferDataListWithOutFeeItem(List<T> ts, Long marketId, String systemCode) {
190   - ts.forEach(e -> transferDataListWithOutFeeItemSingle(marketId, systemCode, e));
191   - }
192   -
193   - protected void transferDataListWithOutFeeItemSingle(Long marketId, String systemCode, T e) {
194   - DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode());
195   - billTrans.transBillCo(e, marketId, systemCode);
196   - transferPayMethod(e.getFEntityDetail(), marketId, systemCode);
197   - getFilteredDynamicDataSingle(dynamicType, marketId, systemCode)
198   - .forEach((k, v) ->
199   - TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v)
200   - );
201   - getFilteredDynamicDataMulti(dynamicType, marketId, systemCode)
202   - .forEach((k, v) ->
203   - TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v)
204   - );
205   - }
206   -
207   - protected void transferPayMethod(List<FEntityDetail> fEntityDetail,Long marketId, String systemCode){
208   - fEntityDetail.forEach(e->{
209   - if (!ObjectUtils.isEmpty(e.getFSettleTypeID())){
  114 + private void transferPayMethod(List<FEntityDetail> fEntityDetail, Long marketId, String systemCode) {
  115 + fEntityDetail.forEach(e -> {
  116 + if (!ObjectUtils.isEmpty(e.getFSettleTypeID())) {
210 117 e.getFSettleTypeID().setFNumber(getPayMethod(e.getFSettleTypeID().getFNumber(), systemCode, marketId));
211 118 }
212 119 });
213 120 }
  121 + protected void transferDataListWithFeeItem(List<T> ts, Long marketId, String systemCode) {
  122 + ts.forEach(e -> {
  123 + DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode());
  124 + billTrans.transBillCo(e, marketId, systemCode);
  125 + transferPayMethod(e.getFEntityDetail(), marketId, systemCode);
  126 + billTrans.transFeeItem(e.getFEntityDetail());
  127 + getFilteredDynamicDataSingle(dynamicType, marketId, systemCode).forEach(singleMapFilter(e));
  128 + getFilteredDynamicDataMulti(dynamicType, marketId, systemCode).forEach(multiMapFilter(e));
  129 + });
  130 + }
  131 + //-------------------------------------------------------------------------------------------------------------------
214 132  
215 133 /**
216   - * 发送采购订单
  134 + * 消息发送器
217 135 *
218   - * @param marketId 市场 ID
219   - * @param systemCode 系统代码
220   - * @param ts 茨
221   - * @throws Exception 例外
222 136 */
223 137 protected void sendPurchaseOrder(List<T> ts, Long marketId, String systemCode) throws Exception {
224 138 var identifyInfo = getIdentifyInfo(marketId, systemCode);
  139 + var util = new PurchaseOrderApiUtils(identifyInfo);
225 140 for (T e : ts) {
226   - var fixedBusinessType = e.getFixedBusinessType();
227   - //业务类型固定的情况下
228   - if (!ObjectUtils.isEmpty(fixedBusinessType)) {
229   - e.getFBillTypeID().setFNUMBER(fixedBusinessType);
230   - }
231   - var util = new PurchaseOrderApiUtils(identifyInfo);
232   - boolean purchaseOrder = util.getPurchaseOrder(e.getFBillTypeID().getFNUMBER(), e.getF_ZDB_Text1(), getAllAmountFor(e), e.getF_ZDB_Text667());
  141 + Optional.ofNullable(e.getFixedBusinessType()).ifPresent(f -> e.getFBillTypeID().setFNUMBER(f));
  142 + setChargeItem(e.getFEntityDetail());
  143 + var purchaseOrder = util.getPurchaseOrder(e);
233 144 if (purchaseOrder) {
234 145 util.createOnePurchaseOrder(JsonUtils.toJsonString(e), BillType.RECEIVABLES.value);
235 146 }
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/demarcate/AbstractRecHandler.java
... ... @@ -15,6 +15,9 @@ import org.springframework.util.ObjectUtils;
15 15 import java.util.HashMap;
16 16 import java.util.List;
17 17 import java.util.Map;
  18 +import java.util.Optional;
  19 +import java.util.function.BiConsumer;
  20 +import java.util.function.Predicate;
18 21 import java.util.stream.Collectors;
19 22  
20 23 /**
... ... @@ -50,22 +53,14 @@ public abstract class AbstractRecHandler&lt;T extends BaseRecCo&gt; extends AbstractBa
50 53 }
51 54  
52 55 /**
53   - * 转换动态配置部门
  56 + * 固定转换方法 动态获取需要转换的数据,进行kv匹配
54 57 *
55   - * @param t t
56   - * @param data 数据
57 58 */
58 59 protected static <T extends BaseRecCo> void transferDynamicDept(T t, BusinessDetailDto data) {
59 60 t.getFSALEDEPTID().setFNumber(data.getItemValue());
60 61 t.getFRECEIVEBILLENTRY().forEach(e -> e.getFCOSTDEPARTMENTID().setFNUMBER(data.getItemValue()));
61 62 }
62 63  
63   - /**
64   - * Transfer Dynamic 客户
65   - *
66   - * @param t t
67   - * @param data 数据
68   - */
69 64 protected static <T extends BaseRecCo> void transferDynamicCustomer(T t, BusinessDetailDto data) {
70 65 if (!ObjectUtils.isEmpty(t.getFCONTACTUNIT())) {
71 66 t.getFCONTACTUNIT().setFNumber(data.getItemValue());
... ... @@ -75,144 +70,81 @@ public abstract class AbstractRecHandler&lt;T extends BaseRecCo&gt; extends AbstractBa
75 70 }
76 71 }
77 72  
78   - /**
79   - * 转移动态结算类型
80   - *
81   - * @param t t
82   - * @param data 数据
83   - */
84 73 protected static <T extends BaseRecCo> void transferDynamicSettleType(T t, BusinessDetailDto data) {
85 74 t.getFRECEIVEBILLENTRY().forEach(e -> e.getFSETTLETYPEID().setFNumber(data.getItemValue()));
86 75 }
87 76  
88   - /**
89   - * Transfer Dynamic Charge 项目
90   - *
91   - * @param data 数据
92   - * @param entity 实体
93   - */
94 77 protected static <T extends BaseRecCo> void transferDynamicChargeItem(T entity, List<BusinessDetailDto> data) {
95 78 Map<String, String> relationMap = new HashMap<>();
96 79 Map<String, String> codeMap = new HashMap<>();
97   - for (BusinessDetailDto dto : data) {
98   - if (!ObjectUtils.isEmpty(dto.getItemRelationId())) {
99   - relationMap.put(String.valueOf(dto.getItemRelationId()), dto.getItemValue());
100   - }
101   - if (!ObjectUtils.isEmpty(dto.getItemCode())) {
102   - codeMap.put(dto.getItemCode(), dto.getItemValue());
103   - }
104   - }
105   - entity.getFRECEIVEBILLENTRY().forEach(e -> {
106   - if (!ObjectUtils.isEmpty(e.getFCOSTID())) {
107   - var costId = e.getFCOSTID().getFNUMBER();
108   - if (relationMap.containsKey(costId)) {
109   - e.getFCOSTID().setFNUMBER(relationMap.get(costId));
110   - } else if (codeMap.containsKey(costId)) {
111   - e.getFCOSTID().setFNUMBER(codeMap.get(costId));
112   - }
113   - }
114   - });
  80 + createMultiMap(data, relationMap, codeMap);
  81 + entity.getFRECEIVEBILLENTRY().forEach(e->multiMapChose(e, relationMap, codeMap));
115 82 }
116 83  
117   - /**
118   - * Transfer Dynamic 业务类型
119   - *
120   - * @param t t
121   - * @param data 数据
122   - */
123 84 protected static <T extends BaseRecCo> void transferDynamicBusinessType(T t, BusinessDetailDto data) {
124 85 t.setFixedBusinessType(data.getItemValue());
125 86 }
126 87  
  88 + private static <T extends BaseRecCo> BiConsumer<String, List<BusinessDetailDto>> multiMapFilter(T e) {
  89 + return (k, v) ->
  90 + TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v);
  91 + }
  92 +
  93 + private static <T extends BaseRecCo> BiConsumer<String, BusinessDetailDto> singleMapFilter(T e) {
  94 + return (k, v) ->
  95 + TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v);
  96 + }
  97 +
  98 + //------------------------------------------------------------------------------------------------------------------
  99 +
127 100 /**
128   - * 有效数据同步
129 101 *
130   - * @param ts 茨
131   - * @param marketId 市场 ID
132   - * @param systemCode 系统代码
133   - * @return {@link List}<{@link T}>
  102 + * 同步方法
  103 + *
134 104 */
135 105 protected <T extends BaseRecCo> List<T> validDataSync(List<T> ts, Long marketId, String systemCode) {
136   - return ts.stream()
137   - .filter(
138   - t -> isSync(marketId, systemCode, DynamicType.fromCode(t.getSystemDynamicCode())
139   - )
140   - ).collect(Collectors.toList());
  106 + return ts.stream().filter(syncJudge(marketId, systemCode)).collect(Collectors.toList());
  107 + }
  108 +
  109 + private <T extends BaseRecCo> Predicate<T> syncJudge(Long marketId, String systemCode) {
  110 + return t -> isSync(marketId, systemCode, DynamicType.fromCode(t.getSystemDynamicCode()));
141 111 }
142 112  
143 113 /**
144   - * 传输数据列表
  114 + * 批量转换方法
145 115 *
146   - * @param ts 茨
147   - * @param marketId 市场 ID
148   - * @param systemCode 系统代码
149 116 */
150   - protected void transferDataListWithFeeItem(List<T> ts, Long marketId, String systemCode) {
151   - ts.forEach(e -> {
152   - DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode());
153   - recTrans.transRecCo(e, marketId, systemCode);
154   - recTrans.transFeeItem(e.getFRECEIVEBILLENTRY());
155   - transferPayMethod(e.getFRECEIVEBILLENTRY(),marketId,systemCode);
156   - getFilteredDynamicDataSingle(dynamicType, marketId, systemCode)
157   - .forEach((k, v) ->
158   - TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v)
159   - );
160   - getFilteredDynamicDataMulti(dynamicType, marketId, systemCode)
161   - .forEach((k, v) ->
162   - TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v)
163   - );
  117 + private void transferPayMethod(List<FRECEIVEBILLENTRY> freceivebillentries, Long marketId, String systemCode){
  118 + freceivebillentries.forEach(e->{
  119 + if (!ObjectUtils.isEmpty(e.getFSETTLETYPEID())){
  120 + e.getFSETTLETYPEID().setFNumber(getPayMethod(e.getFSETTLETYPEID().getFNumber(), systemCode, marketId));
  121 + }
164 122 });
165 123 }
166 124  
167   - /**
168   - * 传输数据列表
169   - *
170   - * @param ts 茨
171   - * @param marketId 市场 ID
172   - * @param systemCode 系统代码
173   - */
174   - protected void transferDataListWithOutFeeItem(List<T> ts, Long marketId, String systemCode) {
  125 + protected void transferDataListWithFeeItem(List<T> ts, Long marketId, String systemCode) {
175 126 ts.forEach(e -> {
176 127 DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode());
177 128 recTrans.transRecCo(e, marketId, systemCode);
  129 + recTrans.transFeeItem(e.getFRECEIVEBILLENTRY());
178 130 transferPayMethod(e.getFRECEIVEBILLENTRY(),marketId,systemCode);
179   - getFilteredDynamicDataSingle(dynamicType, marketId, systemCode)
180   - .forEach((k, v) ->
181   - TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v)
182   - );
183   - getFilteredDynamicDataMulti(dynamicType, marketId, systemCode)
184   - .forEach((k, v) ->
185   - TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v)
186   - );
  131 + getFilteredDynamicDataSingle(dynamicType, marketId, systemCode).forEach(singleMapFilter(e));
  132 + getFilteredDynamicDataMulti(dynamicType, marketId, systemCode).forEach(multiMapFilter(e));
187 133 });
188 134 }
189 135  
190   - protected void transferPayMethod(List<FRECEIVEBILLENTRY> freceivebillentries, Long marketId, String systemCode){
191   - freceivebillentries.forEach(e->{
192   - if (!ObjectUtils.isEmpty(e.getFSETTLETYPEID())){
193   - e.getFSETTLETYPEID().setFNumber(getPayMethod(e.getFSETTLETYPEID().getFNumber(), systemCode, marketId));
194   - }
195   - });
196   - }
197 136  
198 137 /**
199   - * 发送采购订单
  138 + * 消息发送器
200 139 *
201   - * @param marketId 市场 ID
202   - * @param systemCode 系统代码
203   - * @param ts 茨
204   - * @throws Exception 例外
205 140 */
206 141 protected void sendPurchaseOrder(List<T> ts, Long marketId, String systemCode) throws Exception {
207 142 var identifyInfo = getIdentifyInfo(marketId, systemCode);
  143 + var util = new ReceiptsOrderApiUtils(identifyInfo);
208 144 for (T e : ts) {
209   - var fixedBusinessType = e.getFixedBusinessType();
210   - //业务类型固定的情况下
211   - if (!ObjectUtils.isEmpty(fixedBusinessType)) {
212   - e.getFBillTypeID().setFNUMBER(fixedBusinessType);
213   - }
214   - var util = new ReceiptsOrderApiUtils(identifyInfo);
215   - boolean purchaseOrder = util.getReceiptsOrder(e.getFBillTypeID().getFNUMBER(), e.getFREMARK());
  145 + Optional.ofNullable(e.getFixedBusinessType()).ifPresent(f -> e.getFBillTypeID().setFNUMBER(f));
  146 + setChargeItem(e.getFRECEIVEBILLENTRY());
  147 + boolean purchaseOrder = util.getReceiptsOrder(e);
216 148 if (purchaseOrder) {
217 149 util.createOnePurchaseOrder(JsonUtils.toJsonString(e), BillType.RECEIPTS.value);
218 150 }
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/demarcate/AbstractRefundHandler.java
... ... @@ -15,6 +15,9 @@ import org.springframework.util.ObjectUtils;
15 15 import java.util.HashMap;
16 16 import java.util.List;
17 17 import java.util.Map;
  18 +import java.util.Optional;
  19 +import java.util.function.BiConsumer;
  20 +import java.util.function.Predicate;
18 21 import java.util.stream.Collectors;
19 22  
20 23 /**
... ... @@ -49,23 +52,14 @@ public abstract class AbstractRefundHandler&lt;T extends BaseRefundCo&gt; extends Abst
49 52 }
50 53  
51 54 /**
52   - * 转换动态配置部门
53   - *
54   - * @param t t
55   - * @param data 数据
  55 + * 固定转换方法 动态获取需要转换的数据,进行kv匹配
56 56 */
57   - protected static <T extends BaseRefundCo> void transferDynamicDept(T t, BusinessDetailDto data) {
  57 + private static <T extends BaseRefundCo> void transferDynamicDept(T t, BusinessDetailDto data) {
58 58 t.getFSALEDEPTID().setFNumber(data.getItemValue());
59   - t.getFREFUNDBILLENTRY().forEach(e-> e.getFCOSTDEPARTMENTID().setFNUMBER(data.getItemValue()));
  59 + t.getFREFUNDBILLENTRY().forEach(e -> e.getFCOSTDEPARTMENTID().setFNUMBER(data.getItemValue()));
60 60 }
61 61  
62   - /**
63   - * Transfer Dynamic 客户
64   - *
65   - * @param t t
66   - * @param data 数据
67   - */
68   - protected static <T extends BaseRefundCo> void transferDynamicCustomer(T t, BusinessDetailDto data) {
  62 + private static <T extends BaseRefundCo> void transferDynamicCustomer(T t, BusinessDetailDto data) {
69 63 if (!ObjectUtils.isEmpty(t.getFCONTACTUNIT())) {
70 64 t.getFCONTACTUNIT().setFNumber(data.getItemValue());
71 65 }
... ... @@ -74,144 +68,79 @@ public abstract class AbstractRefundHandler&lt;T extends BaseRefundCo&gt; extends Abst
74 68 }
75 69 }
76 70  
77   - /**
78   - * 转移动态结算类型
79   - *
80   - * @param t t
81   - * @param data 数据
82   - */
83   - protected static <T extends BaseRefundCo> void transferDynamicSettleType(T t, BusinessDetailDto data) {
  71 + private static <T extends BaseRefundCo> void transferDynamicSettleType(T t, BusinessDetailDto data) {
84 72 t.getFREFUNDBILLENTRY().forEach(e -> e.getFSETTLETYPEID().setFNumber(data.getItemValue()));
85 73 }
86 74  
87   - /**
88   - * Transfer Dynamic Charge 项目
89   - *
90   - * @param data 数据
91   - * @param entity 实体
92   - */
93   - protected static <T extends BaseRefundCo> void transferDynamicChargeItem(T entity, List<BusinessDetailDto> data) {
  75 + private static <T extends BaseRefundCo> void transferDynamicChargeItem(T entity, List<BusinessDetailDto> data) {
94 76 Map<String, String> relationMap = new HashMap<>();
95 77 Map<String, String> codeMap = new HashMap<>();
96   - for (BusinessDetailDto dto : data) {
97   - if (!ObjectUtils.isEmpty(dto.getItemRelationId())) {
98   - relationMap.put(String.valueOf(dto.getItemRelationId()), dto.getItemValue());
99   - }
100   - if (!ObjectUtils.isEmpty(dto.getItemCode())) {
101   - codeMap.put(dto.getItemCode(), dto.getItemValue());
102   - }
103   - }
104   - entity.getFREFUNDBILLENTRY().forEach(e -> {
105   - if (!ObjectUtils.isEmpty(e.getFCOSTID())) {
106   - var costId = e.getFCOSTID().getFNUMBER();
107   - if (relationMap.containsKey(costId)) {
108   - e.getFCOSTID().setFNUMBER(relationMap.get(costId));
109   - } else if (codeMap.containsKey(costId)) {
110   - e.getFCOSTID().setFNUMBER(codeMap.get(costId));
111   - }
112   - }
113   - });
  78 + createMultiMap(data, relationMap, codeMap);
  79 + entity.getFREFUNDBILLENTRY().forEach(e -> multiMapChose(e, relationMap, codeMap));
114 80 }
115 81  
116   - /**
117   - * Transfer Dynamic 业务类型
118   - *
119   - * @param t t
120   - * @param data 数据
121   - */
122   - protected static <T extends BaseRefundCo> void transferDynamicBusinessType(T t, BusinessDetailDto data) {
  82 + private static <T extends BaseRefundCo> void transferDynamicBusinessType(T t, BusinessDetailDto data) {
123 83 t.setFixedBusinessType(data.getItemValue());
124 84 }
125 85  
  86 + private static <T extends BaseRefundCo> BiConsumer<String, List<BusinessDetailDto>> multiMapFilter(T e) {
  87 + return (k, v) ->
  88 + TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v);
  89 + }
  90 +
  91 + private static <T extends BaseRefundCo> BiConsumer<String, BusinessDetailDto> singleMapFilter(T e) {
  92 + return (k, v) ->
  93 + TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v);
  94 + }
  95 +
  96 + //------------------------------------------------------------------------------------------------------------------
  97 +
126 98 /**
127   - * 有效数据同步
128   - *
129   - * @param ts 茨
130   - * @param marketId 市场 ID
131   - * @param systemCode 系统代码
132   - * @return {@link List}<{@link T}>
  99 + * 同步方法
133 100 */
134 101 protected <T extends BaseRefundCo> List<T> validDataSync(List<T> ts, Long marketId, String systemCode) {
135   - return ts.stream()
136   - .filter(
137   - t -> isSync(marketId, systemCode, DynamicType.fromCode(t.getSystemDynamicCode())
138   - )
139   - ).collect(Collectors.toList());
  102 + return ts.stream().filter(syncJudge(marketId, systemCode)).collect(Collectors.toList());
  103 + }
  104 +
  105 + private <T extends BaseRefundCo> Predicate<T> syncJudge(Long marketId, String systemCode) {
  106 + return t -> isSync(marketId, systemCode, DynamicType.fromCode(t.getSystemDynamicCode()));
140 107 }
141 108  
142 109 /**
143   - * 传输数据列表
144   - *
145   - * @param ts 茨
146   - * @param marketId 市场 ID
147   - * @param systemCode 系统代码
  110 + * 批量转换方法
148 111 */
149   - protected void transferDataListWithFeeItem(List<T> ts, Long marketId, String systemCode) {
150   - ts.forEach(e -> {
151   - DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode());
152   - refundTrans.transRefundCo(e, marketId, systemCode);
153   - refundTrans.transFeeItem(e.getFREFUNDBILLENTRY());
154   - transferPayMethod(e.getFREFUNDBILLENTRY(), marketId, systemCode);
155   - getFilteredDynamicDataSingle(dynamicType, marketId, systemCode)
156   - .forEach((k, v) ->
157   - TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v)
158   - );
159   - getFilteredDynamicDataMulti(dynamicType, marketId, systemCode)
160   - .forEach((k, v) ->
161   - TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v)
162   - );
  112 + private void transferPayMethod(List<FREFUNDBILLENTRY> frefundbillentries, Long marketId, String systemCode) {
  113 + frefundbillentries.forEach(e -> {
  114 + if (!ObjectUtils.isEmpty(e.getFSETTLETYPEID())) {
  115 + e.getFSETTLETYPEID().setFNumber(getPayMethod(e.getFSETTLETYPEID().getFNumber(), systemCode, marketId));
  116 + }
163 117 });
164 118 }
165 119  
166   - /**
167   - * 传输数据列表
168   - *
169   - * @param ts 茨
170   - * @param marketId 市场 ID
171   - * @param systemCode 系统代码
172   - */
173   - protected void transferDataListWithOutFeeItem(List<T> ts, Long marketId, String systemCode) {
  120 + protected void transferDataListWithFeeItem(List<T> ts, Long marketId, String systemCode) {
174 121 ts.forEach(e -> {
175 122 DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode());
176 123 refundTrans.transRefundCo(e, marketId, systemCode);
  124 + refundTrans.transFeeItem(e.getFREFUNDBILLENTRY());
177 125 transferPayMethod(e.getFREFUNDBILLENTRY(), marketId, systemCode);
178   - getFilteredDynamicDataSingle(dynamicType, marketId, systemCode)
179   - .forEach((k, v) ->
180   - TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v)
181   - );
182   - getFilteredDynamicDataMulti(dynamicType, marketId, systemCode)
183   - .forEach((k, v) ->
184   - TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v)
185   - );
  126 + getFilteredDynamicDataSingle(dynamicType, marketId, systemCode).forEach(singleMapFilter(e));
  127 + getFilteredDynamicDataMulti(dynamicType, marketId, systemCode).forEach(multiMapFilter(e));
186 128 });
187 129 }
188 130  
189   - protected void transferPayMethod(List<FREFUNDBILLENTRY> frefundbillentries, Long marketId, String systemCode){
190   - frefundbillentries.forEach(e->{
191   - if (!ObjectUtils.isEmpty(e.getFSETTLETYPEID())){
192   - e.getFSETTLETYPEID().setFNumber(getPayMethod(e.getFSETTLETYPEID().getFNumber(), systemCode, marketId));
193   - }
194   - });
195   - }
  131 + //-------------------------------------------------------------------------------------------------------------------
196 132  
197 133 /**
198   - * 发送采购订单
199   - *
200   - * @param marketId 市场 ID
201   - * @param systemCode 系统代码
202   - * @param ts 茨
203   - * @throws Exception 例外
  134 + * 消息发送器
204 135 */
  136 +
205 137 protected void sendPurchaseOrder(List<T> ts, Long marketId, String systemCode) throws Exception {
206 138 var identifyInfo = getIdentifyInfo(marketId, systemCode);
  139 + var util = new ReceiptsRefundOrderApiUtils(identifyInfo);
207 140 for (T e : ts) {
208   - var fixedBusinessType = e.getFixedBusinessType();
209   - //业务类型固定的情况下
210   - if (!ObjectUtils.isEmpty(fixedBusinessType)) {
211   - e.getFBillTypeID().setFNUMBER(fixedBusinessType);
212   - }
213   - var util = new ReceiptsRefundOrderApiUtils(identifyInfo);
214   - boolean purchaseOrder = util.getReceiptsRefundOrder(e.getFBillTypeID().getFNUMBER(), e.getFREMARK());
  141 + Optional.ofNullable(e.getFixedBusinessType()).ifPresent(f -> e.getFBillTypeID().setFNUMBER(f));
  142 + setChargeItem(e.getFREFUNDBILLENTRY());
  143 + boolean purchaseOrder = util.getReceiptsRefundOrder(e);
215 144 if (purchaseOrder) {
216 145 util.createOnePurchaseOrder(JsonUtils.toJsonString(e), BillType.RECEIPT_AND_REFUND_FORM.value);
217 146 }
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/domain/model/FBase.java 0 → 100644
  1 +package com.diligrp.etrade.thirdparty.domain.model;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonProperty;
  4 +
  5 +/**
  6 + * @Author: zhangmeiyang
  7 + * @CreateTime: 2024-12-18 15:28
  8 + * @Version: todo
  9 + */
  10 +public class FBase {
  11 + private FCOSTID FCOSTID;
  12 + private String systemChargeItemCode;
  13 + private String fixChargeItemCode;
  14 +
  15 + @JsonProperty("FCOSTID")
  16 + public FCOSTID getFCOSTID() {
  17 + return FCOSTID;
  18 + }
  19 +
  20 + public void setFCOSTID(FCOSTID FCOSTID) {
  21 + this.FCOSTID = FCOSTID;
  22 + }
  23 +
  24 + @JsonProperty("systemChargeItemCode")
  25 + public String getSystemChargeItemCode() {
  26 + return systemChargeItemCode;
  27 + }
  28 +
  29 + public void setSystemChargeItemCode(String systemChargeItemCode) {
  30 + this.systemChargeItemCode = systemChargeItemCode;
  31 + }
  32 +
  33 + @JsonProperty("fixChargeItemCode")
  34 + public String getFixChargeItemCode() {
  35 + return fixChargeItemCode;
  36 + }
  37 +
  38 + public void setFixChargeItemCode(String fixChargeItemCode) {
  39 + this.fixChargeItemCode = fixChargeItemCode;
  40 + }
  41 +}
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/domain/model/FEntityDetail.java
... ... @@ -9,8 +9,7 @@ import java.math.BigDecimal;
9 9 * @CreateTime: 2024-10-28 16:41
10 10 * @Version: todo
11 11 */
12   -public class FEntityDetail {
13   - private FCOSTID FCOSTID;
  12 +public class FEntityDetail extends FBase{
14 13 private FASSETID FASSETID;
15 14 private BigDecimal FPriceQty;
16 15 private BigDecimal FTaxPrice;
... ... @@ -19,15 +18,6 @@ public class FEntityDetail {
19 18 private FSettleTypeID FSettleTypeID;
20 19 private FCOSTDEPARTMENTID FCOSTDEPARTMENTID;
21 20  
22   - @JsonProperty("FCOSTID")
23   - public FCOSTID getFCOSTID() {
24   - return FCOSTID;
25   - }
26   -
27   - public void setFCOSTID(FCOSTID FCOSTID) {
28   - this.FCOSTID = FCOSTID;
29   - }
30   -
31 21 @JsonProperty("FASSETID")
32 22 public FASSETID getFASSETID() {
33 23 return FASSETID;
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/domain/model/FRECEIVEBILLENTRY.java
... ... @@ -9,23 +9,13 @@ import java.math.BigDecimal;
9 9 * @CreateTime: 2024-11-25 10:10
10 10 * @Version: todo
11 11 */
12   -public class FRECEIVEBILLENTRY {
13   - private FCOSTID FCOSTID;
  12 +public class FRECEIVEBILLENTRY extends FBase{
14 13 private FSETTLETYPE FSETTLETYPEID;
15 14 private BigDecimal FRECTOTALAMOUNTFOR;
16 15 private FPURPOSEID FPURPOSEID;
17 16 private FACCOUNTID FACCOUNTID;
18 17 private FCOSTDEPARTMENTID FCOSTDEPARTMENTID;
19 18  
20   - @JsonProperty("FCOSTID")
21   - public FCOSTID getFCOSTID() {
22   - return FCOSTID;
23   - }
24   -
25   - public void setFCOSTID(FCOSTID FCOSTID) {
26   - this.FCOSTID = FCOSTID;
27   - }
28   -
29 19 @JsonProperty("FSETTLETYPEID")
30 20 public FSETTLETYPE getFSETTLETYPEID() {
31 21 return FSETTLETYPEID;
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/domain/model/FREFUNDBILLENTRY.java
... ... @@ -9,8 +9,7 @@ import java.math.BigDecimal;
9 9 * @CreateTime: 2024-11-28 09:13
10 10 * @Version: todo
11 11 */
12   -public class FREFUNDBILLENTRY {
13   - private FCOSTID FCOSTID;
  12 +public class FREFUNDBILLENTRY extends FBase{
14 13 private FSETTLETYPE FSETTLETYPEID;
15 14 private BigDecimal FREFUNDAMOUNTFOR;
16 15 private String FNOTE;
... ... @@ -18,15 +17,6 @@ public class FREFUNDBILLENTRY {
18 17 private FACCOUNTID FACCOUNTID;
19 18 private FCOSTDEPARTMENTID FCOSTDEPARTMENTID;
20 19  
21   - @JsonProperty("FCOSTID")
22   - public FCOSTID getFCOSTID() {
23   - return FCOSTID;
24   - }
25   -
26   - public void setFCOSTID(FCOSTID FCOSTID) {
27   - this.FCOSTID = FCOSTID;
28   - }
29   -
30 20 @JsonProperty("FSETTLETYPEID")
31 21 public FSETTLETYPE getFSETTLETYPEID() {
32 22 return FSETTLETYPEID;
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/bill/BusinessBillHandler.java
... ... @@ -19,7 +19,7 @@ public class BusinessBillHandler extends AbstractBillHandler&lt;BusinessBillCo&gt; {
19 19 @Override
20 20 public void handle(String json, Long marketId, String systemCode) throws Exception{
21 21 List<BusinessBillCo> businessBillCos = JsonUtils.fromJsonString(json, new TypeReference<>() {});
22   - transferDataListWithOutFeeItem(businessBillCos, marketId, systemCode);
  22 + transferDataListWithFeeItem(businessBillCos, marketId, systemCode);
23 23 sendPurchaseOrder(businessBillCos, marketId, systemCode);
24 24 }
25 25  
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/bill/CardBillHandler.java
... ... @@ -20,7 +20,7 @@ public class CardBillHandler extends AbstractBillHandler&lt;CardBillCo&gt; {
20 20 @Override
21 21 public void handle(String json, Long marketId, String systemCode) throws Exception {
22 22 List<CardBillCo> cardBillCos = JsonUtils.fromJsonString(json, new TypeReference<>() {});
23   - transferDataListWithOutFeeItem(cardBillCos, marketId, systemCode);
  23 + transferDataListWithFeeItem(cardBillCos, marketId, systemCode);
24 24 cardBillCos.forEach(e-> e.setF_ZDB_Text667(ProcessType.POSITIVE.name));
25 25 sendPurchaseOrder(cardBillCos,marketId, systemCode);
26 26 }
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/bill/DepositBillHandler.java
... ... @@ -19,7 +19,7 @@ public class DepositBillHandler extends AbstractBillHandler&lt;DepositBillCo&gt; {
19 19 @Override
20 20 public void handle(String json, Long marketId, String systemCode) throws Exception {
21 21 List<DepositBillCo> depositBillCos = JsonUtils.fromJsonString(json, new TypeReference<>() {});
22   - transferDataListWithOutFeeItem(depositBillCos, marketId, systemCode);
  22 + transferDataListWithFeeItem(depositBillCos, marketId, systemCode);
23 23 sendPurchaseOrder(depositBillCos, marketId, systemCode);
24 24 }
25 25  
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/bill/SettleBillHandler.java
... ... @@ -4,12 +4,10 @@ import com.diligrp.etrade.core.util.JsonUtils;
4 4 import com.diligrp.etrade.thirdparty.demarcate.AbstractBillHandler;
5 5 import com.diligrp.etrade.thirdparty.domain.co.business.bill.SettleBillCo;
6 6 import com.diligrp.etrade.thirdparty.type.BusinessEnum;
7   -import com.diligrp.etrade.thirdparty.type.DynamicType;
8 7 import com.fasterxml.jackson.core.type.TypeReference;
9 8 import org.springframework.stereotype.Component;
10 9  
11 10 import java.util.List;
12   -import java.util.Optional;
13 11  
14 12 /**
15 13 * @Author: zhangmeiyang
... ... @@ -22,11 +20,7 @@ public class SettleBillHandler extends AbstractBillHandler&lt;SettleBillCo&gt; {
22 20 @Override
23 21 public void handle(String json, Long marketId, String systemCode) throws Exception {
24 22 List<SettleBillCo> settleBillCos = JsonUtils.fromJsonString(json, new TypeReference<>() {});
25   - settleBillCos.forEach(e ->
26   - Optional.of(e).filter(x -> DynamicType.BAIL.code.equals(x.getSystemDynamicCode()))
27   - .ifPresentOrElse(
28   - x -> transferDataListWithOutFeeItemSingle(marketId, systemCode, x),
29   - () -> transferDataListWithFeeItemSingle(marketId, systemCode, e)));
  23 + transferDataListWithFeeItem(settleBillCos, marketId, systemCode);
30 24 sendPurchaseOrder(settleBillCos, marketId, systemCode);
31 25 }
32 26  
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/rec/CardRecHandler.java
... ... @@ -20,7 +20,7 @@ public class CardRecHandler extends AbstractRecHandler&lt;CardRecCo&gt; {
20 20 @Override
21 21 public void handle(String json, Long marketId, String systemCode) throws Exception {
22 22 List<CardRecCo> cardRecCos = JsonUtils.fromJsonString(json, new TypeReference<>() {});
23   - transferDataListWithOutFeeItem(cardRecCos, marketId, systemCode);
  23 + transferDataListWithFeeItem(cardRecCos, marketId, systemCode);
24 24 sendPurchaseOrder(cardRecCos, marketId, systemCode);
25 25 }
26 26  
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/rec/DepositRecHandler.java
... ... @@ -19,7 +19,7 @@ public class DepositRecHandler extends AbstractRecHandler&lt;DepositRecCo&gt; {
19 19 @Override
20 20 public void handle(String json, Long marketId, String systemCode) throws Exception {
21 21 List<DepositRecCo> depositRecCos = JsonUtils.fromJsonString(json, new TypeReference<>() {});
22   - transferDataListWithOutFeeItem(depositRecCos, marketId, systemCode);
  22 + transferDataListWithFeeItem(depositRecCos, marketId, systemCode);
23 23 sendPurchaseOrder(depositRecCos, marketId, systemCode);
24 24 }
25 25  
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/refund/CardRefundHandler.java
... ... @@ -21,7 +21,7 @@ public class CardRefundHandler extends AbstractRefundHandler&lt;CardRefundCo&gt; {
21 21 public void handle(String json, Long marketId, String systemCode) throws Exception {
22 22 List<CardRefundCo> cardRefundCos = JsonUtils.fromJsonString(json, new TypeReference<>() {});
23 23 cardRefundCos.forEach(e->e.getFREFUNDBILLENTRY().forEach(f->f.setFNOTE(DEFAULT_REASON)));
24   - transferDataListWithOutFeeItem(cardRefundCos, marketId, systemCode);
  24 + transferDataListWithFeeItem(cardRefundCos, marketId, systemCode);
25 25 sendPurchaseOrder(cardRefundCos, marketId, systemCode);
26 26 }
27 27  
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/BaseApiUtils.java
... ... @@ -4,13 +4,14 @@ import com.diligrp.etrade.core.util.JsonUtils;
4 4 import com.diligrp.etrade.thirdparty.error.ThirdPartyException;
5 5 import com.diligrp.etrade.thirdparty.message.GeneralSendMessage;
6 6 import com.diligrp.etrade.thirdparty.type.ThirdPartyErrorCodeEnum;
7   -import com.esotericsoftware.minlog.Log;
8 7 import com.fasterxml.jackson.core.type.TypeReference;
9 8 import com.google.gson.Gson;
10 9 import com.kingdee.bos.webapi.entity.IdentifyInfo;
11 10 import com.kingdee.bos.webapi.entity.RepoError;
12 11 import com.kingdee.bos.webapi.entity.RepoRet;
13 12 import com.kingdee.bos.webapi.sdk.K3CloudApi;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
14 15  
15 16 import java.util.ArrayList;
16 17 import java.util.List;
... ... @@ -29,13 +30,15 @@ public abstract class BaseApiUtils {
29 30 protected K3CloudApi api;
30 31 protected static Gson gson = new Gson();
31 32  
  33 + private final static Logger LOG = LoggerFactory.getLogger(BaseApiUtils.class);
  34 +
32 35 public BaseApiUtils(IdentifyInfo identifyInfo) {
33 36 api = new K3CloudApi(identifyInfo,false);
34 37 }
35 38  
36 39 protected <T extends RepoRet<?>> void errorInfoRecord(T repoRet) {
37 40 ThirdPartyErrorCodeEnum errorCodeEnum = ThirdPartyErrorCodeEnum.getByCode(repoRet.getResult().getResponseStatus().getErrorCode());
38   - Log.warn("金蝶对接系统异常,错误码数据记录:{}",errorCodeEnum.code);
  41 + LOG.warn("金蝶对接系统异常,错误码数据记录:{}",errorCodeEnum.code);
39 42 ArrayList<RepoError> errors = repoRet.getResult().getResponseStatus().getErrors();
40 43 List<String> messages = errors.stream().map(RepoError::getMessage).toList();
41 44 throw new ThirdPartyException(JsonUtils.toJsonString(messages));
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/PurchaseOrderApiUtils.java
1 1 package com.diligrp.etrade.thirdparty.utils;
2 2  
3 3 import com.diligrp.etrade.core.util.JsonUtils;
  4 +import com.diligrp.etrade.thirdparty.domain.co.business.bill.BaseBillCo;
  5 +import com.diligrp.etrade.thirdparty.domain.model.FEntityDetail;
4 6 import com.diligrp.etrade.thirdparty.message.GeneralQueryMessage;
5 7 import com.kingdee.bos.webapi.entity.IdentifyInfo;
6 8 import org.slf4j.Logger;
7 9 import org.slf4j.LoggerFactory;
8 10  
  11 +import java.math.BigDecimal;
9 12 import java.util.List;
10 13  
11 14 /**
... ... @@ -24,10 +27,27 @@ public class PurchaseOrderApiUtils extends BaseApiUtils {
24 27 super(identifyInfo);
25 28 }
26 29  
27   - public boolean getPurchaseOrder(String FBillTypeID, String F_ZDB_text1,String allAmountFor,String F_ZDB_Text667 ) throws Exception {
  30 + private static <T extends BaseBillCo> String getAllAmountFor(T e) {
  31 + var allAmountFor = BigDecimal.ZERO;
  32 + for (FEntityDetail f : e.getFEntityDetail()) {
  33 + BigDecimal single = f.getFPrice().multiply(f.getFPriceQty());
  34 + allAmountFor = allAmountFor.add(single);
  35 + }
  36 + return allAmountFor.toString();
  37 + }
  38 +
  39 + public <T extends BaseBillCo> boolean getPurchaseOrder(T e) throws Exception {
  40 + return getPurchaseOrder(
  41 + e.getFBillTypeID().getFNUMBER(),
  42 + e.getF_ZDB_Text1(),
  43 + getAllAmountFor(e),
  44 + e.getF_ZDB_Text667());
  45 + }
  46 +
  47 + private boolean getPurchaseOrder(String FBillTypeID, String F_ZDB_text1, String allAmountFor, String F_ZDB_Text667) throws Exception {
28 48 String FilterString = """
29 49 FBillTypeID.FNumber = '%s' and F_ZDB_text1 ='%s' and FALLAMOUNTFOR = '%s' and F_ZDB_Text667 = '%s'
30   - """.formatted(FBillTypeID, F_ZDB_text1,allAmountFor,F_ZDB_Text667);
  50 + """.formatted(FBillTypeID, F_ZDB_text1, allAmountFor, F_ZDB_Text667);
31 51 var query = new GeneralQueryMessage();
32 52 query.setFilterString(FilterString);
33 53 query.setFieldKeys("FID");
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/ReceiptsOrderApiUtils.java
1 1 package com.diligrp.etrade.thirdparty.utils;
2 2  
3 3 import com.diligrp.etrade.core.util.JsonUtils;
  4 +import com.diligrp.etrade.thirdparty.domain.co.business.rec.BaseRecCo;
4 5 import com.diligrp.etrade.thirdparty.message.GeneralQueryMessage;
5 6 import com.kingdee.bos.webapi.entity.IdentifyInfo;
6 7 import org.slf4j.Logger;
... ... @@ -24,10 +25,14 @@ public class ReceiptsOrderApiUtils extends BaseApiUtils {
24 25 super(identifyInfo);
25 26 }
26 27  
27   - public boolean getReceiptsOrder(String FBillTypeID,String remark) throws Exception {
  28 + public <T extends BaseRecCo> boolean getReceiptsOrder(T e) throws Exception {
  29 + return getReceiptsOrder(e.getFBillTypeID().getFNUMBER(), e.getFREMARK());
  30 + }
  31 +
  32 + private boolean getReceiptsOrder(String FBillTypeID, String remark) throws Exception {
28 33 String FilterString = """
29 34 FBillTypeID.FNumber = '%s' AND FREMARK = '%s';
30   - """.formatted(FBillTypeID,remark);
  35 + """.formatted(FBillTypeID, remark);
31 36 var query = new GeneralQueryMessage();
32 37 query.setFilterString(FilterString);
33 38 query.setFieldKeys("FID");
... ...
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/ReceiptsRefundOrderApiUtils.java
1 1 package com.diligrp.etrade.thirdparty.utils;
2 2  
3 3 import com.diligrp.etrade.core.util.JsonUtils;
  4 +import com.diligrp.etrade.thirdparty.domain.co.business.refund.BaseRefundCo;
4 5 import com.diligrp.etrade.thirdparty.message.GeneralQueryMessage;
5 6 import com.kingdee.bos.webapi.entity.IdentifyInfo;
6 7 import org.slf4j.Logger;
... ... @@ -24,6 +25,10 @@ public class ReceiptsRefundOrderApiUtils extends BaseApiUtils {
24 25 super(identifyInfo);
25 26 }
26 27  
  28 + public <T extends BaseRefundCo> boolean getReceiptsRefundOrder(T e) throws Exception {
  29 + return getReceiptsRefundOrder(e.getFBillTypeID().getFNUMBER(), e.getFREMARK());
  30 + }
  31 +
27 32 public boolean getReceiptsRefundOrder(String FBillTypeID,String remark) throws Exception {
28 33 String FilterString = """
29 34 FBillTypeID.FNumber = '%s' AND FREMARK = '%s';
... ...