最近项目开发要求实现红包功能,仿微信(不含留言),但只能使用余额发红包。下面小编给大家分享PHP仿微信发红包领红包效果,感兴趣的朋友一起看看吧
近期项目需要在聊天的基础上新增红包功能,需求:仿微信(不含留言),但只能使用余额发红包。于是多次使用微信红包,了解各种交互界面及业务需求,如展示信息、分类(个人,群普通,群拼手气)、个数限制(100)、金额限制(200)、过期时间(24小时)等等,然后着手开发,下面提及的基本全是提供给app端的接口,毕竟我是phper。
一、设计数据表如下
CREATE TABLE `red_packet` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',`for_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '发放对象(用户或群id)',`pay_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '支付状态:0未支付,1已支付',`type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '类型:1、个人,2、群普通,3、群拼手气',`intro` varchar(255) NOT NULL DEFAULT '' COMMENT '简介',`number` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '个数',`total_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.0' COMMENT '总金额',`single_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.0' COMMENT '单个红包金额(群拼手气时为0)',`return_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.0' COMMENT '退还金额',`is_cli_handle` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否经过cli退款处理:0否,1是',`expend_time` mediumint(1) unsigned NOT NULL DEFAULT '0' COMMENT '领取消耗时间',`add_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',`pay_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '支付时间',PRIMARY KEY (`id`),KEY `user_id` (`user_id`),KEY `pay_status` (`pay_status`),KEY `pay_time` (`pay_time`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='红包发放表';CREATE TABLE `red_packet_log` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,`rp_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '红包id',`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '领取人id',`money` decimal(10,2) unsigned NOT NULL DEFAULT '0.0' COMMENT '领取金额',`is_good` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否手气最佳:0否,1是',`add_time` int(10) un<strong>(本文来源gaodai#ma#com搞@@代~&码网</strong><pre>搞代gaodaima码
signed NOT NULL DEFAULT '0' COMMENT '添加时间',`update_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '领取时间',PRIMARY KEY (`id`),KEY `rp_id` (`rp_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='红包领取日志表';
二、发红包