new files
This commit is contained in:
166
pro_v3.5.1/app/controller/admin/v1/merchant/SystemStore.php
Normal file
166
pro_v3.5.1/app/controller/admin/v1/merchant/SystemStore.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?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\merchant;
|
||||
|
||||
use think\annotation\Inject;
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\store\SystemStoreServices;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 门店管理控制器
|
||||
* Class SystemAttachment
|
||||
* @package app\admin\controller\system
|
||||
*
|
||||
*/
|
||||
class SystemStore extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SystemStoreServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemStoreServices $services;
|
||||
|
||||
/**
|
||||
* 获取门店列表1
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
[['keywords', 's'], ''],
|
||||
[['type', 'd'], 0]
|
||||
]);
|
||||
return $this->success($this->services->getStoreList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取门店头部
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_header()
|
||||
{
|
||||
$count = $this->services->getStoreData();
|
||||
return $this->success(compact('count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店设置
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function get_info()
|
||||
{
|
||||
[$id] = $this->request->getMore([
|
||||
[['id', 'd'], 0],
|
||||
], true);
|
||||
$info = $this->services->getStoreDispose($id);
|
||||
return $this->success(compact('info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 位置选择
|
||||
* @return mixed
|
||||
*/
|
||||
public function select_address()
|
||||
{
|
||||
$key = sys_config('tengxun_map_key');
|
||||
if (!$key) return $this->fail('提示:前往设置->系统设置->第三方接口 配置腾讯地图KEY');
|
||||
return $this->success(compact('key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置单个门店是否显示
|
||||
* @param string $is_show
|
||||
* @param string $id
|
||||
* @return Response
|
||||
*/
|
||||
public function set_show($is_show = '', $id = '')
|
||||
{
|
||||
($is_show == '' || $id == '') && $this->fail('缺少参数');
|
||||
$res = $this->services->update((int)$id, ['is_show' => (int)$is_show]);
|
||||
if ($res) {
|
||||
return $this->success($is_show == 1 ? '设置显示成功' : '设置隐藏成功');
|
||||
} else {
|
||||
return $this->fail($is_show == 1 ? '设置显示失败' : '设置隐藏失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存修改门店信息
|
||||
* param int $id
|
||||
* */
|
||||
public function save($id = 0)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['introduction', ''],
|
||||
['image', ''],
|
||||
['phone', ''],
|
||||
['address', ''],
|
||||
['detailed_address', ''],
|
||||
['latlng', ''],
|
||||
['day_time', []],
|
||||
]);
|
||||
$this->validate($data, \app\validate\admin\merchant\SystemStoreValidate::class, 'save');
|
||||
|
||||
$data['address'] = implode(',', $data['address']);
|
||||
$data['latlng'] = explode(',', $data['latlng']);
|
||||
if (!isset($data['latlng'][0]) || !isset($data['latlng'][1])) {
|
||||
return $this->fail('请选择门店位置');
|
||||
}
|
||||
$data['latitude'] = $data['latlng'][0];
|
||||
$data['longitude'] = $data['latlng'][1];
|
||||
$data['day_time'] = implode(' - ', $data['day_time']);
|
||||
unset($data['latlng']);
|
||||
if ($data['image'] && strstr($data['image'], 'http') === false) {
|
||||
$site_url = sys_config('site_url');
|
||||
$data['image'] = $site_url . $data['image'];
|
||||
}
|
||||
$this->services->saveStore((int)$id, $data);
|
||||
return $this->success('操作成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除恢复门店
|
||||
* @param $id
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return $this->fail('数据不存在');
|
||||
$storeInfo = $this->services->get($id);
|
||||
if (!$storeInfo) {
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
if ($storeInfo->is_del == 1) {
|
||||
$storeInfo->is_del = 0;
|
||||
if (!$storeInfo->save())
|
||||
return $this->fail('恢复失败,请稍候再试!');
|
||||
else
|
||||
return $this->success('恢复自提点成功!');
|
||||
} else {
|
||||
$storeInfo->is_del = 1;
|
||||
if (!$storeInfo->save())
|
||||
return $this->fail('删除失败,请稍候再试!');
|
||||
else
|
||||
return $this->success('删除自提点成功!');
|
||||
}
|
||||
}
|
||||
}
|
||||
175
pro_v3.5.1/app/controller/admin/v1/merchant/SystemStoreStaff.php
Normal file
175
pro_v3.5.1/app/controller/admin/v1/merchant/SystemStoreStaff.php
Normal file
@@ -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\merchant;
|
||||
|
||||
use app\services\store\SystemStoreServices;
|
||||
use app\services\store\SystemStoreStaffServices;
|
||||
use FormBuilder\Exception\FormBuilderException;
|
||||
use think\annotation\Inject;
|
||||
use app\controller\admin\AuthController;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 店员
|
||||
* Class SystemStoreStaff
|
||||
* @package app\controller\admin\v1\merchant
|
||||
*/
|
||||
class SystemStoreStaff extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SystemStoreStaffServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemStoreStaffServices $services;
|
||||
|
||||
/**
|
||||
* 获取店员列表
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
[['store_id', 'd'], 0],
|
||||
]);
|
||||
return $this->success($this->services->getStoreStaffList($where, ['store', 'user']));
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店列表
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function store_list(SystemStoreServices $services)
|
||||
{
|
||||
return $this->success($services->getStore());
|
||||
}
|
||||
|
||||
/**
|
||||
* 店员新增表单
|
||||
* @return mixed
|
||||
* @throws FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return $this->success($this->services->createForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* 店员修改表单
|
||||
* @return mixed
|
||||
* @throws FormBuilderException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
[$id] = $this->request->getMore([
|
||||
[['id', 'd'], 0],
|
||||
], true);
|
||||
return $this->success($this->services->updateForm($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存店员信息
|
||||
*/
|
||||
public function save($id = 0)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['image', ''],
|
||||
['uid', 0],
|
||||
['avatar', ''],
|
||||
['store_id', ''],
|
||||
['staff_name', ''],
|
||||
['phone', ''],
|
||||
['verify_status', 1],
|
||||
['status', 1],
|
||||
]);
|
||||
if ($data['store_id'] == '') {
|
||||
return $this->fail('请选择所属提货点');
|
||||
}
|
||||
if ($data['staff_name'] == '') {
|
||||
return $this->fail('请填写核销员名称');
|
||||
}
|
||||
if ($data['phone'] == '') {
|
||||
return $this->fail('请填写核销员电话');
|
||||
}
|
||||
if ($data['uid'] == 0) {
|
||||
return $this->fail('请选择用户');
|
||||
}
|
||||
if (!$id) {
|
||||
if ($data['image'] == '') {
|
||||
return $this->fail('请选择用户');
|
||||
}
|
||||
if ($this->services->count(['uid' => $data['uid'], 'store_id' => $data['store_id'], 'is_del' => 0])) {
|
||||
return $this->fail('添加的核销员用户已存在!');
|
||||
}
|
||||
$data['uid'] = $data['image']['uid'];
|
||||
$data['avatar'] = $data['image']['image'];
|
||||
} else {
|
||||
$data['avatar'] = $data['image'];
|
||||
}
|
||||
unset($data['image']);
|
||||
if ($id) {
|
||||
$res = $this->services->update($id, $data);
|
||||
if ($res) {
|
||||
return $this->success('编辑成功');
|
||||
} else {
|
||||
return $this->fail('编辑失败');
|
||||
}
|
||||
} else {
|
||||
$data['add_time'] = time();
|
||||
$res = $this->services->save($data);
|
||||
if ($res) {
|
||||
return $this->success('核销员添加成功');
|
||||
} else {
|
||||
return $this->fail('核销员添加失败,请稍后再试');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置单个店员是否开启
|
||||
* @param string $is_show
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_show($is_show = '', $id = '')
|
||||
{
|
||||
if ($is_show == '' || $id == '') {
|
||||
$this->fail('缺少参数');
|
||||
}
|
||||
$res = $this->services->update($id, ['status' => (int)$is_show]);
|
||||
if ($res) {
|
||||
return $this->success($is_show == 1 ? '开启成功' : '关闭成功');
|
||||
} else {
|
||||
return $this->fail($is_show == 1 ? '开启失败' : '关闭失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店员
|
||||
* @param $id
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return $this->fail('数据不存在');
|
||||
if (!$this->services->delete($id))
|
||||
return $this->fail('删除失败,请稍候再试!');
|
||||
else
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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\merchant;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\user\UserServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 核销订单
|
||||
* Class SystemVerifyOrder
|
||||
* @package app\controller\admin\v1\merchant
|
||||
*/
|
||||
class SystemVerifyOrder extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreOrderServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreOrderServices $services;
|
||||
|
||||
/**
|
||||
* 获取核销订单列表
|
||||
* return json
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['data', '', '', 'time'],
|
||||
['real_name', ''],
|
||||
['store_id', ''],
|
||||
['type', ''],
|
||||
['field_key', ''],
|
||||
]);
|
||||
$data = $this->services->getOrderList($where + ['status' => 6], ['*'], ['store', 'staff']);
|
||||
return $this->success(['count' => $data['count'], 'data' => $data['data'], 'badge' => $data['stat']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 未使用,获取核销订单头部
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVerifyBadge()
|
||||
{
|
||||
return $this->success([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表推荐人详细
|
||||
* @param $uid
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function order_spread_user($uid)
|
||||
{
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$userInfo = $userServices->getUserInfo((int)$uid);
|
||||
$spread = [];
|
||||
if ($userInfo['spread_uid']) {
|
||||
$spread = $userServices->getUserInfo((int)$userInfo['spread_uid']);
|
||||
if ($spread) {
|
||||
$spread = $spread->toArray();
|
||||
$spread['brokerage_pric'] = $spread['brokerage_price'];
|
||||
$spread['birthday'] = $spread['birthday'] ?: '';
|
||||
$spread['last_time'] = $spread['last_time'] ? date('Y-m-d H:i:s', $spread['last_time']) : '';
|
||||
}
|
||||
}
|
||||
return $this->success(['spread' => $spread]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user