消息通知
This commit is contained in:
parent
f98a988b94
commit
6253917cf3
|
|
@ -45,4 +45,6 @@ public interface ProductMapper extends BaseMapper<Product> {
|
|||
|
||||
List<RecommendProVO> getTodayProInfo();
|
||||
|
||||
String getShopName(@Param("shopId") Long shopId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.czg.product.vo.ConsCheckStockRecordVo;
|
|||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.product.mapper.ConsInfoMapper;
|
||||
import com.czg.service.product.mapper.ConsStockFlowMapper;
|
||||
import com.czg.service.product.mapper.ProductMapper;
|
||||
import com.czg.service.product.util.WxAccountUtil;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
|
|
@ -30,6 +31,7 @@ import com.mybatisflex.core.query.QueryWrapper;
|
|||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -45,9 +47,11 @@ import java.util.List;
|
|||
*/
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, ConsStockFlow> implements ConsStockFlowService {
|
||||
|
||||
private final ConsInfoMapper consInfoMapper;
|
||||
private final ProductMapper productMapper;
|
||||
@Resource
|
||||
private WxAccountUtil wxAccountUtil;
|
||||
|
||||
|
|
@ -234,7 +238,15 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
|
|||
Long shopId = entity.getShopId();
|
||||
BigDecimal afterNumber = entity.getAfterNumber();
|
||||
ConsInfo consInfo = consInfoMapper.selectOneById(entity.getConId());
|
||||
String shopName = StpKit.USER.getShopName();
|
||||
String shopName = "";
|
||||
try {
|
||||
shopName = StpKit.USER.getShopName();
|
||||
} catch (Exception e) {
|
||||
log.error("获取店铺名称失败");
|
||||
}
|
||||
if (StrUtil.isEmpty(shopName)) {
|
||||
shopName = productMapper.getShopName(shopId);
|
||||
}
|
||||
BigDecimal conWarning = consInfo.getConWarning();
|
||||
// 库存小于警告值,发送消息提醒
|
||||
if (NumberUtil.isLess(afterNumber, conWarning)) {
|
||||
|
|
@ -243,9 +255,10 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
|
|||
return;
|
||||
}
|
||||
String conName = StrUtil.format("{}数量<预警值{}", consInfo.getConName(), conWarning);
|
||||
String finalShopName = shopName;
|
||||
ThreadUtil.execAsync(() -> {
|
||||
openIdList.parallelStream().forEach(openId -> {
|
||||
wxAccountUtil.sendStockMsg(shopName, conName, afterNumber, openId);
|
||||
wxAccountUtil.sendStockMsg(finalShopName, conName, afterNumber, openId);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.czg.service.product.mapper.ProductStockFlowMapper;
|
|||
import com.czg.service.product.util.WxAccountUtil;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -27,6 +28,7 @@ import java.util.List;
|
|||
* @since 2025-03-14 15:45
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ProductStockFlowServiceImpl extends ServiceImpl<ProductStockFlowMapper, ProductStockFlow> implements ProductStockFlowService {
|
||||
|
||||
@Resource
|
||||
|
|
@ -42,7 +44,15 @@ public class ProductStockFlowServiceImpl extends ServiceImpl<ProductStockFlowMap
|
|||
Long shopId = entity.getShopId();
|
||||
BigDecimal afterNumber = entity.getAfterNumber();
|
||||
Product product = productMapper.selectOneById(entity.getProductId());
|
||||
String shopName = StpKit.USER.getShopName();
|
||||
String shopName = "";
|
||||
try {
|
||||
shopName = StpKit.USER.getShopName();
|
||||
} catch (Exception e) {
|
||||
log.error("获取店铺名称失败");
|
||||
}
|
||||
if (StrUtil.isEmpty(shopName)) {
|
||||
shopName = productMapper.getShopName(shopId);
|
||||
}
|
||||
BigDecimal warnLine = Convert.toBigDecimal(product.getWarnLine());
|
||||
// 库存小于警告值,发送消息提醒
|
||||
if (NumberUtil.isLess(afterNumber, warnLine)) {
|
||||
|
|
@ -51,9 +61,10 @@ public class ProductStockFlowServiceImpl extends ServiceImpl<ProductStockFlowMap
|
|||
return;
|
||||
}
|
||||
String conName = StrUtil.format("{}数量<预警值{}", product.getName(), warnLine);
|
||||
String finalShopName = shopName;
|
||||
ThreadUtil.execAsync(() -> {
|
||||
openIdList.parallelStream().forEach(openId -> {
|
||||
wxAccountUtil.sendStockMsg(shopName, conName, afterNumber, openId);
|
||||
wxAccountUtil.sendStockMsg(finalShopName, conName, afterNumber, openId);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,6 +215,9 @@
|
|||
left join tb_shop_info as b on a.shop_id=b.id
|
||||
where c.group_category_id is not null and c.group_category_id != '[]' and c.create_time >= date_format(now(), '%Y-%m-%d 00:00:00')
|
||||
</select>
|
||||
<select id="getShopName" resultType="java.lang.String">
|
||||
select shop_name from tb_shop_info where id = #{shopId}
|
||||
</select>
|
||||
<update id="updateProductStockNum">
|
||||
update tb_product
|
||||
<if test="type == 'add'">
|
||||
|
|
|
|||
Loading…
Reference in New Issue