chore: 添加静态资源文件和版本配置文件

添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材
添加系统版本配置文件(.version)和常量定义文件(.constant)
更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件
添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
2026-03-06 20:14:23 +08:00
commit c9a98f342c
4485 changed files with 490986 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?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;
use crmeb\basic\BaseController;
use think\Response;
/**
* 基类 所有控制器继承的类
* Class AuthController
* @package app\controller\admin
* @method Response success($msg = 'ok', array $data = [])
* @method Response fail($msg = 'error', array $data = [])
*/
class AuthController extends BaseController
{
/**
* 当前登录供应商ID
* @var
*/
protected $supplierId;
/**
* 当前登录供应商信息
* @var
*/
protected $supplierInfo;
/**
* 当前管理员权限
* @var array
*/
protected $auth = [];
/**
* 初始化
*/
protected function initialize()
{
$this->supplierId = $this->request->hasMacro('supplierId') ? $this->request->supplierId() : 0;
$this->supplierInfo = $this->request->hasMacro('supplierInfo') ? $this->request->supplierInfo() : [];
$this->auth = $this->supplierInfo['rule'] ?? [];
}
}

View File

@@ -0,0 +1,269 @@
<?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;
use app\services\order\StoreOrderRefundServices;
use app\services\order\StoreOrderServices;
use app\services\other\CityAreaServices;
use app\services\order\supplier\SupplierOrderServices;
use app\services\supplier\SystemSupplierServices;
use app\services\system\SystemMenusServices;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
/**
* 公共接口基类 主要存放公共接口
* Class Common
* @package app\controller\admin
*/
class Common extends AuthController
{
/**
* 获取logo
* @param SystemSupplierServices $supplierServices
* @return Response
*/
public function getLogo(SystemSupplierServices $supplierServices): Response
{
$supplier = $supplierServices->get((int)$this->supplierId, ['id', 'name']);
return $this->success([
'logo' => sys_config('site_logo'),
'logo_square' => sys_config('site_logo_square'),
'site_name' => $supplier && isset($supplier['name']) && $supplier['name'] ? $supplier['name'] : sys_config('site_name')
]);
}
/**
* @return Response
*/
public function getConfig(): Response
{
return $this->success([
'tengxun_map_key' => sys_config('tengxun_map_key'),
'open_erp' => !!sys_config('erp_open')
]);
}
/**
* 省市区信息
* @param CityAreaServices $services
* @param int $pid
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function city(CityAreaServices $services, $pid = 0): Response
{
return $this->success($services->getCityTreeList((int)$pid));
}
/**
* 格式化菜单
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function menusList(): Response
{
/** @var SystemMenusServices $menusServices */
$menusServices = app()->make(SystemMenusServices::class);
$list = $menusServices->getSearchList(3);
$counts = $menusServices->getColumn([
['type', 3],
['is_show', '=', 1],
['auth_type', '=', 1],
['is_del', '=', 0],
['is_show_path', '=', 0],
], 'pid');
$data = [];
foreach ($list as $key => $item) {
$pid = $item->getData('pid');
$data[$key] = json_decode($item, true);
$data[$key]['pid'] = $pid;
if (in_array($item->id, $counts)) {
$data[$key]['type'] = 1;
} else {
$data[$key]['type'] = 0;
}
}
return $this->success(sort_list_tier($data));
}
/**
* 首页运营头部统计
* @param SupplierOrderServices $orderServices
* @return mixed
*/
public function homeStatics(SupplierOrderServices $orderServices)
{
[$time] = $this->request->getMore([
['data', '', '', 'time']
], true);
$time = $orderServices->timeHandle($time, true);
$data = $orderServices->homeStatics((int)$this->supplierId, $time);
return $this->success($data);
}
/**
* 营业趋势图表
* @param SupplierOrderServices $orderServices
* @return mixed
*/
public function orderChart(SupplierOrderServices $orderServices)
{
[$time] = $this->request->getMore([
['data', '', '', 'time']
], true);
$time = $orderServices->timeHandle($time, true);
$data = $orderServices->orderCharts((int)$this->supplierId, $time);
return $this->success($data);
}
/**
* 订单类型分析
* @param SupplierOrderServices $orderServices
* @return mixed
*/
public function orderType(SupplierOrderServices $orderServices)
{
[$time] = $this->request->getMore([
['data', '', '', 'time']
], true);
$time = $orderServices->timeHandle($time, true);
$data = $orderServices->getOrderType((int)$this->supplierId, $time);
return $this->success($data);
}
/**
* 订单来源分析
* @param SupplierOrderServices $orderServices
* @return mixed
*/
public function orderChannel(SupplierOrderServices $orderServices)
{
[$time] = $this->request->getMore([
['data', '', '', 'time']
], true);
$time = $orderServices->timeHandle($time, true);
$data = $orderServices->getOrderChannel((int)$this->supplierId, $time);
return $this->success($data);
}
/**
* 待办事统计
* @return mixed
*/
public function jnotice()
{
/** @var StoreOrderServices $orderServices */
$orderServices = app()->make(StoreOrderServices::class);
$orderNum = $orderServices->storeOrderCount((int)$this->supplierId, -1, 'supplier_id');
/** @var StoreOrderRefundServices $refundServices */
$refundServices = app()->make(StoreOrderRefundServices::class);
$orderRefundNum = $refundServices->count(['is_cancel' => 0, 'refund_type' => [0, 1, 2, 4, 5], 'supplier_id' => $this->supplierId]);
$value = [];
if ($orderNum > 0) {
$value[] = [
'title' => '您有' . $orderNum . '个待发货的订单',
'type' => 'bulb',
'url' => '/supplier/order/list?type=7&status=1'
];
}
if ($orderRefundNum) {
$value[] = [
'title' => '您有' . $orderRefundNum . '个售后订单待处理',
'type' => 'bulb',
'url' => '/supplier/order/refund'
];
}
return $this->success($this->noticeData($value));
}
/**
* 消息返回格式
* @param array $data
* @return array
*/
public function noticeData(array $data): array
{
// 消息图标
$iconColor = [
// 邮件 消息
'mail' => [
'icon' => 'md-mail',
'color' => '#3391e5'
],
// 普通 消息
'bulb' => [
'icon' => 'md-bulb',
'color' => '#87d068'
],
// 警告 消息
'information' => [
'icon' => 'md-information',
'color' => '#fe5c57'
],
// 关注 消息
'star' => [
'icon' => 'md-star',
'color' => '#ff9900'
],
// 申请 消息
'people' => [
'icon' => 'md-people',
'color' => '#f06292'
],
];
// 消息类型
$type = array_keys($iconColor);
// 默认数据格式
$default = [
'icon' => 'md-bulb',
'iconColor' => '#87d068',
'title' => '',
'url' => '',
'type' => 'bulb',
'read' => 0,
'time' => 0
];
$value = [];
foreach ($data as $item) {
$val = array_merge($default, $item);
if (isset($item['type']) && in_array($item['type'], $type)) {
$val['type'] = $item['type'];
$val['iconColor'] = $iconColor[$item['type']]['color'] ?? '';
$val['icon'] = $iconColor[$item['type']]['icon'] ?? '';
}
$value[] = $val;
}
return $value;
}
/**
* 获取版权
* @return mixed
*/
public function getCopyright()
{
try {
$copyright = $this->__z6uxyJQ4xYa5ee1mx5();
} catch (\Throwable $e) {
$copyright = ['copyrightContext' => '', 'copyrightImage' => ''];
}
$copyright['version'] = get_crmeb_version();
return $this->success($copyright);
}
}

