master
袁野 6 months ago
parent 1c6d1f3cc6
commit cd824e15be
  1. 49
      cweb/src/main/java/com/cweb/controller/discount/DiscountController.java
  2. 7
      order/src/main/java/com/order/controller/business/BsOrderGoodsController.java
  3. 7
      service/src/main/java/com/hfkj/model/order/OrderModel.java
  4. 1
      service/src/main/java/com/hfkj/service/discount/CouponDiscountUserRelService.java
  5. 14
      service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountServiceImpl.java
  6. 19
      service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountUserRelServiceImpl.java
  7. 11
      service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java
  8. 10
      service/src/main/java/com/hfkj/service/order/OrderCreateService.java
  9. 18
      service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java
  10. 10
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java

@ -9,10 +9,7 @@ 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.CouponDiscount; import com.hfkj.entity.*;
import com.hfkj.entity.CouponDiscountGoodsRel;
import com.hfkj.entity.GoodsMsg;
import com.hfkj.entity.GoodsSpecs;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.SecUserSessionObject;
import com.hfkj.model.UserSessionObject; import com.hfkj.model.UserSessionObject;
@ -47,6 +44,8 @@ public class DiscountController {
@Resource @Resource
private CouponDiscountUserRelService discountUserRelService; private CouponDiscountUserRelService discountUserRelService;
@Resource
private CouponDiscountService couponDiscountService;
@RequestMapping(value = "/getListUserDiscount", method = RequestMethod.GET) @RequestMapping(value = "/getListUserDiscount", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -70,6 +69,48 @@ public class DiscountController {
} }
} }
@RequestMapping(value = "/getGoodsDiscount", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取商品可用优惠券")
public ResponseData getGoodsDiscount(@RequestParam(value = "specsIds", required = true) String specsIds) {
try {
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
Map<String, Object> mapSpecs = new HashMap<>();
mapSpecs.put("specsIds", specsIds);
// 查询规格可用优惠券
List<CouponDiscountGoodsRel> couponDiscountGoodsRel = couponDiscountService.getListGoodsRel(mapSpecs);
if (couponDiscountGoodsRel == null) {
return ResponseMsgUtil.success(null);
}
List<CouponDiscountUserRel> list = new ArrayList<>();
for(CouponDiscountGoodsRel rel : couponDiscountGoodsRel) {
Map<String, Object> map = new HashMap<>();
map.put("userId", userSession.getUser().getId());
map.put("status", 1);
map.put("discountId", rel.getDiscountId());
CouponDiscountUserRel couponDiscountUserRel = discountUserRelService.getRel(map);
list.add(couponDiscountUserRel);
}
return ResponseMsgUtil.success(list);
} catch (Exception e) {
log.error("GoodsDetailController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -15,6 +15,7 @@ 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.service.order.BsOrderService;
import com.hfkj.sysenum.SecUserObjectTypeEnum; import com.hfkj.sysenum.SecUserObjectTypeEnum;
import com.hfkj.sysenum.order.OrderGoodsStatusEnum; import com.hfkj.sysenum.order.OrderGoodsStatusEnum;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -45,6 +46,9 @@ public class BsOrderGoodsController {
@Resource @Resource
private UserCenter userCenter; private UserCenter userCenter;
@Resource
private BsOrderService orderService;
@RequestMapping(value="/getListGoods",method = RequestMethod.GET) @RequestMapping(value="/getListGoods",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -122,7 +126,8 @@ public class BsOrderGoodsController {
if (goodsOrder.getStatus() == OrderGoodsStatusEnum.status1.getCode()) { if (goodsOrder.getStatus() == OrderGoodsStatusEnum.status1.getCode()) {
goodsOrder.setStatus(OrderGoodsStatusEnum.status2.getCode()); goodsOrder.setStatus(OrderGoodsStatusEnum.status2.getCode());
} }
// 删除缓存
orderService.cacheDelete(goodsOrder.getOrderNo());
bsOrderGoodsService.update(goodsOrder); bsOrderGoodsService.update(goodsOrder);
return ResponseMsgUtil.success("更新成功!"); return ResponseMsgUtil.success("更新成功!");

@ -3,6 +3,7 @@ package com.hfkj.model.order;
import com.hfkj.entity.BsOrder; import com.hfkj.entity.BsOrder;
import com.hfkj.entity.BsOrderChild; import com.hfkj.entity.BsOrderChild;
import com.hfkj.entity.BsOrderDeduction; import com.hfkj.entity.BsOrderDeduction;
import com.hfkj.entity.GoodsUserAddress;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@ -21,6 +22,12 @@ public class OrderModel extends BsOrder {
*/ */
private BsOrderDeduction deduction; private BsOrderDeduction deduction;
/**
* 业务信息
* todo 1.0阶段暂用后续会删除
*/
private Object business;
/** /**
* 子订单列表 * 子订单列表
*/ */

@ -40,4 +40,5 @@ public interface CouponDiscountUserRelService {
* @return * @return
*/ */
CouponDiscountUserRel getRel(Long id); CouponDiscountUserRel getRel(Long id);
CouponDiscountUserRel getRel(Map<String , Object> map);
} }

@ -9,10 +9,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service("couponDiscountService") @Service("couponDiscountService")
public class CouponDiscountServiceImpl implements CouponDiscountService { public class CouponDiscountServiceImpl implements CouponDiscountService {
@ -85,6 +82,15 @@ public class CouponDiscountServiceImpl implements CouponDiscountService {
criteria.andDiscountIdEqualTo(MapUtils.getLong(map, "discountId")); criteria.andDiscountIdEqualTo(MapUtils.getLong(map, "discountId"));
} }
if (StringUtils.isNotBlank(MapUtils.getString(map, "specsIds"))) {
String[] specsIds = MapUtils.getString(map, "specsIds").split(",");
List<Long> list = new ArrayList<>();
for (String specsId : specsIds) {
list.add(Long.valueOf(specsId));
}
criteria.andSpecsIdIn(list);
}
return couponDiscountGoodsRelMapper.selectByExample(example); return couponDiscountGoodsRelMapper.selectByExample(example);
} }

@ -52,5 +52,24 @@ public class CouponDiscountUserRelServiceImpl implements CouponDiscountUserRelSe
return couponDiscountUserRelMapper.selectByPrimaryKey(id); return couponDiscountUserRelMapper.selectByPrimaryKey(id);
} }
@Override
public CouponDiscountUserRel getRel(Map<String, Object> map) {
CouponDiscountUserRelExample example = new CouponDiscountUserRelExample();
CouponDiscountUserRelExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map, "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId"));
}
if (MapUtils.getInteger(map, "discountId") != null) {
criteria.andDiscountIdEqualTo(MapUtils.getLong(map, "discountId"));
}
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
return null;
}
} }

