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:
2024-06-28 14:12:24 +08:00
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>");