View File

@@ -0,0 +1,184 @@
<?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;
use app\Request;
use crmeb\utils\Captcha;
use crmeb\services\CacheService;
use app\services\supplier\LoginServices;
use think\annotation\Inject;
use think\exception\ValidateException;
use app\validate\api\user\RegisterValidates;
use think\facade\Config;
use think\facade\Cache;
/**
* 登录
* Class AuthController
* @package app\api\controller
*/
class Login
{
/**
* @var LoginServices
*/
#[Inject]
protected LoginServices $services;
/**
* @param Request $request
* @return mixed
* @author 等风来
* @email 136327134@qq.com
* @date 2022/10/11
*/
public function getAjCaptcha(Request $request)
{
[$account,] = $request->postMore([
'account',
], true);
$key = 'supplier_login_captcha_' . $account;
return app('json')->success(['is_captcha' => Cache::get($key) > 2]);
}
/**
* @return mixed
*/
public function ajcaptcha(Request $request)
{
$captchaType = $request->get('captchaType');
return app('json')->success(aj_captcha_create($captchaType));
}
/**
* 一次验证
* @return mixed
*/
public function ajcheck(Request $request)
{
[$token, $pointJson, $captchaType] = $request->postMore([
['token', ''],
['pointJson', ''],
['captchaType', ''],
], true);
try {
aj_captcha_check_one($captchaType, $token, $pointJson);
return app('json')->success();
} catch (\Throwable $e) {
return app('json')->fail(400336);
}
}
/**
* 获取后台登录页轮播图以及LOGO
* @return mixed
*/
public function info()
{
return app('json')->success($this->services->getLoginInfo());
}
/**
* 验证码
* @return \app\controller\admin\Login|\think\Response
*/
public function captcha()
{
return app()->make(Captcha::class)->create();
}
/**
* H5账号登陆
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function login(Request $request)
{
[$account, $password, $captchaType, $captchaVerification] = $request->postMore([
'account',
'pwd',
['captchaType', ''],
['captchaVerification', '']
], true);
validate(\app\validate\supplier\SystemSupplierValidate::class)->scene('login')->check(['account' => $account, 'pwd' => $password]);
$key = 'supplier_login_captcha_' . $account;
if (Cache::has($key) && Cache::get($key) > 2) {
if (!$captchaType || !$captchaVerification) {
return app('json')->fail('请拖动滑块验证');
}
//二次验证
try {
aj_captcha_check_two($captchaType, $captchaVerification);
} catch (\Throwable $e) {
return app('json')->fail($e->getError());
}
}
$res = $this->services->login($account, $password, 'supplier');
if ($res) {
Cache::delete($key);
}
return app('json')->success($res);
}
/**
* 退出登录
* @param Request $request
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function logout(Request $request)
{
$key = trim(ltrim($request->header(Config::get('cookie.token_name')), 'Bearer'));
CacheService::redisHandler()->delete(md5($key));
return app('json')->success();
}
/**
* 密码修改
* @param Request $request
* @return mixed
*/
public function reset(Request $request)
{
[$account, $captcha, $password] = $request->postMore([['account', ''], ['captcha', ''], ['password', '']], true);
try {
validate(RegisterValidates::class)->scene('register')->check(['account' => $account, 'captcha' => $captcha, 'password' => $password]);
} catch (ValidateException $e) {
return app('json')->fail($e->getError());
}
$verifyCode = CacheService::get('code_' . $account);
if (!$verifyCode)
return app('json')->fail('请先获取验证码');
$verifyCode = substr($verifyCode, 0, 6);
if ($verifyCode != $captcha) {
return app('json')->fail('验证码错误');
}
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
return app('json')->fail('密码必须是在6到16位之间');
if ($password == '123456') return app('json')->fail('密码太过简单,请输入较为复杂的密码');
$resetStatus = $this->services->reset($account, $password);
if ($resetStatus) return app('json')->success('修改成功');
return app('json')->fail('修改失败');
}
}

View File

