Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserShopMsgMapper.java
#	src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserShopMsg.java
#	src/main/resources/mapper/TbUserShopMsgMapper.xml
This commit is contained in:
SongZhang 2024-06-28 14:12:24 +08:00
commit dbfd971f26
16 changed files with 259 additions and 184 deletions

View File

@ -29,6 +29,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@CrossOrigin(origins = "*")
@RestController
@ -60,32 +61,18 @@ public class LoginContoller {
RedisUtil redisUtil;
// @RequestMapping("/wx/business/login")
@RequestMapping("/wx/business/login")
public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code,
@RequestParam(value = "rawData", required = false) String rawData,
@RequestParam(value = "signature", required = false) String signature
@RequestParam(value = "shopId", required = false) String shopId
) {
// 用户非敏感信息rawData
// 签名signature
JSONObject rawDataJson = JSON.parseObject(rawData);
// 1.接收小程序发送的code
// 2.开发者服务器 登录凭证校验接口 appi + appsecret + code
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, businessAppId, businessSecrete);
// 3.接收微信接口服务 获取返回的参数
String openid = SessionKeyOpenId.getString("openid");
String sessionKey = SessionKeyOpenId.getString("session_key");
// 4.校验签名 小程序发送的签名signature与服务器端生成的签名signature2 = sha1(rawData + sessionKey)
String signature2 = DigestUtils.sha1Hex(rawData + sessionKey);
if (!signature.equals(signature2)) {
return Result.fail("签名校验失败");
if(Objects.isNull(openid)){
return Result.fail("获取微信id失败");
}
return Result.success(CodeEnum.ENCRYPT);
return loginService.wxBusinessLogin(openid,shopId);
}
/**

View File

@ -148,4 +148,10 @@ public class UserContoller {
// String userSign = jsonObject.getString("userSign");
return userService.userAll(integralFlowVo,"userSign");
}
}

View File

@ -2,6 +2,8 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
/**
* @author Administrator
@ -9,7 +11,10 @@ import org.apache.ibatis.annotations.Select;
* @createDate 2024-06-28 09:55:30
* @Entity com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg
*/
@Component
@Mapper
public interface TbUserShopMsgMapper {
int deleteByPrimaryKey(Integer shopId);
int deleteByPrimaryKey(Long id);
@ -17,12 +22,11 @@ public interface TbUserShopMsgMapper {
int insertSelective(TbUserShopMsg record);
TbUserShopMsg selectByPrimaryKey(Integer shopId);
TbUserShopMsg selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(TbUserShopMsg record);
int updateByPrimaryKey(TbUserShopMsg record);
@Select("select * from tb_user_shop_msg where shop_id=#{shopId}")
TbUserShopMsg selectByShopId(String shopId);
}

View File

@ -2,93 +2,67 @@ package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
* @TableName tb_user_shop_msg
*/
@Data
public class TbUserShopMsg implements Serializable {
/**
*
*/
private Integer shopId;
/**
*
*/
private String openId;
/**
*
*/
private String remark;
/**
* 状态 1 正常 0 禁用
*/
private String status;
/**
*
*/
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;
}
TbUserShopMsg other = (TbUserShopMsg) that;
return (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
&& (this.getOpenId() == null ? other.getOpenId() == null : this.getOpenId().equals(other.getOpenId()))
&& (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
public Integer getShopId() {
return shopId;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
result = prime * result + ((getOpenId() == null) ? 0 : getOpenId().hashCode());
result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
return result;
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", shopId=").append(shopId);
sb.append(", openId=").append(openId);
sb.append(", remark=").append(remark);
sb.append(", status=").append(status);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
public String getOpenId() {
return openId;
}
}
public void setOpenId(String openId) {
this.openId = openId == null ? null : openId.trim();
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status == null ? null : status.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

View File

@ -114,4 +114,22 @@ public class RabbitConfig {
public Binding bindingcons_Register() {
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT);
}
@Bean
public DirectExchange cons_msg_Exchange_Register() {
return new DirectExchange(RabbitConstants.CONS_MSG_COLLECT_PUT);
}
@Bean
public Queue queuecons_msg_Register() {
return new Queue(RabbitConstants.CONS_MSG_COLLECT_QUEUE_PUT, true); //队列持久
}
@Bean
public Binding bindingcons_msg_Register() {
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT);
}
}

View File

@ -49,4 +49,14 @@ public interface RabbitConstants {
public static final String CONS_COLLECT_ROUTINGKEY_PUT = "cons_collect_routingkey_put";
public static final String CONS_MSG_COLLECT_PUT="cons_msg_collect_put";
public static final String CONS_MSG_COLLECT_QUEUE_PUT = "cons_msg_collect_queue_put";
public static final String CONS_MSG_COLLECT_ROUTINGKEY_PUT = "cons_msg_collect_routingkey_put";
}

View File

@ -51,7 +51,10 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);
}
public void con_msg(String content){
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.CONS_MSG_COLLECT_PUT, RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT, content, correlationId);
}
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {

View File

@ -130,6 +130,16 @@ public class CartService {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
JSONObject objectMsg=new JSONObject();
objectMsg.put("skuId",tbProductSkuWithBLOBs.getId());
objectMsg.put("shopId",Integer.valueOf(shopId));
producer.con_msg(objectMsg.toString());
if (Integer.valueOf(tbProduct.getIsPauseSale()).equals(1)) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
@ -149,6 +159,11 @@ public class CartService {
redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":product" + productId, tbProduct.getStockNumber() + "");
}
skuNum = redisUtil.getMessage(RedisCst.PRODUCT + shopId + ":product" + productId);
if (!skuNum.equals(tbProduct.getStockNumber() + "")) {
skuNum = tbProduct.getStockNumber() + "";
redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":product" + productId, skuNum);
}
} else {
boolean exist = redisUtil.exists(RedisCst.PRODUCT + shopId + ":" + skuId);
if (!exist) {
@ -156,6 +171,11 @@ public class CartService {
redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":" + skuId, Math.round(stock) + "");
}
skuNum = redisUtil.getMessage(RedisCst.PRODUCT + shopId + ":" + skuId);
if (!skuNum.equals(Math.round(tbProductSkuWithBLOBs.getStockNumber()) + "")) {
skuNum = Math.round(tbProductSkuWithBLOBs.getStockNumber()) + "";
redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":product" + productId, skuNum);
}
}
Integer buyNum = jsonObject.getInteger("num");

