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

This commit is contained in:
SongZhang 2024-07-05 14:22:42 +08:00
commit 6ef9a10639
8 changed files with 86 additions and 62 deletions

View File

@ -1,13 +1,10 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.dao.TbUserShopMsgMapper;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.WxMpQrcodeService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
@ -19,7 +16,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.*;

View File

@ -6,16 +6,18 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface TbUserShopMsgMapper {
int deleteByPrimaryKey(Integer shopId);
int deleteByPrimaryKey(Integer id);
int insert(TbUserShopMsg record);
int insertSelective(TbUserShopMsg record);
TbUserShopMsg selectByPrimaryKey(Integer shopId);
TbUserShopMsg selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbUserShopMsg record);
@ -23,4 +25,7 @@ public interface TbUserShopMsgMapper {
@Select("select * from tb_user_shop_msg where shop_id=#{shopId}")
TbUserShopMsg selectByShopId(@Param("shopId") String shopId);
}
List<TbUserShopMsg> selectAllByShopId(@Param("shopId") Integer shopId);
}

View File

@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.Date;
public class TbUserShopMsg implements Serializable {
private Integer id;
private Integer shopId;
private String openId;
@ -18,6 +20,14 @@ public class TbUserShopMsg implements Serializable {
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getShopId() {
return shopId;
}

View File

@ -116,48 +116,52 @@ public class ConsMsgConsumer {
String key = redisUtil.getMessage(RedisCst.ORDER_MESSAGE.concat(tbConsInfo.getShopId().toString()).concat("#").concat(tbConsInfo.getId().toString()));
if (Objects.isNull(key)) {
TbUserShopMsg tbUserShopMsg = tbUserShopMsgMapper.selectByPrimaryKey(tbConsInfo.getShopId());
if (Objects.nonNull(tbUserShopMsg) && Objects.nonNull(tbUserShopMsg.getOpenId())) {
JSONObject access_token = getAccessToken();
String accessToken = String.valueOf(access_token.get("access_token"));
List<TbUserShopMsg> tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId());
if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) {
JSONObject object1 = new JSONObject();
for (TbUserShopMsg tbUserShopMsg : tbUserShopMsgs) {
JSONObject access_token = getAccessToken();
String accessToken = String.valueOf(access_token.get("access_token"));
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
object1.put("touser", tbUserShopMsg.getOpenId());
JSONObject object1 = new JSONObject();
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
object1.put("touser", tbUserShopMsg.getOpenId());
JSONObject data = new JSONObject();
JSONObject data = new JSONObject();
JSONObject thing1 = new JSONObject();
thing1.put("value", shopInfo.getShopName());
JSONObject thing1 = new JSONObject();
thing1.put("value", shopInfo.getShopName());
JSONObject thing5 = new JSONObject();
thing5.put("value", "耗材库存不足,请及时补充。");
JSONObject thing5 = new JSONObject();
thing5.put("value", "耗材库存不足,请及时补充。");
JSONObject thing6 = new JSONObject();
thing6.put("value", product.getName());
JSONObject thing6 = new JSONObject();
thing6.put("value", product.getName());
JSONObject thing7 = new JSONObject();
thing7.put("value", tbConsInfo.getStockNumber().toPlainString());
JSONObject thing7 = new JSONObject();
thing7.put("value", tbConsInfo.getStockNumber().toPlainString());
data.put("thing1", thing1);
data.put("thing6", thing6);
data.put("number7", thing7);
data.put("thing5", thing5);
data.put("thing1", thing1);
data.put("thing6", thing6);
data.put("number7", thing7);
data.put("thing5", thing5);
object1.put("data", data);
object1.put("data", data);
object1.put("miniprogram_state", miniprogramState);
object1.put("lang", "zh_CN");
object1.put("miniprogram_state", miniprogramState);
object1.put("lang", "zh_CN");
String response = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
log.info("返回结果:{}", response);
JSONObject resObj = JSONObject.parseObject(response);
if (ObjectUtil.isNotEmpty(resObj) && ObjectUtil.isNotNull(resObj) && "0".equals(String.valueOf(resObj.get("errcode")))) {
redisUtil.saveMessage(key, object1.toString(),10*60*1000);
String response = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
log.info("返回结果:{}", response);
JSONObject resObj = JSONObject.parseObject(response);
if (ObjectUtil.isNotEmpty(resObj) && ObjectUtil.isNotNull(resObj) && "0".equals(String.valueOf(resObj.get("errcode")))) {
redisUtil.saveMessage(key, object1.toString(),10*60*1000);
}
}
}
}

View File

@ -44,6 +44,9 @@ public class ConsService {
String orderId=jsonObject.getString("orderId");
Thread.sleep(1000L);
List<TbOrderDetail> orderDetails= tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(Objects.isNull(orderDetails)||orderDetails.size()<=0){
@ -71,17 +74,17 @@ public class ConsService {
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum()));
flow.setAmount(amount);
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount));
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
flow.setBizCode("createCart");
flow.setBizName("加入购物车消耗");
flow.setBizName("销售扣除");
flow.setBizType("-");
}else if("delete".equals(type)){
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())).negate();
flow.setAmount(amount.abs());
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount));
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
flow.setBizCode("cancelCart");
flow.setBizName("取消购物车返回");
flow.setBizName("退单返还");
flow.setBizType("+");
}

View File

@ -544,9 +544,6 @@ public class OrderService {
jsonObject.put("type","create");
producer.cons(jsonObject.toString());
return Result.success(CodeEnum.SUCCESS, orderInfo);
}

View File

@ -52,14 +52,8 @@
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<table tableName="tb_cons_info" domainObjectName="TbConsInfo"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" >
</table>
<table tableName="tb_prosku_con" domainObjectName="TbProskuCon"
<table tableName="tb_user_shop_msg" domainObjectName="TbUserShopMsg"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" >
</table>

View File

@ -2,7 +2,8 @@
<!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 column="shop_id" jdbcType="INTEGER" property="shopId" />
<id column="id" jdbcType="INTEGER" property="id" />
<result 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" />
@ -10,29 +11,32 @@
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
shop_id, open_id, remark, status, create_time, update_time
id, 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}
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_user_shop_msg
where shop_id = #{shopId,jdbcType=INTEGER}
where id = #{id,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 into tb_user_shop_msg (id, shop_id, open_id,
remark, status, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{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="id != null">
id,
</if>
<if test="shopId != null">
shop_id,
</if>
@ -53,6 +57,9 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="shopId != null">
#{shopId,jdbcType=INTEGER},
</if>
@ -76,6 +83,9 @@
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
update tb_user_shop_msg
<set>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
<if test="openId != null">
open_id = #{openId,jdbcType=VARCHAR},
</if>
@ -92,15 +102,20 @@
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where shop_id = #{shopId,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
update tb_user_shop_msg
set open_id = #{openId,jdbcType=VARCHAR},
set shop_id = #{shopId,jdbcType=INTEGER},
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}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectAllByShopId" resultMap="BaseResultMap">
select * from tb_user_shop_msg where shop_id=#{shopId}
</select>
</mapper>