@@ -0,0 +1,227 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\supplier;
use app\common\controller\Order as CommonOrder;
use app\Request;
use app\services\order\StoreOrderDeliveryServices;
use app\services\order\StoreOrderServices;
use app\services\store\DeliveryServiceServices;
use app\services\order\supplier\SupplierOrderServices;
use crmeb\services\SystemConfigService;
use think\annotation\Inject;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
/**
* Class Order
* @package app\controller\supplier
* @property Request $request
*/
class Order extends AuthController
{
use CommonOrder;
/**
* @var StoreOrderServices
*/
#[Inject]
protected StoreOrderServices $services;
/**
* @var SupplierOrderServices
*/
#[Inject]
protected SupplierOrderServices $supplierOrderServices;
/**
* 配货单信息
* @return mixed
* @throws DataNotFoundException
* @throws ModelNotFoundException
* @throws \think\db\exception\DbException
*/
public function distributionInfo()
{
[$ids] = $this->request->postMore([
['ids', '']
], true);
if (!$ids) {
return app('json')->fail('缺少参数');
}
$id = stringToIntArray($ids);
$data = $this->supplierOrderServices->getDistribution($id);
if (!$data) {
return app('json')->fail('获取失败');
}
$res['list'] = $data;
$station = SystemConfigService::more(['site_name', 'refund_address', 'refund_phone']);
$res = array_merge($res, $station);
return $this->success($res);
}
/**
* 获取订单列表
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function lst(Request $request)
{
$where = $request->getMore([
['status', ''],
['real_name', ''],
['is_del', ''],
['data', '', '', 'time'],
['type', ''],
['pay_type', ''],
['order', ''],
['field_key', ''],
]);
$where['type'] = trim($where['type']);
$where['is_system_del'] = 0;
$where['supplier_id'] = $this->supplierId;
$where['type'] = trim($where['type'], ' ');
return $this->success($this->services->getOrderList($where, ['*'], ['split' => function ($query) {
$query->field('id,pid');
}, 'pink', 'invoice']));
}
/**
*获取所有配送员列表
*/
public function get_delivery_list()
{
/** @var DeliveryServiceServices $deliverServices */
$deliverServices = app()->make(DeliveryServiceServices::class);
$data = $deliverServices->getDeliveryList(2, (int)$this->supplierId);
return $this->success($data);
}
/**
* 订单发送货
* @param Request $request
* @param StoreOrderDeliveryServices $services
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function update_delivery(Request $request, StoreOrderDeliveryServices $services, $id)
{
$data = $request->postMore([
['type', 1],
['delivery_name', ''],//快递公司名称
['delivery_id', ''],//快递单号
['delivery_code', ''],//快递公司编码
['express_record_type', 2],//发货记录类型
['express_temp_id', ""],//电子面单模板
['to_name', ''],//寄件人姓名
['to_tel', ''],//寄件人电话
['to_addr', ''],//寄件人地址
['sh_delivery_name', ''],//送货人姓名
['sh_delivery_id', ''],//送货人电话
['sh_delivery_uid', ''],//送货人ID
['delivery_type', 1],//送货类型
['station_type', 1],//送货类型
['cargo_weight', 0],//重量
['mark', '', '', 'remark'],//管理员备注
['remark', '', '', 'delivery_remark'],//第三方配送备注
['fictitious_content', '']//虚拟发货内容
]);
if (!$id) {
return app('json')->fail('缺少发货ID');
}
$services->setItem('supplier_id', $this->supplierId);
$services->delivery((int)$id, $data);
$services->reset();
return app('json')->success('SUCCESS');
}
/**
* 订单拆单发送货
* @param Request $request
* @param StoreOrderDeliveryServices $services
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function split_delivery(Request $request, StoreOrderDeliveryServices $services, $id)
{
$data = $request->postMore([
['type', 1],
['delivery_name', ''],//快递公司名称
['delivery_id', ''],//快递单号
['delivery_code', ''],//快递公司编码
['express_record_type', 2],//发货记录类型
['express_temp_id', ""],//电子面单模板
['to_name', ''],//寄件人姓名
['to_tel', ''],//寄件人电话
['to_addr', ''],//寄件人地址
['sh_delivery_name', ''],//送货人姓名
['sh_delivery_id', ''],//送货人电话
['sh_delivery_uid', ''],//送货人ID
['delivery_type', 1],//送货类型
['station_type', 1],//送货类型
['cargo_weight', 0],//重量
['mark', ''],//备注
['remark', ''],//配送备注
['fictitious_content', ''],//虚拟发货内容
['cart_ids', []]
]);
if (!$id) {
return app('json')->fail('缺少发货ID');
}
if (!$data['cart_ids']) {
return app('json')->fail('请选择发货商品');
}
foreach ($data['cart_ids'] as $cart) {
if (!isset($cart['cart_id']) || !$cart['cart_id'] || !isset($cart['cart_num']) || !$cart['cart_num']) {
return app('json')->fail('请重新选择发货商品,或发货件数');
}
}
$services->setItem('supplier_id', $this->supplierId);
$services->splitDelivery((int)$id, $data);
$services->reset();
return app('json')->success('SUCCESS');
}
/**
* 获取订单拆分子订单列表
* @return mixed
*/
public function split_order(Request $request, $id)
{
if (!$id) {
return app('json')->fail('缺少订单ID');
}
$where = ['pid' => $id, 'is_system_del' => 0, 'supplier_id' => $this->supplierId];
if (!$this->services->count($where)) {
$where = ['id' => $id, 'is_system_del' => 0, 'supplier_id' => $this->supplierId];
}
return app('json')->success($this->services->getSplitOrderList($where, ['*'], ['split', 'pink', 'invoice', 'supplier']));
}
}

View File

@@ -0,0 +1,232 @@
<?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;
use app\Request;
use app\services\order\StoreOrderRefundServices;
use app\services\order\StoreOrderServices;
use app\services\user\UserServices;
use think\annotation\Inject;
/**
* Class Refund
* @package app\controller\supplier
*/
class Refund extends AuthController
{
/**
* @var StoreOrderRefundServices
*/
#[Inject]
protected StoreOrderRefundServices $services;
/**
* 退款订单列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getRefundList()
{
$where = $this->request->getMore([
['order_id', ''],
['time', ''],
['apply_type', ''],
['refund_type', ''],
['refund_reason','']
]);
$where['supplier_id'] = $this->supplierId;
return $this->success($this->services->refundList($where));
}
/**
* 订单详情
* @param UserServices $userServices
* @param $id
* @return mixed
*/
public function detail(UserServices $userServices, $id)
{
$order = $this->services->refundDetail($id);
$data['orderInfo'] = $order;
$userInfo = ['spread_uid' => '', 'spread_name' => '无'];
if ($order['uid']) {
$userInfo = $userServices->get((int)$order['uid']);
if (!$userInfo) return app('json')->fail('用户信息不存在');
$userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
$userInfo = $userInfo->toArray();
$userInfo['spread_name'] = '无';
if ($order['spread_uid']) {
$spreadName = $userServices->value(['uid' => $order['spread_uid']], 'nickname');
if ($spreadName) {
$userInfo['spread_name'] = $order['uid'] == $order['spread_uid'] ? $spreadName . '(自购)' : $spreadName;
$userInfo['spread_uid'] = $order['spread_uid'];
} else {
$userInfo['spread_uid'] = '';
}
} else {
$userInfo['spread_uid'] = '';
}
}
$data['userInfo'] = $userInfo;
return app('json')->successful('ok', $data);
}
/**
* 退款表单生成
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function refund($id)
{
if (!$id) {
return app('json')->fail('Data does not exist!');
}
return app('json')->success($this->services->refundOrderForm((int)$id));
}
/**
* 订单退款
* @param Request $request
* @param StoreOrderServices $services
* @param $id
* @return mixed
*/
public function update_refund(Request $request, StoreOrderServices $services, $id)
{
$data = $request->postMore([
['refund_price', 0],
['type', 1]
]);
if (!$id) {
return app('json')->fail('Data does not exist!');
}
$data['refund_price'] = sprintf("%.2f", $data['refund_price']);
$orderRefund = $this->services->get($id);
if (!$orderRefund) {
return app('json')->fail('Data does not exist!');
}
if ($orderRefund['is_cancel'] == 1) {
return app('json')->fail('用户已取消申请');
}
$order = $services->get((int)$orderRefund['store_order_id']);
if (!$order) {
return app('json')->fail('Data does not exist!');
}
if (!in_array($orderRefund['refund_type'], [0, 1, 2, 5]) && !($orderRefund['refund_type'] == 4 && $orderRefund['apply_type'] == 3)) {
return app('json')->fail('售后订单状态不支持该操作');
}
if ($data['type'] == 1) {
$data['refund_type'] = 6;
} else if ($data['type'] == 2) {
$data['refund_type'] = 3;
}
$data['refunded_time'] = time();
$type = $data['type'];
//拒绝退款
if ($type == 2) {
$this->services->refuseRefund((int)$orderRefund['id'], $data, $orderRefund);
return app('json')->successful('修改退款状态成功!');
} else {
//0元退款
if ($orderRefund['refund_price'] == 0) {
$refund_price = 0;
} else {
if (!$data['refund_price']) {
return app('json')->fail('请输入退款金额');
}
if ($orderRefund['refund_price'] == $orderRefund['refunded_price']) {
return app('json')->fail('已退完支付金额!不能再退款了');
}
$refund_price = $data['refund_price'];
$data['refunded_price'] = bcadd($data['refund_price'], $orderRefund['refunded_price'], 2);
$bj = bccomp((string)$orderRefund['refund_price'], (string)$data['refunded_price'], 2);
if ($bj < 0) {
return app('json')->fail('退款金额大于支付金额,请修改退款金额');
}
}
unset($data['type']);
$refund_data['pay_price'] = $order['pay_price'];
$refund_data['refund_price'] = $refund_price;
//修改订单退款状态
unset($data['refund_price']);
if ($this->services->agreeRefund($id, $refund_data)) {
//退款处理
$this->services->update($id, $data);
return app('json')->success('退款成功');
}
// else {
// $this->services->storeProductOrderRefundYFasle((int)$id, $refund_price);
// return app('json')->fail('退款失败');
// }
}
}
/**
* 商家同意退货退款
* @return mixed
*/
public function agreeRefund()
{
[$id] = $this->request->getMore([
['order_id', '']
], true);
$this->services->agreeRefundProdcut((int)$id);
return app('json')->success('操作成功');
}
/**
* 修改备注
* @param $id
* @return mixed
*/
public function remark($id)
{
$data = $this->request->postMore([['remark', '']]);
if (!$data['remark'])
return app('json')->fail('请输入要备注的内容');
if (!$id)
return app('json')->fail('缺少参数');
if (!$order = $this->services->get($id)) {
return app('json')->fail('修改的订单不存在!');
}
$order->remark = $data['remark'];
if ($order->save()) {
return app('json')->success('备注成功');
} else
return app('json')->fail('备注失败');
}
/**
* 售后原因
* @return \think\Response
* User: liusl
* DateTime: 2024/9/7 14:21
*/
public function refund_reason()
{
$reason = sys_config('stor_reason') ?: [];//退款理由
$reason = str_replace("\r\n", "\n", $reason);//防止不兼容
$reason = explode("\n", $reason);
return app('json')->successful($reason);
}
}

