handle out of time
This commit is contained in:
@@ -16,5 +16,7 @@ import java.util.Map;
|
||||
public interface PayWechatOrderService extends IService<PayWechatOrderEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
void add(String orderSn,String prepayId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import cn.com.marsoft.tool.ToolObject;
|
||||
import com.alibaba.druid.mock.MockConnection;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -30,9 +29,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
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;
|
||||
@@ -61,32 +57,32 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
private MockConnection connection;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) throws Exception{
|
||||
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")){
|
||||
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 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")
|
||||
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 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")
|
||||
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")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,7 +91,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
for (BuyOrderEntity record : records) {
|
||||
Integer userId = record.getUserId();
|
||||
MyUserEntity myUserEntity = myUserService.getById(userId);
|
||||
if(!ObjectUtils.isEmpty(myUserEntity)){
|
||||
if (!ObjectUtils.isEmpty(myUserEntity)) {
|
||||
record.setUserName(myUserEntity.getName());
|
||||
record.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", record.getOrderId())));
|
||||
@@ -128,9 +124,10 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
List<BuyOrderEntity> records = page.getRecords();
|
||||
for (BuyOrderEntity buyOrderEntity : records) {
|
||||
Integer orderId = buyOrderEntity.getOrderId();
|
||||
buyOrderEntity.setTimestamp(buyOrderEntity.getCreateTime().getTime()/1000);
|
||||
List<BuyOrderDetailEntity> entities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", orderId));
|
||||
if (entities!=null) {
|
||||
if (entities != null) {
|
||||
for (BuyOrderDetailEntity entity : entities) {
|
||||
Integer productId = entity.getProductId();
|
||||
ShopProductEntity shopPro = shopProductService.getById(productId);
|
||||
@@ -141,7 +138,6 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,24 +181,24 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
@Transactional
|
||||
public void sendFMS(Integer[] orderIds, String shipperCode, String shipperName) {
|
||||
|
||||
logger.info("##########################开始批量发货!时间:"+ new Date());
|
||||
logger.info("##########################开始批量发货!时间:" + new Date());
|
||||
try {
|
||||
String timeId = IdWorker.getTimeId();
|
||||
List<FMSOrderEntity> fmsOrderList = new ArrayList<>();
|
||||
// 查询订单详情
|
||||
List<BuyOrderEntity> orderList = this.buyOrderDao.queryListByOrderIds(orderIds);
|
||||
Map<Integer,Object> userMap = new HashMap<>();
|
||||
Map<Integer, Object> userMap = new HashMap<>();
|
||||
// 清洗出有哪些用户
|
||||
for(BuyOrderEntity order : orderList){
|
||||
order.setOrderCode(timeId+order.getUserId());
|
||||
userMap.put(order.getUserId(),order);
|
||||
for (BuyOrderEntity order : orderList) {
|
||||
order.setOrderCode(timeId + order.getUserId());
|
||||
userMap.put(order.getUserId(), order);
|
||||
}
|
||||
this.saveOrUpdateBatch(orderList);
|
||||
List<Integer> keys = userMap.keySet().stream().collect(Collectors.toList());
|
||||
List<BuyOrderDetailEntity> buyOrderDetailList = this.buyOrderDetailDao.queryListByOrderIds(orderIds);
|
||||
for(int k : keys){
|
||||
for (int k : keys) {
|
||||
Object o = userMap.get(k);
|
||||
BuyOrderEntity order = new ObjectMapper().convertValue(o,BuyOrderEntity.class);
|
||||
BuyOrderEntity order = new ObjectMapper().convertValue(o, BuyOrderEntity.class);
|
||||
|
||||
FMSOrderEntity fmsOrder = new FMSOrderEntity();
|
||||
// 生成一个新的订单号保存到订单表中
|
||||
@@ -216,8 +212,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
fmsOrder.setReceiverAddress(order.getAddress());
|
||||
fmsOrder.setRemark(order.getRemark());
|
||||
List<FMSCommodity> fmsCommoditylist = new ArrayList<>();
|
||||
for (BuyOrderDetailEntity orderDetail : buyOrderDetailList){
|
||||
if(orderDetail.getUserId().equals(k)){
|
||||
for (BuyOrderDetailEntity orderDetail : buyOrderDetailList) {
|
||||
if (orderDetail.getUserId().equals(k)) {
|
||||
FMSCommodity fmsCommodity = new FMSCommodity();
|
||||
fmsCommodity.setGoodsName(orderDetail.getProductName());
|
||||
fmsCommodity.setGoodsQuantity(orderDetail.getQuantity());
|
||||
@@ -232,7 +228,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
fmsOrderList.add(fmsOrder);
|
||||
}
|
||||
|
||||
// 消息队列批量保存
|
||||
// 消息队列批量保存
|
||||
// fmsOrderDao.batchInsert(fmsOrderList);
|
||||
// fmsCommodityDao.batchInsert(fmsCommoditylist);
|
||||
|
||||
@@ -242,24 +238,24 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
if ("true".equals(json.getString("Success"))) {
|
||||
JSONObject jsonObj = JSONObject.parseObject(json.getString("Order"));
|
||||
// 业务数据
|
||||
Map<Integer,Object> objMap = new HashMap<>();
|
||||
Map<Integer, Object> objMap = new HashMap<>();
|
||||
List<BuyOrderEntity> list = this.list(new QueryWrapper<BuyOrderEntity>().eq("order_code", jsonObj.getString("OrderCode")));
|
||||
for(BuyOrderEntity order : list){
|
||||
for (BuyOrderEntity order : list) {
|
||||
// 改变订单状态为已发货
|
||||
order.setOrderStatus("2");
|
||||
// 改变订单信息为已有商品发货
|
||||
order.setIsSend("1");
|
||||
this.updateById(order);
|
||||
objMap.put(order.getOrderId(),order);
|
||||
objMap.put(order.getOrderId(), order);
|
||||
}
|
||||
List<Integer> orderIdList = objMap.keySet().stream().collect(Collectors.toList());
|
||||
Integer [] oIds = orderIdList.toArray(new Integer[orderIdList.size()]);
|
||||
Integer[] oIds = orderIdList.toArray(new Integer[orderIdList.size()]);
|
||||
List<BuyOrderDetailEntity> buyOrderEntityList = this.buyOrderDetailDao.queryListByOrderIds(oIds);
|
||||
String SortingCode = jsonObj.getString("SortingCode");
|
||||
for(BuyOrderDetailEntity buy :buyOrderEntityList){
|
||||
String SortingCode = jsonObj.getString("SortingCode");
|
||||
for (BuyOrderDetailEntity buy : buyOrderEntityList) {
|
||||
buy.setFmsHtml(json.getString("PrintTemplate"));
|
||||
buy.setCreatTime(new Date());
|
||||
buy.setShippingSn(SortingCode.substring(0,SortingCode.indexOf("/")));
|
||||
buy.setShippingSn(SortingCode.substring(0, SortingCode.indexOf("/")));
|
||||
buy.setShipperCode(jsonObj.getString("ShipperCode"));
|
||||
buy.setShipperName(shipperName);
|
||||
buy.setIsPrint("0");
|
||||
@@ -268,7 +264,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
|
||||
}
|
||||
}
|
||||
logger.info("##########################结束批量发货!时间:"+ new Date());
|
||||
logger.info("##########################结束批量发货!时间:" + new Date());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -318,20 +314,20 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
// }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 {
|
||||
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(rntStr);
|
||||
if ("true".equals(jsonObject.getString("Success"))) {
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
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 {
|
||||
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(rntStr);
|
||||
if ("true".equals(jsonObject.getString("Success"))) {
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(rntStr);
|
||||
@@ -374,22 +370,22 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
}
|
||||
|
||||
Map<Integer,Object> map = new HashMap<>();
|
||||
Map<Integer, Object> map = new HashMap<>();
|
||||
// 使用清洗后的List获得其中有多少个用户
|
||||
for(BuyOrderEntity o : washOrderList){
|
||||
for (BuyOrderEntity o : washOrderList) {
|
||||
map.put(o.getUserId(), o);
|
||||
}
|
||||
//获取map的所有key转为list
|
||||
List<Integer> keys = map.keySet().stream().collect(Collectors.toList());
|
||||
List<UserOrderVo> userOrderVoList = new ArrayList<>();
|
||||
for(int key : keys){
|
||||
for (int key : keys) {
|
||||
UserOrderVo userOrderVo = new UserOrderVo();
|
||||
List<BuyOrderEntity> orderEntityList = new ArrayList<>();
|
||||
for(BuyOrderEntity o : buyOrderList){
|
||||
if(o.getUserId().equals(key)){
|
||||
for (BuyOrderEntity o : buyOrderList) {
|
||||
if (o.getUserId().equals(key)) {
|
||||
userOrderVo.setTel(o.getUserPhone());
|
||||
userOrderVo.setUserName(o.getShippingUser());
|
||||
userOrderVo.setAddress(o.getProvince()+o.getCity()+o.getDistrict()+o.getAddress());
|
||||
userOrderVo.setAddress(o.getProvince() + o.getCity() + o.getDistrict() + o.getAddress());
|
||||
orderEntityList.add(o);
|
||||
userOrderVo.setOrderList(orderEntityList);
|
||||
}
|
||||
@@ -398,11 +394,11 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
// 判断订单是否有可合并的如果没有移除掉该值
|
||||
for (UserOrderVo u : userOrderVoList) {
|
||||
if(u.getOrderList().size() <= 1){
|
||||
if (u.getOrderList().size() <= 1) {
|
||||
userOrderVoList.remove(u);
|
||||
u.getOrderList().remove(0);
|
||||
}
|
||||
if(u.getOrderList().size() == 0){
|
||||
if (u.getOrderList().size() == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -417,7 +413,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Page checkOrder(Map<String, Object> params){
|
||||
public Page checkOrder(Map<String, Object> params) {
|
||||
|
||||
// 查询所有订单信息
|
||||
List<BuyOrderEntity> orderList = new ArrayList<>();
|
||||
@@ -435,22 +431,22 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
orderList.add(order);
|
||||
}
|
||||
// 获取有订单的所有用户
|
||||
Map<Integer,Object> map = new HashMap<>();
|
||||
Map<Integer, Object> map = new HashMap<>();
|
||||
|
||||
for(BuyOrderEntity order : orderList){
|
||||
for (BuyOrderEntity order : orderList) {
|
||||
map.put(order.getUserId(), order);
|
||||
}
|
||||
//获取map的所有key转为list
|
||||
List<Integer> keys = map.keySet().stream().collect(Collectors.toList());
|
||||
|
||||
for(int key : keys){
|
||||
for (int key : keys) {
|
||||
UserOrderVo userOrderVo = new UserOrderVo();
|
||||
List<BuyOrderEntity> orderEntityList = new ArrayList<>();
|
||||
for(BuyOrderEntity o : buyOrderList.getRecords()){
|
||||
if(o.getUserId().equals(key)){
|
||||
for (BuyOrderEntity o : buyOrderList.getRecords()) {
|
||||
if (o.getUserId().equals(key)) {
|
||||
userOrderVo.setUserName(o.getShippingUser());
|
||||
userOrderVo.setTel(o.getUserPhone());
|
||||
userOrderVo.setAddress(o.getProvince()+o.getCity()+o.getDistrict()+o.getAddress());
|
||||
userOrderVo.setAddress(o.getProvince() + o.getCity() + o.getDistrict() + o.getAddress());
|
||||
orderEntityList.add(o);
|
||||
userOrderVo.setOrderList(orderEntityList);
|
||||
}
|
||||
@@ -458,8 +454,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
userOrderVoList.add(userOrderVo);
|
||||
}
|
||||
|
||||
for(UserOrderVo userOrder : userOrderVoList){
|
||||
if(userOrder.getOrderList().size() > 1){
|
||||
for (UserOrderVo userOrder : userOrderVoList) {
|
||||
if (userOrder.getOrderList().size() > 1) {
|
||||
rntList.add(userOrder);
|
||||
|
||||
}
|
||||
@@ -477,7 +473,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
*/
|
||||
@Override
|
||||
public void blendSendFMS(Integer[] orderDetailIds, String shipperCode, String shipperName) {
|
||||
logger.info("##########################开始混合发货!:"+ new Date());
|
||||
logger.info("##########################开始混合发货!:" + new Date());
|
||||
try {
|
||||
// 生成订单号
|
||||
String timeId = IdWorker.getTimeId();
|
||||
@@ -485,12 +481,12 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
List<BuyOrderDetailEntity> washDetailList = new ArrayList<>();
|
||||
List<BuyOrderDetailEntity> detailList = this.buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>());
|
||||
|
||||
for(BuyOrderDetailEntity buy : detailList){
|
||||
for(int orderDetailId : orderDetailIds){
|
||||
if(buy.getAllOrderId() == orderDetailId){
|
||||
for (BuyOrderDetailEntity buy : detailList) {
|
||||
for (int orderDetailId : orderDetailIds) {
|
||||
if (buy.getAllOrderId() == orderDetailId) {
|
||||
FMSOrderDetailEntity fms = new FMSOrderDetailEntity();
|
||||
fms.setDetailId(buy.getAllOrderId());
|
||||
fms.setOrderCode(timeId+buy.getUserId());
|
||||
fms.setOrderCode(timeId + buy.getUserId());
|
||||
fms.setOrderId(buy.getOrderId());
|
||||
fmsList.add(fms);
|
||||
washDetailList.add(buy);
|
||||
@@ -505,9 +501,9 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
// 初始化快递商品信息
|
||||
List<FMSCommodity> fmsCommoditylist = new ArrayList<>();
|
||||
|
||||
if(washDetailList != null && washDetailList.size() > 0){
|
||||
if (washDetailList != null && washDetailList.size() > 0) {
|
||||
BuyOrderEntity order = this.getById(washDetailList.get(0).getOrderId());
|
||||
fmsOrder.setOrderCode(timeId+order.getUserId());
|
||||
fmsOrder.setOrderCode(timeId + order.getUserId());
|
||||
fmsOrder.setShipperCode(shipperCode);
|
||||
fmsOrder.setReceiverName(order.getShippingUser());
|
||||
fmsOrder.setReceiverMobile(order.getUserPhone());
|
||||
@@ -515,7 +511,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
fmsOrder.setReceiverCityName(order.getCity());
|
||||
fmsOrder.setReceiverExpAreaName(order.getDistrict());
|
||||
fmsOrder.setReceiverAddress(order.getAddress());
|
||||
for(BuyOrderDetailEntity buy : washDetailList){
|
||||
for (BuyOrderDetailEntity buy : washDetailList) {
|
||||
FMSCommodity fmsCommodity = new FMSCommodity();
|
||||
fmsCommodity.setGoodsName(buy.getProductName());
|
||||
fmsCommodity.setGoodsQuantity(buy.getQuantity());
|
||||
@@ -533,17 +529,17 @@ 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));
|
||||
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){
|
||||
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");
|
||||
if (PrintTemplate.equals(buyOrderDetailService.getById(detail))){
|
||||
return;
|
||||
}else {
|
||||
if (PrintTemplate.equals(buyOrderDetailService.getById(detail))) {
|
||||
return;
|
||||
} else {
|
||||
detail.setFmsHtml(PrintTemplate);
|
||||
}
|
||||
|
||||
@@ -558,16 +554,16 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
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){
|
||||
if (list.size() == 0) {
|
||||
o.setIsSend("1");
|
||||
o.setOrderStatus("2");
|
||||
}else{
|
||||
} else {
|
||||
o.setIsSend("1");
|
||||
}
|
||||
this.updateById(o);
|
||||
buyOrderDao.updateById(o);
|
||||
|
||||
//todo 混合发货原本属于订单A的的信息无缘无故跑到订单B。或者订单C里面去
|
||||
//todo 混合发货原本属于订单A的的信息无缘无故跑到订单B。或者订单C里面去
|
||||
|
||||
|
||||
// todo 打印面单快递单号重复 主要问题在html表格里面有 可能是数据太多导致混乱把数据清除再做一次混合发货 查看错误
|
||||
@@ -578,15 +574,15 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
|
||||
}
|
||||
}
|
||||
logger.info("##########################结束混合发货!时间:"+ new Date());
|
||||
}catch (Exception e) {
|
||||
logger.info("##########################结束混合发货!时间:" + new Date());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品类型计算快递费
|
||||
* 根据商品类型计算快递费
|
||||
*
|
||||
* @param param
|
||||
* @param productMap
|
||||
@@ -594,82 +590,81 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getProductGoodsType(Map<String, Object> param,Map<String, Object> productMap){
|
||||
public int getProductGoodsType(Map<String, Object> param, Map<String, Object> productMap) {
|
||||
// param : key商品Id,value商品数量
|
||||
// 定义不同种类的数组
|
||||
Map<String,Object> pictureMap = new HashMap<>();
|
||||
Map<String,Object> bookMap = new HashMap<>();
|
||||
Map<String, Object> pictureMap = new HashMap<>();
|
||||
Map<String, Object> bookMap = new HashMap<>();
|
||||
List<ProductVo> advanceBookingList = new ArrayList<>();
|
||||
List<ProductVo> deviceList = new ArrayList<>();
|
||||
|
||||
int transPrice = 0;
|
||||
|
||||
if(!ObjectUtils.isEmpty(productMap)){
|
||||
if (!ObjectUtils.isEmpty(productMap)) {
|
||||
Set set = productMap.keySet();
|
||||
Iterator ite = set.iterator();
|
||||
while (ite.hasNext()) {
|
||||
int i = 1;
|
||||
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()));
|
||||
}else{
|
||||
pictureMap.put("picture",(float)pictureMap.get("picture") + (float)product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
}
|
||||
}
|
||||
if("02".equals(product.getGoodsType())){
|
||||
if(ObjectUtils.isEmpty(bookMap)){
|
||||
bookMap.put("book",(float)product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
}else{
|
||||
bookMap.put("book",(float)bookMap.get("book") + (float)product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
}
|
||||
}
|
||||
if("03".equals(product.getGoodsType())){
|
||||
ProductVo p = new ProductVo();
|
||||
p.setKdCode(param.get("kdCode").toString());
|
||||
p.setArea(param.get("area").toString());
|
||||
p.setNum(Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
p.setWeight(product.getWeight().intValue());
|
||||
deviceList.add(p);
|
||||
}
|
||||
if("04".equals(product.getGoodsType())){
|
||||
ProductVo p = new ProductVo();
|
||||
p.setKdCode(param.get("kdCode").toString());
|
||||
p.setArea(param.get("area").toString());
|
||||
p.setNum(Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
p.setWeight(product.getWeight().intValue());
|
||||
advanceBookingList.add(p);
|
||||
}
|
||||
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()));
|
||||
} else {
|
||||
pictureMap.put("picture", (float) pictureMap.get("picture") + (float) product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
}
|
||||
}
|
||||
if ("02".equals(product.getGoodsType())) {
|
||||
if (ObjectUtils.isEmpty(bookMap)) {
|
||||
bookMap.put("book", (float) product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
} else {
|
||||
bookMap.put("book", (float) bookMap.get("book") + (float) product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
}
|
||||
}
|
||||
if ("03".equals(product.getGoodsType())) {
|
||||
ProductVo p = new ProductVo();
|
||||
p.setKdCode(param.get("kdCode").toString());
|
||||
p.setArea(param.get("area").toString());
|
||||
p.setNum(Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
p.setWeight(product.getWeight().intValue());
|
||||
deviceList.add(p);
|
||||
}
|
||||
if ("04".equals(product.getGoodsType())) {
|
||||
ProductVo p = new ProductVo();
|
||||
p.setKdCode(param.get("kdCode").toString());
|
||||
p.setArea(param.get("area").toString());
|
||||
p.setNum(Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
p.setWeight(product.getWeight().intValue());
|
||||
advanceBookingList.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(pictureMap)){
|
||||
pictureMap.put("kdCode",param.get("kdCode"));
|
||||
pictureMap.put("area",param.get("area"));
|
||||
pictureMap.put("weight",pictureMap.get("picture"));
|
||||
if (!ObjectUtils.isEmpty(pictureMap)) {
|
||||
pictureMap.put("kdCode", param.get("kdCode"));
|
||||
pictureMap.put("area", param.get("area"));
|
||||
pictureMap.put("weight", pictureMap.get("picture"));
|
||||
transPrice += this.getTransPrice(pictureMap);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(bookMap)){
|
||||
bookMap.put("kdCode",param.get("kdCode"));
|
||||
bookMap.put("area",param.get("area"));
|
||||
bookMap.put("weight",bookMap.get("book"));
|
||||
if (!ObjectUtils.isEmpty(bookMap)) {
|
||||
bookMap.put("kdCode", param.get("kdCode"));
|
||||
bookMap.put("area", param.get("area"));
|
||||
bookMap.put("weight", bookMap.get("book"));
|
||||
transPrice += this.getTransPrice(bookMap);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(deviceList)){
|
||||
if (!ObjectUtils.isEmpty(deviceList)) {
|
||||
transPrice += this.getTransPrice(deviceList);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(advanceBookingList)){
|
||||
if (!ObjectUtils.isEmpty(advanceBookingList)) {
|
||||
transPrice += this.getTransPrice(advanceBookingList);
|
||||
}
|
||||
return transPrice;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getRandom(int len) {
|
||||
Random r = new Random();
|
||||
StringBuilder rs = new StringBuilder();
|
||||
@@ -680,7 +675,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public R randomOrderCode( BuyOrderEntity buyOrder) {
|
||||
public R randomOrderCode(BuyOrderEntity buyOrder) {
|
||||
SimpleDateFormat dmDate = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String randata = getRandom(6);
|
||||
Date date = new Date();
|
||||
@@ -689,16 +684,17 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
if (Xsode.length() < 24) {
|
||||
Xsode = Xsode + 0;
|
||||
}
|
||||
return R.ok(Xsode) ;
|
||||
return R.ok(Xsode);
|
||||
}
|
||||
/*
|
||||
打印时查重
|
||||
*/
|
||||
|
||||
/*
|
||||
打印时查重
|
||||
*/
|
||||
@Override
|
||||
public PageUtils querySheet(Map<String, Object> params) {
|
||||
IPage<BuyOrderEntity> page = this.page(
|
||||
new Query<BuyOrderEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderEntity>().eq("is_print","0")
|
||||
new QueryWrapper<BuyOrderEntity>().eq("is_print", "0")
|
||||
.groupBy("shipping_sn")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
@@ -738,14 +734,13 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 计算仪器,预售快递费用
|
||||
*
|
||||
* @param productList
|
||||
* @return
|
||||
*/
|
||||
public int getTransPrice(List<ProductVo> productList){
|
||||
public int getTransPrice(List<ProductVo> productList) {
|
||||
|
||||
// 首重
|
||||
int amount = 0;
|
||||
@@ -753,43 +748,43 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
int continuousWeight = 0;
|
||||
// 费用
|
||||
int fare = 0;
|
||||
for(ProductVo p : productList){
|
||||
String prov = p.getArea().substring(0,p.getArea().indexOf("_"));
|
||||
for (ProductVo p : productList) {
|
||||
String prov = p.getArea().substring(0, p.getArea().indexOf("_"));
|
||||
float weight = p.getNum() * p.getWeight();
|
||||
// 韵达计费规则
|
||||
if("YD".equals(p.getKdCode())){
|
||||
if ("YD".equals(p.getKdCode())) {
|
||||
// 如果ID等于71 说明是天津发天津
|
||||
if("71".equals(prov)){
|
||||
if ("71".equals(prov)) {
|
||||
amount = 6;
|
||||
continuousWeight = 3;
|
||||
}
|
||||
// 首重十元 续重四元
|
||||
String tenStr [] = {"70","73","75","76","77","79","81","82","83","84","85","86","87","88","91","92","96","80","78"};
|
||||
String tenStr[] = {"70", "73", "75", "76", "77", "79", "81", "82", "83", "84", "85", "86", "87", "88", "91", "92", "96", "80", "78"};
|
||||
boolean tenBoolean = Arrays.asList(tenStr).contains(prov);
|
||||
if(tenBoolean){
|
||||
if (tenBoolean) {
|
||||
amount = 10;
|
||||
continuousWeight = 4;
|
||||
}
|
||||
// 首重十二元
|
||||
String twelveStr[] = {"74","89","90","93","94","97","98","99"};
|
||||
String twelveStr[] = {"74", "89", "90", "93", "94", "97", "98", "99"};
|
||||
boolean twelveBoolean = Arrays.asList(twelveStr).contains(prov);
|
||||
if(twelveBoolean){
|
||||
if (twelveBoolean) {
|
||||
amount = 12;
|
||||
continuousWeight = 5;
|
||||
// 甘肃 97,青海 98,内蒙古 74 ,海南90 续重 6元
|
||||
if(prov.equals("97") || prov.equals("98")|| prov.equals("74") || prov.equals("90")){
|
||||
if (prov.equals("97") || prov.equals("98") || prov.equals("74") || prov.equals("90")) {
|
||||
continuousWeight = 6;
|
||||
}
|
||||
}
|
||||
// 首重二十元,续重二十元
|
||||
if("100".equals(prov)){
|
||||
if ("100".equals(prov)) {
|
||||
amount = 20;
|
||||
continuousWeight = 20;
|
||||
}
|
||||
|
||||
if(weight <= 1000){
|
||||
if (weight <= 1000) {
|
||||
fare += amount;
|
||||
}else {
|
||||
} else {
|
||||
fare += (int) (amount + (continuousWeight * Math.floor(weight / 1000)));
|
||||
}
|
||||
}
|
||||
@@ -801,6 +796,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
|
||||
/**
|
||||
* 计算快递费用
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
public int getTransPrice(Map<String, Object> param) {
|
||||
@@ -808,46 +804,46 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
int fare = 0;
|
||||
String KDCode = param.get("kdCode").toString();
|
||||
String area = param.get("area").toString();
|
||||
String prov = area.substring(0,area.indexOf("_"));
|
||||
float weight = (float)param.get("weight");
|
||||
String prov = area.substring(0, area.indexOf("_"));
|
||||
float weight = (float) param.get("weight");
|
||||
// 韵达计费规则
|
||||
if("YD".equals(KDCode)){
|
||||
if ("YD".equals(KDCode)) {
|
||||
// 如果ID等于71 说明是天津发天津
|
||||
int amount = 0;
|
||||
int continuousWeight = 0;
|
||||
if("71".equals(prov)){
|
||||
amount = 6;
|
||||
continuousWeight = 3;
|
||||
if ("71".equals(prov)) {
|
||||
amount = 6;
|
||||
continuousWeight = 3;
|
||||
}
|
||||
// 首重十元 续重四元
|
||||
String tenStr [] = {"70","73","75","76","77","79","81","82","83","84","85","86","87","88","91","92","96","80","78"};
|
||||
String tenStr[] = {"70", "73", "75", "76", "77", "79", "81", "82", "83", "84", "85", "86", "87", "88", "91", "92", "96", "80", "78"};
|
||||
boolean tenBoolean = Arrays.asList(tenStr).contains(prov);
|
||||
if(tenBoolean){
|
||||
if (tenBoolean) {
|
||||
amount = 10;
|
||||
continuousWeight = 4;
|
||||
}
|
||||
// 首重十二元
|
||||
String twelveStr[] = {"74","89","90","93","94","97","98","99"};
|
||||
String twelveStr[] = {"74", "89", "90", "93", "94", "97", "98", "99"};
|
||||
boolean twelveBoolean = Arrays.asList(twelveStr).contains(prov);
|
||||
if(twelveBoolean){
|
||||
if (twelveBoolean) {
|
||||
amount = 12;
|
||||
continuousWeight = 5;
|
||||
// 甘肃 97,青海 98,内蒙古 74 ,海南90 续重 6元
|
||||
if(prov.equals("97") || prov.equals("98")|| prov.equals("74") || prov.equals("90")){
|
||||
continuousWeight = 6;
|
||||
if (prov.equals("97") || prov.equals("98") || prov.equals("74") || prov.equals("90")) {
|
||||
continuousWeight = 6;
|
||||
}
|
||||
}
|
||||
// 首重二十元,续重二十元
|
||||
if("100".equals(prov)){
|
||||
if ("100".equals(prov)) {
|
||||
amount = 20;
|
||||
continuousWeight = 20;
|
||||
}
|
||||
// 如果重量等于0 说明是包邮
|
||||
if(weight == 0){
|
||||
if (weight == 0) {
|
||||
return 0;
|
||||
} else if(weight <= 1000){
|
||||
} else if (weight <= 1000) {
|
||||
return amount;
|
||||
}else {
|
||||
} else {
|
||||
return (int) (amount + (continuousWeight * Math.floor(weight / 1000)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,23 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.PayWechatOrderDao;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import com.peanut.modules.book.entity.PayWechatOrderEntity;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.book.service.PayWechatOrderService;
|
||||
import com.peanut.modules.book.service.PayZfbOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("payWechatOrderService")
|
||||
public class PayWechatOrderServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOrderEntity> implements PayWechatOrderService {
|
||||
|
||||
@Autowired
|
||||
BuyOrderService buyOrderService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayWechatOrderEntity> page = this.page(
|
||||
@@ -27,4 +33,21 @@ public class PayWechatOrderServiceImpl extends ServiceImpl<PayWechatOrderDao, Pa
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(String orderSn, String prepayId) {
|
||||
QueryWrapper<BuyOrderEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("order_sn", orderSn);
|
||||
BuyOrderEntity buyOrder = buyOrderService.getOne(wrapper);
|
||||
PayWechatOrderEntity entity = new PayWechatOrderEntity();
|
||||
entity.setCustomerId(buyOrder.getUserId());
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setOrderSn(buyOrder.getOrderSn());
|
||||
entity.setPrepayId(prepayId);
|
||||
entity.setTotalAmount(buyOrder.getRealMoney());
|
||||
entity.setSystemLog("预支付完成");
|
||||
entity.setPayType(buyOrder.getOrderType());
|
||||
entity.setOrderId(buyOrder.getOrderSn());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user