chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材 添加系统版本配置文件(.version)和常量定义文件(.constant) 更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件 添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
128
app/controller/supplier/product/StoreBrand.php
Normal file
128
app/controller/supplier/product/StoreBrand.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\services\product\brand\StoreBrandServices;
|
||||
use think\annotation\Inject;use think\facade\App;
|
||||
|
||||
/**
|
||||
* 商品品牌控制器
|
||||
* Class StoreBrand
|
||||
* @package app\controller\supplier\product
|
||||
*/
|
||||
class StoreBrand extends AuthController
|
||||
{
|
||||
/**
|
||||
* @var StoreBrandServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreBrandServices $services;
|
||||
|
||||
/**
|
||||
* 品牌列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['brand_name', ''],
|
||||
['pid', 0]
|
||||
]);
|
||||
$where['is_del'] = 0;
|
||||
$data = $this->services->getList($where);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取品牌cascader格式数据
|
||||
* @param $type
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function cascader_list($type = 1)
|
||||
{
|
||||
return $this->success($this->services->cascaderList($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param string $is_show
|
||||
* @param string $id
|
||||
*/
|
||||
public function set_show($is_show = '', $id = '')
|
||||
{
|
||||
if ($is_show == '' || $id == '') return $this->fail('缺少参数');
|
||||
$this->services->setShow($id, $is_show);
|
||||
return $this->success($is_show == 1 ? '显示成功' : '隐藏成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增品牌
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['fid', []],
|
||||
['brand_name', ''],
|
||||
['sort', 0],
|
||||
['is_show', 0]
|
||||
]);
|
||||
if (!$data['brand_name']) {
|
||||
return $this->fail('请输入品牌名称');
|
||||
}
|
||||
if (iconv_strlen($data['brand_name'], 'UTF-8') > 10) {
|
||||
return $this->fail('品牌名称过长');
|
||||
}
|
||||
$this->services->createData($data);
|
||||
return $this->success('添加品牌成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新品牌
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['fid', []],
|
||||
['brand_name', ''],
|
||||
['sort', 0],
|
||||
['is_show', 0]
|
||||
]);
|
||||
if (!$data['brand_name']) {
|
||||
return $this->fail('请输入品牌名称');
|
||||
}
|
||||
if (iconv_strlen($data['brand_name'], 'UTF-8') > 10) {
|
||||
return $this->fail('品牌名称过长');
|
||||
}
|
||||
$this->services->editData($id, $data);
|
||||
return $this->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除品牌
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$this->services->del((int)$id);
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
}
|
||||
569
app/controller/supplier/product/StoreProduct.php
Normal file
569
app/controller/supplier/product/StoreProduct.php
Normal file
@@ -0,0 +1,569 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product;
|
||||
|
||||
|
||||
use app\controller\admin\v1\system\SystemClearData;
|
||||
use app\jobs\BatchHandleJob;
|
||||
use app\services\other\queue\QueueServices;
|
||||
use app\services\product\branch\StoreBranchProductAttrValueServices;
|
||||
use app\services\product\branch\StoreBranchProductServices;
|
||||
use app\services\product\category\StoreProductCategoryServices;
|
||||
use app\services\product\product\StoreProductBatchProcessServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\product\shipping\ShippingTemplatesServices;
|
||||
use app\services\product\sku\StoreProductAttrServices;
|
||||
use app\services\product\sku\StoreProductAttrValueServices;
|
||||
use app\services\product\sku\StoreProductRuleServices;
|
||||
use app\services\user\label\UserLabelCateServices;
|
||||
use app\services\user\label\UserLabelServices;
|
||||
use crmeb\services\UploadService;
|
||||
use think\annotation\Inject;
|
||||
use app\controller\supplier\AuthController;
|
||||
|
||||
/**
|
||||
* Class StoreProduct
|
||||
* @package app\controller\supplier\product
|
||||
*/
|
||||
class StoreProduct extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreProductServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductServices $services;
|
||||
|
||||
/**
|
||||
* 显示资源列表头部
|
||||
* @return mixed
|
||||
*/
|
||||
public function type_header(StoreProductCategoryServices $storeProductCategoryServices)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['store_name', ''],
|
||||
['cate_id', ''],
|
||||
['type', 1, '', 'status'],
|
||||
['show_type', ''],
|
||||
['sales', 'normal'],
|
||||
['pid', ''],
|
||||
['data', '', '', 'time'],
|
||||
['store_label_id', ''],
|
||||
['brand_id', '']
|
||||
]);
|
||||
$cateId = $where['cate_id'];
|
||||
if ($cateId) {
|
||||
$cateId = is_string($cateId) ? [$cateId] : $cateId;
|
||||
$cateId = array_merge($cateId, $storeProductCategoryServices->getColumn(['pid' => $cateId], 'id'));
|
||||
$cateId = array_unique(array_diff($cateId, [0]));
|
||||
}
|
||||
$where['cate_id'] = $cateId;
|
||||
$where['supplier_id'] = $this->supplierId;
|
||||
$list = $this->services->getHeader(0, $where);
|
||||
return app('json')->success(compact('list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(StoreProductCategoryServices $storeProductCategoryServices)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['store_name', ''],
|
||||
['cate_id', ''],
|
||||
['type', 1, '', 'status'],
|
||||
['show_type', ''],
|
||||
['sales', 'normal'],
|
||||
['pid', ''],
|
||||
['data', '', '', 'time'],
|
||||
['store_label_id', ''],
|
||||
['brand_id', '']
|
||||
]);
|
||||
$cateId = $where['cate_id'];
|
||||
if ($cateId) {
|
||||
$cateId = is_string($cateId) ? [$cateId] : $cateId;
|
||||
$cateId = array_merge($cateId, $storeProductCategoryServices->getColumn(['pid' => $cateId], 'id'));
|
||||
$cateId = array_unique(array_diff($cateId, [0]));
|
||||
}
|
||||
$where['cate_id'] = $cateId;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
$where['type'] = 2;
|
||||
$data = $this->services->getList($where);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取选择的商品列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function search_list()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['cate_id', ''],
|
||||
['store_name', ''],
|
||||
['type', 1, '', 'status'],
|
||||
['is_live', 0],
|
||||
['is_new', ''],
|
||||
['is_vip_product', ''],
|
||||
['is_presale_product', ''],
|
||||
['data', '', '', 'time'],
|
||||
['store_label_id', ''],
|
||||
['brand_id', '']
|
||||
]);
|
||||
$where['is_show'] = 1;
|
||||
$where['is_del'] = 0;
|
||||
$where['type'] = 2;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
/** @var StoreProductCategoryServices $storeCategoryServices */
|
||||
$storeCategoryServices = app()->make(StoreProductCategoryServices::class);
|
||||
if ($where['cate_id'] !== '') {
|
||||
if ($storeCategoryServices->value(['id' => $where['cate_id']], 'pid')) {
|
||||
$where['sid'] = $where['cate_id'];
|
||||
} else {
|
||||
$where['cid'] = $where['cate_id'];
|
||||
}
|
||||
}
|
||||
unset($where['cate_id']);
|
||||
$list = $this->services->searchList($where);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类cascader格式数据
|
||||
* @param $type
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function cascader_list(StoreProductCategoryServices $services)
|
||||
{
|
||||
return app('json')->success($services->cascaderList(2, (int)$this->supplierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品详细信息
|
||||
* @param int $id
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function read($id = 0)
|
||||
{
|
||||
return app('json')->success($this->services->getInfo((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建或编辑
|
||||
* @param StoreProductAttrServices $attrServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function save(StoreProductAttrServices $attrServices, $id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['product_type', 0],//商品类型
|
||||
['supplier_id', 0],//供应商ID
|
||||
['cate_id', []],
|
||||
['store_name', ''],
|
||||
['store_info', ''],
|
||||
['keyword', ''],
|
||||
['unit_name', '件'],
|
||||
['recommend_image', ''],
|
||||
['slider_image', []],
|
||||
['is_sub', []],//佣金是单独还是默认
|
||||
['sort', 0],
|
||||
// ['sales', 0],
|
||||
['ficti', 100],
|
||||
['give_integral', 0],
|
||||
['is_show', 0],
|
||||
['is_hot', 0],
|
||||
['is_benefit', 0],
|
||||
['is_best', 0],
|
||||
['is_new', 0],
|
||||
['mer_use', 0],
|
||||
['is_postage', 0],
|
||||
['is_good', 0],
|
||||
['description', ''],
|
||||
['spec_type', 0],
|
||||
['video_open', 0],
|
||||
['video_link', ''],
|
||||
['items', []],
|
||||
['attrs', []],
|
||||
['attr', []],
|
||||
['recommend', []],//商品推荐
|
||||
['activity', []],
|
||||
['coupon_ids', []],
|
||||
['label_id', []],
|
||||
['command_word', ''],
|
||||
['tao_words', ''],
|
||||
['type', 0, '', 'is_copy'],
|
||||
['delivery_type', []],//物流设置
|
||||
['freight', 1],//运费设置
|
||||
['postage', 0],//邮费
|
||||
['temp_id', 0],//运费模版
|
||||
['recommend_list', []],
|
||||
['brand_id', []],
|
||||
['soure_link', ''],
|
||||
['bar_code', ''],
|
||||
['code', ''],
|
||||
// ['is_support_refund', 1],//是否支持退款
|
||||
['is_presale_product', 0],//预售商品开关
|
||||
['presale_time', []],//预售时间
|
||||
['presale_day', 0],//预售发货日
|
||||
['is_vip_product', 0],//是否付费会员商品
|
||||
['auto_on_time', 0],//自动上架时间
|
||||
['auto_off_time', 0],//自动下架时间
|
||||
['custom_form', []],//自定义表单
|
||||
['system_form_id', 0],//系统表单ID
|
||||
['store_label_id', []],//商品标签
|
||||
['ensure_id', []],//商品保障服务区
|
||||
['specs', []],//商品参数
|
||||
['specs_id', 0],//商品参数ID
|
||||
['is_limit', 0],//是否限购
|
||||
['limit_type', 0],//限购类型
|
||||
['limit_num', 0],//限购数量
|
||||
['product_clear', []],//商品用户可见,普通,采购商,付费会员可见
|
||||
]);
|
||||
$data['is_verify'] = 0;
|
||||
//供应商商品不支持门店
|
||||
$data['delivery_type'] = [1];
|
||||
$this->services->saveData((int)$id, $data, 2, (int)$this->supplierId);
|
||||
|
||||
$this->services->cacheTag()->clear();
|
||||
$attrServices->cacheTag()->clear();
|
||||
return $this->success($id ? '保存商品信息成功' : '添加商品成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存编辑
|
||||
* @param StoreBranchProductAttrValueServices $services
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(StoreBranchProductAttrValueServices $services, $id = 0)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['attrs', []],
|
||||
['label_id', []],
|
||||
['is_show', 1]
|
||||
]);
|
||||
$storeId = $this->storeId;
|
||||
$services->updataAll((int)$id, (array)$data, (int)$storeId);
|
||||
return app('json')->success('保存商品信息成功');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取关联用户标签列表
|
||||
* @param UserLabelServices $service
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUserLabel(UserLabelCateServices $userLabelCateServices, UserLabelServices $service)
|
||||
{
|
||||
$cate = $userLabelCateServices->getLabelCateAll(2, (int)$this->supplierId);
|
||||
$data = [];
|
||||
$label = [];
|
||||
if ($cate) {
|
||||
foreach ($cate as $value) {
|
||||
$data[] = [
|
||||
'id' => $value['id'] ?? 0,
|
||||
'value' => $value['id'] ?? 0,
|
||||
'label_cate' => 0,
|
||||
'label_name' => $value['name'] ?? '',
|
||||
'label' => $value['name'] ?? '',
|
||||
'store_id' => $value['store_id'] ?? 0,
|
||||
'type' => $value['type'] ?? 1,
|
||||
];
|
||||
}
|
||||
$label = $service->getColumn(['type' => 2, 'relation_id' => $this->supplierId], '*');
|
||||
if ($label) {
|
||||
foreach ($label as &$item) {
|
||||
$item['label'] = $item['label_name'];
|
||||
$item['value'] = $item['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return app('json')->success($service->get_tree_children($data, $label));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param StoreBranchProductServices $services
|
||||
* @param $is_show
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function set_show(StoreBranchProductServices $services, $is_show = '', $id = '')
|
||||
{
|
||||
if (!$id) return $this->fail('缺少商品ID');
|
||||
$services->setShow($this->supplierId, $id, $is_show);
|
||||
return $this->success($is_show == 1 ? '上架成功' : '下架成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取规格模板
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function get_rule(StoreProductRuleServices $services)
|
||||
{
|
||||
return $this->success($services->getRule(2, (int)$this->supplierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品详细信息
|
||||
* @param int $id
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function get_product_info($id = 0)
|
||||
{
|
||||
return $this->success($this->services->getInfo((int)$id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取运费模板列表
|
||||
* @param ShippingTemplatesServices $services
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function get_template(ShippingTemplatesServices $services)
|
||||
{
|
||||
return $this->success($services->getTemp(2, (int)$this->supplierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取视频上传token
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getTempKeys()
|
||||
{
|
||||
$upload = UploadService::init();
|
||||
$type = (int)sys_config('upload_type', 1);
|
||||
$key = $this->request->get('key', '');
|
||||
$path = $this->request->get('path', '');
|
||||
$contentType = $this->request->get('contentType', '');
|
||||
if ($type === 5) {
|
||||
if (!$key || !$contentType) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
$re = $upload->getTempKeys($key, $path, $contentType);
|
||||
} else {
|
||||
$re = $upload->getTempKeys();
|
||||
}
|
||||
return $re ? $this->success($re) : $this->fail($upload->getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品所有规格数据
|
||||
* @param StoreBranchProductAttrValueServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttrs(StoreBranchProductAttrValueServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少商品ID');
|
||||
}
|
||||
return $this->success($services->getStoreProductAttr((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//删除商品检测是否有参与活动
|
||||
// $this->services->checkActivity($id);
|
||||
$res = $this->services->del($id);
|
||||
event('product.delete', [$id]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成规格列表
|
||||
* @param int $id
|
||||
* @param int $type
|
||||
* @return mixed
|
||||
*/
|
||||
public function is_format_attr($id = 0, $type = 0)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['attrs', []],
|
||||
['items', []],
|
||||
['product_type', 0]
|
||||
|
||||
]);
|
||||
// if ($id > 0 && $type == 1) $this->services->checkActivity($id);
|
||||
$info = $this->services->getAttr($data, $id, $type, 2, 0, true);
|
||||
return $this->success(compact('info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速修改商品规格库存
|
||||
* @param StoreProductAttrValueServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function saveProductAttrsStock(StoreProductAttrValueServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少商品ID');
|
||||
}
|
||||
[$attrs] = $this->request->getMore([
|
||||
['attrs', []]
|
||||
], true);
|
||||
if (!$attrs) {
|
||||
return $this->fail('请重新修改规格库存');
|
||||
}
|
||||
foreach ($attrs as $attr) {
|
||||
if (!isset($attr['unique']) || !isset($attr['pm']) || !isset($attr['stock'])) {
|
||||
return $this->fail('请重新修改规格库存');
|
||||
}
|
||||
}
|
||||
return $this->success(['stock' => $services->saveProductAttrsStock((int)$id, $attrs)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置批量商品上架
|
||||
* @return mixed
|
||||
*/
|
||||
public function product_show()
|
||||
{
|
||||
[$ids, $all, $where] = $this->request->postMore([
|
||||
['ids', []],
|
||||
['all', 0],
|
||||
['where', []],
|
||||
], true);
|
||||
if ($all == 0) {//单页不走队列
|
||||
if (empty($ids)) return $this->fail('请选择需要上架的商品');
|
||||
$this->services->setShow($ids, 1);
|
||||
return $this->success('上架成功');
|
||||
}
|
||||
if ($all == 1) {
|
||||
$ids = [];
|
||||
if (isset($where['type'])) {
|
||||
$where['status'] = $where['type'];
|
||||
unset($where['type']);
|
||||
}
|
||||
$where['type'] = 2;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
}
|
||||
$type = 4;//商品上架
|
||||
/** @var QueueServices $queueService */
|
||||
$queueService = app()->make(QueueServices::class);
|
||||
$queueService->setQueueData($where, 'id', $ids, $type);
|
||||
//加入队列
|
||||
BatchHandleJob::dispatch(['up', $type]);
|
||||
return $this->success('后台程序已执商品上架任务!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置批量商品下架
|
||||
* @return mixed
|
||||
*/
|
||||
public function product_unshow()
|
||||
{
|
||||
[$ids, $all, $where] = $this->request->postMore([
|
||||
['ids', []],
|
||||
['all', 0],
|
||||
['where', []],
|
||||
], true);
|
||||
if ($all == 0) {//单页不走队列
|
||||
if (empty($ids)) return $this->fail('请选择需要下架的商品');
|
||||
$this->services->setShow($ids, 0);
|
||||
return $this->success('下架成功');
|
||||
}
|
||||
if ($all == 1) {
|
||||
$all_ids = $this->services->getColumn(['is_show' => 1, 'is_del' => 0, 'type' => 2, 'relation_id' => $this->supplierId], 'id');
|
||||
// $this->services->checkActivity($all_ids);
|
||||
$ids = [];
|
||||
if (isset($where['type'])) {
|
||||
$where['status'] = $where['type'];
|
||||
unset($where['type']);
|
||||
}
|
||||
$where['type'] = 2;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
}
|
||||
$type = 4;//商品下架
|
||||
/** @var QueueServices $queueService */
|
||||
$queueService = app()->make(QueueServices::class);
|
||||
$queueService->setQueueData($where, 'id', $ids, $type);
|
||||
//加入队列
|
||||
BatchHandleJob::dispatch(['down', $type]);
|
||||
return $this->success('后台程序已执商品下架任务!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品批量操作
|
||||
* @param StoreProductBatchProcessServices $batchProcessServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function batchProcess(StoreProductBatchProcessServices $batchProcessServices)
|
||||
{
|
||||
[$type, $ids, $all, $where, $data] = $this->request->postMore([
|
||||
['type', 1],
|
||||
['ids', ''],
|
||||
['all', 0],
|
||||
['where', ""],
|
||||
['data', []]
|
||||
], true);
|
||||
if (!$ids && $all == 0) return $this->fail('请选择批处理商品');
|
||||
if (!$data) {
|
||||
return $this->fail('请选择批处理数据');
|
||||
}
|
||||
if (isset($where['type'])) {
|
||||
$where['status'] = $where['type'];
|
||||
unset($where['type']);
|
||||
}
|
||||
$where['type'] = 2;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
//批量操作
|
||||
$batchProcessServices->batchProcess((int)$type, $ids, $data, !!$all, $where);
|
||||
return app('json')->success('已加入消息队列,请稍后查看');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除回收站商品
|
||||
* @param $id
|
||||
* @param SystemClearData $clearData
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/9/30 15:39
|
||||
*/
|
||||
public function thoroughDelete($id, SystemClearData $clearData)
|
||||
{
|
||||
$info = $this->services->getOne(['id' => $id]);
|
||||
if (!$info) return $this->fail('商品不存在');
|
||||
if ($info->relation_id != $this->supplierId) return $this->fail('只能删除供应商自己商品');
|
||||
if ($info->is_del == 0) return $this->fail('只能删除回收站商品');
|
||||
|
||||
$clearData->recycleProduct([$id]);
|
||||
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
}
|
||||
161
app/controller/supplier/product/StoreProductCategory.php
Normal file
161
app/controller/supplier/product/StoreProductCategory.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\services\product\category\StoreProductCategoryServices;
|
||||
use think\annotation\Inject;use think\facade\App;
|
||||
|
||||
/**
|
||||
* 商品分类控制器
|
||||
* Class StoreProductCategory
|
||||
*/
|
||||
class StoreProductCategory extends AuthController
|
||||
{
|
||||
/**
|
||||
* @var StoreProductCategoryServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductCategoryServices $services;
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['is_show', ''],
|
||||
['pid', 0],
|
||||
['cate_name', ''],
|
||||
]);
|
||||
// $where['type'] = 2;
|
||||
// $where['relation_id'] = $this->supplierId;
|
||||
$where['pid'] = (int)$where['pid'];
|
||||
$data = $this->services->getList($where);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分类搜索
|
||||
* @return mixed
|
||||
*/
|
||||
public function tree_list($type)
|
||||
{
|
||||
$list = $this->services->getTierList(1, $type);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类cascader格式数据
|
||||
* @param $type
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function cascader_list($type = 1)
|
||||
{
|
||||
return $this->success($this->services->cascaderList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param string $is_show
|
||||
* @param string $id
|
||||
*/
|
||||
public function set_show($is_show = '', $id = '')
|
||||
{
|
||||
if ($is_show == '' || $id == '') return $this->fail('缺少参数');
|
||||
$this->services->setShow($id, $is_show);
|
||||
return $this->success($is_show == 1 ? '显示成功' : '隐藏成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成新增表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return $this->success($this->services->createForm(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增分类
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['pid', 0],
|
||||
['cate_name', ''],
|
||||
['pic', ''],
|
||||
['big_pic', ''],
|
||||
['sort', 0],
|
||||
['is_show', 0]
|
||||
]);
|
||||
if (!$data['cate_name']) {
|
||||
return $this->fail('请输入分类名称');
|
||||
}
|
||||
$data['type'] = 2;
|
||||
$data['relation_id'] = $this->supplierId;
|
||||
$this->services->createData($data);
|
||||
return $this->success('添加分类成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成更新表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return $this->success($this->services->editForm((int)$id, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新分类
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['pid', 0],
|
||||
['cate_name', ''],
|
||||
['pic', ''],
|
||||
['big_pic', ''],
|
||||
['sort', 0],
|
||||
['is_show', 0]
|
||||
]);
|
||||
if (!$data['cate_name']) {
|
||||
return $this->fail('请输入分类名称');
|
||||
}
|
||||
$this->services->editData($id, $data);
|
||||
return $this->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$this->services->del((int)$id);
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
}
|
||||
78
app/controller/supplier/product/StoreProductReply.php
Normal file
78
app/controller/supplier/product/StoreProductReply.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\services\product\product\StoreProductReplyServices;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 评论管理 控制器
|
||||
* Class StoreProductReply
|
||||
* @package app\controller\supplier\product
|
||||
*/
|
||||
class StoreProductReply extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreProductReplyServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductReplyServices $services;
|
||||
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['is_reply', ''],
|
||||
['store_name', ''],
|
||||
['account', ''],
|
||||
['data', ''],
|
||||
['product_id', 0]
|
||||
]);
|
||||
$where['type'] = 2;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
$list = $this->services->sysPage($where);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$this->services->del($id);
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复评论
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_reply($id)
|
||||
{
|
||||
[$content] = $this->request->postMore([
|
||||
['content', '']
|
||||
], true);
|
||||
$this->services->setReply((int)$id, $content, 2, (int)$this->supplierId);
|
||||
return $this->success('回复成功!');
|
||||
}
|
||||
|
||||
}
|
||||
98
app/controller/supplier/product/StoreProductRule.php
Normal file
98
app/controller/supplier/product/StoreProductRule.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\services\product\sku\StoreProductRuleServices;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 规则管理
|
||||
* Class StoreProductRule
|
||||
* @package app\controller\supplier\product
|
||||
*/
|
||||
class StoreProductRule extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreProductRuleServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductRuleServices $services;
|
||||
|
||||
/**
|
||||
* 规格列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['rule_name', '']
|
||||
]);
|
||||
$where['type'] = 2;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
$list = $this->services->getList($where);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存规格
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['rule_name', ''],
|
||||
['spec', []]
|
||||
]);
|
||||
if (!$data['rule_name']) {
|
||||
return $this->fail('请输入分类名称');
|
||||
}
|
||||
$data['type'] = 2;
|
||||
$data['relation_id'] = $this->supplierId;
|
||||
$this->services->save($id, $data, 2, (int)$this->supplierId);
|
||||
return $this->success('保存成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取规格信息
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
$info = $this->services->getInfo((int)$id);
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少ID');
|
||||
}
|
||||
$info = $this->services->getInfo((int)$id);
|
||||
if (!$info) {
|
||||
return $this->fail('删除的数据不存在');
|
||||
}
|
||||
$this->services->delete($id);
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
}
|
||||
169
app/controller/supplier/product/StoreProductUnit.php
Normal file
169
app/controller/supplier/product/StoreProductUnit.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\services\product\product\StoreProductUnitServices;
|
||||
use think\annotation\Inject;use think\facade\App;
|
||||
use app\Request;
|
||||
|
||||
/**
|
||||
* 商品单位
|
||||
* Class StoreProductUnit
|
||||
* @package app\controller\supplier\product
|
||||
*/
|
||||
class StoreProductUnit extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreProductUnitServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductUnitServices $services;
|
||||
|
||||
/**
|
||||
* 获取所有商品单位
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAllUnit()
|
||||
{
|
||||
return $this->success($this->services->getAllUnitList(2, (int)$this->supplierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['name', '']
|
||||
]);
|
||||
$where['type'] = 2;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
$where['status'] = 1;
|
||||
$where['is_del'] = 0;
|
||||
return $this->success($this->services->getUnitList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return $this->success($this->services->createForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \app\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['name', ''],
|
||||
['sort', 0]
|
||||
]);
|
||||
|
||||
validate(\app\validate\admin\product\StoreProductUnitValidate::class)->scene('get')->check(['name' => $data['name']]);
|
||||
|
||||
if ($this->services->getCount(['name' => $data['name'], 'is_del' => 0, 'type' => 2, 'relation_id' => $this->supplierId])) {
|
||||
return $this->fail('单位已经存在,请勿重复添加');
|
||||
}
|
||||
$data['add_time'] = time();
|
||||
if ($this->services->save($data)) {
|
||||
return $this->success('保存成功');
|
||||
} else {
|
||||
return $this->fail('保存失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少ID');
|
||||
}
|
||||
$info = $this->services->get($id);
|
||||
if (!$info) {
|
||||
return $this->fail('获取商品单位失败');
|
||||
}
|
||||
return $this->success($info->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return $this->success($this->services->updateForm((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \app\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['name', ''],
|
||||
['sort', 0]
|
||||
]);
|
||||
|
||||
validate(\app\validate\admin\product\StoreProductUnitValidate::class)->scene('get')->check(['name' => $data['name']]);
|
||||
|
||||
$unit = $this->services->getOne(['name' => $data['name'], 'is_del' => 0, 'type' => 2, 'relation_id' => $this->supplierId]);
|
||||
if ($unit && $unit['id'] != $id) {
|
||||
return $this->fail('单位名称已经存在');
|
||||
}
|
||||
if ($this->services->update($id, $data)) {
|
||||
return $this->success('修改成功');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id || !($info = $this->services->get($id))) {
|
||||
return $this->fail('删除的数据不存在');
|
||||
}
|
||||
if ($info && $info['is_del'] == 0) {
|
||||
$this->services->update($id, ['is_del' => 1]);
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
}
|
||||
162
app/controller/supplier/product/ensure/StoreProductEnsure.php
Normal file
162
app/controller/supplier/product/ensure/StoreProductEnsure.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product\ensure;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\Request;
|
||||
use app\services\product\ensure\StoreProductEnsureServices;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 商品保障服务
|
||||
* Class StoreProductEnsure
|
||||
* @package app\controller\supplier\product\ensure
|
||||
*/
|
||||
class StoreProductEnsure extends AuthController
|
||||
{
|
||||
/**
|
||||
* @var StoreProductEnsureServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductEnsureServices $services;
|
||||
|
||||
/**
|
||||
* 获取保障服务列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['name', '']
|
||||
]);
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
$where['type'] = 2;
|
||||
return $this->success($this->services->getEnsureList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取保障服务列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function allEnsure()
|
||||
{
|
||||
return $this->success($this->services->getAllEnsure(2, (int)$this->supplierId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成新增表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return $this->success($this->services->createForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增保障服务
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['image', ''],
|
||||
['desc', ''],
|
||||
['sort', 0],
|
||||
]);
|
||||
if (!$data['name']) {
|
||||
return $this->fail('请输入保障服务条款');
|
||||
}
|
||||
if (!$data['image']) return $this->fail('请上传图标');
|
||||
if ($this->services->getOne(['name' => $data['name']])) {
|
||||
return $this->fail('保障服务条款已存在');
|
||||
}
|
||||
$data['type'] = 2;
|
||||
$data['relation_id'] = $this->supplierId;
|
||||
$data['add_time'] = time();
|
||||
$this->services->save($data);
|
||||
return $this->success('添加保障服务成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成更新表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return $this->success($this->services->editForm((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新保障服务
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['image', ''],
|
||||
['desc', ''],
|
||||
['sort', 0],
|
||||
]);
|
||||
if (!$data['name']) {
|
||||
return $this->fail('请输入保障服务条款');
|
||||
}
|
||||
if (!$data['image']) return $this->fail('请上传图标');
|
||||
$cate = $this->services->getOne(['name' => $data['name']]);
|
||||
if ($cate && $cate['id'] != $id) {
|
||||
return $this->fail('保障服务条款已存在');
|
||||
}
|
||||
$this->services->update($id, $data);
|
||||
return $this->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置保障服务是否显示
|
||||
* @param $id
|
||||
* @param $is_show
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_show($id, $is_show)
|
||||
{
|
||||
($is_show == '' || $id == '') && $this->fail('缺少参数');
|
||||
$res = $this->services->update((int)$id, ['status' => (int)$is_show]);
|
||||
if ($res) {
|
||||
return $this->success('设置成功');
|
||||
} else {
|
||||
return $this->fail('设置失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除保障服务
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id || !$this->services->count(['id' => $id])) {
|
||||
return $this->fail('删除的数据不存在');
|
||||
}
|
||||
$this->services->delete((int)$id);
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
}
|
||||
125
app/controller/supplier/product/label/StoreProductLabel.php
Normal file
125
app/controller/supplier/product/label/StoreProductLabel.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product\label;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\services\product\label\StoreProductLabelServices;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
use app\Request;
|
||||
|
||||
/**
|
||||
* 商品标签
|
||||
* Class StoreProductLabel
|
||||
* @package app\controller\supplier\product\label
|
||||
*/
|
||||
class StoreProductLabel extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreProductLabelServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductLabelServices $services;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 带标签的标签组树形结构
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function tree_list()
|
||||
{
|
||||
return $this->success($this->services->getProductLabelTreeList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品标签列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function allLabel()
|
||||
{
|
||||
return $this->success($this->services->getList(2, (int)$this->supplierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加、编辑商品标签
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save(Request $request, $id)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['label_cate', 0],
|
||||
['label_name', ''],
|
||||
]);
|
||||
if (!$data['label_cate']) {
|
||||
return $this->fail('请选择标签组');
|
||||
}
|
||||
if (!trim($data['label_name'])) {
|
||||
return $this->fail('请输入标签名称');
|
||||
}
|
||||
$label = $this->services->getOne(['label_cate' => $data['label_cate'], 'label_name' => $data['label_name'], 'type' => 2, 'relation_id' => $this->supplierId]);
|
||||
if ($id) {
|
||||
if ($label && $id != $label['id']) {
|
||||
return $this->fail('标签已经存在');
|
||||
}
|
||||
if ($this->services->update($id, $data)) {
|
||||
return $this->success('编辑成功');
|
||||
} else {
|
||||
return $this->fail('编辑失败');
|
||||
}
|
||||
} else {
|
||||
if ($label) {
|
||||
return $this->fail('标签已经存在');
|
||||
}
|
||||
$data['type'] = 2;
|
||||
$data['relation_id'] = $this->supplierId;
|
||||
$data['add_time'] = time();
|
||||
if ($this->services->save($data)) {
|
||||
return $this->success('保存成功');
|
||||
} else {
|
||||
return $this->fail('保存失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id || !$this->services->count(['id' => $id])) {
|
||||
return $this->fail('删除的数据不存在');
|
||||
}
|
||||
$this->services->delete($id);
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getLabelForm()
|
||||
{
|
||||
return $this->success($this->services->getLabelForm());
|
||||
}
|
||||
}
|
||||
135
app/controller/supplier/product/label/StoreProductLabelCate.php
Normal file
135
app/controller/supplier/product/label/StoreProductLabelCate.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product\label;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\Request;
|
||||
use app\services\product\label\StoreProductLabelCateServices;
|
||||
use app\services\product\label\StoreProductLabelServices;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 商品标签组
|
||||
* Class StoreProductLabelCate
|
||||
* @package app\controller\supplier\product\label
|
||||
*/
|
||||
class StoreProductLabelCate extends AuthController
|
||||
{
|
||||
/**
|
||||
* @var StoreProductLabelCateServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductLabelCateServices $services;
|
||||
|
||||
/**
|
||||
* 获取标签组列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['name', '']
|
||||
]);
|
||||
$where['type'] = 2;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
$where['group'] = 2;
|
||||
$where['product_label'] = 1;
|
||||
return $this->success($this->services->getProductLabelCateList($where));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成新增表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return $this->success($this->services->createForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增标签组
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['sort', 0],
|
||||
]);
|
||||
if (!trim($data['name'])) {
|
||||
return $this->fail('请输入标签组名称');
|
||||
}
|
||||
if ($this->services->getOne(['name' => $data['name'], 'group' => 2, 'type' => 2, 'relation_id' => $this->supplierId])) {
|
||||
return $this->fail('标签组已存在');
|
||||
}
|
||||
$data['type'] = 2;
|
||||
$data['relation_id'] = $this->supplierId;
|
||||
$data['group'] = 2;
|
||||
$data['add_time'] = time();
|
||||
$this->services->save($data);
|
||||
return $this->success('添加标签组成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成更新表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return $this->success($this->services->editForm((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新标签组
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['sort', 0],
|
||||
]);
|
||||
if (!$data['name']) {
|
||||
return $this->fail('请输入标签组名称');
|
||||
}
|
||||
$cate = $this->services->getOne(['name' => $data['name'], 'group' => 2, 'type' => 2, 'relation_id' => $this->supplierId]);
|
||||
if ($cate && $cate['id'] != $id) {
|
||||
return $this->fail('标签组已存在');
|
||||
}
|
||||
$this->services->update($id, $data);
|
||||
return $this->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签组
|
||||
* @param StoreProductLabelServices $labelServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(StoreProductLabelServices $labelServices, $id)
|
||||
{
|
||||
if (!$id || !$this->services->count(['id' => $id])) {
|
||||
return $this->fail('删除的数据不存在');
|
||||
}
|
||||
if ($labelServices->count(['label_cate' => $id])) {
|
||||
return $this->fail('标签组下有标签不能删除');
|
||||
}
|
||||
$this->services->delete((int)$id);
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
}
|
||||
116
app/controller/supplier/product/shipping/ShippingTemplates.php
Normal file
116
app/controller/supplier/product/shipping/ShippingTemplates.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product\shipping;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\services\product\shipping\ShippingTemplatesServices;
|
||||
use app\services\other\SystemCityServices;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 运费模板
|
||||
* Class ShippingTemplates
|
||||
* @package app\controller\supplier\setting
|
||||
*/
|
||||
class ShippingTemplates extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ShippingTemplatesServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected ShippingTemplatesServices $services;
|
||||
|
||||
|
||||
/**
|
||||
* 运费模板列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function temp_list()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
[['name', 's'], '']
|
||||
]);
|
||||
$where['type'] = 2;
|
||||
$where['relation_id'] = $this->supplierId;
|
||||
return $this->success($this->services->getShippingList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return $this->success($this->services->getShipping((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存或者修改
|
||||
* @param int $id
|
||||
*/
|
||||
public function save($id = 0)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
[['region_info', 'a'], []],
|
||||
[['appoint_info', 'a'], []],
|
||||
[['no_delivery_info', 'a'], []],
|
||||
[['sort', 'd'], 0],
|
||||
[['type', 'd'], 0, '', 'group'],
|
||||
[['name', 's'], ''],
|
||||
[['appoint', 'd'], 0],
|
||||
[['no_delivery', 'd'], 0]
|
||||
]);
|
||||
$this->validate($data, \app\validate\admin\setting\ShippingTemplatesValidate::class, 'save');
|
||||
$temp['type'] = 2;
|
||||
$temp['relation_id'] = $this->supplierId;
|
||||
$temp['name'] = $data['name'];
|
||||
$temp['group'] = $data['group'];
|
||||
$temp['appoint'] = $data['appoint'] && $data['appoint_info'] ? 1 : 0;
|
||||
$temp['no_delivery'] = $data['no_delivery'] && $data['no_delivery_info'] ? 1 : 0;
|
||||
$temp['sort'] = $data['sort'];
|
||||
$temp['add_time'] = time();
|
||||
$this->services->save((int)$id, $temp, $data);
|
||||
event('product.shipping.update');
|
||||
return $this->success((int)$id ? '修改成功!' : '添加成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除运费模板
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
[$id] = $this->request->getMore([
|
||||
[['id', 'd'], 0],
|
||||
], true);
|
||||
if ($id == 1) {
|
||||
return $this->fail('默认模板不能删除');
|
||||
} else {
|
||||
$this->services->detete($id);
|
||||
event('product.shipping.update');
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 城市数据
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function city_list(SystemCityServices $services)
|
||||
{
|
||||
return $this->success($services->getShippingCity());
|
||||
}
|
||||
}
|
||||
150
app/controller/supplier/product/specs/StoreProductSpecs.php
Normal file
150
app/controller/supplier/product/specs/StoreProductSpecs.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\supplier\product\specs;
|
||||
|
||||
use app\controller\supplier\AuthController;
|
||||
use app\services\product\specs\StoreProductSpecsServices;
|
||||
use app\services\product\specs\StoreProductSpecsTemplateServices;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
use app\Request;
|
||||
|
||||
/**
|
||||
* 商品参数
|
||||
* Class StoreProductSpecs
|
||||
* @package app\controller\supplier\product\specs
|
||||
*/
|
||||
class StoreProductSpecs extends AuthController
|
||||
{
|
||||
/**
|
||||
* 参数模版services
|
||||
* @var StoreProductSpecsTemplateServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductSpecsTemplateServices $templateServices;
|
||||
|
||||
/**
|
||||
* @var StoreProductSpecsServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductSpecsServices $services;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['name', '']
|
||||
]);
|
||||
return $this->success($this->templateServices->getProductSpecsTemplateList($where, 2, (int)$this->supplierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function allSpecs(Request $request)
|
||||
{
|
||||
return $this->success($this->templateServices->getAllSpecs(2, (int)$this->supplierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数模版信息
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getInfo($id)
|
||||
{
|
||||
if (!$id) return $this->fail('缺少参数ID');
|
||||
$temp = $this->templateServices->get(['id' => $id, 'group' => 3], ['*'], ['specs']);
|
||||
if (!$temp) {
|
||||
return $this->fail('参数模版不存在');
|
||||
}
|
||||
return $this->success($temp->toArray());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加、编辑商品参数模版
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save(Request $request, $id)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['name', ''],
|
||||
['specs', []],
|
||||
['sort', ''],
|
||||
]);
|
||||
if (!$data['name']) {
|
||||
return $this->fail('请输入参数模版名称');
|
||||
}
|
||||
$specs = $data['specs'];
|
||||
unset($data['specs']);
|
||||
$type = 2;
|
||||
$supplier_id = (int)$this->supplierId;
|
||||
$temp = $this->templateServices->getOne(['name' => $data['name'], 'group' => 3, 'type' => $type, 'relation_id' => $supplier_id]);
|
||||
if ($id) {
|
||||
if ($temp && $id != $temp['id']) {
|
||||
return $this->fail('参数模版已经存在');
|
||||
}
|
||||
$this->templateServices->transaction(function () use ($id, $data, $specs, $type, $supplier_id) {
|
||||
if (!$this->templateServices->update($id, $data)) {
|
||||
return $this->success('编辑失败');
|
||||
}
|
||||
if (!$this->services->updateData($id, $specs)) {
|
||||
return $this->success('编辑失败');
|
||||
}
|
||||
});
|
||||
return $this->success('编辑成功');
|
||||
} else {
|
||||
if ($temp) {
|
||||
return $this->fail('参数模版已经存在');
|
||||
}
|
||||
$data['type'] = $type;
|
||||
$data['relation_id'] = $supplier_id;
|
||||
$data['group'] = 3;
|
||||
$data['add_time'] = time();
|
||||
$this->templateServices->transaction(function () use ($id, $data, $specs, $type, $supplier_id) {
|
||||
if (!$res = $this->templateServices->save($data)) {
|
||||
return $this->success('保存失败');
|
||||
}
|
||||
if (!$this->services->saveData((int)$res->id, $specs, $type, $supplier_id)) {
|
||||
return $this->success('保存失败');
|
||||
}
|
||||
});
|
||||
return $this->success('保存成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id || !($this->templateServices->count(['id' => $id]))) {
|
||||
return $this->fail('删除的数据不存在');
|
||||
}
|
||||
$this->templateServices->delete($id);
|
||||
$this->services->delete(['temp_id' => $id]);
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user