Ver código fonte

销售订单佣金追溯,成本分配,以及托书结汇发票调整

zengtx 1 ano atrás
pai
commit
eccbbd1bd3

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/entity/SyCostAllocation.java

@@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.jeecg.modules.report.entity.AccessorItem;
 import org.jeecgframework.poi.excel.annotation.ExcelCollection;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -243,4 +244,7 @@ public class SyCostAllocation implements Serializable {
 
     private String sheetName;
 
+    // 销售订单附件
+    List<AccessorItem> accessorItemList;
+
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationFabricMapper.xml

@@ -51,6 +51,7 @@ where trim(cSOCode) like CONCAT(#{code},'%') and cSOCode not like '%样%'
 
 		WHERE om.iVerifyStateNew = 2
 		and om.cCode like CONCAT(#{code},'%') 	and omi.cInvCcode like '19%'
+		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
 		GROUP BY om.cCode,oti.cInvCode
 		) vim on vim.cInvCode = vif.cInvCode
 		where trim(vif.cCode) like CONCAT(#{code},'%')
@@ -130,6 +131,7 @@ where trim(cSOCode) like CONCAT(#{code},'%') and cSOCode not like '%样%'
 		WHERE om.iVerifyStateNew = 2
 		and om.cCode like CONCAT(#{code},'%')
 		and omi.cInvCcode like '19%'
+		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
 		GROUP BY om.cCode,oti.cInvCode
 		) vim on vim.cInvCode = vif.cInvCode
 		where trim(vif.cCode) like CONCAT(#{code},'%')

+ 5 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationIngredientMapper.xml

@@ -53,7 +53,7 @@
 
 		AND omi.cInvCcode LIKE '19%'
 		AND om.cCode LIKE CONCAT(#{code},'%')
-
+and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
 		GROUP BY om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName ) AS t1
 
 		left join (SELECT ven.cVenAbbName AS cVenAbbName,bi.cInvCode,pod.isosid,SUM ( bi.iSum ) AS rmbAmount,SUM ( bi.iOriSum ) AS usdAmount,
@@ -99,7 +99,7 @@
 
 		AND omi.cInvCcode LIKE '19%'
 		AND om.cCode LIKE CONCAT(#{code},'%')
-
+and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
 		GROUP BY om.ccode,ot.cInvCode,om.ccode,oti.cInvName ) AS t1
 
 		left join (
@@ -200,6 +200,7 @@
 join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
 		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
 		and om.cCode LIKE CONCAT(#{code},'%')
+		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
 		group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
 		) as t1,
 		(
@@ -231,6 +232,7 @@ join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.
 join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
 		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
 		and om.cCode LIKE CONCAT(#{code},'%')
+		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
 		group by  om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
 		) as t1
 		left join (
@@ -265,6 +267,7 @@ join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.
 join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
 		WHERE om.iVerifyStateNew = 2  and omi.cInvCcode like '19%'
 		and om.cCode LIKE CONCAT(#{code},'%')
+		and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
 		group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
 		) as t1,
 		(

+ 12 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationMapper.xml

@@ -35,9 +35,10 @@
                      FROM     
                      UFDATA_101_2021.dbo.OM_MOMain om     
                      inner JOIN UFDATA_101_2021.dbo.OM_MODetails od ON om.MOID = od.MOID   
-
-                     WHERE     
+   inner JOIN (select MOID,max(iSendQTY) as iSendQTY from UFDATA_101_2021.dbo.OM_MOMaterials GROUP BY MOID) ot on ot.MOID=om.MOID
+      WHERE
                      om.iVerifyStateNew = 2  and om.cCode like CONCAT(#{code},'%')
+                     and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
                      ) o ON s.isosid  = o.isosid AND s.cInvCode = o.cInvCode     
         inner JOIN UFDATA_101_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode     
         inner JOIN UFDATA_101_2021.dbo.Inventory c on c.cInvCode=s.cInvCode     
@@ -64,9 +65,10 @@
                      FROM     
                      UFDATA_103_2021.dbo.OM_MOMain om     
                      inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID     
-
-                     WHERE     
+   inner JOIN (select MOID,max(iSendQTY) as iSendQTY from UFDATA_103_2021.dbo.OM_MOMaterials GROUP BY MOID) ot on ot.MOID=om.MOID
+      WHERE
                      om.iVerifyStateNew = 2  and om.cCode like CONCAT(#{code},'%')
+                     and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
                      ) o ON a.isosid  = o.isosid AND a.cInvCode = o.cInvCode     
         inner JOIN UFDATA_103_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode     
         inner JOIN UFDATA_103_2021.dbo.Inventory c on c.cInvCode=a.cInvCode     
@@ -101,9 +103,10 @@
                      FROM     
                      UFDATA_103_2021.dbo.OM_MOMain om     
                      inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID    
-
-                     WHERE     
+   inner JOIN (select MOID,max(iSendQTY) as iSendQTY from UFDATA_103_2021.dbo.OM_MOMaterials GROUP BY MOID) ot on ot.MOID=om.MOID
+    WHERE
                      om.iVerifyStateNew = 2  and om.cCode like CONCAT(#{code},'%')
+                     and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
                      ) o ON a.isosid  = o.isosid AND a.cInvCode = o.cInvCode     
         inner JOIN UFDATA_103_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode     
         inner JOIN UFDATA_103_2021.dbo.Inventory c on c.cInvCode=a.cInvCode     
@@ -135,9 +138,10 @@
                      FROM
                      UFDATA_103_2021.dbo.OM_MOMain om
                      inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
-
-                     WHERE
+                        inner JOIN (select MOID,max(iSendQTY) as iSendQTY from UFDATA_103_2021.dbo.OM_MOMaterials GROUP BY MOID) ot on ot.MOID=om.MOID
+                           WHERE
                      om.iVerifyStateNew = 2  and om.cCode like CONCAT(#{code},'%')
+                     and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) ))
                      ) o ON a.isosid  = o.isosid AND a.cInvCode = o.cInvCode
         inner JOIN UFDATA_103_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
         inner JOIN UFDATA_103_2021.dbo.Inventory c on c.cInvCode=a.cInvCode

+ 9 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/impl/SyCostAllocationServiceImpl.java

@@ -190,6 +190,15 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
             return null;
         }
         syCostAllocation = list.get(0);
+
+        // 销售订单附件
+        List<AccessorItem> accessorItemList = new ArrayList<>();
+        if (org.jeecg.modules.system.util.oConvertUtils.isNotEmpty(syCostAllocation.getGarmentContractno())) {
+            accessorItemList = fabricLossMapper.getSoAccList(Arrays.asList(syCostAllocation.getGarmentContractno().split(",")));
+            accessorItemList.forEach(e -> e.setFileurl("/report/FabricLoss/getFile?fileId=" + e.getCFileId() + "&filename=" + e.getFilename()));
+        }
+        syCostAllocation.setAccessorItemList(accessorItemList);
+
         //税率赋值,默认13
         syCostAllocation.setTaxrate(new BigDecimal(13));
         //制单人 取当前查询人

+ 28 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/orderData/service/impl/SyOrderDataServiceImpl.java

@@ -31,6 +31,7 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -61,7 +62,6 @@ public class SyOrderDataServiceImpl extends ServiceImpl<SyOrderDataMapper, SyOrd
         Date day=new Date();
         //定义集合
         List<Map<String, Object>> sumlist = new ArrayList<>();
-
         try {
             //查找单证是否有当前销售订单 如果有 默认客户进行当前订单的更新操作
             //更新数据,如为更新数据 删除老数据重新添加新数据
@@ -225,6 +225,33 @@ public class SyOrderDataServiceImpl extends ServiceImpl<SyOrderDataMapper, SyOrd
                 String orderID = jianSon.get(0).get("syOrderDataId").toString();
                 for (JSONObject Object:jianSon) {
                     SyOrderDataItem sy2 = JSONObject.toJavaObject(Object, SyOrderDataItem.class);
+
+                    //如果102销售订单客户 做判断 如果是香港森语 就需要向上追溯(取佣金)
+                    if(sy.getAccount().equals("102") && sy.getCustomerAbbreviation().equals("International Apparel Group")) {
+                        String ymoneySql = "select  sosose101.cbdefine2 as ymoney " +
+                                "from UFDATA_102_2021.dbo.SO_SODetails sosos102 " +
+                                "left join UFDATA_102_2021.dbo.SO_SOmain soso102 on soso102.id=sosos102.id " +
+                                "left join UFDATA_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID HDK on  " +
+                                "(HDK.accid='1000000002'and soso102.cCusCode='T020001' ) and hdk.did=sosos102.iSOsID and hdk.cvouchertype='17' " +
+                                "left join UFDATA_101_2021.dbo.PO_Podetails popos101 on popos101.id=hdk.PreDid  " +
+                                "left join UFDATA_101_2021.dbo.SO_SODetails_extradefine sosose101 on sosose101.iSOsID=popos101.iorderdid " +
+                                "left join UFDATA_102_2021.dbo.Inventory inv102 on inv102.cInvCode=sosos102.cInvCode  " +
+                                "where soso102.cCusCode='T020001' and left(inv102.cInvCCode,2)='19'  " +
+                                "and soso102.cSOCode='"+sy.getOrderNumber()+"' and sosos102.AutoID =" + sy2.getId();
+                        List<Map<String, Object>> ymoneyList = new ArrayList<>();
+
+                        if (sy.getAccount().equals("101")) {
+                            ymoneyList = senYuDataSourceOne.queryForList(ymoneySql);
+                        } else if (sy.getAccount().equals("102")) {
+                            ymoneyList = senYuDataSourceTwo.queryForList(ymoneySql);
+                        } else if (sy.getAccount().equals("103")) {
+                            ymoneyList = senYuDataSourceThree.queryForList(ymoneySql);
+                        }
+                        if (ymoneyList.size() > 0) {
+                            sy2.setYmoney(new BigDecimal(ymoneyList.get(0).get("ymoney").toString()));
+                        }
+                    }
+
                     sy2.setId(sy.getAccount()+sy2.getId());
                     if(isNewOrder){
                         String item = syOrderDataItemService.queryItemMub(sy2.getId());

+ 7 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/service/impl/SyShippingDetailsServiceImpl.java

@@ -161,16 +161,16 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
                 entity.setShippingDetailsId(id);
                 entity.setId(oConvertUtils.id());
                 sort++;
-                //设置报关单价 = 含税单价-佣金
-                BigDecimal yj = li.getYmoney();
-                if(oConvertUtils.isEmpty(yj)){
-                    yj = BigDecimal.ZERO;
-                }
+                //设置报关单价 = 含税单价-佣金   2023.8.23 改为 报关单价 = 含税单价
+//                BigDecimal yj = li.getYmoney();
+//                if(oConvertUtils.isEmpty(yj)){
+//                    yj = BigDecimal.ZERO;
+//                }
                 if(oConvertUtils.isEmpty(li.getITaxPrice())){
                     li.setITaxPrice(BigDecimal.ZERO);
                 }
-                BigDecimal customsDeclarationUnitPrice = li.getUnitPriceIncludingTax().subtract(yj);
-                entity.setCustomsDeclarationUnitPrice(customsDeclarationUnitPrice);
+//                BigDecimal customsDeclarationUnitPrice = li.getUnitPriceIncludingTax().subtract(yj);
+                entity.setCustomsDeclarationUnitPrice(li.getUnitPriceIncludingTax());
 
                 //报关要素
                 entity.setElementsId(elementId);

+ 22 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/syShippingOrder/controller/SyShippingOrderController.java

@@ -636,6 +636,8 @@ public class SyShippingOrderController extends JeecgController<SyShippingOrder,
 		 BigDecimal tatolVolume = BigDecimal.ZERO;
 		 //总箱数
 		 BigDecimal tatolBoxnumber = BigDecimal.ZERO;
+		 //报关总金额
+		 BigDecimal totalDeclarationTotalPrice = BigDecimal.ZERO;
 
 		 //获取当前时间
 		 Date date = new Date();
@@ -671,7 +673,17 @@ public class SyShippingOrderController extends JeecgController<SyShippingOrder,
 					 tatolMoney = tatolMoney.add(li.getTotalPrice());
 					 tatolVolume = tatolVolume.add(li.getVolume());
 					 tatolBoxnumber = tatolBoxnumber.add(li.getBoxNumber());
+					 if(oConvertUtils.isEmpty(li.getTotalDeclarationTotalPrice())){
+						 li.setTotalDeclarationTotalPrice(li.getTotalPrice());
+					 }
+					 totalDeclarationTotalPrice = totalDeclarationTotalPrice.add(li.getTotalDeclarationTotalPrice());
 					 li.setDestination(entity.getArriveInCountry());
+					 if(oConvertUtils.isEmpty(li.getDeclarationUnitPrice())){
+						 li.setDeclarationUnitPrice(li.getUnitPrice());
+					 }
+					 if(oConvertUtils.isEmpty(li.getDeclarationTotalPrice())){
+						 li.setDeclarationTotalPrice(li.getTotalPrice());
+					 }
 				 }
 			 } else {
 				 readyFabric = "申报要素-面辅料";
@@ -685,7 +697,17 @@ public class SyShippingOrderController extends JeecgController<SyShippingOrder,
 					 tatolMoney = tatolMoney.add(li.getTotalPrice());
 					 tatolVolume = tatolVolume.add(li.getVolume());
 					 tatolBoxnumber = tatolBoxnumber.add(li.getBoxNumber());
+					 if(oConvertUtils.isEmpty(li.getTotalDeclarationTotalPrice())){
+						 li.setTotalDeclarationTotalPrice(li.getTotalPrice());
+					 }
+					 totalDeclarationTotalPrice = totalDeclarationTotalPrice.add(li.getTotalDeclarationTotalPrice());
 					 li.setDestination(entity.getArriveInCountry());
+					 if(oConvertUtils.isEmpty(li.getDeclarationUnitPrice())){
+						 li.setDeclarationUnitPrice(li.getUnitPrice());
+					 }
+					 if(oConvertUtils.isEmpty(li.getDeclarationTotalPrice())){
+						 li.setDeclarationTotalPrice(li.getTotalPrice());
+					 }
 				 }
 
 			 }

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/syShippingOrder/entity/SyShippingOrderItem.java

@@ -342,4 +342,11 @@ public class SyShippingOrderItem {
 	//是否TC
 
 	private String isTc;
+
+	//报关金额(结汇发票使用)
+	@TableField(exist = false)
+	private BigDecimal declarationTotalPrice;
+	//报关总金额(结汇发票使用)
+	@TableField(exist = false)
+	private BigDecimal totalDeclarationTotalPrice;
 }

+ 4 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/syShippingOrder/mapper/xml/SyShippingOrderMapper.xml

@@ -171,7 +171,7 @@ d.terms_of_deliveryvalue as termsOfDeliveryvalue
     <select id="queryEelementMerge" resultType="org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrderItem">
 
 select GROUP_CONCAT(a.id) as id,b.hs_code as hsCode,b.declaration_name as declarationName,b.english_product_name as englishProductName,case when ready_fabric != '辅料' then sum(c.meter) else sum(c.actual_declared_quantity) end as meter,sum(a.number) as number,a.unit_price as unitPrice,
-round(sum(a.total_price),2) as totalPrice,round(sum(a.gross_weight),2) as grossWeight,round(sum(a.net_weight),2) as netWeight,'KG' as pcs,a.volume as volume,a.pk_org as pkOrg,
+round(sum(a.total_price),2) as totalPrice,a.declaration_unit_price as declarationUnitPrice,(a.number*a.declaration_unit_price) as declarationTotalPrice,round(sum(a.gross_weight),2) as grossWeight,round(sum(a.net_weight),2) as netWeight,'KG' as pcs,a.volume as volume,a.pk_org as pkOrg,
 'USD' as curr,'CHINA' as dree,'宁波其他/宁波象山县' as place,'照章征税' as certificate,a.style_number as styleNumber,a.smail_po as smailPo,sum(a.box_number) as boxNumber,
 a.order_number as orderNumber,a.client_abbreviation as clientAbbreviation,'CTNS' as ctns,'KGS' as kgs,'CBM' as cbm,c.factory_Unit_Price as factoryUnitPrice,
 b.declaration_unit as declarationUnit
@@ -189,11 +189,11 @@ where a.sy_shipping_order_item_id =#{id}
     <select id="queryEelement" resultType="org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrderItem">
 
 select case when t.istc ='0' then '否' else '是' end as isTc,t.preDate,t.supplier,t.id, t.hsCode,sum(t.boxNumber) as boxNumber, t.declarationName,t.englishProductName,sum(t.number) as number,round(t.unitPrice,2) as unitPrice,
-round(sum(t.totalPrice),2) as totalPrice,round(sum(t.grossWeight),2) as grossWeight,round(sum(t.netWeight),2) as netWeight,t.pcs,t.pacs,
-round(sum(t.volume),3) as volume,t.curr,t.dree,t.place,t.certificate,t.styleNumber,t.smailPo,t.orderNumber,t.ctns,t.kgs,t.cbm,pkOrg,t.factoryUnitPrice,
+round(sum(t.totalPrice),2) as totalPrice,round(sum(t.declarationTotalPrice),2) as declarationTotalPrice,round(sum(t.grossWeight),2) as grossWeight,round(sum(t.netWeight),2) as netWeight,t.pcs,t.pacs,
+round(sum(t.volume),3) as volume,t.declarationUnitPrice,t.curr,t.dree,t.place,t.certificate,t.styleNumber,t.smailPo,t.orderNumber,t.ctns,t.kgs,t.cbm,pkOrg,t.factoryUnitPrice,
 t.outerBoxLength,t.outerBoxWidth,t.outerBoxHeight,t.hod,t.unIt,t.emp,GROUP_CONCAT(DISTINCT t.purchaseOutsourcingOrderNo) as purchaseOutsourcingOrderNo,t.packId,t.salesman,t.earliestDeliveryDate,t.declarationUnit,
 t.clientAbbreviation,t.pcGw,t.priceGw from (
-select del.istc as isTc,DATE_FORMAT(a.pre_shipment_date,'%y-%m-%d') as preDate,a.garment_factory as garmentFactory,a.supplier,GROUP_CONCAT(a.id) as id,b.hs_code as hsCode,b.declaration_name as declarationName,b.english_product_name as englishProductName,sum(a.number) as number,a.unit_price as unitPrice,
+select a.declaration_unit_price as declarationUnitPrice,sum(a.number*a.declaration_unit_price) as declarationTotalPrice,del.istc as isTc,DATE_FORMAT(a.pre_shipment_date,'%y-%m-%d') as preDate,a.garment_factory as garmentFactory,a.supplier,GROUP_CONCAT(a.id) as id,b.hs_code as hsCode,b.declaration_name as declarationName,b.english_product_name as englishProductName,sum(a.number) as number,a.unit_price as unitPrice,
 sum(a.number*a.unit_price) as totalPrice,a.gross_weight as grossWeight,a.net_weight as netWeight,a.master_metering as pcs,a.volume as volume,a.elements_Id as elementsId,
 'USD' as curr,'CHINA' as dree,'宁波其他/宁波象山县' as place,'照章征税' as certificate,a.style_number as styleNumber,a.smail_po as smailPo,a.box_number as boxNumber,
 a.order_number as orderNumber,a.client_abbreviation as clientAbbreviation,'PCS' as pacs,'CTNS' as ctns,'KGS' as kgs,'CBM' as cbm,c.salesman as salesman,'PC' as pcGw,'/PC' as priceGw,

+ 28 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/quartz/job/AddOrderJob.java

@@ -25,6 +25,7 @@ import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -216,6 +217,33 @@ public class AddOrderJob implements Job,ApplicationContextAware {
                 String orderID = jianSon.get(0).get("syOrderDataId").toString();
                 for (JSONObject Object:jianSon) {
                     SyOrderDataItem sy2 = JSONObject.toJavaObject(Object, SyOrderDataItem.class);
+
+                    //如果902销售订单客户 做判断 如果是香港森语 就需要向上追溯(取佣金)
+                    if(sy.getAccount().equals("102") && sy.getCustomerAbbreviation().equals("International Apparel Group")) {
+                        String ymoneySql = "select  sosose901.cbdefine2 as ymoney " +
+                                "from UFDATA_902_2021.dbo.SO_SODetails sosos902 " +
+                                "left join UFDATA_902_2021.dbo.SO_SOmain soso902 on soso902.id=sosos902.id " +
+                                "left join UFDATA_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID HDK on  " +
+                                "(HDK.accid='1000000002'and soso902.cCusCode='T020001' ) and hdk.did=sosos902.iSOsID and hdk.cvouchertype='17' " +
+                                "left join UFDATA_901_2021.dbo.PO_Podetails popos901 on popos901.id=hdk.PreDid  " +
+                                "left join UFDATA_901_2021.dbo.SO_SODetails_extradefine sosose901 on sosose901.iSOsID=popos901.iorderdid " +
+                                "left join UFDATA_902_2021.dbo.Inventory inv902 on inv902.cInvCode=sosos902.cInvCode  " +
+                                "where soso902.cCusCode='T020001' and left(inv902.cInvCCode,2)='19'  " +
+                                "and soso902.cSOCode='"+sy.getOrderNumber()+"' and sosos902.AutoID =" + sy2.getId();
+                        List<Map<String, Object>> ymoneyList = new ArrayList<>();
+
+                        if (sy.getAccount().equals("101")) {
+                            ymoneyList = senYuDataSourceOne.queryForList(ymoneySql);
+                        } else if (sy.getAccount().equals("102")) {
+                            ymoneyList = senYuDataSourceTwo.queryForList(ymoneySql);
+                        } else if (sy.getAccount().equals("103")) {
+                            ymoneyList = senYuDataSourceThree.queryForList(ymoneySql);
+                        }
+                        if (ymoneyList.size() > 0) {
+                            sy2.setYmoney(new BigDecimal(ymoneyList.get(0).get("ymoney").toString()));
+                        }
+                    }
+
                     sy2.setId(sy.getAccount()+sy2.getId());
                     if(isNewOrder){
                         String item = syOrderDataItemService.queryItemMub(sy2.getId());