From d827760a5c4538c2d9bdf5f4d161dd3207f286ab Mon Sep 17 00:00:00 2001 From: liuy <37787198+LiuyCodes@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4TOB=E9=80=80=E8=B4=A7?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SoSaleReturnPluginInitializerToB.java | 117 ++++++++++++++++-- .../SoSaleReturnPluginInitializerToC.java | 2 +- .../SoSaleReturnPluginInitializerToBTest.java | 12 ++ 3 files changed, 123 insertions(+), 8 deletions(-) diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java index b049160d..1c2ce890 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java @@ -24,6 +24,10 @@ import com.hzya.frame.plugin.lets.util.DateStrUtil; import com.hzya.frame.plugin.lets.util.QueryBdBusitypeUtil; import com.hzya.frame.split.SplitListByCountUtil; import com.hzya.frame.ttxofs.dto.InterfaceParamDto; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.SaleOrderMessageDto; +import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchData; +import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchJsonRootBean; import com.hzya.frame.ttxofs.dto.returngoodsearch.RertunGoodsRootBean; import com.hzya.frame.ttxofs.dto.returngoodsearch.ReturnGoodHeaderDetailsDataDto; import com.hzya.frame.ttxofs.dto.returngoodsearch.ReturnGoodSearchDetailsDto; @@ -31,6 +35,7 @@ import com.hzya.frame.ttxofs.dto.returngoodsearch.ReturnGoodSearchHeaderDto; import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; import com.hzya.frame.ttxofs.service.OfsUnifiedService; import com.hzya.frame.web.entity.JsonResultEntity; +import lombok.Data; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -153,15 +158,15 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setClosedAt_start("2024-07-16 16:44:00"); - queryOfsSoSaleOutVo.setClosedAt_end("2024-07-16 16:44:02"); +// queryOfsSoSaleOutVo.setClosedAt_start("2024-07-16 16:44:00"); +// queryOfsSoSaleOutVo.setClosedAt_end("2024-07-16 16:44:02"); queryOfsSoSaleOutVo.setClientCode("LETS"); // queryOfsSoSaleOutVo.setInternalInstructionType("SALES"); - queryOfsSoSaleOutVo.setCompanyCode("SHLZ"); - // queryOfsSoSaleOutVo.setStatus(900L); +// queryOfsSoSaleOutVo.setCompanyCode("SHLZ"); +// queryOfsSoSaleOutVo.setStatus(900L); queryOfsSoSaleOutVo.setPageNo(1L); queryOfsSoSaleOutVo.setPageSize(50L); -// queryOfsSoSaleOutVo.setCode("LETS-RE2024071600000001"); + queryOfsSoSaleOutVo.setCode("LETS-RE2024070800000001"); queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L); logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { @@ -486,6 +491,16 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); List details = stockinOrder.getDetails(); + //通过售后订单,查询销售订单 + SaleOrderMessageDto saleOrderMessageDto = queryAfterSalesOrder(header); + if (saleOrderMessageDto == null) { + Assert.state(false, "没有匹配到售后订单,系统业务无法完成"); + } + HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); + String memberId = header1.getMemberId(); + Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); + Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); + // 销售公司、发货公司 String companyCode = header.getCompanyCode(); Assert.notNull(companyCode, "O表头公司不能为空"); @@ -556,12 +571,17 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { } //客商基本档案 - String custName = "天猫intoyou旗舰店-自营"; +// String custName = "天猫intoyou旗舰店-自营"; BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); bdCubasdocEntity.setDataSourceCode("lets_u8c"); bdCubasdocEntity.setDr(0L); - bdCubasdocEntity.setCustname(custName); + bdCubasdocEntity.setDef1(memberId); List bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); + if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) { + Assert.state(false, "根据OFS会员id{},无法查询到U8C客商基本档案", memberId); + } else if (bdCubasdocEntityList.size() >= 2) { + Assert.state(false, "根据OFS会员id{},无法查询到U8C客商基本档案", memberId); + } //客商管理档案 BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity(); @@ -571,6 +591,9 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc()); bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER); List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1); + if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) { + Assert.state(false, "根据客商基本档案主键{},没有办法查询到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); + } //查找平台 String platformZdyId = "0001A210000000000JUD"; @@ -826,4 +849,84 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity { tocofsReturngoodsDetailedEntity.setBusinessType("TOB_RETURN");//业务类型 } } + + /** + * 根据售后订单号,查询售后订单 + * + * @param refOrderCode 售后订单号 + * @author liuyang + */ + public RerturnGoodsOrderSearchData getOfsRertunOrder(String refOrderCode) throws Exception { + Long pageSize = 200L; + Long pageNo = 1L; + + QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); + queryOfsSoSaleOutVo.setPageNo(pageNo); + queryOfsSoSaleOutVo.setPageSize(pageSize); + queryOfsSoSaleOutVo.setCode(refOrderCode); + + InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); + interfaceParamDto.setApi("ofs.returnOrder.search"); + interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo)); + RerturnGoodsOrderSearchJsonRootBean rerturnGoodsOrderSearchJsonRootBean = (RerturnGoodsOrderSearchJsonRootBean) ofsUnifiedService.unified(interfaceParamDto); + if (rerturnGoodsOrderSearchJsonRootBean != null) { + if ("false".equals(rerturnGoodsOrderSearchJsonRootBean.getError()) && "0".equals(rerturnGoodsOrderSearchJsonRootBean.getCode()) && "Success".equals(rerturnGoodsOrderSearchJsonRootBean.getMsg())) { + List data = rerturnGoodsOrderSearchJsonRootBean.getData(); + if (data != null && data.size() > 0) { + return data.get(0); + } + } else { + logger.error("查询售后订单失败,接口返回结果:{}", JSON.toJSON(rerturnGoodsOrderSearchJsonRootBean)); + } + } else { + logger.error("rerturnGoodsOrderSearchJsonRootBean为空(返回结果为空),查询入参条件:{}!", JSON.toJSON(queryOfsSoSaleOutVo)); + } + Assert.state(false, "根据售后订单号:{} 没有查询到OFS售后订单", refOrderCode); + return null; + } + + /** + * 查询OFS销售订单 + * + * @param code OFS销售订单编码 + * @author liuyang + */ + public SaleOrderMessageDto getOfsOrder(String code) throws Exception { + Long pageSize = 200L; + Long pageNo = 1L; + + QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); + queryOfsSoSaleOutVo.setPageNo(pageNo); + queryOfsSoSaleOutVo.setPageSize(pageSize); + queryOfsSoSaleOutVo.setCode(code); + + InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); + interfaceParamDto.setApi("ofs.salesOrder.search"); + interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo)); + SaleOrderMessageDto saleOrderMessageDto = (SaleOrderMessageDto) ofsUnifiedService.unified(interfaceParamDto); + return saleOrderMessageDto; + } + + /** + * 查询售后订单 + * + * @author liuyang + */ + private SaleOrderMessageDto queryAfterSalesOrder(StockinOrderSearchResponse.StockinOrder.StockinH header) throws Exception { + if (header != null) { + //根据售后入库单、查询售后订单 + RerturnGoodsOrderSearchData ofsRertunOrder = getOfsRertunOrder(header.getRefOrderCode()); + if (ofsRertunOrder == null || ofsRertunOrder.getHeader() == null || ofsRertunOrder.getDetails() == null) { + Assert.state(false, "根据OFS售后订单编码{},无法查询到售后订单信息!", header.getRefOrderCode()); + } + SaleOrderMessageDto ofsOrder = getOfsOrder(ofsRertunOrder.getHeader().getRefOrderCode()); + if (ofsOrder == null) { + Assert.state(false, "根据OFS销售订单编码{},无法查询到销售订单信息!", ofsRertunOrder.getHeader().getRefOrderCode()); + } + return ofsOrder; + } else { + logger.error("queryAfterSalesOrder方法入参为null(header为null!)"); + } + return null; + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java index 64bfeb77..79ac60c9 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java @@ -127,7 +127,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { queryOfsSoSaleOutVo.setCreated_end("2024-07-16 15:35:37"); queryOfsSoSaleOutVo.setClientCode("LETS"); // queryOfsSoSaleOutVo.setInternalInstructionType("SALES"); - queryOfsSoSaleOutVo.setCompanyCode("SHLZ"); +// queryOfsSoSaleOutVo.setCompanyCode("SHLZ"); // queryOfsSoSaleOutVo.setStatus(900L); queryOfsSoSaleOutVo.setPageNo(1L); queryOfsSoSaleOutVo.setPageSize(50L); diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToBTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToBTest.java index 7c6109e3..6b1ce1f6 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToBTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToBTest.java @@ -1,6 +1,7 @@ package com.hzya.frame.plugin.lets.plugin.sales; import com.hzya.frame.WebappApplication; +import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -32,4 +33,15 @@ public class SoSaleReturnPluginInitializerToBTest { e.printStackTrace(); } } + +// @Test +// public void startImplement2() { +// try { +// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); +// queryOfsSoSaleOutVo.setClientCode("LETS"); +// soSaleReturnPluginInitializerToB.getOfsRertunOrder(queryOfsSoSaleOutVo); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } } \ No newline at end of file