View 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\export;
use app\controller\supplier\AuthController;
use app\services\other\export\ExportServices;
use app\services\order\StoreOrderServices;
use app\services\other\ExpressServices;
use app\services\other\queue\QueueAuxiliaryServices;
use app\services\other\queue\QueueServices;
use app\services\supplier\finance\SupplierFlowingWaterServices;
use think\annotation\Inject;
/**
* 导出excel类
* Class ExportExcel
* @package app\controller\supplier\export
*/
class ExportExcel extends AuthController
{
/**
* @var ExportServices
*/
#[Inject]
protected ExportServices $service;
/**
* 订单列表导出
* @param StoreOrderServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function storeOrder(StoreOrderServices $services)
{
$where_tmp = $this->request->getMore([
['status', ''],
['real_name', ''],
['data', '', '', 'time'],
['type', ''],
['ids', '']
]);
$type = $where_tmp['type'];
$with = [];
if ($where_tmp['ids']) {
$where['id'] = stringToIntArray($where_tmp['ids']);
}
if ($type) {
$where['status'] = 1;
$where['paid'] = 1;
$where['is_del'] = 0;
$where['shipping_type'] = 1;
$where['is_system_del'] = 0;
$with = ['pink', 'refund' => function ($query) {
$query->whereIn('refund_type', [0, 1, 2, 4, 5])->where('is_cancel', 0)->where('is_del', 0)->field('id,store_order_id');
}];
}
if (!$where_tmp['ids'] && !$type) {
unset($where_tmp['ids']);
unset($where_tmp['type']);
$where = $where_tmp;
}
$where['is_system_del'] = 0;
$where['pid'] = 0;
$where['store_id'] = 0;
$where['supplier_id'] = $this->supplierId;
$data = $services->getExportList($where, $with, $this->service->limit);
return $this->success($this->service->storeOrder($data, $type));
}
/**
* 导出批量任务发货的记录
* @param int $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function batchOrderDelivery($id, $queueType, $cacheType)
{
/** @var QueueAuxiliaryServices $auxiliaryService */
$auxiliaryService = app()->make(QueueAuxiliaryServices::class);
/** @var QueueServices $queueService */
$queueService = app()->make(QueueServices::class);
$queueInfo = $queueService->getQueueOne(['id' => $id]);
if (!$queueInfo) return $this->fail("数据不存在");
$queueValue = json_decode($queueInfo['queue_in_value'], true);
if (!$queueValue || !isset($queueValue['cacheType'])) return $this->fail("数据参数缺失");
$data = $auxiliaryService->getExportData(['binding_id' => $id, 'type' => $cacheType], $this->service->limit);
return $this->success($this->service->batchOrderDelivery($data, $queueType));
}
/**
* 物流公司表导出
* @return mixed
*/
public function expressList()
{
/** @var ExpressServices $expressService */
$expressService = app()->make(ExpressServices::class);
$data = $expressService->apiExpressList();
return $this->success($this->service->expressList($data));
}
public function waterRecord(SupplierFlowingWaterServices $services)
{
[$ids] = $this->request->getMore([
['ids', ''],
], true);
$where['id'] = stringToIntArray($ids);
$where['supplier_id'] = $this->supplierId;
$where['is_del'] = 0;
$data = $services->getList($where);
return $this->success($this->service->SupplierFinanceRecord($data['list'] ?? []));
}
}

View File

