new files
This commit is contained in:
105
pro_v3.5.1/app/controller/admin/v1/supplier/Common.php
Normal file
105
pro_v3.5.1/app/controller/admin/v1/supplier/Common.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?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\admin\v1\supplier;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\order\supplier\SupplierOrderServices;
|
||||
use app\services\supplier\SystemSupplierServices;
|
||||
|
||||
/**
|
||||
* 公共接口基类 主要存放公共接口
|
||||
* Class Common
|
||||
* @package app\controller\admin
|
||||
*/
|
||||
class Common extends AuthController
|
||||
{
|
||||
/**
|
||||
* 首页运营头部统计
|
||||
* @param SupplierOrderServices $orderServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function homeStatics(SupplierOrderServices $orderServices)
|
||||
{
|
||||
[$supplierId, $time] = $this->request->getMore([
|
||||
['supplier_id', 0],
|
||||
['data', '', '', 'time']
|
||||
], true);
|
||||
|
||||
$time = $orderServices->timeHandle($time, true);
|
||||
$data = $orderServices->homeStatics((int)$supplierId, $time);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 营业趋势图表
|
||||
* @param SupplierOrderServices $orderServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function orderChart(SupplierOrderServices $orderServices)
|
||||
{
|
||||
[$supplierId, $time] = $this->request->getMore([
|
||||
['supplier_id', 0],
|
||||
['data', '', '', 'time']
|
||||
], true);
|
||||
$time = $orderServices->timeHandle($time, true);
|
||||
$data = $orderServices->orderCharts((int)$supplierId, $time);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单类型分析
|
||||
* @param SupplierOrderServices $orderServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function orderType(SupplierOrderServices $orderServices)
|
||||
{
|
||||
[$supplierId, $time] = $this->request->getMore([
|
||||
['supplier_id', 0],
|
||||
['data', '', '', 'time']
|
||||
], true);
|
||||
$time = $orderServices->timeHandle($time, true);
|
||||
$data = $orderServices->getOrderType((int)$supplierId, $time);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单来源分析
|
||||
* @param SupplierOrderServices $orderServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function orderChannel(SupplierOrderServices $orderServices)
|
||||
{
|
||||
[$supplierId, $time] = $this->request->getMore([
|
||||
['supplier_id', 0],
|
||||
['data', '', '', 'time']
|
||||
], true);
|
||||
$time = $orderServices->timeHandle($time, true);
|
||||
$data = $orderServices->getOrderChannel((int)$supplierId, $time);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页供应商统计
|
||||
* @param SystemSupplierServices $supplierServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function supplierChart(SystemSupplierServices $supplierServices)
|
||||
{
|
||||
[$supplierId, $time] = $this->request->getMore([
|
||||
['supplier_id', 0],
|
||||
['data', '', '', 'time']
|
||||
], true);
|
||||
$time = $supplierServices->timeHandle($time);
|
||||
return $this->success($supplierServices->supplierChart((int)$supplierId, $time));
|
||||
}
|
||||
|
||||
}
|
||||
204
pro_v3.5.1/app/controller/admin/v1/supplier/RefundOrder.php
Normal file
204
pro_v3.5.1/app/controller/admin/v1/supplier/RefundOrder.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\admin\v1\supplier;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\Request;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\user\UserServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
class RefundOrder 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', ''],
|
||||
['refund_type', ''],
|
||||
['supplier_id', '']
|
||||
]);
|
||||
|
||||
$where['supplier'] = 1;
|
||||
return $this->success($this->services->refundList($where, ['user', 'supplier']));
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款表单生成
|
||||
* @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],
|
||||
['refuse_reason', '']
|
||||
]);
|
||||
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)$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;
|
||||
if ($order['refund_price'] > 0) {
|
||||
mt_srand();
|
||||
$refund_data['refund_id'] = $order['order_id'] . rand(100, 999);
|
||||
}
|
||||
//修改订单退款状态
|
||||
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()
|
||||
{
|
||||
[$order_id] = $this->request->getMore([
|
||||
['order_id', '']
|
||||
], true);
|
||||
$this->services->agreeRefundProdcut((int)$order_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('备注失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function refundDetail($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
$orderInfo = $this->services->refundDetail($id, ['*'], ['invoice', 'virtual', 'supplierInfo']);
|
||||
$userInfo = ['spread_uid' => '', 'spread_name' => '无'];
|
||||
if ($orderInfo['uid']) {
|
||||
/** @var UserServices $services */
|
||||
$services = app()->make(UserServices::class);
|
||||
$userInfo = $services->getUserWithTrashedInfo($orderInfo['uid']);
|
||||
if (!$userInfo) return app('json')->fail('用户信息不存在');
|
||||
$userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
|
||||
$userInfo = $userInfo->toArray();
|
||||
$userInfo['spread_name'] = '无';
|
||||
if ($orderInfo['spread_uid']) {
|
||||
$spreadName = $services->value(['uid' => $orderInfo['spread_uid']], 'nickname');
|
||||
if ($spreadName) {
|
||||
$userInfo['spread_name'] = $orderInfo['uid'] == $orderInfo['spread_uid'] ? $spreadName . '(自购)' : $spreadName;
|
||||
$userInfo['spread_uid'] = $orderInfo['spread_uid'];
|
||||
} else {
|
||||
$userInfo['spread_uid'] = '';
|
||||
}
|
||||
} else {
|
||||
$userInfo['spread_uid'] = '';
|
||||
}
|
||||
}
|
||||
return $this->success(compact('orderInfo', 'userInfo'));
|
||||
}
|
||||
}
|
||||
83
pro_v3.5.1/app/controller/admin/v1/supplier/StoreOrder.php
Normal file
83
pro_v3.5.1/app/controller/admin/v1/supplier/StoreOrder.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?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\admin\v1\supplier;
|
||||
|
||||
use think\annotation\Inject;
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\common\controller\Order as CommonOrder;
|
||||
use app\services\order\supplier\SupplierOrderServices;
|
||||
|
||||
/**
|
||||
* Class StoreOrder
|
||||
* @package app\controller\admin\v1\supplier
|
||||
*/
|
||||
class StoreOrder extends AuthController
|
||||
{
|
||||
use CommonOrder;
|
||||
|
||||
/**
|
||||
* @var StoreOrderServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreOrderServices $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', ''],
|
||||
['real_name', ''],
|
||||
['is_del', ''],
|
||||
['data', '', '', 'time'],
|
||||
['type', ''],
|
||||
['pay_type', ''],
|
||||
['order', ''],
|
||||
['field_key', ''],
|
||||
['supplier_id', '']
|
||||
]);
|
||||
|
||||
if ($where['supplier_id'] < 1) {
|
||||
$where['supplier_id'] = -1;
|
||||
}
|
||||
$where['type'] = trim($where['type']);
|
||||
$where['is_system_del'] = 0;
|
||||
|
||||
$where['store_id'] = 0;
|
||||
$where['type'] = trim($where['type'], ' ');
|
||||
return $this->success($this->services->getOrderList($where, ['*'], ['split' => function ($query) {
|
||||
$query->field('id,pid');
|
||||
}, 'pink', 'invoice', 'supplier']));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提醒发货
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function deliverRemind(int $supplierId, int $id)
|
||||
{
|
||||
if (!$supplierId || !$id) return $this->fail('参数异常');
|
||||
|
||||
/** @var SupplierOrderServices $supplierOrderServices */
|
||||
$supplierOrderServices = app()->make(SupplierOrderServices::class);
|
||||
$supplierOrderServices->deliverRemind($supplierId, $id);
|
||||
return $this->success('提醒成功');
|
||||
}
|
||||
|
||||
}
|
||||
152
pro_v3.5.1/app/controller/admin/v1/supplier/Supplier.php
Normal file
152
pro_v3.5.1/app/controller/admin/v1/supplier/Supplier.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?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\admin\v1\supplier;
|
||||
|
||||
use app\controller\admin\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('设置失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
140
pro_v3.5.1/app/controller/admin/v1/supplier/SupplierApply.php
Normal file
140
pro_v3.5.1/app/controller/admin/v1/supplier/SupplierApply.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?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\admin\v1\supplier;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\supplier\LoginServices;
|
||||
use app\services\supplier\SystemSupplierServices;
|
||||
use app\services\system\SystemUserApplyServices;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 供应商申请
|
||||
* Class SupplierApply
|
||||
* @package app\controller\admin\v1\supplier
|
||||
*/
|
||||
class SupplierApply extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* 供应商申请类型
|
||||
* @var int
|
||||
*/
|
||||
protected int $type = 2;
|
||||
|
||||
/**
|
||||
* @var SystemUserApplyServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemUserApplyServices $services;
|
||||
|
||||
/**
|
||||
* 获取供应商列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['data', '', '', 'time'],
|
||||
['status', ],
|
||||
[['keyword', 's'], ''],
|
||||
]);
|
||||
$where['is_del'] = 0;
|
||||
$where['type'] = $this->type;
|
||||
return $this->success($this->services->getApplyList($where));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取供应商信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
if (!$id) return $this->fail('缺少参数');
|
||||
return $this->success($this->services->get((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核商品表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function verifyForm($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
return $this->success($this->services->verifyForm((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请审核
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function verifyApply($id)
|
||||
{
|
||||
if (!$id) return $this->fail('缺少参数');
|
||||
$data = $this->request->postMore([
|
||||
['status', 1],
|
||||
['fail_msg', '']
|
||||
]);
|
||||
return $this->success('操作成功', $this->services->verifyApply((int)$id, $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 备注表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function markForm($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
return $this->success($this->services->markForm((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 备注
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function mark($id)
|
||||
{
|
||||
if (!$id) return $this->fail('缺少参数');
|
||||
[$mark] = $this->request->postMore([
|
||||
['mark', ''],
|
||||
], true);
|
||||
if (!$mark) {
|
||||
return $this->fail('请输入备注');
|
||||
}
|
||||
$this->services->update($id, ['mark' => $mark]);
|
||||
return $this->success('备注成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除申请
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return $this->fail('删除失败,缺少参数');
|
||||
$this->services->update((int)$id, ['is_del' => 1]);
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
198
pro_v3.5.1/app/controller/admin/v1/supplier/SupplierExtract.php
Normal file
198
pro_v3.5.1/app/controller/admin/v1/supplier/SupplierExtract.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?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\admin\v1\supplier;
|
||||
|
||||
|
||||
use app\services\supplier\finance\SupplierFlowingWaterServices;
|
||||
use think\annotation\Inject;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\App;
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\supplier\finance\SupplierExtractServices;
|
||||
use think\facade\Config;
|
||||
|
||||
|
||||
/**
|
||||
* 供应商提现
|
||||
* Class SupplierExtract
|
||||
* @package app\controller\admin\v1\supplier
|
||||
*/
|
||||
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'],
|
||||
['supplier_id', '']
|
||||
]);
|
||||
if (isset($where['extract_type']) && $where['extract_type'] == 'wx') {
|
||||
$where['extract_type'] = 'weixin';
|
||||
}
|
||||
$whereData = [
|
||||
'supplier_id' => $where['supplier_id'],
|
||||
'is_del' => 0,
|
||||
];
|
||||
if ($this->supplierId != 0) {
|
||||
$whereData['supplier_id'] = $this->supplierId;
|
||||
}
|
||||
|
||||
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) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
if (!$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 $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function verify($id)
|
||||
{
|
||||
if (!$id) $this->fail('缺少参数');
|
||||
[$type, $message] = $this->request->postMore([
|
||||
['type', 1],
|
||||
['message', '']
|
||||
], true);
|
||||
$adminId = $this->adminId;
|
||||
if ($this->supplierId != 0) {
|
||||
return app('json')->fail('没有权限');
|
||||
}
|
||||
|
||||
if ($type == 1) {
|
||||
$res = $this->services->adopt($id, $adminId);
|
||||
} else {
|
||||
$res = $this->services->refuse((int)$id, $message, $adminId);
|
||||
}
|
||||
return $this->success($res ? '操作成功' : '操作失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function transfer($id)
|
||||
{
|
||||
if (!$id) $this->fail('缺少参数');
|
||||
return $this->success($this->services->add_transfer((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账提交
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save_transfer($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['voucher_image', ''],
|
||||
['voucher_title', '']
|
||||
]);
|
||||
if ($this->supplierId != 0) {
|
||||
return app('json')->fail('没有权限');
|
||||
}
|
||||
|
||||
$info = $this->services->getExtract($id);
|
||||
if (!$info) $this->fail('提现记录不存在');
|
||||
if ($info['status'] != 1) $this->fail('请先审核提现记录');
|
||||
if ($info['pay_status'] == 1) $this->fail('请勿重复提现');
|
||||
$data['pay_status'] = 1;
|
||||
if (!$this->services->update($id, $data)) {
|
||||
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('转账失败');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?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\admin\v1\supplier;
|
||||
|
||||
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\supplier\finance\SupplierFlowingWaterServices;
|
||||
|
||||
|
||||
/**
|
||||
* 供应商流水
|
||||
* Class SupplierFlowingWater
|
||||
* @package app\controller\admin\v1\supplier
|
||||
*/
|
||||
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([
|
||||
['data', '', '', 'time'],
|
||||
['supplier_id', '']
|
||||
]);
|
||||
if($this->supplierId){
|
||||
$where['supplier_id'] = $this->supplierId;
|
||||
}
|
||||
$where['keyword'] = $this->request->param('keyword', '');
|
||||
$where['is_del'] = 0;
|
||||
return app('json')->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加备注
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function mark($id)
|
||||
{
|
||||
[$mark] = $this->request->getMore([
|
||||
['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, ['remark' => $mark])) {
|
||||
return app('json')->fail('备注失败');
|
||||
}
|
||||
return app('json')->success('备注成功');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 账单记录
|
||||
* @return mixed
|
||||
*/
|
||||
public function fundRecord()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['timeType', 'day'],
|
||||
['data', '', '', 'time'],
|
||||
['supplier_id', ''],
|
||||
['status', '']
|
||||
]);
|
||||
if($this->supplierId){
|
||||
$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', ''],
|
||||
['supplier_id', '']
|
||||
]);
|
||||
if($this->supplierId){
|
||||
$where['supplier_id'] = $this->supplierId;
|
||||
}
|
||||
$where['keyword'] = $this->request->param('keyword', '');
|
||||
$where['id'] = stringToIntArray($where['ids']);
|
||||
unset($where['ids']);
|
||||
$where['is_del'] = 0;
|
||||
return app('json')->success($this->services->getList($where));
|
||||
}
|
||||
}
|
||||
@@ -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\admin\v1\supplier;
|
||||
|
||||
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\supplier\finance\SupplierTransactionsServices;
|
||||
|
||||
|
||||
/**
|
||||
* 门店流水
|
||||
* Class StoreFinanceFlow
|
||||
* @package app\controller\admin\v1\store
|
||||
*/
|
||||
class SupplierTransactions extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SupplierTransactionsServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected SupplierTransactionsServices $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([
|
||||
['data', '', '', 'time'],
|
||||
['store_id', '']
|
||||
]);
|
||||
$where['keyword'] = $this->request->param('keyword', '');
|
||||
$where['is_del'] = 0;
|
||||
$where['trade_type'] = 1;
|
||||
$where['no_type'] = 2;
|
||||
return app('json')->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加备注
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function mark($id)
|
||||
{
|
||||
[$mark] = $this->request->getMore([
|
||||
['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, ['remark' => $mark])) {
|
||||
return app('json')->fail('备注失败');
|
||||
}
|
||||
return app('json')->success('备注成功');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 账单记录
|
||||
* @return mixed
|
||||
*/
|
||||
public function fundRecord()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['timeType', 'day'],
|
||||
['data', '', '', 'time'],
|
||||
['store_id', '']
|
||||
]);
|
||||
$where['trade_type'] = 1;
|
||||
$where['no_type'] = 1;
|
||||
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', ''],
|
||||
['store_id', '']
|
||||
]);
|
||||
$where['keyword'] = $this->request->param('keyword', '');
|
||||
$where['id'] = stringToIntArray($where['ids']);
|
||||
unset($where['ids']);
|
||||
$where['is_del'] = 0;
|
||||
$where['trade_type'] = 1;
|
||||
return app('json')->success($this->services->getList($where));
|
||||
}
|
||||
}
|
||||
187
pro_v3.5.1/app/controller/admin/v1/supplier/SystemSupplier.php
Normal file
187
pro_v3.5.1/app/controller/admin/v1/supplier/SystemSupplier.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?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\admin\v1\supplier;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\supplier\LoginServices;
|
||||
use app\services\supplier\SystemSupplierServices;
|
||||
use app\services\system\admin\SystemAdminServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 供应商管理控制器
|
||||
* Class SystemSupplier
|
||||
* @package app\controller\admin\v1\supplier
|
||||
*/
|
||||
class SystemSupplier extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SystemSupplierServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemSupplierServices $services;
|
||||
|
||||
/**
|
||||
* 获取供应商列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
[['keywords', 's'], ''],
|
||||
]);
|
||||
$where['is_del'] = 0;
|
||||
return $this->success($this->services->getSupplierList($where, ['id', 'supplier_name', 'name', 'phone', 'address', 'is_show', 'add_time', 'mark', 'sort']));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存供应商
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['supplier_name', ''],
|
||||
['account', ''],
|
||||
['name', ''],
|
||||
['phone', ''],
|
||||
['conf_pwd', ''],
|
||||
['pwd', ''],
|
||||
['email', ''],
|
||||
['roles', []],
|
||||
['is_show', 0],
|
||||
['sort', 0],
|
||||
['address', ''],
|
||||
['province', 0],
|
||||
['city', 0],
|
||||
['area', 0],
|
||||
['street', 0],
|
||||
['detailed_address', ''],
|
||||
['mark', '']
|
||||
]);
|
||||
|
||||
$this->validate($data, \app\validate\supplier\SystemSupplierValidate::class, 'save');
|
||||
if (!$data['pwd']) {
|
||||
return $this->fail('请输入登录密码');
|
||||
}
|
||||
if ($data['conf_pwd'] != $data['pwd']) {
|
||||
return $this->fail('两次输入的密码不相同');
|
||||
}
|
||||
$this->services->create($data);
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改供应商信息
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id = 0)
|
||||
{
|
||||
if ($this->supplierId) {
|
||||
$id = $this->supplierId;
|
||||
}
|
||||
if (!$id) return $this->fail('缺少参数');
|
||||
$data = $this->request->postMore([
|
||||
['supplier_name', ''],
|
||||
['account', ''],
|
||||
['name', ''],
|
||||
['phone', ''],
|
||||
['conf_pwd', ''],
|
||||
['pwd', ''],
|
||||
['email', ''],
|
||||
['roles', []],
|
||||
['is_show', 0],
|
||||
['sort', 0],
|
||||
['address', ''],
|
||||
['province', 0],
|
||||
['city', 0],
|
||||
['area', 0],
|
||||
['street', 0],
|
||||
['detailed_address', ''],
|
||||
['mark', '']
|
||||
]);
|
||||
|
||||
$this->validate($data, \app\validate\supplier\SystemSupplierValidate::class, 'admin_update');
|
||||
|
||||
$this->services->save((int)$id, $data);
|
||||
return $this->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除供应商
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return $this->fail('删除失败,缺少参数');
|
||||
$this->services->delete((int)$id, ['is_del' => 1, 'status' => 0]);
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
$this->services->update((int)$id, ['is_show' => $status]);
|
||||
return $this->success($status == 0 ? '关闭成功' : '开启成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取供应商信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function read($id = 0)
|
||||
{
|
||||
if ($this->supplierId) {
|
||||
$id = $this->supplierId;
|
||||
}
|
||||
if (!$id) return $this->fail('缺少参数');
|
||||
$info = $this->services->getSupplierInfo((int)$id, '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 mixed
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
return $this->success($this->services->getSupplierSearch(['is_del' => 0], ['id', 'supplier_name']));
|
||||
}
|
||||
|
||||
/**
|
||||
* 供应登录
|
||||
* @param LoginServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function supplierLogin(LoginServices $services, $id, SystemAdminServices $adminServices)
|
||||
{
|
||||
$supplierInfo = $this->services->getOne(['id' => $id, 'is_del' => 0], '*', ['admin']);
|
||||
if (!$supplierInfo || !$supplierInfo->account || $supplierInfo->admin_is_del) {
|
||||
return $this->fail('供应商管理员异常');
|
||||
}
|
||||
return $this->success($adminServices->login($supplierInfo['account'], '', 'supplier', false, true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
<?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\admin\v1\supplier\system;
|
||||
|
||||
use app\controller\admin\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, '/supplier/admin',(int)$this->supplierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存管理员
|
||||
* @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;
|
||||
$data['level'] = 1;
|
||||
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, '/supplier/admin/',(int)$this->supplierId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新管理员
|
||||
* @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 ? '关闭成功' : '开启成功');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user