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,18 +55,12 @@ 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);
}
}
}
}
return null;
@ -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

@ -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,6 +159,7 @@ 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 -> {
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());
"商品库存不足,请及时补充。", 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,7 +27,7 @@
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">
@ -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,6 +135,9 @@
<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}
</update>
@ -138,7 +146,7 @@
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}
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

@ -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>