diff --git a/app/Http/Desktop/Views/search/course.volt b/app/Http/Desktop/Views/search/course.volt index 81c3b991..76a315b2 100644 --- a/app/Http/Desktop/Views/search/course.volt +++ b/app/Http/Desktop/Views/search/course.volt @@ -1,25 +1,29 @@ -
- {% for item in pager.items %} - {% set course_url = url({'for':'desktop.course.show','id':item.id}) %} - {% set teacher_url = url({'for':'desktop.teacher.show','id':item.teacher.id}) %} -
-
- - {{ item.title }} - -
-
-
- {{ item.title }} +{% if pager.total_pages > 0 %} +
+ {% for item in pager.items %} + {% set course_url = url({'for':'desktop.course.show','id':item.id}) %} + {% set teacher_url = url({'for':'desktop.teacher.show','id':item.teacher.id}) %} +
+ -
{{ item.summary }}
-
- 讲师:{{ item.teacher.name }} - 难度:{{ level_info(item.level) }} - 课时:{{ item.lesson_count }} - 学员:{{ item.user_count }} +
+ +
{{ item.summary }}
+
+ 讲师:{{ item.teacher.name }} + 难度:{{ level_info(item.level) }} + 课时:{{ item.lesson_count }} + 学员:{{ item.user_count }} +
-
- {% endfor %} -
+ {% endfor %} +
+{% else %} + {{ partial('search/empty') }} +{% endif %} diff --git a/app/Http/Desktop/Views/search/empty.volt b/app/Http/Desktop/Views/search/empty.volt new file mode 100644 index 00000000..c0625b2a --- /dev/null +++ b/app/Http/Desktop/Views/search/empty.volt @@ -0,0 +1,4 @@ +
+
+
没有找到{{ query }}相关内容,换个关键字试试吧!
+
\ No newline at end of file diff --git a/app/Http/Desktop/Views/search/group.volt b/app/Http/Desktop/Views/search/group.volt index 0ba5526e..abda5544 100644 --- a/app/Http/Desktop/Views/search/group.volt +++ b/app/Http/Desktop/Views/search/group.volt @@ -1,24 +1,28 @@ -
- {% for item in pager.items %} - {% set group_url = url({'for':'desktop.group.show','id':item.id}) %} - {% set owner_url = url({'for':'desktop.user.show','id':item.owner.id}) %} - {% set item.about = item.about ? item.about : '这个家伙真懒,什么也没有留下!' %} -
-
- - {{ item.name }} - -
-
-
- {{ item.name }} +{% if pager.total_pages > 0 %} +
+ {% for item in pager.items %} + {% set group_url = url({'for':'desktop.group.show','id':item.id}) %} + {% set owner_url = url({'for':'desktop.user.show','id':item.owner.id}) %} + {% set item.about = item.about ? item.about : '这个家伙真懒,什么也没有留下!' %} +
+ -
{{ item.about }}
-
- 组长:{{ item.owner.name }} - 成员:{{ item.user_count }} +
+ +
{{ item.about }}
+
+ 组长:{{ item.owner.name }} + 成员:{{ item.user_count }} +
-
- {% endfor %} -
+ {% endfor %} +
+{% else %} + {{ partial('search/empty') }} +{% endif %} \ No newline at end of file diff --git a/app/Http/Desktop/Views/search/index.volt b/app/Http/Desktop/Views/search/index.volt index 1b92c2fc..255d468c 100644 --- a/app/Http/Desktop/Views/search/index.volt +++ b/app/Http/Desktop/Views/search/index.volt @@ -43,14 +43,7 @@
- {% if pager.total_pages > 0 %} - {{ partial('partials/pager') }} - {% else %} -
-
-
没有找到{{ query }}相关内容,换个关键字试试吧!
-
- {% endif %} + {{ partial('partials/pager') }}
{{ partial('search/sidebar') }} diff --git a/app/Http/Desktop/Views/search/user.volt b/app/Http/Desktop/Views/search/user.volt index de7ff2f2..d31265c2 100644 --- a/app/Http/Desktop/Views/search/user.volt +++ b/app/Http/Desktop/Views/search/user.volt @@ -8,26 +8,30 @@ {% endif %} {%- endmacro %} -
- {% for item in pager.items %} - {% set user_url = url({'for':'desktop.user.show','id':item.id}) %} - {% set item.about = item.about ? item.about : '这个家伙真懒,什么也没有留下!' %} -
-
- - {{ item.name }} - -
-
-
- {{ item.name }} +{% if pager.total_pages > 0 %} +
+ {% for item in pager.items %} + {% set user_url = url({'for':'desktop.user.show','id':item.id}) %} + {% set item.about = item.about ? item.about : '这个家伙真懒,什么也没有留下!' %} +
+ -
{{ item.about }}
-
- 性别:{{ gender_info(item.gender) }} - 地区:{{ item.location }} +
+ +
{{ item.about }}
+
+ 性别:{{ gender_info(item.gender) }} + 地区:{{ item.location }} +
-
- {% endfor %} -
+ {% endfor %} +
+{% else %} + {{ partial('search/empty') }} +{% endif %} diff --git a/app/Library/Paginator/Adapter/QueryBuilder.php b/app/Library/Paginator/Adapter/QueryBuilder.php index c826866b..4574d06c 100644 --- a/app/Library/Paginator/Adapter/QueryBuilder.php +++ b/app/Library/Paginator/Adapter/QueryBuilder.php @@ -2,11 +2,11 @@ namespace App\Library\Paginator\Adapter; -use App\Library\Paginator\Query; -use Phalcon\Paginator\Adapter\QueryBuilder as BaseQueryBuilder; +use App\Library\Paginator\Query as PaginatorQuery; +use Phalcon\Paginator\Adapter\QueryBuilder as PhQueryBuilder; use stdClass; -class QueryBuilder extends BaseQueryBuilder +class QueryBuilder extends PhQueryBuilder { protected $baseUrl; @@ -17,7 +17,7 @@ class QueryBuilder extends BaseQueryBuilder { $pager = parent::paginate(); - $query = new Query(); + $query = new PaginatorQuery(); $this->baseUrl = $query->getBaseUrl(); $this->params = $query->getParams(); diff --git a/app/Library/Paginator/Adapter/XunSearch.php b/app/Library/Paginator/Adapter/XunSearch.php index cd1b85bb..c8c93639 100644 --- a/app/Library/Paginator/Adapter/XunSearch.php +++ b/app/Library/Paginator/Adapter/XunSearch.php @@ -2,7 +2,8 @@ namespace App\Library\Paginator\Adapter; -use App\Library\Paginator\Query; +use App\Library\Paginator\Query as PaginatorQuery; +use App\Library\Validators\Common as CommonValidator; use Phalcon\Paginator\Adapter as PaginatorAdapter; use Phalcon\Paginator\Exception as PaginatorException; use stdClass; @@ -44,11 +45,11 @@ class XunSearch extends PaginatorAdapter throw new PaginatorException('Invalid query parameter'); } - if (empty($config['page']) || $config['page'] != intval($config['page'])) { + if (isset($config['page']) && !CommonValidator::positiveNumber($config['page'])) { throw new PaginatorException('Invalid page parameter'); } - if (empty($config['limit']) || $config['limit'] != intval($config['limit'])) { + if (isset($config['limit']) && !CommonValidator::positiveNumber($config['limit'])) { throw new PaginatorException('Invalid limit parameter'); } @@ -60,7 +61,7 @@ class XunSearch extends PaginatorAdapter $this->_page = $config['page'] ?? 1; $this->_limitRows = $config['limit'] ?? 15; - $query = new Query(); + $query = new PaginatorQuery(); $this->baseUrl = $query->getBaseUrl(); $this->params = $query->getParams(); diff --git a/app/Library/Validators/Common.php b/app/Library/Validators/Common.php index 3c89c88f..3e69d0b8 100644 --- a/app/Library/Validators/Common.php +++ b/app/Library/Validators/Common.php @@ -22,7 +22,7 @@ class Common public static function email($str) { - return filter_var($str, FILTER_VALIDATE_EMAIL) ? true : false; + return filter_var($str, FILTER_VALIDATE_EMAIL) !== false; } public static function url($str) @@ -31,30 +31,40 @@ class Common $str = 'http:' . $str; } - return filter_var($str, FILTER_VALIDATE_URL) ? true : false; + return filter_var($str, FILTER_VALIDATE_URL) !== false; } - public static function intNumber($str) + public static function intNumber($value) { - return filter_var($str, FILTER_VALIDATE_INT) ? true : false; + return filter_var($value, FILTER_VALIDATE_INT) !== false; } - public static function floatNumber($str) + public static function floatNumber($value) { - return filter_var($str, FILTER_VALIDATE_FLOAT) === false; - } - - public static function natureNumber($number) - { - if (preg_match('/^0$/', $number)) { - return true; + if (filter_var($value, FILTER_VALIDATE_FLOAT) === false) { + return false; } - if (preg_match('/^[1-9][0-9]?/', $number)) { - return true; + if (strpos($value, '.') === false) { + return false; } - return false; + $head = strstr($value, '.', true); + + if ($head[0] == '0' && strlen($head) > 1) { + return false; + } + + return true; + } + + public static function positiveNumber($value) + { + if (!self::intNumber($value)) { + return false; + } + + return $value > 0; } public static function idCard($str) diff --git a/app/Models/Audit.php b/app/Models/Audit.php index afe748b0..273717e8 100644 --- a/app/Models/Audit.php +++ b/app/Models/Audit.php @@ -70,7 +70,7 @@ class Audit extends Model { $this->create_time = time(); - if (!empty($this->req_data)) { + if (is_array($this->req_data) && !empty($this->req_data)) { $this->req_data = kg_json_encode($this->req_data); } else { $this->req_data = ''; diff --git a/app/Models/Carousel.php b/app/Models/Carousel.php index 539004bf..1b8c883b 100644 --- a/app/Models/Carousel.php +++ b/app/Models/Carousel.php @@ -8,14 +8,6 @@ use Phalcon\Text; class Carousel extends Model { - /** - * 平台类型 - */ - const PLATFORM_DESKTOP = 'desktop'; - const PLATFORM_MOBILE = 'mobile'; - const PLATFORM_APP = 'app'; - const PLATFORM_MINI = 'mini'; - /** * 目标类型 */ @@ -58,13 +50,6 @@ class Carousel extends Model */ public $summary; - /** - * 平台 - * - * @var string - */ - public $platform; - /** * 目标 * @@ -79,6 +64,13 @@ class Carousel extends Model */ public $content; + /** + * 平台 + * + * @var int + */ + public $platform; + /** * 优先级 * @@ -133,8 +125,6 @@ class Carousel extends Model public function beforeCreate() { - $this->create_time = time(); - if (empty($this->cover)) { $this->cover = kg_default_cover_path(); } elseif (Text::startsWith($this->cover, 'http')) { @@ -144,23 +134,25 @@ class Carousel extends Model if (is_array($this->style) && !empty($this->style)) { $this->style = kg_json_encode($this->style); } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); + if (Text::startsWith($this->cover, 'http')) { + $this->cover = self::getCoverPath($this->cover); + } + + if (is_array($this->style) && !empty($this->style)) { + $this->style = kg_json_encode($this->style); + } if ($this->deleted == 1) { $this->published = 0; } - if (Text::startsWith($this->cover, 'http')) { - $this->cover = self::getCoverPath($this->cover); - } - - if (!empty($this->style)) { - $this->style = kg_json_encode($this->style); - } + $this->update_time = time(); } public function afterFetch() @@ -169,7 +161,7 @@ class Carousel extends Model $this->cover = kg_ci_cover_img_url($this->cover); } - if (!empty($this->style)) { + if (is_string($this->style) && !empty($this->style)) { $this->style = json_decode($this->style, true); } } @@ -203,14 +195,4 @@ class Carousel extends Model ]; } - public static function platformTypes() - { - return [ - self::PLATFORM_DESKTOP => 'desktop', - self::PLATFORM_MOBILE => 'mobile', - self::PLATFORM_APP => 'app', - self::PLATFORM_MINI => '小程序', - ]; - } - } diff --git a/app/Models/Category.php b/app/Models/Category.php index b44baddd..df693ba3 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -122,11 +122,11 @@ class Category extends Model public function beforeUpdate() { - $this->update_time = time(); - if ($this->deleted == 1) { $this->published = 0; } + + $this->update_time = time(); } public function afterCreate() diff --git a/app/Models/Chapter.php b/app/Models/Chapter.php index b6153288..e6f4fdb7 100644 --- a/app/Models/Chapter.php +++ b/app/Models/Chapter.php @@ -186,8 +186,6 @@ class Chapter extends Model public function beforeCreate() { - $this->create_time = time(); - $course = Course::findFirst($this->course_id); $this->model = $course->model; @@ -210,19 +208,21 @@ class Chapter extends Model $this->attrs = kg_json_encode($attrs); } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); + if (is_array($this->attrs) && !empty($this->attrs)) { + $this->attrs = kg_json_encode($this->attrs); + } if ($this->deleted == 1) { $this->published = 0; } - if (is_array($this->attrs)) { - $this->attrs = kg_json_encode($this->attrs); - } + $this->update_time = time(); } public function afterCreate() @@ -234,7 +234,7 @@ class Chapter extends Model public function afterFetch() { - if (!empty($this->attrs) && is_string($this->attrs)) { + if (is_string($this->attrs) && !empty($this->attrs)) { $this->attrs = json_decode($this->attrs, true); } } diff --git a/app/Models/ChapterRead.php b/app/Models/ChapterRead.php index 1545eaf0..2f20ee40 100644 --- a/app/Models/ChapterRead.php +++ b/app/Models/ChapterRead.php @@ -57,9 +57,9 @@ class ChapterRead extends Model $this->create_time = time(); /** - * text类型不能填充默认值 + * text类型不能自动填充默认值 */ - if (empty($this->content)) { + if (is_null($this->content)) { $this->content = ''; } } diff --git a/app/Models/ChapterUser.php b/app/Models/ChapterUser.php index cde7c085..911c1d5c 100644 --- a/app/Models/ChapterUser.php +++ b/app/Models/ChapterUser.php @@ -14,13 +14,6 @@ class ChapterUser extends Model */ public $id; - /** - * 计划编号 - * - * @var int - */ - public $plan_id; - /** * 课程编号 * @@ -42,6 +35,13 @@ class ChapterUser extends Model */ public $user_id; + /** + * 计划编号 + * + * @var int + */ + public $plan_id; + /** * 学习时长 * diff --git a/app/Models/ChapterVod.php b/app/Models/ChapterVod.php index 52cbe08d..f06ad558 100644 --- a/app/Models/ChapterVod.php +++ b/app/Models/ChapterVod.php @@ -63,20 +63,20 @@ class ChapterVod extends Model public function beforeCreate() { - $this->create_time = time(); - if (is_array($this->file_transcode) && !empty($this->file_transcode)) { $this->file_transcode = kg_json_encode($this->file_transcode); } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); - if (is_array($this->file_transcode) && !empty($this->file_transcode)) { $this->file_transcode = kg_json_encode($this->file_transcode); } + + $this->update_time = time(); } public function afterFetch() diff --git a/app/Models/Consult.php b/app/Models/Consult.php index 25f1beba..affeddaf 100644 --- a/app/Models/Consult.php +++ b/app/Models/Consult.php @@ -136,11 +136,11 @@ class Consult extends Model public function beforeUpdate() { - $this->update_time = time(); - if ($this->deleted == 1) { $this->published = 0; } + + $this->update_time = time(); } } diff --git a/app/Models/Course.php b/app/Models/Course.php index 0a82e12b..3c190525 100644 --- a/app/Models/Course.php +++ b/app/Models/Course.php @@ -256,8 +256,6 @@ class Course extends Model public function beforeCreate() { - $this->create_time = time(); - $attrs = []; switch ($this->model) { @@ -288,6 +286,8 @@ class Course extends Model if (!empty($attrs)) { $this->attrs = kg_json_encode($attrs); } + + $this->create_time = time(); } public function beforeUpdate() @@ -301,7 +301,7 @@ class Course extends Model $this->cover = self::getCoverPath($this->cover); } - if (is_array($this->attrs)) { + if (is_array($this->attrs) && !empty($this->attrs)) { $this->attrs = kg_json_encode($this->attrs); } @@ -322,7 +322,7 @@ class Course extends Model public function afterUpdate() { /** - * 课程标题和群组名称保持一致 + * 群组名称和课程标题保持一致 */ if ($this->hasUpdated('title')) { $imGroup = ImGroup::findFirst(['course_id' => $this->id]); @@ -341,7 +341,7 @@ class Course extends Model $this->cover = kg_ci_cover_img_url($this->cover); } - if (!empty($this->attrs) && is_string($this->attrs)) { + if (is_string($this->attrs) && !empty($this->attrs)) { $this->attrs = json_decode($this->attrs, true); } } diff --git a/app/Models/CourseUser.php b/app/Models/CourseUser.php index a332cfcf..609b6851 100644 --- a/app/Models/CourseUser.php +++ b/app/Models/CourseUser.php @@ -51,14 +51,14 @@ class CourseUser extends Model /** * 角色类型 * - * @var string + * @var int */ public $role_type; /** * 来源类型 * - * @var string + * @var int */ public $source_type; @@ -130,9 +130,9 @@ class CourseUser extends Model public function beforeCreate() { - $this->create_time = time(); - $this->plan_id = (int)date('Ymd'); + + $this->create_time = time(); } public function beforeUpdate() diff --git a/app/Models/Danmu.php b/app/Models/Danmu.php index 95bfa59e..ae9221fe 100644 --- a/app/Models/Danmu.php +++ b/app/Models/Danmu.php @@ -144,11 +144,11 @@ class Danmu extends Model public function beforeUpdate() { - $this->update_time = time(); - if ($this->deleted == 1) { $this->published = 0; } + + $this->update_time = time(); } public static function sizeTypes() @@ -184,7 +184,6 @@ class Danmu extends Model $types = self::positionTypes(); $keys = array_keys($types); - $index = array_rand($keys); return $keys[$index]; @@ -195,7 +194,6 @@ class Danmu extends Model $types = self::colorTypes(); $keys = array_keys($types); - $index = array_rand($keys); return $keys[$index]; diff --git a/app/Models/Help.php b/app/Models/Help.php index c1929d02..aab1153b 100644 --- a/app/Models/Help.php +++ b/app/Models/Help.php @@ -90,23 +90,23 @@ class Help extends Model public function beforeCreate() { - $this->create_time = time(); - /** * text类型不会自动填充默认值 */ if (is_null($this->content)) { $this->content = ''; } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); - if ($this->deleted == 1) { $this->published = 0; } + + $this->update_time = time(); } public function afterCreate() diff --git a/app/Models/ImGroup.php b/app/Models/ImGroup.php index eba27c47..743127b0 100644 --- a/app/Models/ImGroup.php +++ b/app/Models/ImGroup.php @@ -126,13 +126,13 @@ class ImGroup extends Model public function beforeCreate() { - $this->create_time = time(); - if (empty($this->avatar)) { $this->avatar = kg_default_avatar_path(); } elseif (Text::startsWith($this->avatar, 'http')) { $this->avatar = self::getAvatarPath($this->avatar); } + + $this->create_time = time(); } public function beforeUpdate() diff --git a/app/Models/ImMessage.php b/app/Models/ImMessage.php index b369d4ff..92dbd568 100644 --- a/app/Models/ImMessage.php +++ b/app/Models/ImMessage.php @@ -102,13 +102,11 @@ class ImMessage extends Model public function beforeCreate() { - $this->create_time = time(); - - $this->chat_id = 0; - if ($this->receiver_type == self::TYPE_FRIEND) { $this->chat_id = self::getChatId($this->sender_id, $this->receiver_id); } + + $this->create_time = time(); } public function beforeUpdate() diff --git a/app/Models/ImNotice.php b/app/Models/ImNotice.php index 0db34ae9..64d6fb37 100644 --- a/app/Models/ImNotice.php +++ b/app/Models/ImNotice.php @@ -41,7 +41,7 @@ class ImNotice extends Model /** * 条目类型 * - * @var string + * @var int */ public $item_type; @@ -106,25 +106,25 @@ class ImNotice extends Model public function beforeCreate() { - $this->create_time = time(); - if (!empty($this->item_info)) { $this->item_info = kg_json_encode($this->item_info); } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); - - if (is_array($this->item_info)) { + if (is_array($this->item_info) && !empty($this->item_info)) { $this->item_info = kg_json_encode($this->item_info); } + + $this->update_time = time(); } public function afterFetch() { - if (!empty($this->item_info) && is_string($this->item_info)) { + if (is_string($this->item_info) && !empty($this->item_info)) { $this->item_info = json_decode($this->item_info, true); } } diff --git a/app/Models/ImUser.php b/app/Models/ImUser.php index dddb35fb..4b358218 100644 --- a/app/Models/ImUser.php +++ b/app/Models/ImUser.php @@ -112,22 +112,22 @@ class ImUser extends Model public function beforeCreate() { - $this->create_time = time(); - if (empty($this->avatar)) { $this->avatar = kg_default_avatar_path(); } elseif (Text::startsWith($this->avatar, 'http')) { $this->avatar = self::getAvatarPath($this->avatar); } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); - if (Text::startsWith($this->avatar, 'http')) { $this->avatar = self::getAvatarPath($this->avatar); } + + $this->update_time = time(); } public function afterFetch() diff --git a/app/Models/Learning.php b/app/Models/Learning.php index ce6834a8..09391062 100644 --- a/app/Models/Learning.php +++ b/app/Models/Learning.php @@ -19,13 +19,6 @@ class Learning extends Model */ public $request_id; - /** - * 计划编号 - * - * @var int - */ - public $plan_id; - /** * 课程编号 * @@ -47,6 +40,13 @@ class Learning extends Model */ public $user_id; + /** + * 计划编号 + * + * @var int + */ + public $plan_id; + /** * 持续时长 * diff --git a/app/Models/Nav.php b/app/Models/Nav.php index 626781b9..2ae8711b 100644 --- a/app/Models/Nav.php +++ b/app/Models/Nav.php @@ -141,11 +141,11 @@ class Nav extends Model public function beforeUpdate() { - $this->update_time = time(); - if ($this->deleted == 1) { $this->published = 0; } + + $this->update_time = time(); } public static function positionTypes() diff --git a/app/Models/Order.php b/app/Models/Order.php index c9246584..1c570ce3 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -77,14 +77,14 @@ class Order extends Model /** * 条目编号 * - * @var string + * @var int */ public $item_id; /** * 条目类型 * - * @var string + * @var int */ public $item_type; @@ -144,24 +144,24 @@ class Order extends Model public function beforeCreate() { - $this->sn = date('YmdHis') . rand(1000, 9999); - $this->status = self::STATUS_PENDING; - $this->create_time = time(); + $this->sn = date('YmdHis') . rand(1000, 9999); - if (is_array($this->item_info)) { + if (is_array($this->item_info) && !empty($this->item_info)) { $this->item_info = kg_json_encode($this->item_info); } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); - - if (is_array($this->item_info)) { + if (is_array($this->item_info) && !empty($this->item_info)) { $this->item_info = kg_json_encode($this->item_info); } + + $this->update_time = time(); } public function afterSave() @@ -178,7 +178,7 @@ class Order extends Model { $this->amount = (float)$this->amount; - if (!empty($this->item_info) && is_string($this->item_info)) { + if (is_string($this->item_info) && !empty($this->item_info)) { $this->item_info = json_decode($this->item_info, true); } } @@ -198,6 +198,7 @@ class Order extends Model { return [ self::STATUS_PENDING => '待支付', + self::STATUS_SHIPPING => '发货中', self::STATUS_FINISHED => '已完成', self::STATUS_CLOSED => '已关闭', self::STATUS_REFUNDED => '已退款', diff --git a/app/Models/OrderStatus.php b/app/Models/OrderStatus.php index 7b33ee6d..2f38f6ec 100644 --- a/app/Models/OrderStatus.php +++ b/app/Models/OrderStatus.php @@ -22,7 +22,7 @@ class OrderStatus extends Model /** * 状态类型 * - * @var string + * @var int */ public $status; diff --git a/app/Models/Package.php b/app/Models/Package.php index d929b49c..9205112f 100644 --- a/app/Models/Package.php +++ b/app/Models/Package.php @@ -102,11 +102,11 @@ class Package extends Model public function beforeUpdate() { - $this->update_time = time(); - if ($this->deleted == 1) { $this->published = 0; } + + $this->update_time = time(); } public function afterCreate() diff --git a/app/Models/Page.php b/app/Models/Page.php index efef8aa4..aed492e1 100644 --- a/app/Models/Page.php +++ b/app/Models/Page.php @@ -76,23 +76,23 @@ class Page extends Model public function beforeCreate() { - $this->create_time = time(); - /** * text类型不会自动填充默认值 */ if (is_null($this->content)) { $this->content = ''; } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); - if ($this->deleted == 1) { $this->published = 0; } + + $this->update_time = time(); } public function afterCreate() diff --git a/app/Models/Refund.php b/app/Models/Refund.php index f37c0e44..f893bd2c 100644 --- a/app/Models/Refund.php +++ b/app/Models/Refund.php @@ -27,7 +27,7 @@ class Refund extends Model /** * 用户编号 * - * @var string + * @var int */ public $owner_id; @@ -69,7 +69,7 @@ class Refund extends Model /** * 状态类型 * - * @var string + * @var int */ public $status; @@ -132,13 +132,6 @@ class Refund extends Model $this->sn = date('YmdHis') . rand(1000, 9999); $this->create_time = time(); - - /** - * 退款周期内无条件审批,状态为approved - */ - if (!$this->status) { - $this->status = self::STATUS_PENDING; - } } public function beforeUpdate() diff --git a/app/Models/RefundStatus.php b/app/Models/RefundStatus.php index c8b1b55f..5b57d592 100644 --- a/app/Models/RefundStatus.php +++ b/app/Models/RefundStatus.php @@ -22,7 +22,7 @@ class RefundStatus extends Model /** * 状态类型 * - * @var string + * @var int */ public $status; diff --git a/app/Models/Review.php b/app/Models/Review.php index 46b0562b..5d6b6e4f 100644 --- a/app/Models/Review.php +++ b/app/Models/Review.php @@ -131,20 +131,20 @@ class Review extends Model public function beforeCreate() { - $this->create_time = time(); - $this->rating = $this->getAvgRating(); + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); - $this->rating = $this->getAvgRating(); if ($this->deleted == 1) { $this->published = 0; } + + $this->update_time = time(); } protected function getAvgRating() diff --git a/app/Models/Role.php b/app/Models/Role.php index 5ab46137..69b1f7e0 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -103,25 +103,25 @@ class Role extends Model public function beforeCreate() { - $this->create_time = time(); - - if (!empty($this->routes)) { + if (is_array($this->routes) && !empty($this->routes)) { $this->routes = kg_json_encode($this->routes); } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); - - if (is_array($this->routes)) { + if (is_array($this->routes) && !empty($this->routes)) { $this->routes = kg_json_encode($this->routes); } + + $this->update_time = time(); } public function afterFetch() { - if (!empty($this->routes) && is_string($this->routes)) { + if (is_string($this->routes) && !empty($this->routes)) { $this->routes = json_decode($this->routes, true); } } diff --git a/app/Models/Task.php b/app/Models/Task.php index e9b11c45..a8bf607c 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -64,7 +64,7 @@ class Task extends Model /** * 状态标识 * - * @var string + * @var int */ public $status; @@ -98,25 +98,25 @@ class Task extends Model { $this->status = self::STATUS_PENDING; - $this->create_time = time(); - - if (!empty($this->item_info)) { + if (is_array($this->item_info) && !empty($this->item_info)) { $this->item_info = kg_json_encode($this->item_info); } + + $this->create_time = time(); } public function beforeUpdate() { - $this->update_time = time(); - - if (is_array($this->item_info)) { + if (is_array($this->item_info) && !empty($this->item_info)) { $this->item_info = kg_json_encode($this->item_info); } + + $this->update_time = time(); } public function afterFetch() { - if (!empty($this->item_info) && is_string($this->item_info)) { + if (is_string($this->item_info) && !empty($this->item_info)) { $this->item_info = json_decode($this->item_info, true); } } diff --git a/app/Models/Topic.php b/app/Models/Topic.php index 097a364f..f4776907 100644 --- a/app/Models/Topic.php +++ b/app/Models/Topic.php @@ -88,11 +88,11 @@ class Topic extends Model public function beforeUpdate() { - $this->update_time = time(); - if ($this->deleted == 1) { $this->published = 0; } + + $this->update_time = time(); } public function afterCreate() diff --git a/app/Models/Trade.php b/app/Models/Trade.php index 5134dba4..0a3d24bf 100644 --- a/app/Models/Trade.php +++ b/app/Models/Trade.php @@ -66,7 +66,7 @@ class Trade extends Model /** * 平台类型 * - * @var string + * @var int */ public $channel; @@ -80,7 +80,7 @@ class Trade extends Model /** * 状态类型 * - * @var string + * @var int */ public $status; @@ -126,11 +126,11 @@ class Trade extends Model public function beforeCreate() { - $this->create_time = time(); - $this->status = self::STATUS_PENDING; $this->sn = date('YmdHis') . rand(1000, 9999); + + $this->create_time = time(); } public function beforeUpdate() diff --git a/app/Models/TradeStatus.php b/app/Models/TradeStatus.php index 002d9742..9b1a2f5a 100644 --- a/app/Models/TradeStatus.php +++ b/app/Models/TradeStatus.php @@ -22,7 +22,7 @@ class TradeStatus extends Model /** * 状态类型 * - * @var string + * @var int */ public $status; diff --git a/app/Models/User.php b/app/Models/User.php index 5f5edb5a..a96ab300 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -177,13 +177,13 @@ class User extends Model public function beforeCreate() { - $this->create_time = time(); - if (empty($this->avatar)) { $this->avatar = kg_default_avatar_path(); } elseif (Text::startsWith($this->avatar, 'http')) { $this->avatar = self::getAvatarPath($this->avatar); } + + $this->create_time = time(); } public function beforeUpdate() diff --git a/config/xs.user.default.ini b/config/xs.user.default.ini index e458deff..ed9d1b41 100644 --- a/config/xs.user.default.ini +++ b/config/xs.user.default.ini @@ -19,7 +19,7 @@ type = string [about] type = body -[location] +[area] type = string index = self