1.通知中心相关接口

2.代客下单
This commit is contained in:
2024-08-12 14:55:21 +08:00
parent 220c717085
commit 0e9996bcf0
40 changed files with 1355 additions and 59 deletions

View File

@@ -1,15 +1,19 @@
package cn.ysk.cashier.utils;
import cn.ysk.cashier.enums.ShopWxMsgTypeEnum;
import cn.ysk.cashier.mybatis.entity.TbShopMsgState;
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
import cn.ysk.cashier.mybatis.service.TbShopMsgStateService;
import cn.ysk.cashier.mybatis.service.TbShopOpenIdService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.function.Consumer;
@Component
@Slf4j
@@ -20,14 +24,22 @@ public class WxMsgUtils {
private final RedisUtils redisUtils;
private final WxAccountUtil wxAccountUtil;
private final TbShopMsgStateService shopMsgStateService;
public WxMsgUtils(TbShopOpenIdService tbShopOpenIdService, RedisUtils redisUtils, WxAccountUtil wxAccountUtil) {
public WxMsgUtils(TbShopOpenIdService tbShopOpenIdService, RedisUtils redisUtils, WxAccountUtil wxAccountUtil, TbShopMsgStateService shopMsgStateService) {
this.tbShopOpenIdService = tbShopOpenIdService;
this.redisUtils = redisUtils;
this.wxAccountUtil = wxAccountUtil;
this.shopMsgStateService = shopMsgStateService;
}
public void aboardOperationMsg(String operationDesc) {
public void aboardOperationMsg(String operationDesc, Integer shopId1) {
TbShopMsgState msgState = shopMsgStateService.lambdaQuery().eq(TbShopMsgState::getShopId, shopId1)
.eq(TbShopMsgState::getType, 2).one();
if (msgState == null || msgState.getState().equals(0)) {
log.info("店铺未开启推送");
return;
}
HttpServletRequest request = RequestHolder.getHttpServletRequest();
Object o = redisUtils.get("online-token-"+getToken(request));
@@ -39,7 +51,12 @@ public class WxMsgUtils {
jsonObject = JSONObject.parseObject(jsonString);
shopId = (Integer) jsonObject.get("shopId");
nickName = jsonObject.get("nickName") == null ? "" : jsonObject.get("nickName").toString();
List<TbShopOpenId> openIds = tbShopOpenIdService.lambdaQuery().eq(TbShopOpenId::getShopId, shopId).list();
List<TbShopOpenId> openIds = tbShopOpenIdService.lambdaQuery()
.eq(TbShopOpenId::getShopId, shopId)
.eq(TbShopOpenId::getStatus, 1)
.and((queryWrapper) -> queryWrapper.eq(TbShopOpenId::getType, ShopWxMsgTypeEnum.ALL_MSG.getType())
.or().eq(TbShopOpenId::getType, ShopWxMsgTypeEnum.OPERATION_MSG.getType()))
.list();
log.info("即将开始推送敏感操作消息, 接收推送openId列表: {}", openIds);
String finalNickName = nickName;
wxAccountUtil.sendOperationMsg(openIds, finalNickName, operationDesc);