1.库存预警提示语修改

2.库存预警30分钟内只推送一次
3.点歌支付成功同步保存平台订单号
This commit is contained in:
SongZhang 2024-07-11 09:36:26 +08:00
parent 4b2996adb3
commit 9c9c7d8608
10 changed files with 100 additions and 105 deletions

View File

@ -55,15 +55,9 @@ public class NotifyController {
JSONObject object=JSONUtil.parseObj(map.get("bizData").toString());
if(ObjectUtil.isNotEmpty(object)&&object.containsKey("state")){
if("TRADE_SUCCESS".equals(object.get("state").toString())){
JSONObject extParam = object.getJSONObject("extParam");
String orderNo=object.get("mchOrderNo").toString();
if (ObjectUtil.isNotEmpty(extParam)&&ObjectUtil.isNotNull(extParam)&&PayTypeConstant.MINI_PAY.equals(extParam.getStr("payType"))) {
log.info("接收到微信点歌支付成功回调,订单编号:{}", orderNo);
return payService.songPaySuccess(orderNo, extParam.getStr("orderNo"));
}else {
String tradeNo=object.get("payOrderId").toString();
return payService.fstMemberInSuccess(orderNo,tradeNo);
}
String tradeNo=object.get("payOrderId").toString();
return payService.fstMemberInSuccess(orderNo,tradeNo);
}
}
}
@ -159,8 +153,9 @@ public class NotifyController {
if (ObjectUtil.isNotEmpty(map) && map.containsKey("code") && "000000".equals(map.get("code") + "")) {
JSONObject object = JSONUtil.parseObj(map.get("bizData"));
if (ObjectUtil.isNotEmpty(object) && object.containsKey("state") && "TRADE_SUCCESS".equals(object.getStr("state"))) {
String tradeNo=object.get("payOrderId").toString();
String orderNo = object.getStr("mchOrderNo");
return payService.songOrderSuccess(orderNo, DateUtils.getTime(new Date()));
return payService.songOrderSuccess(orderNo, tradeNo);
}
}
return null;

View File

@ -11,7 +11,7 @@ import java.util.Map;
/**
* @author Administrator
* @description 针对表tb_shop_song_order的数据库操作Mapper
* @createDate 2024-07-09 15:23:30
* @createDate 2024-07-11 09:24:20
* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder
*/
public interface TbShopSongOrderMapper {
@ -38,6 +38,14 @@ public interface TbShopSongOrderMapper {
" <if test=\"state!=null\">AND a.state = #{state}</if></script>")
List<Map<String, Object>> selectByUserId(@Param("openId") String openId, @Param("state") Integer state);
@Select(" SELECT\n" +
" *\n" +
" FROM\n" +
" tb_shop_song_order AS a\n" +
" LEFT JOIN tb_shop_song AS b ON a.song_id = b.id\n" +
" WHERE\n" +
" a.open_id = #{openId}\n" +
" AND a.id=#{id}")
Map<String, Object> selectByUserIdAndId(@Param("openId") String openId, @Param("id") Integer id);
@Select("select * from fycashier.tb_shop_song_order where order_no=#{orderNo};")

View File

@ -6,13 +6,13 @@ import java.util.Date;
import lombok.Data;
/**
*
*
* @TableName tb_shop_song_order
*/
@Data
public class TbShopSongOrder implements Serializable {
/**
*
*
*/
private Integer id;
@ -27,7 +27,7 @@ public class TbShopSongOrder implements Serializable {
private String songName;
/**
* 用户id
* 用户openId
*/
private String openId;
@ -81,6 +81,11 @@ public class TbShopSongOrder implements Serializable {
*/
private BigDecimal realMoney;
/**
* 平台订单号
*/
private String payOrderId;
private static final long serialVersionUID = 1L;
@Override
@ -108,7 +113,8 @@ public class TbShopSongOrder implements Serializable {
&& (this.getToName() == null ? other.getToName() == null : this.getToName().equals(other.getToName()))
&& (this.getNote() == null ? other.getNote() == null : this.getNote().equals(other.getNote()))
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
&& (this.getRealMoney() == null ? other.getRealMoney() == null : this.getRealMoney().equals(other.getRealMoney()));
&& (this.getRealMoney() == null ? other.getRealMoney() == null : this.getRealMoney().equals(other.getRealMoney()))
&& (this.getPayOrderId() == null ? other.getPayOrderId() == null : this.getPayOrderId().equals(other.getPayOrderId()));
}
@Override
@ -129,6 +135,7 @@ public class TbShopSongOrder implements Serializable {
result = prime * result + ((getNote() == null) ? 0 : getNote().hashCode());
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
result = prime * result + ((getRealMoney() == null) ? 0 : getRealMoney().hashCode());
result = prime * result + ((getPayOrderId() == null) ? 0 : getPayOrderId().hashCode());
return result;
}
@ -152,8 +159,9 @@ public class TbShopSongOrder implements Serializable {
sb.append(", note=").append(note);
sb.append(", shopId=").append(shopId);
sb.append(", realMoney=").append(realMoney);
sb.append(", payOrderId=").append(payOrderId);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
}

View File

@ -24,4 +24,5 @@ public class RedisCst {
public static final String OUT_NUMBER="ORDER:NUMBER:";
// 创建订单锁
public static final String CREATE_ORDER_LOCK = "CREATE_ORDER_LOCK:";
public static final String SEND_STOCK_WARN_MSG = "SEND_STOCK_WARN_MSG:";
}

View File

@ -460,9 +460,16 @@ public class CartService {
) {
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectByShopId(Integer.valueOf(product.getShopId()));
shopOpenIds.forEach(item -> {
wechatUtil.sendStockWarnMsg(shopInfo.getShopName(), product.getName(),
product.getIsDistribute() == 1 ? String.valueOf(product.getStockNumber() - num) : String.valueOf(productSku.getStockNumber() - num),
"耗材库存不足,请及时补充。", item.getOpenId());
String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId());
if (message == null) {
wechatUtil.sendStockWarnMsg(shopInfo.getShopName(), product.getName(),
product.getIsDistribute() == 1 ? String.valueOf(product.getStockNumber() - num) : String.valueOf(productSku.getStockNumber() - num),
"商品库存不足,请及时补充。", item.getOpenId());
redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L);
}else {
log.info("{}已在30分钟内推送过消息跳过发送", item.getOpenId());
}
});
}
}

View File

@ -1205,30 +1205,7 @@ public class PayService {
PushToClientChannelHandlerAdapter.getInstance().AppSendInfoV1(orderInfo.getShopId(), orderInfo.getOrderNo(), client);
}
/**
* 点歌支付成功
*
* @param mchOrderNo 商户订单编号
* @param orderNo
* @return
*/
public String songPaySuccess(String mchOrderNo, String orderNo) {
TbMemberIn memberIn = tbMemberInMapper.selectByOrderNo(mchOrderNo);
if (ObjectUtil.isEmpty(memberIn)) {
return "充值记录不存在";
}
if (!"7".equals(memberIn.getStatus())) {
return "订单已处理";
}
memberIn.setTradeNo(orderNo);
memberIn.setStatus("0");
memberIn.setUpdateTime(new Date());
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
shopSongOrderService.successPay(orderNo);
return "success";
}
public Result paySongOrder(String openId, String shopId, Integer orderId, String ip, TbMerchantThirdApply thirdApply) throws JsonProcessingException {
if (ObjectUtil.isEmpty(openId) || Objects.isNull(openId)) {
@ -1237,7 +1214,7 @@ public class PayService {
TbShopSongOrder songOrder = tbShopSongOrderMapper.selectByPrimaryKey(Long.valueOf(orderId));
if (songOrder.getState() != 0 && songOrder.getState() != -1) {
if (songOrder == null || songOrder.getState() != 0 && songOrder.getState() != -1) {
return Result.fail("订单状态异常,不允许支付");
}
@ -1287,14 +1264,14 @@ public class PayService {
}
@Transactional(rollbackFor = Exception.class)
public String songOrderSuccess(String mchOrderNo, String orderNo) {
public String songOrderSuccess(String mchOrderNo, String tradeNo) {
TbShopSongOrder songOrder = tbShopSongOrderMapper.selectByOrderNo(mchOrderNo);
if (ObjectUtil.isEmpty(songOrder)) {
return "订单信息不存在";
}
log.info("更新点歌订单:{}", songOrder);
shopSongOrderService.successPay(mchOrderNo);
shopSongOrderService.successPay(mchOrderNo, tradeNo);
return "SUCCESS";
}

View File

@ -7,7 +7,7 @@ package com.chaozhanggui.system.cashierservice.service;
*/
public interface TbShopSongOrderService {
void successPay(String orderNo);
void successPay(String orderNo, String tradeNo);
void clearExpireOrder();
}

View File

@ -26,13 +26,14 @@ public class TbShopSongOrderServiceImpl
}
@Override
public void successPay(String orderNo) {
public void successPay(String orderNo, String tradeNo) {
TbShopSongOrder shopSongOrder = shopSongOrderMapper.selectByOrderNo(orderNo);
if (shopSongOrder.getState().equals(1)) {
log.warn("点歌支付成功,重复支付,订单编号:{}", orderNo);
return;
}
shopSongOrder.setState(1);
shopSongOrder.setPayOrderId(tradeNo);
shopSongOrder.setRealMoney(shopSongOrder.getPayMoney());
shopSongOrderMapper.updateByPrimaryKeySelective(shopSongOrder);
shopSongMapper.incrNum(1, shopSongOrder.getSongId());

View File

@ -8,7 +8,7 @@
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="songId" column="song_id" jdbcType="INTEGER"/>
<result property="songName" column="song_name" jdbcType="VARCHAR"/>
<result property="openId" column="open_id" jdbcType="INTEGER"/>
<result property="openId" column="open_id" jdbcType="VARCHAR"/>
<result property="payMoney" column="pay_money" jdbcType="DECIMAL"/>
<result property="state" column="state" jdbcType="TINYINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
@ -19,6 +19,7 @@
<result property="note" column="note" jdbcType="VARCHAR"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="realMoney" column="real_money" jdbcType="DECIMAL"/>
<result property="payOrderId" column="pay_order_id" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
@ -26,19 +27,19 @@
open_id,pay_money,state,
create_time,client_type,order_no,
from_name,to_name,note,
shop_id,real_money
shop_id,real_money,pay_order_id
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_shop_song_order
where id = #{id,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from tb_shop_song_order
where id = #{id,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder" useGeneratedKeys="true">
insert into tb_shop_song_order
@ -46,12 +47,14 @@
,open_id,pay_money,state
,create_time,client_type,order_no
,from_name,to_name,note
,shop_id,real_money)
,shop_id,real_money,pay_order_id
)
values (#{id,jdbcType=INTEGER},#{songId,jdbcType=INTEGER},#{songName,jdbcType=VARCHAR}
,#{openId,jdbcType=INTEGER},#{payMoney,jdbcType=DECIMAL},#{state,jdbcType=TINYINT}
,#{openId,jdbcType=VARCHAR},#{payMoney,jdbcType=DECIMAL},#{state,jdbcType=TINYINT}
,#{createTime,jdbcType=TIMESTAMP},#{clientType,jdbcType=TINYINT},#{orderNo,jdbcType=VARCHAR}
,#{fromName,jdbcType=VARCHAR},#{toName,jdbcType=VARCHAR},#{note,jdbcType=VARCHAR}
,#{shopId,jdbcType=INTEGER},#{realMoney,jdbcType=DECIMAL})
,#{shopId,jdbcType=INTEGER},#{realMoney,jdbcType=DECIMAL},#{payOrderId,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder" useGeneratedKeys="true">
insert into tb_shop_song_order
@ -70,12 +73,13 @@
<if test="note != null">note,</if>
<if test="shopId != null">shop_id,</if>
<if test="realMoney != null">real_money,</if>
<if test="payOrderId != null">pay_order_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="songId != null">#{songId,jdbcType=INTEGER},</if>
<if test="songName != null">#{songName,jdbcType=VARCHAR},</if>
<if test="openId != null">#{openId,jdbcType=INTEGER},</if>
<if test="openId != null">#{openId,jdbcType=VARCHAR},</if>
<if test="payMoney != null">#{payMoney,jdbcType=DECIMAL},</if>
<if test="state != null">#{state,jdbcType=TINYINT},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
@ -86,6 +90,7 @@
<if test="note != null">#{note,jdbcType=VARCHAR},</if>
<if test="shopId != null">#{shopId,jdbcType=INTEGER},</if>
<if test="realMoney != null">#{realMoney,jdbcType=DECIMAL},</if>
<if test="payOrderId != null">#{payOrderId,jdbcType=VARCHAR},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder">
@ -98,7 +103,7 @@
song_name = #{songName,jdbcType=VARCHAR},
</if>
<if test="openId != null">
open_id = #{openId,jdbcType=INTEGER},
open_id = #{openId,jdbcType=VARCHAR},
</if>
<if test="payMoney != null">
pay_money = #{payMoney,jdbcType=DECIMAL},
@ -130,15 +135,18 @@
<if test="realMoney != null">
real_money = #{realMoney,jdbcType=DECIMAL},
</if>
<if test="payOrderId != null">
pay_order_id = #{payOrderId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder">
update tb_shop_song_order
set
set
song_id = #{songId,jdbcType=INTEGER},
song_name = #{songName,jdbcType=VARCHAR},
open_id = #{openId,jdbcType=INTEGER},
open_id = #{openId,jdbcType=VARCHAR},
pay_money = #{payMoney,jdbcType=DECIMAL},
state = #{state,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
@ -148,18 +156,8 @@
to_name = #{toName,jdbcType=VARCHAR},
note = #{note,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=INTEGER},
real_money = #{realMoney,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
real_money = #{realMoney,jdbcType=DECIMAL},
pay_order_id = #{payOrderId,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByUserIdAndId" resultType="java.util.Map">
SELECT
*
FROM
tb_shop_song_order AS a
LEFT JOIN tb_shop_song AS b ON a.song_id = b.id
WHERE
a.open_id = #{openId}
AND a.id=#{id}
</select>
</mapper>

View File

@ -53,15 +53,15 @@
</resultMap>
<sql id="Base_Column_List">
id, amount, charge_amount, line_of_credit, consume_amount, consume_number, total_score,
lock_score, card_no, card_password, level_id, head_img, nick_name, telephone, wx_ma_app_id,
birth_day, sex, mini_app_open_id, open_id, union_id, code, type, identify, status,
parent_id, parent_level, parent_type, project_id, merchant_id, is_resource, is_online,
is_vip, vip_effect_at, tips, source_path, is_sales_person, is_attention_mp, city,
search_word, last_log_in_at, last_leave_at, created_at, updated_at, bind_parent_at,
lock_score, card_no, card_password, level_id, head_img, nick_name, telephone, wx_ma_app_id,
birth_day, sex, mini_app_open_id, open_id, union_id, code, type, identify, status,
parent_id, parent_level, parent_type, project_id, merchant_id, is_resource, is_online,
is_vip, vip_effect_at, tips, source_path, is_sales_person, is_attention_mp, city,
search_word, last_log_in_at, last_leave_at, created_at, updated_at, bind_parent_at,
grand_parent_id,password,is_pwd,pwd
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
select
<include refid="Base_Column_List" />
from tb_user_info
where id = #{id,jdbcType=INTEGER}
@ -73,35 +73,35 @@
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserInfo" useGeneratedKeys="true" keyProperty="id">
insert into tb_user_info (id, amount, charge_amount,
line_of_credit, consume_amount, consume_number,
total_score, lock_score, card_no,
card_password, level_id, head_img,
nick_name, telephone, wx_ma_app_id,
birth_day, sex, mini_app_open_id,
open_id, union_id, code,
type, identify, status,
parent_id, parent_level, parent_type,
project_id, merchant_id, is_resource,
is_online, is_vip, vip_effect_at,
tips, source_path, is_sales_person,
is_attention_mp, city, search_word,
last_log_in_at, last_leave_at, created_at,
line_of_credit, consume_amount, consume_number,
total_score, lock_score, card_no,
card_password, level_id, head_img,
nick_name, telephone, wx_ma_app_id,
birth_day, sex, mini_app_open_id,
open_id, union_id, code,
type, identify, status,
parent_id, parent_level, parent_type,
project_id, merchant_id, is_resource,
is_online, is_vip, vip_effect_at,
tips, source_path, is_sales_person,
is_attention_mp, city, search_word,
last_log_in_at, last_leave_at, created_at,
updated_at, bind_parent_at, grand_parent_id,password,is_pwd,pwd
)
values (#{id,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL}, #{chargeAmount,jdbcType=DECIMAL},
#{lineOfCredit,jdbcType=DECIMAL}, #{consumeAmount,jdbcType=DECIMAL}, #{consumeNumber,jdbcType=INTEGER},
#{totalScore,jdbcType=INTEGER}, #{lockScore,jdbcType=INTEGER}, #{cardNo,jdbcType=VARCHAR},
#{cardPassword,jdbcType=VARCHAR}, #{levelId,jdbcType=VARCHAR}, #{headImg,jdbcType=VARCHAR},
#{nickName,jdbcType=VARCHAR}, #{telephone,jdbcType=VARCHAR}, #{wxMaAppId,jdbcType=VARCHAR},
#{birthDay,jdbcType=VARCHAR}, #{sex,jdbcType=TINYINT}, #{miniAppOpenId,jdbcType=VARCHAR},
#{openId,jdbcType=VARCHAR}, #{unionId,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{identify,jdbcType=TINYINT}, #{status,jdbcType=TINYINT},
#{parentId,jdbcType=VARCHAR}, #{parentLevel,jdbcType=VARCHAR}, #{parentType,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{isResource,jdbcType=TINYINT},
#{isOnline,jdbcType=TINYINT}, #{isVip,jdbcType=TINYINT}, #{vipEffectAt,jdbcType=INTEGER},
#{tips,jdbcType=VARCHAR}, #{sourcePath,jdbcType=VARCHAR}, #{isSalesPerson,jdbcType=TINYINT},
#{isAttentionMp,jdbcType=TINYINT}, #{city,jdbcType=VARCHAR}, #{searchWord,jdbcType=VARCHAR},
#{lastLogInAt,jdbcType=BIGINT}, #{lastLeaveAt,jdbcType=BIGINT}, #{createdAt,jdbcType=BIGINT},
#{lineOfCredit,jdbcType=DECIMAL}, #{consumeAmount,jdbcType=DECIMAL}, #{consumeNumber,jdbcType=INTEGER},
#{totalScore,jdbcType=INTEGER}, #{lockScore,jdbcType=INTEGER}, #{cardNo,jdbcType=VARCHAR},
#{cardPassword,jdbcType=VARCHAR}, #{levelId,jdbcType=VARCHAR}, #{headImg,jdbcType=VARCHAR},
#{nickName,jdbcType=VARCHAR}, #{telephone,jdbcType=VARCHAR}, #{wxMaAppId,jdbcType=VARCHAR},
#{birthDay,jdbcType=VARCHAR}, #{sex,jdbcType=TINYINT}, #{miniAppOpenId,jdbcType=VARCHAR},
#{openId,jdbcType=VARCHAR}, #{unionId,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{identify,jdbcType=TINYINT}, #{status,jdbcType=TINYINT},
#{parentId,jdbcType=VARCHAR}, #{parentLevel,jdbcType=VARCHAR}, #{parentType,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{isResource,jdbcType=TINYINT},
#{isOnline,jdbcType=TINYINT}, #{isVip,jdbcType=TINYINT}, #{vipEffectAt,jdbcType=INTEGER},
#{tips,jdbcType=VARCHAR}, #{sourcePath,jdbcType=VARCHAR}, #{isSalesPerson,jdbcType=TINYINT},
#{isAttentionMp,jdbcType=TINYINT}, #{city,jdbcType=VARCHAR}, #{searchWord,jdbcType=VARCHAR},
#{lastLogInAt,jdbcType=BIGINT}, #{lastLeaveAt,jdbcType=BIGINT}, #{createdAt,jdbcType=BIGINT},
#{updatedAt,jdbcType=BIGINT}, #{bindParentAt,jdbcType=BIGINT}, #{grandParentId,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{isPwd,jdbcType=VARCHAR},#{pwd,jdbcType=VARCHAR}
)
@ -585,7 +585,7 @@
<select id="selectByOpenId" resultMap="BaseResultMap">
select * from tb_user_info where mini_app_open_id=#{openId}
select * from tb_user_info where mini_app_open_id=#{openId} limit 1
</select>
@ -595,4 +595,4 @@
<select id="selectAll" resultType="com.chaozhanggui.system.cashierservice.entity.TbUserInfo">
select * from tb_user_info
</select>
</mapper>
</mapper>