@Wahson
2019-10-09T02:55:49.000000Z
字数 2826
阅读 593
1. 报价可强制立即推送
2. 可指定区域(城市)、牌号、公司推送
3. 记录每个用户推送记录
4. 限制每个客户每天推送次数
5. 可自定义发送模板部分内容(除发送时间,报价详情)
6. 发送预览功能,给自己先发一条消息,确保内容符合要求,再群发用户
7. 权限管理,仅管理员以上可以看到主动推送功能
消息发送成功后,保存发送历史,更新推送记录,记录发送时间,累计发送次数
业务消息指业务流程上的消息通知,如订单成交通知等,报价消息指定时、主动推送的报价消息
create table wx_push_his(
id bigint not null auto_increment primary key,
wx_user_id bigint not null comment '微信用户id',
content varchar(512) not null comment '推送内容,json',
inner_app_id int(3) not null comment 'wx_app.id',
push_type smallint(3) not null comment '推送类型,1:业务通知(biz_notice);2:报价通知(price_notice)',
created_at timestamp default current_timestamp() not null,
remark varchar(64) null comment '备注'
) charset = utf8mb4 engine = innoDb comment '微信消息推送历史';
create table wx_push_record(
id bigint not null auto_increment primary key,
wx_user_id bigint not null comment '微信用户id',
inner_app_id int(3) not null comment 'wx_app.id',
times_of_curr_day int(3) not null default 0 comment '当天推送次数,每天清零',
last_push_at timestamp not null comment '上一次推送时间',
push_type smallint(3) not null comment '推送类型,1:业务提醒(biz_notice);2:报价通知(price_notice)',
created_at timestamp default current_timestamp() not null,
updated_at timestamp default current_timestamp() not null,
remark varchar(64) null comment '备注',
constraint uniq_user_app unique (wx_user_id, inner_app_id, push_type)
) charset = utf8mb4 engine = innoDb comment '微信推送记录表';
actor初始化时缓存策略数据,通过binlog(增,删,改)进行更新
一个app_id会有多个策略,查询返回数组
create table wx_push_strategy(
id bigint not null auto_increment primary key,
inner_app_id int(3) not null comment 'wx_app.id',
min_interval smallint(5) not null comment '推送最小间隔,单位:分钟',
max_times_of_period smallint(5) default null comment '每个用户在本推送时段内推送最多次数,为null时为无限次',
push_start_time time default '10:00:00' not null comment '推送开始时间',
push_end_time time default '17:00:00' not null comment '推送结束时间',
created_at timestamp default current_timestamp() not null,
updated_at timestamp default current_timestamp() not null,
remark varchar(64) null comment '备注',
key idx_app_id(inner_app_id)
) charset = utf8mb4 engine = innoDb comment '微信消息推送策略';
use product_db;
create table product_offer_stats(
id int(10) not null auto_increment primary key ,
product_id int not null comment '产品id',
category varchar(12) not null comment '产品分类',
designation varchar(32) not null comment '产品牌号',
manufacturer_id int not null comment '生产商ID',
manufacturer_name varchar(32) not null comment '生产商名称',
min_price decimal(13, 2) default 0.00 not null comment '最低价',
max_price decimal(13, 2) default 0.00 not null comment '最高价',
avg_price decimal(13, 2) default 0.00 not null comment '均价',
offer_date date not null comment '报价日期',
created_at timestamp default current_timestamp() not null,
key idx_offer_date_product(offer_date, product_id)
) charset = utf8mb4 engine = innoDb comment '报价统计';
select * from product_offer_stats where product_id = 1 and offer_date > current_date - 5 order by offer_date desc limit 1;
explain select * from product_offer_stats where id in (select max(id)
from product_offer_stats
where offer_date > current_date - 5
group by product_id
)