@@ -0,0 +1,231 @@
<?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\file;
use app\controller\supplier\AuthController;
use app\services\other\CacheServices;
use app\services\system\admin\SystemAdminServices;
use app\services\system\attachment\SystemAttachmentServices;
use think\annotation\Inject;
/**
* 图片管理类
* Class SystemAttachment
* @package app\controller\store\file
*/
class SystemAttachment extends AuthController
{
/**
* @var SystemAttachmentServices
*/
#[Inject]
protected SystemAttachmentServices $service;
/**
* 显示列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['pid', 0],
['file_type', 1]
]);
$where['type'] = 4;
$where['relation_id'] = $this->supplierId;
return app('json')->success($this->service->getImageList($where));
}
/**
* 删除指定资源
*
* @param string $ids
* @return \think\Response
*/
public function delete()
{
[$ids] = $this->request->postMore([
['ids', '']
], true);
$this->service->del($ids);
return app('json')->success('删除成功');
}
/**
* 图片上传
* @param int $upload_type
* @param int $type
* @return mixed
*/
public function upload($upload_type = 0, $type = 0)
{
[$pid, $file] = $this->request->postMore([
['pid', 0],
['file', 'file'],
], true);
$res = $this->service->storeUpload((int)$pid, $file, (int)$this->supplierId, 4, $upload_type);
return app('json')->success('上传成功', ['src' => $res]);
}
/**
* 移动图片
* @return mixed
*/
public function moveImageCate()
{
$data = $this->request->postMore([
['pid', 0],
['images', '']
]);
$this->service->move($data);
return app('json')->success('移动成功');
}
/**
* 修改文件名
* @param $id
* @return mixed
*/
public function update($id)
{
$realName = $this->request->post('real_name', '');
if (!$realName) {
return app('json')->fail('文件名称不能为空');
}
$this->service->update($id, ['real_name' => $realName]);
return app('json')->success('修改成功');
}
/**
* 获取上传类型
* @return mixed
*/
public function uploadType()
{
$data['upload_type'] = (string)sys_config('upload_type', 1);
return app('json')->success($data);
}
/**
* 视频分片上传
* @return mixed
*/
public function videoUpload()
{
$data = $this->request->postMore([
['chunkNumber', 0],//第几分片
['currentChunkSize', 0],//分片大小
['chunkSize', 0],//总大小
['totalChunks', 0],//分片总数
['file', 'file'],//文件
['md5', ''],//MD5
['filename', ''],//文件名称
['pid', 0],//分类ID
]);
$fileHandle = $this->request->file($data['file']);
if (!$fileHandle) return $this->fail('上传信息为空');
$res = $this->service->videoUpload($data, $fileHandle, 4, (int)$this->supplierId);
return app('json')->success($res);
}
/**
* 保存云端视频记录
* @return mixed
*/
public function saveVideoAttachment()
{
$data = $this->request->postMore([
['path', ''],//视频地址
['cover_image', ''],//封面地址
['pid', 0],//分类ID
['upload_type', 1],//上传类型
]);
$res = $this->service->saveOssVideoAttachment($data, 4, (int)$this->supplierId, (int)$data['upload_type']);
return app('json')->success($res);
}
/**获取扫码上传页面链接以及参数
* @return \think\Response
*/
public function scanUploadQrcode(CacheServices $services)
{
[$pid] = $this->request->getMore([
['pid', 0]
], true);
$uploadToken = md5(time());
$upload_file_size_max = config('upload.filesize');//文件上传大小kb
$services->setDbCache($this->supplierId . '_supplier_scan_upload', $uploadToken, 68400);
$url = sys_config('site_url') . '/app/upload?pid=' . $pid . '&cache=' . $this->supplierId . '_supplier_scan_upload&type=4&relation_id=' . $this->supplierId . '&upload_file_size_max=' . $upload_file_size_max . '&token=' . $uploadToken;
return app('json')->success(['url' => $url]);
}
/**删除二维码
* @return \think\Response
*/
public function removeUploadQrcode(CacheServices $services)
{
$services->delectDbCache($this->supplierId . '_supplier_scan_upload');
return app('json')->success();
}
/**获取扫码上传的图片数据
* @param $scan_token
* @return \think\Response
*/
public function scanUploadImage($scan_token)
{
return app('json')->success($this->service->scanUploadImage($scan_token));
}
/**网络图片上传
* @return \think\Response
*/
public function onlineUpload()
{
$data = $this->request->postMore([
['pid', 0],
['images', []]
]);
$this->service->onlineUpload($data, 4, (int)$this->supplierId);
return app('json')->success('上传完成');
}
/**获取上传信息
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getAdminsData()
{
/** @var SystemAdminServices $adminServices */
$adminServices = app()->make(SystemAdminServices::class);
$data['is_way'] = $adminServices->value(['id' => $this->supplierId], 'is_way');
$data['upload_file_size_max'] = config('upload.filesize');//文件上传大小kb
return app('json')->success($data);
}
/**保存上传信息
* @param int $is_way
* @return \think\Response
*/
public function setAdminsData(int $is_way = 0)
{
/** @var SystemAdminServices $adminServices */
$adminServices = app()->make(SystemAdminServices::class);
if (!in_array($is_way, [0, 1, 2])) return app('json')->fail('参数有误!');
$res = $adminServices->update($this->supplierId, ['is_way' => $is_way]);
if ($res) return app('json')->success('ok');
else return app('json')->fail('保存失败');
}
}

View 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\file;
use app\controller\supplier\AuthController;
use app\services\system\attachment\SystemAttachmentCategoryServices;
use think\annotation\Inject;
/**
* 图片分类管理类
* Class SystemAttachmentCategory
* @package app\controller\supplier\file
*/
class SystemAttachmentCategory extends AuthController
{
/**
* @var SystemAttachmentCategoryServices
*/
#[Inject]
protected SystemAttachmentCategoryServices $service;
/**
* 显示资源列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['name', ''],
['pid', 0],
['file_type', 1]
]);
$where['type'] = 4;
$where['relation_id'] = $this->supplierId;
if ($where['name'] != '') $where['pid'] = '';
return app('json')->success($this->service->getAll($where));
}
/**
* 新增表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create($id)
{
[$file_type] = $this->request->postMore([
['file_type', 1]
], true);
return app('json')->success($this->service->createForm($id, 4, $this->supplierId, (int)$file_type));
}
/**
* 保存新增
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['pid', 0],
['name', ''],
['file_type', 1]
]);
if (!$data['name']) {
return app('json')->fail('请输入分类名称');
}
$data['type'] = 4;
$data['relation_id'] = $this->supplierId;
$this->service->save($data);
return app('json')->success('添加成功');
}
/**
* 编辑表单
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function edit($id)
{
[$file_type] = $this->request->postMore([
['file_type', 1]
], true);
return app('json')->success($this->service->editForm($id, 4, $this->supplierId, (int)$file_type));
}
/**
* 保存更新的资源
*
* @param \think\Request $request
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$data = $this->request->postMore([
['pid', 0],
['name', ''],
['file_type', 1]
]);
if (!$data['name']) {
return app('json')->fail('请输入分类名称');
}
$info = $this->service->get($id);
$data['relation_id'] = $this->supplierId;
$count = $this->service->count(['pid' => $id]);
if ($count && $info['pid'] != $data['pid']) return app('json')->fail('该分类有下级分类,无法修改上级');
$this->service->update($id, $data);
return app('json')->success('分类编辑成功!');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
$this->service->del($id);
return app('json')->success('删除成功!');
}
}

View 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\finance;
use app\services\supplier\finance\SupplierFlowingWaterServices;
use think\annotation\Inject;
use think\exception\ValidateException;
use think\facade\App;
use think\facade\Config;
use app\controller\supplier\AuthController;
use app\services\supplier\finance\SupplierExtractServices;
/**
* 供应商提现
* Class SupplierExtract
* @package app\controller\supplier\finance
*/
class SupplierExtract extends AuthController
{
/**
* @var SupplierExtractServices
*/
#[Inject]
protected SupplierExtractServices $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([
['status', ''],
['pay_status', ''],
['extract_type', ''],
['nireid', '', '', 'like'],
['data', '', '', 'time'],
]);
if (isset($where['extract_type']) && $where['extract_type'] == 'wx') {
$where['extract_type'] = 'weixin';
}
$where['supplier_id'] = $this->supplierId;
$whereData = [
'supplier_id' => $this->supplierId,
'is_del' => 0,
];
return app('json')->success($this->services->index($where,$whereData));
}
/**
* 增加备注
* @param $id
* @return mixed
*/
public function mark($id)
{
[$mark] = $this->request->getMore([
['mark', '']
], true);
if (!$id || !$mark) {
return app('json')->fail('缺少参数');
}
$extract = $this->services->get((int)$id);
if (!$extract) {
return app('json')->fail('转账记录不存在');
}
if (!$this->services->update($id, ['supplier_mark' => $mark])) {
return app('json')->fail('备注失败');
}
return app('json')->success('备注成功');
}
/**
* 提现申请
* @param Request $request
* @return mixed
*/
public function cash()
{
$extractInfo = $this->request->postMore([
['extract_type', ''],
['money', 0],
['mark', '']
]);
$extractType = Config::get('pay.extractType', []);
//最低提现
$supplier_extract_min_price = sys_config('supplier_extract_min_price') ?? 0;
//最高提现
$supplier_extract_max_price = sys_config('supplier_extract_max_price') ?? 0;
if ($extractInfo['money'] < $supplier_extract_min_price)
return app('json')->fail('最低提现' . $supplier_extract_min_price . '元');
if ($extractInfo['money'] > $supplier_extract_max_price)
return app('json')->fail('最高提现' . $supplier_extract_max_price . '元');
//可提现金额
/** @var SupplierFlowingWaterServices $financeFlowServices */
$financeFlowServices = app()->make(SupplierFlowingWaterServices::class);
$whereData = [
'supplier_id' => $this->supplierId,
'is_del' => 0,
];
$price_not = $financeFlowServices->getSumFinance(['supplier_id' => $this->supplierId], $whereData);
if ($extractInfo['money'] > $price_not) {
throw new ValidateException($price_not > 0 ? '可提现金额为' . $price_not . '元': '暂无可提现金额');
}
if (!in_array($extractInfo['extract_type'], $extractType))
return app('json')->fail('转账方式不存在');
if (!preg_match('/^[0-9]+(.[0-9]{1,2})?$/', (float)$extractInfo['money'])) return app('json')->fail('转账金额输入有误');
if ($this->services->cash((int)$this->supplierId, $extractInfo))
return app('json')->successful('申请转账成功!');
else
return app('json')->fail('转账失败');
}
}

