diff --git a/app/admin/model/Store.php b/app/admin/model/Store.php index 10eb5b52..ec5bf440 100644 --- a/app/admin/model/Store.php +++ b/app/admin/model/Store.php @@ -13,6 +13,7 @@ declare (strict_types=1); namespace app\admin\model; use app\admin\model\Page as PageModel; +use app\admin\model\store\User; use app\common\model\Store as StoreModel; use app\admin\model\store\User as StoreUserModel; @@ -92,6 +93,29 @@ class Store extends StoreModel public function auditStore(array $data) { $storeInfo = $this->toArray(); - print_r($storeInfo);exit; + if($storeInfo['status'] != 0){ + $this->error = '状态异常,请勿重复操作'; + return false; + } + $user = User::where(['user_id' => $storeInfo['user_id']])->find(); + if (StoreUserModel::checkExist($user['mobile'])) { + $this->error = '商家用户名已存在'; + return false; + } + if($data['status'] == 1){ + return $this->transaction(function () use ($data) { + // 添加小程序记录 + $data['is_recycle'] = 0; + if ($status = $this->save($data)) { + // 新增商家用户信息 + (new StoreUserModel)->add((int)$this['store_id'], $data); + // 新增默认首页数据 + (new PageModel)->insertDefault((int)$this['store_id']); + } + return $status; + }); + }else{ + + } } } diff --git a/app/api/model/Article.php b/app/api/model/Article.php index 58daf544..22197d5b 100644 --- a/app/api/model/Article.php +++ b/app/api/model/Article.php @@ -98,7 +98,7 @@ class Article extends ArticleModel public function helpCenter() { - $cat = CategoryModel::where(['status' => 1])->order('sort desc')->select()->toArray(); + $cat = CategoryModel::where(['status' => 1])->with(['catImg'])->order('sort desc')->select()->toArray(); foreach ($cat as $k => $v) { $cat[$k]['child'] = $this->where('status', '=', 1) ->where('is_delete', '=', 0) diff --git a/app/api/model/article/Category.php b/app/api/model/article/Category.php index 78910e92..373e6db0 100644 --- a/app/api/model/article/Category.php +++ b/app/api/model/article/Category.php @@ -43,4 +43,5 @@ class Category extends CategoryModel { return $this->getList(['status' => 1]); } + } diff --git a/app/common/model/article/Category.php b/app/common/model/article/Category.php index 95f1cffe..0894158d 100644 --- a/app/common/model/article/Category.php +++ b/app/common/model/article/Category.php @@ -13,6 +13,7 @@ declare (strict_types=1); namespace app\common\model\article; use cores\BaseModel; +use think\model\relation\HasOne; /** * 文章分类模型 @@ -37,6 +38,16 @@ class Category extends BaseModel return static::get($categoryId); } + /** + * 关联用户头像表 + * @return HasOne + */ + public function catImg(): HasOne + { + return $this->hasOne('UploadFile', 'file_id', 'img_id') + ->bind(['img_url' => 'preview_url']); + } + /** * 获取列表 * @param array $where