wysf
bruce 10 months ago
parent 74d4f5816d
commit f88ad8e281
  1. 56
      app/api/controller/User.php
  2. 39
      app/common/model/Maintenance.php
  3. 54
      app/common/model/MaintenanceCategory.php
  4. 82
      app/store/controller/content/Maintenance.php
  5. 83
      app/store/controller/content/MaintenanceCategory.php
  6. 107
      app/store/model/Maintenance.php
  7. 68
      app/store/model/MaintenanceCategory.php

@ -33,6 +33,7 @@ use think\response\Json;
use think\Db;
use app\common\model\dealer\Order as DealerOrderModel;
use app\common\model\Order as OrderModel;
/**
* 用户管理
* Class User
@ -319,6 +320,7 @@ class User extends Controller
$Qrcode = new InviteUser($userInfo, 'MP-WEIXIN');
return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]);
}
/**
* 用户列表
* @return Json
@ -346,11 +348,12 @@ class User extends Controller
} elseif ($value['user_type'] == 30) {
$value['order_num'] = DealerOrderModel::where('first_user_id|second_user_id|third_user_id', '=', $value['user_id'])->count();
}
}
return $this->renderSuccess(compact('list'));
}
public function updateUser(): Json
{
$params = $this->request->param();
@ -359,12 +362,14 @@ class User extends Controller
UserModel::where('user_id', $user_id)->update($params);
return $this->renderSuccess('ok');
}
/**
* 生成会员码
* [getMembershipInviteQrcode description]
* @return [type] [description]
*/
public function getMembershipInviteQrcode(){
public function getMembershipInviteQrcode()
{
$user_id = $userInfo = UserService::getCurrentLoginUserId(true);
$obj = new \app\common\service\qrcode\BaseQRcode();
// 小程序码参数
@ -373,56 +378,39 @@ class User extends Controller
// 下载小程序码
$page = 'pages/login/index';
$qrcode = $obj->getQrcode((int)$storeId, $scene, $page, 'MP-WEIXIN');
return $this->renderSuccess(str_replace(root_path()."public/", base_url(), $qrcode));
return $this->renderSuccess(str_replace(root_path() . "public/", base_url(), $qrcode));
}
/**
* 生成分销商码
* [getDealerInviteQrcode description]
* @return [type] [description]
*/
public function getDealerInviteQrcode(){
public function getDealerInviteQrcode()
{
$storeId = request()->header()['storeid'];
$user_id = $userInfo = UserService::getCurrentLoginUserId(true);
$obj = new \app\common\service\qrcode\BaseQRcode();
$scene = 'uid:' . $user_id;
$qrcode = $obj->getQrcode((int)$storeId, $scene, null, 'MP-WEIXIN');
return $this->renderSuccess(str_replace(root_path()."public/", base_url(), $qrcode));
return $this->renderSuccess(str_replace(root_path() . "public/", base_url(), $qrcode));
}
public function maintenance()
public function maintenance()
{
$storeId = request()->header()['storeid'];
$list = Db::table('yoshop_maintenance')
->where(['store_id' => $storeId, 'status' => 1, 'parent_id' => 0])
->field('id','name')
->select()
->toArray();
foreach ($list as &$item) {
$item['tags'] = Db::table('yoshop_maintenance')
->field('name,id,url')
->where(['parent_id' => $item['id']])
$storeId = request()->header()['storeid'];
$list = Db::table('yoshop_maintenance_category')
->where(['store_id' => $storeId, 'status' => 1,])
->select()
->toArray();
foreach ($list as &$item) {
$item['tags'] = Db::table('yoshop_maintenance')
->where(['category_id' => $item['id'], 'is_delete' => 0])
->select()
->toArray();
}
return $this->renderSuccess($list);
}
}

@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use think\model\relation\BelongsTo;
/**
* 文件库分组模型
* Class UploadGroup
* @package app\common\model
*/
class Maintenance extends BaseModel
{
// 定义表名
protected $name = 'maintenance';
public static function detail(int $articleId, array $with = [])
{
return self::get($articleId, $with);
}
public function category(): BelongsTo
{
$module = self::getCalledModule();
return $this->BelongsTo("app\\{$module}\\model\\MaintenanceCategory", 'category_id');
}
}

@ -0,0 +1,54 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use think\model\relation\HasOne;
/**
* 文章分类模型
* Class Category
* @package app\common\model
*/
class MaintenanceCategory extends BaseModel
{
// 定义表名
protected $name = 'maintenance_category';
/**
* 分类详情
* @param int $categoryId
* @return static|array|null
*/
public static function detail(int $categoryId)
{
return static::get($categoryId);
}
/**
* 获取列表
* @param array $where
* @return \think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(array $where = []): \think\Collection
{
return $this->where($where)
->order(['sort', $this->getPk()])
->select();
}
}

@ -0,0 +1,82 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\controller\content;
use think\response\Json;
use app\store\controller\Controller;
use app\store\model\Maintenance as MaintenanceModel;
/**
* 文章管理控制器
* Class article
* @package app\store\controller\content
*/
class Maintenance extends Controller
{
/**
* 文章列表
* @return Json
* @throws \think\db\exception\DbException
*/
public function list(): Json
{
$model = new MaintenanceModel;
$list = $model->getList($this->request->param());
return $this->renderSuccess(compact('list'));
}
/**
* @return Json
*/
public function add(): Json
{
// 新增记录
$model = new MaintenanceModel;
if ($model->add($this->postForm())) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
}
/**
* @param int $articleId
* @return Json
*/
public function edit(int $articleId): Json
{
// 文章详情
$model = MaintenanceModel::detail($articleId);
// 更新记录
if ($model->edit($this->postForm())) {
return $this->renderSuccess('更新成功');
}
return $this->renderError($model->getError() ?: '更新失败');
}
/**
* 删除文章
* @param int $articleId
* @return Json
*/
public function delete(int $articleId): Json
{
// 文章详情
$model = MaintenanceModel::detail($articleId);
if (!$model->setDelete()) {
return $this->renderError($model->getError() ?: '删除失败');
}
return $this->renderSuccess('删除成功');
}
}

@ -0,0 +1,83 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\controller\content;
use think\response\Json;
use app\store\controller\Controller;
use app\store\model\MaintenanceCategory as MaintenanceCategoryModel;
/**
* 文章分类
* Class Category
* @package app\store\controller\content\article
*/
class MaintenanceCategory extends Controller
{
/**
* 文章分类列表
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function list(): Json
{
$model = new MaintenanceCategoryModel;
$list = $model->getList();
return $this->renderSuccess(compact('list'));
}
/**
* 添加文章分类
* @return Json
*/
public function add(): Json
{
// 新增记录
$model = new MaintenanceCategoryModel;
if ($model->add($this->postForm())) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
}
/**
* 编辑文章分类
* @param int $categoryId
* @return Json
*/
public function edit(int $categoryId): Json
{
// 分类详情
$model = MaintenanceCategoryModel::detail($categoryId);
// 更新记录
if ($model->edit($this->postForm())) {
return $this->renderSuccess('更新成功');
}
return $this->renderError($model->getError() ?: '更新失败');
}
/**
* 删除文章分类
* @param int $categoryId
* @return Json
*/
public function delete(int $categoryId): Json
{
$model = MaintenanceCategoryModel::detail($categoryId);
if (!$model->remove($categoryId)) {
return $this->renderError($model->getError() ?: '删除失败');
}
return $this->renderSuccess('删除成功');
}
}

@ -0,0 +1,107 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\model;
use app\common\model\Maintenance as MaintenanceModel;
/**
* 文章模型
* Class Article
* @package app\store\model
*/
class Maintenance extends MaintenanceModel
{
/**
* 获取列表
* @param array $param
* @return \think\Paginator
* @throws \think\db\exception\DbException
*/
public function getList(array $param = []): \think\Paginator
{
// 查询参数
$params = $this->setQueryDefaultValue($param, [
'name' => '',
'categoryId' => 0,
'status' => -1,
]);
// 检索查询条件
$filter = [];
!empty($params['name']) && $filter[] = ['name', 'like', "%{$params['title']}%"];
$params['status'] > -1 && $filter[] = ['status', '=', $params['status']];
$params['categoryId'] > 0 && $filter[] = ['category_id', '=', $params['categoryId']];
// 查询列表数据
$data = $this->where($filter)
->where('is_delete', '=', 0)
->order(['sort' => 'asc', 'create_time' => 'desc'])
->paginate(15);
return self::preload($data, ['category']);
}
/**
* 新增记录
* @param array $data
* @return bool
*/
public function add(array $data): bool
{
if (empty($data['name'])) {
$this->error = '请输入保修名称';
return false;
}
if (($data['parent_id']) != 0) {
if (empty($data['url'])) {
$this->error = '请输地址';
return false;
}
}
$data['store_id'] = self::$storeId;
return $this->save($data);
}
/**
* 更新记录
* @param array $data
* @return bool
*/
public function edit(array $data): bool
{
if (empty($data['name'])) {
$this->error = '请输入保修名称';
return false;
}
if (empty($data['url'])) {
$this->error = '请输入地址';
return false;
}
return $this->save($data) !== false;
}
/**
* 软删除
* @return bool
*/
public function setDelete(): bool
{
return $this->save(['is_delete' => 1]);
}
public static function getTotal(array $where = []): int
{
return (new static)->where($where)->where('is_delete', '=', 0)->count();
}
}

@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\model;
use app\store\model\Maintenance as MaintenanceModel;
use app\common\model\MaintenanceCategory as MaintenanceCategoryModel;
/**
* 文章分类模型
* Class Category
* @package app\store\model\article
*/
class MaintenanceCategory extends MaintenanceCategoryModel
{
/**
* 添加新记录
* @param array $data
* @return bool
*/
public function add(array $data): bool
{
// 保存记录
$data['store_id'] = self::$storeId;
return $this->save($data);
}
/**
* 编辑记录
* @param array $data
* @return bool
*/
public function edit(array $data): bool
{
// 保存记录
return $this->save($data);
}
/**
* 删除商品分类
* @param int $categoryId
* @return bool
*/
public function remove(int $categoryId): bool
{
// 判断是否存在文章
$articleCount = MaintenanceModel::getTotal(['category_id' => $categoryId]);
if ($articleCount > 0) {
$this->error = '该分类下存在' . $articleCount . '个报修,不允许删除';
return false;
}
// 删除记录
return $this->delete();
}
}
Loading…
Cancel
Save