叫号微信小程序模板消息实现
This commit is contained in:
@@ -19,6 +19,7 @@ import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.service.app.TbCallService;
|
||||
import cn.ysk.cashier.utils.Utils;
|
||||
import cn.ysk.cashier.utils.WxMiniUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -41,6 +42,7 @@ public class TbCallServiceImpl implements TbCallService {
|
||||
private final TbShopInfoRepository shopInfoRepository;
|
||||
private final StringRedisTemplate redisTemplate;
|
||||
private final TbCallQueueMapper tbCallQueueMapper;
|
||||
private final WxMiniUtils wxMiniUtils;
|
||||
|
||||
@Override
|
||||
public Object add(CallTableDTO addCallTableDTO) {
|
||||
@@ -201,9 +203,50 @@ public class TbCallServiceImpl implements TbCallService {
|
||||
|
||||
// 发送模板消息通知用户
|
||||
|
||||
TbShopInfo shopInfo = shopInfoRepository.findById(callQueue.getShopId()).orElse(null);
|
||||
if (shopInfo == null) {
|
||||
throw new BadRequestException("店铺信息不存在");
|
||||
}
|
||||
|
||||
List<TbCallQueue> current = callQueueService.lambdaQuery()
|
||||
.eq(TbCallQueue::getCallTableId, callQueue.getCallTableId())
|
||||
.and(r -> {
|
||||
r.eq(TbCallQueue::getState, 1)
|
||||
.or()
|
||||
.eq(TbCallQueue::getState, 0);
|
||||
})
|
||||
.orderByAsc(TbCallQueue::getCreateTime)
|
||||
.page(new Page<>(1, 1)).getRecords();
|
||||
|
||||
if (StrUtil.isBlank(callQueue.getOpenId())) {
|
||||
throw new BadRequestException("此用户未订阅微信小程序消息");
|
||||
}
|
||||
|
||||
wxMiniUtils.sendNearCallMsg(shopInfo.getShopName(), getStrByState(Integer.valueOf(callQueue.getState())),
|
||||
callQueue.getCallNum(), current.isEmpty() ? "" : current.get(0).getCallNum(), "排号信息", callQueue.getOpenId());
|
||||
|
||||
return callQueueService.updateById(callQueue);
|
||||
}
|
||||
|
||||
private String getStrByState(Integer state) {
|
||||
String msg = "";
|
||||
switch (state) {
|
||||
case -1:
|
||||
msg = "已取消";
|
||||
break;
|
||||
case 0:
|
||||
msg = "排队中";
|
||||
break;
|
||||
case 1:
|
||||
msg = "已到号";
|
||||
break;
|
||||
case 3:
|
||||
msg = "已过号";
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object updateInfo(UpdateCallQueueDTO updateCallQueueDTO) {
|
||||
TbCallQueue callQueue = callQueueService.lambdaQuery()
|
||||
|
||||
Reference in New Issue
Block a user