袁野 3 months ago
parent 261df447c5
commit fd5947c45e
  1. 16
      cweb/src/main/java/com/cweb/controller/discount/DiscountController.java
  2. 24
      cweb/src/main/java/com/cweb/controller/qianZhu/StarbucksController.java
  3. 118
      order/src/main/java/com/order/controller/business/BsOrderStarbucksController.java
  4. 20
      service/src/main/java/com/hfkj/model/order/OrderStarbucksModel.java
  5. 11
      service/src/main/java/com/hfkj/service/SecDictionaryService.java
  6. 9
      service/src/main/java/com/hfkj/service/impl/SecDictionaryServiceImpl.java
  7. 11
      service/src/main/java/com/hfkj/service/order/BsOrderChildService.java
  8. 6
      service/src/main/java/com/hfkj/service/order/OrderCreateService.java
  9. 43
      service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java
  10. 4
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java

@ -113,16 +113,24 @@ public class DiscountController {
listDiscount.forEach(d -> {
Map<String, Object> mapSpecs = new HashMap<>();
mapSpecs.put("discountId", d.getDiscountId());
mapSpecs.put("specsIds", specsIds);
// 查询规格可用优惠券
List<CouponDiscountGoodsRel> couponDiscountGoodsRel = couponDiscountService.getListGoodsRel(mapSpecs);
List<Long> specsIdList = new ArrayList<>();
List<Long> specsIdListS = new ArrayList<>();
couponDiscountGoodsRel.forEach(dg -> {
specsIdList.add(dg.getSpecsId());
});
String specsIdsStr = StringUtils.join(specsIdList, ",");
if (specsIdsStr.contains(specsIds)) {
String[] s = specsIds.split(",");
for(String ss : s) {
specsIdListS.add(Long.parseLong(ss));
}
Collections.sort(specsIdList);
Collections.sort(specsIdListS);
if (specsIdList.toString().equals(specsIdListS.toString())) {
listFind.add(d);
}
});
@ -179,7 +187,7 @@ public class DiscountController {
try {
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
List<SecDictionary> dictionary = dictionaryService.getDictionary(code);
List<SecDictionary> dictionary = dictionaryService.getDictionaryByOl(code);
if (!dictionary.isEmpty()) {
for (SecDictionary secDictionary : dictionary) {
@ -189,7 +197,7 @@ public class DiscountController {
map.put("discountId", secDictionary.getCodeValue());
List<CouponDiscountUserRel> list = discountUserRelService.getList(map);
if (!list.isEmpty()) {
if (list.isEmpty()) {
couponDiscountPackageService.giveDiscountPackage(Integer.valueOf(secDictionary.getCodeName()), userSession.getUser().getPhone());
}

@ -73,34 +73,14 @@ public class StarbucksController {
@RequestMapping(value="/starbucksProducts",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询星巴克产品")
public ResponseData starbucksProducts(
@RequestParam(name = "code", required = false) String code,
@RequestParam(name = "lat", required = true) String lat,
@RequestParam(name = "lon", required = true) String lon) {
public ResponseData starbucksProducts(@RequestParam(name = "code", required = false) String code) {
try {
Map<String, Object> params = new HashMap<>();
params.put("lat", lat);
params.put("lon", lon);
List<JSONObject> list = StarbucksService.starbucksStoresList(params);
if (code != null) {
list = list.stream()
.filter(s -> s.getString("code").equals(code))
.collect(Collectors.toList()); // 将结果收集到列表中
}
List<JSONObject> products = new ArrayList<>();
JSONObject product = new JSONObject();
if (!list.isEmpty()) {
JSONObject data = list.get(0);
product.put("store", data);
// 查询产品配置
BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type4.getCode());
// 查询产品
Map<String , Object> map = new HashMap<>();
map.put("pageIndex", 1);
@ -193,8 +173,6 @@ public class StarbucksController {
}
}
}
Map<String, List<JSONObject>> collect = products.stream().collect(Collectors.groupingBy(jsonObject -> jsonObject.getString("categoryName")));
AtomicReference<Integer> i = new AtomicReference<>(1);

@ -0,0 +1,118 @@
package com.order.controller.business;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.PageUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsOrderChild;
import com.hfkj.entity.BsOrderStarbucks;
import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.model.order.OrderStarbucksModel;
import com.hfkj.service.goods.BsOrderStarbucksService;
import com.hfkj.service.order.BsOrderChildService;
import com.hfkj.sysenum.SecUserObjectTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
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.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Controller
@RequestMapping(value="/orderStarbucks")
@Api(value="星巴克订单管理")
public class BsOrderStarbucksController {
private static final Logger log = LoggerFactory.getLogger(BsOrderStarbucksController.class);
@Resource
private BsOrderChildService bsOrderChildService;
@Resource
private BsOrderStarbucksService bsOrderStarbucksService;
@RequestMapping(value="/getListStarbucks",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询列表")
public ResponseData getListStarbucks(
@RequestParam(value = "orderNo" , required = false) String orderNo,
@RequestParam(value = "childOrderNo" , required = false) String childOrderNo,
@RequestParam(value = "userPhone" , required = false) String userPhone,
@RequestParam(value = "productSpecName" , required = false) String productSpecName,
@RequestParam(value = "storeAddress" , required = false) String storeAddress,
@RequestParam(value = "storeName" , required = false) String storeName,
@RequestParam(value = "productName" , required = false) String productName,
@RequestParam(value = "payType" , required = false) Integer payType,
@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 = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) {
try {
Map<String , Object> map = new HashMap<>();
map.put("orderNo", orderNo);
map.put("childOrderNo", childOrderNo);
map.put("productType", 4);
map.put("productSpecName", productSpecName);
map.put("productName", productName);
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
map.put("status", status);
List<BsOrderChild> list = bsOrderChildService.getList(map);
List<BsOrderStarbucks> starbucksList = bsOrderStarbucksService.getList(new HashMap<>());
List<OrderStarbucksModel> starbucksModelList = new ArrayList<>();
for (BsOrderChild bsOrderChild : list) {
OrderStarbucksModel starbucksModel = new OrderStarbucksModel();
BeanUtils.copyProperties(bsOrderChild, starbucksModel);
List<BsOrderStarbucks> starbucks= starbucksList.stream().filter(s -> s.getOrderNo().equals(starbucksModel.getOrderNo())).
collect(Collectors.toList());
if (!starbucks.isEmpty()) {
starbucksModel.setStoreAddress(starbucks.get(0).getStoreAddress());
starbucksModel.setStoreName(starbucks.get(0).getStoreName());
starbucksModel.setUserPhone(starbucks.get(0).getUserPhone());
starbucksModelList.add(starbucksModel);
}
}
if (storeAddress != null) {
starbucksModelList = starbucksModelList.stream().filter(s -> s.getStoreAddress().contains(storeAddress)) // 使用contains方法进行模糊查询
.collect(Collectors.toList());
}
if (storeName != null) {
starbucksModelList = starbucksModelList.stream().filter(s -> s.getStoreName().contains(storeName)) // 使用contains方法进行模糊查询
.collect(Collectors.toList());
}
if (userPhone != null) {
starbucksModelList = starbucksModelList.stream().filter(s -> s.getUserPhone().contains(userPhone)) // 使用contains方法进行模糊查询
.collect(Collectors.toList());
}
return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum, starbucksModelList.size(), pageSize, new PageInfo<>(starbucksModelList)));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,20 @@
package com.hfkj.model.order;
import com.hfkj.entity.BsOrderChild;
import lombok.Data;
@Data
public class OrderStarbucksModel extends BsOrderChild{
/**
* 门店地址
*/
private String storeAddress;
/**
* 门店名称
*/
private String storeName;
private String userPhone;
}

@ -24,6 +24,17 @@ public interface SecDictionaryService {
*/
List<SecDictionary> getDictionary(String codeType);
/**
* @MethodName getDictionaryByOl
* @Description: 查询在线
* @param codeType
* @return: java.util.List<com.hfkj.entity.SecDictionary>
* @Author: Sum1Dream
* @Date: 2024/8/7 上午10:36
*/
List<SecDictionary> getDictionaryByOl(String codeType);
/**
* 获取数据字典
* @param codeType

@ -8,6 +8,7 @@ import com.hfkj.service.SecDictionaryService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -44,6 +45,14 @@ public class SecDictionaryServiceImpl implements SecDictionaryService {
return getDictionary().stream().filter(o -> o.getCodeType().equals(codeType)).collect(Collectors.toList());
}
@Override
public List<SecDictionary> getDictionaryByOl(String codeType) {
SecDictionaryExample example = new SecDictionaryExample();
example.createCriteria().andCodeTypeEqualTo(codeType);
example.or().andCodeTypeEqualTo(codeType);
return secDictionaryMapper.selectByExample(example);
}
@Override
public SecDictionary getDictionary(String codeType, String codeValue) {
List<SecDictionary> list = getDictionary().stream()

@ -5,6 +5,7 @@ import com.hfkj.model.order.OrderChildModel;
import com.hfkj.model.order.OrderModel;
import java.util.List;
import java.util.Map;
/**
* @className: BsOrderChildService
@ -33,6 +34,16 @@ public interface BsOrderChildService {
*/
List<OrderChildModel> getOrderChildListByOrderNo(String orderNo);
/**
* @MethodName getList
* @Description: 查询子订单
* @param map
* @return: java.util.List<com.hfkj.model.order.OrderChildModel>
* @Author: Sum1Dream
* @Date: 2024/8/7 下午2:55
*/
List<BsOrderChild> getList(Map<String ,Object> map);
/**
* 获取未完成的子订单数量
* @param orderNo

@ -381,7 +381,8 @@ public class OrderCreateService {
// 子订单价格
BigDecimal childPrice = new BigDecimal(0);
// 产品规格
StringBuilder productSpecName = new StringBuilder();
// 筛选数据
for (Object orderItem : orderItems) {
JSONObject orderItemObject = (JSONObject) orderItem;
@ -438,12 +439,13 @@ public class OrderCreateService {
orderStarbucksService.create(bsOrderStarbucks);
childPrice = childPrice.add(bsOrderStarbucks.getPrice().multiply(orderItemObject.getBigDecimal("num")));
productSpecName.append(starbucks.getString("name")).append("*").append(orderItemObject.getInteger("num")).append("/");
}
orderChild.setMerId(productConfig.getMerId());
orderChild.setProductName("星巴克");
orderChild.setProductCount(1);
orderChild.setProductSpecName("星巴克");
orderChild.setProductSpecName(String.valueOf(productSpecName.toString()));
// 星巴克创建订单
// 获取token

@ -14,6 +14,8 @@ import com.hfkj.service.goods.impl.BsOrderStarbucksServiceImpl;
import com.hfkj.service.order.BsOrderChildService;
import com.hfkj.sysenum.order.OrderChildProductTypeEnum;
import com.hfkj.sysenum.order.OrderChildStatusEnum;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -191,6 +193,47 @@ public class BsOrderChildServiceImpl implements BsOrderChildService {
return orderChildModelList;
}
@Override
public List<BsOrderChild> getList(Map<String, Object> map) {
BsOrderChildExample example = new BsOrderChildExample();
BsOrderChildExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "merId") != null) {
criteria.andMerIdEqualTo(MapUtils.getLong(map, "merId"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "orderNo"))) {
criteria.andOrderNoEqualTo(MapUtils.getString(map, "orderNo"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "childOrderNo"))) {
criteria.andChildOrderNoEqualTo(MapUtils.getString(map, "childOrderNo"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "productSpecName"))) {
criteria.andProductSpecNameLike(MapUtils.getString(map, "productSpecName"));
}
if (MapUtils.getInteger(map, "productType") != null) {
criteria.andProductTypeEqualTo(MapUtils.getInteger(map, "productType"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "productName"))) {
criteria.andProductNameLike("%"+MapUtils.getString(map, "productName")+"%");
}
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) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
example.setOrderByClause("create_time desc");
return orderChildMapper.selectByExample(example);
}
@Override
public long getUndoneChildOrder(String orderNo) {
BsOrderChildExample example = new BsOrderChildExample();

@ -340,9 +340,11 @@ public class BsOrderServiceImpl implements BsOrderService {
deduction.setCouponDiscountPrice(discount.getPrice());
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (1 == discount.getType()) {
if (discount.getCondition().compareTo(order.getProductTotalPrice()) < 0) {
if (order.getProductTotalPrice().compareTo(discount.getCondition()) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未满足优惠券满减条件");
}
deduction.setCouponDiscountActualPrice(discount.getPrice());
} else if (2 == discount.getType()) {
deduction.setCouponDiscountActualPrice(discount.getPrice());

Loading…
Cancel
Save