| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\admin\logic;
- use app\admin\model\dao\MoneyLog;
- use app\admin\model\dao\ScoreLog;
- use app\admin\model\dao\ShopOrder;
- use app\admin\model\dao\SystemArticle;
- use app\admin\model\dao\User;
- use app\common\model\BoxModel;
- use app\common\model\SystemArticleModel;
- use app\common\model\UserMoneyModel;
- use think\facade\Cache;
- use think\facade\Db;
- class SystemArticleLogic
- {
- public static function getList($page, $limit, $where, $sort)
- {
- $count = (new SystemArticleModel())
- ->where($where)
- ->count();
- $list = (new SystemArticleModel())
- ->where($where)
- ->withAttr('type', function ($val, $data) {
- return config('type.article')[$val] ? config('type.article')[$val] : '未知类型';
- })
- ->page($page, $limit)
- ->order($sort)
- ->select();
- return [$count, $list];
- }
- public static function add($row)
- {
- $row['banner_desc'] = htmlspecialchars_decode($row['banner_desc']);
- $row['create_time'] = sr_getcurtime(time());
- unset($row['file']);
- $type_info = SystemArticle::getById($row['type']);
- if ($type_info) {
- $count = SystemArticle::count($row['type']);
- if ($count >= $type_info['max_count']) {
- return [false, '这种类型只能存在' . $type_info['max_count'] . '种'];
- }
- }
- return (new SystemArticleModel())->insert($row);
- }
- }
|