1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /**
- *
- * @author: xaboy<365615158@qq.com>
- * @day: 2018/01/22
- */
- namespace app\models\store;
- use crmeb\basic\BaseModel;
- use crmeb\traits\ModelTrait;
- /**
- * TODO 优惠券Model
- * Class StoreCoupon
- * @package app\models\store
- */
- class StoreCoupon extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'store_coupon';
- use ModelTrait;
- /**
- * 优惠券过期
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public static function end_coupon()
- {
- $coupon = StoreCoupon::where('end_time', '<', time())->select();
- if ($coupon){
- foreach ($coupon as $item)
- {
- if ($item['end_time'] > 0){
- $product = StoreProduct::where('coupon', $item['id'])->where('is_show', 1)->find();
- if ($product){
- $product['is_show'] = 0;
- $product->save();
- }
- }
- }
- }
- }
- }
|