1.消息推送修改
This commit is contained in:
@@ -220,9 +220,7 @@ 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缺失");
|
||||||
}
|
}
|
||||||
String msg = wxMsgSubDTO.getShopId().replace("msg", "");
|
loginService.addShopId(wxMsgSubDTO.getOpenId(), wxMsgSubDTO.getShopId(), null, wxMsgSubDTO.getNickname(), wxMsgSubDTO.getAvatar());
|
||||||
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,7 +156,9 @@ public class UserContoller {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/subQrCode")
|
@GetMapping("/subQrCode")
|
||||||
public Result getSubQrCode(String shopId) throws Exception {
|
public Result getSubQrCode(
|
||||||
|
@RequestParam String shopId
|
||||||
|
) throws Exception {
|
||||||
String url = userService.getSubQrCode(shopId);
|
String url = userService.getSubQrCode(shopId);
|
||||||
return Result.successWithData(url);
|
return Result.successWithData(url);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,4 +38,16 @@ 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);")
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ 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;
|
||||||
@@ -336,11 +337,11 @@ 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.selectByShopId(Integer.valueOf(product.getShopId()));
|
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType());
|
||||||
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());
|
, 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);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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;
|
||||||
@@ -60,32 +61,61 @@ 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 type, String nickName, String avatar) {
|
public void addShopId(String openId, String shopId, Integer type1, String nickName, String avatar) {
|
||||||
// 为商家绑定openid
|
// 为商家绑定openid
|
||||||
TbShopOpenId tbShopOpenId = shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId), type);
|
// TbShopOpenId tbShopOpenId = shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId), null);
|
||||||
if (tbShopOpenId == null) {
|
List<TbShopOpenId> shopOpenIdList = shopOpenIdMapper.selectStateByShopIdAndOpenId(openId, shopId);
|
||||||
TbShopOpenId shopOpenId = new TbShopOpenId();
|
int openCount = shopOpenIdMapper.selectStateByShopId(shopId);
|
||||||
shopOpenId.setOpenId(openId);
|
|
||||||
shopOpenId.setCreateTime(DateUtil.date());
|
if (shopOpenIdList.isEmpty()) {
|
||||||
shopOpenId.setShopId(Integer.valueOf(shopId));
|
for (int type : MSG_TYPE_LIST) {
|
||||||
shopOpenId.setStatus(1);
|
addShopOpenId(openId, shopId, nickName, avatar, openCount, type);
|
||||||
shopOpenId.setNickname(nickName);
|
}
|
||||||
shopOpenId.setAvatar(avatar);
|
|
||||||
shopOpenId.setType(type == null ? -1 : type);
|
|
||||||
shopOpenIdMapper.insert(shopOpenId);
|
|
||||||
} else {
|
} else {
|
||||||
tbShopOpenId.setUpdateTime(DateUtil.date());
|
boolean fullSize = shopOpenIdList.size() == MSG_TYPE_LIST.length;
|
||||||
tbShopOpenId.setNickname(nickName);
|
HashMap<String, Object> typeMap = new HashMap<>();
|
||||||
tbShopOpenId.setAvatar(avatar);
|
for (TbShopOpenId tbShopOpenId : shopOpenIdList) {
|
||||||
shopOpenIdMapper.updateByPrimaryKeySelective(tbShopOpenId);
|
typeMap.put(tbShopOpenId.getType().toString(), tbShopOpenId.getOpenId());
|
||||||
|
tbShopOpenId.setType(null);
|
||||||
|
tbShopOpenId.setUpdateTime(DateUtil.date());
|
||||||
|
tbShopOpenId.setNickname(nickName);
|
||||||
|
tbShopOpenId.setAvatar(avatar);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Result wxBusinessLogin(String openId, String shopId) {
|
public Result wxBusinessLogin(String openId, String shopId) {
|
||||||
TbUserShopMsg shopMsg = tbUserShopMsgMapper.selectByShopIdAndOpenId(Integer.valueOf(shopId), openId);
|
TbUserShopMsg shopMsg = tbUserShopMsgMapper.selectByShopIdAndOpenId(Integer.valueOf(shopId), openId);
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.service;
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
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.*;
|
||||||
@@ -13,9 +10,6 @@ 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;
|
||||||
@@ -23,14 +17,11 @@ 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;
|
||||||
@@ -264,7 +255,9 @@ 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();
|
||||||
QrCodeUtil.generate(wxAccountUtil.getRadarQrCode(Integer.valueOf(shopId), -1), new QrConfig(500, 500).
|
// String url = wxAccountUtil.getRadarQrCode(Integer.valueOf(shopId), -1);
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user