促销价格 功能设计
2015-07-29 18:16
295 查看
原理 : 需要用到cron计划任务, 访问变动的url (即类名下的方法)
在专家需要进行一场活动时, 首先填写 未来时间段的开始时间、结束时间以及这时间段的商品价格。记录到活动表中
同时 ,将商品表中的act_price进行填写活动价
在活动开始前,一切以原价展示,进行中将原价和活动价交换,(因为页面始终显示的是原价的字段,为了统一)。 活动结束后,再将 原价和活动价交换。
表:
1、商品表 、活动表
其中活动表有一个记录状态,为方便价格相互交换
字段 status int 10 默认为0 【注释:活动状态:0 未开始 1进行中 2活动已结束】
定时 访问 http://xxx/index.php?s=/addon/Activity/Activity/endactivity http://xxx//index.php?s=/addon/Activity/Activity/startactivity
在专家需要进行一场活动时, 首先填写 未来时间段的开始时间、结束时间以及这时间段的商品价格。记录到活动表中
同时 ,将商品表中的act_price进行填写活动价
在活动开始前,一切以原价展示,进行中将原价和活动价交换,(因为页面始终显示的是原价的字段,为了统一)。 活动结束后,再将 原价和活动价交换。
表:
1、商品表 、活动表
其中活动表有一个记录状态,为方便价格相互交换
字段 status int 10 默认为0 【注释:活动状态:0 未开始 1进行中 2活动已结束】
定时 访问 http://xxx/index.php?s=/addon/Activity/Activity/endactivity http://xxx//index.php?s=/addon/Activity/Activity/startactivity
//活动后期后,价格恢复原价 public function endactivity(){ $current_time = time(); //var_dump($current_time);exit(); //$act=M('activity')->where('act_starttime EGT '.$zuotian.' and act_starttime ELT ' .$mingtian)->select(); //$act=M('activity')->where('act_starttime >= '.$zuotian.' and act_starttime <= ' .$mingtian)->select(); $act=M('activity')->where('act_endtime <= ' .$current_time.' and status <>2')->select(); var_dump(M('activity')->getlastsql());exit(); foreach($act as $val){ $act_shopid=explode(',',$val['act_shopid']); M('activity')->where('id = ' .$val['id'])->setField('status',2); //var_dump(M('activity')->getlastsql()); //var_dump($act_shopid);exit(); foreach($act_shopid as $val){ if($val){ $shopdate=M('goodsshop')->where('id='.$val)->find(); $date=array('price'=>$shopdate['act_price'],'act_price'=>$shopdate['price']); M('goodsshop')->where('id='.$val)->save($date); } } } echo "update activity is over!"; } //活动由未开始,变为进行中, 活动价为当前价 public function startactivity(){ $current_time = time(); //$act=M('activity')->where('act_endtime ELT '.$zuotian.' and act_endtime EGT ' .$mingtian)->select(); $act=M('activity')->where('act_starttime <= '.$current_time.' and act_endtime >= ' .$current_time.' and status=0')->select(); //var_dump(M('activity')->getlastsql());exit(); foreach($act as $val){ $act_shopid=explode(',',$val['act_shopid']); M('activity')->where('id = ' .$val['id'])->setField('status',1); foreach($act_shopid as $val){ if($val){ $shopdate=M('goodsshop')->where('id='.$val)->find(); $date=array('price'=>$shopdate['act_price'],'act_price'=>$shopdate['price']); M('goodsshop')->where('id='.$val)->save($date); } var_dump(M('goodsshop')->getlastsql()); } } echo "update activity is over!"; }
相关文章推荐
- source、sh、bash、./执行脚本的区别
- 关于回调函数的个人理解
- 函数柯里化or not
- HTML5实现摇一摇
- 关于卫星RNSS与RDSS
- 运行时类型标识RTTI常见问题分析
- 如何查看Oracle数据库表空间大小(空闲、已使用),是否要增加表空间的数据文件
- shiro实现HasAnyPermission 标签效果
- RabbitMQ 快速入门
- 判断图片上传
- Maven零散笔记——常用配置(tomcat-maven-plugin)
- 并发管理器的工作原理 和 cmclean.sql的潜在危险
- The Podfile
- 手动创建UIWindow及UIWindowLevel的说明
- java中 Unicode和UTF-8的关系
- 机器学习—k近邻与kd树
- 解析大型.NET ERP系统数据访问 对象关系映射框架LLBL Gen Pro
- 一个使用超简单C++封装的网络库(包含服务器端和客户端,跨平台,比较适用于移动终端)
- 常用命令
- C++加密解密php代码的方法