From dc291231eed95890be780cb46a7aee518b801933 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 9 Aug 2024 16:42:17 +0800 Subject: [PATCH 01/18] =?UTF-8?q?1.=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CommonController.java | 4 +- .../controller/UserContoller.java | 4 +- .../dao/TbShopOpenIdMapper.java | 12 ++++ .../entity/Enum/ShopWxMsgTypeEnum.java | 17 +++++ .../cashierservice/service/CartService.java | 5 +- .../cashierservice/service/LoginService.java | 62 ++++++++++++++----- .../cashierservice/service/UserService.java | 15 ++--- 7 files changed, 86 insertions(+), 33 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopWxMsgTypeEnum.java diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java index 1c0f114..83211ee 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java @@ -220,9 +220,7 @@ public class CommonController { if (wxMsgSubDTO.getOpenId() == null || wxMsgSubDTO.getShopId() == null) { return Result.fail("shopId或openId缺失"); } - 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()); + loginService.addShopId(wxMsgSubDTO.getOpenId(), wxMsgSubDTO.getShopId(), null, wxMsgSubDTO.getNickname(), wxMsgSubDTO.getAvatar()); return Result.success(CodeEnum.SUCCESS); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index fcd72ad..28cce38 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -156,7 +156,9 @@ public class UserContoller { * @return */ @GetMapping("/subQrCode") - public Result getSubQrCode(String shopId) throws Exception { + public Result getSubQrCode( + @RequestParam String shopId + ) throws Exception { String url = userService.getSubQrCode(shopId); return Result.successWithData(url); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java index 8d875e1..8e6a0f1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java @@ -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 ") 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 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 selectStateByShopIdAndOpenId(@Param("openId") String openId, @Param("shopId") String shopId); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopWxMsgTypeEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopWxMsgTypeEnum.java new file mode 100644 index 0000000..766e548 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopWxMsgTypeEnum.java @@ -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; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index a967298..81409f7 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; 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.netty.PushToAppChannelHandlerAdapter; 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) && productSku.getStockNumber() - num <= productSku.getWarnLine() ) { - List shopOpenIds = shopOpenIdMapper.selectByShopId(Integer.valueOf(product.getShopId())); + List shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType()); shopOpenIds.forEach(item -> { String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId()); if (message == null) { - wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), + WxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num) , item.getOpenId()); redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index ada1443..c9194ed 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -1,6 +1,7 @@ package com.chaozhanggui.system.cashierservice.service; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; @@ -60,32 +61,61 @@ public class LoginService { private final TbShopOpenIdMapper shopOpenIdMapper; + private final static int[] MSG_TYPE_LIST = new int[] {0, 1, 2}; + public LoginService(TbShopOpenIdMapper 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 - 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); +// TbShopOpenId tbShopOpenId = shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId), null); + List shopOpenIdList = shopOpenIdMapper.selectStateByShopIdAndOpenId(openId, shopId); + int openCount = shopOpenIdMapper.selectStateByShopId(shopId); + + if (shopOpenIdList.isEmpty()) { + for (int type : MSG_TYPE_LIST) { + addShopOpenId(openId, shopId, nickName, avatar, openCount, type); + } + } else { - tbShopOpenId.setUpdateTime(DateUtil.date()); - tbShopOpenId.setNickname(nickName); - tbShopOpenId.setAvatar(avatar); - shopOpenIdMapper.updateByPrimaryKeySelective(tbShopOpenId); + boolean fullSize = shopOpenIdList.size() == MSG_TYPE_LIST.length; + HashMap typeMap = new HashMap<>(); + for (TbShopOpenId tbShopOpenId : shopOpenIdList) { + 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) { TbUserShopMsg shopMsg = tbUserShopMsgMapper.selectByShopIdAndOpenId(Integer.valueOf(shopId), openId); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java index 0c11041..47dbcff 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java @@ -1,11 +1,8 @@ package com.chaozhanggui.system.cashierservice.service; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.extra.qrcode.QrConfig; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; 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.exception.MsgException; 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.wxUtil.WxAccountUtil; import com.github.pagehelper.PageHelper; @@ -23,14 +17,11 @@ import com.github.pagehelper.PageInfo; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import org.springframework.beans.factory.annotation.Autowired; 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.ResourceLoader; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -264,7 +255,9 @@ public class UserService { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Resource resource = resourceLoader.getResource("classpath:/static/logo.jpg"); 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); From bee86bbb738b194d6df15cb85e1c4392c87685a7 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Tue, 13 Aug 2024 09:44:39 +0800 Subject: [PATCH 02/18] =?UTF-8?q?1.=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=BA=97=E9=93=BA=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/entity/TbShopMsgState.java | 94 +++++++++++++++++++ .../mapper/TbShopMsgStateMapper.java | 28 ++++++ .../cashierservice/service/CartService.java | 4 +- .../cashierservice/wxUtil/WxAccountUtil.java | 13 ++- .../resources/mapper/TbShopMsgStateMapper.xml | 91 ++++++++++++++++++ 5 files changed, 227 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopMsgState.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbShopMsgStateMapper.java create mode 100644 src/main/resources/mapper/TbShopMsgStateMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopMsgState.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopMsgState.java new file mode 100644 index 0000000..7afb82e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopMsgState.java @@ -0,0 +1,94 @@ +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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbShopMsgStateMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbShopMsgStateMapper.java new file mode 100644 index 0000000..10f7430 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbShopMsgStateMapper.java @@ -0,0 +1,28 @@ +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); +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index 81409f7..2bdda19 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -341,9 +341,9 @@ public class CartService { shopOpenIds.forEach(item -> { String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId()); if (message == null) { - WxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), + wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num) - , item.getOpenId()); + , item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopInfo.getId()); redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L); }else { log.info("{}已在30分钟内推送过消息,跳过发送", item.getOpenId()); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java index 35e9098..245130e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java @@ -6,7 +6,10 @@ import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpUtil; 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.mapper.TbShopMsgStateMapper; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -27,6 +30,8 @@ public class WxAccountUtil { @Value("${wx.ysk.warnMsgTmpId}") private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0"; + private final TbShopMsgStateMapper shopMsgStateMapper; + static LinkedHashMap linkedHashMap=new LinkedHashMap<>(); static { @@ -98,7 +103,13 @@ public class WxAccountUtil { throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误")); } - public static JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId) { + public JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId, ShopWxMsgTypeEnum typeEnum, Integer shopId) { + TbShopMsgState shopMsgState = shopMsgStateMapper.selectByType(typeEnum.getType(), shopId); + if (shopMsgState == null || shopMsgState.getState().equals(0)) { + log.info("店铺未开启推送:{}", shopMsgState); + return null; + } + stock = stock < 0 ? 0 : stock; Integer finalStock = stock; Map data = new HashMap() {{ diff --git a/src/main/resources/mapper/TbShopMsgStateMapper.xml b/src/main/resources/mapper/TbShopMsgStateMapper.xml new file mode 100644 index 0000000..cd820c5 --- /dev/null +++ b/src/main/resources/mapper/TbShopMsgStateMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + id,shop_id,type, + state,create_time,update_time + + + + + + delete from tb_shop_msg_state + where id = #{id,jdbcType=INTEGER} + + + 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 into tb_shop_msg_state + + id, + shop_id, + type, + state, + create_time, + update_time, + + + #{id,jdbcType=INTEGER}, + #{shopId,jdbcType=INTEGER}, + #{type,jdbcType=INTEGER}, + #{state,jdbcType=INTEGER}, + #{createTime,jdbcType=TIMESTAMP}, + #{updateTime,jdbcType=TIMESTAMP}, + + + + update tb_shop_msg_state + + + 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 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} + + From 8281c2b9bc682b51e0c9418eadc2d8ac5fcc1583 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 14 Aug 2024 09:46:28 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E5=BC=80=E9=80=9A=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LoginContoller.java | 9 ++--- .../controller/UserContoller.java | 7 ++++ .../cashierservice/entity/TbShopUser.java | 30 +++++++++++++++- .../entity/vo/OpenMemberVo.java | 15 ++++++++ .../exception/DefaultExceptionAdvice.java | 3 +- .../cashierservice/service/UserService.java | 36 +++++++++++++------ 6 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index cbdcdb2..3fced4d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -201,11 +201,11 @@ public class LoginContoller { String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr); try { if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) { - if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) { +// if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) { return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber")); - } - log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber")); - return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString()); +// } +// log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber")); +// return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString()); } } catch (Exception e){ // e.printStackTrace(); @@ -277,6 +277,7 @@ public class LoginContoller { String userId = TokenUtil.parseParamFromToken(token).getString("userId"); userInfo.setId(Integer.valueOf(userId)); userInfo.setUpdatedAt(System.currentTimeMillis()); +// log.info("更新用户信息 param,{}",JSONObject.toJSONString(userInfo)); return loginService.upUserInfo(userInfo); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index fcd72ad..05b5db6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -12,6 +12,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbShopUser; import com.chaozhanggui.system.cashierservice.entity.TbUserInfo; import com.chaozhanggui.system.cashierservice.entity.vo.IntegralFlowVo; import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo; +import com.chaozhanggui.system.cashierservice.entity.vo.OpenMemberVo; import com.chaozhanggui.system.cashierservice.service.UserService; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; @@ -61,6 +62,12 @@ public class UserContoller { // jsonObject.put("data",object); // return jsonObject; // } + + @PostMapping("/openMember") + public Result openMember(@RequestBody OpenMemberVo memberVo){ + return userService.openMember(memberVo); + } + @GetMapping("/shopUserInfo") public Result shopUserInfo(@RequestParam("userId") String userId, @RequestHeader("openId") String openId, @RequestParam("shopId") String shopId) throws Exception { TbShopUser shopUser = new TbShopUser(); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java index 9531fdf..1621a49 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java @@ -63,7 +63,10 @@ public class TbShopUser implements Serializable { private Long updatedAt; private String miniOpenId; - private String shopName; + private String shopName=""; + private String lat=""; + private String lng=""; + private String address=""; private static final long serialVersionUID = 1L; @@ -307,4 +310,29 @@ public class TbShopUser implements Serializable { public void setMiniOpenId(String miniOpenId) { this.miniOpenId = miniOpenId == null ? null : miniOpenId.trim(); } + + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java new file mode 100644 index 0000000..b08c50e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java @@ -0,0 +1,15 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +@Data +public class OpenMemberVo { + private Integer id; + private Integer shopId; + private String headImg; + + private String nickName; + + private String telephone; + private String birthDay; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/exception/DefaultExceptionAdvice.java b/src/main/java/com/chaozhanggui/system/cashierservice/exception/DefaultExceptionAdvice.java index b68db15..02b7c10 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/exception/DefaultExceptionAdvice.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/exception/DefaultExceptionAdvice.java @@ -146,7 +146,8 @@ public class DefaultExceptionAdvice { @ResponseStatus(HttpStatus.OK) @ExceptionHandler(MsgException.class) public ResponseEntity handleException(MsgException e) { - LOGGER.error("业务异常", e); + // LOGGER.error("业务异常", e); + LOGGER.error("业务异常", e.getMessage()); Result response = Result.fail(e.getMessage()); response.setMsg(e.getMessage()); return new ResponseEntity<>(response, HttpStatus.OK); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java index 0c11041..3b2dca0 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java @@ -1,19 +1,18 @@ package com.chaozhanggui.system.cashierservice.service; -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.QrConfig; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; -import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow; +import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; +import com.chaozhanggui.system.cashierservice.entity.TbShopUser; +import com.chaozhanggui.system.cashierservice.entity.TbUserInfo; import com.chaozhanggui.system.cashierservice.entity.vo.IntegralFlowVo; import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo; +import com.chaozhanggui.system.cashierservice.entity.vo.OpenMemberVo; import com.chaozhanggui.system.cashierservice.exception.MsgException; 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.*; @@ -23,19 +22,18 @@ import com.github.pagehelper.PageInfo; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import org.springframework.beans.factory.annotation.Autowired; 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.ResourceLoader; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.math.BigDecimal; -import java.util.*; +import java.util.Date; +import java.util.List; +import java.util.Objects; import java.util.concurrent.TimeUnit; @Service @@ -270,4 +268,22 @@ public class UserService { return fileService.uploadFileByInputStream("png", new ByteArrayInputStream(outputStream.toByteArray())); } + + public Result openMember(OpenMemberVo memberVo) { +// TbUserInfo userInfo = new TbUserInfo(); +// userInfo.setId(memberVo.getId()); +// userInfo.setHeadImg(memberVo.getHeadImg()); +// userInfo.setNickName(memberVo.getNickName()); +// userInfo.setTelephone(memberVo.getTelephone()); +// userInfo.setBirthDay(memberVo.getBirthDay()); +// userInfoMapper.updateByPrimaryKeySelective(userInfo); + TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(memberVo.getId().toString(), memberVo.getShopId().toString()); + tbShopUser.setName(memberVo.getNickName()); + tbShopUser.setHeadImg(memberVo.getHeadImg()); + tbShopUser.setTelephone(memberVo.getTelephone()); + tbShopUser.setBirthDay(memberVo.getBirthDay()); + tbShopUser.setIsVip(Byte.parseByte("1")); + shopUserMapper.updateByPrimaryKey(tbShopUser); + return Result.success(CodeEnum.SUCCESS); + } } From a9b32b4e576bc4e80dc866bf694b08772e0a6cb0 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Wed, 14 Aug 2024 09:55:18 +0800 Subject: [PATCH 04/18] =?UTF-8?q?1.=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/dao/TbShopOpenIdMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java index 8e6a0f1..478c8d2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java @@ -45,7 +45,7 @@ public interface TbShopOpenIdMapper { @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);") + @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 selectStateByShopIdAndType(@Param("shopId") String shopId, @Param("type") int type); @Select("select * from tb_shop_open_id where shop_id=#{shopId} and open_id=#{openId};") From 68d12fe2ed69ec8c874c688d8fb77d0c15c2a719 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 14 Aug 2024 11:34:51 +0800 Subject: [PATCH 05/18] =?UTF-8?q?=E5=95=86=E5=93=81=20=E5=8F=AF=E5=94=AE?= =?UTF-8?q?=E6=97=B6=E9=97=B4=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/TbProductGroupMapper.java | 13 ++-- .../cashierservice/entity/TbProduct.java | 11 +++ .../cashierservice/entity/TbProductGroup.java | 43 ++++++++++++ .../service/ProductService.java | 70 +++++++++++++++++-- .../resources/mapper/TbProductGroupMapper.xml | 10 ++- 5 files changed, 136 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductGroupMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductGroupMapper.java index 13d89fd..1609ea7 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductGroupMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductGroupMapper.java @@ -10,23 +10,24 @@ import java.util.List; @Component @Mapper public interface TbProductGroupMapper { - int deleteByPrimaryKey(Integer id); +// int deleteByPrimaryKey(Integer id); - int insert(TbProductGroup record); +// int insert(TbProductGroup record); - int insertSelective(TbProductGroup record); +// int insertSelective(TbProductGroup record); TbProductGroup selectByPrimaryKey(Integer id); - int updateByPrimaryKeySelective(TbProductGroup record); +// int updateByPrimaryKeySelective(TbProductGroup record); - int updateByPrimaryKeyWithBLOBs(TbProductGroup record); +// int updateByPrimaryKeyWithBLOBs(TbProductGroup record); - int updateByPrimaryKey(TbProductGroup record); +// int updateByPrimaryKey(TbProductGroup record); List selectByIdAndShopId(@Param("code") String code); List selectByQrcode(@Param("qrCode") String qrCode,@Param("groupId") Integer groupId); List selectByShopId(@Param("shopId") String shopId,@Param("groupId") Integer groupId); + List selectByProductId(@Param("shopId") String shopId,@Param("productId") String productId); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java index ed6e8bf..ba7404d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java @@ -137,6 +137,9 @@ public class TbProduct implements Serializable { private Integer stockNumber; private Integer suit; + //是否可售 1 可售 0非可售 + private Integer isSale = 1; + public String getImages() { return images; @@ -672,4 +675,12 @@ public class TbProduct implements Serializable { public void setSuit(Integer suit) { this.suit = suit; } + + public Integer getIsSale() { + return isSale; + } + + public void setIsSale(Integer isSale) { + this.isSale = isSale; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java index 9460370..d06a9bb 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java @@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.entity; import org.springframework.data.annotation.Transient; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.List; @@ -31,6 +32,15 @@ public class TbProductGroup implements Serializable { private String productIds; + //是否可售 1 可售 0非可售 + private Integer isSale = 1; + //是否使用时间管控 0不使用 1使用 + private Integer useTime = 0; + + private String saleStartTime; + + private String saleEndTime; + @Transient @@ -144,4 +154,37 @@ public class TbProductGroup implements Serializable { public void setProductIds(String productIds) { this.productIds = productIds == null ? null : productIds.trim(); } + + + public Integer getUseTime() { + return useTime; + } + + public void setUseTime(Integer useTime) { + this.useTime = useTime; + } + + public String getSaleStartTime() { + return saleStartTime; + } + + public void setSaleStartTime(String saleStartTime) { + this.saleStartTime = saleStartTime; + } + + public String getSaleEndTime() { + return saleEndTime; + } + + public void setSaleEndTime(String saleEndTime) { + this.saleEndTime = saleEndTime; + } + + public Integer getIsSale() { + return isSale; + } + + public void setIsSale(Integer isSale) { + this.isSale = isSale; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 491aea6..f16e026 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -18,6 +18,7 @@ import com.chaozhanggui.system.cashierservice.util.*; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.common.util.concurrent.AtomicDouble; +import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +27,10 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; @@ -136,32 +141,72 @@ public class ProductService { Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null; //招牌菜 List tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId)); - concurrentMap.put("hots", handleDate(tbProducts)); + concurrentMap.put("hots", handleDate(tbProducts,true)); List groupList = tbProductGroupMapper.selectByShopId(shopId, id); if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) { //热销 TbProductGroup hot = new TbProductGroup(); hot.setName("热销"); List hots = tbProductMapper.selectHot(shopId); - hot.setProducts(handleDate(hots)); + hot.setProducts(handleDate(hots,true)); //商品 groupList.parallelStream().forEach(g -> { + if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime())); String in = g.getProductIds().substring(1, g.getProductIds().length() - 1); if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) { // List products = tbProductMapper.selectByIdIn(in); List products = tbProductMapper.selectByIdInAndCheck(in); - g.setProducts(handleDate(products)); + g.setProducts(handleDate(products,false)); } else { g.setProducts(new ArrayList<>()); } }); groupList.add(0, hot); + groupList.sort(Comparator.comparingInt(TbProductGroup::getIsSale)); concurrentMap.put("productInfo", groupList); } return Result.success(CodeEnum.SUCCESS, concurrentMap); } + /** + * 判断是否在可售时间内 + * @param startTimeStr HH:mm + * @param endTimeStr HH:mm + * @return 1 可售 0 不可售 + */ + public Integer getIsSale(String startTimeStr,String endTimeStr) { + // 定义时间格式 + DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + // 解析时间字符串为 LocalTime 对象 + LocalTime startTime = LocalTime.parse(startTimeStr, timeFormatter); + LocalTime endTime = LocalTime.parse(endTimeStr, timeFormatter); + // 获取当前日期 + LocalDate today = LocalDate.now(); + // 创建 LocalDateTime 对象 + LocalDateTime startDateTime = LocalDateTime.of(today, startTime); + LocalDateTime endDateTime = LocalDateTime.of(today, endTime); + // 如果结束时间早于开始时间,说明时间段跨日 + if (endDateTime.isBefore(startDateTime)) { + endDateTime = endDateTime.plusDays(1); + } + // 获取当前日期时间 + LocalDateTime now = LocalDateTime.now(); + if (now.isBefore(startDateTime)) { + // 将当前时间加上24小时(一天),进行比较 + LocalDateTime nowPlus24 = now.plusHours(24); + //当前时间 小于开始时间,且结束时间小于开始时间 + if (nowPlus24.isBefore(endDateTime)) { + return 1; + } + } else { + if (now.isBefore(endDateTime)) { + return 1; + } + } + return 0; + } + public Object querySpec(QuerySpecDTO querySpecDTO) { TbProduct tbProduct = tbProductMapper.selectById(querySpecDTO.getProductId()); if (tbProduct == null) { @@ -296,9 +341,26 @@ public class ProductService { } } - public List handleDate(List products){ + /** + * 组装商品 + * @param products 商品列表 + * @param check 是否校验可售 + * @return + */ + public List handleDate(List products,boolean check){ if (!CollectionUtils.isEmpty(products)) { products.parallelStream().forEach(it -> { + if(check){ + List tbProductGroups = tbProductGroupMapper.selectByProductId(it.getShopId(), it.getId().toString()); + for (TbProductGroup g : tbProductGroups) { + if (g.getUseTime()==1) { + if (getIsSale(g.getSaleStartTime(), g.getSaleEndTime()) == 0) { + it.setIsSale(0); + return; + } + } + } + } TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId())); it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : ""); //购物车数量 diff --git a/src/main/resources/mapper/TbProductGroupMapper.xml b/src/main/resources/mapper/TbProductGroupMapper.xml index 5082065..a8f0112 100644 --- a/src/main/resources/mapper/TbProductGroupMapper.xml +++ b/src/main/resources/mapper/TbProductGroupMapper.xml @@ -11,6 +11,9 @@ + + + @@ -18,7 +21,7 @@ - id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, created_at, updated_at + id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, created_at, updated_at , use_time, sale_start_time, sale_end_time product_ids @@ -234,4 +237,9 @@ order by sort asc + + \ No newline at end of file From 3ab16294367fbfec9b485b6ffabfff7d72d044ae Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 9 Aug 2024 16:42:17 +0800 Subject: [PATCH 06/18] =?UTF-8?q?1.=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CommonController.java | 4 +- .../controller/UserContoller.java | 4 +- .../dao/TbShopOpenIdMapper.java | 12 +++ .../entity/Enum/ShopWxMsgTypeEnum.java | 17 +++++ .../cashierservice/service/CartService.java | 5 +- .../cashierservice/service/LoginService.java | 73 ++++++++++++------- .../cashierservice/service/UserService.java | 15 +--- 7 files changed, 86 insertions(+), 44 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopWxMsgTypeEnum.java diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java index 1c0f114..83211ee 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java @@ -220,9 +220,7 @@ public class CommonController { if (wxMsgSubDTO.getOpenId() == null || wxMsgSubDTO.getShopId() == null) { return Result.fail("shopId或openId缺失"); } - 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()); + loginService.addShopId(wxMsgSubDTO.getOpenId(), wxMsgSubDTO.getShopId(), null, wxMsgSubDTO.getNickname(), wxMsgSubDTO.getAvatar()); return Result.success(CodeEnum.SUCCESS); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index fcd72ad..28cce38 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -156,7 +156,9 @@ public class UserContoller { * @return */ @GetMapping("/subQrCode") - public Result getSubQrCode(String shopId) throws Exception { + public Result getSubQrCode( + @RequestParam String shopId + ) throws Exception { String url = userService.getSubQrCode(shopId); return Result.successWithData(url); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java index 8d875e1..8e6a0f1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java @@ -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 ") 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 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 selectStateByShopIdAndOpenId(@Param("openId") String openId, @Param("shopId") String shopId); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopWxMsgTypeEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopWxMsgTypeEnum.java new file mode 100644 index 0000000..766e548 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopWxMsgTypeEnum.java @@ -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; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index a967298..81409f7 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; 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.netty.PushToAppChannelHandlerAdapter; 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) && productSku.getStockNumber() - num <= productSku.getWarnLine() ) { - List shopOpenIds = shopOpenIdMapper.selectByShopId(Integer.valueOf(product.getShopId())); + List shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType()); shopOpenIds.forEach(item -> { String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId()); if (message == null) { - wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), + WxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num) , item.getOpenId()); redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index 0f02095..c9194ed 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -1,6 +1,7 @@ package com.chaozhanggui.system.cashierservice.service; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; @@ -60,43 +61,61 @@ public class LoginService { private final TbShopOpenIdMapper shopOpenIdMapper; + private final static int[] MSG_TYPE_LIST = new int[] {0, 1, 2}; + public LoginService(TbShopOpenIdMapper shopOpenIdMapper) { this.shopOpenIdMapper = shopOpenIdMapper; } - public void addShopId(String openId, String shopId, Integer type, String nickName, String avatar) { - TbUserShopMsg shopMsg = tbUserShopMsgMapper.selectByShopIdAndOpenId(Integer.valueOf(shopId), openId); - if (Objects.isNull(shopMsg)) { - shopMsg = new TbUserShopMsg(); - shopMsg.setShopId(Integer.valueOf(shopId)); - shopMsg.setOpenId(openId); - shopMsg.setCreateTime(new Date()); - shopMsg.setStatus("1"); - tbUserShopMsgMapper.insert(shopMsg); - } - - + public void addShopId(String openId, String shopId, Integer type1, String nickName, String avatar) { // 为商家绑定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); +// TbShopOpenId tbShopOpenId = shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId), null); + List shopOpenIdList = shopOpenIdMapper.selectStateByShopIdAndOpenId(openId, shopId); + int openCount = shopOpenIdMapper.selectStateByShopId(shopId); + + if (shopOpenIdList.isEmpty()) { + for (int type : MSG_TYPE_LIST) { + addShopOpenId(openId, shopId, nickName, avatar, openCount, type); + } + } else { - tbShopOpenId.setUpdateTime(DateUtil.date()); - tbShopOpenId.setNickname(nickName); - tbShopOpenId.setAvatar(avatar); - shopOpenIdMapper.updateByPrimaryKeySelective(tbShopOpenId); + boolean fullSize = shopOpenIdList.size() == MSG_TYPE_LIST.length; + HashMap typeMap = new HashMap<>(); + for (TbShopOpenId tbShopOpenId : shopOpenIdList) { + 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) { TbUserShopMsg shopMsg = tbUserShopMsgMapper.selectByShopIdAndOpenId(Integer.valueOf(shopId), openId); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java index 0c11041..47dbcff 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java @@ -1,11 +1,8 @@ package com.chaozhanggui.system.cashierservice.service; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.extra.qrcode.QrConfig; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; 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.exception.MsgException; 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.wxUtil.WxAccountUtil; import com.github.pagehelper.PageHelper; @@ -23,14 +17,11 @@ import com.github.pagehelper.PageInfo; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import org.springframework.beans.factory.annotation.Autowired; 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.ResourceLoader; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -264,7 +255,9 @@ public class UserService { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Resource resource = resourceLoader.getResource("classpath:/static/logo.jpg"); 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); From efd0d80dc36d8f2bdc37140a4e2dbf50bba4adcd Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Tue, 13 Aug 2024 09:44:39 +0800 Subject: [PATCH 07/18] =?UTF-8?q?1.=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=BA=97=E9=93=BA=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/entity/TbShopMsgState.java | 94 +++++++++++++++++++ .../mapper/TbShopMsgStateMapper.java | 28 ++++++ .../cashierservice/service/CartService.java | 4 +- .../cashierservice/wxUtil/WxAccountUtil.java | 13 ++- .../resources/mapper/TbShopMsgStateMapper.xml | 91 ++++++++++++++++++ 5 files changed, 227 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopMsgState.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbShopMsgStateMapper.java create mode 100644 src/main/resources/mapper/TbShopMsgStateMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopMsgState.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopMsgState.java new file mode 100644 index 0000000..7afb82e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopMsgState.java @@ -0,0 +1,94 @@ +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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbShopMsgStateMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbShopMsgStateMapper.java new file mode 100644 index 0000000..10f7430 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbShopMsgStateMapper.java @@ -0,0 +1,28 @@ +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); +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index 81409f7..2bdda19 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -341,9 +341,9 @@ public class CartService { shopOpenIds.forEach(item -> { String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId()); if (message == null) { - WxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), + wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num) - , item.getOpenId()); + , item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopInfo.getId()); redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L); }else { log.info("{}已在30分钟内推送过消息,跳过发送", item.getOpenId()); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java index 35e9098..245130e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java @@ -6,7 +6,10 @@ import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpUtil; 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.mapper.TbShopMsgStateMapper; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -27,6 +30,8 @@ public class WxAccountUtil { @Value("${wx.ysk.warnMsgTmpId}") private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0"; + private final TbShopMsgStateMapper shopMsgStateMapper; + static LinkedHashMap linkedHashMap=new LinkedHashMap<>(); static { @@ -98,7 +103,13 @@ public class WxAccountUtil { throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误")); } - public static JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId) { + public JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId, ShopWxMsgTypeEnum typeEnum, Integer shopId) { + TbShopMsgState shopMsgState = shopMsgStateMapper.selectByType(typeEnum.getType(), shopId); + if (shopMsgState == null || shopMsgState.getState().equals(0)) { + log.info("店铺未开启推送:{}", shopMsgState); + return null; + } + stock = stock < 0 ? 0 : stock; Integer finalStock = stock; Map data = new HashMap() {{ diff --git a/src/main/resources/mapper/TbShopMsgStateMapper.xml b/src/main/resources/mapper/TbShopMsgStateMapper.xml new file mode 100644 index 0000000..cd820c5 --- /dev/null +++ b/src/main/resources/mapper/TbShopMsgStateMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + id,shop_id,type, + state,create_time,update_time + + + + + + delete from tb_shop_msg_state + where id = #{id,jdbcType=INTEGER} + + + 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 into tb_shop_msg_state + + id, + shop_id, + type, + state, + create_time, + update_time, + + + #{id,jdbcType=INTEGER}, + #{shopId,jdbcType=INTEGER}, + #{type,jdbcType=INTEGER}, + #{state,jdbcType=INTEGER}, + #{createTime,jdbcType=TIMESTAMP}, + #{updateTime,jdbcType=TIMESTAMP}, + + + + update tb_shop_msg_state + + + 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 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} + + From dae3a75e0ce7f7237f9664b7a02c0488f5b7a13e Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Wed, 14 Aug 2024 09:55:18 +0800 Subject: [PATCH 08/18] =?UTF-8?q?1.=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/dao/TbShopOpenIdMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java index 8e6a0f1..478c8d2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java @@ -45,7 +45,7 @@ public interface TbShopOpenIdMapper { @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);") + @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 selectStateByShopIdAndType(@Param("shopId") String shopId, @Param("type") int type); @Select("select * from tb_shop_open_id where shop_id=#{shopId} and open_id=#{openId};") From 8ea20b8394fb607fff01adddc860781cae6b8ae4 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Wed, 14 Aug 2024 14:56:39 +0800 Subject: [PATCH 09/18] =?UTF-8?q?1.=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/wxUtil/WxAccountUtil.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java index 245130e..73baaa9 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java @@ -104,6 +104,11 @@ public class WxAccountUtil { } public JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId, ShopWxMsgTypeEnum typeEnum, Integer shopId) { + TbShopMsgState allState = shopMsgStateMapper.selectByType(ShopWxMsgTypeEnum.ALL_MSG.getType(), shopId); + if (allState == null || allState.getState().equals(0)) { + log.info("店铺未开启全局推送:{}", allState); + return null; + } TbShopMsgState shopMsgState = shopMsgStateMapper.selectByType(typeEnum.getType(), shopId); if (shopMsgState == null || shopMsgState.getState().equals(0)) { log.info("店铺未开启推送:{}", shopMsgState); From 57472bdf003ce1f0f339e04f3b53737a76dea67c Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 14 Aug 2024 09:46:28 +0800 Subject: [PATCH 10/18] =?UTF-8?q?=E5=BC=80=E9=80=9A=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LoginContoller.java | 9 +++--- .../controller/UserContoller.java | 7 +++++ .../cashierservice/entity/TbShopUser.java | 30 ++++++++++++++++++- .../entity/vo/OpenMemberVo.java | 15 ++++++++++ .../exception/DefaultExceptionAdvice.java | 3 +- .../cashierservice/service/UserService.java | 26 +++++++++++++++- 6 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index cbdcdb2..3fced4d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -201,11 +201,11 @@ public class LoginContoller { String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr); try { if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) { - if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) { +// if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) { return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber")); - } - log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber")); - return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString()); +// } +// log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber")); +// return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString()); } } catch (Exception e){ // e.printStackTrace(); @@ -277,6 +277,7 @@ public class LoginContoller { String userId = TokenUtil.parseParamFromToken(token).getString("userId"); userInfo.setId(Integer.valueOf(userId)); userInfo.setUpdatedAt(System.currentTimeMillis()); +// log.info("更新用户信息 param,{}",JSONObject.toJSONString(userInfo)); return loginService.upUserInfo(userInfo); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index 28cce38..e90bfe9 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -12,6 +12,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbShopUser; import com.chaozhanggui.system.cashierservice.entity.TbUserInfo; import com.chaozhanggui.system.cashierservice.entity.vo.IntegralFlowVo; import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo; +import com.chaozhanggui.system.cashierservice.entity.vo.OpenMemberVo; import com.chaozhanggui.system.cashierservice.service.UserService; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; @@ -61,6 +62,12 @@ public class UserContoller { // jsonObject.put("data",object); // return jsonObject; // } + + @PostMapping("/openMember") + public Result openMember(@RequestBody OpenMemberVo memberVo){ + return userService.openMember(memberVo); + } + @GetMapping("/shopUserInfo") public Result shopUserInfo(@RequestParam("userId") String userId, @RequestHeader("openId") String openId, @RequestParam("shopId") String shopId) throws Exception { TbShopUser shopUser = new TbShopUser(); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java index 9531fdf..1621a49 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java @@ -63,7 +63,10 @@ public class TbShopUser implements Serializable { private Long updatedAt; private String miniOpenId; - private String shopName; + private String shopName=""; + private String lat=""; + private String lng=""; + private String address=""; private static final long serialVersionUID = 1L; @@ -307,4 +310,29 @@ public class TbShopUser implements Serializable { public void setMiniOpenId(String miniOpenId) { this.miniOpenId = miniOpenId == null ? null : miniOpenId.trim(); } + + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java new file mode 100644 index 0000000..b08c50e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java @@ -0,0 +1,15 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +@Data +public class OpenMemberVo { + private Integer id; + private Integer shopId; + private String headImg; + + private String nickName; + + private String telephone; + private String birthDay; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/exception/DefaultExceptionAdvice.java b/src/main/java/com/chaozhanggui/system/cashierservice/exception/DefaultExceptionAdvice.java index b68db15..02b7c10 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/exception/DefaultExceptionAdvice.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/exception/DefaultExceptionAdvice.java @@ -146,7 +146,8 @@ public class DefaultExceptionAdvice { @ResponseStatus(HttpStatus.OK) @ExceptionHandler(MsgException.class) public ResponseEntity handleException(MsgException e) { - LOGGER.error("业务异常", e); + // LOGGER.error("业务异常", e); + LOGGER.error("业务异常", e.getMessage()); Result response = Result.fail(e.getMessage()); response.setMsg(e.getMessage()); return new ResponseEntity<>(response, HttpStatus.OK); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java index 47dbcff..cd72a41 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java @@ -5,11 +5,17 @@ import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.extra.qrcode.QrConfig; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; -import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow; +import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; +import com.chaozhanggui.system.cashierservice.entity.TbShopUser; +import com.chaozhanggui.system.cashierservice.entity.TbUserInfo; import com.chaozhanggui.system.cashierservice.entity.vo.IntegralFlowVo; import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo; +import com.chaozhanggui.system.cashierservice.entity.vo.OpenMemberVo; import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.redis.RedisCst; +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.wxUtil.WxAccountUtil; import com.github.pagehelper.PageHelper; @@ -263,4 +269,22 @@ public class UserService { return fileService.uploadFileByInputStream("png", new ByteArrayInputStream(outputStream.toByteArray())); } + + public Result openMember(OpenMemberVo memberVo) { +// TbUserInfo userInfo = new TbUserInfo(); +// userInfo.setId(memberVo.getId()); +// userInfo.setHeadImg(memberVo.getHeadImg()); +// userInfo.setNickName(memberVo.getNickName()); +// userInfo.setTelephone(memberVo.getTelephone()); +// userInfo.setBirthDay(memberVo.getBirthDay()); +// userInfoMapper.updateByPrimaryKeySelective(userInfo); + TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(memberVo.getId().toString(), memberVo.getShopId().toString()); + tbShopUser.setName(memberVo.getNickName()); + tbShopUser.setHeadImg(memberVo.getHeadImg()); + tbShopUser.setTelephone(memberVo.getTelephone()); + tbShopUser.setBirthDay(memberVo.getBirthDay()); + tbShopUser.setIsVip(Byte.parseByte("1")); + shopUserMapper.updateByPrimaryKey(tbShopUser); + return Result.success(CodeEnum.SUCCESS); + } } From a4601fac99114b828e77baddf77e007b2656b319 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 14 Aug 2024 11:34:51 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E5=95=86=E5=93=81=20=E5=8F=AF=E5=94=AE?= =?UTF-8?q?=E6=97=B6=E9=97=B4=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/TbProductGroupMapper.java | 13 ++-- .../cashierservice/entity/TbProduct.java | 11 +++ .../cashierservice/entity/TbProductGroup.java | 43 ++++++++++++ .../service/ProductService.java | 70 +++++++++++++++++-- .../resources/mapper/TbProductGroupMapper.xml | 10 ++- 5 files changed, 136 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductGroupMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductGroupMapper.java index 13d89fd..1609ea7 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductGroupMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductGroupMapper.java @@ -10,23 +10,24 @@ import java.util.List; @Component @Mapper public interface TbProductGroupMapper { - int deleteByPrimaryKey(Integer id); +// int deleteByPrimaryKey(Integer id); - int insert(TbProductGroup record); +// int insert(TbProductGroup record); - int insertSelective(TbProductGroup record); +// int insertSelective(TbProductGroup record); TbProductGroup selectByPrimaryKey(Integer id); - int updateByPrimaryKeySelective(TbProductGroup record); +// int updateByPrimaryKeySelective(TbProductGroup record); - int updateByPrimaryKeyWithBLOBs(TbProductGroup record); +// int updateByPrimaryKeyWithBLOBs(TbProductGroup record); - int updateByPrimaryKey(TbProductGroup record); +// int updateByPrimaryKey(TbProductGroup record); List selectByIdAndShopId(@Param("code") String code); List selectByQrcode(@Param("qrCode") String qrCode,@Param("groupId") Integer groupId); List selectByShopId(@Param("shopId") String shopId,@Param("groupId") Integer groupId); + List selectByProductId(@Param("shopId") String shopId,@Param("productId") String productId); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java index ed6e8bf..ba7404d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java @@ -137,6 +137,9 @@ public class TbProduct implements Serializable { private Integer stockNumber; private Integer suit; + //是否可售 1 可售 0非可售 + private Integer isSale = 1; + public String getImages() { return images; @@ -672,4 +675,12 @@ public class TbProduct implements Serializable { public void setSuit(Integer suit) { this.suit = suit; } + + public Integer getIsSale() { + return isSale; + } + + public void setIsSale(Integer isSale) { + this.isSale = isSale; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java index 9460370..d06a9bb 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java @@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.entity; import org.springframework.data.annotation.Transient; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.List; @@ -31,6 +32,15 @@ public class TbProductGroup implements Serializable { private String productIds; + //是否可售 1 可售 0非可售 + private Integer isSale = 1; + //是否使用时间管控 0不使用 1使用 + private Integer useTime = 0; + + private String saleStartTime; + + private String saleEndTime; + @Transient @@ -144,4 +154,37 @@ public class TbProductGroup implements Serializable { public void setProductIds(String productIds) { this.productIds = productIds == null ? null : productIds.trim(); } + + + public Integer getUseTime() { + return useTime; + } + + public void setUseTime(Integer useTime) { + this.useTime = useTime; + } + + public String getSaleStartTime() { + return saleStartTime; + } + + public void setSaleStartTime(String saleStartTime) { + this.saleStartTime = saleStartTime; + } + + public String getSaleEndTime() { + return saleEndTime; + } + + public void setSaleEndTime(String saleEndTime) { + this.saleEndTime = saleEndTime; + } + + public Integer getIsSale() { + return isSale; + } + + public void setIsSale(Integer isSale) { + this.isSale = isSale; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 491aea6..f16e026 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -18,6 +18,7 @@ import com.chaozhanggui.system.cashierservice.util.*; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.common.util.concurrent.AtomicDouble; +import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +27,10 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; @@ -136,32 +141,72 @@ public class ProductService { Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null; //招牌菜 List tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId)); - concurrentMap.put("hots", handleDate(tbProducts)); + concurrentMap.put("hots", handleDate(tbProducts,true)); List groupList = tbProductGroupMapper.selectByShopId(shopId, id); if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) { //热销 TbProductGroup hot = new TbProductGroup(); hot.setName("热销"); List hots = tbProductMapper.selectHot(shopId); - hot.setProducts(handleDate(hots)); + hot.setProducts(handleDate(hots,true)); //商品 groupList.parallelStream().forEach(g -> { + if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime())); String in = g.getProductIds().substring(1, g.getProductIds().length() - 1); if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) { // List products = tbProductMapper.selectByIdIn(in); List products = tbProductMapper.selectByIdInAndCheck(in); - g.setProducts(handleDate(products)); + g.setProducts(handleDate(products,false)); } else { g.setProducts(new ArrayList<>()); } }); groupList.add(0, hot); + groupList.sort(Comparator.comparingInt(TbProductGroup::getIsSale)); concurrentMap.put("productInfo", groupList); } return Result.success(CodeEnum.SUCCESS, concurrentMap); } + /** + * 判断是否在可售时间内 + * @param startTimeStr HH:mm + * @param endTimeStr HH:mm + * @return 1 可售 0 不可售 + */ + public Integer getIsSale(String startTimeStr,String endTimeStr) { + // 定义时间格式 + DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + // 解析时间字符串为 LocalTime 对象 + LocalTime startTime = LocalTime.parse(startTimeStr, timeFormatter); + LocalTime endTime = LocalTime.parse(endTimeStr, timeFormatter); + // 获取当前日期 + LocalDate today = LocalDate.now(); + // 创建 LocalDateTime 对象 + LocalDateTime startDateTime = LocalDateTime.of(today, startTime); + LocalDateTime endDateTime = LocalDateTime.of(today, endTime); + // 如果结束时间早于开始时间,说明时间段跨日 + if (endDateTime.isBefore(startDateTime)) { + endDateTime = endDateTime.plusDays(1); + } + // 获取当前日期时间 + LocalDateTime now = LocalDateTime.now(); + if (now.isBefore(startDateTime)) { + // 将当前时间加上24小时(一天),进行比较 + LocalDateTime nowPlus24 = now.plusHours(24); + //当前时间 小于开始时间,且结束时间小于开始时间 + if (nowPlus24.isBefore(endDateTime)) { + return 1; + } + } else { + if (now.isBefore(endDateTime)) { + return 1; + } + } + return 0; + } + public Object querySpec(QuerySpecDTO querySpecDTO) { TbProduct tbProduct = tbProductMapper.selectById(querySpecDTO.getProductId()); if (tbProduct == null) { @@ -296,9 +341,26 @@ public class ProductService { } } - public List handleDate(List products){ + /** + * 组装商品 + * @param products 商品列表 + * @param check 是否校验可售 + * @return + */ + public List handleDate(List products,boolean check){ if (!CollectionUtils.isEmpty(products)) { products.parallelStream().forEach(it -> { + if(check){ + List tbProductGroups = tbProductGroupMapper.selectByProductId(it.getShopId(), it.getId().toString()); + for (TbProductGroup g : tbProductGroups) { + if (g.getUseTime()==1) { + if (getIsSale(g.getSaleStartTime(), g.getSaleEndTime()) == 0) { + it.setIsSale(0); + return; + } + } + } + } TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId())); it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : ""); //购物车数量 diff --git a/src/main/resources/mapper/TbProductGroupMapper.xml b/src/main/resources/mapper/TbProductGroupMapper.xml index 5082065..a8f0112 100644 --- a/src/main/resources/mapper/TbProductGroupMapper.xml +++ b/src/main/resources/mapper/TbProductGroupMapper.xml @@ -11,6 +11,9 @@ + + + @@ -18,7 +21,7 @@ - id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, created_at, updated_at + id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, created_at, updated_at , use_time, sale_start_time, sale_end_time product_ids @@ -234,4 +237,9 @@ order by sort asc + + \ No newline at end of file From 48a6628acbc7d03e96a12e5531de50c5a8bc73f5 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 14 Aug 2024 16:07:38 +0800 Subject: [PATCH 12/18] =?UTF-8?q?=E5=95=86=E5=93=81=20=E5=8F=AF=E5=94=AE?= =?UTF-8?q?=E6=97=B6=E9=97=B4=20=E5=A4=84=E7=90=86=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/ProductService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index f16e026..252048f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -141,14 +141,14 @@ public class ProductService { Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null; //招牌菜 List tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId)); - concurrentMap.put("hots", handleDate(tbProducts,true)); + concurrentMap.put("hots", handleDate(tbProducts,true,1)); List groupList = tbProductGroupMapper.selectByShopId(shopId, id); if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) { //热销 TbProductGroup hot = new TbProductGroup(); hot.setName("热销"); List hots = tbProductMapper.selectHot(shopId); - hot.setProducts(handleDate(hots,true)); + hot.setProducts(handleDate(hots,true,1)); //商品 groupList.parallelStream().forEach(g -> { if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime())); @@ -156,7 +156,7 @@ public class ProductService { if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) { // List products = tbProductMapper.selectByIdIn(in); List products = tbProductMapper.selectByIdInAndCheck(in); - g.setProducts(handleDate(products,false)); + g.setProducts(handleDate(products,false,g.getIsSale())); } else { g.setProducts(new ArrayList<>()); } @@ -347,7 +347,7 @@ public class ProductService { * @param check 是否校验可售 * @return */ - public List handleDate(List products,boolean check){ + public List handleDate(List products,boolean check,Integer isSale){ if (!CollectionUtils.isEmpty(products)) { products.parallelStream().forEach(it -> { if(check){ @@ -360,6 +360,8 @@ public class ProductService { } } } + }else { + it.setIsSale(isSale); } TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId())); it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : ""); From 878cc895d44f547c2f33fb07f9cb55194ef35754 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 16 Aug 2024 09:27:58 +0800 Subject: [PATCH 13/18] =?UTF-8?q?=E5=95=86=E5=93=81=20=E5=8F=AF=E5=94=AE?= =?UTF-8?q?=E6=97=B6=E9=97=B4=20=E5=88=86=E7=BB=84=20=E6=8E=92=E5=BA=8F=20?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E4=BF=A1=E6=81=AF=20=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/entity/TbProductGroup.java | 1 - .../system/cashierservice/service/ProductService.java | 2 +- src/main/resources/mapper/TbShopUserFlowMapper.xml | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java index d06a9bb..1c5b0b6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductGroup.java @@ -3,7 +3,6 @@ package com.chaozhanggui.system.cashierservice.entity; import org.springframework.data.annotation.Transient; -import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.List; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 252048f..8e844ad 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -161,8 +161,8 @@ public class ProductService { g.setProducts(new ArrayList<>()); } }); + groupList.sort(Comparator.comparingInt(TbProductGroup::getIsSale).reversed()); groupList.add(0, hot); - groupList.sort(Comparator.comparingInt(TbProductGroup::getIsSale)); concurrentMap.put("productInfo", groupList); } diff --git a/src/main/resources/mapper/TbShopUserFlowMapper.xml b/src/main/resources/mapper/TbShopUserFlowMapper.xml index 9e02f10..9d7b16f 100644 --- a/src/main/resources/mapper/TbShopUserFlowMapper.xml +++ b/src/main/resources/mapper/TbShopUserFlowMapper.xml @@ -130,6 +130,7 @@ SELECT f.*, + u.`head_img`, u.`name` FROM tb_shop_user_flow f From 605b1778a41fef63e86dd233e6802f3f2137f960 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 16 Aug 2024 14:07:01 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=92=8C=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=89=8B=E6=9C=BA=E5=8F=B7=20=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/UserService.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java index 3b2dca0..716ea72 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java @@ -270,13 +270,18 @@ public class UserService { } public Result openMember(OpenMemberVo memberVo) { -// TbUserInfo userInfo = new TbUserInfo(); -// userInfo.setId(memberVo.getId()); -// userInfo.setHeadImg(memberVo.getHeadImg()); -// userInfo.setNickName(memberVo.getNickName()); -// userInfo.setTelephone(memberVo.getTelephone()); -// userInfo.setBirthDay(memberVo.getBirthDay()); -// userInfoMapper.updateByPrimaryKeySelective(userInfo); + TbUserInfo userInfo = new TbUserInfo(); + userInfo.setId(memberVo.getId()); + userInfo.setHeadImg(memberVo.getHeadImg()); + userInfo.setNickName(memberVo.getNickName()); + userInfo.setTelephone(memberVo.getTelephone()); + userInfo.setBirthDay(memberVo.getBirthDay()); + userInfoMapper.updateByPrimaryKeySelective(userInfo); + List tbShopUsers = shopUserMapper.selectAllByUserId(memberVo.getId().toString()); + for (TbShopUser tbShopUser : tbShopUsers) { + tbShopUser.setTelephone(memberVo.getTelephone()); + shopUserMapper.updateByPrimaryKey(tbShopUser); + } TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(memberVo.getId().toString(), memberVo.getShopId().toString()); tbShopUser.setName(memberVo.getNickName()); tbShopUser.setHeadImg(memberVo.getHeadImg()); From 82b4f773e4b74ca697bf467cc19451cf992e1966 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 16 Aug 2024 14:28:43 +0800 Subject: [PATCH 15/18] =?UTF-8?q?shopUser=E8=BF=94=E5=9B=9E=20=E5=BA=97?= =?UTF-8?q?=E9=93=BA=E7=BB=8F=E7=BA=AC=E5=BA=A6=20=E5=8F=8A=20=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/controller/UserContoller.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index e90bfe9..57a7608 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -115,8 +115,9 @@ public class UserContoller { } if (tbShopInfo != null) { shopUser.setShopName(tbShopInfo.getShopName()); - }else { - shopUser.setShopName(""); + shopUser.setLng(tbShopInfo.getLng()); + shopUser.setLat(tbShopInfo.getLat()); + shopUser.setAddress(tbShopInfo.getAddress()); } return Result.success(CodeEnum.SUCCESS, shopUser); } From 952a6181752ef9a8d5ca431142dda8367ff7e833 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 16 Aug 2024 15:31:07 +0800 Subject: [PATCH 16/18] =?UTF-8?q?shopId=20undefined=20=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/controller/UserContoller.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index 57a7608..b32adf4 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -70,6 +70,9 @@ public class UserContoller { @GetMapping("/shopUserInfo") public Result shopUserInfo(@RequestParam("userId") String userId, @RequestHeader("openId") String openId, @RequestParam("shopId") String shopId) throws Exception { + if(shopId.equals("undefined")){ + return Result.fail("店铺信息错误,请联系管理员!"); + } TbShopUser shopUser = new TbShopUser(); TbShopInfo tbShopInfo = new TbShopInfo(); if (StringUtils.isNotBlank(shopId) && !shopId.equals("null")) { From 9b868838f4ca17447591fdbf5fe4121e296a99b1 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 2 Aug 2024 10:59:53 +0800 Subject: [PATCH 17/18] =?UTF-8?q?1.=E5=85=AC=E4=BC=97=E5=8F=B7=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E6=96=B0=E5=A2=9Etype=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CommonController.java | 6 +++++- .../dao/TbShopOpenIdMapper.java | 3 +-- .../entity/dto/WxMsgSubDTO.java | 1 + .../cashierservice/service/LoginService.java | 16 +++++++++------- .../cashierservice/service/UserService.java | 2 +- .../cashierservice/wxUtil/WxAccountUtil.java | 4 ++-- .../resources/mapper/TbShopOpenIdMapper.xml | 19 ++++++++++++++----- 7 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java index 33217e3..e0f3a47 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java @@ -19,6 +19,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.web.bind.annotation.*; @@ -38,6 +40,7 @@ import java.util.List; @RequiredArgsConstructor public class CommonController { + private static final Logger log = LoggerFactory.getLogger(CommonController.class); private final ValidateCodeUtil validateCodeUtil; @Autowired @@ -213,10 +216,11 @@ public class CommonController { */ @PostMapping("/subMsg") public Result subscribeWxAccount(@RequestBody WxMsgSubDTO wxMsgSubDTO) { + log.info("接收到订阅消息接口调用,携带数据: {}", wxMsgSubDTO); if (wxMsgSubDTO.getOpenId() == null || wxMsgSubDTO.getShopId() == null) { return Result.fail("shopId或openId缺失"); } - loginService.addShopId(wxMsgSubDTO.getOpenId(), wxMsgSubDTO.getShopId()); + loginService.addShopId(wxMsgSubDTO.getOpenId(), wxMsgSubDTO.getShopId(), wxMsgSubDTO.getType()); return Result.success(CodeEnum.SUCCESS); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java index b1a1f9b..d18bdf1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopOpenIdMapper.java @@ -26,8 +26,7 @@ public interface TbShopOpenIdMapper { int updateByPrimaryKey(TbShopOpenId record); - @Select("select * from tb_shop_open_id where open_id=#{openId} and shop_id=#{shopId} limit 1") - TbShopOpenId countByOpenId(@Param("openId") String openId, @Param("shopId") Integer shopId); + TbShopOpenId countByOpenId(@Param("openId") String openId, @Param("shopId") Integer shopId, @Param("type") Integer type); @Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1") List selectByShopId(@Param("shopId") Integer shopId); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/WxMsgSubDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/WxMsgSubDTO.java index de1eb52..63ef0f2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/WxMsgSubDTO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/WxMsgSubDTO.java @@ -6,4 +6,5 @@ import lombok.Data; public class WxMsgSubDTO { private String shopId; private String openId; + private Integer type; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index 3f612c3..80e9033 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -4,7 +4,6 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.redis.RedisCst; @@ -20,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.util.*; @@ -64,7 +62,7 @@ public class LoginService { this.shopOpenIdMapper = shopOpenIdMapper; } - public void addShopId(String openId,String shopId) { + public void addShopId(String openId, String shopId, Integer type) { TbUserShopMsg shopMsg= tbUserShopMsgMapper.selectByShopIdAndOpenId(Integer.valueOf(shopId),openId); if(Objects.isNull(shopMsg)){ shopMsg=new TbUserShopMsg(); @@ -76,13 +74,17 @@ public class LoginService { } // 为商家绑定openid - if (shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId)) == null) { + 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); shopOpenIdMapper.insert(shopOpenId); + }else { + tbShopOpenId.setUpdateTime(DateUtil.date()); + shopOpenIdMapper.updateByPrimaryKeySelective(tbShopOpenId); } } @@ -95,17 +97,17 @@ public class LoginService { shopMsg.setOpenId(openId); shopMsg.setCreateTime(new Date()); shopMsg.setStatus("1"); - tbUserShopMsgMapper.insert(shopMsg); +// tbUserShopMsgMapper.insert(shopMsg); } // 为商家绑定openid - if (shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId)) == null) { + if (shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId), null) == null) { TbShopOpenId shopOpenId = new TbShopOpenId(); shopOpenId.setOpenId(openId); shopOpenId.setCreateTime(DateUtil.date()); shopOpenId.setShopId(Integer.valueOf(shopId)); shopOpenId.setStatus(1); - shopOpenIdMapper.insert(shopOpenId); +// shopOpenIdMapper.insert(shopOpenId); } return Result.success(CodeEnum.SUCCESS,shopMsg); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java index 9182672..0c11041 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java @@ -264,7 +264,7 @@ public class UserService { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Resource resource = resourceLoader.getResource("classpath:/static/logo.jpg"); InputStream inputStream = resource.getInputStream(); - QrCodeUtil.generate(wxAccountUtil.getRadarQrCode(Integer.valueOf(shopId)), new QrConfig(500, 500). + QrCodeUtil.generate(wxAccountUtil.getRadarQrCode(Integer.valueOf(shopId), -1), new QrConfig(500, 500). setImg(ImageIO.read(inputStream)).setErrorCorrection(ErrorCorrectionLevel.H).setRatio(4), "png", outputStream); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java index 62d2dfa..62349d0 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java @@ -47,13 +47,13 @@ public class WxAccountUtil { // sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI"); } - public static String getRadarQrCode(Integer shopId) { + public static String getRadarQrCode(Integer shopId, Integer type) { HashMap req = new HashMap<>(); req.put("expire_seconds", 300); req.put("action_name", "QR_STR_SCENE"); HashMap actionInfo = new HashMap<>(); HashMap scene = new HashMap<>(); - scene.put("scene_str", "msg" + shopId); + scene.put("scene_str", "msg" + shopId + ":" + type); actionInfo.put("scene", scene); req.put("action_info", actionInfo); log.info("开始获取公众号二维码, 请求数据: {}", req); diff --git a/src/main/resources/mapper/TbShopOpenIdMapper.xml b/src/main/resources/mapper/TbShopOpenIdMapper.xml index 67b9381..db80e80 100644 --- a/src/main/resources/mapper/TbShopOpenIdMapper.xml +++ b/src/main/resources/mapper/TbShopOpenIdMapper.xml @@ -22,12 +22,21 @@ select from tb_shop_open_id - where id = #{id,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} + + delete from tb_shop_open_id - where id = #{id,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} insert into tb_shop_open_id @@ -76,16 +85,16 @@ update_time = #{updateTime,jdbcType=TIMESTAMP}, - where id = #{id,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} update tb_shop_open_id - set + set shop_id = #{shopId,jdbcType=INTEGER}, open_id = #{openId,jdbcType=VARCHAR}, status = #{status,jdbcType=TINYINT}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} From 5cdc276b0c84027db78dc01a576f19b8d04dac9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Mon, 19 Aug 2024 17:36:55 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E7=94=A8=E6=88=B7=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=85=85=E5=80=BC=E9=87=91=E9=A2=9D=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LoginContoller.java | 3 +-- .../controller/UserContoller.java | 1 + .../cashierservice/entity/TbShopInfo.java | 2 ++ .../cashierservice/entity/TbShopUser.java | 18 ++++++++++++++++++ src/main/resources/mapper/TbShopInfoMapper.xml | 4 +++- src/main/resources/mapper/TbUserInfoMapper.xml | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index cbdcdb2..ba1d76f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -125,8 +125,7 @@ public class LoginContoller { // try{ // String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr); // if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) { -// phone =JSONObject.parseObject(data).get("phoneNumber").toString(); -// } +// }// phone =JSONObject.parseObject(data).get("phoneNumber").toString(); // }catch (Exception e){ // log.info("登录传参:获取手机号失败{}",e.getMessage()); // } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index 2908836..8f130ae 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -102,6 +102,7 @@ public class UserContoller { shopUser.setAmount(BigDecimal.ZERO); } if (tbShopInfo != null) { + shopUser.setIsUser(tbShopInfo.getIsCustom()); shopUser.setShopName(tbShopInfo.getShopName()); }else { shopUser.setShopName(""); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java index 2d8b7e9..4e94053 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java @@ -111,6 +111,8 @@ public class TbShopInfo implements Serializable { private String cities; private String districts; + private String isCustom; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java index 9531fdf..684c484 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java @@ -1,5 +1,7 @@ package com.chaozhanggui.system.cashierservice.entity; +import org.springframework.data.annotation.Transient; + import java.io.Serializable; import java.math.BigDecimal; @@ -65,6 +67,14 @@ public class TbShopUser implements Serializable { private String miniOpenId; private String shopName; + @Transient + private String isUser; + + + + + + private static final long serialVersionUID = 1L; public String getId() { @@ -307,4 +317,12 @@ public class TbShopUser implements Serializable { public void setMiniOpenId(String miniOpenId) { this.miniOpenId = miniOpenId == null ? null : miniOpenId.trim(); } + + public String getIsUser() { + return isUser; + } + + public void setIsUser(String isUser) { + this.isUser = isUser; + } } \ No newline at end of file diff --git a/src/main/resources/mapper/TbShopInfoMapper.xml b/src/main/resources/mapper/TbShopInfoMapper.xml index 47dc761..9844f1a 100644 --- a/src/main/resources/mapper/TbShopInfoMapper.xml +++ b/src/main/resources/mapper/TbShopInfoMapper.xml @@ -52,6 +52,8 @@ + + @@ -64,7 +66,7 @@ detail, lat, lng, mch_id, register_type, is_wx_ma_independent, address, city, type, industry, industry_name, business_start_day,business_end_day,business_time, post_time, post_amount_line, on_sale, settle_type, settle_time, enter_at, expire_at, status, average, order_wait_pay_minute, support_device_number, - distribute_level, created_at, updated_at, proxy_id, shop_qrcode, tag,is_open_yhq,is_use_vip,provinces,cities,districts + distribute_level, created_at, updated_at, proxy_id, shop_qrcode, tag,is_open_yhq,is_use_vip,provinces,cities,districts,is_custom view diff --git a/src/main/resources/mapper/TbUserInfoMapper.xml b/src/main/resources/mapper/TbUserInfoMapper.xml index d42bf03..7f5ec68 100644 --- a/src/main/resources/mapper/TbUserInfoMapper.xml +++ b/src/main/resources/mapper/TbUserInfoMapper.xml @@ -50,6 +50,7 @@ + id, amount, charge_amount, line_of_credit, consume_amount, consume_number, total_score,