master
胡锐 6 months ago
commit d5804f7f09
  1. 2
      bweb/src/main/java/com/bweb/controller/goods/GoodsController.java
  2. 77
      order/src/main/java/com/order/controller/business/BsOrderGoodsController.java
  3. 18
      service/src/main/java/com/hfkj/common/utils/OrderUtil.java
  4. 42
      service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java
  5. 115
      service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java
  6. 5
      service/src/main/java/com/hfkj/service/order/OrderCreateService.java

@ -411,8 +411,6 @@ public class GoodsController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态不可操作!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态不可操作!");
} }
goodsMsgService.update(goodsMsg); goodsMsgService.update(goodsMsg);
return ResponseMsgUtil.success("成功"); return ResponseMsgUtil.success("成功");

@ -1,28 +1,36 @@
package com.order.controller.business; package com.order.controller.business;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsOrderGoods;
import com.hfkj.entity.GoodsLogistics;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.SecUserSessionObject;
import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.BsOrderGoodsService;
import com.hfkj.sysenum.SecUserObjectTypeEnum; import com.hfkj.sysenum.SecUserObjectTypeEnum;
import com.hfkj.sysenum.order.OrderGoodsStatusEnum;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
@Controller @Controller
@RequestMapping(value="/orderGoods") @RequestMapping(value="/orderGoods")
@ -51,6 +59,8 @@ public class BsOrderGoodsController {
@RequestParam(value = "goodsName" , required = false) String goodsName, @RequestParam(value = "goodsName" , required = false) String goodsName,
@RequestParam(value = "payType" , required = false) Integer payType, @RequestParam(value = "payType" , required = false) Integer payType,
@RequestParam(value = "status" , required = false) Integer status, @RequestParam(value = "status" , required = false) Integer status,
@RequestParam(value = "createTimeS" , required = false) Long createTimeS,
@RequestParam(value = "createTimeE" , required = false) Long createTimeE,
@RequestParam(value = "pageNum" , required = true) Integer pageNum, @RequestParam(value = "pageNum" , required = true) Integer pageNum,
@RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) { @RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) {
try { try {
@ -73,6 +83,9 @@ public class BsOrderGoodsController {
map.put("goodsSpecsName", goodsSpecsName); map.put("goodsSpecsName", goodsSpecsName);
map.put("goodsName", goodsName); map.put("goodsName", goodsName);
map.put("payType", payType); map.put("payType", payType);
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
map.put("status", status); map.put("status", status);
PageHelper.startPage(pageNum, pageSize); PageHelper.startPage(pageNum, pageSize);
@ -84,4 +97,60 @@ public class BsOrderGoodsController {
} }
} }
@RequestMapping(value="/updateLogisticsNo",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "更新物流订单号")
public ResponseData updateLogisticsNo(@RequestBody BsOrderGoods body
) {
try {
if (body == null
|| body.getId() == null
|| StringUtils.isBlank(body.getLogisticsNo())
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
BsOrderGoods goodsOrder = bsOrderGoodsService.queryDetail(body.getId());
if (goodsOrder == null) {
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "信息错误!");
}
goodsOrder.setLogisticsNo(body.getLogisticsNo());
goodsOrder.setUpdateTime(new Date());
if (goodsOrder.getStatus() == OrderGoodsStatusEnum.status1.getCode()) {
goodsOrder.setStatus(OrderGoodsStatusEnum.status2.getCode());
}
bsOrderGoodsService.update(goodsOrder);
return ResponseMsgUtil.success("更新成功!");
} catch (Exception e) {
log.error("OrderExtController -> getGasOrderDetail() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getLogisticsMsg",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询物流")
public ResponseData getLogisticsMsg(@RequestParam(value = "id" , required = false) Long id) {
try {
Map<String , Object> map = new HashMap<>();
GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(id);
map.put("logistics", logistics);
JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails());
map.put("logisticsTraceDetails", object);
return ResponseMsgUtil.success(map);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -1,5 +1,7 @@
package com.hfkj.common.utils; package com.hfkj.common.utils;
import com.alibaba.fastjson.JSONObject;
import java.util.*; import java.util.*;
/** /**
@ -64,4 +66,20 @@ public class OrderUtil {
return DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + randomNum; return DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + randomNum;
} }
/**
* 查询物流单号
* @return
* @throws Exception
*/
public static JSONObject getLogisticsMsg(String num) {
String appcode = "f9ace4c915054ca697a76fb9a4e1e8c0";
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "APPCODE " + appcode);
Map<String, String> querys = new HashMap<>();
querys.put("number", num);
return HttpsUtils.doGet("https://express3.market.alicloudapi.com/express3" , querys ,headers);
}
} }

@ -1,7 +1,9 @@
package com.hfkj.service.goods; package com.hfkj.service.goods;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.entity.BsOrderGoods; import com.hfkj.entity.BsOrderGoods;
import com.hfkj.entity.GoodsBrand; import com.hfkj.entity.GoodsBrand;
import com.hfkj.entity.GoodsLogistics;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -76,4 +78,44 @@ public interface BsOrderGoodsService {
* @return java.util.List<com.hfkj.entity.GoodsBrand> * @return java.util.List<com.hfkj.entity.GoodsBrand>
*/ */
List<BsOrderGoods> getList(Map<String , Object> map); List<BsOrderGoods> getList(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Name findGoodsLogisticsById
* @Description // 根据id查询物流信息
* @Date 16:19 2023/4/11
* @Param [id]
* @Return com.hai.entity.GoodsLogistics
*/
GoodsLogistics findGoodsLogistics(Long orderGoodsId);
/**
* @Author Sum1Dream
* @Name findGoodsLogisticsByNum
* @Description // 根据快递单号查询物流信息
* @Date 11:41 2023/4/14
* @Param [num]
* @Return com.hai.entity.GoodsLogistics
*/
GoodsLogistics findGoodsLogisticsByNum(String num);
/**
* @Author Sum1Dream
* @Name editLogistics
* @Description // 编辑物流信息
* @Date 11:33 2023/4/14
* @Param [goodsLogistics]
* @Return void
*/
GoodsLogistics editLogistics(JSONObject object);
/**
* @Author Sum1Dream
* @Name getLogisticsMsg
* @Description // 查询物流信息
* @Date 16:19 2023/4/20
* @Param [num]
* @Return com.alibaba.fastjson.JSONObject
*/
Object getLogisticsMsg(Long orderGoodsId);
} }

@ -1,8 +1,17 @@
package com.hfkj.service.goods.impl; package com.hfkj.service.goods.impl;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.OrderUtil;
import com.hfkj.common.utils.RedisUtil;
import com.hfkj.dao.BsOrderGoodsMapper; import com.hfkj.dao.BsOrderGoodsMapper;
import com.hfkj.dao.GoodsLogisticsMapper;
import com.hfkj.entity.BsOrderGoods; import com.hfkj.entity.BsOrderGoods;
import com.hfkj.entity.BsOrderGoodsExample; import com.hfkj.entity.BsOrderGoodsExample;
import com.hfkj.entity.GoodsLogistics;
import com.hfkj.entity.GoodsLogisticsExample;
import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.BsOrderGoodsService;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -12,12 +21,18 @@ import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
@Service("bsOrderGoodsService") @Service("bsOrderGoodsService")
public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
@Resource @Resource
private BsOrderGoodsMapper bsOrderGoodsMapper; private BsOrderGoodsMapper bsOrderGoodsMapper;
@Resource
private GoodsLogisticsMapper goodsLogisticsMapper;
@Resource
private RedisUtil redisUtil;
@Override @Override
public void create(BsOrderGoods orderGoods) { public void create(BsOrderGoods orderGoods) {
@ -105,6 +120,12 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
if (MapUtils.getInteger(map, "payType") != null) { if (MapUtils.getInteger(map, "payType") != null) {
criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType")); criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType"));
} }
if (MapUtils.getLong(map, "createTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS")));
}
if (MapUtils.getLong(map, "createTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
}
if (MapUtils.getInteger(map, "status") != null) { if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
} else { } else {
@ -113,4 +134,98 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
return bsOrderGoodsMapper.selectByExample(example); return bsOrderGoodsMapper.selectByExample(example);
} }
@Override
public GoodsLogistics findGoodsLogistics(Long orderGoodsId) {
GoodsLogisticsExample example = new GoodsLogisticsExample();
GoodsLogisticsExample.Criteria criteria = example.createCriteria();
criteria.andOrderIdEqualTo(orderGoodsId).andStatusEqualTo(1);
List<GoodsLogistics> logistics = goodsLogisticsMapper.selectByExample(example);
if (logistics.size() > 0) {
return logistics.get(0);
}
return null;
}
@Override
public GoodsLogistics findGoodsLogisticsByNum(String num) {
GoodsLogisticsExample example = new GoodsLogisticsExample();
GoodsLogisticsExample.Criteria criteria = example.createCriteria();
criteria.andNumberEqualTo(num).andStatusEqualTo(1);
List<GoodsLogistics> logistics = goodsLogisticsMapper.selectByExample(example);
if (logistics.size() > 0) {
return logistics.get(0);
}
return null;
}
@Override
public GoodsLogistics editLogistics(JSONObject jsonObject) {
JSONObject info = (JSONObject) jsonObject.getJSONArray("info").get(0);
GoodsLogistics logistics = findGoodsLogisticsByNum(info.getString("mailNo"));
if (logistics == null) {
logistics = new GoodsLogistics();
}
logistics.setTaskNo(jsonObject.getString("orderNo"));
logistics.setTheLastTime(info.getDate("theLastTime"));
logistics.setTheLastMessage(info.getString("theLastMessage"));
logistics.setTakeTime(info.getString("takeTime"));
logistics.setNumber(info.getString("mailNo"));
logistics.setLogisticsStatus(info.getString("logisticsStatus"));
logistics.setExpressCompanyName(info.getString("logisticsCompanyName"));
logistics.setLogisticsStatusDesc(info.getString("logisticsStatusDesc"));
logistics.setLogisticsTraceDetails(info.getString("logisticsTraceDetailList"));
logistics.setStatus(1);
if ( logistics.getId() == null || !Objects.equals(logistics.getOrderId(), jsonObject.getLong("orderId"))) {
logistics.setOrderId(jsonObject.getLong("orderId"));
logistics.setCreateTime(new Date());
goodsLogisticsMapper.insert(logistics);
} else {
logistics.setOrderId(jsonObject.getLong("orderId"));
goodsLogisticsMapper.updateByPrimaryKeySelective(logistics);
}
return logistics;
}
@Override
public Object getLogisticsMsg(Long orderGoodsId) {
Object data = redisUtil.get("logisticsMsg" + orderGoodsId);
if (data == null) {
BsOrderGoods orderGoods = queryDetail(orderGoodsId);
if (orderGoods == null || orderGoods.getLogisticsNo() == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!");
}
JSONObject jsonObjects = OrderUtil.getLogisticsMsg(orderGoods.getLogisticsNo());
if (jsonObjects == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!");
}
redisUtil.set("logisticsMsgOl" + orderGoodsId , jsonObjects ,21600);
if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) {
jsonObjects.getJSONObject("data").put("orderId" , orderGoodsId);
GoodsLogistics logistics = editLogistics((JSONObject) jsonObjects.get("data"));
redisUtil.set("logisticsMsg" + orderGoodsId , logistics ,21600);
return logistics;
}
return jsonObjects;
} else {
return data;
}
}
} }

