|
@ -15,12 +15,8 @@ import com.qs.cost.module.domain.LzResponseLog; |
|
|
import com.qs.cost.module.domain.dto.U8API4SaleOrder; |
|
|
import com.qs.cost.module.domain.dto.U8API4SaleOrder; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
@ -41,6 +37,12 @@ public class JiaJinService { |
|
|
private final MainServerProperties mainServerProperties; |
|
|
private final MainServerProperties mainServerProperties; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 0/5 * * * ?") |
|
|
|
|
|
public void query(){ |
|
|
|
|
|
log.info("订单查询开始"); |
|
|
|
|
|
query(1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 请求量子app获取订单 |
|
|
* 请求量子app获取订单 |
|
|
* @param page |
|
|
* @param page |
|
@ -48,6 +50,8 @@ public class JiaJinService { |
|
|
public void query(Integer page){ |
|
|
public void query(Integer page){ |
|
|
if(page==null){ |
|
|
if(page==null){ |
|
|
page = 1; |
|
|
page = 1; |
|
|
|
|
|
}else if (page > 20){ |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
Date now = new Date(); |
|
|
Date now = new Date(); |
|
|
Date lastMonth = DateUtil.getAfterSomedate(now,-1, Calendar.MONTH); |
|
|
Date lastMonth = DateUtil.getAfterSomedate(now,-1, Calendar.MONTH); |
|
@ -69,12 +73,15 @@ public class JiaJinService { |
|
|
LzResponseLog responseLog = new LzResponseLog(); |
|
|
LzResponseLog responseLog = new LzResponseLog(); |
|
|
responseLog.setJson(json); |
|
|
responseLog.setJson(json); |
|
|
responseLogService.save(responseLog); |
|
|
responseLogService.save(responseLog); |
|
|
GetListEntity.OtherEntity otherEntity = new GetListEntity.OtherEntity(); |
|
|
|
|
|
//GetListEntity.OtherEntity otherEntity = getListEntity.getOther();
|
|
|
|
|
|
//解析请求json,并保存订单到数据库
|
|
|
//解析请求json,并保存订单到数据库
|
|
|
for (GetListEntity.OrderEntity orderEntity : getListEntity.getList()) { |
|
|
for (GetListEntity.OrderEntity orderEntity : getListEntity.getList()) { |
|
|
|
|
|
GetListEntity.OtherEntity otherEntity = orderEntity.getOther(); |
|
|
LzOrder lzOrder = new LzOrder(); |
|
|
LzOrder lzOrder = new LzOrder(); |
|
|
lzOrder.setOrderNo(orderEntity.getOrderNo()); |
|
|
lzOrder.setOrderNo(orderEntity.getOrderNo()); |
|
|
|
|
|
if(lzOrderService.existOrder(orderEntity.getOrderNo())>0L){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
lzOrder.setCustomCode(otherEntity.getCustomCode()); |
|
|
lzOrder.setOrderAmount(orderEntity.getOrderAmount()); |
|
|
lzOrder.setOrderAmount(orderEntity.getOrderAmount()); |
|
|
lzOrder.setShippingFare(orderEntity.getShippingFare()); |
|
|
lzOrder.setShippingFare(orderEntity.getShippingFare()); |
|
|
lzOrder.setConsignee(orderEntity.getConsignee()); |
|
|
lzOrder.setConsignee(orderEntity.getConsignee()); |
|
@ -99,6 +106,9 @@ public class JiaJinService { |
|
|
}else { |
|
|
}else { |
|
|
lzOrder.setCheckStatus(2); |
|
|
lzOrder.setCheckStatus(2); |
|
|
} |
|
|
} |
|
|
|
|
|
if(StringUtil.isEmpty(lzOrder.getCustomCode())){ |
|
|
|
|
|
lzOrder.setCheckStatus(2); |
|
|
|
|
|
} |
|
|
try { |
|
|
try { |
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
LocalDateTime orderCreateTime = LocalDateTime.parse(orderEntity.getCreateTime(),df); |
|
|
LocalDateTime orderCreateTime = LocalDateTime.parse(orderEntity.getCreateTime(),df); |
|
@ -118,7 +128,7 @@ public class JiaJinService { |
|
|
System.out.println(); |
|
|
System.out.println(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//@Scheduled(cron = "")
|
|
|
@Scheduled(cron = "0 */5 * * * ?") |
|
|
public void task(){ |
|
|
public void task(){ |
|
|
//获取未同步订单,调用U8服务
|
|
|
//获取未同步订单,调用U8服务
|
|
|
LambdaQueryWrapper<LzOrder> lqw = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<LzOrder> lqw = new LambdaQueryWrapper<>(); |
|
@ -140,7 +150,7 @@ public class JiaJinService { |
|
|
//拿子项税率
|
|
|
//拿子项税率
|
|
|
rate = new BigDecimal(item.getTaxRate()); |
|
|
rate = new BigDecimal(item.getTaxRate()); |
|
|
orderDetail.setInvCode(item.getInvCode()); |
|
|
orderDetail.setInvCode(item.getInvCode()); |
|
|
orderDetail.setTaxRate(new BigDecimal(item.getTaxRate())); |
|
|
orderDetail.setTaxRate(new BigDecimal(item.getTaxRate()).multiply(new BigDecimal(item.getQty()))); |
|
|
orderDetail.setQuantity(new Long(item.getQty())); |
|
|
orderDetail.setQuantity(new Long(item.getQty())); |
|
|
orderDetail.setHasRatePrice(new BigDecimal(item.getSalePrice())); |
|
|
orderDetail.setHasRatePrice(new BigDecimal(item.getSalePrice())); |
|
|
orderDetail.setHasRateSumPrice(new BigDecimal(item.getSaleAmount())); |
|
|
orderDetail.setHasRateSumPrice(new BigDecimal(item.getSaleAmount())); |
|
@ -150,19 +160,19 @@ public class JiaJinService { |
|
|
} |
|
|
} |
|
|
U8API4SaleOrder api4SaleOrder = U8API4SaleOrder.builder() |
|
|
U8API4SaleOrder api4SaleOrder = U8API4SaleOrder.builder() |
|
|
.addType(0) |
|
|
.addType(0) |
|
|
.code("S"+order.getOrderNo()) |
|
|
.code("T"+order.getOrderNo()) |
|
|
.orderDate(DateUtil.localDateTimeToDate(order.getOrderCreateTime())) |
|
|
.orderDate(DateUtil.localDateTimeToDate(order.getOrderCreateTime())) |
|
|
.bizType("普通销售") |
|
|
.bizType("普通销售") |
|
|
.saleType(order.getSaleType()) |
|
|
.saleType(order.getSaleType()) |
|
|
.cusCode(order.getCustomCode()) |
|
|
.cusCode(order.getCustomCode()) |
|
|
.currencyType("人民币") |
|
|
.currencyType("人民币") |
|
|
.depCode(order.getSaleDept()) |
|
|
.depCode(order.getSaleDept()) |
|
|
.createUser(order.getSaleMan()) |
|
|
.createUser(order.getSaleMan())//TODO DEMO
|
|
|
.preShipmentsDate(now) |
|
|
.preShipmentsDate(now) |
|
|
.preFinishedDate(now) |
|
|
.preFinishedDate(now) |
|
|
.taxRate(rate) |
|
|
.taxRate(rate) |
|
|
.remark(order.getRemark()) |
|
|
.remark(order.getRemark()) |
|
|
.remarkFoot(order.getConsignee()+" "+order.getConsigneeMobile()+" "+order.getProvinces()) |
|
|
.remarkFoot(order.getConsignee()+"/"+order.getConsigneeMobile()+"/"+order.getProvinces()+"/"+order.getDetailedAddress()) |
|
|
.details(details) |
|
|
.details(details) |
|
|
.build(); |
|
|
.build(); |
|
|
String jsonBody = JsonUtil.objectToJson(Arrays.asList(api4SaleOrder)); |
|
|
String jsonBody = JsonUtil.objectToJson(Arrays.asList(api4SaleOrder)); |
|
@ -177,6 +187,7 @@ public class JiaJinService { |
|
|
requestBo.setSettingRetryTimes(2); |
|
|
requestBo.setSettingRetryTimes(2); |
|
|
requestBo.setCallbackState("1"); |
|
|
requestBo.setCallbackState("1"); |
|
|
requestBo.setCallbackHost( host + "/lzOrder/callback"); |
|
|
requestBo.setCallbackHost( host + "/lzOrder/callback"); |
|
|
|
|
|
order.setStatus(1); |
|
|
//TODO 方便测试 order.setStatus(1);
|
|
|
//TODO 方便测试 order.setStatus(1);
|
|
|
order.setUpdateTime(LocalDateTime.now()); |
|
|
order.setUpdateTime(LocalDateTime.now()); |
|
|
HttpUtil.post(mainServerProperties.getU8url(),JsonUtil.objectToJson(requestBo)); |
|
|
HttpUtil.post(mainServerProperties.getU8url(),JsonUtil.objectToJson(requestBo)); |
|
@ -188,13 +199,14 @@ public class JiaJinService { |
|
|
* U8中台回调接口 |
|
|
* U8中台回调接口 |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public R<?> callback(@RequestBody U8CallbackVo requestVo){ |
|
|
public R<?> callback(U8CallbackVo requestVo){ |
|
|
String orderNo = requestVo.getId(); |
|
|
String orderNo = requestVo.getApiPk(); |
|
|
LambdaQueryWrapper<LzOrder> lqw = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<LzOrder> lqw = new LambdaQueryWrapper<>(); |
|
|
lqw.eq(LzOrder::getOrderNo,orderNo); |
|
|
lqw.eq(LzOrder::getOrderNo,orderNo); |
|
|
LzOrder lzOrder = lzOrderService.getOne(lqw,false); |
|
|
LzOrder lzOrder = lzOrderService.getOne(lqw,false); |
|
|
//解析返回结果
|
|
|
//解析返回结果
|
|
|
lzOrder.setStatus(2); |
|
|
lzOrder.setStatus(2); |
|
|
|
|
|
lzOrder.setCallbackStatus(1); |
|
|
String response = requestVo.getRespContext(); |
|
|
String response = requestVo.getRespContext(); |
|
|
JSONObject jsonObject = JSONObject.parseObject(response); |
|
|
JSONObject jsonObject = JSONObject.parseObject(response); |
|
|
if(jsonObject.getString("code").equals("200")){ |
|
|
if(jsonObject.getString("code").equals("200")){ |
|
|