|
@@ -65,64 +65,136 @@ public class OrderClubServiceImpl implements OrderClubService {
|
|
// 分页请求数据
|
|
// 分页请求数据
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
List<OrderVo> orderList = orderClubMapper.getOrderList(userId, orderState, orderNo, beginTime, endTime);
|
|
List<OrderVo> orderList = orderClubMapper.getOrderList(userId, orderState, orderNo, beginTime, endTime);
|
|
- for (OrderVo order : orderList) {
|
|
|
|
- // 111, 待付待收待发
|
|
|
|
- if (11 == order.getStatus() && 1 == order.getPayStatus()) {
|
|
|
|
- order.setStatus(111);
|
|
|
|
- }
|
|
|
|
- // 判断交易全退情况下,是否发过货,77,交易全退可以查看物流
|
|
|
|
- int logisticsCount = orderClubMapper.countLogisticsBatch(order.getOrderId());
|
|
|
|
- if (7 == order.getStatus() && logisticsCount > 0) {
|
|
|
|
- order.setStatus(77);
|
|
|
|
|
|
+ orderList.forEach(order -> {
|
|
|
|
+ // 设置订单状态
|
|
|
|
+ setOrderStatus(order);
|
|
|
|
+ // 设置子订单数据
|
|
|
|
+ getShopOrderData(order);
|
|
|
|
+ // 设置付款金额
|
|
|
|
+ getDiscernReceiptAndSetOrder(order);
|
|
|
|
+ });
|
|
|
|
+ PageInfo<OrderVo> pageInfo = new PageInfo(orderList);
|
|
|
|
+ return ResponseJson.success(pageInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据关键词搜索订单
|
|
|
|
+ *
|
|
|
|
+ * @param userId 用户Id
|
|
|
|
+ * @param searchWord 搜索关键词
|
|
|
|
+ * @param pageNum 页码
|
|
|
|
+ * @param pageSize 每页数量
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<PageInfo<OrderVo>> getOrderListByKeyword(Integer userId, String searchWord, int pageNum, int pageSize) {
|
|
|
|
+ // 设置搜索关键词历史记录
|
|
|
|
+ setHistoryRecord(userId, searchWord);
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<OrderVo> orderList = orderClubMapper.getOrderListByKeyword(searchWord, userId);
|
|
|
|
+ //获取主订单数据
|
|
|
|
+ orderList.forEach(order -> {
|
|
|
|
+ // 设置订单状态
|
|
|
|
+ setOrderStatus(order);
|
|
|
|
+ // 设置子订单数据
|
|
|
|
+ getShopOrderData(order);
|
|
|
|
+ // 设置付款金额
|
|
|
|
+ getDiscernReceiptAndSetOrder(order);
|
|
|
|
+ });
|
|
|
|
+ PageInfo<OrderVo> pageInfo = new PageInfo(orderList);
|
|
|
|
+ return ResponseJson.success(pageInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置订单状态
|
|
|
|
+ */
|
|
|
|
+ private void setOrderStatus(OrderVo order) {
|
|
|
|
+ // 111, 待付待收待发
|
|
|
|
+ if (11 == order.getStatus() && 1 == order.getPayStatus()) {
|
|
|
|
+ order.setStatus(111);
|
|
|
|
+ }
|
|
|
|
+ // 判断交易全退情况下,是否发过货,77,交易全退可以查看物流
|
|
|
|
+ int logisticsCount = orderClubMapper.countLogisticsBatch(order.getOrderId());
|
|
|
|
+ if (7 == order.getStatus() && logisticsCount > 0) {
|
|
|
|
+ order.setStatus(77);
|
|
|
|
+ }
|
|
|
|
+ // 判断二手订单情况下,若部分付款和已付款,排除退货/款的情况,且未确认打款供应商,10,添加确认打款供应商按钮
|
|
|
|
+ if (1 == order.getSecondHandOrderFlag() && 0 == order.getRefundType() && 0 == order.getAffirmPaymentFlag()) {
|
|
|
|
+ if (order.getStatus().toString().startsWith("2") || order.getStatus().toString().startsWith("3")) {
|
|
|
|
+ // 之前是 “00”
|
|
|
|
+ order.setAffirmPaymentFlag(10);
|
|
}
|
|
}
|
|
- // 判断二手订单情况下,若部分付款和已付款,排除退货/款的情况,且未确认打款供应商,10,添加确认打款供应商按钮
|
|
|
|
- if (1 == order.getSecondHandOrderFlag() && 0 == order.getRefundType() && 0 == order.getAffirmPaymentFlag()) {
|
|
|
|
- if (order.getStatus().toString().startsWith("2") || order.getStatus().toString().startsWith("3")) {
|
|
|
|
- // 之前是 “00”
|
|
|
|
- order.setAffirmPaymentFlag(10);
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置子订单数据
|
|
|
|
+ */
|
|
|
|
+ private void getShopOrderData(OrderVo order) {
|
|
|
|
+ // 子订单
|
|
|
|
+ String[] shopOrderIdArr = order.getShopOrderIds().split(",");
|
|
|
|
+ List<String> shopOrderIds = Arrays.asList(shopOrderIdArr);
|
|
|
|
+ List<ShopOrderVo> shopOrderList = orderClubMapper.getShopOrderList(shopOrderIds);
|
|
|
|
+ shopOrderList.forEach(shopOrder -> {
|
|
|
|
+ // 店铺促销活动
|
|
|
|
+ PromotionsVo shopPromotion = null;
|
|
|
|
+ if (null != shopOrder.getOrderPromotionsId() && shopOrder.getOrderPromotionsId() > 0) {
|
|
|
|
+ shopPromotion = orderClubMapper.getOrderPromotionsById(shopOrder.getOrderPromotionsId());
|
|
|
|
+ shopOrder.setShopPromotion(shopPromotion);
|
|
}
|
|
}
|
|
- // 子订单
|
|
|
|
- String[] shopOrderIdArr = order.getShopOrderIds().split(",");
|
|
|
|
- List<String> shopOrderIds = Arrays.asList(shopOrderIdArr);
|
|
|
|
- List<ShopOrderVo> shopOrderList = orderClubMapper.getShopOrderList(shopOrderIds);
|
|
|
|
- shopOrderList.forEach(shopOrder -> {
|
|
|
|
- // 店铺促销活动
|
|
|
|
- PromotionsVo shopPromotion = null;
|
|
|
|
- if (null != shopOrder.getOrderPromotionsId() && shopOrder.getOrderPromotionsId() > 0) {
|
|
|
|
- shopPromotion = orderClubMapper.getOrderPromotionsById(shopOrder.getOrderPromotionsId());
|
|
|
|
- shopOrder.setShopPromotion(shopPromotion);
|
|
|
|
|
|
+ List<OrderProductVo> orderProductList = orderClubMapper.getShopOrderProduct(shopOrder.getShopOrderId());
|
|
|
|
+ for (OrderProductVo orderProduct : orderProductList) {
|
|
|
|
+ boolean taxFlag = (0 == orderProduct.getIncludedTax() && (1 == orderProduct.getInvoiceType() || 2 == orderProduct.getInvoiceType()));
|
|
|
|
+ if (taxFlag) {
|
|
|
|
+ orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()).doubleValue());
|
|
|
|
+ orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()).doubleValue());
|
|
}
|
|
}
|
|
- List<OrderProductVo> orderProductList = orderClubMapper.getShopOrderProduct(shopOrder.getShopOrderId());
|
|
|
|
- for (OrderProductVo orderProduct : orderProductList) {
|
|
|
|
- boolean taxFlag = (0 == orderProduct.getIncludedTax() && (1 == orderProduct.getInvoiceType() || 2 == orderProduct.getInvoiceType()));
|
|
|
|
- if (taxFlag) {
|
|
|
|
- orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()).doubleValue());
|
|
|
|
- orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()).doubleValue());
|
|
|
|
- }
|
|
|
|
- orderProduct.setImage(ImageUtil.getImageUrl("product", orderProduct.getImage(), domain));
|
|
|
|
- // 查询订单下商品的促销活动
|
|
|
|
- if (null != orderProduct.getOrderPromotionsId() && orderProduct.getOrderPromotionsId() > 0) {
|
|
|
|
- PromotionsVo promotions = orderClubMapper.getOrderPromotionsById(orderProduct.getOrderPromotionsId());
|
|
|
|
- if (null != promotions) {
|
|
|
|
- if (1 == promotions.getType() && 1 == promotions.getMode()) {
|
|
|
|
- promotions.setTouchPrice(MathUtil.add(promotions.getTouchPrice(), MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), orderProduct.getTaxRate()), 100)).doubleValue());
|
|
|
|
- }
|
|
|
|
- orderProduct.setProductPromotion(promotions);
|
|
|
|
|
|
+ orderProduct.setImage(ImageUtil.getImageUrl("product", orderProduct.getImage(), domain));
|
|
|
|
+ // 查询订单下商品的促销活动
|
|
|
|
+ if (null != orderProduct.getOrderPromotionsId() && orderProduct.getOrderPromotionsId() > 0) {
|
|
|
|
+ PromotionsVo promotions = orderClubMapper.getOrderPromotionsById(orderProduct.getOrderPromotionsId());
|
|
|
|
+ if (null != promotions) {
|
|
|
|
+ if (1 == promotions.getType() && 1 == promotions.getMode()) {
|
|
|
|
+ promotions.setTouchPrice(MathUtil.add(promotions.getTouchPrice(), MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), orderProduct.getTaxRate()), 100)).doubleValue());
|
|
}
|
|
}
|
|
|
|
+ orderProduct.setProductPromotion(promotions);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- shopOrder.setOrderProductList(orderProductList);
|
|
|
|
- shopOrder.setShopLogo(ImageUtil.getImageUrl("shopLogo", shopOrder.getShopLogo(), domain));
|
|
|
|
- });
|
|
|
|
- // 过滤运费商品
|
|
|
|
- shopOrderList.removeIf(shopOrder -> shopOrder.getShopId() == 998);
|
|
|
|
- order.setShopOrderList(shopOrderList);
|
|
|
|
- // 设置付款金额
|
|
|
|
- getDiscernReceiptAndSetOrder(order);
|
|
|
|
|
|
+ }
|
|
|
|
+ shopOrder.setOrderProductList(orderProductList);
|
|
|
|
+ shopOrder.setShopLogo(ImageUtil.getImageUrl("shopLogo", shopOrder.getShopLogo(), domain));
|
|
|
|
+ });
|
|
|
|
+ // 过滤运费商品
|
|
|
|
+ shopOrderList.removeIf(shopOrder -> shopOrder.getShopId() == 998);
|
|
|
|
+ order.setShopOrderList(shopOrderList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置搜索关键词历史记录
|
|
|
|
+ * @param userId 用户Id
|
|
|
|
+ * @param searchWord 搜索关键词
|
|
|
|
+ */
|
|
|
|
+ private void setHistoryRecord(Integer userId, String searchWord) {
|
|
|
|
+ // 初始化一个搜索关键词历史记录
|
|
|
|
+ SearchHistoryVo historyRecord = new SearchHistoryVo();
|
|
|
|
+ historyRecord.setUserId(userId);
|
|
|
|
+ historyRecord.setSearchDate(new Date());
|
|
|
|
+ historyRecord.setSearchWord(searchWord);
|
|
|
|
+ historyRecord.setDelFlag(0);
|
|
|
|
+ // 查询搜索关键词历史记录是否存在
|
|
|
|
+ Integer recordId = orderClubMapper.getSearchHistoryIdByWord(searchWord);
|
|
|
|
+ // 保存搜索关键词历史记录
|
|
|
|
+ if (null != recordId && recordId >0) {
|
|
|
|
+ historyRecord.setId(recordId);
|
|
|
|
+ orderClubMapper.updateSearchHistory(historyRecord);
|
|
|
|
+ } else {
|
|
|
|
+ orderClubMapper.insertSearchHistory(historyRecord);
|
|
|
|
+ }
|
|
|
|
+ // 查询关键字历史记录条数
|
|
|
|
+ int count = orderClubMapper.countSearchHistory(userId);
|
|
|
|
+ // 只保留10条的搜索关键词历史记录
|
|
|
|
+ if (count > 10) {
|
|
|
|
+ orderClubMapper.deleteSearchHistoryLimit(userId);
|
|
}
|
|
}
|
|
- PageInfo<OrderVo> pageInfo = new PageInfo(orderList);
|
|
|
|
- return ResponseJson.success(pageInfo);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -424,4 +496,15 @@ public class OrderClubServiceImpl implements OrderClubService {
|
|
|
|
|
|
return ResponseJson.success("确认收货成功!", null);
|
|
return ResponseJson.success("确认收货成功!", null);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据用户Id查找订单搜索历史记录
|
|
|
|
+ *
|
|
|
|
+ * @param userId 用户Id
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<List<SearchHistoryVo>> getOrderSearchHistory(Integer userId) {
|
|
|
|
+ List<SearchHistoryVo> historyList = orderClubMapper.getOrderSearchHistory(userId);
|
|
|
|
+ return ResponseJson.success(historyList);
|
|
|
|
+ }
|
|
}
|
|
}
|