View File

@@ -0,0 +1,120 @@
<?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\finance;
use app\services\supplier\finance\SupplierFlowingWaterServices;
use think\annotation\Inject;
use think\facade\App;
use app\controller\supplier\AuthController;
/**
* 供应商流水
* Class SupplierFlowingWater
* @package app\controller\supplier\finance
*/
class SupplierFlowingWater extends AuthController
{
/**
* @var SupplierFlowingWaterServices
*/
#[Inject]
protected SupplierFlowingWaterServices $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([
['type', ''],
['data', '', '', 'time'],
]);
$where['keyword'] = $this->request->param('keyword', '');
$where['supplier_id'] = $this->supplierId;
$where['is_del'] = 0;
return app('json')->success($this->services->getList($where));
}
/**
* 增加备注
* @param $id
* @return mixed
*/
public function mark($id)
{
[$mark] = $this->request->postMore([
['mark', '']
], true);
if (!$id || !$mark) {
return app('json')->fail('缺少参数');
}
$info = $this->services->get((int)$id);
if (!$info) {
return app('json')->fail('流水不存在');
}
if (!$this->services->update($id, ['mark' => $mark])) {
return app('json')->fail('备注失败');
}
return app('json')->success('备注成功');
}
/**获取交易类型
* @return \think\Response
*/
public function getType()
{
return app('json')->success($this->services->type);
}
/**
* 账单记录
* @return mixed
*/
public function fundRecord()
{
$where = $this->request->getMore([
['timeType', 'day'],
['data', '', '', 'time'],
['status', '']
]);
$where['supplier_id'] = $this->supplierId;
return app('json')->success($this->services->getFundRecord($where));
}
/**
* 账单详情
* @param $ids
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function fundRecordInfo()
{
$where = $this->request->getMore([
['ids', '']
]);
$where['keyword'] = $this->request->param('keyword', '');
$where['id'] = stringToIntArray($where['ids']);
unset($where['ids']);
$where['is_del'] = 0;
$where['supplier_id'] = $this->supplierId;
return app('json')->success($this->services->getList($where));
}
}

View File

@@ -0,0 +1,34 @@
<?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\finance;
use app\services\supplier\finance\SupplierTransactionsServices;
use think\annotation\Inject;
use think\facade\App;
use app\controller\supplier\AuthController;
/**
* 供应商交易
* Class SupplierTransactions
* @package app\controller\supplier\finance
*/
class SupplierTransactions extends AuthController
{
/**
* @var SupplierTransactionsServices
*/
#[Inject]
protected SupplierTransactionsServices $services;
}

View 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('删除成功!');
}
}

View 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('删除成功');
}
}

View 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('删除成功!');
}
}

View 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('回复成功!');
}
}

View 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('删除成功!');
}
}

View 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('删除成功');
}
}

View 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('删除成功!');
}
}

View 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());
}
}

View 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('删除成功!');
}
}

View 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());
}
}

View 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('删除成功');
}
}

View File

