coupon-admin/app/model/CouponMain.php

58 lines
1.4 KiB
PHP
Raw Normal View History

2021-11-18 09:57:04 +00:00
<?php
namespace app\model;
use think\Collection;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
2021-11-30 07:26:38 +00:00
use think\Model;
2021-11-18 09:57:04 +00:00
/**
2022-03-31 06:42:56 +00:00
* 签到券主表
2021-11-18 09:57:04 +00:00
* Class CouponMain
* @package app\model
*/
class CouponMain extends Base
{
const status_on = 0;//进行中
const status_off = 1;//停止
const on_shelf_on = 0;//上架状态
const on_shelf_off = 1;//下架状态
2021-11-24 06:41:24 +00:00
2022-01-20 05:56:21 +00:00
const on_screen_yes = 1;//展示到商圈大屏
2022-02-08 06:32:23 +00:00
const on_screen_no = 0;//不展示到商圈大屏
2022-02-08 06:37:31 +00:00
2022-03-15 06:10:36 +00:00
const min_redpack_money = 0.3;//
2022-02-25 10:17:23 +00:00
const receive_status_over = 2;//领取状态 已领完
const receive_status_received = 1;//领取状态 已领完
const receive_status_default = 0;//领取状态 可领取
2022-01-20 05:56:21 +00:00
2021-11-24 06:41:24 +00:00
public function business()
{
return $this->hasOne(Business::class, 'code',"business_code");
}
2021-11-24 08:34:56 +00:00
public function couponType()
{
return $this->hasOne(CouponType::class, 'id',"type_id");
}
2022-01-19 05:40:46 +00:00
//public function usingRule()
//{
// return $this->hasOne(UsingRule::class, 'coupon_id',"id");
//}
2021-12-14 09:34:27 +00:00
//创建完成之后
2021-11-30 07:26:38 +00:00
public static function onAfterInsert( $obj)
{
2021-12-14 09:34:27 +00:00
$obj->sort = $obj->id;
$obj->using_count = $obj->count;
$obj->received_count = 0;
$obj->verification_count = 0;
2021-11-30 07:26:38 +00:00
$obj->save();
}
2021-11-18 09:57:04 +00:00
}