目的: 目前ecmall的优惠券有开始时间和结束时间两种,但是如果商家希望实现满100送20购物券1个月有效,那么商家就得建立12个优惠券时间类型很不方便。因此我们考虑增加一个过期模式,即以优惠券当天为起始时间增加一个固定过期时间。例如发券后30天内使用有效。
具体修改方法 1.增加mysql数据列 ---优惠卷增加赠与时间 ALTER TABLE `ecm_user_coupon` ADD `send_time` INT( 10 ) NULL DEFAULT '0' ALTER TABLE `ecm_coupon` ADD `exptype` TINYINT( 1 ) NULL DEFAULT '0' ALTER TABLE `ecm_coupon` ADD `all_shop` TINYINT( 1 ) NULL DEFAULT '0' ALTER TABLE `ecm_coupon` ADD `expday` INT( 10 ) NULL DEFAULT '0' 2.coupon.form.html 增加 <li> <h3>{$lang.time_limit1}:</h3> <p><input type="radio" name="exptype" value="0" <!--{if !$coupon.exptype}-->checked<!--{/if}--> /> <input type="text" class="text width2" name="start_time" value="<!--{if $coupon.start_time}-->{$coupon.start_time|date}<!--{else}-->{$today|date}<!--{/if}-->" id="add_time_from" readonly="readonly" /> {$lang.to} <input type="text" class="text width2" name="end_time" value="<!--{if $coupon.end_time}-->{$coupon.end_time|date}<!--{else}-->{$endday|date}<!--{/if}-->" id="add_time_to" readonly="readonly" /><b class="strong">*</b> </p> </li> <li> <h3>{$lang.time_limit2}:</h3> <p><input type="radio" name="exptype" value="1" <!--{if $coupon.exptype}-->checked<!--{/if}-->/> {$lang.exptype1}<input type="text" class="text width1" name="expday" value="<!--{if $coupon.expday}-->{$coupon.expday}<!--{else}-->30<!--{/if}-->" />{$lang.day} <b class="strong">*</b> </p> </li> 3.coupon.lang.php 'time_limit1' => '使用期限一', 'time_limit2' => '使用期限二', 'expday_drop_confirm' => '删除后所有未用优惠券将全部清空,请确认!', 'view_stat' => '状态', 'stat_ok' => '有效', 'stat_err' => '失效', 4.coupon.app.php add() edit()数据添加部分修改为 $coupon = array( 'coupon_name' => trim($_POST['coupon_name']), 'coupon_value' => $coupon_value, 'store_id' => $this->_store_id, 'use_times' => $use_times, 'start_time' => $start_time, 'end_time' => $end_time, 'min_amount' => $min_amount, //TianYan 'if_issue' => trim($_POST['if_issue']) == 1 ? 1 : 0, 'all_shop' => trim($_POST['all_shop']) == 1 ? 1 : 0, //TianYan 'exptype' => $exptype, //TianYan20091121 'expday' => $expday, //TianYan20091121 ); 5.是优惠券有效验证order.app.php 增加 check_coupon()函数 index()函数增加 if($coupon['exptype']) //TianYan20091121 { $coupon['end_time'] = time()+$coupon['expday']*24*60*60; } 完成 有问题加入Ecmall开发群52492705,联盟成员和已购买插件的等待升级补丁。
![11155900_nDsc.jpg](http://static.oschina.net/uploads/img/201304/11155900_nDsc.jpg)
![11155900_5v7X.jpg](http://static.oschina.net/uploads/img/201304/11155900_5v7X.jpg)