@@ -0,0 +1,114 @@
<?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\queue;
use app\controller\supplier\AuthController;
use app\services\other\queue\QueueAuxiliaryServices;
use app\services\other\queue\QueueServices;
use think\annotation\Inject;
/**
* Class Queue
* @package app\controller\supplier
*/
class Queue extends AuthController
{
/**
* @var QueueServices
*/
#[Inject]
protected QueueServices $services;
/**
* 队列任务列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['data', '', '', 'time'],
['type', [6, 7, 8, 9, 10]],
['status', [0, 1, 2, 3]],
['page', 1],
['limit', 20],
]);
$data = $this->services->getList($where);
return $this->success($data);
}
/**
* 批量发货记录
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function delivery_log($id, $type)
{
/** @var QueueAuxiliaryServices $auxiliaryService */
$auxiliaryService = app()->make(QueueAuxiliaryServices::class);
$data = $auxiliaryService->deliveryLogList(['binding_id' => $id, 'type' => $type]);
return $this->success($data);
}
/**
* 再次执行批量任务
* @param $id
* @param $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function again_do_queue($id, $type)
{
if (!$id || !$type) return $this->fail("参数缺失");
$this->services->againDoQueue($id, $type);
return $this->success("后台程序已再次执行此批量任务");
}
/**
* 清除异常任务
* @param $id
* @param $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function del_wrong_queue($id, $type)
{
if (!$id || !$type) return $this->fail("参数缺失");
$res = $this->services->delWrongQueue($id, $type);
return $this->success($res ? "异常任务清除成功" : "数据无异常");
}
/**
* 任务停止
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function stop_wrong_queue($id)
{
if (!$id) return $this->fail("参数缺失");
$queueInfo = $this->services->getQueueOne(['id' => $id]);
if (!$queueInfo) $this->fail('任务不存在');
$this->services->delWrongQueue($id, $queueInfo['type'], false);
return $this->success("任务停止成功");
}
}

View File

@@ -0,0 +1,96 @@
<?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\system;
use app\controller\supplier\AuthController;
use app\services\store\StoreConfigServices;
use app\services\system\config\SystemConfigServices;
use app\services\system\config\SystemConfigTabServices;
use think\facade\App;
use app\Request;
/**
* Class Config
* @package app\controller\supplier\system
*/
class Config extends AuthController
{
/**
* Config constructor.
* @param App $app
* @param SystemConfigServices $services
*/
public function __construct(App $app, SystemConfigServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取门店配置
* @param $type
* @param StoreConfigServices $services
* @return mixed
*/
public function getConfig($type, StoreConfigServices $services)
{
if (!isset(StoreConfigServices::CONFIG_TYPE[$type])) {
return $this->fail('类型不正确');
}
return $this->success($services->getConfigAll(StoreConfigServices::CONFIG_TYPE[$type], 2, (int)$this->supplierId));
}
/**
* 保存数据
* @param StoreConfigServices $services
* @return mixed
*/
public function save(StoreConfigServices $services)
{
$data = $this->request->post();
$services->saveConfig($data,2, (int)$this->supplierId);
\crmeb\services\SystemConfigService::clear();
return $this->success('修改成功');
}
/**
* 基础配置
* @param Request $request
* @param StoreConfigServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit_basics(Request $request, StoreConfigServices $services)
{
$name = $this->request->param('name', '');
if (!$name) {
return $this->fail('参数错误');
}
$supplier_id = (int)$this->supplierId;
return $this->success($services->getFormBuildRule($name, 2, $supplier_id));
}
/**
* @param string $type
* @return mixed
*/
public function getFormBuild(StoreConfigServices $services, string $type)
{
$supplier_id = (int)$this->supplierId;
return $this->success($services->getFormBuildRule($type, 2, $supplier_id));
}
}

View File

@@ -0,0 +1,133 @@
<?php
namespace app\controller\supplier\system;
use app\controller\supplier\AuthController;
use app\services\system\PrintDocumentServices;
use think\annotation\Inject;
class PrintDocument extends AuthController
{
/**
* @var PrintDocumentServices
*/
#[Inject]
protected PrintDocumentServices $services;
/**
* 打印机列表
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printList()
{
$where = $this->request->getMore([
['type', 0],
['keyword', ''],
]);
$where['supplier_id'] = $this->supplierId;
return $this->success($this->services->printList($where));
}
/**
* 打印机添加表单
* @param $id
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printForm($id)
{
return $this->success($this->services->printForm($id));
}
/**
* 保存打印机
* @param $id
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printSave($id)
{
$data = $this->request->postMore([
['print_name', ''],
['type', 0],
['yly_user_id', ''],
['yly_app_id', ''],
['yly_app_secret', ''],
['yly_sn', ''],
['fey_user', ''],
['fey_ukey', ''],
['fey_sn', ''],
['times', 1],
['print_type', 1],
['status', 1],
]);
$data['supplier_id'] = $this->supplierId;
$this->services->printSave($id, $data);
return $this->success('保存成功');
}
/**
* 打印机状态修改
* @param $id
* @param $status
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printSetStatus($id, $status)
{
$this->services->printSetStatus($id, $status);
return $this->success('修改成功');
}
/**
* 删除打印机
* @param $id
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printDel($id)
{
$this->services->printDel($id);
return $this->success('删除成功');
}
public function getPrintContent($id)
{
return $this->success($this->services->getPrintContent($id));
}
public function savePrintContent($id)
{
$data = $this->request->postMore([
['header', 0],
['delivery', 0],
['buyer_remarks', 0],
['goods', []],
['freight', 0],
['preferential', []],
['pay', []],
['custom', 0],
['order', []],
['code', 0],
['code_url', ''],
['show_notice', 0],
['notice_content', '']
]);
$this->services->savePrintContent($id, $data);
return $this->success('保存成功');
}
}

View File

@@ -0,0 +1,151 @@
<?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\system;
use app\controller\supplier\AuthController;
use app\services\supplier\SystemSupplierServices;
use app\services\system\admin\SystemAdminServices;
use crmeb\exceptions\AdminException;
use think\annotation\Inject;
/**
* 供应商控制器
* Class Supplier
* @package app\controller\supplier
*/
class Supplier extends AuthController
{
/**
* @var SystemSupplierServices
*/
#[Inject]
protected SystemSupplierServices $services;
/**
* 获取供应商信息
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function read()
{
$info = $this->services->getSupplierInfo((int)$this->supplierId, 'id, supplier_name, name, phone, admin_id, email, address, province, city, area, street, detailed_address, sort, is_show, mark', ['admin']);
$info->hidden(['roles', 'admin_is_del', 'admin_type', 'level','admin_id']);
$info = $info->toArray();
$info['pwd'] = '';
return $this->success($info);
}
/**
* 更新供应商信息
* @return \think\Response
*/
public function update()
{
$data = $this->request->postMore([
['supplier_name', ''],
['name', ''],
['phone', ''],
['email', ''],
['address', ''],
['province', 0],
['city', 0],
['area', 0],
['street', 0],
['detailed_address', ''],
['account', ''],
['conf_pwd', ''],
['pwd', ''],
]);
$this->validate($data, \app\validate\supplier\SystemSupplierValidate::class, 'update');
$data['address'] = str_replace([' ', '/', '\\'], '', $data['address']);
$data['detailed_address'] = str_replace([' ', '/', '\\'], '', $data['detailed_address']);
/** @var SystemAdminServices $adminServices */
$adminServices = app()->make(SystemAdminServices::class);
if (!$adminInfo = $adminServices->get($this->supplierInfo['admin_id'])) {
return $this->fail('管理员不存在,无法修改');
}
if ($adminInfo->is_del) {
return $this->fail('管理员已经删除');
}
//修改账号
if (isset($data['account']) && $data['account'] !=$adminInfo->account && $adminServices->isAccountUsable($data['account'], $this->supplierInfo['admin_id'], 4)) {
return $this->fail('管理员账号已存在');
}
if ($data['pwd']) {
if (!$data['conf_pwd']) {
return $this->fail('请输入确认密码');
}
if ($data['conf_pwd'] != $data['pwd']) {
return $this->fail('上次输入的密码不相同');
}
$adminInfo->pwd = $adminServices->passwordHash($data['pwd']);
}
$adminInfo->real_name = $data['name'] ?? $adminInfo->real_name;
$adminInfo->phone = $data['phone'] ?? $adminInfo->phone;
$adminInfo->account = $data['account'] ?? $adminInfo->account;
unset($data['account']);
unset($data['pwd']);
unset($data['conf_pwd']);
// 修改管理员
$res = $adminInfo->save();
if (!$res) return $this->fail('管理员修改失败');
$this->services->update((int)$this->supplierId, $data);
return $this->success('保存成功');
}
/**
* 获取供应商财务信息
* @return mixed
*/
public function getFinanceInfo()
{
$Info = $this->services->get((int)$this->supplierId);
if (!$Info) {
return app('json')->fail('供应商不存在');
}
return app('json')->success($Info->toArray());
}
/**
* 设置供应商财务信息
* @return mixed
*/
public function setFinanceInfo()
{
$data = $this->request->postMore([
['bank_code', ''],
['bank_address', ''],
['alipay_account', ''],
['alipay_qrcode_url', ''],
['wechat', ''],
['wechat_qrcode_url', '']
]);
$Info = $this->services->get((int)$this->supplierId);
if (!$Info) {
return app('json')->fail('供应商不存在');
}
if ($this->services->update($Info['id'], $data)) {
return app('json')->success('设置成功');
} else {
return app('json')->fail('设置失败');
}
}
}

View File

@@ -0,0 +1,174 @@
<?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\system;
use app\controller\supplier\AuthController;
use app\services\supplier\SystemSupplierServices;
use app\services\system\admin\SystemAdminServices;
use think\annotation\Inject;
/**
* Class SystemAdmin
* @package app\controller\admin\v1\setting
*/
class SupplierAdmin extends AuthController
{
/**
* @var SystemSupplierServices
*/
#[Inject]
protected SystemSupplierServices $services;
/**
* @var SystemAdminServices
*/
#[Inject]
protected SystemAdminServices $adminServices;
/**
* 显示管理员资源列表
*
* @return \think\Response
*/
public function index()
{
$where = [
'is_del' => 1,
'admin_type' => 4,
'relation_id' => $this->supplierId,
'level' => 1
];
return $this->success($this->adminServices->getAdminList($where));
}
/**
* 创建表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return $this->success($this->adminServices->createForm(0, '/admin'));
}
/**
* 保存管理员
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['account', ''],
['phone', ''],
['conf_pwd', ''],
['pwd', ''],
['real_name', ''],
['phone', ''],
['roles', []],
['status', 0],
['head_pic', ''],
]);
$this->validate($data, \app\validate\admin\setting\SystemAdminValidate::class, 'supplier_save');
$data['admin_type'] = 4;
$data['relation_id'] = $this->supplierId;
if ($this->adminServices->create($data)) {
return $this->success('添加成功');
} else {
return $this->fail('添加失败');
}
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit(int $id)
{
if (!$id) {
return $this->fail('管理员信息读取失败');
}
return $this->success($this->adminServices->updateForm(0, (int)$id, '/admin/'));
}
/**
* 更新管理员
* @param int $id
* @return mixed
*/
public function update(int $id)
{
$data = $this->request->postMore([
['account', ''],
['phone', ''],
['conf_pwd', ''],
['pwd', ''],
['real_name', ''],
['phone', ''],
['roles', []],
['status', 0],
['head_pic', ''],
]);
$this->validate($data, \app\validate\admin\setting\SystemAdminValidate::class, 'supplier_update');
if ($this->adminServices->save($id, $data)) {
return $this->success('修改成功');
} else {
return $this->fail('修改失败');
}
}
/**
* 管理员详情
* @param int $id
* @return mixed
*/
public function read(int $id)
{
$info = $this->adminServices->get($id);
if (!$info) {
return $this->fail('获取失败');
}
return $this->success($info->toArray());
}
/**
* 删除管理员
* @param int $id
* @return void
*/
public function delete(int $id)
{
if (!$id) {
return $this->fail('删除失败,缺少参数');
}
if ($this->adminServices->update($id, ['is_del' => 1, 'status' => 0])) {
return $this->success('删除成功!');
} else {
return $this->fail('删除失败');
}
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
$this->adminServices->update((int)$id, ['status' => $status]);
return $this->success($status == 0 ? '关闭成功' : '开启成功');
}
}

View File

@@ -0,0 +1,67 @@
<?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\system;
use app\controller\supplier\AuthController;
use app\services\supplier\SupplierTicketPrintServices;
use think\annotation\Inject;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* Class SupplierTicketPrint
* @package app\controller\supplier
*/
class SupplierTicketPrint extends AuthController
{
/**
* @var SupplierTicketPrintServices
*/
#[Inject]
protected SupplierTicketPrintServices $services;
/**
* 获取打印信息
* @return \think\Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function read()
{
return $this->success($this->services->getTicketInfo((int)$this->supplierId));
}
/**
* 更新打印信息
* @return void
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function update()
{
$data = $this->request->postMore([
['develop_id', 0],
['api_key', ''],
['client_id', ''],
['terminal_number', ''],
['status', 0],
]);
$this->validate($data, \app\validate\supplier\SupplierTicketPrintValidate::class, 'update');
$this->services->savePrintData((int)$this->supplierId, $data);
return $this->success('保存成功');
}
}

View File

@@ -0,0 +1,76 @@
<?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\system\form;
use app\controller\supplier\AuthController;
use app\services\system\form\SystemFormServices;
use think\facade\App;
/**
*
* Class SystemForm
* @package app\controller\supplier\system\form
*/
class SystemForm extends AuthController
{
/**
* Diy constructor.
* @param App $app
* @param SystemFormServices $services
*/
public function __construct(App $app, SystemFormServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/*
* 所有系统表单
*/
public function allSystemForm()
{
$data = $this->services->getFormList([], ['id', 'name']);
return $this->success($data['list'] ?? []);
}
/**
* 获取一条数据
* @param int $id
* @return mixed
*/
public function getInfo(int $id)
{
if (!$id) return $this->fail('数据不存在');
[$type] = $this->request->postMore([
['type', 0],
], true);
$info = $this->services->get($id);
if ($info) {
$info = $info->toArray();
} else {
return $this->fail('数据不存在');
}
$info['value'] = json_decode($info['value'], true);
if ($type == 1) {//处理表单数据
$value = $info['value'] ?? [];
$info = $this->services->handleForm($value);
}
return $this->success(compact('info'));
}
}

View File

@@ -0,0 +1,89 @@
<?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\user;
use app\services\user\UserSpreadServices;
use think\annotation\Inject;
use app\services\user\UserServices;
use app\controller\supplier\AuthController;
use app\services\product\product\StoreProductLogServices;
class User extends AuthController
{
/**
* @var UserServices
*/
#[Inject]
protected UserServices $services;
/**
* 显示用户信息
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
if (is_string($id)) {
$id = (int)$id;
}
return $this->success($this->services->read($id));
}
/**
* 获取单个用户信息
* @param $id 用户id
* @return mixed
*/
public function oneUserInfo($id)
{
$data = $this->request->getMore([
['type', ''],
]);
$id = (int)$id;
if ($data['type'] == '') return $this->fail('缺少参数');
return $this->success($this->services->oneUserInfo($id, $data['type']));
}
/**
* 商品浏览记录
* @param $id
* @param StoreProductLogServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function visitList($id, StoreProductLogServices $services)
{
$where['uid'] = (int)$id;
$where['type'] = 'visit';
return app('json')->success($services->getList($where, 'product_id'));
}
/**
* 获取推广人记录
* @param $id
* @param UserSpreadServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function spreadList($id, UserSpreadServices $services)
{
$where['store_id'] = 0;
$where['staff_id'] = 0;
$where['uid'] = $id;
return app('json')->success($services->getSpreadList($where, '*', ['spreadUser', 'admin'], false));
}
}