@ -26,6 +26,11 @@ import java.util.Objects;
@Service("bsOrderGoodsService") @Service("bsOrderGoodsService")
public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
// 缓存前缀KEY
public final static String CACHE_KEY = "LOGISTICS:";
// 订单缓存时间 7天
public final static Integer CACHE_TIME = 60*60*6;
@Resource @Resource
private BsOrderGoodsMapper bsOrderGoodsMapper; private BsOrderGoodsMapper bsOrderGoodsMapper;
@Resource @Resource
@ -203,7 +208,7 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
@Override @Override
public Object getLogisticsMsg(Long orderGoodsId) { public Object getLogisticsMsg(Long orderGoodsId) {
Object data = redisUtil.get("logisticsMsg" + orderGoodsId); Object data = redisUtil.get(CACHE_KEY + orderGoodsId);
if (data == null) { if (data == null) {
BsOrderGoods orderGoods = queryDetail(orderGoodsId); BsOrderGoods orderGoods = queryDetail(orderGoodsId);
if (orderGoods == null || orderGoods.getLogisticsNo() == null) { if (orderGoods == null || orderGoods.getLogisticsNo() == null) {
@ -216,11 +221,11 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!");
} }
redisUtil.set("logisticsMsgOl" + orderGoodsId , jsonObjects ,21600); redisUtil.set(CACHE_KEY + orderGoods.getLogisticsNo(), jsonObjects, CACHE_TIME);
if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) { if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) {
jsonObjects.getJSONObject("data").put("orderId" , orderGoodsId); jsonObjects.getJSONObject("data").put("orderId" , orderGoodsId);
GoodsLogistics logistics = editLogistics((JSONObject) jsonObjects.get("data")); GoodsLogistics logistics = editLogistics((JSONObject) jsonObjects.get("data"));
redisUtil.set("logisticsMsg" + orderGoodsId , logistics ,21600); redisUtil.set(CACHE_KEY + orderGoodsId, logistics, CACHE_TIME);
return logistics; return logistics;
} }
return jsonObjects; return jsonObjects;

@ -179,6 +179,14 @@ public class OrderCreateService {
if (address == null) { if (address == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的收货地址"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的收货地址");
} }
JSONObject jsonObject;
if (orderChild.getBusiness() == null) {
jsonObject = new JSONObject();
} else {
jsonObject = new JSONObject((Map<String, Object>) orderChild.getBusiness());
}
jsonObject.put("address", address);
// 创建实物订单 // 创建实物订单
BsOrderGoods orderGoods = new BsOrderGoods(); BsOrderGoods orderGoods = new BsOrderGoods();
@ -210,6 +218,8 @@ public class OrderCreateService {
shoppingCartService.delete(object.getLong("shopCartId")); shoppingCartService.delete(object.getLong("shopCartId"));
} }
orderChild.setBusiness(jsonObject);
return orderChild; return orderChild;
} }

