| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace bizMall\goods\classes;
- use common\components\business;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- use bizMall\base\classes\BaseClass;
- class CategoryClass extends BaseClass
- {
-
- public static $baseFile = '\bizMall\goods\models\Category';
-
- //可以使用的分类:花束 花盒 蝴蝶兰 花篮 植物 永生花 散花 充值卡 花艺课 花礼 瓶器
-
- //取出商家所有的分类 ssh 2019.12.7
- public static function getCategoryIdList($sjId)
- {
- $category = self::getAllByCondition(['sjId' => $sjId, 'delStatus' => 0], null, '*', 'id');
- return empty($category) ? [] : array_keys($category);
- }
-
- //获取详情 ssh 2019.12.8
- public static function getInfo($id)
- {
- $info = self::getById($id);
- $list = self::groupBaseInfo([$info]);
- return current($list);
- }
-
- //组合信息 ssh 2019.12.8
- public static function groupBaseInfo($list)
- {
- foreach ($list as $key => $val) {
- $val = business::formatCategoryImg($val);
- $list[$key] = $val;
- }
- return $list;
- }
-
- //添加分类 ssh 2019.12.8
- public static function addCategory($data)
- {
- $categoryName = $data['categoryName'];
- $sjId = $data['sjId'];
- $exists = self::getByCondition(['sjId' => $sjId, 'delStatus' => 0, 'categoryName' => $categoryName]);
- if (!empty($exists)) {
- util::fail('分类名称已经存在');
- }
- return self::add($data);
- }
-
- //分类启用与停用 ssh 2019.12.8
- public static function changeStatus($categoryId, $status)
- {
- return self::updateById($categoryId, ['status' => $status]);
- }
- //删除分类 ssh 2020.3.3
- public static function deleteCategory($id)
- {
- self::updateById($id, ['delStatus' => 1]);
- return true;
- }
-
- }
|