Pārlūkot izejas kodu

商城财务导出

zouxuan 2 gadi atpakaļ
vecāks
revīzija
c1f8491f06

+ 26 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -1716,26 +1716,8 @@ public class ExportServiceImpl implements ExportService {
             }
             row.setTransferFee(transferFee);
             row.setPlatformFee(row.getActualAmount().multiply(tenantConfig.getChargeRate()).divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP));
-            if(StringUtils.isNotEmpty(row.getGoodsJson())){
-                List<JSONObject> orderItemList = JSONObject.parseArray(JSONObject.parseObject(row.getGoodsJson()).getString("orderItemList"), JSONObject.class);
-                for (JSONObject json : orderItemList) {
-                    try {
-                        String category = productCategoryMap.get(Long.parseLong(json.get("productId").toString()));
-                        BigDecimal realAmount = new BigDecimal(json.get("realAmount").toString());
-                        int index = categoryNames.indexOf(category) + 1;
-                        if(index == 0){
-                            continue;
-                        }
-                        Method method = row.getClass().getMethod("getCategory" + index, null);
-                        BigDecimal invoke = (BigDecimal)method.invoke(row);
-                        invoke = invoke.add(realAmount);
-                        Method method1 = row.getClass().getMethod("setCategory" + index, BigDecimal.class);
-                        method1.invoke(row,invoke);
-                    }catch (Exception e){
-                        e.printStackTrace();
-                    }
-                }
-            }
+            //解析json
+            this.parseGoodsJson(row,categoryNames,productCategoryMap);
             //活动购买的商品列表
             String paymentChannel = "";
             if (row.getPaymentChannel() == null) {
@@ -1761,6 +1743,30 @@ public class ExportServiceImpl implements ExportService {
         HSSFWorkbook workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
         exportManagerDownload(workbook, managerDownload);
     }
+
+    private void parseGoodsJson(StudentPaymentOrderMallExportDto row,List<String> categoryNames,Map<Long,String> productCategoryMap){
+        if(StringUtils.isNotEmpty(row.getGoodsJson())){
+            List<JSONObject> orderItemList = JSONObject.parseArray(JSONObject.parseObject(row.getGoodsJson()).getString("orderItemList"), JSONObject.class);
+            for (JSONObject json : orderItemList) {
+                try {
+                    String category = productCategoryMap.get(Long.parseLong(json.get("productId").toString()));
+                    BigDecimal realAmount = new BigDecimal(json.get("realAmount").toString());
+                    int index = categoryNames.indexOf(category) + 1;
+                    if(index == 0){
+                        continue;
+                    }
+                    Method method = row.getClass().getMethod("getCategory" + index, null);
+                    BigDecimal invoke = (BigDecimal)method.invoke(row);
+                    invoke = invoke.add(realAmount);
+                    Method method1 = row.getClass().getMethod("setCategory" + index, BigDecimal.class);
+                    method1.invoke(row,invoke);
+                }catch (Exception e){
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
     @Override
     public void orderList(Map<String, Object> params, ManagerDownload managerDownload) {
         List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);