@ -70,20 +70,32 @@ public class BsOrderChildServiceImpl implements BsOrderChildService {
List<BsOrderChild> list = orderChildMapper.selectByExample(example); List<BsOrderChild> list = orderChildMapper.selectByExample(example);
List<OrderChildModel> orderChildModelList = new ArrayList<>(); List<OrderChildModel> orderChildModelList = new ArrayList<>();
for (BsOrderChild orderChild : list) { for (BsOrderChild orderChild : list) {
OrderChildModel childModel = new OrderChildModel(); OrderChildModel childModel = new OrderChildModel();
BeanUtils.copyProperties(orderChild, childModel); BeanUtils.copyProperties(orderChild, childModel);
BsOrderGoods orderGoods = orderGoodsService.findGoodsOrder(orderNo); BsOrderGoods orderGoods = orderGoodsService.findGoodsOrder(orderNo);
GoodsUserAddress address = goodsUserAddressService.queryDetail(orderGoods.getId()); if (orderGoods != null) {
GoodsUserAddress address = goodsUserAddressService.queryDetail(orderGoods.getDeliveryAddressId());
JSONObject object = new JSONObject((Map<String, Object>) childModel.getBusiness()); JSONObject object;
if (childModel.getBusiness() == null) {
object = new JSONObject();
} else {
object = new JSONObject((Map<String, Object>) childModel.getBusiness());
}
object.put("address", address); object.put("address", address);
if (orderGoods.getLogisticsNo() != null) { if (orderGoods.getLogisticsNo() != null) {
object.put("logisticsNo", orderGoods.getLogisticsNo()); object.put("logisticsNo", orderGoods.getLogisticsNo());
} }
childModel.setBusiness(object);
}
orderChildModelList.add(childModel); orderChildModelList.add(childModel);
} }

@ -1,5 +1,6 @@
package com.hfkj.service.order.impl; package com.hfkj.service.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
@ -445,6 +446,15 @@ public class BsOrderServiceImpl implements BsOrderService {
// 子订单 // 子订单
orderModel.setOrderChildList(orderChildService.getOrderChildListByOrderNo(orderNo)); orderModel.setOrderChildList(orderChildService.getOrderChildListByOrderNo(orderNo));
// todo 1.0阶段暂时需要返回收货地址使用
for (OrderChildModel orderChild : orderModel.getOrderChildList()) {
if (orderChild.getProductType() == 1) {
orderModel.setBusiness(orderChild.getBusiness());
}
}
// 更新缓存 // 更新缓存
cache(orderModel); cache(orderModel);
return orderModel; return orderModel;

Loading…
Cancel
Save