Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
60ca3e40fd
|
|
@ -1,20 +1,25 @@
|
|||
package com.czg.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 公众号 通知
|
||||
|
|
@ -52,18 +57,31 @@ public class NotifyController {
|
|||
else if ("POST".equals(request.getMethod())) {
|
||||
log.info("接收到微信 POST 消息请求 - signature: {}, timestamp: {}, nonce: {}",
|
||||
signature, timestamp, nonce);
|
||||
// 读取 POST 请求体中的 XML 数据(微信推送的消息格式为 XML)
|
||||
// 1. 读取请求体中的 XML 数据
|
||||
String xmlData = readPostXml(request);
|
||||
JSONObject jsonObject = JSON.parseObject(xmlData);
|
||||
log.info("微信 POST 消息内容: {}", jsonObject);
|
||||
if (xmlData.isEmpty()) {
|
||||
log.error("微信 POST 消息体为空");
|
||||
return "";
|
||||
}
|
||||
log.info("微信 POST 消息 XML 原始内容: {}", xmlData);
|
||||
|
||||
// 2. 解析 XML 为 Map(便于获取字段)
|
||||
Map<String, String> messageMap;
|
||||
try {
|
||||
messageMap = parseXmlToMap(xmlData);
|
||||
} catch (DocumentException e) {
|
||||
log.error("XML 解析失败,原始内容: {}", xmlData, e);
|
||||
return "";
|
||||
}
|
||||
log.info("微信 POST 消息内容: {}", messageMap);
|
||||
// 获取消息类型(如 event)
|
||||
String msgType = jsonObject.getString("MsgType");
|
||||
String msgType = messageMap.get("MsgType");
|
||||
// 获取事件类型(如 unsubscribe:用户取消关注 subscribe:用户关注)
|
||||
String event = jsonObject.getString("Event");
|
||||
String event = messageMap.get("Event");
|
||||
// 获取用户 OpenID
|
||||
String openId = jsonObject.getString("FromUserName");
|
||||
String openId = messageMap.get("FromUserName");
|
||||
//携带参数
|
||||
String eventKey = jsonObject.getString("EventKey");
|
||||
String eventKey = messageMap.get("EventKey");
|
||||
Long userId = null;
|
||||
log.info("解析结果 - 消息类型: {}, 事件类型: {}, 用户 OpenID: {} 携带参数: {}", msgType, event, openId, eventKey);
|
||||
if (eventKey != null && eventKey.startsWith("qrscene_")) {
|
||||
|
|
@ -114,4 +132,47 @@ public class NotifyController {
|
|||
return xmlSb.toString();
|
||||
}
|
||||
|
||||
|
||||
// 将 XML 字符串解析为 Map<String, String>
|
||||
private static Map<String, String> parseXmlToMap(String xmlData) throws DocumentException {
|
||||
Map<String, String> resultMap = new HashMap<>(16);
|
||||
Document document = DocumentHelper.parseText(xmlData);
|
||||
Element rootElement = document.getRootElement();
|
||||
|
||||
// 遍历所有子节点,将节点名和文本值存入 Map
|
||||
Iterator<Element> elementIterator = rootElement.elementIterator();
|
||||
while (elementIterator.hasNext()) {
|
||||
Element childElement = elementIterator.next();
|
||||
resultMap.put(childElement.getName(), childElement.getTextTrim());
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = "<xml><ToUserName><![CDATA[gh_11fc27b7ef34]]></ToUserName><FromUserName><![CDATA[owWHW7Tzeh2gx3WmFsFSxBq2JUTk]]></FromUserName><CreateTime>1761095747</CreateTime><MsgType><![CDATA[event]]></MsgType><Event><![CDATA[subscribe]]></Event><EventKey><![CDATA[qrscene_275]]></EventKey><Ticket><![CDATA[gQGF8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUTZDVHRTMXhmbUoxYUlYdk5GY2sAAgSsLvhoAwQAjScA]]></Ticket></xml>";
|
||||
// 2. 解析 XML 为 Map(便于获取字段)
|
||||
Map<String, String> messageMap = new HashMap<>();
|
||||
try {
|
||||
messageMap = parseXmlToMap(str);
|
||||
} catch (DocumentException e) {
|
||||
log.error("XML 解析失败,", e);
|
||||
}
|
||||
log.info("微信 POST 消息内容: {}", messageMap);
|
||||
//携带参数
|
||||
String eventKey = messageMap.get("EventKey");
|
||||
Long userId = null;
|
||||
if (eventKey != null && eventKey.startsWith("qrscene_")) {
|
||||
try {
|
||||
// 截取 "qrscene_" 前缀后的字符串(长度为 8),并转为 Long
|
||||
String numberStr = eventKey.substring("qrscene_".length());
|
||||
userId = Long.parseLong(numberStr);
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("EventKey 后缀不是有效数字,eventKey: {}", eventKey, e);
|
||||
}
|
||||
}
|
||||
System.out.println("userId: " + userId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,76 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.BaseQueryParam;
|
||||
import com.czg.TimeQueryParam;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.market.dto.MkProductSmartSuggestDTO;
|
||||
import com.czg.market.service.MkProductSmartSuggestService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.czg.validator.group.UpdateGroup;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 点单智能推荐
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/suggest")
|
||||
public class AProductSmartSuggestController {
|
||||
@Resource
|
||||
private MkProductSmartSuggestService suggestService;
|
||||
|
||||
/**
|
||||
* 点单智能推荐-分页
|
||||
*/
|
||||
@GetMapping("page")
|
||||
public CzgResult<Page<MkProductSmartSuggestDTO>> getProductSmartSuggestPage(BaseQueryParam param) {
|
||||
Page<MkProductSmartSuggestDTO> data = suggestService.getProductSmartSuggestPage(param, StpKit.USER.getShopId());
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 点单智能推荐-新增
|
||||
*/
|
||||
@PostMapping
|
||||
@OperationLog("点单智能推荐-新增")
|
||||
public CzgResult<Void> addProductSmartSuggest(@RequestBody @Validated({InsertGroup.class, DefaultGroup.class}) MkProductSmartSuggestDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
dto.setShopId(shopId);
|
||||
suggestService.addProductSmartSuggest(dto);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 点单智能推荐-修改
|
||||
*/
|
||||
@PutMapping
|
||||
@OperationLog("点单智能推荐-修改")
|
||||
public CzgResult<Void> updateProductSmartSuggest(@RequestBody @Validated({UpdateGroup.class, DefaultGroup.class}) MkProductSmartSuggestDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
dto.setShopId(shopId);
|
||||
suggestService.updateProductSmartSuggestById(dto);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 点单智能推荐-删除
|
||||
*/
|
||||
@DeleteMapping
|
||||
@OperationLog("点单智能推荐-删除")
|
||||
public CzgResult<String> deleteMkProductSmartSuggest(@RequestParam Long id) {
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
suggestService.deleteProductSmartSuggest(id);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.market.entity.MkProductSmartSuggest;
|
||||
import com.czg.market.service.MkProductSmartSuggestService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 点单智能推荐
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user/suggest")
|
||||
public class UProductSmartSuggestController {
|
||||
@Resource
|
||||
private MkProductSmartSuggestService suggestService;
|
||||
|
||||
/**
|
||||
* 获取点单智能推荐
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<List<MkProductSmartSuggest>> getActivity(@RequestParam Long shopId) {
|
||||
List<MkProductSmartSuggest> list = suggestService.getProductSmartSuggestByShopId(shopId);
|
||||
return CzgResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -42,13 +42,13 @@ public class AAMarketTasks {
|
|||
memberTask.task();
|
||||
}
|
||||
|
||||
//满减活动定时任务
|
||||
//满减活动/限时折扣 处理任务状态 定时任务
|
||||
@Resource
|
||||
private DiscountActivityTask discountActivityTask;
|
||||
private ActivityStatusTask activityStatusTask;
|
||||
//每天0点 0分 1秒 执行
|
||||
@Scheduled(cron = "1 0 0 * * ? ")
|
||||
public void discountActivityTask() {
|
||||
discountActivityTask.task();
|
||||
public void activityStatusTask() {
|
||||
activityStatusTask.task();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.czg.task;
|
||||
|
||||
import com.czg.market.entity.MkDiscountActivity;
|
||||
import com.czg.market.entity.MkLimitTimeDiscount;
|
||||
import com.czg.market.service.MkDiscountActivityService;
|
||||
import com.czg.market.service.MkLimitTimeDiscountService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -17,14 +19,17 @@ import java.time.LocalDateTime;
|
|||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DiscountActivityTask {
|
||||
public class ActivityStatusTask {
|
||||
@Resource
|
||||
private MkDiscountActivityService discountActivityService;
|
||||
@Resource
|
||||
private MkLimitTimeDiscountService limitTimeDiscountService;
|
||||
|
||||
/**
|
||||
* 满减活动 过期
|
||||
* 满减活动/限时折扣 任务状态更新任务
|
||||
*/
|
||||
public void task() {
|
||||
//满减活动
|
||||
discountActivityService.update(new MkDiscountActivity().setStatus(2),
|
||||
new QueryWrapper()
|
||||
.eq(MkDiscountActivity::getStatus, 1)
|
||||
|
|
@ -34,5 +39,17 @@ public class DiscountActivityTask {
|
|||
discountActivityService.update(new MkDiscountActivity().setStatus(3),
|
||||
new QueryWrapper().le(MkDiscountActivity::getValidEndTime, LocalDateTime.now())
|
||||
);
|
||||
|
||||
//限时折扣
|
||||
limitTimeDiscountService.update(new MkLimitTimeDiscount().setStatus(2),
|
||||
new QueryWrapper()
|
||||
.eq(MkLimitTimeDiscount::getStatus, 1)
|
||||
.le(MkLimitTimeDiscount::getValidStartTime, LocalDateTime.now())
|
||||
.gt(MkLimitTimeDiscount::getValidEndTime, LocalDateTime.now())
|
||||
);
|
||||
|
||||
limitTimeDiscountService.update(new MkLimitTimeDiscount().setStatus(3),
|
||||
new QueryWrapper().le(MkLimitTimeDiscount::getValidEndTime, LocalDateTime.now())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,9 +59,9 @@ public class ShopInfoEditDTO {
|
|||
*/
|
||||
private Integer isEnableDiscount;
|
||||
/**
|
||||
* 是否启用限时折扣 1-是 0-否
|
||||
* 点餐智能推荐 1-是 0-否
|
||||
*/
|
||||
private Integer isLimitTimeDiscount;
|
||||
private Integer isProductSuggest;
|
||||
/**
|
||||
* 台桌预订短信
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -47,10 +47,9 @@ public class ShopConfig implements Serializable {
|
|||
*/
|
||||
private Integer isEnableDiscount;
|
||||
/**
|
||||
* 是否启用限时折扣 1-是 0-否
|
||||
* 点餐智能推荐 1-是 0-否
|
||||
*/
|
||||
|
||||
private Integer isLimitTimeDiscount;
|
||||
private Integer isProductSuggest;
|
||||
/**
|
||||
* 是否允许账号登录 1-是 0-否
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -262,11 +262,12 @@ public class ShopInfo implements Serializable {
|
|||
*/
|
||||
@Column(ignore = true)
|
||||
private Integer isEnableDiscount;
|
||||
|
||||
/**
|
||||
* 是否启用限时折扣 1-是 0-否
|
||||
* 点餐智能推荐 1-是 0-否
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private Integer isLimitTimeDiscount;
|
||||
private Integer isProductSuggest;
|
||||
/**
|
||||
* 是否允许账号登录 1-是 0-否
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,105 @@
|
|||
|
||||
package com.czg.market.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Time;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.czg.validator.group.UpdateGroup;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 点单智能推荐 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-21
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class MkProductSmartSuggestDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 自增主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 商品集合
|
||||
*/
|
||||
@NotBlank(message = "商品集合不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
||||
private String foods;
|
||||
|
||||
/**
|
||||
* 自定义引导语
|
||||
*/
|
||||
private String guideDetail;
|
||||
|
||||
/**
|
||||
* 可用周期,如:周一,周二,周三,周四,周五,周六,周日
|
||||
*/
|
||||
@NotBlank(message = "可用周期不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
||||
private String useDays;
|
||||
|
||||
/**
|
||||
* 时间段类型:all-全时段,custom-指定时段
|
||||
*/
|
||||
@NotBlank(message = "时间段类型不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
||||
private String useTimeType;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private String useStartTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private String useEndTime;
|
||||
|
||||
/**
|
||||
* 状态:0禁用 1开启
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 0否1是
|
||||
*/
|
||||
private Boolean isDel;
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
|
@ -27,6 +28,7 @@ import java.time.LocalTime;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("mk_limit_time_discount")
|
||||
@Accessors(chain = true)
|
||||
public class MkLimitTimeDiscount implements Serializable {
|
||||
|
||||
@Serial
|
||||
|
|
|
|||
|
|
@ -0,0 +1,105 @@
|
|||
package com.czg.market.entity;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Time;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 点单智能推荐 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-21
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("mk_product_smart_suggest")
|
||||
public class MkProductSmartSuggest implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 自增主键
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 商品集合
|
||||
*/
|
||||
private String foods;
|
||||
|
||||
/**
|
||||
* 自定义引导语
|
||||
*/
|
||||
private String guideDetail;
|
||||
|
||||
/**
|
||||
* 可用周期,如:周一,周二,周三,周四,周五,周六,周日
|
||||
*/
|
||||
private String useDays;
|
||||
|
||||
/**
|
||||
* 时间段类型:all-全时段,custom-指定时段
|
||||
*/
|
||||
private String useTimeType;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@JSONField(format = "HH:mm")
|
||||
private Time useStartTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JSONField(format = "HH:mm")
|
||||
private Time useEndTime;
|
||||
|
||||
/**
|
||||
* 状态:0禁用 1开启
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 0否1是
|
||||
*/
|
||||
private Boolean isDel;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.czg.market.service;
|
||||
|
||||
import com.czg.BaseQueryParam;
|
||||
import com.czg.market.dto.MkProductSmartSuggestDTO;
|
||||
import com.czg.market.entity.MkProductSmartSuggest;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 点单智能推荐 服务层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-21
|
||||
*/
|
||||
public interface MkProductSmartSuggestService extends IService<MkProductSmartSuggest> {
|
||||
Page<MkProductSmartSuggestDTO> getProductSmartSuggestPage(BaseQueryParam param, Long shopId);
|
||||
|
||||
List<MkProductSmartSuggest> getProductSmartSuggestByShopId(Long shopId);
|
||||
|
||||
void addProductSmartSuggest(MkProductSmartSuggestDTO param);
|
||||
|
||||
void updateProductSmartSuggestById(MkProductSmartSuggestDTO param);
|
||||
|
||||
void deleteProductSmartSuggest(Long id);
|
||||
}
|
||||
|
|
@ -22,6 +22,10 @@ import java.util.List;
|
|||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class CheckOrderPay implements Serializable {
|
||||
|
||||
//限时折扣部分
|
||||
private LimitRateDTO limitRate;
|
||||
|
||||
/**
|
||||
* 是否霸王餐
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package com.czg.order.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 限时折扣dto
|
||||
* order专用 对应mk_limit_time_discount
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class LimitRateDTO {
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 折扣% 范围1-99
|
||||
*/
|
||||
private Integer discountRate;
|
||||
|
||||
/**
|
||||
* 折扣优先级 limit-time/vip-price
|
||||
*/
|
||||
private String discountPriority;
|
||||
|
||||
/**
|
||||
* 参与商品 1全部 2部分
|
||||
*/
|
||||
private Integer foodType;
|
||||
|
||||
/**
|
||||
* 参与商品
|
||||
*/
|
||||
private String foods;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.czg.service.market.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.market.entity.MkProductSmartSuggest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 点单智能推荐 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-21
|
||||
*/
|
||||
public interface MkProductSmartSuggestMapper extends BaseMapper<MkProductSmartSuggest> {
|
||||
|
||||
/**
|
||||
* 根据店铺ID查询智能推荐
|
||||
* @param shopId 店铺ID
|
||||
* @param week 周几
|
||||
* @return 智能推荐列表
|
||||
*/
|
||||
List<MkProductSmartSuggest> selectListByShopId(Long shopId, String week);
|
||||
}
|
||||
|
|
@ -61,11 +61,6 @@ public class MkLimitTimeDiscountServiceImpl extends ServiceImpl<MkLimitTimeDisco
|
|||
|
||||
@Override
|
||||
public MkLimitTimeDiscount getLimitTimeDiscountByShopId(Long shopId) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(shopId);
|
||||
AssertUtil.isNull(shopInfo, "店铺不存在");
|
||||
if (shopInfo.getIsLimitTimeDiscount() == null || shopInfo.getIsLimitTimeDiscount() == 0) {
|
||||
return null;
|
||||
}
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
return mapper.selectOneByShopId(mainShopId, shopId, CzgStrUtils.getStrWeek());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
package com.czg.service.market.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.BaseQueryParam;
|
||||
import com.czg.TimeQueryParam;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.market.dto.MkProductSmartSuggestDTO;
|
||||
import com.czg.market.dto.MkProductSmartSuggestDTO;
|
||||
import com.czg.market.entity.MkLimitTimeDiscount;
|
||||
import com.czg.market.entity.MkProductSmartSuggest;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.CzgStrUtils;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.market.entity.MkProductSmartSuggest;
|
||||
import com.czg.market.service.MkProductSmartSuggestService;
|
||||
import com.czg.service.market.mapper.MkProductSmartSuggestMapper;
|
||||
import org.apache.catalina.LifecycleState;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 点单智能推荐 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-21
|
||||
*/
|
||||
@Service
|
||||
public class MkProductSmartSuggestServiceImpl extends ServiceImpl<MkProductSmartSuggestMapper, MkProductSmartSuggest> implements MkProductSmartSuggestService {
|
||||
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
|
||||
@Override
|
||||
public Page<MkProductSmartSuggestDTO> getProductSmartSuggestPage(BaseQueryParam param, Long shopId) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq(MkProductSmartSuggest::getShopId, shopId)
|
||||
.eq(MkProductSmartSuggest::getIsDel, 0)
|
||||
.orderBy(MkProductSmartSuggest::getUpdateTime).desc();
|
||||
return pageAs(PageUtil.buildPage(), queryWrapper, MkProductSmartSuggestDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MkProductSmartSuggest> getProductSmartSuggestByShopId(Long shopId) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(shopId);
|
||||
AssertUtil.isNull(shopInfo, "店铺不存在");
|
||||
if (shopInfo.getIsProductSuggest() == null || shopInfo.getIsProductSuggest() == 0) {
|
||||
return null;
|
||||
}
|
||||
return mapper.selectListByShopId(shopId, CzgStrUtils.getStrWeek());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProductSmartSuggest(MkProductSmartSuggestDTO param) {
|
||||
param.setIsDel(false);
|
||||
MkProductSmartSuggest activity = BeanUtil.toBean(param, MkProductSmartSuggest.class);
|
||||
save(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProductSmartSuggestById(MkProductSmartSuggestDTO param) {
|
||||
param.setIsDel(false);
|
||||
MkProductSmartSuggest suggest = BeanUtil.toBean(param, MkProductSmartSuggest.class);
|
||||
updateById(suggest, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProductSmartSuggest(Long id) {
|
||||
MkProductSmartSuggest suggest = new MkProductSmartSuggest();
|
||||
suggest.setId(id);
|
||||
suggest.setIsDel(true);
|
||||
updateById(suggest, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
AND NOW() BETWEEN valid_start_time AND valid_end_time
|
||||
AND (use_time_type = 'all' OR
|
||||
(use_time_type = 'custom' AND TIME(NOW()) BETWEEN use_start_time AND use_end_time))
|
||||
AND use_days LIKE CONCAT('%', #{useDay}, '%')
|
||||
AND FIND_IN_SET(#{useDay}, use_days) > 0
|
||||
ORDER BY sort,
|
||||
update_time DESC,
|
||||
create_time DESC
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.market.mapper.MkProductSmartSuggestMapper">
|
||||
<select id="selectListByShopId" resultType="com.czg.market.entity.MkProductSmartSuggest">
|
||||
SELECT *
|
||||
FROM mk_product_smart_suggest
|
||||
WHERE shop_id = #{shopId}
|
||||
AND is_del = 0
|
||||
AND status = 1
|
||||
AND NOW() BETWEEN valid_start_time AND valid_end_time
|
||||
AND (use_time_type = 'all' OR
|
||||
(use_time_type = 'custom' AND TIME(NOW()) BETWEEN use_start_time AND use_end_time))
|
||||
AND FIND_IN_SET(#{week}, use_days) > 0
|
||||
ORDER BY sort,
|
||||
update_time DESC,
|
||||
create_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue