初始版本
This commit is contained in:
154
server/app/adminapi/logic/goods/GoodsCategoryLogic.php
Executable file
154
server/app/adminapi/logic/goods/GoodsCategoryLogic.php
Executable file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\goods;
|
||||
|
||||
|
||||
use app\common\enum\DefaultEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
|
||||
class GoodsCategoryLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 通用分类列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/8 6:09 下午
|
||||
*/
|
||||
public function commonLists($is_son)
|
||||
{
|
||||
$where = [];
|
||||
if ($is_son) {
|
||||
$where[] = ['level','=',2];
|
||||
}
|
||||
$lists = (new GoodsCategory())->field('id,name,pid,level')
|
||||
->where(['is_show'=>DefaultEnum::SHOW])
|
||||
->where($where)
|
||||
->order(['sort'=>'desc','id'=>'asc'])
|
||||
->select()
|
||||
->toArray();
|
||||
if (!$is_son) {
|
||||
$lists = linear_to_tree($lists,'sons');
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加服务分类
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 5:03 下午
|
||||
*/
|
||||
public function add($params)
|
||||
{
|
||||
$level = isset($params['pid']) ? (GoodsCategory::where('id',$params['pid'])->value('level') + 1) : 1;
|
||||
$is_recommend = $params['is_recommend'] ?? 0;
|
||||
if (isset($params['pid']) && $params['pid'] > 0) {
|
||||
$is_recommend = GoodsCategory::where('id',$params['pid'])->value('is_recommend');
|
||||
}
|
||||
GoodsCategory::create([
|
||||
'name' => $params['name'],
|
||||
'pid' => $params['pid'] ?? 0,
|
||||
'level' => $level,
|
||||
'image' => $params['image'] ?? '',
|
||||
'sort' => $params['sort'] ?? DefaultEnum::SORT,
|
||||
'is_show' => $params['is_show'],
|
||||
'is_recommend' => $is_recommend,
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看服务分类详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/8 5:21 下午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$result = GoodsCategory::where('id',$id)->findOrEmpty()->toArray();
|
||||
|
||||
$result['pid'] = $result['pid'] ?: '';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑服务分类
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 6:25 下午
|
||||
*/
|
||||
public function edit($params)
|
||||
{
|
||||
$level = isset($params['pid']) ? (GoodsCategory::where('id',$params['pid'])->value('level') + 1) : 1;
|
||||
|
||||
GoodsCategory::update([
|
||||
'name' => $params['name'],
|
||||
'pid' => $params['pid'] ?? 0,
|
||||
'level' => $level,
|
||||
'image' => $params['image'] ?? '',
|
||||
'sort' => $params['sort'],
|
||||
'is_show' => $params['is_show'],
|
||||
'is_recommend' => $params['is_recommend'] ?? 0,
|
||||
],['id'=>$params['id']]);
|
||||
|
||||
//更新下级首页推荐
|
||||
GoodsCategory::update([
|
||||
'is_recommend' => $params['is_recommend'] ?? 0,
|
||||
],['pid'=>$params['id']]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除服务分类
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 6:34 下午
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
return GoodsCategory::destroy($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改服务分类状态
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/10 10:57 上午
|
||||
*/
|
||||
public function status($params)
|
||||
{
|
||||
GoodsCategory::update(['is_show'=>$params['is_show']],['id'=>$params['id']]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
64
server/app/adminapi/logic/goods/GoodsCommentLogic.php
Executable file
64
server/app/adminapi/logic/goods/GoodsCommentLogic.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\goods;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\goods\GoodsComment;
|
||||
|
||||
class GoodsCommentLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 服务评价回复
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/9 7:02 下午
|
||||
*/
|
||||
public function reply($params)
|
||||
{
|
||||
GoodsComment::update(['reply'=>$params['remark'] ?? '','status'=>1],['id'=>$params['id']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 回复详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/10 9:40 上午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
return GoodsComment::where(['id'=>$id])->field('id,reply')->findOrEmpty()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除服务评价
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/10 9:41 上午
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
return GoodsComment::destroy($id);
|
||||
}
|
||||
}
|
||||
315
server/app/adminapi/logic/goods/GoodsLogic.php
Executable file
315
server/app/adminapi/logic/goods/GoodsLogic.php
Executable file
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\goods;
|
||||
|
||||
|
||||
use app\common\enum\DefaultEnum;
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\city\City;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\goods\GoodsCityIndex;
|
||||
use app\common\model\goods\GoodsImage;
|
||||
use app\common\model\goods\GoodsSkillIndex;
|
||||
use app\common\model\skill\Skill;
|
||||
use think\facade\Db;
|
||||
|
||||
class GoodsLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 分类列表
|
||||
* @return GoodsCategory[]|array|\think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/8/19 15:41
|
||||
*/
|
||||
public function categoryLists()
|
||||
{
|
||||
return GoodsCategory::where(['is_show'=>1,'level'=>1])
|
||||
// ->with(['son'])
|
||||
->withCount(['goods'])
|
||||
->field('id,name,image,is_show')
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 城市列表
|
||||
* @return City[]|array|\think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/8/19 15:55
|
||||
*/
|
||||
public function cityLists(){
|
||||
return City::field('city_id as id,name')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 技能列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/8/19 16:34
|
||||
*/
|
||||
public function skillLists()
|
||||
{
|
||||
return Skill::field('id,name')->select()->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加服务
|
||||
* @param $params
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/9 3:28 下午
|
||||
*/
|
||||
public function add($params)
|
||||
{
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
$goodsImage = $params['goods_image'];
|
||||
$image = array_shift($params['goods_image']);
|
||||
//添加服务信息
|
||||
$goods = Goods::create([
|
||||
'name' => $params['name'],
|
||||
'category_id' => $params['category_id'],
|
||||
'image' => $image,
|
||||
'price' => $params['price'],
|
||||
'duration' => $params['duration'],
|
||||
'scribing_price' => $params['scribing_price'] ?? 0.00,
|
||||
'status' => $params['status'],
|
||||
'sort' => $params['sort'] ?? DefaultEnum::SORT,
|
||||
'tags' => $params['tags'] ?? '',
|
||||
'content' => $params['content'] ?? '',
|
||||
'overtime_price' => $params['overtime_price'] ?? '',
|
||||
'overtime_duration' => $params['overtime_duration'] ?? '',
|
||||
'commission_ratio' => $params['commission_ratio'] ?? '',
|
||||
'shop_ratio' => $params['shop_ratio'] ?? '',
|
||||
'virtual_order_num' => $params['virtual_order_num'] ?? '',
|
||||
'appoint_start_time' => $params['appoint_start_time'] ?? '',
|
||||
'appoint_end_time' => $params['appoint_end_time'] ?? '',
|
||||
'audit_status' => GoodsEnum::AUDIT_STATUS_PASS,
|
||||
'audit_remark' => '',
|
||||
]);
|
||||
$goodsImageLists = [];
|
||||
//添加服务轮播图信息
|
||||
foreach ($goodsImage as $image_uri) {
|
||||
$goodsImageLists[] = [
|
||||
'goods_id' => $goods->id,
|
||||
'uri' => $image_uri,
|
||||
];
|
||||
}
|
||||
(new GoodsImage())->saveAll($goodsImageLists);
|
||||
|
||||
$goodsCityLists = [];
|
||||
$goodsSkillLists = [];
|
||||
foreach ($params['skill_id'] as $skillId)
|
||||
{
|
||||
$goodsSkillLists[] = [
|
||||
'goods_id' => $goods->id,
|
||||
'skill_id' => $skillId
|
||||
];
|
||||
}
|
||||
(new GoodsSkillIndex())->saveAll($goodsSkillLists);
|
||||
if($params['city_id']){
|
||||
foreach ($params['city_id'] as $cityId){
|
||||
$goodsCityLists[] = [
|
||||
'goods_id' => $goods->id,
|
||||
'city_id' => $cityId
|
||||
];
|
||||
}
|
||||
}
|
||||
(new GoodsCityIndex())->saveAll($goodsCityLists);
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看服务详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/9 3:51 下午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$result = Goods::where('id',$id)
|
||||
->withoutField('order_num,update_time,delete_time')
|
||||
->append(['category_desc','goods_image'])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
|
||||
$goods_image = [];
|
||||
foreach ($result['goods_image'] as &$image) {
|
||||
$goods_image[] = $image['uri'];
|
||||
}
|
||||
$result['goods_image'] = $goods_image;
|
||||
$result['city_id'] = GoodsCityIndex::where(['goods_id'=>$id])->column('city_id');
|
||||
$result['skill_id'] = GoodsSkillIndex::where(['goods_id'=>$id])->column('skill_id');
|
||||
if(empty($result['city_id'])){
|
||||
$result['city_id'] = null;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑服务
|
||||
* @param $params
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/9 4:06 下午
|
||||
*/
|
||||
public function edit($params)
|
||||
{
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
$goodsImage = $params['goods_image'];
|
||||
$image = array_shift($params['goods_image']);
|
||||
|
||||
//更新服务信息
|
||||
Goods::update([
|
||||
'name' => $params['name'],
|
||||
'category_id' => $params['category_id'],
|
||||
'image' => $image,
|
||||
'price' => $params['price'],
|
||||
'duration' => $params['duration'],
|
||||
'scribing_price' => $params['scribing_price'] ?? 0.00,
|
||||
'status' => $params['status'],
|
||||
'sort' => $params['sort'] ?? DefaultEnum::SORT,
|
||||
'tags' => $params['tags'] ?? '',
|
||||
'content' => $params['content'] ?? '',
|
||||
'overtime_price' => $params['overtime_price'] ?? '',
|
||||
'overtime_duration' => $params['overtime_duration'] ?? '',
|
||||
'commission_ratio' => $params['commission_ratio'] ?? '',
|
||||
'shop_ratio' => $params['shop_ratio'] ?? '',
|
||||
'virtual_order_num' => $params['virtual_order_num'] ?? '',
|
||||
'appoint_start_time' => $params['appoint_start_time'] ?? '',
|
||||
'appoint_end_time' => $params['appoint_end_time'] ?? '',
|
||||
],['id'=>$params['id']]);
|
||||
$goodsImageLists = [];
|
||||
//删除旧的轮播图
|
||||
GoodsImage::where('goods_id',$params['id'])->delete();
|
||||
//添加服务轮播图信息
|
||||
foreach ($goodsImage as $image_uri) {
|
||||
$goodsImageLists[] = [
|
||||
'goods_id' => $params['id'],
|
||||
'uri' => $image_uri,
|
||||
];
|
||||
}
|
||||
(new GoodsImage())->saveAll($goodsImageLists);
|
||||
//删除管理图片,删除管理城市
|
||||
GoodsSkillIndex::where('goods_id',$params['id'])->delete();
|
||||
GoodsCityIndex::where('goods_id',$params['id'])->delete();
|
||||
$goodsCityLists = [];
|
||||
$goodsSkillLists = [];
|
||||
foreach ($params['skill_id'] as $skillId)
|
||||
{
|
||||
$goodsSkillLists[] = [
|
||||
'goods_id' => $params['id'],
|
||||
'skill_id' => $skillId
|
||||
];
|
||||
}
|
||||
(new GoodsSkillIndex())->saveAll($goodsSkillLists);
|
||||
if($params['city_id']) {
|
||||
foreach ($params['city_id'] as $cityId) {
|
||||
$goodsCityLists[] = [
|
||||
'goods_id' => $params['id'],
|
||||
'city_id' => $cityId
|
||||
];
|
||||
}
|
||||
}
|
||||
(new GoodsCityIndex())->saveAll($goodsCityLists);
|
||||
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除服务
|
||||
* @param $ids
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/9 4:13 下午
|
||||
*/
|
||||
public function del($ids)
|
||||
{
|
||||
// 启动事务
|
||||
// Db::startTrans();
|
||||
try {
|
||||
//删除师傅绑定的服务
|
||||
// foreach ($ids as $id) {
|
||||
// $staff_lists = Staff::whereRaw("FIND_IN_SET($id,goods_ids)")->select()->toArray();
|
||||
// foreach ($staff_lists as $list) {
|
||||
// $goods_ids = str_replace(','.$id.',',',',$list['goods_ids']);
|
||||
// if ($goods_ids == ',') {
|
||||
// $goods_ids = '';
|
||||
// }
|
||||
// Staff::update(['goods_ids'=>$goods_ids],['id'=>$list['id']]);
|
||||
// }
|
||||
// }
|
||||
|
||||
//删除服务
|
||||
Goods::destroy($ids);
|
||||
|
||||
// 提交事务
|
||||
// Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
// Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改服务状态
|
||||
* @param $params
|
||||
* @return Goods
|
||||
* @author ljj
|
||||
* @date 2022/2/9 4:54 下午
|
||||
*/
|
||||
public function status($params)
|
||||
{
|
||||
return Goods::update(['status'=>$params['status']],['id'=>$params['ids']]);
|
||||
}
|
||||
}
|
||||
110
server/app/adminapi/logic/goods/GoodsUnitLogic.php
Executable file
110
server/app/adminapi/logic/goods/GoodsUnitLogic.php
Executable file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\goods;
|
||||
|
||||
|
||||
use app\common\enum\DefaultEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\goods\GoodsUnit;
|
||||
|
||||
class GoodsUnitLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 通用单位列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/9 3:48 下午
|
||||
*/
|
||||
public function commonLists()
|
||||
{
|
||||
$lists = (new GoodsUnit())->field('id,name')
|
||||
->order(['sort'=>'asc','id'=>'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加服务单位
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 11:37 上午
|
||||
*/
|
||||
public function add($params)
|
||||
{
|
||||
GoodsUnit::create([
|
||||
'name' => $params['name'],
|
||||
'sort' => $params['sort'] ?? DefaultEnum::SORT,
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看服务单位详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/8 11:49 上午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
return GoodsUnit::where('id',$id)->findOrEmpty()->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑服务单位
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 11:58 上午
|
||||
*/
|
||||
public function edit($params)
|
||||
{
|
||||
GoodsUnit::update([
|
||||
'name' => $params['name'],
|
||||
'sort' => $params['sort'] ?? DefaultEnum::SORT,
|
||||
],['id'=>$params['id']]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除服务单位
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 12:09 下午
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
GoodsUnit::destroy($id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user