From 70ad26394c57cf4eeecf5cc1f134b2aef938107a Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 12 Aug 2024 13:59:35 +0800 Subject: [PATCH] / --- .../com/bweb/controller/TestController.java | 35 +++++++++++++++++-- .../com/order/controller/OrderController.java | 1 - .../business/BsOrderDownloadController.java | 11 ++++++ .../business/BsOrderGoodsController.java | 19 ++++++---- .../java/com/hfkj/entity/BsOrderGoods.java | 2 +- .../service/goods/BsOrderGoodsService.java | 1 + .../goods/impl/BsOrderGoodsServiceImpl.java | 29 +++++++++++---- .../service/order/OrderCreateService.java | 2 +- .../service/order/OrderPaySuccessService.java | 10 +++--- .../order/impl/BsOrderChildServiceImpl.java | 15 ++++++++ .../order/OrderLogisticsStatusEnum.java | 32 +++++++++++++++++ 11 files changed, 133 insertions(+), 24 deletions(-) create mode 100644 order/src/main/java/com/order/controller/business/BsOrderDownloadController.java create mode 100644 service/src/main/java/com/hfkj/sysenum/order/OrderLogisticsStatusEnum.java diff --git a/bweb/src/main/java/com/bweb/controller/TestController.java b/bweb/src/main/java/com/bweb/controller/TestController.java index 10b66ee..bcfc9cb 100644 --- a/bweb/src/main/java/com/bweb/controller/TestController.java +++ b/bweb/src/main/java/com/bweb/controller/TestController.java @@ -5,15 +5,15 @@ import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.OrderUtil; import com.hfkj.common.utils.ResponseMsgUtil; -import com.hfkj.entity.CouponDiscountGoodsRel; -import com.hfkj.entity.GoodsMsg; -import com.hfkj.entity.GoodsSpecs; +import com.hfkj.entity.*; import com.hfkj.model.ResponseData; import com.hfkj.service.discount.CouponDiscountService; +import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.GoodsMsgService; import com.hfkj.service.goods.GoodsSpecsService; import com.hfkj.service.hlt.HltCanteenService; import com.hfkj.service.hlt.HuiLianTongUnionCardService; +import com.hfkj.service.order.BsOrderChildService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -44,6 +44,11 @@ public class TestController { @Resource private CouponDiscountService couponDiscountService; + @Resource + private BsOrderChildService orderChildService; + @Resource + private BsOrderGoodsService orderGoodsService; + @RequestMapping(value="/canteenConsume",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "食堂消费") @@ -100,4 +105,28 @@ public class TestController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value="/orderGoodsUpdate",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "商品更新") + public ResponseData orderGoodsUpdate() { + try { + + + List orderGoodsList = orderGoodsService.getList(); + + for (BsOrderGoods goods : orderGoodsList) { + BsOrderChild child = orderChildService.getDetail(goods.getChildOrderNo()); + goods.setStatus(child.getStatus()); + goods.setUpdateTime(new Date()); + orderGoodsService.update(goods); + } + + return ResponseMsgUtil.success("成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/order/src/main/java/com/order/controller/OrderController.java b/order/src/main/java/com/order/controller/OrderController.java index e1b1536..752e024 100644 --- a/order/src/main/java/com/order/controller/OrderController.java +++ b/order/src/main/java/com/order/controller/OrderController.java @@ -87,7 +87,6 @@ public class OrderController { body.setUserName(userSession.getUser().getName()); body.setUserPhone(userSession.getUser().getPhone()); - return ResponseMsgUtil.success(orderService.create(body)); } catch (Exception e) { diff --git a/order/src/main/java/com/order/controller/business/BsOrderDownloadController.java b/order/src/main/java/com/order/controller/business/BsOrderDownloadController.java new file mode 100644 index 0000000..dec5a23 --- /dev/null +++ b/order/src/main/java/com/order/controller/business/BsOrderDownloadController.java @@ -0,0 +1,11 @@ +package com.order.controller.business; + +import io.swagger.annotations.Api; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping(value="/orderDownload") +@Api(value="订单下载管理") +public class BsOrderDownloadController { +} diff --git a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java index 87dcc58..9fbb1d9 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java @@ -19,6 +19,7 @@ import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.order.BsOrderService; import com.hfkj.sysenum.SecUserObjectTypeEnum; import com.hfkj.sysenum.order.OrderGoodsStatusEnum; +import com.hfkj.sysenum.order.OrderLogisticsStatusEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -62,6 +63,7 @@ public class BsOrderGoodsController { @RequestParam(value = "userPhone" , required = false) String userPhone, @RequestParam(value = "goodsSpecsName" , required = false) String goodsSpecsName, @RequestParam(value = "goodsName" , required = false) String goodsName, + @RequestParam(value = "logisticsStatus" , required = false) String logisticsStatus, @RequestParam(value = "payType" , required = false) Integer payType, @RequestParam(value = "status" , required = false) Integer status, @RequestParam(value = "createTimeS" , required = false) Long createTimeS, @@ -85,12 +87,12 @@ public class BsOrderGoodsController { map.put("orderNo", orderNo); map.put("childOrderNo", childOrderNo); map.put("userPhone", userPhone); + map.put("logisticsStatus", logisticsStatus); map.put("goodsSpecsName", goodsSpecsName); map.put("goodsName", goodsName); map.put("payType", payType); map.put("createTimeS", createTimeS); map.put("createTimeE", createTimeE); - map.put("status", status); PageHelper.startPage(pageNum, pageSize); @@ -126,14 +128,12 @@ public class BsOrderGoodsController { goodsOrder.setLogisticsNo(logisticsNo); goodsOrder.setUpdateTime(new Date()); - if (goodsOrder.getStatus() == OrderGoodsStatusEnum.status1.getCode()) { - goodsOrder.setStatus(OrderGoodsStatusEnum.status2.getCode()); - } // 删除缓存 orderService.cacheDelete(goodsOrder.getOrderNo()); bsOrderGoodsService.cacheDelete(goodsOrder.getLogisticsNo()); bsOrderGoodsService.update(goodsOrder); + getLogisticsMsg(goodsOrder.getId()); return ResponseMsgUtil.success("更新成功!"); } catch (Exception e) { @@ -156,10 +156,15 @@ public class BsOrderGoodsController { GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(orderGoods.getLogisticsNo()); - orderGoods.setLogisticsStatus(logistics.getLogisticsStatus()); - orderGoods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); - bsOrderGoodsService.update(orderGoods); + if (logistics.getLogisticsStatus() != null) { + orderGoods.setLogisticsStatus(logistics.getLogisticsStatus()); + orderGoods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); + } else { + orderGoods.setLogisticsStatus(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getCode()); + orderGoods.setLogisticsStatusDesc(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getName()); + } + bsOrderGoodsService.update(orderGoods); map.put("logistics", logistics); JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); map.put("logisticsTraceDetails", object); diff --git a/service/src/main/java/com/hfkj/entity/BsOrderGoods.java b/service/src/main/java/com/hfkj/entity/BsOrderGoods.java index 25871e9..2517b9a 100644 --- a/service/src/main/java/com/hfkj/entity/BsOrderGoods.java +++ b/service/src/main/java/com/hfkj/entity/BsOrderGoods.java @@ -165,7 +165,7 @@ public class BsOrderGoods implements Serializable { private Integer payType; /** - * 1:待发货 2:已发货 3:配送中 4:已送达 5:已取消 6:退货中 7:已退货 8:待支付 0:删除 + * bs_order_child订单表同步 */ private Integer status; diff --git a/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java b/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java index 0e600a0..daaf481 100644 --- a/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java +++ b/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java @@ -87,6 +87,7 @@ public interface BsOrderGoodsService { * @return java.util.List */ List getList(Map map); + List getList(); /** * @Author Sum1Dream diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java index d565c88..d54861f 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java @@ -15,15 +15,13 @@ import com.hfkj.entity.GoodsLogisticsExample; import com.hfkj.model.order.OrderModel; import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.order.BsOrderService; +import com.hfkj.sysenum.order.OrderChildStatusEnum; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; @Service("bsOrderGoodsService") public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { @@ -31,7 +29,7 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { // 缓存前缀KEY public final static String CACHE_KEY = "LOGISTICS:"; // 订单缓存时间 7天 - public final static Integer CACHE_TIME = 60*60*6; + public final static Integer CACHE_TIME = 60*30; @Resource private BsOrderGoodsMapper bsOrderGoodsMapper; @@ -84,7 +82,7 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { @Override public BsOrderGoods findGoodsOrderByChild(String orderChildNo) { BsOrderGoodsExample example = new BsOrderGoodsExample(); - example.createCriteria().andStatusNotEqualTo(0).andChildOrderNoEqualTo(orderChildNo); + example.createCriteria().andChildOrderNoEqualTo(orderChildNo); List list = bsOrderGoodsMapper.selectByExample(example); @@ -125,6 +123,14 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { if (StringUtils.isNotBlank(MapUtils.getString(map, "userPhone"))) { criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone")); } + if (StringUtils.isNotBlank(MapUtils.getString(map, "logisticsStatus"))) { + if (MapUtils.getString(map , "logisticsStatus").equals("待发货")) { + criteria.andLogisticsStatusIsNull(); + } else { + criteria.andLogisticsStatusEqualTo(MapUtils.getString(map, "logisticsStatus")); + } + + } if (MapUtils.getLong(map, "goodsType") != null) { criteria.andGoodsTypeIdEqualTo(MapUtils.getLong(map, "goodsType")); } @@ -160,6 +166,13 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { return bsOrderGoodsMapper.selectByExample(example); } + @Override + public List getList() { + BsOrderGoodsExample example = new BsOrderGoodsExample(); + + return bsOrderGoodsMapper.selectByExample(example); + } + @Override public GoodsLogistics findGoodsLogistics(Long orderGoodsId) { GoodsLogisticsExample example = new GoodsLogisticsExample(); @@ -270,9 +283,11 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态,不支持确认收货!"); } - orderGoods.setStatus(9); + // 子订单完成 orderService.childOrderComplete(orderGoods.getChildOrderNo()); + orderGoods.setStatus(OrderChildStatusEnum.status3.getCode()); + orderGoods.setUpdateTime(new Date()); update(orderGoods); // 删除缓存 orderService.cacheDelete(orderGoods.getOrderNo()); diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index 90e3703..db8104c 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -239,7 +239,7 @@ public class OrderCreateService { orderGoods.setGoodsSpecsName(goodsSpecs.getName()); orderGoods.setGoodsSpecsOriginalPrice(goodsSpecs.getOriginalPrice()); orderGoods.setGoodsCount(orderChild.getProductCount()); - orderGoods.setStatus(OrderGoodsStatusEnum.status8.getCode()); + orderGoods.setStatus(orderChild.getStatus()); orderGoods.setDeliveryAddress(address.getAddress()); orderGoods.setDeliveryAddressId(address.getId()); orderGoods.setCreateTime(new Date()); diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index 0260149..e565a71 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -224,14 +224,16 @@ public class OrderPaySuccessService { goodsOrder.setPaySerialNo(order.getPaySerialNo()); goodsOrder.setPayTime(order.getPayTime()); goodsOrder.setUpdateTime(new Date()); - goodsOrder.setStatus(1); - + goodsOrder.setStatus(childOrder.getStatus()); + bsOrderGoodsService.update(goodsOrder); } catch (Exception e) { - goodsOrder.setExceptionStatus(true); + if (goodsOrder == null) { + goodsOrder = new BsOrderGoods(); + } goodsOrder.setExceptionMsg(e.getMessage()); + bsOrderGoodsService.update(goodsOrder); } - bsOrderGoodsService.update(goodsOrder); } public void cinema(OrderModel order,BsOrderChild childOrder) { diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java index 84ab6bd..d0acfb1 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java @@ -12,8 +12,10 @@ import com.hfkj.service.BsProductConfigService; import com.hfkj.service.goods.*; import com.hfkj.service.goods.impl.BsOrderStarbucksServiceImpl; import com.hfkj.service.order.BsOrderChildService; +import com.hfkj.service.order.BsOrderService; import com.hfkj.sysenum.order.OrderChildProductTypeEnum; import com.hfkj.sysenum.order.OrderChildStatusEnum; +import com.hfkj.sysenum.order.OrderLogisticsStatusEnum; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -48,6 +50,9 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { @Resource private BsProductConfigService bsProductConfigService; + @Resource + private BsOrderService orderService; + @Override public void editData(BsOrderChild data) { data.setUpdateTime(new Date()); @@ -113,6 +118,16 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { object.put("orderGoodsId", orderGoods.getId()); childModel.setBusiness(object); + if (orderGoods.getLogisticsStatus() != null && orderGoods.getLogisticsStatus().equals(OrderLogisticsStatusEnum.statusSIGN.getCode())) { + // 子订单完成 + orderService.childOrderComplete(orderGoods.getChildOrderNo()); + orderGoods.setStatus(OrderChildStatusEnum.status3.getCode()); + orderGoods.setUpdateTime(new Date()); + orderGoodsService.update(orderGoods); + // 删除缓存 + orderService.cacheDelete(orderGoods.getOrderNo()); + } + } } else if (childModel.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { childModel.setBusiness(goodsVpdService.queryDetailBySpecsId(childModel.getProductSpecId())); diff --git a/service/src/main/java/com/hfkj/sysenum/order/OrderLogisticsStatusEnum.java b/service/src/main/java/com/hfkj/sysenum/order/OrderLogisticsStatusEnum.java new file mode 100644 index 0000000..0b66dde --- /dev/null +++ b/service/src/main/java/com/hfkj/sysenum/order/OrderLogisticsStatusEnum.java @@ -0,0 +1,32 @@ +package com.hfkj.sysenum.order; + +import lombok.Getter; + +@Getter +public enum OrderLogisticsStatusEnum { + + statusDELIVERING("派件中" , "DELIVERING"), + + statusTRANSPORT("运输中", "TRANSPORT"), + + statusAGENT_SIGN("已代签收", "AGENT_SIGN"), + + statusSIGN("已签收", "SIGN"), + + statusACCEPT("已揽收", "ACCEPT"), + + statusFAILED("包裹异常", "FAILED"), + + statusWAIT_ACCEPT("待揽收", "WAIT_ACCEPT"), + ; + + private final String code; + + private final String name; + + + OrderLogisticsStatusEnum(String name, String code) { + this.code = code; + this.name = name; + } +}