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 1/2] =?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 2/2] =?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,