----快递鸟电子面单发货修改

This commit is contained in:
yc13649764453
2023-05-29 14:21:28 +08:00
parent c73aa17392
commit 763e24b4e0

View File

@@ -1,20 +1,22 @@
package com.peanut.modules.book.service.impl;
import com.alibaba.druid.mock.MockConnection;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.peanut.common.Interface.KdApiEOrder;
import com.peanut.common.utils.HttpClientUtils;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.book.dao.*;
import com.peanut.common.utils.R;
import com.peanut.modules.book.dao.BuyOrderDao;
import com.peanut.modules.book.dao.BuyOrderDetailDao;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*;
import com.peanut.modules.book.vo.ProductVo;
@@ -26,6 +28,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.xml.soap.Text;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -47,20 +53,35 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
private FMSOrderDetailService fmsOrderDetailService;
protected Logger logger = LoggerFactory.getLogger(BuyOrderServiceImpl.class);
private MockConnection connection;
@Override
public PageUtils queryPage(Map<String, Object> params) {
public PageUtils queryPage(Map<String, Object> params) throws Exception{
IPage<BuyOrderEntity> page = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String startTime = null;
String endTime = null;
if(params.containsKey("startTime")){
startTime = sdf.format(Long.parseLong(params.get("startTime").toString()));
endTime = sdf.format(Long.parseLong(params.get("endTime").toString()));
}
if (ObjectUtils.isEmpty(params.get("orderStatus"))) {
page = this.page(
new Query<BuyOrderEntity>().getPage(params),
new QueryWrapper<BuyOrderEntity>()
new ExcludeEmptyQueryWrapper<BuyOrderEntity>().eq("user_phone",params.get("key")).
or().like("order_sn",params.get("key")).or().like("shipping_user",params.get("key"))
.apply(startTime != null ,"date_format (create_time,'%Y-%m-%d') >= date_format ({0},'%Y-%m-%d')",startTime)
.apply(endTime != null,"date_format (create_time,'%Y-%m-%d') <= date_format ({0},'%Y-%m-%d')", endTime).orderByDesc("create_time")
);
} else {
page = this.page(
new Query<BuyOrderEntity>().getPage(params),
new QueryWrapper<BuyOrderEntity>().eq("order_status", params.get("orderStatus"))
new ExcludeEmptyQueryWrapper<BuyOrderEntity>().eq("order_status", params.get("orderStatus")).eq("user_phone",params.get("key"))
.or().like("order_sn",params.get("key")).or().like("shipping_user",params.get("key"))
.apply(startTime != null ,"date_format (create_time,'%Y-%m-%d') >= date_format ({0},'%Y-%m-%d')",startTime)
.apply(endTime != null,"date_format (create_time,'%Y-%m-%d') <= date_format ({0},'%Y-%m-%d')", endTime).orderByDesc("create_time")
);
}
@@ -69,11 +90,14 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
for (BuyOrderEntity record : records) {
Integer userId = record.getUserId();
MyUserEntity myUserEntity = myUserService.getById(userId);
if(!ObjectUtils.isEmpty(myUserEntity)){
record.setUserName(myUserEntity.getName());
record.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>()
.eq("order_id", record.getOrderId())));
}
}
return new PageUtils(page);
}
@@ -271,6 +295,23 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
param.put("ShipperCode", shipperCode);
param.put("LogisticCode", expNo);
try {
//todo expNo不等于1则执行第一个代码块否则执行第二个代码块。 5.5
// if (!expNo.equals(1)) {
// 列出所有包裹
// }else {
// 直接展示
// }
String A =expNo;
if (!expNo.equals(1)){
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
JSONObject jsonObject = JSONObject.parseObject(rntStr);
if ("true".equals(jsonObject.getString("Success"))) {
return jsonObject;
}
}else {
return null;
}
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
JSONObject jsonObject = JSONObject.parseObject(rntStr);
if ("true".equals(jsonObject.getString("Success"))) {
@@ -414,9 +455,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
* @return
*/
@Override
public void blendSendFMS(Integer[] orderDetailIds,String shipperCode,String shipperName) {
logger.info("##########################开始混合发货!时间:"+ new Date());
public void blendSendFMS(Integer[] orderDetailIds, String shipperCode, String shipperName) {
logger.info("##########################开始混合发货!:"+ new Date());
try {
// 生成订单号
String timeId = IdWorker.getTimeId();
@@ -432,7 +472,6 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
fms.setOrderCode(timeId+buy.getUserId());
fms.setOrderId(buy.getOrderId());
fmsList.add(fms);
washDetailList.add(buy);
}
}
@@ -473,19 +512,25 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
JSONObject jsonObj = JSONObject.parseObject(json.getString("Order"));
String orderCode = jsonObj.getString("OrderCode");
List<FMSOrderDetailEntity> fmsOrderDetailList = this.fmsOrderDetailService.list(new QueryWrapper<FMSOrderDetailEntity>().eq("order_code", orderCode));
String SortingCode = jsonObj.getString("SortingCode");
System.out.println("############################################开始进入判断4444444jsonArr"+ jsonArr+"json="+json+"orderCode="+orderCode);
String SortingCode = jsonObj.getString("LogisticCode");
String ShipperCode=jsonObj.getString("ShipperCode");
String PrintTemplate=json.getString("PrintTemplate");
for(FMSOrderDetailEntity fms : fmsOrderDetailList){
BuyOrderEntity o = this.getById(fms.getOrderId());
BuyOrderDetailEntity detail = this.buyOrderDetailService.getById(fms.getDetailId());
detail.setOrderStatus("1");
detail.setFmsHtml(json.getString("PrintTemplate"));
detail.setFmsHtml(PrintTemplate);
detail.setCreatTime(new Date());
detail.setShippingSn(SortingCode.substring(0,SortingCode.indexOf("/")));
detail.setShipperCode(jsonObj.getString("ShipperCode"));
detail.setShippingSn(SortingCode);
detail.setShipperCode(ShipperCode);
detail.setShipperName(shipperName);
detail.setIsPrint("0");
this.buyOrderDetailService.updateById(detail);
List<BuyOrderDetailEntity> list = this.buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", fms.getOrderId()).eq("order_status", "0"));
// this.buyOrderDetailService.updateById(detail);
this.buyOrderDetailService.saveOrUpdate(detail);
List<BuyOrderDetailEntity> list = this.buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", fms.getOrderId())
.eq("order_status", "0"));
// .eq("order_status", "0")
if(list.size() == 0){
o.setIsSend("1");
o.setOrderStatus("2");
@@ -493,6 +538,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
o.setIsSend("1");
}
this.updateById(o);
buyOrderDao.updateById(o);
}
}
@@ -531,6 +577,9 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
Object next =ite.next();
// 根据Id查询信息后 计算出各个种类商品的总重量
ShopProductEntity product = this.shopProductService.getById(Integer.valueOf(next.toString()));
if("0".equals(product.getIsFreeMail())){
product.setWeight(0f);
}
if("01".equals(product.getGoodsType())){
if(ObjectUtils.isEmpty(pictureMap)){
pictureMap.put("picture",(float)product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
@@ -585,6 +634,30 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
}
public static String getRandom(int len) {
Random r = new Random();
StringBuilder rs = new StringBuilder();
for (int i = 0; i < len; i++) {
rs.append(r.nextInt(10));
}
return rs.toString();
}
@Override
public R randomOrderCode( BuyOrderEntity buyOrder) {
SimpleDateFormat dmDate = new SimpleDateFormat("yyyyMMddHHmmss");
String randata = getRandom(6);
Date date = new Date();
String dateran = dmDate.format(date);
String Xsode = "XS" + dateran + randata;
if (Xsode.length() < 24) {
Xsode = Xsode + 0;
}
return R.ok(Xsode) ;
}
/**
* 计算仪器,预售快递费用
*
@@ -688,8 +761,10 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
amount = 20;
continuousWeight = 20;
}
if(weight <= 1000){
// 如果重量等于0 说明是包邮
if(weight == 0){
return 0;
} else if(weight <= 1000){
return amount;
}else {
return (int) (amount + (continuousWeight * Math.floor(weight / 1000)));