@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.Map; import java.util.Map;
/** /**
@ -177,7 +178,7 @@ public class OrderCreateService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的收货地址"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的收货地址");
} }
// 创建卡券订单 // 创建实物订单
BsOrderGoods orderGoods = new BsOrderGoods(); BsOrderGoods orderGoods = new BsOrderGoods();
orderGoods.setOrderNo(orderChild.getOrderNo()); orderGoods.setOrderNo(orderChild.getOrderNo());
orderGoods.setChildOrderNo(orderChild.getChildOrderNo()); orderGoods.setChildOrderNo(orderChild.getChildOrderNo());
@ -198,6 +199,8 @@ public class OrderCreateService {
orderGoods.setStatus(OrderGoodsStatusEnum.status8.getCode()); orderGoods.setStatus(OrderGoodsStatusEnum.status8.getCode());
orderGoods.setDeliveryAddress(address.getAddress()); orderGoods.setDeliveryAddress(address.getAddress());
orderGoods.setDeliveryAddressId(address.getId()); orderGoods.setDeliveryAddressId(address.getId());
orderGoods.setCreateTime(new Date());
orderGoods.setUpdateTime(new Date());
bsOrderGoodsService.create(orderGoods); bsOrderGoodsService.create(orderGoods);

Loading…
Cancel
Save