Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 538fc8f91b |
@@ -220,7 +220,9 @@ public class CommonController {
|
|||||||
if (wxMsgSubDTO.getOpenId() == null || wxMsgSubDTO.getShopId() == null) {
|
if (wxMsgSubDTO.getOpenId() == null || wxMsgSubDTO.getShopId() == null) {
|
||||||
return Result.fail("shopId或openId缺失");
|
return Result.fail("shopId或openId缺失");
|
||||||
}
|
}
|
||||||
loginService.addShopId(wxMsgSubDTO.getOpenId(), wxMsgSubDTO.getShopId(), null, wxMsgSubDTO.getNickname(), wxMsgSubDTO.getAvatar());
|
String msg = wxMsgSubDTO.getShopId().replace("msg", "");
|
||||||
|
String[] split = msg.split(",");
|
||||||
|
loginService.addShopId(wxMsgSubDTO.getOpenId(), split[0], split.length > 1 ? Integer.valueOf(split[1]) : null, wxMsgSubDTO.getNickname(), wxMsgSubDTO.getAvatar());
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,9 +156,7 @@ public class UserContoller {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/subQrCode")
|
@GetMapping("/subQrCode")
|
||||||
public Result getSubQrCode(
|
public Result getSubQrCode(String shopId) throws Exception {
|
||||||
@RequestParam String shopId
|
|
||||||
) throws Exception {
|
|
||||||
String url = userService.getSubQrCode(shopId);
|
String url = userService.getSubQrCode(shopId);
|
||||||
return Result.successWithData(url);
|
return Result.successWithData(url);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,16 +38,4 @@ public interface TbShopOpenIdMapper {
|
|||||||
|
|
||||||
@Update("update tb_shop_open_id set nickname=#{nickName}, avatar=#{avatar} where open_id=#{openId} and status=1 ")
|
@Update("update tb_shop_open_id set nickname=#{nickName}, avatar=#{avatar} where open_id=#{openId} and status=1 ")
|
||||||
int updateBaseInfoByOpenId(@Param("openId") String openId, @Param("nickName") String nickName, @Param("avatar") String avatar);
|
int updateBaseInfoByOpenId(@Param("openId") String openId, @Param("nickName") String nickName, @Param("avatar") String avatar);
|
||||||
|
|
||||||
@Select("select count(*) from tb_shop_open_id where shop_id=#{shopId} and status=1;")
|
|
||||||
int selectStateByShopId(@Param("shopId") String shopId);
|
|
||||||
|
|
||||||
@Select("select count(*) from tb_shop_open_id where shop_id=#{shopId} and status=1 and type=#{type};")
|
|
||||||
int countStateByShopIdAndType(@Param("shopId") String shopId, @Param("type") int type);
|
|
||||||
|
|
||||||
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1 and (type=#{type} or type=-1) group by open_id;")
|
|
||||||
List<TbShopOpenId> selectStateByShopIdAndType(@Param("shopId") String shopId, @Param("type") int type);
|
|
||||||
|
|
||||||
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and open_id=#{openId};")
|
|
||||||
List<TbShopOpenId> selectStateByShopIdAndOpenId(@Param("openId") String openId, @Param("shopId") String shopId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.entity.Enum;
|
|
||||||
|
|
||||||
public enum ShopWxMsgTypeEnum {
|
|
||||||
ALL_MSG(-1),
|
|
||||||
STOCK_MSG(0),
|
|
||||||
CONSUMABLES_MSG(1),
|
|
||||||
OPERATION_MSG(2);
|
|
||||||
private final Integer type;
|
|
||||||
|
|
||||||
ShopWxMsgTypeEnum(Integer type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.entity;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @TableName tb_shop_msg_state
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class TbShopMsgState implements Serializable {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private Integer shopId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private Integer state;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object that) {
|
|
||||||
if (this == that) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (that == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != that.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
TbShopMsgState other = (TbShopMsgState) that;
|
|
||||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
|
||||||
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
|
|
||||||
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
|
|
||||||
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
|
|
||||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
|
||||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
|
||||||
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
|
|
||||||
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
|
|
||||||
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
|
|
||||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
|
||||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(getClass().getSimpleName());
|
|
||||||
sb.append(" [");
|
|
||||||
sb.append("Hash = ").append(hashCode());
|
|
||||||
sb.append(", id=").append(id);
|
|
||||||
sb.append(", shopId=").append(shopId);
|
|
||||||
sb.append(", type=").append(type);
|
|
||||||
sb.append(", state=").append(state);
|
|
||||||
sb.append(", createTime=").append(createTime);
|
|
||||||
sb.append(", updateTime=").append(updateTime);
|
|
||||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.mapper;
|
|
||||||
|
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbShopMsgState;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Administrator
|
|
||||||
* @description 针对表【tb_shop_msg_state】的数据库操作Mapper
|
|
||||||
* @createDate 2024-08-12 14:38:33
|
|
||||||
* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopMsgState
|
|
||||||
*/
|
|
||||||
public interface TbShopMsgStateMapper {
|
|
||||||
|
|
||||||
int deleteByPrimaryKey(Long id);
|
|
||||||
|
|
||||||
int insert(TbShopMsgState record);
|
|
||||||
|
|
||||||
int insertSelective(TbShopMsgState record);
|
|
||||||
|
|
||||||
TbShopMsgState selectByPrimaryKey(Long id);
|
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(TbShopMsgState record);
|
|
||||||
|
|
||||||
int updateByPrimaryKey(TbShopMsgState record);
|
|
||||||
|
|
||||||
@Select("select * from tb_shop_msg_state where shop_id=#{shopId} and type=#{type};")
|
|
||||||
TbShopMsgState selectByType(Integer type, Integer shopId);
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum;
|
|
||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
import com.chaozhanggui.system.cashierservice.netty.PushToAppChannelHandlerAdapter;
|
import com.chaozhanggui.system.cashierservice.netty.PushToAppChannelHandlerAdapter;
|
||||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||||
@@ -337,13 +336,13 @@ public class CartService {
|
|||||||
(product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine())
|
(product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine())
|
||||||
|| (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine()
|
|| (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine()
|
||||||
) {
|
) {
|
||||||
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType());
|
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectByShopId(Integer.valueOf(product.getShopId()));
|
||||||
shopOpenIds.forEach(item -> {
|
shopOpenIds.forEach(item -> {
|
||||||
String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId());
|
String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId());
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
|
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
|
||||||
product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num)
|
product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num)
|
||||||
, item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopInfo.getId());
|
, item.getOpenId());
|
||||||
redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L);
|
redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L);
|
||||||
}else {
|
}else {
|
||||||
log.info("{}已在30分钟内推送过消息,跳过发送", item.getOpenId());
|
log.info("{}已在30分钟内推送过消息,跳过发送", item.getOpenId());
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.service;
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@@ -61,59 +60,41 @@ public class LoginService {
|
|||||||
|
|
||||||
private final TbShopOpenIdMapper shopOpenIdMapper;
|
private final TbShopOpenIdMapper shopOpenIdMapper;
|
||||||
|
|
||||||
private final static int[] MSG_TYPE_LIST = new int[] {0, 1, 2};
|
|
||||||
|
|
||||||
public LoginService(TbShopOpenIdMapper shopOpenIdMapper) {
|
public LoginService(TbShopOpenIdMapper shopOpenIdMapper) {
|
||||||
this.shopOpenIdMapper = shopOpenIdMapper;
|
this.shopOpenIdMapper = shopOpenIdMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addShopId(String openId, String shopId, Integer type1, String nickName, String avatar) {
|
public void addShopId(String openId, String shopId, Integer type, String nickName, String avatar) {
|
||||||
// 为商家绑定openid
|
TbUserShopMsg shopMsg = tbUserShopMsgMapper.selectByShopIdAndOpenId(Integer.valueOf(shopId), openId);
|
||||||
// TbShopOpenId tbShopOpenId = shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId), null);
|
if (Objects.isNull(shopMsg)) {
|
||||||
List<TbShopOpenId> shopOpenIdList = shopOpenIdMapper.selectStateByShopIdAndOpenId(openId, shopId);
|
shopMsg = new TbUserShopMsg();
|
||||||
int openCount = shopOpenIdMapper.selectStateByShopId(shopId);
|
shopMsg.setShopId(Integer.valueOf(shopId));
|
||||||
|
shopMsg.setOpenId(openId);
|
||||||
if (shopOpenIdList.isEmpty()) {
|
shopMsg.setCreateTime(new Date());
|
||||||
for (int type : MSG_TYPE_LIST) {
|
shopMsg.setStatus("1");
|
||||||
addShopOpenId(openId, shopId, nickName, avatar, openCount, type);
|
tbUserShopMsgMapper.insert(shopMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 为商家绑定openid
|
||||||
|
TbShopOpenId tbShopOpenId = shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId), type);
|
||||||
|
if (tbShopOpenId == null) {
|
||||||
|
TbShopOpenId shopOpenId = new TbShopOpenId();
|
||||||
|
shopOpenId.setOpenId(openId);
|
||||||
|
shopOpenId.setCreateTime(DateUtil.date());
|
||||||
|
shopOpenId.setShopId(Integer.valueOf(shopId));
|
||||||
|
shopOpenId.setStatus(1);
|
||||||
|
shopOpenId.setNickname(nickName);
|
||||||
|
shopOpenId.setAvatar(avatar);
|
||||||
|
shopOpenId.setType(type == null ? -1 : type);
|
||||||
|
shopOpenIdMapper.insert(shopOpenId);
|
||||||
} else {
|
} else {
|
||||||
boolean fullSize = shopOpenIdList.size() == MSG_TYPE_LIST.length;
|
|
||||||
HashMap<String, Object> typeMap = new HashMap<>();
|
|
||||||
for (TbShopOpenId tbShopOpenId : shopOpenIdList) {
|
|
||||||
typeMap.put(tbShopOpenId.getType().toString(), tbShopOpenId.getOpenId());
|
|
||||||
tbShopOpenId.setType(null);
|
|
||||||
tbShopOpenId.setUpdateTime(DateUtil.date());
|
tbShopOpenId.setUpdateTime(DateUtil.date());
|
||||||
tbShopOpenId.setNickname(nickName);
|
tbShopOpenId.setNickname(nickName);
|
||||||
tbShopOpenId.setAvatar(avatar);
|
tbShopOpenId.setAvatar(avatar);
|
||||||
shopOpenIdMapper.updateByPrimaryKeySelective(tbShopOpenId);
|
shopOpenIdMapper.updateByPrimaryKeySelective(tbShopOpenId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullSize) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int type : MSG_TYPE_LIST) {
|
|
||||||
if (typeMap.get(String.valueOf(type)) == null) {
|
|
||||||
addShopOpenId(openId, shopId, nickName, avatar, openCount, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addShopOpenId(String openId, String shopId, String nickName, String avatar, int openCount, int type) {
|
|
||||||
int count = shopOpenIdMapper.countStateByShopIdAndType(shopId, type);
|
|
||||||
TbShopOpenId shopOpenId = new TbShopOpenId();
|
|
||||||
shopOpenId.setOpenId(openId);
|
|
||||||
shopOpenId.setCreateTime(DateUtil.date());
|
|
||||||
shopOpenId.setShopId(Integer.valueOf(shopId));
|
|
||||||
shopOpenId.setStatus(openCount > 0 ? count > 0 ? 1 : 0 : 0);
|
|
||||||
shopOpenId.setNickname(nickName);
|
|
||||||
shopOpenId.setAvatar(avatar);
|
|
||||||
shopOpenId.setType(type);
|
|
||||||
shopOpenIdMapper.insert(shopOpenId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.service;
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||||
import cn.hutool.extra.qrcode.QrConfig;
|
import cn.hutool.extra.qrcode.QrConfig;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
@@ -10,6 +13,9 @@ import com.chaozhanggui.system.cashierservice.entity.vo.IntegralFlowVo;
|
|||||||
import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo;
|
import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo;
|
||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||||
|
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.*;
|
import com.chaozhanggui.system.cashierservice.util.*;
|
||||||
import com.chaozhanggui.system.cashierservice.wxUtil.WxAccountUtil;
|
import com.chaozhanggui.system.cashierservice.wxUtil.WxAccountUtil;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
@@ -17,11 +23,14 @@ import com.github.pagehelper.PageInfo;
|
|||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.ResourceLoader;
|
import org.springframework.core.io.ResourceLoader;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -255,9 +264,7 @@ public class UserService {
|
|||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
Resource resource = resourceLoader.getResource("classpath:/static/logo.jpg");
|
Resource resource = resourceLoader.getResource("classpath:/static/logo.jpg");
|
||||||
InputStream inputStream = resource.getInputStream();
|
InputStream inputStream = resource.getInputStream();
|
||||||
// String url = wxAccountUtil.getRadarQrCode(Integer.valueOf(shopId), -1);
|
QrCodeUtil.generate(wxAccountUtil.getRadarQrCode(Integer.valueOf(shopId), -1), new QrConfig(500, 500).
|
||||||
String url = StrUtil.format("https://invoice.sxczgkj.cn/index/wechat/weuserk?shopId={}", shopId);
|
|
||||||
QrCodeUtil.generate(url, new QrConfig(500, 500).
|
|
||||||
setImg(ImageIO.read(inputStream)).setErrorCorrection(ErrorCorrectionLevel.H).setRatio(4), "png", outputStream);
|
setImg(ImageIO.read(inputStream)).setErrorCorrection(ErrorCorrectionLevel.H).setRatio(4), "png", outputStream);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ import cn.hutool.extra.qrcode.QrCodeUtil;
|
|||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum;
|
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbShopMsgState;
|
|
||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
import com.chaozhanggui.system.cashierservice.mapper.TbShopMsgStateMapper;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -30,8 +27,6 @@ public class WxAccountUtil {
|
|||||||
@Value("${wx.ysk.warnMsgTmpId}")
|
@Value("${wx.ysk.warnMsgTmpId}")
|
||||||
private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0";
|
private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0";
|
||||||
|
|
||||||
private final TbShopMsgStateMapper shopMsgStateMapper;
|
|
||||||
|
|
||||||
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -103,13 +98,7 @@ public class WxAccountUtil {
|
|||||||
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId, ShopWxMsgTypeEnum typeEnum, Integer shopId) {
|
public static JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId) {
|
||||||
TbShopMsgState shopMsgState = shopMsgStateMapper.selectByType(typeEnum.getType(), shopId);
|
|
||||||
if (shopMsgState == null || shopMsgState.getState().equals(0)) {
|
|
||||||
log.info("店铺未开启推送:{}", shopMsgState);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
stock = stock < 0 ? 0 : stock;
|
stock = stock < 0 ? 0 : stock;
|
||||||
Integer finalStock = stock;
|
Integer finalStock = stock;
|
||||||
Map<String, Object> data = new HashMap<String, Object>() {{
|
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
<?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.chaozhanggui.system.cashierservice.mapper.TbShopMsgStateMapper">
|
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState">
|
|
||||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
|
||||||
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
|
||||||
<result property="type" column="type" jdbcType="INTEGER"/>
|
|
||||||
<result property="state" column="state" jdbcType="INTEGER"/>
|
|
||||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
||||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
|
||||||
id,shop_id,type,
|
|
||||||
state,create_time,update_time
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
|
||||||
select
|
|
||||||
<include refid="Base_Column_List" />
|
|
||||||
from tb_shop_msg_state
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
|
||||||
delete from tb_shop_msg_state
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</delete>
|
|
||||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState" useGeneratedKeys="true">
|
|
||||||
insert into tb_shop_msg_state
|
|
||||||
( id,shop_id,type
|
|
||||||
,state,create_time,update_time
|
|
||||||
)
|
|
||||||
values (#{id,jdbcType=INTEGER},#{shopId,jdbcType=INTEGER},#{type,jdbcType=INTEGER}
|
|
||||||
,#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState" useGeneratedKeys="true">
|
|
||||||
insert into tb_shop_msg_state
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="id != null">id,</if>
|
|
||||||
<if test="shopId != null">shop_id,</if>
|
|
||||||
<if test="type != null">type,</if>
|
|
||||||
<if test="state != null">state,</if>
|
|
||||||
<if test="createTime != null">create_time,</if>
|
|
||||||
<if test="updateTime != null">update_time,</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="id != null">#{id,jdbcType=INTEGER},</if>
|
|
||||||
<if test="shopId != null">#{shopId,jdbcType=INTEGER},</if>
|
|
||||||
<if test="type != null">#{type,jdbcType=INTEGER},</if>
|
|
||||||
<if test="state != null">#{state,jdbcType=INTEGER},</if>
|
|
||||||
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
|
||||||
<if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState">
|
|
||||||
update tb_shop_msg_state
|
|
||||||
<set>
|
|
||||||
<if test="shopId != null">
|
|
||||||
shop_id = #{shopId,jdbcType=INTEGER},
|
|
||||||
</if>
|
|
||||||
<if test="type != null">
|
|
||||||
type = #{type,jdbcType=INTEGER},
|
|
||||||
</if>
|
|
||||||
<if test="state != null">
|
|
||||||
state = #{state,jdbcType=INTEGER},
|
|
||||||
</if>
|
|
||||||
<if test="createTime != null">
|
|
||||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
|
||||||
</if>
|
|
||||||
<if test="updateTime != null">
|
|
||||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
|
||||||
</if>
|
|
||||||
</set>
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</update>
|
|
||||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState">
|
|
||||||
update tb_shop_msg_state
|
|
||||||
set
|
|
||||||
shop_id = #{shopId,jdbcType=INTEGER},
|
|
||||||
type = #{type,jdbcType=INTEGER},
|
|
||||||
state = #{state,jdbcType=INTEGER},
|
|
||||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
|
||||||
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</update>
|
|
||||||
</mapper>
|
|
||||||
Reference in New Issue
Block a user