123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace app\models\lala;
- use app\models\system\SystemMoney;
- use app\models\user\User;
- use app\models\user\UserMoney;
- use Exception;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- /**
- * TODO 文章Model
- * Class Article
- * @package app\models\article
- */
- class LalaRatio extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'lala_ratio';
- use ModelTrait;
- public static function initRatio($date)
- {
- $ratio_value = 0;
- $date = $date ?: date('Y-m-d');
- $ratio = self::where('date', $date)->find();
- if (!$ratio && $date == date('Y-m-d')) {
- $r = self::order('id', 'desc')->value('ratio');
- $r = $r - 3;
- $ratio = self::create(['date' => $date, 'ratio' => ($r >= 0 ? $r : 0)]);
- }
- return $ratio->ratio ?? $ratio_value;
- }
- }
|