diff --git a/pom.xml b/pom.xml index eb82e33..efd3dbe 100644 --- a/pom.xml +++ b/pom.xml @@ -107,6 +107,19 @@ hutool-all 5.6.2 + + + junit + junit + RELEASE + test + + + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/src/main/java/com/qs/cost/common/conf/MainServerProperties.java b/src/main/java/com/qs/cost/common/conf/MainServerProperties.java index ebe4221..61059fe 100644 --- a/src/main/java/com/qs/cost/common/conf/MainServerProperties.java +++ b/src/main/java/com/qs/cost/common/conf/MainServerProperties.java @@ -13,7 +13,7 @@ import org.springframework.stereotype.Component; @Getter @Setter @Component -@ConfigurationProperties(prefix = "server.timetable") +@ConfigurationProperties(prefix = "server") public class MainServerProperties { private String host; @@ -22,4 +22,6 @@ public class MainServerProperties { private String year; + private String u8url; + } diff --git a/src/main/java/com/qs/cost/common/dto/u8/U8RequestBo.java b/src/main/java/com/qs/cost/common/dto/u8/U8RequestBo.java index ec56423..4b17724 100644 --- a/src/main/java/com/qs/cost/common/dto/u8/U8RequestBo.java +++ b/src/main/java/com/qs/cost/common/dto/u8/U8RequestBo.java @@ -59,13 +59,16 @@ public class U8RequestBo { /** * 是否回调(0-否;1-是) */ - private Integer callbackState; + private String callbackState; /** * 回调地址(callbackState=1时,不能为空) */ private String callbackHost; - + /** + * 立马运行(默认false) + */ + private Boolean immediatelyRun; } diff --git a/src/main/java/com/qs/cost/common/utils/HttpUtil.java b/src/main/java/com/qs/cost/common/utils/HttpUtil.java index bcf2f2e..4bc66d4 100644 --- a/src/main/java/com/qs/cost/common/utils/HttpUtil.java +++ b/src/main/java/com/qs/cost/common/utils/HttpUtil.java @@ -11,6 +11,7 @@ import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; @@ -19,6 +20,7 @@ import org.apache.http.util.EntityUtils; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Map; @@ -70,14 +72,11 @@ public class HttpUtil { } /** post的URL的参数map请求 */ - public static HttpResult post(String url, Map params) { + public static HttpResult post(String url, String json) { HttpPost httpPost = new HttpPost(url); - ArrayList pairs = covertParams2NVPS(params); - try { - httpPost.setEntity(new UrlEncodedFormEntity(pairs, UTF8)); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + httpPost.setHeader("Accept","application/json"); + httpPost.setHeader("Content-Type","application/json"); + httpPost.setEntity(new StringEntity(json, StandardCharsets.UTF_8)); return getHttpResult(httpPost); } diff --git a/src/main/java/com/qs/cost/module/controller/LzOrderController.java b/src/main/java/com/qs/cost/module/controller/LzOrderController.java index e3011a9..399e16c 100644 --- a/src/main/java/com/qs/cost/module/controller/LzOrderController.java +++ b/src/main/java/com/qs/cost/module/controller/LzOrderController.java @@ -2,6 +2,7 @@ package com.qs.cost.module.controller; import com.qs.cost.common.dto.R; import com.qs.cost.common.dto.u8.U8CallbackVo; +import com.qs.cost.common.utils.JsonUtil; import com.qs.cost.module.service.JiaJinService; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; @@ -22,6 +23,7 @@ public class LzOrderController { @PostMapping("/callback") public R callback(@RequestBody U8CallbackVo requestVo){ + System.out.println(JsonUtil.objectToJson(requestVo)); jiaJinService.callback(requestVo); return R.ok(); } diff --git a/src/main/java/com/qs/cost/module/domain/GetListEntity.java b/src/main/java/com/qs/cost/module/domain/GetListEntity.java index 4680e55..8b6e211 100644 --- a/src/main/java/com/qs/cost/module/domain/GetListEntity.java +++ b/src/main/java/com/qs/cost/module/domain/GetListEntity.java @@ -15,7 +15,6 @@ public class GetListEntity { private List list; - private OtherEntity other; @JsonProperty("Status") private Boolean status; @@ -36,23 +35,39 @@ public class GetListEntity { @Data public static class ItemEntity{ + + @JsonProperty("ProductId") + private String productId; + + @JsonProperty("ProductSkuId") + private String skuId; + @JsonProperty("ERPCode") private String invCode; + @JsonProperty("ProductCode") + private String productCode; + + @JsonProperty("ProductName") + private String productName; + //数量 @JsonProperty("Qty") private Integer qty; //总支付金额 @JsonProperty("SellingPrice") - private BigDecimal saleAmount; + private String saleAmount; //销售单价 - @JsonProperty("SellingPrice") - private BigDecimal salePrice; + @JsonProperty("TaxPrice") + private String salePrice; @JsonProperty("TaxPercent") - private BigDecimal taxRate; + private String taxRate; + + @JsonProperty("TaxIncluded") + private Boolean taxIncluded; } @@ -85,20 +100,48 @@ public class GetListEntity { private Object items; + @JsonProperty("Other") + private OtherEntity other; + } @Data public static class OtherEntity{ - - @JsonProperty("sales_class") + /** + * 客户编号 + */ + @JsonProperty("Name") + private String name; + + /** + * 客户编号 + */ + @JsonProperty("Code") + private String customCode; + + /** + * 销售部门编号 + */ + @JsonProperty("SalesClass") private String salesClass; - @JsonProperty("sales_man") + /** + * 业务员编号 + */ + @JsonProperty("SalesMan") private String salesMan; - @JsonProperty("sales_type") + /** + * 销售类型 + */ + @JsonProperty("SalesType") private String salesType; + /** + * 税率 + */ + @JsonProperty("TaxPercent") + private String taxPercent; } /** diff --git a/src/main/java/com/qs/cost/module/domain/LzOrder.java b/src/main/java/com/qs/cost/module/domain/LzOrder.java index bd6302a..883f7f6 100644 --- a/src/main/java/com/qs/cost/module/domain/LzOrder.java +++ b/src/main/java/com/qs/cost/module/domain/LzOrder.java @@ -35,6 +35,9 @@ public class LzOrder implements Serializable { @Length(max = 20,message = "订单编号长度不能超过20字") private String orderNo; + /** 客户编号 */ + private String customCode; + /** 订单金额 */ @NotNull(message = "订单金额不能为空") private BigDecimal orderAmount; @@ -80,7 +83,7 @@ public class LzOrder implements Serializable { /** 检查item状态:0-正常;1-存货编码缺失;2-数据异常 */ private Integer checkStatus; - private Integer callBackStatus; + private Integer callbackStatus; private String items; diff --git a/src/main/java/com/qs/cost/module/service/JiaJinService.java b/src/main/java/com/qs/cost/module/service/JiaJinService.java index 29767e3..ea6b0c6 100644 --- a/src/main/java/com/qs/cost/module/service/JiaJinService.java +++ b/src/main/java/com/qs/cost/module/service/JiaJinService.java @@ -69,7 +69,8 @@ public class JiaJinService { LzResponseLog responseLog = new LzResponseLog(); responseLog.setJson(json); responseLogService.save(responseLog); - GetListEntity.OtherEntity otherEntity = getListEntity.getOther(); + GetListEntity.OtherEntity otherEntity = new GetListEntity.OtherEntity(); + //GetListEntity.OtherEntity otherEntity = getListEntity.getOther(); //解析请求json,并保存订单到数据库 for (GetListEntity.OrderEntity orderEntity : getListEntity.getList()) { LzOrder lzOrder = new LzOrder(); @@ -83,7 +84,7 @@ public class JiaJinService { lzOrder.setSaleType(otherEntity.getSalesType()); lzOrder.setSaleDept(otherEntity.getSalesClass()); lzOrder.setSaleMan(otherEntity.getSalesMan()); - String itemJson = orderEntity.getItems().toString(); + String itemJson = JsonUtil.objectToJson(orderEntity.getItems()); lzOrder.setItems(itemJson); lzOrder.setCheckStatus(0); List items = JsonUtil.jsonToList(itemJson,GetListEntity.ItemEntity.class); @@ -123,7 +124,6 @@ public class JiaJinService { lqw.eq(LzOrder::getStatus,0); lqw.eq(LzOrder::getCheckStatus,0); List orders = lzOrderService.list(lqw); - //DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); Date now = new Date(); for (LzOrder order : orders) { String host = mainServerProperties.getHost(); @@ -131,19 +131,18 @@ public class JiaJinService { String book = mainServerProperties.getBook(); //封装jsonBody List details = new ArrayList<>(); - String itemJson = order.getItems(); List items = JsonUtil.jsonToList(itemJson,GetListEntity.ItemEntity.class); BigDecimal rate = BigDecimal.ONE; for (GetListEntity.ItemEntity item : items) { U8API4SaleOrder.OrderDetail orderDetail = new U8API4SaleOrder.OrderDetail(); //拿子项税率 - rate = item.getTaxRate(); + rate = new BigDecimal(item.getTaxRate()); orderDetail.setInvCode(item.getInvCode()); - orderDetail.setTaxRate(item.getTaxRate()); + orderDetail.setTaxRate(new BigDecimal(item.getTaxRate())); orderDetail.setQuantity(new Long(item.getQty())); - orderDetail.setHasRatePrice(item.getSalePrice()); - orderDetail.setHasRateSumPrice(item.getSaleAmount()); + orderDetail.setHasRatePrice(new BigDecimal(item.getSalePrice())); + orderDetail.setHasRateSumPrice(new BigDecimal(item.getSaleAmount())); orderDetail.setPreShipmentsDate(now); orderDetail.setPreFinishedDate(now); } @@ -153,8 +152,7 @@ public class JiaJinService { .orderDate(DateUtil.localDateTimeToDate(order.getOrderCreateTime())) .bizType("普通销售") .saleType("01") - //TODO 客户编码未定 - .cusCode("") + .cusCode(order.getCustomCode()) .currencyType("人民币") .depCode(order.getSaleDept()) .createUser(order.getSaleMan()) @@ -175,10 +173,11 @@ public class JiaJinService { requestBo.setJsonBody(jsonBody); requestBo.setKeyId(""); requestBo.setSettingRetryTimes(2); - requestBo.setCallbackState(1); + requestBo.setCallbackState("1"); requestBo.setCallbackHost( host + "/lzOrder/callback"); - order.setStatus(1); + //TODO 方便测试 order.setStatus(1); order.setUpdateTime(LocalDateTime.now()); + HttpUtil.post(mainServerProperties.getU8url(),JsonUtil.objectToJson(requestBo)); } lzOrderService.updateBatchById(orders); } @@ -205,7 +204,7 @@ public class JiaJinService { Map paramMap = new HashMap<>(10); paramMap.put("orderNos",orderNo); paramMap.put("sign",sign); - HttpResult httpResult = HttpUtil.post(url,paramMap); + HttpResult httpResult = HttpUtil.post(url,JsonUtil.objectToJson(paramMap)); if(httpResult.getCode()==200){ if(httpResult.getData().contains("true")){ lzOrder.setCheckStatus(1); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 3ec47ed..9de4999 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,12 +1,14 @@ #服务配置 server: - port: 7701 - #本服务访问根地址,用于读取 - host: '127.0.0.1:7001' + port: 7101 + #本服务访问根地址,用于回调 + host: 'http://127.0.0.1:7101' #帐套 book: 999 #年份 year: 2020 + #U8平台 + u8url: http://127.0.0.1:7100/api/jobRequest #SpringBoot相关 spring: #数据源 diff --git a/src/test/java/boot/BootTest.java b/src/test/java/boot/BootTest.java new file mode 100644 index 0000000..d02d307 --- /dev/null +++ b/src/test/java/boot/BootTest.java @@ -0,0 +1,94 @@ +package boot; + +import com.qs.cost.Application; +import com.qs.cost.common.conf.MainServerProperties; +import com.qs.cost.common.utils.JsonUtil; +import com.qs.cost.common.utils.StringUtil; +import com.qs.cost.module.domain.GetListEntity; +import com.qs.cost.module.domain.LzOrder; +import com.qs.cost.module.domain.LzResponseLog; +import com.qs.cost.module.service.JiaJinService; +import com.qs.cost.module.service.LzOrderService; +import com.qs.cost.module.service.LzResponseLogService; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; + +/** + * @author YenHex + * @since 2022/7/12 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class) +@Slf4j +public class BootTest { + + @Autowired private LzResponseLogService responseLogService; + @Autowired private LzOrderService lzOrderService; + @Autowired private JiaJinService jiaJinService; + + @Test + public void test2(){ + jiaJinService.task(); + } + + @Test + public void test() { + String json = "{\"List\":[{\"OrderNO\":\"2022071205963\",\"OrderAmount\":\"520.00\",\"ShippingFare\":\"0.00\",\"Consignee\":\"测试1\",\"ConsigneeMobile\":\"13612345678\",\"Provinces\":\"广东省,广州市,天河区\",\"DetailedAddress\":\"棠东\",\"CreateTime\":\"2022-07-12 15:04:39\",\"Items\":[{\"ProductId\":78,\"ProductSkuId\":0,\"ERPCode\":\"351100005\",\"ProductCode\":\"0013\",\"ProductName\":\"鹿游仙境(一箱装)\",\"Qty\":1,\"SellingPrice\":\"520.00\",\"TaxIncluded\":true,\"TaxPrice\":\"67.60\",\"TaxPercent\":\"13.00\"}],\"Other\":{\"Name\":\"月饼团购(散客)\",\"Code\":\"12421561\",\"SalesClass\":\"199\",\"SalesMan\":\"22100057\",\"SalesType\":\"15\",\"TaxPercent\":\"13.00\"}},{\"OrderNO\":\"2022071283521\",\"OrderAmount\":\"520.00\",\"ShippingFare\":\"0.00\",\"Consignee\":\"测试1\",\"ConsigneeMobile\":\"13612345678\",\"Provinces\":\"广东省,广州市,天河区\",\"DetailedAddress\":\"棠东\",\"CreateTime\":\"2022-07-12 11:09:43\",\"Items\":[{\"ProductId\":78,\"ProductSkuId\":0,\"ERPCode\":\"351100005\",\"ProductCode\":\"0013\",\"ProductName\":\"鹿游仙境(一箱装)\",\"Qty\":1,\"SellingPrice\":\"520.00\",\"TaxIncluded\":false,\"TaxPrice\":\"0.00\",\"TaxPercent\":0}],\"Other\":{\"Name\":null,\"Code\":null,\"SalesClass\":null,\"SalesMan\":null,\"SalesType\":null,\"TaxPercent\":\"0.00\"}},{\"OrderNO\":\"2022071280607\",\"OrderAmount\":\"520.00\",\"ShippingFare\":\"0.00\",\"Consignee\":\"测试1\",\"ConsigneeMobile\":\"13612345678\",\"Provinces\":\"广东省,广州市,天河区\",\"DetailedAddress\":\"棠东\",\"CreateTime\":\"2022-07-12 11:08:12\",\"Items\":[{\"ProductId\":78,\"ProductSkuId\":0,\"ERPCode\":\"351100005\",\"ProductCode\":\"0013\",\"ProductName\":\"鹿游仙境(一箱装)\",\"Qty\":1,\"SellingPrice\":\"520.00\",\"TaxIncluded\":false,\"TaxPrice\":\"0.00\",\"TaxPercent\":0}],\"Other\":{\"Name\":null,\"Code\":null,\"SalesClass\":null,\"SalesMan\":null,\"SalesType\":null,\"TaxPercent\":\"0.00\"}},{\"OrderNO\":\"2022070605623\",\"OrderAmount\":\"1200.00\",\"ShippingFare\":\"0.00\",\"Consignee\":\"测试3\",\"ConsigneeMobile\":\"13612345678\",\"Provinces\":\"广东省,广州市,天河区\",\"DetailedAddress\":\"棠东abchds\",\"CreateTime\":\"2022-07-06 09:54:30\",\"Items\":[{\"ProductId\":101,\"ProductSkuId\":0,\"ERPCode\":\"301010710\",\"ProductCode\":\"202205\",\"ProductName\":\"梨不开你(一箱装)\",\"Qty\":1,\"SellingPrice\":\"1200.00\",\"TaxIncluded\":true,\"TaxPrice\":\"156.00\",\"TaxPercent\":\"13.00\"}],\"Other\":{\"Name\":\"月饼团购(散客)\",\"Code\":\"12421561\",\"SalesClass\":\"199\",\"SalesMan\":\"22100057\",\"SalesType\":\"15\",\"TaxPercent\":\"13.00\"}},{\"OrderNO\":\"2022070628929\",\"OrderAmount\":\"630.00\",\"ShippingFare\":\"0.00\",\"Consignee\":\"测试2\",\"ConsigneeMobile\":\"13612345678\",\"Provinces\":\"广东省,广州市,天河区\",\"DetailedAddress\":\"棠东abc\",\"CreateTime\":\"2022-07-06 09:47:56\",\"Items\":[{\"ProductId\":86,\"ProductSkuId\":0,\"ERPCode\":null,\"ProductCode\":\"0021\",\"ProductName\":\"双黄白莲蓉(一箱装)\",\"Qty\":1,\"SellingPrice\":\"630.00\",\"TaxIncluded\":true,\"TaxPrice\":\"81.90\",\"TaxPercent\":\"13.00\"}],\"Other\":{\"Name\":\"月饼团购(散客)\",\"Code\":\"12421561\",\"SalesClass\":\"199\",\"SalesMan\":\"22100057\",\"SalesType\":\"15\",\"TaxPercent\":\"13.00\"}},{\"OrderNO\":\"2022070649545\",\"OrderAmount\":\"712.00\",\"ShippingFare\":\"0.00\",\"Consignee\":\"测试2\",\"ConsigneeMobile\":\"13612345678\",\"Provinces\":\"广东省,广州市,天河区\",\"DetailedAddress\":\"棠东abc\",\"CreateTime\":\"2022-07-06 09:47:40\",\"Items\":[{\"ProductId\":87,\"ProductSkuId\":0,\"ERPCode\":null,\"ProductCode\":\"0022\",\"ProductName\":\"中秋礼道(一箱装)\",\"Qty\":1,\"SellingPrice\":\"712.00\",\"TaxIncluded\":true,\"TaxPrice\":\"92.56\",\"TaxPercent\":\"13.00\"}],\"Other\":{\"Name\":\"月饼团购(散客)\",\"Code\":\"12421561\",\"SalesClass\":\"199\",\"SalesMan\":\"22100057\",\"SalesType\":\"15\",\"TaxPercent\":\"13.00\"}},{\"OrderNO\":\"2022070698848\",\"OrderAmount\":\"1500.00\",\"ShippingFare\":\"0.00\",\"Consignee\":\"测试2\",\"ConsigneeMobile\":\"13612345678\",\"Provinces\":\"广东省,广州市,天河区\",\"DetailedAddress\":\"棠东abc\",\"CreateTime\":\"2022-07-06 09:43:37\",\"Items\":[{\"ProductId\":100,\"ProductSkuId\":0,\"ERPCode\":null,\"ProductCode\":\"202204\",\"ProductName\":\"花月缤纷(一箱装)\",\"Qty\":1,\"SellingPrice\":\"1500.00\",\"TaxIncluded\":true,\"TaxPrice\":\"195.00\",\"TaxPercent\":\"13.00\"}],\"Other\":{\"Name\":\"月饼团购(散客)\",\"Code\":\"12421561\",\"SalesClass\":\"199\",\"SalesMan\":\"22100057\",\"SalesType\":\"15\",\"TaxPercent\":\"13.00\"}},{\"OrderNO\":\"2022070685170\",\"OrderAmount\":\"3600.00\",\"ShippingFare\":\"0.00\",\"Consignee\":\"测试1\",\"ConsigneeMobile\":\"13612345678\",\"Provinces\":\"广东省,广州市,天河区\",\"DetailedAddress\":\"棠东\",\"CreateTime\":\"2022-07-06 09:42:31\",\"Items\":[{\"ProductId\":101,\"ProductSkuId\":0,\"ERPCode\":\"301010710\",\"ProductCode\":\"202205\",\"ProductName\":\"梨不开你(一箱装)\",\"Qty\":3,\"SellingPrice\":\"1200.00\",\"TaxIncluded\":true,\"TaxPrice\":\"156.00\",\"TaxPercent\":\"13.00\"}],\"Other\":{\"Name\":\"月饼团购(散客)\",\"Code\":\"12421561\",\"SalesClass\":\"199\",\"SalesMan\":\"22100057\",\"SalesType\":\"15\",\"TaxPercent\":\"13.00\"}}],\"Status\":true,\"Msg\":\"获取成功\",\"page\":1,\"total_count\":8,\"page_count\":1,\"page_size\":10}" ; + GetListEntity getListEntity = JsonUtil.jsonToPojo(json, GetListEntity.class); + if (getListEntity == null) { + return; + } + //保存请求json + LzResponseLog responseLog = new LzResponseLog(); + responseLog.setJson(json); + responseLogService.save(responseLog); + //解析请求json,并保存订单到数据库 + for (GetListEntity.OrderEntity orderEntity : getListEntity.getList()) { + GetListEntity.OtherEntity otherEntity = orderEntity.getOther(); + LzOrder lzOrder = new LzOrder(); + lzOrder.setOrderNo(orderEntity.getOrderNo()); + lzOrder.setOrderAmount(orderEntity.getOrderAmount()); + lzOrder.setShippingFare(orderEntity.getShippingFare()); + lzOrder.setConsignee(orderEntity.getConsignee()); + lzOrder.setConsigneeMobile(orderEntity.getConsigneeMobile()); + lzOrder.setProvinces(orderEntity.getProvinces()); + lzOrder.setDetailedAddress(orderEntity.getDetailedAddress()); + lzOrder.setSaleType(otherEntity.getSalesType()); + lzOrder.setSaleDept(otherEntity.getSalesClass()); + lzOrder.setSaleMan(otherEntity.getSalesMan()); + lzOrder.setCustomCode(otherEntity.getCustomCode()); + String itemJson = JsonUtil.objectToJson(orderEntity.getItems()); + lzOrder.setItems(itemJson); + lzOrder.setCheckStatus(0); + System.out.println(itemJson); + List items = JsonUtil.jsonToList(itemJson, GetListEntity.ItemEntity.class); + if (items != null && items.size() > 0) { + for (GetListEntity.ItemEntity item : items) { + if (StringUtil.isEmpty(item.getInvCode())) { + lzOrder.setCheckStatus(1); + break; + } + } + } else { + lzOrder.setCheckStatus(2); + } + try { + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime orderCreateTime = LocalDateTime.parse(orderEntity.getCreateTime(), df); + lzOrder.setOrderCreateTime(orderCreateTime); + } catch (Exception e) { + log.error(e.getMessage()); + } + lzOrderService.save(lzOrder); + break; + } + } +} diff --git a/src/test/java/boot/PrintDemo.java b/src/test/java/boot/PrintDemo.java index 7c560bc..ed1bf5e 100644 --- a/src/test/java/boot/PrintDemo.java +++ b/src/test/java/boot/PrintDemo.java @@ -18,7 +18,7 @@ public class PrintDemo { public static void main(String[] args) { - String date = "2020/04/25-2022/07/26"; + String date = "2020/07/25-2022/07/26"; String page = "1"; String pageSize = "10"; String params = "date="+date+"&page="+page+"&page_size="+pageSize; diff --git a/src/test/java/boot/PrintDemo3.java b/src/test/java/boot/PrintDemo3.java new file mode 100644 index 0000000..fa6319c --- /dev/null +++ b/src/test/java/boot/PrintDemo3.java @@ -0,0 +1,36 @@ +package boot; + +import com.qs.cost.common.dto.HttpResult; +import com.qs.cost.common.utils.HttpUtil; +import com.qs.cost.common.utils.JsonUtil; +import com.qs.cost.common.utils.SecureUtil; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author YenHex + * @since 2021/12/1 + */ +public class PrintDemo3 { + + public static final String lzyunli = "lzyunli"; + + + public static void main(String[] args) { + String params = "orderNos=123"; + System.out.println(params); + String signParam = lzyunli + params + lzyunli; + System.out.println("加密前:"+signParam); + String sign = SecureUtil.md5(signParam); + String url = "http://wsapp6.lzyunli.com/index.php/upOrder"; + Map paramMap = new HashMap<>(); + paramMap.put("orderNos","123"); + paramMap.put("sign",sign); + HttpResult httpResult = HttpUtil.post(url,JsonUtil.objectToJson(paramMap)); + System.out.println(httpResult.getData()); + } + + + +}