You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
9.0 KiB
95 lines
9.0 KiB
3 years ago
|
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\",\"Order
|
||
|
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<GetListEntity.ItemEntity> 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;
|
||
|
}
|
||
|
}
|
||
|
}
|