View File

@ -53,6 +53,34 @@ public class LoginService {
RedisUtil redisUtil;
@Autowired
TbUserShopMsgMapper tbUserShopMsgMapper;
public Result wxBusinessLogin(String openId,String shopId){
TbUserShopMsg shopMsg= tbUserShopMsgMapper.selectByPrimaryKey(Integer.valueOf(shopId));
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);
}else {
shopMsg.setOpenId(openId);
shopMsg.setUpdateTime(new Date());
tbUserShopMsgMapper.updateByPrimaryKey(shopMsg);
}
return Result.success(CodeEnum.SUCCESS,shopMsg);
}
@Transactional(rollbackFor = Exception.class)
public Result wxCustomLogin(String openId, String headImage, String nickName, String telephone, String ip) throws Exception {
TbUserInfo userInfo = new TbUserInfo();

View File

@ -19,6 +19,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
public class FeieyunPrintUtil {

View File

@ -89,7 +89,10 @@ public class PrinterUtils {
sb.append("<C><B>"+detailPO.getMerchantName()+"</B></C><BR><BR>");
sb.append("<C><BOLD>"+type+""+detailPO.getMasterId()+"】</BOLD></C><BR><BR>");
sb.append("<CB><BOLD>"+detailPO.getOutNumber()+"</BOLD></CB><BR><BR>");
if(Objects.nonNull(detailPO.getOutNumber())){
sb.append("<CB><BOLD>"+detailPO.getOutNumber()+"</BOLD></CB><BR><BR>");
}
sb.append("<S><L>订单号: "+detailPO.getOrderNo()+" </L></S><BR>");
sb.append("<S><L>交易时间: "+detailPO.getTradeDate()+" </L></S><BR>");
sb.append("<S><L>收银员: "+detailPO.getOperator()+" </L></S><BR><BR><BR>");

View File

@ -59,6 +59,9 @@ server:
port: 9888
prod: dev1
queue: cart_queue_putdev1
subscribe:
message:
miniprogramState: trial

View File

@ -56,6 +56,9 @@ thirdPay:
callFSTBack: https://cashier.sxczgkj.cn${server.servlet.context-path}notify/notifyfstCallBack
prod: prod1
queue: cart_queue_putprod1
subscribe:
message:
miniprogramState: formal

View File

@ -5,8 +5,8 @@ server:
wx:
login:
business:
appId:
secrete:
appId: wxcf0fe8cdba153fd6
secrete: c33e06467c6879a62af633d50ed6b720
custom:
appId: wxd88fffa983758a30
secrete: a34a61adc0602118b49400baa8812454

View File

@ -915,7 +915,7 @@
<update id="updateStockById">
update tb_product
set stock_number = stock_number - #{number,jdbcType=INTEGER}
set stock_number = stock_number - #{num,jdbcType=INTEGER}
where id = #{productId}
</update>

View File

@ -1,91 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbUserShopMsgMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
<id property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="openId" column="open_id" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
shop_id,open_id,remark,
status,create_time,update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_user_shop_msg
where shop_id = #{shopId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from tb_user_shop_msg
where shop_id = #{shopId,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="shop_id" keyProperty="shopId" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg" useGeneratedKeys="true">
insert into tb_user_shop_msg
( shop_id,open_id,remark
,status,create_time,update_time
)
values (#{shopId,jdbcType=INTEGER},#{openId,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR}
,#{status,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" keyColumn="shop_id" keyProperty="shopId" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg" useGeneratedKeys="true">
insert into tb_user_shop_msg
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="shopId != null">shop_id,</if>
<if test="openId != null">open_id,</if>
<if test="remark != null">remark,</if>
<if test="status != null">status,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="shopId != null">#{shopId,jdbcType=INTEGER},</if>
<if test="openId != null">#{openId,jdbcType=VARCHAR},</if>
<if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
<if test="status != null">#{status,jdbcType=VARCHAR},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
update tb_user_shop_msg
<set>
<if test="openId != null">
open_id = #{openId,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where shop_id = #{shopId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
update tb_user_shop_msg
set
open_id = #{openId,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where shop_id = #{shopId,jdbcType=INTEGER}
</update>
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
<id column="shop_id" jdbcType="INTEGER" property="shopId" />
<result column="open_id" jdbcType="VARCHAR" property="openId" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
shop_id, open_id, remark, status, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_user_shop_msg
where shop_id = #{shopId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_user_shop_msg
where shop_id = #{shopId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
insert into tb_user_shop_msg (shop_id, open_id, remark,
status, create_time, update_time
)
values (#{shopId,jdbcType=INTEGER}, #{openId,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
insert into tb_user_shop_msg
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="shopId != null">
shop_id,
</if>
<if test="openId != null">
open_id,
</if>
<if test="remark != null">
remark,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="shopId != null">
#{shopId,jdbcType=INTEGER},
</if>
<if test="openId != null">
#{openId,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
update tb_user_shop_msg
<set>
<if test="openId != null">
open_id = #{openId,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where shop_id = #{shopId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
update tb_user_shop_msg
set open_id = #{openId,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where shop_id = #{shopId,jdbcType=INTEGER}
</update>
</mapper>