mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 21:40:50 +00:00
更新开源v4.5.0版本
This commit is contained in:
parent
291b620ec3
commit
5e335c04f1
23
.gitignore
vendored
23
.gitignore
vendored
@ -1,20 +1,31 @@
|
||||
/.git
|
||||
/.idea
|
||||
/crmeb/.constant
|
||||
*.log
|
||||
*.DS_Store
|
||||
/crmeb/runtime/cache
|
||||
/crmeb/runtime/log
|
||||
/crmeb/runtime/session
|
||||
/crmeb/runtime/temp
|
||||
/crmeb/public/uploads
|
||||
*.log
|
||||
/crmeb/public/install/install.lock
|
||||
#/crmeb/.env
|
||||
/crmeb/app/adminapi/controller/UpgradeController.php
|
||||
/crmeb/app/adminapi/controller/v1/statistic/BalanceStatistic.php
|
||||
/crmeb/app/adminapi/controller/v1/statistic/OrderStatistic.php
|
||||
/crmeb/app/adminapi/controller/v1/statistic/ProductStatistic.php
|
||||
/crmeb/app/adminapi/controller/v1/statistic/TradeStatistic.php
|
||||
/crmeb/app/adminapi/controller/v1/statistic/UserStatistic.php
|
||||
/crmeb/public/install.lock
|
||||
/crmeb/timer.pid
|
||||
/crmeb/workerman.pid
|
||||
/crmeb/.env
|
||||
/crmeb/.constant
|
||||
/crmeb/runtime/timer.pid
|
||||
/crmeb/runtime/workerman.pid
|
||||
/docker-compose/mysql/data/
|
||||
/docker-compose/mysql/log/
|
||||
/docker-compose/nginx/log/
|
||||
/template/admin/node_modules/
|
||||
/template/admin/dist/
|
||||
/template/admin/.idea/
|
||||
/template/admin/node_modules/
|
||||
/template/uni-app/node_modules/
|
||||
/template/uni-app-live/node_modules/
|
||||
/template/uni-app/unpackage/
|
||||
/template/uni-app/.hbuilderx/
|
||||
|
||||
15
README.md
15
README.md
@ -1,4 +1,4 @@
|
||||
.jpg")
|
||||

|
||||
<p align="center" >
|
||||
<img src="https://images.gitee.com/uploads/images/2021/1109/164354_0aafe3d2_892944.gif" />
|
||||
</p>
|
||||
@ -7,12 +7,13 @@
|
||||
|
||||
|
||||
|
||||
CRMEB打通版是一款全开源支持免费商用的PHP单商户商城系统;
|
||||
CRMEB打通版是一款全开源支持免费商用的PHP **多语言** 商城系统;
|
||||
|
||||
CRMEB技术团队(官网:www.crmeb.com)历经5年时间匠心之作!系统采用前后端分离技术,基于TP6+Uni-app框架开发;客户移动端采用uni-app开发,管理后台前端使用iviewUI开发。系统支持微信公众号端、微信小程序端、H5端、PC端多端账号同步,可快速打包生成APP;
|
||||
CRMEB技术团队(官网:www.crmeb.com)历经6年时间匠心之作!系统采用前后端分离技术,基于TP6+Uni-app框架开发;客户移动端采用uni-app开发,管理后台前端使用iviewUI开发。系统支持微信公众号端、微信小程序端、H5端、PC端多端账号同步,可快速打包生成APP;
|
||||
|
||||
赋能开发者,减少重复造轮子;系统支持自动检查安装环境一键安装部署,使用简单方便;围绕方便二次开发,系统内置强大灵活的权限管理,可以控制到每一个菜单;通过内置组合数据,管理碎片化数据,系统配置快速添加系统配置参数,所有用户操作地方都内置钩子,代码严格分控制层(中间件、路由)、Services层、Dao层、Model层;后台应用form-builder PHP快速生成现代化表单;并提供详细的使用文档、开发文档、接口文档、数据字典等相关文档;及十几个技术交流群、技术论坛答疑;让您二开无忧,帮助更多开发者快速上手,节省开发时间,提升开发效率;助力企业实现数字化经营!
|
||||
|
||||
|
||||

|
||||
<p align="center" >
|
||||
<a href="https://gitee.com/ZhongBangKeJi/CRMEB/blob/master/README.md"> 宽屏预览 </a>
|
||||
</p>
|
||||
@ -100,7 +101,9 @@ Redis
|
||||
15.支持队列降低流量高峰,解除耦合,高可用;
|
||||
16.一键安装自动检查系统环境一键安装;
|
||||
17.移动端使用uni-app进行开发,方便编译成各种格式的代码;
|
||||
18.严格代码规范,层次分明
|
||||
18.严格代码规范,层次分明;
|
||||
19.移动端支持多语言切换;
|
||||
20.后台返回错误码统一
|
||||
~~~
|
||||
|
||||
## 页面展示
|
||||
@ -110,7 +113,7 @@ Redis
|
||||

|
||||

|
||||

|
||||
|
||||
### <a href='http://s.crmeb.com/goods_detail/728' target='_blank'>点击查看高清版全套UI设计图</a>
|
||||
|
||||
|
||||
## 系统演示
|
||||
|
||||
18
crmeb/.gitignore
vendored
Normal file
18
crmeb/.gitignore
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/.idea
|
||||
/.vscode
|
||||
*.log
|
||||
/.env
|
||||
/.history
|
||||
**/*.pid
|
||||
runtime/
|
||||
install.lock
|
||||
public/uploads
|
||||
public/admin
|
||||
public/pages
|
||||
public/phpExcel
|
||||
public/static
|
||||
public/*.txt
|
||||
public/h5
|
||||
*.zip
|
||||
*.rar
|
||||
.DS_Store
|
||||
@ -1,2 +1,4 @@
|
||||
version=CRMEB-KY v4.4.3
|
||||
version_code=443
|
||||
version=CRMEB-KY v4.5.0
|
||||
version_code=450
|
||||
app_id=ze7x9rxsv09l6pvsyo
|
||||
app_key=fuF7U9zaybLa5gageVQzxtxQMFnvU2OI
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
CRMEB v4.x 后端程序目录
|
||||
CRMEB v4.5 后端程序目录
|
||||
===============
|
||||
|
||||
> 运行环境要求PHP7.1-7.4。
|
||||
@ -76,9 +76,9 @@ php think timer [ status ] [ --d ]
|
||||
```
|
||||
参数
|
||||
- status: 状态
|
||||
- start: 启动
|
||||
- stop: 关闭
|
||||
- restart: 重启
|
||||
- start: 启动
|
||||
- stop: 关闭
|
||||
- restart: 重启
|
||||
- --d : 后台执行
|
||||
|
||||
## 长连接服务
|
||||
@ -93,9 +93,9 @@ php think workerman start --d
|
||||
```
|
||||
参数
|
||||
- status: 状态
|
||||
- start: 启动
|
||||
- stop: 关闭
|
||||
- restart: 重启
|
||||
- start: 启动
|
||||
- stop: 关闭
|
||||
- restart: 重启
|
||||
- --d : 后台执行
|
||||
|
||||
## 文档
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
namespace app\adminapi;
|
||||
|
||||
|
||||
use app\exceptions\CommonException;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\exceptions\AuthException;
|
||||
@ -35,7 +34,6 @@ class AdminApiExceptionHandle extends Handle
|
||||
AuthException::class,
|
||||
AdminException::class,
|
||||
ApiException::class,
|
||||
CommonException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -58,12 +56,12 @@ class AdminApiExceptionHandle extends Handle
|
||||
$log = [
|
||||
request()->adminId(), //管理员ID
|
||||
request()->ip(), //客户ip
|
||||
ceil(msectime() - (request()->time(true) * 1000)), //耗时(毫秒)
|
||||
ceil(msectime() - (request()->time(true) * 1000)), //耗时(毫秒)
|
||||
request()->rule()->getMethod(), //请求类型
|
||||
str_replace("/", "", request()->rootUrl()), //应用
|
||||
str_replace("/", "", request()->rootUrl()), //应用
|
||||
request()->baseUrl(), //路由
|
||||
json_encode(request()->param(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), //请求参数
|
||||
json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), //报错数据
|
||||
json_encode(request()->param(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),//请求参数
|
||||
json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), //报错数据
|
||||
|
||||
];
|
||||
Log::write(implode("|", $log), "error");
|
||||
@ -87,13 +85,20 @@ class AdminApiExceptionHandle extends Handle
|
||||
] : [];
|
||||
// 添加自定义异常处理机制
|
||||
if ($e instanceof DbException) {
|
||||
return app('json')->fail('数据获取失败', $massageData);
|
||||
} elseif ($e instanceof AuthException || $e instanceof ValidateException || $e instanceof ApiException || $e instanceof CommonException) {
|
||||
return app('json')->make($e->getCode() ? : 400, $e->getMessage());
|
||||
} elseif ($e instanceof AdminException) {
|
||||
return app('json')->fail(100102, $massageData);
|
||||
} elseif ($e instanceof ValidateException) {
|
||||
return app('json')->fail($e->getMessage(), $massageData);
|
||||
} elseif ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $e->getMessage(), $massageData);
|
||||
} else {
|
||||
return app('json')->code(200)->make(400, $e->getMessage(), $massageData);
|
||||
return app('json')->fail('很抱歉!系统开小差了', Env::get('app_debug', false) ? [
|
||||
'message' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'code' => $e->getCode(),
|
||||
'line' => $e->getLine(),
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : []);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ namespace app\adminapi\controller;
|
||||
|
||||
|
||||
use crmeb\basic\BaseController;
|
||||
use think\facade\Validate;
|
||||
|
||||
/**
|
||||
* 基类 所有控制器继承的类
|
||||
@ -48,15 +49,14 @@ class AuthController extends BaseController
|
||||
$this->adminInfo = $this->request->adminInfo();
|
||||
$this->auth = $this->request->adminInfo['rule'] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证数据
|
||||
* @access protected
|
||||
* @param array $data 数据
|
||||
* @param string|array $validate 验证器名或者验证规则数组
|
||||
* @param string|array $message 验证场景或者提示信息
|
||||
* @param bool $batch 是否批量验证
|
||||
* @return array|string|true
|
||||
* @throws ValidateException
|
||||
* @param array $data
|
||||
* @param $validate
|
||||
* @param null $message
|
||||
* @param bool $batch
|
||||
* @return bool
|
||||
*/
|
||||
final protected function validate(array $data, $validate, $message = null, bool $batch = false)
|
||||
{
|
||||
|
||||
@ -15,11 +15,13 @@ use app\services\system\SystemAuthServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\product\product\StoreProductReplyServices;
|
||||
use app\services\system\UpgradeServices;
|
||||
use app\services\user\UserExtractServices;
|
||||
use app\services\product\sku\StoreProductAttrValueServices;
|
||||
use app\services\system\SystemMenusServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\services\HttpService;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 公共接口基类 主要存放公共接口
|
||||
@ -42,70 +44,53 @@ class Common extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function auth()
|
||||
{
|
||||
$version = get_crmeb_version();
|
||||
|
||||
$host = $this->request->host();
|
||||
// 正常域名
|
||||
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
|
||||
'domain_name' => $this->request->host(),
|
||||
'domain_name' => $host,
|
||||
'label' => 19,
|
||||
'version' => $version
|
||||
]);
|
||||
$res = $res ? json_decode($res, true) : [];
|
||||
|
||||
//兼容test.
|
||||
if ($res['data']['status'] !== 1) {
|
||||
$host = $this->request->host();
|
||||
$data = explode('.', $host);
|
||||
$n = count($data);
|
||||
$preg = '/[\w].+\.(com|net|org|gov|edu)\.cn$/';
|
||||
if (($n > 2) && preg_match($preg, $host)) {
|
||||
//双后缀取后3位
|
||||
$url = $data[$n - 3] . '.' . $data[$n - 2] . '.' . $data[$n - 1];
|
||||
} else {
|
||||
//非双后缀取后两位
|
||||
$url = $data[$n - 2] . '.' . $data[$n - 1];
|
||||
}
|
||||
$host = str_replace('test.', '', $host);
|
||||
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
|
||||
'domain_name' => $url,
|
||||
'domain_name' => $host,
|
||||
'label' => 19,
|
||||
'version' => $version
|
||||
]);
|
||||
$res = $res ? json_decode($res, true) : [];
|
||||
}
|
||||
|
||||
//如果是主域名兼容www.
|
||||
if ($res['data']['status'] !== 1) {
|
||||
$host = str_replace('www.', '', $host);
|
||||
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
|
||||
'domain_name' => $this->request->host(),
|
||||
'label' => 1,
|
||||
'version' => $version
|
||||
]);
|
||||
$res = $res ? json_decode($res, true) : [];
|
||||
}
|
||||
if ($res['data']['status'] !== 1) {
|
||||
$host = $this->request->host();
|
||||
$data = explode('.', $host);
|
||||
$n = count($data);
|
||||
$preg = '/[\w].+\.(com|net|org|gov|edu)\.cn$/';
|
||||
if (($n > 2) && preg_match($preg, $host)) {
|
||||
//双后缀取后3位
|
||||
$url = $data[$n - 3] . '.' . $data[$n - 2] . '.' . $data[$n - 1];
|
||||
} else {
|
||||
//非双后缀取后两位
|
||||
$url = $data[$n - 2] . '.' . $data[$n - 1];
|
||||
}
|
||||
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
|
||||
'domain_name' => $url,
|
||||
'label' => 1,
|
||||
'domain_name' => $host,
|
||||
'label' => 19,
|
||||
'version' => $version
|
||||
]);
|
||||
$res = $res ? json_decode($res, true) : [];
|
||||
}
|
||||
|
||||
//升级状态
|
||||
/** @var UpgradeServices $upgradeServices */
|
||||
$upgradeServices = app()->make(UpgradeServices::class);
|
||||
$upgradeStatus = $upgradeServices->getUpgradeStatus();
|
||||
|
||||
$status = $res['data']['status'] ?? -9;
|
||||
$defaultRecordCode = '00000000';
|
||||
switch ((int)$status) {
|
||||
case 1:
|
||||
//审核成功
|
||||
$authCode = $res['data']['auth_code'] ?? $defaultRecordCode;
|
||||
$authCode = $res['data']['auth_code'] ?? '';
|
||||
$autoContent = $res['data']['auto_content'] ?? '';
|
||||
try {
|
||||
/** @var SystemConfigServices $services */
|
||||
@ -124,11 +109,11 @@ class Common extends AuthController
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
return app('json')->fail('授权成功,写入数据库失败,请检查数据库链接配置');
|
||||
return app('json')->fail(400330);
|
||||
}
|
||||
return app('json')->success(['status' => 1, 'authCode' => $authCode, 'day' => 0]);
|
||||
return app('json')->success(['status' => 1, 'copyright' => $this->copyright(), 'authCode' => $authCode, 'day' => 0, 'force_reminder' => $upgradeStatus['force_reminder'] ?? 0]);
|
||||
default:
|
||||
return app('json')->success(['status' => -9]);
|
||||
return app('json')->success(['status' => -9, 'force_reminder' => $upgradeStatus['force_reminder'] ?? 0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +123,6 @@ class Common extends AuthController
|
||||
*/
|
||||
public function auth_apply(SystemAuthServices $services)
|
||||
{
|
||||
$version = get_crmeb_version();
|
||||
$data = $this->request->postMore([
|
||||
['company_name', ''],
|
||||
['domain_name', ''],
|
||||
@ -148,34 +132,23 @@ class Common extends AuthController
|
||||
['captcha', ''],
|
||||
]);
|
||||
if (!$data['company_name']) {
|
||||
return app('json')->fail('请填写公司名称');
|
||||
return app('json')->fail(400331);
|
||||
}
|
||||
if (!$data['domain_name']) {
|
||||
return app('json')->fail('请填写授权域名');
|
||||
return app('json')->fail(400332);
|
||||
}
|
||||
|
||||
if (!$data['phone']) {
|
||||
return app('json')->fail('请填写手机号码');
|
||||
return app('json')->fail(400333);
|
||||
}
|
||||
if (!$data['order_id']) {
|
||||
return app('json')->fail('请填写订单id');
|
||||
return app('json')->fail(400334);
|
||||
}
|
||||
if (!$data['captcha']) {
|
||||
return app('json')->fail('请填写验证码');
|
||||
return app('json')->fail(400137);
|
||||
}
|
||||
$datas = explode('.', $data['domain_name']);
|
||||
$n = count($datas);
|
||||
$preg = '/[\w].+\.(com|net|org|gov|edu)\.cn$/';
|
||||
if (($n > 2) && preg_match($preg, $data['domain_name'])) {
|
||||
//双后缀取后3位
|
||||
$domain_name = $datas[$n - 3] . '.' . $datas[$n - 2] . '.' . $datas[$n - 1];
|
||||
} else {
|
||||
//非双后缀取后两位
|
||||
$domain_name = $datas[$n - 2] . '.' . $datas[$n - 1];
|
||||
}
|
||||
$data['domain_name'] = $domain_name;
|
||||
$services->authApply($data);
|
||||
return app('json')->success("申请授权成功!");
|
||||
return app('json')->success(400335);
|
||||
|
||||
}
|
||||
|
||||
@ -382,5 +355,89 @@ class Common extends AuthController
|
||||
return app('json')->success(sort_list_tier($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询购买版权
|
||||
* @return mixed
|
||||
*/
|
||||
public function copyright()
|
||||
{
|
||||
try {
|
||||
if (Cache::has('nncnL_crmeb_copyright')) {
|
||||
$copyrightContext = Cache::get('nncnL_crmeb_copyright');
|
||||
} else {
|
||||
/** @var SystemConfigServices $services */
|
||||
$services = app()->make(SystemConfigServices::class);
|
||||
$copyrightContext = $services->value(['menu_name' => 'nncnL_crmeb_copyright'], 'value');
|
||||
$copyrightContext = $copyrightContext ? json_decode($copyrightContext, true) : null;
|
||||
Cache::set('nncnL_crmeb_copyright', $copyrightContext, 3600);
|
||||
}
|
||||
|
||||
if (Cache::has('nncnL_crmeb_copyright_image')) {
|
||||
$copyrightImage = Cache::get('nncnL_crmeb_copyright_image');
|
||||
} else {
|
||||
/** @var SystemConfigServices $services */
|
||||
$services = app()->make(SystemConfigServices::class);
|
||||
$copyrightImage = $services->value(['menu_name' => 'nncnL_crmeb_copyright_image'], 'value');
|
||||
$copyrightImage = $copyrightImage ? json_decode($copyrightImage, true) : null;
|
||||
Cache::set('nncnL_crmeb_copyright_image', $copyrightImage, 3600);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$copyrightContext = '';
|
||||
$copyrightImage = '';
|
||||
}
|
||||
return app('json')->success(compact('copyrightContext', 'copyrightImage'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存版权
|
||||
* @return mixed
|
||||
*/
|
||||
public function saveCopyright()
|
||||
{
|
||||
[$copyright, $copyrightImg] = $this->request->postMore(['copyright', 'copyright_img',], true);
|
||||
|
||||
/** @var SystemConfigServices $services */
|
||||
$services = app()->make(SystemConfigServices::class);
|
||||
if ($services->count(['menu_name' => 'nncnL_crmeb_copyright'])) {
|
||||
$services->update([
|
||||
'menu_name' => 'nncnL_crmeb_copyright'
|
||||
], [
|
||||
'value' => json_encode($copyright)
|
||||
]);
|
||||
} else {
|
||||
$services->save([
|
||||
'menu_name' => 'nncnL_crmeb_copyright',
|
||||
'type' => 'text',
|
||||
'input_type' => 'input',
|
||||
'config_tab_id' => 1,
|
||||
'value' => json_encode($copyright),
|
||||
'status' => 2,
|
||||
'info' => ''
|
||||
]);
|
||||
}
|
||||
|
||||
if ($services->count(['menu_name' => 'nncnL_crmeb_copyright_image'])) {
|
||||
$services->update([
|
||||
'menu_name' => 'nncnL_crmeb_copyright_imge'
|
||||
], [
|
||||
'value' => json_encode($copyrightImg)
|
||||
]);
|
||||
} else {
|
||||
$services->save([
|
||||
'menu_name' => 'nncnL_crmeb_copyright_image',
|
||||
'type' => 'text',
|
||||
'input_type' => 'input',
|
||||
'config_tab_id' => 1,
|
||||
'value' => json_encode($copyrightImg),
|
||||
'status' => 2,
|
||||
'info' => ''
|
||||
]);
|
||||
}
|
||||
|
||||
Cache::set('nncnL_crmeb_copyright', $copyright, 3600);
|
||||
Cache::set('nncnL_crmeb_copyright_image', $copyrightImg, 3600);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ class Login extends AuthController
|
||||
], true);
|
||||
|
||||
if (!app()->make(Captcha::class)->check($imgcode)) {
|
||||
return app('json')->fail('验证码错误,请重新输入');
|
||||
return app('json')->fail(400336);
|
||||
}
|
||||
|
||||
$this->validate(['account' => $account, 'pwd' => $password], \app\adminapi\validate\setting\SystemAdminValidata::class, 'get');
|
||||
|
||||
@ -44,21 +44,4 @@ class PublicController
|
||||
{
|
||||
return app('json')->success(getWorkerManUrl());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前系统版本
|
||||
* @return array
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
$version_arr = [];
|
||||
$curent_version = @file(app()->getRootPath() . '.version');
|
||||
|
||||
foreach ($curent_version as $val) {
|
||||
list($k, $v) = explode('=', $val);
|
||||
$version_arr[$k] = $v;
|
||||
}
|
||||
return app('json')->success($version_arr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,13 +6,11 @@
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use crmeb\services\UploadService;
|
||||
|
||||
class Test
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,14 +10,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\agent;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\agent\AgentLevelServices;
|
||||
use app\services\agent\AgentLevelTaskServices;
|
||||
use think\facade\App;
|
||||
|
||||
|
||||
/**
|
||||
* 分销等级控制器
|
||||
* Class AgentLevel
|
||||
* @package app\controller\admin\v1\agent
|
||||
*/
|
||||
@ -35,9 +34,11 @@ class AgentLevel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* 后台分销等级列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -49,9 +50,9 @@ class AgentLevel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
* 添加分销等级表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@ -59,9 +60,8 @@ class AgentLevel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @return \think\Response
|
||||
* 保存分销等级
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
@ -72,37 +72,35 @@ class AgentLevel extends AuthController
|
||||
['one_brokerage', 0],
|
||||
['two_brokerage', 0],
|
||||
['status', 0]]);
|
||||
if (!$data['name']) return app('json')->fail('请输入等级名称');
|
||||
if (!$data['grade']) return app('json')->fail('请输入等级');
|
||||
if (!$data['image']) return app('json')->fail('请选择等级图标');
|
||||
if (!$data['name']) return app('json')->fail(400200);
|
||||
if (!$data['grade']) return app('json')->fail(400201);
|
||||
if (!$data['image']) return app('json')->fail(400202);
|
||||
if ($data['two_brokerage'] > $data['one_brokerage']) {
|
||||
return app('json')->fail('二级返佣比例不能大于一级');
|
||||
return app('json')->fail(400203);
|
||||
}
|
||||
$grade = $this->services->get(['grade' => $data['grade'], 'is_del' => 0]);
|
||||
if ($grade) {
|
||||
return app('json')->fail('当前等级已存在');
|
||||
return app('json')->fail(400204);
|
||||
}
|
||||
$data['add_time'] = time();
|
||||
$this->services->save($data);
|
||||
return app('json')->success('添加等级成功!');
|
||||
return app('json')->success(400205);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* @param $id
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 编辑分销等级表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
@ -110,10 +108,12 @@ class AgentLevel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 修改分销等级
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
@ -124,16 +124,16 @@ class AgentLevel extends AuthController
|
||||
['one_brokerage', 0],
|
||||
['two_brokerage', 0],
|
||||
['status', 0]]);
|
||||
if (!$data['name']) return app('json')->fail('请输入等级名称');
|
||||
if (!$data['grade']) return app('json')->fail('请输入等级');
|
||||
if (!$data['image']) return app('json')->fail('请选择等级图标');
|
||||
if (!$data['name']) return app('json')->fail(400200);
|
||||
if (!$data['grade']) return app('json')->fail(400201);
|
||||
if (!$data['image']) return app('json')->fail(400202);
|
||||
if ($data['two_brokerage'] > $data['one_brokerage']) {
|
||||
return app('json')->fail('二级分拥比例不能大于一级');
|
||||
return app('json')->fail(400203);
|
||||
}
|
||||
if (!$levelInfo = $this->services->getLevelInfo((int)$id)) return app('json')->fail('编辑的等级不存在!');
|
||||
if (!$levelInfo = $this->services->getLevelInfo((int)$id)) return app('json')->fail(400206);
|
||||
$grade = $this->services->get(['grade' => $data['grade'], 'is_del' => 0]);
|
||||
if ($grade && $grade['id'] != $id) {
|
||||
return app('json')->fail('当前等级已存在');
|
||||
return app('json')->fail(400204);
|
||||
}
|
||||
|
||||
$levelInfo->name = $data['name'];
|
||||
@ -143,11 +143,11 @@ class AgentLevel extends AuthController
|
||||
$levelInfo->two_brokerage = $data['two_brokerage'];
|
||||
$levelInfo->status = $data['status'];
|
||||
$levelInfo->save();
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
* 删除分销等级
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
@ -156,17 +156,20 @@ class AgentLevel extends AuthController
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('参数错误,请重新打开');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
//检查分销等级数据是否存在
|
||||
$levelInfo = $this->services->getLevelInfo((int)$id);
|
||||
if ($levelInfo) {
|
||||
//更新数据为已删除
|
||||
$res = $this->services->update($id, ['is_del' => 1]);
|
||||
if (!$res)
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
//删除该等级的任务为已删除
|
||||
/** @var AgentLevelTaskServices $agentLevelTaskServices */
|
||||
$agentLevelTaskServices = app()->make(AgentLevelTaskServices::class);
|
||||
$agentLevelTaskServices->update(['level_id' => $id], ['is_del' => 1]);
|
||||
}
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,8 +180,8 @@ class AgentLevel extends AuthController
|
||||
*/
|
||||
public function set_status($id = 0, $status = '')
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
if ($status == '' || $id == 0) return app('json')->fail(100100);
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,13 +10,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\agent;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\agent\AgentLevelTaskServices;
|
||||
use think\facade\App;
|
||||
|
||||
|
||||
/**
|
||||
* 分销等级任务控制器
|
||||
* Class AgentLevelTask
|
||||
* @package app\controller\admin\v1\agent
|
||||
*/
|
||||
@ -34,9 +33,11 @@ class AgentLevelTask extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* 显示等级任务列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -46,7 +47,7 @@ class AgentLevelTask extends AuthController
|
||||
['keyword', '']
|
||||
]);
|
||||
if (!$where['id']) {
|
||||
return app('json')->fail('缺少参数ID');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$where['level_id'] = $where['id'];
|
||||
unset($where['id']);
|
||||
@ -54,24 +55,26 @@ class AgentLevelTask extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
* 等级任务添加表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
[$level_id] = $this->request->postMore([
|
||||
['level_id', 0]], true);
|
||||
if (!$level_id) {
|
||||
return app('json')->fail('缺少等级ID');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->createForm((int)$level_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @return \think\Response
|
||||
* 保存等级任务
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
@ -83,32 +86,30 @@ class AgentLevelTask extends AuthController
|
||||
['desc', 0],
|
||||
['sort', 0],
|
||||
['status', 0]]);
|
||||
if (!$data['level_id']) return app('json')->fail('缺少等级ID');
|
||||
if (!$data['name']) return app('json')->fail('请输入任务名称');
|
||||
if (!$data['type']) return app('json')->fail('请选择任务类型');
|
||||
if (!$data['number']) return app('json')->fail('请输入限定数量');
|
||||
if (!$data['level_id']) return app('json')->fail(100100);
|
||||
if (!$data['name']) return app('json')->fail(400207);
|
||||
if (!$data['type']) return app('json')->fail(400208);
|
||||
if (!$data['number']) return app('json')->fail(400209);
|
||||
$this->services->checkTypeTask(0, $data);
|
||||
$data['add_time'] = time();
|
||||
$this->services->save($data);
|
||||
return app('json')->success('添加等级成功!');
|
||||
return app('json')->success(400210);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* @param $id
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 等级任务修改表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
@ -116,10 +117,12 @@ class AgentLevelTask extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 修改等级任务
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
@ -130,10 +133,10 @@ class AgentLevelTask extends AuthController
|
||||
['desc', 0],
|
||||
['sort', 0],
|
||||
['status', 0]]);
|
||||
if (!$data['name']) return app('json')->fail('请输入等级名称');
|
||||
if (!$data['type']) return app('json')->fail('请选择任务类型');
|
||||
if (!$data['number']) return app('json')->fail('请输入限定数量');
|
||||
if (!$levelTaskInfo = $this->services->getLevelTaskInfo((int)$id)) return app('json')->fail('编辑的任务不存在!');
|
||||
if (!$data['name']) return app('json')->fail(400207);
|
||||
if (!$data['type']) return app('json')->fail(400208);
|
||||
if (!$data['number']) return app('json')->fail(400209);
|
||||
if (!$levelTaskInfo = $this->services->getLevelTaskInfo((int)$id)) return app('json')->fail(400211);
|
||||
$this->services->checkTypeTask((int)$id, $data);
|
||||
$levelTaskInfo->name = $data['name'];
|
||||
$levelTaskInfo->type = $data['type'];
|
||||
@ -142,11 +145,11 @@ class AgentLevelTask extends AuthController
|
||||
$levelTaskInfo->sort = $data['sort'];
|
||||
$levelTaskInfo->status = $data['status'];
|
||||
$levelTaskInfo->save();
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
* 删除等级任务
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
@ -155,14 +158,14 @@ class AgentLevelTask extends AuthController
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('参数错误,请重新打开');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$levelTaskInfo = $this->services->getLevelTaskInfo((int)$id);
|
||||
if ($levelTaskInfo) {
|
||||
$res = $this->services->update($id, ['is_del' => 1]);
|
||||
if (!$res)
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,9 +176,9 @@ class AgentLevelTask extends AuthController
|
||||
*/
|
||||
public function set_status($id = 0, $status = '')
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
if ($status == '' || $id == 0) return app('json')->fail(100100);
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,14 +10,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\agent;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\agent\AgentLevelServices;
|
||||
use app\services\agent\AgentManageServices;
|
||||
use app\services\user\UserServices;
|
||||
use think\facade\App;
|
||||
|
||||
|
||||
/**
|
||||
* 分销商管理控制器
|
||||
* Class AgentManage
|
||||
@ -39,6 +37,9 @@ class AgentManage extends AuthController
|
||||
/**
|
||||
* 分销管理列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -52,6 +53,9 @@ class AgentManage extends AuthController
|
||||
/**
|
||||
* 分销头部统计
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function get_badge()
|
||||
{
|
||||
@ -77,8 +81,6 @@ class AgentManage extends AuthController
|
||||
return app('json')->success($this->services->getStairList($where));
|
||||
}
|
||||
|
||||
//TODO 废弃
|
||||
|
||||
/**
|
||||
* 推广人列表头部统计
|
||||
* @return mixed
|
||||
@ -112,50 +114,51 @@ class AgentManage extends AuthController
|
||||
return app('json')->success($this->services->getStairOrderList((int)$where['uid'], $where));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查看公众号推广二维码
|
||||
* @param int $uid
|
||||
* @return json
|
||||
* */
|
||||
* @param string $uid
|
||||
* @param string $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function look_code($uid = '', $action = '')
|
||||
{
|
||||
if (!$uid || !$action) return app('json')->fail('缺少参数');
|
||||
if (!$uid || !$action) return app('json')->fail(100100);
|
||||
try {
|
||||
if (method_exists($this, $action)) {
|
||||
$res = $this->$action($uid);
|
||||
if ($res)
|
||||
return app('json')->success($res);
|
||||
else
|
||||
return app('json')->fail($res['msg'] ?? '获取失败,请稍后再试!');
|
||||
return app('json')->fail(100016);
|
||||
} else
|
||||
return app('json')->fail('暂无此方法');
|
||||
return app('json')->fail(100029);
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail('获取推广二维码失败,请检查您的微信配置', ['line' => $e->getLine(), 'messag' => $e->getMessage()]);
|
||||
return app('json')->fail(400212, ['line' => $e->getLine(), 'messag' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公众号二维码
|
||||
* */
|
||||
* @param $uid
|
||||
* @return array
|
||||
*/
|
||||
public function wechant_code($uid)
|
||||
{
|
||||
$qr_code = $this->services->wechatCode((int)$uid);
|
||||
if (isset($qr_code['url']))
|
||||
return ['code_src' => $qr_code['url']];
|
||||
else
|
||||
return app('json')->fail('获取失败,请稍后再试!');
|
||||
return app('json')->fail(100016);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 查看小程序推广二维码
|
||||
* 查看小程序推广二维码
|
||||
* @param string $uid
|
||||
*/
|
||||
public function look_xcx_code($uid = '')
|
||||
{
|
||||
if (!strlen(trim($uid))) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->lookXcxCode((int)$uid));
|
||||
}
|
||||
@ -167,18 +170,19 @@ class AgentManage extends AuthController
|
||||
*/
|
||||
public function look_h5_code($uid = '')
|
||||
{
|
||||
if (!strlen(trim($uid))) return app('json')->fail('缺少参数');
|
||||
if (!strlen(trim($uid))) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->lookH5Code((int)$uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解除单个用户的推广权限
|
||||
* @param int $uid
|
||||
* */
|
||||
* @param $uid
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete_spread($uid)
|
||||
{
|
||||
if (!$uid) app('json')->fail('缺少参数');
|
||||
return app('json')->success($this->services->delSpread((int)$uid) ? '解除成功' : '解除失败');
|
||||
if (!$uid) app('json')->fail(100100);
|
||||
return app('json')->success($this->services->delSpread((int)$uid) ? 100014 : 100015);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,24 +197,24 @@ class AgentManage extends AuthController
|
||||
[['spread_uid', 'd'], 0],
|
||||
], true);
|
||||
if (!$uid || !$spreadUid) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
if ($uid == $spreadUid) {
|
||||
return app('json')->fail('上级推广人不能为自己');
|
||||
return app('json')->fail(400213);
|
||||
}
|
||||
$userInfo = $services->get($uid);
|
||||
if (!$userInfo) {
|
||||
return app('json')->fail('用户不存在');
|
||||
return app('json')->fail(400214);
|
||||
}
|
||||
if (!$services->count(['uid' => $spreadUid])) {
|
||||
return app('json')->fail('上级用户不存在');
|
||||
return app('json')->fail(400215);
|
||||
}
|
||||
if ($userInfo->spread_uid == $spreadUid) {
|
||||
return app('json')->fail('当前推广人已经是所选人');
|
||||
return app('json')->fail(400216);
|
||||
}
|
||||
$spreadInfo = $services->get($spreadUid);
|
||||
if ($spreadInfo->spread_uid == $uid) {
|
||||
return app('json')->fail('上级推广人不能为自己下级');
|
||||
return app('json')->fail(400217);
|
||||
}
|
||||
//之前的上级减少推广人数
|
||||
if ($userInfo->spread_uid) {
|
||||
@ -223,7 +227,7 @@ class AgentManage extends AuthController
|
||||
$userInfo->spread_uid = $spreadUid;
|
||||
$userInfo->spread_time = time();
|
||||
$userInfo->save();
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -233,8 +237,8 @@ class AgentManage extends AuthController
|
||||
*/
|
||||
public function delete_system_spread($uid)
|
||||
{
|
||||
if (!$uid) app('json')->fail('缺少参数');
|
||||
return app('json')->success($this->services->delSystemSpread((int)$uid) ? '取消成功' : '取消失败');
|
||||
if (!$uid) app('json')->fail(100100);
|
||||
return app('json')->success($this->services->delSystemSpread((int)$uid) ? 100019 : 100020);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,7 +253,7 @@ class AgentManage extends AuthController
|
||||
*/
|
||||
public function getLevelForm(AgentLevelServices $services, $uid)
|
||||
{
|
||||
if (!$uid) app('json')->fail('缺少参数');
|
||||
if (!$uid) app('json')->fail(100100);
|
||||
return app('json')->success($services->levelForm((int)$uid));
|
||||
}
|
||||
|
||||
@ -268,8 +272,8 @@ class AgentManage extends AuthController
|
||||
[['id', 'd'], 0],
|
||||
], true);
|
||||
if (!$uid || !$id) {
|
||||
app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($services->givelevel((int)$uid, (int)$id) ? '赠送成功' : '赠送失败');
|
||||
return app('json')->success($services->givelevel((int)$uid, (int)$id) ? 400218 : 400219);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
<?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\adminapi\controller\v1\agent;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -10,6 +18,11 @@ use app\services\user\UserServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 事业部控制器
|
||||
* Class Division
|
||||
* @package app\adminapi\controller\v1\agent
|
||||
*/
|
||||
class Division extends AuthController
|
||||
{
|
||||
/**
|
||||
@ -26,6 +39,9 @@ class Division extends AuthController
|
||||
/**
|
||||
* 事业部列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function divisionList()
|
||||
{
|
||||
@ -61,6 +77,7 @@ class Division extends AuthController
|
||||
* 添加编辑事业部
|
||||
* @param $uid
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function divisionCreate($uid)
|
||||
{
|
||||
@ -86,13 +103,14 @@ class Division extends AuthController
|
||||
['roles', []]
|
||||
]);
|
||||
$this->services->divisionSave($data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加编辑代理商
|
||||
* @param $uid
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function divisionAgentCreate($uid)
|
||||
{
|
||||
@ -114,10 +132,10 @@ class Division extends AuthController
|
||||
['edit', 0],
|
||||
]);
|
||||
$userInfo = $userServices->get((int)$data['uid']);
|
||||
if (!$userInfo) throw new AdminException('参数错误,找不到用户');
|
||||
if (!$userInfo) throw new AdminException(100100);
|
||||
$data['division_id'] = $this->adminInfo['division_id'];
|
||||
$this->services->divisionAgentSave($data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,7 +147,7 @@ class Division extends AuthController
|
||||
public function setDivisionStatus($status, $uid)
|
||||
{
|
||||
$this->services->setDivisionStatus($status, $uid);
|
||||
return app('json')->success($status ? '开启成功' : '关闭成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,7 +159,7 @@ class Division extends AuthController
|
||||
public function delDivision($type, $uid)
|
||||
{
|
||||
$this->services->delDivision($type, $uid);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,7 +221,7 @@ class Division extends AuthController
|
||||
/** @var DivisionAgentApplyServices $applyServices */
|
||||
$applyServices = app()->make(DivisionAgentApplyServices::class);
|
||||
$data = $applyServices->applyAgentSave($data);
|
||||
return app('json')->success('处理成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,40 +234,6 @@ class Division extends AuthController
|
||||
/** @var DivisionAgentApplyServices $applyServices */
|
||||
$applyServices = app()->make(DivisionAgentApplyServices::class);
|
||||
$applyServices->delApply($id);
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代理商协议
|
||||
* @param AgreementServices $agreementServices
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function agentAgreementInfo(AgreementServices $agreementServices)
|
||||
{
|
||||
$list = $agreementServices->getAgreementBytype(2);
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存代理商协议
|
||||
* @param AgreementServices $agreementServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function agentAgreementSave(AgreementServices $agreementServices)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['id', 0],
|
||||
['type', 2],
|
||||
['title', ""],
|
||||
['content', ''],
|
||||
['status', ''],
|
||||
]);
|
||||
$data['title'] = '代理商规则';
|
||||
$data['status'] = 1;
|
||||
$res = $agreementServices->saveAgreement($data, $data['id']);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -16,11 +16,10 @@ use app\services\system\attachment\SystemAttachmentServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\App;
|
||||
use think\Request;
|
||||
use think\facade\Route as Url;
|
||||
use app\adminapi\controller\AuthController;
|
||||
use crmeb\services\{FileService, FormBuilder as Form, MiniProgramService, template\Template, UploadService};
|
||||
use think\facade\Cache;
|
||||
use crmeb\services\FileService;
|
||||
use app\services\other\UploadService;
|
||||
use crmeb\services\app\MiniProgramService;
|
||||
|
||||
/**
|
||||
* Class RoutineTemplate
|
||||
@ -42,161 +41,6 @@ class RoutineTemplate extends AuthController
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['name', ''],
|
||||
['status', '']
|
||||
]);
|
||||
$where['type'] = 0;
|
||||
$data = $this->services->getTemplateList($where);
|
||||
$industry = Cache::tag($this->cacheTag)->remember('_wechat_industry', function () {
|
||||
try {
|
||||
$cache = (new Template('wechat'))->getIndustry();
|
||||
if (!$cache) return [];
|
||||
Cache::tag($this->cacheTag, ['_wechat_industry']);
|
||||
return $cache->toArray();
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}, 0) ?: [];
|
||||
!is_array($industry) && $industry = [];
|
||||
$industry['primary_industry'] = isset($industry['primary_industry']) ? $industry['primary_industry']['first_class'] . ' | ' . $industry['primary_industry']['second_class'] : '未选择';
|
||||
$industry['secondary_industry'] = isset($industry['secondary_industry']) ? $industry['secondary_industry']['first_class'] . ' | ' . $industry['secondary_industry']['second_class'] : '未选择';
|
||||
$lst = [
|
||||
'industry' => $industry,
|
||||
'count' => $data['count'],
|
||||
'list' => $data['list']
|
||||
];
|
||||
return app('json')->success($lst);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$f = array();
|
||||
$f[] = Form::input('tempkey', '模板编号');
|
||||
$f[] = Form::input('tempid', '模板ID');
|
||||
$f[] = Form::input('name', '模板名');
|
||||
$f[] = Form::input('content', '回复内容')->type('textarea');
|
||||
$f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
||||
return app('json')->success(create_form('添加模板消息', $f, Url::buildUrl('/app/routine'), 'POST'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
'tempkey',
|
||||
'tempid',
|
||||
'name',
|
||||
'content',
|
||||
['status', 0]
|
||||
]);
|
||||
if ($data['tempkey'] == '') return app('json')->fail('请输入模板编号');
|
||||
if ($data['tempkey'] != '' && $this->services->getOne(['tempkey' => $data['tempkey']]))
|
||||
return app('json')->fail('请输入模板编号已存在,请重新输入');
|
||||
if ($data['tempid'] == '') return app('json')->fail('请输入模板ID');
|
||||
if ($data['name'] == '') return app('json')->fail('请输入模板名');
|
||||
if ($data['content'] == '') return app('json')->fail('请输入回复内容');
|
||||
$data['add_time'] = time();
|
||||
$this->services->save($data);
|
||||
return app('json')->success('添加模板消息成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
$product = $this->services->get($id);
|
||||
if (!$product) return app('json')->fail('数据不存在!');
|
||||
$f = array();
|
||||
$f[] = Form::input('tempkey', '模板编号', $product->getData('tempkey'))->disabled(1);
|
||||
$f[] = Form::input('name', '模板名', $product->getData('name'))->disabled(1);
|
||||
$f[] = Form::input('tempid', '模板ID', $product->getData('tempid'));
|
||||
$f[] = Form::radio('status', '状态', $product->getData('status'))->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
||||
return app('json')->success(create_form('编辑模板消息', $f, Url::buildUrl('/app/routine/' . $id), 'PUT'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
'tempid',
|
||||
['status', 0]
|
||||
]);
|
||||
if ($data['tempid'] == '') return app('json')->fail('请输入模板ID');
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
$product = $this->services->get($id);
|
||||
if (!$product) return app('json')->fail('数据不存在!');
|
||||
$this->services->update($id, $data, 'id');
|
||||
return app('json')->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在!');
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
else
|
||||
return app('json')->success('删除成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
$this->services->update($id, ['status' => $status], 'id');
|
||||
return app('json')->success($status == 0 ? '关闭成功' : '开启成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步订阅消息
|
||||
* @return mixed
|
||||
@ -207,24 +51,11 @@ class RoutineTemplate extends AuthController
|
||||
public function syncSubscribe()
|
||||
{
|
||||
if (!sys_config('routine_appId') || !sys_config('routine_appsecret')) {
|
||||
throw new AdminException('请先配置小程序appid、appSecret等参数');
|
||||
throw new AdminException(400236);
|
||||
}
|
||||
$all = $this->services->getTemplateList(['status' => 1, 'type' => 0]);
|
||||
$errData = [];
|
||||
$errMessage = [
|
||||
'-1' => '系统繁忙,此时请稍候再试',
|
||||
'40001' => 'AppSecret错误或者AppSecret不属于这个小程序,请确认AppSecret 的正确性',
|
||||
'40002' => '请确保grant_type字段值为client_credential',
|
||||
'40013' => '不合法的AppID,请检查AppID的正确性,避免异常字符,注意大小写',
|
||||
'40125' => '小程序配置无效,请检查配置',
|
||||
'41002' => '缺少appid参数',
|
||||
'41004' => '缺少secret参数',
|
||||
'43104' => 'appid与openid不匹配',
|
||||
'45009' => '达到微信api每日限额上限',
|
||||
'200011' => '此账号已被封禁,无法操作',
|
||||
'200012' => '个人模版数已达上限,上限25个',
|
||||
'200014' => '请检查小程序所属类目',
|
||||
];
|
||||
$errCode = [-1, 40001, 40002, 40013, 40125, 41002, 41004, 43104, 45009, 200011, 200012, 200014];
|
||||
if ($all['list']) {
|
||||
$time = time();
|
||||
foreach ($all['list'] as $template) {
|
||||
@ -241,8 +72,8 @@ class RoutineTemplate extends AuthController
|
||||
} catch (\Throwable $e) {
|
||||
$wechatErr = $e->getMessage();
|
||||
if (is_string($wechatErr)) throw new AdminException($wechatErr);
|
||||
if (in_array($wechatErr->getCode(), array_keys($errMessage))) {
|
||||
throw new AdminException($errMessage[$wechatErr->getCode()]);
|
||||
if (in_array($wechatErr->getCode(), $errCode)) {
|
||||
throw new AdminException($wechatErr->getCode());
|
||||
}
|
||||
$errData[1] = '获取关键词列表失败:' . $wechatErr->getMessage();
|
||||
}
|
||||
@ -264,8 +95,8 @@ class RoutineTemplate extends AuthController
|
||||
} catch (\Throwable $e) {
|
||||
$wechatErr = $e->getMessage();
|
||||
if (is_string($wechatErr)) throw new AdminException($wechatErr);
|
||||
if (in_array($wechatErr->getCode(), array_keys($errMessage))) {
|
||||
throw new AdminException($errMessage[$wechatErr->getCode()]);
|
||||
if (in_array($wechatErr->getCode(), $errCode)) {
|
||||
throw new AdminException($wechatErr->getCode());
|
||||
}
|
||||
$errData[2] = '添加订阅消息模版失败:' . $wechatErr->getMessage();
|
||||
}
|
||||
@ -290,7 +121,7 @@ class RoutineTemplate extends AuthController
|
||||
['name', ''],
|
||||
['is_live', 0]
|
||||
], true);
|
||||
if (sys_config('routine_appId', '') == '') throw new AdminException('请先配置小程序appId');
|
||||
if (sys_config('routine_appId', '') == '') throw new AdminException(400236);
|
||||
try {
|
||||
@unlink(public_path() . 'statics/download/routine.zip');
|
||||
//拷贝源文件
|
||||
@ -367,6 +198,14 @@ class RoutineTemplate extends AuthController
|
||||
@file_put_contents($newFileUrl, $string); // 写入配置文件
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序码
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getDownloadInfo()
|
||||
{
|
||||
$data['routine_name'] = sys_config('routine_name', '');
|
||||
@ -387,7 +226,7 @@ class RoutineTemplate extends AuthController
|
||||
} else {
|
||||
$res = false;
|
||||
}
|
||||
if (!$res) throw new ValidateException('二维码生成失败');
|
||||
if (!$res) throw new ValidateException(400237);
|
||||
$upload = UploadService::init(1);
|
||||
if ($upload->to('routine/code')->setAuthThumb(false)->stream((string)$res['res'], $name) === false) {
|
||||
return $upload->getError();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,7 +10,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\application\wechat;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\wechat\WechatMenuServices;
|
||||
use think\facade\App;
|
||||
@ -51,8 +50,8 @@ class Menus extends AuthController
|
||||
public function save()
|
||||
{
|
||||
$buttons = request()->post('button/a', []);
|
||||
if (!count($buttons)) return app('json')->fail('请添加至少一个按钮');
|
||||
if (!count($buttons)) return app('json')->fail(400238);
|
||||
$this->services->saveMenu($buttons);
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -36,22 +36,27 @@ class Reply extends AuthController
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**关注回复
|
||||
* @return mixed|void
|
||||
/**
|
||||
* 关注回复
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function reply()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['key', ''],
|
||||
]);
|
||||
if ($where['key'] == '') return app('json')->fail('请输入参数key');
|
||||
if ($where['key'] == '') return app('json')->fail(100100);
|
||||
$info = $this->services->getDataByKey($where['key']);
|
||||
return app('json')->success(compact('info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键字回复列表
|
||||
* */
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
@ -64,7 +69,11 @@ class Reply extends AuthController
|
||||
|
||||
/**
|
||||
* 关键字详情
|
||||
* */
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
$info = $this->services->getKeyInfo($id);
|
||||
@ -73,7 +82,9 @@ class Reply extends AuthController
|
||||
|
||||
/**
|
||||
* 保存关键字
|
||||
* */
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save($id = 0)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
@ -84,19 +95,19 @@ class Reply extends AuthController
|
||||
]);
|
||||
try {
|
||||
if (!isset($data['key']) && empty($data['key']))
|
||||
return app('json')->fail('请输入关键字');
|
||||
return app('json')->fail(400239);
|
||||
if (!isset($data['type']) && empty($data['type']))
|
||||
return app('json')->fail('请选择回复类型');
|
||||
return app('json')->fail(400240);
|
||||
if (!in_array($data['type'], $this->services->replyType()))
|
||||
return app('json')->fail('回复类型有误!');
|
||||
return app('json')->fail(400241);
|
||||
|
||||
if (!isset($data['data']) || !is_array($data['data']))
|
||||
return app('json')->fail('回复消息参数有误!');
|
||||
return app('json')->fail(400242);
|
||||
$res = $this->services->redact($data['data'], $id, $data['key'], $data['type'], $data['status']);
|
||||
if (!$res)
|
||||
return app('json')->fail('保存失败!');
|
||||
return app('json')->fail(100006);
|
||||
else
|
||||
return app('json')->success('保存成功!', $data);
|
||||
return app('json')->success(100000, $data);
|
||||
} catch (HttpException $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
@ -104,20 +115,22 @@ class Reply extends AuthController
|
||||
|
||||
/**
|
||||
* 删除关键字
|
||||
* */
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->services->delete($id)) {
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
} else {
|
||||
/** @var WechatKeyServices $keyServices */
|
||||
$keyServices = app()->make(WechatKeyServices::class);
|
||||
$res = $keyServices->delete($id, 'reply_id');
|
||||
if (!$res) {
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
}
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,9 +141,9 @@ class Reply extends AuthController
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
if ($status == '' || $id == 0) return app('json')->fail(100100);
|
||||
$this->services->update($id, ['status' => $status], 'id');
|
||||
return app('json')->success($status == 0 ? '禁用成功' : '启用成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,13 +157,13 @@ class Reply extends AuthController
|
||||
public function code_reply($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('参数错误');
|
||||
return app('json')->fail('100100');
|
||||
}
|
||||
/** @var QrcodeServices $qrcode */
|
||||
$qrcode = app()->make(QrcodeServices::class);
|
||||
$code = $qrcode->getForeverQrcode('reply', $id);
|
||||
if (!$code['ticket']) {
|
||||
return app('json')->fail('获取二维码失败,请检查是否配置公众号');
|
||||
return app('json')->fail(400237);
|
||||
}
|
||||
return app('json')->success($code->toArray());
|
||||
}
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\application\wechat;
|
||||
|
||||
|
||||
use app\adminapi\business\wechat\WechatMessageBusiness;
|
||||
use app\adminapi\model\wechat\WechatMessage as MessageModel;
|
||||
use app\adminapi\controller\AuthController;
|
||||
|
||||
/**
|
||||
* 用户扫码点击事件
|
||||
* Class SystemMessage
|
||||
* @package app\admin\controller\system
|
||||
*/
|
||||
class WechatMessage extends AuthController
|
||||
{
|
||||
/**
|
||||
* 显示操作记录
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->getMore([
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
['nickname', ''],
|
||||
['type', ''],
|
||||
['data', ''],
|
||||
]);
|
||||
return app('json')->success(app()->make(WechatMessageBusiness::class)->systemPage($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作名称列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function operate()
|
||||
{
|
||||
$operate = app()->make(MessageModel::class)->mold;
|
||||
return app('json')->success(compact('operate'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -11,7 +11,7 @@
|
||||
namespace app\adminapi\controller\v1\application\wechat;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use crmeb\services\WechatService;
|
||||
use crmeb\services\app\WechatService;
|
||||
use think\facade\App;
|
||||
use app\services\wechat\WechatNewsCategoryServices;
|
||||
use app\services\article\ArticleServices;
|
||||
@ -56,9 +56,6 @@ class WechatNewsCategory extends AuthController
|
||||
* 图文详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
@ -79,16 +76,14 @@ class WechatNewsCategory extends AuthController
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或编辑保存
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
@ -99,14 +94,14 @@ class WechatNewsCategory extends AuthController
|
||||
try {
|
||||
$id = [];
|
||||
$countList = count($data['list']);
|
||||
if (!$countList) return app('json')->fail('请添加图文');
|
||||
if (!$countList) return app('json')->fail(400243);
|
||||
/** @var ArticleServices $services */
|
||||
$services = app()->make(ArticleServices::class);
|
||||
foreach ($data['list'] as $k => $v) {
|
||||
if ($v['title'] == '') return app('json')->fail('标题不能为空');
|
||||
if ($v['author'] == '') return app('json')->fail('作者不能为空');
|
||||
if ($v['content'] == '') return app('json')->fail('正文不能为空');
|
||||
if ($v['synopsis'] == '') return app('json')->fail('摘要不能为空');
|
||||
if ($v['title'] == '') return app('json')->fail(400244);
|
||||
if ($v['author'] == '') return app('json')->fail(400245);
|
||||
if ($v['content'] == '') return app('json')->fail(400246);
|
||||
if ($v['synopsis'] == '') return app('json')->fail(400247);
|
||||
$v['status'] = 1;
|
||||
$v['add_time'] = time();
|
||||
if ($v['id']) {
|
||||
@ -124,8 +119,8 @@ class WechatNewsCategory extends AuthController
|
||||
}
|
||||
$countId = count($id);
|
||||
if ($countId != $countList) {
|
||||
if ($data['id']) return app('json')->fail('修改失败');
|
||||
else return app('json')->fail('添加失败');
|
||||
if ($data['id']) return app('json')->fail(100007);
|
||||
else return app('json')->fail(100022);
|
||||
} else {
|
||||
$newsCategory['cate_name'] = $data['list'][0]['title'];
|
||||
$newsCategory['new_id'] = implode(',', $id);
|
||||
@ -134,22 +129,19 @@ class WechatNewsCategory extends AuthController
|
||||
$newsCategory['status'] = 1;
|
||||
if ($data['id']) {
|
||||
$this->services->update($data['id'], $newsCategory, 'id');
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
} else {
|
||||
$this->services->save($newsCategory);
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100021);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
return app('json')->fail(100101);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* @param int $id
|
||||
* @param string $wechat
|
||||
* $wechat 不为空 发消息 / 空 群发消息
|
||||
*/
|
||||
public function push()
|
||||
{
|
||||
@ -157,7 +149,7 @@ class WechatNewsCategory extends AuthController
|
||||
['id', 0],
|
||||
['user_ids', '']
|
||||
]);
|
||||
if (!$data['id']) return app('json')->fail('参数错误');
|
||||
if (!$data['id']) return app('json')->fail(100100);
|
||||
$list = $this->services->getWechatNewsItem($data['id']);
|
||||
$wechatNews = [];
|
||||
if ($list) {
|
||||
@ -187,9 +179,9 @@ class WechatNewsCategory extends AuthController
|
||||
$errorLog[] = $v['nickname'] . '没有关注发送失败(不是微信公众号用户)';
|
||||
}
|
||||
}
|
||||
} else return app('json')->fail('发送失败,参数不正确');
|
||||
if (!count($errorLog)) return app('json')->success('全部发送成功');
|
||||
else return app('json')->success(implode(',', $errorLog) . ',剩余的发送成功');
|
||||
} else return app('json')->fail(100031);
|
||||
if (!count($errorLog)) return app('json')->success(100030);
|
||||
else return app('json')->success(100030);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,14 +1,19 @@
|
||||
<?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\adminapi\controller\v1\application\wechat;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\wechat\WechatQrcodeCateServices;
|
||||
use app\services\wechat\WechatQrcodeRecordServices;
|
||||
use app\services\wechat\WechatQrcodeServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use think\facade\App;
|
||||
|
||||
class WechatQrcode extends AuthController
|
||||
@ -66,7 +71,7 @@ class WechatQrcode extends AuthController
|
||||
['cate_name', '']
|
||||
]);
|
||||
$this->qrcodeCateServices->saveData($data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,7 +82,7 @@ class WechatQrcode extends AuthController
|
||||
public function delCate($id)
|
||||
{
|
||||
$this->qrcodeCateServices->delCate($id);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,7 +103,7 @@ class WechatQrcode extends AuthController
|
||||
['time', 0],
|
||||
]);
|
||||
$this->wechatQrcodeServices->saveQrcode($id, $data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,7 +128,7 @@ class WechatQrcode extends AuthController
|
||||
*/
|
||||
public function qrcodeInfo($id = 0)
|
||||
{
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$info = $this->wechatQrcodeServices->qrcodeInfo($id);
|
||||
return app('json')->success($info);
|
||||
}
|
||||
@ -135,9 +140,9 @@ class WechatQrcode extends AuthController
|
||||
*/
|
||||
public function delQrcode($id = 0)
|
||||
{
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->wechatQrcodeServices->update($id, ['is_del' => 1]);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,9 +153,9 @@ class WechatQrcode extends AuthController
|
||||
*/
|
||||
public function setStatus($id, $status)
|
||||
{
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->wechatQrcodeServices->update($id, ['status' => $status]);
|
||||
return app('json')->success('设置成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,4 +185,4 @@ class WechatQrcode extends AuthController
|
||||
$where['qid'] = $qid;
|
||||
return app('json')->success($this->qrcodeRecordServices->qrcodeStatistic($where, $time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -13,13 +13,8 @@ namespace app\adminapi\controller\v1\application\wechat;
|
||||
use app\adminapi\controller\AuthController;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use app\services\message\TemplateMessageServices;
|
||||
use crmeb\services\{
|
||||
FormBuilder as Form, template\Template, WechatService
|
||||
};
|
||||
use crmeb\services\app\WechatService;
|
||||
use think\facade\App;
|
||||
use think\facade\Route as Url;
|
||||
use think\Request;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 微信模板消息
|
||||
@ -28,8 +23,6 @@ use think\facade\Cache;
|
||||
*/
|
||||
class WechatTemplate extends AuthController
|
||||
{
|
||||
protected $cacheTag = '_system_wechat';
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* WechatTemplate constructor.
|
||||
@ -42,166 +35,6 @@ class WechatTemplate extends AuthController
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['name', ''],
|
||||
['status', '']
|
||||
]);
|
||||
$where['type'] = 1;
|
||||
$data = $this->services->getTemplateList($where);
|
||||
$industry = Cache::tag($this->cacheTag)->remember('_wechat_industry', function () {
|
||||
try {
|
||||
$cache = (new Template('wechat'))->getIndustry();
|
||||
if (!$cache){
|
||||
$cache = (new Template('wechat'))->getIndustry();
|
||||
}
|
||||
Cache::tag($this->cacheTag, ['_wechat_industry']);
|
||||
return $cache->toArray();
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}, 0) ?: [];
|
||||
!is_array($industry) && $industry = [];
|
||||
$industry['primary_industry'] = isset($industry['primary_industry']) ? $industry['primary_industry']['first_class'] . ' | ' . $industry['primary_industry']['second_class'] : '未选择';
|
||||
$industry['secondary_industry'] = isset($industry['secondary_industry']) ? $industry['secondary_industry']['first_class'] . ' | ' . $industry['secondary_industry']['second_class'] : '未选择';
|
||||
$lst = array(
|
||||
'industry' => $industry,
|
||||
'count' => $data['count'],
|
||||
'list' => $data['list']
|
||||
);
|
||||
return app('json')->success($lst);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$f = array();
|
||||
$f[] = Form::input('tempkey', '模板编号');
|
||||
$f[] = Form::input('tempid', '模板ID');
|
||||
$f[] = Form::input('name', '模板名');
|
||||
$f[] = Form::input('content', '回复内容')->type('textarea');
|
||||
$f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
||||
return app('json')->success(create_form('添加模板消息', $f, Url::buildUrl('/app/wechat/template'), 'POST'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
'tempkey',
|
||||
'tempid',
|
||||
'name',
|
||||
'content',
|
||||
['status', 0],
|
||||
['type', 1]
|
||||
]);
|
||||
if ($data['tempkey'] == '') return app('json')->fail('请输入模板编号');
|
||||
if ($data['tempkey'] != '' && $this->services->getOne(['tempkey' => $data['tempkey']]))
|
||||
return app('json')->fail('请输入模板编号已存在,请重新输入');
|
||||
if ($data['tempid'] == '') return app('json')->fail('请输入模板ID');
|
||||
if ($data['name'] == '') return app('json')->fail('请输入模板名');
|
||||
if ($data['content'] == '') return app('json')->fail('请输入回复内容');
|
||||
$data['add_time'] = time();
|
||||
$this->services->save($data);
|
||||
return app('json')->success('添加模板消息成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
$product = $this->services->get($id);
|
||||
if (!$product) return app('json')->fail('数据不存在!');
|
||||
$f = array();
|
||||
$f[] = Form::input('tempkey', '模板编号', $product->getData('tempkey'))->disabled(1);
|
||||
$f[] = Form::input('name', '模板名', $product->getData('name'))->disabled(1);
|
||||
$f[] = Form::input('tempid', '模板ID', $product->getData('tempid'));
|
||||
$f[] = Form::radio('status', '状态', $product->getData('status'))->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
||||
return app('json')->success(create_form('编辑模板消息', $f, Url::buildUrl('/app/wechat/template/' . $id), 'PUT'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
'tempid',
|
||||
['status', 0],
|
||||
['type', 1]
|
||||
]);
|
||||
if ($data['tempid'] == '') return app('json')->fail('请输入模板ID');
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
$product = $this->services->get($id);
|
||||
if (!$product) return app('json')->fail('数据不存在!');
|
||||
$this->services->update($id, $data, 'id');
|
||||
return app('json')->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在!');
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
else
|
||||
return app('json')->success('删除成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
$this->services->update($id, ['status' => $status], 'id');
|
||||
return app('json')->success($status == 0 ? '关闭成功' : '开启成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步微信模版消息
|
||||
* @return mixed
|
||||
@ -212,12 +45,9 @@ class WechatTemplate extends AuthController
|
||||
public function syncSubscribe()
|
||||
{
|
||||
if (!sys_config('wechat_appid') || !sys_config('wechat_appsecret')) {
|
||||
throw new AdminException('请先配置微信公众号appid、appSecret等参数');
|
||||
throw new AdminException(400248);
|
||||
}
|
||||
$tempall = $this->services->getTemplateList(['status' => 1, 'type' => 1]);
|
||||
/*
|
||||
* 删除所有模版ID
|
||||
*/
|
||||
//获取微信平台已经添加的模版
|
||||
$list = WechatService::getPrivateTemplates();//获取所有模版
|
||||
foreach ($list->template_list as $v)
|
||||
@ -230,33 +60,10 @@ class WechatTemplate extends AuthController
|
||||
{
|
||||
//添加模版消息
|
||||
$res = WechatService::addTemplateId($temp['tempkey']);
|
||||
// if($temp['tempid'])
|
||||
// {
|
||||
// //删除已有模版
|
||||
// WechatService::deleleTemplate($temp['tempid']);
|
||||
// }
|
||||
if(!$res->errcode && $res->template_id){
|
||||
$this->services->update($temp['id'],['tempid'=>$res->template_id]);
|
||||
}
|
||||
}
|
||||
return app('json')->success('模版消息一键设置成功');
|
||||
|
||||
/**
|
||||
* 批量修改模版格式
|
||||
*/
|
||||
//获取所有模版
|
||||
// $list = WechatService::getPrivateTemplates();//获取所有模版
|
||||
//
|
||||
// foreach ($tempall['list'] as $v)
|
||||
// {
|
||||
// foreach ($list->template_list as $item)
|
||||
// {
|
||||
// echo $item['template_id'];
|
||||
// if ($item['template_id'] == $v['tempid']) {
|
||||
// $this->services->update($v['id'], ['content'=>'']);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
return app('json')->success(400249);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,399 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\application\wechat;
|
||||
|
||||
use app\adminapi\business\wechat\WechatUserBusiness;
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\adminapi\model\order\StoreOrder;
|
||||
use app\adminapi\model\user\{User, UserBill};
|
||||
use app\models\wechat\WechatUser as UserModel;
|
||||
use crmeb\services\{FormBuilder as Form, WechatService};
|
||||
use think\Collection;
|
||||
use think\facade\Route as Url;
|
||||
|
||||
/**
|
||||
* 微信用户管理
|
||||
* Class WechatUser
|
||||
* @package app\admin\controller\wechat
|
||||
*/
|
||||
class WechatUser extends AuthController
|
||||
|
||||
{
|
||||
/**
|
||||
* 显示操作记录
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
['nickname', ''],
|
||||
['data', ''],
|
||||
['tagid_list', ''],
|
||||
['groupid', '-1'],
|
||||
['sex', ''],
|
||||
['export', ''],
|
||||
['subscribe', '']
|
||||
]);
|
||||
$tagidList = explode(',', $where['tagid_list']);
|
||||
foreach ($tagidList as $k => $v) {
|
||||
if (!$v) {
|
||||
unset($tagidList[$k]);
|
||||
}
|
||||
}
|
||||
$tagidList = array_unique($tagidList);
|
||||
$where['tagid_list'] = implode(',', $tagidList);
|
||||
//TODO 没找到 WechatUserBusiness
|
||||
$list = app()->make(WechatUserBusiness::class)->systemPage($where);
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标签和分组
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_tag_group()
|
||||
{
|
||||
try {
|
||||
$groupList = UserModel::getUserGroup();
|
||||
$tagList = UserModel::getUserTag();
|
||||
} catch (\Exception $e) {
|
||||
$groupList = [];
|
||||
$tagList = [];
|
||||
}
|
||||
return app('json')->success(compact('groupList', 'tagList'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户标签表单
|
||||
* @param $openid
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function edit_user_tag($openid)
|
||||
{
|
||||
if (!$openid) return app('json')->fail('参数错误!');
|
||||
$list = Collection::make(UserModel::getUserTag())->each(function ($item) {
|
||||
return ['value' => $item['id'], 'label' => $item['name']];
|
||||
});
|
||||
$tagList = UserModel::where('openid', $openid)->value('tagid_list');
|
||||
|
||||
$tagList = explode(',', $tagList) ?: [];
|
||||
$f = [Form::select('tag_id', '用户标签', $tagList)->setOptions($list->toArray())->multiple(1)];
|
||||
return app('json')->success(create_form('编辑用户标签', $f, Url::buildUrl('/app/wechat/user_tag/' . $openid), 'PUT'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户标签
|
||||
* @param $openid
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_user_tag($openid)
|
||||
{
|
||||
if (!$openid) return app('json')->fail('参数错误!');
|
||||
$tagId = request()->post('tag_id/a', []);
|
||||
if (!$tagId) return app('json')->fail('请选择用户标签!');
|
||||
$tagList = explode(',', UserModel::where('openid', $openid)->value('tagid_list')) ?: [];
|
||||
UserModel::edit(['tagid_list' => $tagId], $openid, 'openid');
|
||||
if (!$tagId[0]) unset($tagId[0]);
|
||||
UserModel::edit(['tagid_list' => $tagId], $openid, 'openid');
|
||||
try {
|
||||
foreach ($tagList as $tag) {
|
||||
if ($tag) WechatService::userTagService()->batchUntagUsers([$openid], $tag);
|
||||
}
|
||||
foreach ($tagId as $tag) {
|
||||
WechatService::userTagService()->batchTagUsers([$openid], $tag);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
UserModel::rollbackTrans();
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
UserModel::commitTrans();
|
||||
return app('json')->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户分组表单
|
||||
* @param $openid
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function edit_user_group($openid)
|
||||
{
|
||||
if (!$openid) return app('json')->fail('参数错误!');
|
||||
$list = Collection::make(UserModel::getUserGroup())->each(function ($item) {
|
||||
return ['value' => $item['id'], 'label' => $item['name']];
|
||||
});
|
||||
$groupId = UserModel::where('openid', $openid)->value('groupid');
|
||||
$f = [Form::select('group_id', '用户分组', (string)$groupId)->setOptions($list->toArray())];
|
||||
return app('json')->success(create_form('编辑用户标签', $f, Url::buildUrl('/app/wechat/user_group/' . $openid), 'PUT'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户分组
|
||||
* @param $openid
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_user_group($openid)
|
||||
{
|
||||
if (!$openid) return app('json')->fail('参数错误!');
|
||||
$groupId = request()->post('group_id');
|
||||
// if(!$groupId) return app('json')->fail('请选择用户分组!');
|
||||
UserModel::beginTrans();
|
||||
UserModel::edit(['groupid' => $groupId], $openid, 'openid');
|
||||
try {
|
||||
WechatService::userGroupService()->moveUser($openid, $groupId);
|
||||
} catch (\Exception $e) {
|
||||
UserModel::rollbackTrans();
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
UserModel::commitTrans();
|
||||
return app('json')->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户标签列表
|
||||
*/
|
||||
public function tag($refresh = 0)
|
||||
{
|
||||
$list = [];
|
||||
if ($refresh == 1) {
|
||||
UserModel::clearUserTag();
|
||||
$this->redirect(Url::buildUrl('tag'));
|
||||
}
|
||||
try {
|
||||
$list = UserModel::getUserTag();
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
return app('json')->success(compact('list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加标签表单
|
||||
* @return mixed
|
||||
*/
|
||||
public function create_tag()
|
||||
{
|
||||
$f = [Form::input('name', '标签名称')];
|
||||
return app('json')->success(create_form('添加标签', $f, Url::buildUrl('/app/wechat/tag'), 'POST'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function save_tag()
|
||||
{
|
||||
$tagName = request()->post('name');
|
||||
if (!$tagName) return app('json')->fail('请输入标签名称!');
|
||||
try {
|
||||
WechatService::userTagService()->create($tagName);
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
UserModel::clearUserTag();
|
||||
return app('json')->success('添加标签成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改标签表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit_tag($id)
|
||||
{
|
||||
$f = [Form::input('name', '标签名称')];
|
||||
return app('json')->success(create_form('编辑标签', $f, Url::buildUrl('/app/wechat/tag/' . $id), 'PUT'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改标签
|
||||
* @param $id
|
||||
*/
|
||||
public function update_tag($id)
|
||||
{
|
||||
$tagName = request()->post('name');
|
||||
if (!$tagName) return app('json')->fail('请输入标签名称!');
|
||||
try {
|
||||
WechatService::userTagService()->update($id, $tagName);
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
UserModel::clearUserTag();
|
||||
return app('json')->success('修改标签成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete_tag($id)
|
||||
{
|
||||
try {
|
||||
WechatService::userTagService()->delete($id);
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
UserModel::clearUserTag();
|
||||
return app('json')->success('删除标签成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户分组列表
|
||||
*/
|
||||
|
||||
public function group($refresh = 0)
|
||||
{
|
||||
$list = [];
|
||||
try {
|
||||
if ($refresh == 1) {
|
||||
UserModel::clearUserGroup();
|
||||
$this->redirect(Url::buildUrl('group'));
|
||||
}
|
||||
$list = UserModel::getUserGroup();
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
return app('json')->success(compact('list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分组表单
|
||||
* @return mixed
|
||||
*/
|
||||
public function create_group()
|
||||
{
|
||||
$f = [Form::input('name', '分组名称')];
|
||||
return app('json')->success(create_form('添加分组', $f, Url::buildUrl('/app/wechat/group'), 'POST'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function save_group()
|
||||
{
|
||||
$tagName = request()->post('name');
|
||||
if (!$tagName) return app('json')->fail('请输入分组名称!');
|
||||
try {
|
||||
WechatService::userGroupService()->create($tagName);
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
UserModel::clearUserGroup();
|
||||
return app('json')->success('添加分组成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分组表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit_group($id)
|
||||
{
|
||||
$f = [Form::input('name', '分组名称')];
|
||||
return app('json')->success(create_form('编辑分组', $f, Url::buildUrl('/app/wechat/group/' . $id), 'PUT'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分组
|
||||
* @param $id
|
||||
*/
|
||||
public function update_group($id)
|
||||
{
|
||||
$tagName = request()->post('name');
|
||||
if (!$tagName) return app('json')->fail('请输入分组名称!');
|
||||
try {
|
||||
WechatService::userGroupService()->update($id, $tagName);
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
UserModel::clearUserGroup();
|
||||
return app('json')->success('修改分组成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分组
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete_group($id)
|
||||
{
|
||||
try {
|
||||
WechatService::userTagService()->delete($id);
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
UserModel::clearUserGroup();
|
||||
return app('json')->success('删除分组成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步标签
|
||||
* @param $openid
|
||||
* @return mixed
|
||||
*/
|
||||
public function syn_tag($openid)
|
||||
{
|
||||
if (!$openid) return app('json')->fail('参数错误!');
|
||||
$data = array();
|
||||
if (UserModel::be($openid, 'openid')) {
|
||||
try {
|
||||
$tag = WechatService::userTagService()->userTags($openid)->toArray();
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
if ($tag['tagid_list']) $data['tagid_list'] = implode(',', $tag['tagid_list']);
|
||||
else $data['tagid_list'] = '';
|
||||
$res = UserModel::edit($data, $openid, 'openid');
|
||||
if ($res) return app('json')->success('同步成功');
|
||||
else return app('json')->fail('同步失败!');
|
||||
} else return app('json')->fail('参数错误!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 一级推荐人页面
|
||||
* @return mixed
|
||||
*/
|
||||
public function stair($uid = '')
|
||||
{
|
||||
if ($uid == '') return app('json')->fail('参数错误');
|
||||
$list = (new User())->alias('u')
|
||||
->where('u.spread_uid', $uid)
|
||||
->field('u.avatar,u.nickname,u.now_money,u.add_time,u.uid')
|
||||
->where('u.status', 1)
|
||||
->order('u.add_time DESC')
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($list as $key => $value) $list[$key]['orderCount'] = (new StoreOrder())->getOrderCount($value['uid']);
|
||||
return app('json')->success(compact('list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人资金详情页面
|
||||
* @return mixed
|
||||
*/
|
||||
public function now_money($uid = '')
|
||||
{
|
||||
if ($uid == '') return app('json')->fail('参数错误');
|
||||
$list = (new UserBill())->where('uid', $uid)->where('category', 'now_money')
|
||||
->field('mark,pm,number,add_time')
|
||||
->where('status', 1)->order('add_time DESC')->select()->toArray();
|
||||
foreach ($list as &$v) {
|
||||
$v['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
|
||||
}
|
||||
return app('json')->success(compact('list'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -74,39 +74,31 @@ class Article extends AuthController
|
||||
['status', 1]
|
||||
]);
|
||||
$this->service->save($data);
|
||||
return app('json')->success('添加成功!');
|
||||
return app('json')->success(100021);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个文章数据
|
||||
* @param $id
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function read($id)
|
||||
public function read($id = 0)
|
||||
{
|
||||
if ($id) {
|
||||
$info = $this->service->read($id);
|
||||
return app('json')->success($info);
|
||||
} else {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$info = $this->service->read($id);
|
||||
return app('json')->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章
|
||||
* @param $id
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete($id)
|
||||
public function delete($id = 0)
|
||||
{
|
||||
if ($id) {
|
||||
$this->service->del($id);
|
||||
return app('json')->success('删除成功!');
|
||||
} else {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->service->del($id);
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,15 +108,15 @@ class Article extends AuthController
|
||||
*/
|
||||
public function relation($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
list($product_id) = $this->request->postMore([
|
||||
['product_id', 0]
|
||||
], true);
|
||||
$res = $this->service->bindProduct($id, $product_id);
|
||||
if ($res) {
|
||||
return app('json')->success('关联成功');
|
||||
return app('json')->success(400300);
|
||||
} else {
|
||||
return app('json')->fail('关联失败');
|
||||
return app('json')->fail(400301);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,12 +127,12 @@ class Article extends AuthController
|
||||
*/
|
||||
public function unrelation($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$res = $this->service->bindProduct($id);
|
||||
if ($res) {
|
||||
return app('json')->success('取消关联成功!');
|
||||
return app('json')->success(100019);
|
||||
} else {
|
||||
return app('json')->fail('取消失败');
|
||||
return app('json')->fail(100020);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\cms;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -23,8 +22,16 @@ use think\facade\App;
|
||||
*/
|
||||
class ArticleCategory extends AuthController
|
||||
{
|
||||
/**
|
||||
* @var ArticleCategoryServices
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
/**
|
||||
* ArticleCategory constructor.
|
||||
* @param App $app
|
||||
* @param ArticleCategoryServices $service
|
||||
*/
|
||||
public function __construct(App $app, ArticleCategoryServices $service)
|
||||
{
|
||||
parent::__construct($app);
|
||||
@ -62,6 +69,7 @@ class ArticleCategory extends AuthController
|
||||
/**
|
||||
* 保存新建分类
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
@ -74,22 +82,23 @@ class ArticleCategory extends AuthController
|
||||
['status', 0]
|
||||
]);
|
||||
if (!$data['title']) {
|
||||
return app('json')->fail('请填写分类名称');
|
||||
return app('json')->fail(400100);
|
||||
}
|
||||
$data['add_time'] = time();
|
||||
$this->service->save($data);
|
||||
CacheService::delete('ARTICLE_CATEGORY');
|
||||
return app('json')->success('添加分类成功!');
|
||||
return app('json')->success(100021);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建修改表单
|
||||
* @param $id
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit($id = 0)
|
||||
{
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->service->createForm($id));
|
||||
}
|
||||
|
||||
@ -97,6 +106,7 @@ class ArticleCategory extends AuthController
|
||||
* 保存修改分类
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
@ -111,19 +121,21 @@ class ArticleCategory extends AuthController
|
||||
]);
|
||||
$this->service->update($data);
|
||||
CacheService::delete('ARTICLE_CATEGORY');
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章分类
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->service->del($id);
|
||||
CacheService::delete('ARTICLE_CATEGORY');
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,10 +147,10 @@ class ArticleCategory extends AuthController
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
if ($status == '' || $id == 0) return app('json')->fail(100100);
|
||||
$this->service->setStatus($id, $status);
|
||||
CacheService::delete('ARTICLE_CATEGORY');
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,16 +2,14 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\diy;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\activity\bargain\StoreBargainServices;
|
||||
use app\services\activity\combination\StoreCombinationServices;
|
||||
@ -22,13 +20,19 @@ use app\services\other\CacheServices;
|
||||
use app\services\product\product\StoreCategoryServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\services\FileService;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class Diy
|
||||
* @package app\controller\admin\v1\diy
|
||||
*/
|
||||
class Diy extends AuthController
|
||||
{
|
||||
protected $services;
|
||||
|
||||
/**
|
||||
* @param App $app
|
||||
* @param DiyServices $services
|
||||
*/
|
||||
public function __construct(App $app, DiyServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
@ -56,7 +60,7 @@ class Diy extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存资源
|
||||
* 保存可视化编辑资源
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*/
|
||||
@ -76,7 +80,7 @@ class Diy extends AuthController
|
||||
if (isset($v['goodsList']['list']) && $v['goodsList']['list'] && $v['tabConfig']['tabVal'] == 1) {
|
||||
$limitMax = config('database.page.limitMax', 50);
|
||||
if (count($v['goodsList']['list']) > $limitMax) {
|
||||
return app('json')->fail('您设置得商品个数超出系统限制,最大限制' . $limitMax . '个商品');
|
||||
return app('json')->fail(400350);
|
||||
}
|
||||
$v['ids'] = array_column($v['goodsList']['list'], 'id');
|
||||
$v['goodsList']['list'] = [];
|
||||
@ -86,7 +90,7 @@ class Diy extends AuthController
|
||||
}
|
||||
$data['value'] = json_encode($value);
|
||||
$this->services->saveData($id, $data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,7 +124,7 @@ class Diy extends AuthController
|
||||
if (isset($item['goodsList']['list']) && is_array($item['goodsList']['list'])) {
|
||||
$limitMax = config('database.page.limitMax', 50);
|
||||
if (isset($item['numConfig']['val']) && isset($item['tabConfig']['tabVal']) && $item['tabConfig']['tabVal'] == 0 && $item['numConfig']['val'] > $limitMax) {
|
||||
return app('json')->fail('您设置得商品个数超出系统限制,最大限制' . $limitMax . '个商品');
|
||||
return app('json')->fail(400350);
|
||||
}
|
||||
$item['goodsList']['ids'] = array_column($item['goodsList']['list'], 'id');
|
||||
unset($item['goodsList']['list']);
|
||||
@ -140,7 +144,7 @@ class Diy extends AuthController
|
||||
} elseif (isset($value['d_goodList']['goodsList']['list'])) {
|
||||
$limitMax = config('database.page.limitMax', 50);
|
||||
if (isset($value['d_goodList']['numConfig']['val']) && isset($value['d_goodList']['tabConfig']['tabVal']) && $value['d_goodList']['tabConfig']['tabVal'] == 0 && $value['d_goodList']['numConfig']['val'] > $limitMax) {
|
||||
return app('json')->fail('您设置得商品个数超出系统限制,最大限制' . $limitMax . '个商品');
|
||||
return app('json')->fail(400350);
|
||||
}
|
||||
$value['d_goodList']['goodsList']['ids'] = array_column($value['d_goodList']['goodsList']['list'], 'id');
|
||||
unset($value['d_goodList']['goodsList']['list']);
|
||||
@ -165,7 +169,7 @@ class Diy extends AuthController
|
||||
$data['version'] = '1.0';
|
||||
$data['type'] = 2;
|
||||
$data['is_diy'] = 1;
|
||||
return app('json')->success($id ? '修改成功' : '保存成功', ['id' => $this->services->saveData($id, $data)]);
|
||||
return app('json')->success($id ? 100001 : 100000, ['id' => $this->services->saveData($id, $data)]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,7 +180,7 @@ class Diy extends AuthController
|
||||
public function del($id)
|
||||
{
|
||||
$this->services->del($id);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,32 +190,30 @@ class Diy extends AuthController
|
||||
*/
|
||||
public function setStatus($id)
|
||||
{
|
||||
// $name = $this->services->value(['id' => $id], 'template_name');
|
||||
// if (!is_file(public_path('template') . $name . '.zip')) {
|
||||
// throw new AdminException('请上传模板压缩包');
|
||||
// }
|
||||
// FileService::delDir(runtime_path('wap'));
|
||||
// FileService::delDir(public_path('pages'));
|
||||
// FileService::delDir(public_path('static'));
|
||||
// @unlink(public_path() . 'index.html');
|
||||
$this->services->setStatus($id);
|
||||
// FileService::zipOpen(public_path('template') . $name . '.zip', public_path());
|
||||
return app('json')->success('设置成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一条数据
|
||||
* @param int $id
|
||||
* @param StoreProductServices $services
|
||||
* @param StoreSeckillServices $seckillServices
|
||||
* @param StoreCombinationServices $combinationServices
|
||||
* @param StoreBargainServices $bargainServices
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getInfo(int $id, StoreProductServices $services, StoreSeckillServices $seckillServices, StoreCombinationServices $combinationServices, StoreBargainServices $bargainServices)
|
||||
{
|
||||
if (!$id) throw new AdminException('参数错误');
|
||||
if (!$id) throw new AdminException(100100);
|
||||
$info = $this->services->get($id);
|
||||
if ($info) {
|
||||
$info = $info->toArray();
|
||||
} else {
|
||||
throw new AdminException('模板不存在');
|
||||
throw new AdminException(400351);
|
||||
}
|
||||
if (!$info['value']) return app('json')->success(compact('info'));
|
||||
$info['value'] = json_decode($info['value'], true);
|
||||
@ -263,12 +265,12 @@ class Diy extends AuthController
|
||||
*/
|
||||
public function getDiyInfo($id, StoreProductServices $services)
|
||||
{
|
||||
if (!$id) throw new AdminException('参数错误');
|
||||
if (!$id) throw new AdminException(100100);
|
||||
$info = $this->services->get($id);
|
||||
if ($info) {
|
||||
$info = $info->toArray();
|
||||
} else {
|
||||
throw new AdminException('模板不存在');
|
||||
throw new AdminException(400351);
|
||||
}
|
||||
$info['value'] = json_decode($info['value'], true);
|
||||
if ($info['value']) {
|
||||
@ -300,13 +302,11 @@ class Diy extends AuthController
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($info['value']) {
|
||||
if (isset($info['value']['d_goodList']['goodsList'])) {
|
||||
$info['value']['d_goodList']['goodsList']['list'] = [];
|
||||
}
|
||||
if (isset($info['value']['d_goodList']['goodsList']['ids']) && count($info['value']['d_goodList']['goodsList']['ids'])) {
|
||||
$info['value']['d_goodList']['goodsList']['list'] = $services->getSearchList(['ids' => $info['value']['d_goodList']['goodsList']['ids']]);
|
||||
}
|
||||
if (isset($info['value']['d_goodList']['goodsList'])) {
|
||||
$info['value']['d_goodList']['goodsList']['list'] = [];
|
||||
}
|
||||
if (isset($info['value']['d_goodList']['goodsList']['ids']) && count($info['value']['d_goodList']['goodsList']['ids'])) {
|
||||
$info['value']['d_goodList']['goodsList']['list'] = $services->getSearchList(['ids' => $info['value']['d_goodList']['goodsList']['ids']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -377,14 +377,6 @@ class Diy extends AuthController
|
||||
/** @var StoreCategoryServices $categoryService */
|
||||
$categoryService = app()->make(StoreCategoryServices::class);
|
||||
$list = $categoryService->cascaderList(1, 1);
|
||||
// $list = $categoryService->getTierList(1, 1);
|
||||
// $data = [];
|
||||
// foreach ($list as $value) {
|
||||
// $data[] = [
|
||||
// 'id' => $value['id'],
|
||||
// 'title' => $value['html'] . $value['cate_name']
|
||||
// ];
|
||||
// }
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
@ -433,15 +425,15 @@ class Diy extends AuthController
|
||||
*/
|
||||
public function Recovery($id)
|
||||
{
|
||||
if (!$id) throw new AdminException('参数错误');
|
||||
if (!$id) throw new AdminException(100100);
|
||||
$info = $this->services->get($id);
|
||||
if ($info) {
|
||||
$info->value = $info->default_value;
|
||||
$info->update_time = time();
|
||||
$info->save();
|
||||
return app('json')->success('还原成功');
|
||||
return app('json')->success(100014);
|
||||
} else {
|
||||
throw new AdminException('模板不存在');
|
||||
throw new AdminException(400351);
|
||||
}
|
||||
}
|
||||
|
||||
@ -463,6 +455,7 @@ class Diy extends AuthController
|
||||
/**
|
||||
* 添加页面
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@ -478,13 +471,13 @@ class Diy extends AuthController
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
]);
|
||||
if (!$data['name']) throw new AdminException('请输入页面名称');
|
||||
if (!$data['name']) app('json')->fail(400352);
|
||||
$data['version'] = '1.0';
|
||||
$data['add_time'] = time();
|
||||
$data['type'] = 0;
|
||||
$data['is_diy'] = 1;
|
||||
$this->services->save($data);
|
||||
return app('json')->success('保存成功!');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -494,21 +487,24 @@ class Diy extends AuthController
|
||||
*/
|
||||
public function setRecovery($id)
|
||||
{
|
||||
if (!$id) throw new AdminException('参数错误');
|
||||
if (!$id) throw new AdminException(100100);
|
||||
$info = $this->services->get($id);
|
||||
if ($info) {
|
||||
$info->default_value = $info->value;
|
||||
$info->update_time = time();
|
||||
$info->save();
|
||||
return app('json')->success('设置成功');
|
||||
return app('json')->success(100014);
|
||||
} else {
|
||||
throw new AdminException('模板不存在');
|
||||
throw new AdminException(100026);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getProductList()
|
||||
{
|
||||
@ -552,15 +548,15 @@ class Diy extends AuthController
|
||||
*/
|
||||
public function colorChange($status, $type)
|
||||
{
|
||||
if (!$status) throw new AdminException('参数错误');
|
||||
if (!$status) throw new AdminException(100100);
|
||||
$info = $this->services->get(['template_name' => $type, 'type' => 1]);
|
||||
if ($info) {
|
||||
$info->value = $status;
|
||||
$info->update_time = time();
|
||||
$info->save();
|
||||
return app('json')->success('设置成功');
|
||||
return app('json')->success(100014);
|
||||
} else {
|
||||
throw new AdminException('模板不存在');
|
||||
throw new AdminException(100026);
|
||||
}
|
||||
}
|
||||
|
||||
@ -577,6 +573,9 @@ class Diy extends AuthController
|
||||
/**
|
||||
* 保存个人中心数据
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function memberSaveData()
|
||||
{
|
||||
@ -588,7 +587,7 @@ class Diy extends AuthController
|
||||
['routine_my_menus', []]
|
||||
]);
|
||||
$this->services->memberSaveData($data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -629,7 +628,7 @@ class Diy extends AuthController
|
||||
/** @var CacheServices $cacheServices */
|
||||
$cacheServices = app()->make(CacheServices::class);
|
||||
$cacheServices->setDbCache('open_adv', $data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
namespace app\adminapi\controller\v1\diy;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\diy\DiyServices;
|
||||
use app\services\diy\PageCategoryServices;
|
||||
@ -53,10 +52,10 @@ class PageLink extends AuthController
|
||||
*/
|
||||
public function getLinks($cate_id, PageCategoryServices $pageCategoryServices)
|
||||
{
|
||||
if (!$cate_id) return app('json')->fail('缺少参数');
|
||||
if (!$cate_id) return app('json')->fail(100100);
|
||||
$category = $pageCategoryServices->get((int)$cate_id);
|
||||
if (!$category) {
|
||||
return app('json')->fail('页面分类不存在');
|
||||
return app('json')->fail(400103);
|
||||
}
|
||||
switch ($category['type']) {
|
||||
case 'special':
|
||||
@ -88,17 +87,17 @@ class PageLink extends AuthController
|
||||
['name', ''],
|
||||
['url', '']
|
||||
]);
|
||||
if (!$cate_id || !$data['name'] || !$data['url']) return app('json')->fail('缺少参数');
|
||||
if (!$cate_id || !$data['name'] || !$data['url']) return app('json')->fail(100100);
|
||||
$category = $pageCategoryServices->get((int)$cate_id);
|
||||
if (!$category) {
|
||||
return app('json')->fail('页面分类不存在');
|
||||
return app('json')->fail(400103);
|
||||
}
|
||||
$data['cate_id'] = $cate_id;
|
||||
$data['add_time'] = time();
|
||||
if (!$this->services->save($data)) {
|
||||
return app('json')->fail('添加失败');
|
||||
return app('json')->fail(100022);
|
||||
}
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100021);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,9 +107,9 @@ class PageLink extends AuthController
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->services->del($id);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -125,6 +125,9 @@ class ExportExcel extends AuthController
|
||||
* 分销管理 用户推广
|
||||
* @param AgentManageServices $services
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function userAgent(AgentManageServices $services)
|
||||
{
|
||||
@ -138,7 +141,7 @@ class ExportExcel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信用户导出
|
||||
* 微信用户导出(弃用)
|
||||
* @param WechatUserServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
@ -184,7 +187,7 @@ class ExportExcel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 商铺拼团导出
|
||||
* 拼团导出
|
||||
* @param StoreCombinationServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
@ -220,7 +223,7 @@ class ExportExcel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 商铺秒杀导出
|
||||
* 秒杀导出
|
||||
* @param StoreSeckillServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
@ -236,7 +239,7 @@ class ExportExcel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 商铺产品导出
|
||||
* 产品导出
|
||||
* @param StoreProductServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
@ -280,7 +283,11 @@ class ExportExcel extends AuthController
|
||||
|
||||
/**
|
||||
* 获取提货点
|
||||
* @param SystemStoreServices $services
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function storeMerchant(SystemStoreServices $services)
|
||||
{
|
||||
@ -292,7 +299,8 @@ class ExportExcel extends AuthController
|
||||
return app('json')->success($this->service->storeMerchant($data));
|
||||
}
|
||||
|
||||
/**会员卡导出
|
||||
/**
|
||||
* 会员卡导出
|
||||
* @param int $id
|
||||
* @param MemberCardServices $services
|
||||
* @return mixed
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -15,14 +15,21 @@ use app\services\system\attachment\SystemAttachmentServices;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 图片管理类
|
||||
* 附件管理类
|
||||
* Class SystemAttachment
|
||||
* @package app\adminapi\controller\v1\file
|
||||
*/
|
||||
class SystemAttachment extends AuthController
|
||||
{
|
||||
/**
|
||||
* @var SystemAttachmentServices
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
/**
|
||||
* @param App $app
|
||||
* @param SystemAttachmentServices $service
|
||||
*/
|
||||
public function __construct(App $app, SystemAttachmentServices $service)
|
||||
{
|
||||
parent::__construct($app);
|
||||
@ -43,9 +50,7 @@ class SystemAttachment extends AuthController
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param string $ids
|
||||
* @return \think\Response
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
@ -53,7 +58,7 @@ class SystemAttachment extends AuthController
|
||||
['ids', '']
|
||||
], true);
|
||||
$this->service->del($ids);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +75,7 @@ class SystemAttachment extends AuthController
|
||||
['menu_name', '']
|
||||
], true);
|
||||
$res = $this->service->upload((int)$pid, $file, $upload_type, $type, $menuName);
|
||||
return app('json')->success('上传成功', ['src' => $res]);
|
||||
return app('json')->success(100032, ['src' => $res]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +89,7 @@ class SystemAttachment extends AuthController
|
||||
['images', '']
|
||||
]);
|
||||
$this->service->move($data);
|
||||
return app('json')->success('移动成功');
|
||||
return app('json')->success(100034);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,10 +101,10 @@ class SystemAttachment extends AuthController
|
||||
{
|
||||
$realName = $this->request->post('real_name', '');
|
||||
if (!$realName) {
|
||||
return app('json')->fail('文件名称不能为空');
|
||||
return app('json')->fail(400104);
|
||||
}
|
||||
$this->service->update($id, ['real_name' => $realName]);
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -21,9 +21,15 @@ use think\facade\App;
|
||||
*/
|
||||
class SystemAttachmentCategory extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SystemAttachmentCategoryServices
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
/**
|
||||
* @param App $app
|
||||
* @param SystemAttachmentCategoryServices $service
|
||||
*/
|
||||
public function __construct(App $app, SystemAttachmentCategoryServices $service)
|
||||
{
|
||||
parent::__construct($app);
|
||||
@ -32,8 +38,7 @@ class SystemAttachmentCategory extends AuthController
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -66,10 +71,10 @@ class SystemAttachmentCategory extends AuthController
|
||||
['name', '']
|
||||
]);
|
||||
if (!$data['name']) {
|
||||
return app('json')->fail('请输入分类名称');
|
||||
return app('json')->fail(400100);
|
||||
}
|
||||
$this->service->save($data);
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100021);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,10 +90,8 @@ class SystemAttachmentCategory extends AuthController
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
@ -97,24 +100,23 @@ class SystemAttachmentCategory extends AuthController
|
||||
['name', '']
|
||||
]);
|
||||
if (!$data['name']) {
|
||||
return app('json')->fail('请输入分类名称');
|
||||
return app('json')->fail(400100);
|
||||
}
|
||||
$info = $this->service->get($id);
|
||||
$count = $this->service->count(['pid' => $id]);
|
||||
if ($count && $info['pid'] != $data['pid']) return app('json')->fail('该分类有下级分类,无法修改上级');
|
||||
if ($count && $info['pid'] != $data['pid']) return app('json')->fail(400105);
|
||||
$this->service->update($id, $data);
|
||||
return app('json')->success('分类编辑成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$this->service->del($id);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\finance;
|
||||
|
||||
use app\services\user\UserBillServices;
|
||||
@ -88,7 +87,7 @@ class Finance extends AuthController
|
||||
*/
|
||||
public function get_extract_list($id = '')
|
||||
{
|
||||
if ($id == '') return app('json')->fail('缺少参数');
|
||||
if ($id == '') return app('json')->fail(100100);
|
||||
$where = $this->request->getMore([
|
||||
['start_time', ''],
|
||||
['end_time', ''],
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
<?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\adminapi\controller\v1\finance;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -42,9 +50,9 @@ class UserBalance extends AuthController
|
||||
[$mark] = $this->request->postMore([
|
||||
['mark', '']
|
||||
], true);
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if ($mark === '') return app('json')->fail('备注不能为空');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
if ($mark === '') return app('json')->fail(400106);
|
||||
$this->services->recordRemark($id, $mark);
|
||||
return app('json')->success('备注成功');
|
||||
return app('json')->success(100024);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -35,8 +35,10 @@ class UserExtract extends AuthController
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -53,30 +55,28 @@ class UserExtract extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 显示编辑资源表单页
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100026);
|
||||
return app('json')->success($this->services->edit((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数!');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$id = (int)$id;
|
||||
$UserExtract = $this->services->getExtract($id);
|
||||
if (!$UserExtract) app('json')->fail('数据不存在');
|
||||
if (!$UserExtract) app('json')->fail(100026);
|
||||
if ($UserExtract['extract_type'] == 'alipay') {
|
||||
$data = $this->request->postMore([
|
||||
'real_name',
|
||||
@ -84,9 +84,9 @@ class UserExtract extends AuthController
|
||||
'extract_price',
|
||||
'alipay_code',
|
||||
]);
|
||||
if (!$data['real_name']) return app('json')->fail('请输入姓名');
|
||||
if ($data['extract_price'] <= -1) return app('json')->fail('请输入提现金额');
|
||||
if (!$data['alipay_code']) return app('json')->fail('请输入支付宝账号');
|
||||
if (!$data['real_name']) return app('json')->fail(400107);
|
||||
if ($data['extract_price'] <= -1) return app('json')->fail(400108);
|
||||
if (!$data['alipay_code']) return app('json')->fail(400109);
|
||||
} else if ($UserExtract['extract_type'] == 'weixin') {
|
||||
$data = $this->request->postMore([
|
||||
'real_name',
|
||||
@ -94,8 +94,8 @@ class UserExtract extends AuthController
|
||||
'extract_price',
|
||||
'wechat',
|
||||
]);
|
||||
if ($data['extract_price'] <= -1) return app('json')->fail('请输入提现金额');
|
||||
if (!$data['wechat']) return app('json')->fail('请输入微信账号');
|
||||
if ($data['extract_price'] <= -1) return app('json')->fail(400108);
|
||||
if (!$data['wechat']) return app('json')->fail(400110);
|
||||
} else {
|
||||
$data = $this->request->postMore([
|
||||
'real_name',
|
||||
@ -104,12 +104,12 @@ class UserExtract extends AuthController
|
||||
'bank_code',
|
||||
'bank_address',
|
||||
]);
|
||||
if (!$data['real_name']) return app('json')->fail('请输入姓名');
|
||||
if ($data['extract_price'] <= -1) return app('json')->fail('请输入提现金额');
|
||||
if (!$data['bank_code']) return app('json')->fail('请输入银行卡号');
|
||||
if (!$data['bank_address']) return app('json')->fail('请输入开户行');
|
||||
if (!$data['real_name']) return app('json')->fail(400107);
|
||||
if ($data['extract_price'] <= -1) return app('json')->fail(400108);
|
||||
if (!$data['bank_code']) return app('json')->fail(400111);
|
||||
if (!$data['bank_address']) return app('json')->fail(400112);
|
||||
}
|
||||
return app('json')->success($this->services->update($id, $data) ? '修改成功' : '修改失败');
|
||||
return app('json')->success($this->services->update($id, $data) ? 100001 : 100007);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,12 +119,12 @@ class UserExtract extends AuthController
|
||||
*/
|
||||
public function refuse($id)
|
||||
{
|
||||
if (!$id) app('json')->fail('缺少参数');
|
||||
if (!$id) app('json')->fail(100100);
|
||||
$data = $this->request->postMore([
|
||||
['message', '']
|
||||
]);
|
||||
if ($data['message'] == '') return app('json')->fail('拒绝理由不能为空');
|
||||
return app('json')->success($this->services->refuse((int)$id, $data['message']) ? '操作成功' : '操作失败');
|
||||
if ($data['message'] == '') return app('json')->fail(400113);
|
||||
return app('json')->success($this->services->refuse((int)$id, $data['message']) ? 100014 : 100015);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,7 +134,7 @@ class UserExtract extends AuthController
|
||||
*/
|
||||
public function adopt($id)
|
||||
{
|
||||
if (!$id) app('json')->fail('缺少参数');
|
||||
return app('json')->success($this->services->adopt((int)$id) ? '操作成功' : '操作失败');
|
||||
if (!$id) app('json')->fail(100100);
|
||||
return app('json')->success($this->services->adopt((int)$id) ? 100014 : 100015);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,7 +10,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\finance;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\user\UserRechargeServices;
|
||||
use think\facade\App;
|
||||
@ -34,7 +33,6 @@ class UserRecharge extends AuthController
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
@ -49,14 +47,13 @@ class UserRecharge extends AuthController
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
return app('json')->success($this->services->delRecharge((int)$id) ? '删除成功' : '删除失败');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->delRecharge((int)$id) ? 100002 : 100008);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,26 +70,28 @@ class UserRecharge extends AuthController
|
||||
return app('json')->success($this->services->user_recharge($where));
|
||||
}
|
||||
|
||||
/**退款表单
|
||||
/**
|
||||
* 退款表单
|
||||
* @param $id
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function refund_edit($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100026);
|
||||
return app('json')->success($this->services->refund_edit((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款操作
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function refund_update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
'refund_price',
|
||||
]);
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
return app('json')->success($this->services->refund_update((int)$id, $data['refund_price']) ? '退款成功' : '退款失败');
|
||||
if (!$id) return app('json')->fail(100026);
|
||||
return app('json')->success($this->services->refund_update((int)$id, $data['refund_price']) ? 100036 : 100037);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -34,9 +34,11 @@ class Express extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* 获取物流列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -47,9 +49,9 @@ class Express extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
* 显示创建资源表单页
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@ -58,7 +60,6 @@ class Express extends AuthController
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save()
|
||||
@ -68,27 +69,16 @@ class Express extends AuthController
|
||||
'code',
|
||||
['sort', 0],
|
||||
['is_show', 0]]);
|
||||
if (!$data['name']) return app('json')->fail('请输入公司名称');
|
||||
if (!$data['name']) return app('json')->fail(400400);
|
||||
$this->services->save($data);
|
||||
return app('json')->success('添加公司成功!');
|
||||
return app('json')->success(400401);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 显示编辑资源表单页
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
@ -97,9 +87,8 @@ class Express extends AuthController
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
@ -109,15 +98,15 @@ class Express extends AuthController
|
||||
['net_name', ''],
|
||||
['sort', 0],
|
||||
['is_show', 0]]);
|
||||
if (!$expressInfo = $this->services->get($id)) return app('json')->fail('编辑的记录不存在!');
|
||||
if (!$expressInfo = $this->services->get($id)) return app('json')->fail(100026);
|
||||
if ($expressInfo['partner_id'] == 1 && !$data['account']) {
|
||||
return app('json')->fail('请输入月结账号');
|
||||
return app('json')->fail(400402);
|
||||
}
|
||||
if ($expressInfo['partner_key'] == 1 && !$data['key']) {
|
||||
return app('json')->fail('请输入月结密码');
|
||||
return app('json')->fail(400403);
|
||||
}
|
||||
if ($expressInfo['net'] == 1 && !$data['net_name']) {
|
||||
return app('json')->fail('请输入取件网点');
|
||||
return app('json')->fail(400404);
|
||||
}
|
||||
$expressInfo->account = $data['account'];
|
||||
$expressInfo->key = $data['key'];
|
||||
@ -126,23 +115,22 @@ class Express extends AuthController
|
||||
$expressInfo->is_show = $data['is_show'];
|
||||
$expressInfo->status = 1;
|
||||
$expressInfo->save();
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('参数错误,请重新打开');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$res = $this->services->delete($id);
|
||||
if (!$res)
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,9 +141,9 @@ class Express extends AuthController
|
||||
*/
|
||||
public function set_status($id = 0, $status = '')
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
if ($status == '' || $id == 0) return app('json')->fail(100100);
|
||||
$this->services->update($id, ['is_show' => $status]);
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,6 +153,6 @@ class Express extends AuthController
|
||||
public function syncExpress()
|
||||
{
|
||||
$this->services->syncExpress();
|
||||
return app('json')->success('同步成功');
|
||||
return app('json')->success(100039);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,12 +8,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\application\wechat;
|
||||
namespace app\adminapi\controller\v1\kefu;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\kefu\LoginServices;
|
||||
use app\services\message\service\StoreServiceLogServices;
|
||||
use app\services\message\service\StoreServiceServices;
|
||||
use app\services\kefu\service\StoreServiceLogServices;
|
||||
use app\services\kefu\service\StoreServiceServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\user\UserWechatuserServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
@ -40,8 +40,10 @@ class StoreService extends AuthController
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -49,9 +51,9 @@ class StoreService extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
* 显示创建资源表单页
|
||||
* @param UserWechatuserServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(UserWechatuserServices $services)
|
||||
{
|
||||
@ -74,8 +76,9 @@ class StoreService extends AuthController
|
||||
return app('json')->success($this->services->create());
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* 保存新建的资源
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
@ -93,61 +96,61 @@ class StoreService extends AuthController
|
||||
['nickname', ''],
|
||||
['status', 1],
|
||||
]);
|
||||
if ($data['image'] == '') return app('json')->fail('请选择用户');
|
||||
if ($data['image'] == '') return app('json')->fail(400250);
|
||||
$data['uid'] = $data['image']['uid'];
|
||||
/** @var UserServices $userService */
|
||||
$userService = app()->make(UserServices::class);
|
||||
$userInfo = $userService->get($data['uid']);
|
||||
if ($data['phone'] == '') {
|
||||
if (!$userInfo['phone']) {
|
||||
throw new AdminException('该用户没有绑定手机号,请手动填写');
|
||||
throw new AdminException(400251);
|
||||
} else {
|
||||
$data['phone'] = $userInfo['phone'];
|
||||
}
|
||||
} else {
|
||||
if (!check_phone($data['phone'])) {
|
||||
throw new AdminException('请输入正确的手机号');
|
||||
throw new AdminException(400252);
|
||||
}
|
||||
}
|
||||
if ($data['nickname'] == '') $data['nickname'] = $userInfo['nickname'];
|
||||
$data['avatar'] = $data['image']['image'];
|
||||
if ($this->services->count(['uid' => $data['uid']])) {
|
||||
return app('json')->fail('客服已存在!');
|
||||
return app('json')->fail(400253);
|
||||
}
|
||||
unset($data['image']);
|
||||
$data['add_time'] = time();
|
||||
if (!$data['account']) {
|
||||
return app('json')->fail('请输入账号');
|
||||
return app('json')->fail(400254);
|
||||
}
|
||||
if (!preg_match('/^[a-zA-Z0-9]{4,30}$/', $data['account'])) {
|
||||
return app('json')->fail('账号必须为数字或者字母的组合4-30位');
|
||||
return app('json')->fail(400255);
|
||||
}
|
||||
if (!$data['password']) {
|
||||
return app('json')->fail('请输入密码');
|
||||
return app('json')->fail(400256);
|
||||
}
|
||||
if (!preg_match('/^[0-9a-z_$]{6,20}$/i', $data['password'])) {
|
||||
return app('json')->fail('密码必须为数字或者字母的组合6-20位');
|
||||
return app('json')->fail(400257);
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone']])) {
|
||||
return app('json')->fail('该手机号的客服已存在!');
|
||||
return app('json')->fail(400258);
|
||||
}
|
||||
if ($this->services->count(['account' => $data['account']])) {
|
||||
return app('json')->fail('该客服账号已存在!');
|
||||
return app('json')->fail(400259);
|
||||
}
|
||||
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||
$res = $this->services->save($data);
|
||||
if ($res) {
|
||||
return app('json')->success('客服添加成功');
|
||||
return app('json')->success(400260);
|
||||
} else {
|
||||
return app('json')->fail('客服添加失败,请稍后再试');
|
||||
return app('json')->fail(400261);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 显示编辑资源表单页
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
@ -156,9 +159,8 @@ class StoreService extends AuthController
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
@ -175,79 +177,82 @@ class StoreService extends AuthController
|
||||
]);
|
||||
$customer = $this->services->get((int)$id);
|
||||
if (!$customer) {
|
||||
return app('json')->fail('数据不存在');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
if ($data["nickname"] == '') {
|
||||
return app('json')->fail("客服名称不能为空!");
|
||||
return app('json')->fail(400262);
|
||||
}
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail('请输入正确的手机号');
|
||||
return app('json')->fail(400252);
|
||||
}
|
||||
if ($customer['phone'] != $data['phone'] && $this->services->count(['phone' => $data['phone']])) {
|
||||
return app('json')->fail('该手机号的客服已存在!');
|
||||
return app('json')->fail(400258);
|
||||
}
|
||||
if ($data['password']) {
|
||||
if (!preg_match('/^[0-9a-z_$]{6,16}$/i', $data['password'])) {
|
||||
return app('json')->fail('密码必须为数字或者字母的组合');
|
||||
return app('json')->fail(400257);
|
||||
}
|
||||
if (!$data['true_password']) {
|
||||
return app('json')->fail('请输入确认密码');
|
||||
return app('json')->fail(400263);
|
||||
}
|
||||
if ($data['password'] != $data['true_password']) {
|
||||
return app('json')->fail('两次输入的密码不正确');
|
||||
return app('json')->fail(400264);
|
||||
}
|
||||
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||
} else {
|
||||
unset($data['password']);
|
||||
}
|
||||
$this->services->update($id, $data);
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param UserServices $services
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_status(UserServices $services, $id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
if ($status == '' || $id == 0) return app('json')->fail(100100);
|
||||
$info = $this->services->get($id, ['status', 'uid']);
|
||||
if (!$services->count(['uid' => $info['uid']])) {
|
||||
$info->status = 1;
|
||||
$info->save();
|
||||
return app('json')->fail('用户不存在,客服将强制禁止登录');
|
||||
return app('json')->fail(400265);
|
||||
}
|
||||
$info->status = $status;
|
||||
$info->save();
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天记录
|
||||
*
|
||||
* @return \think\Response
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function chat_user($id)
|
||||
{
|
||||
$uid = $this->services->value(['id' => $id], 'uid');
|
||||
if (!$uid) {
|
||||
return app('json')->fail('数据不存在!');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
return app('json')->success($this->services->getChatUser((int)$uid));
|
||||
}
|
||||
@ -296,10 +301,10 @@ class StoreService extends AuthController
|
||||
{
|
||||
$serviceInfo = $services->get($id);
|
||||
if (!$serviceInfo) {
|
||||
return app('json')->fail('登录的客服不存在');
|
||||
return app('json')->fail(400266);
|
||||
}
|
||||
if (!$serviceInfo->account || !$serviceInfo->password) {
|
||||
return app('json')->fail('请先填写客服账号和密码再尝试进入客服平台');
|
||||
return app('json')->fail(400267);
|
||||
}
|
||||
return app('json')->success($services->authLogin($serviceInfo->account));
|
||||
}
|
||||
@ -9,11 +9,11 @@
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\application\wechat;
|
||||
namespace app\adminapi\controller\v1\kefu;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\message\service\StoreServiceFeedbackServices;
|
||||
use app\services\kefu\service\StoreServiceFeedbackServices;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
@ -64,7 +64,7 @@ class StoreServiceFeedback extends AuthController
|
||||
public function edit($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->editForm((int)$id));
|
||||
}
|
||||
@ -81,14 +81,14 @@ class StoreServiceFeedback extends AuthController
|
||||
['status', 0],
|
||||
]);
|
||||
if (!$id || !($feedInfo = $this->services->get($id))) {
|
||||
return app('json')->fail('反馈内容不存在');
|
||||
return app('json')->fail(400268);
|
||||
}
|
||||
$feedInfo->make = $data['make'];
|
||||
if ($data['status']) {
|
||||
$feedInfo->status = $data['status'];
|
||||
}
|
||||
$feedInfo->save();
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,12 +100,12 @@ class StoreServiceFeedback extends AuthController
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
if ($this->services->delete($id)) {
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
} else {
|
||||
return app('json')->fail('删除失败');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,12 +9,12 @@
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\application\wechat;
|
||||
namespace app\adminapi\controller\v1\kefu;
|
||||
|
||||
use app\Request;
|
||||
use think\facade\App;
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\message\service\StoreServiceSpeechcraftServices;
|
||||
use app\services\kefu\service\StoreServiceSpeechcraftServices;
|
||||
use app\adminapi\validate\service\StoreServiceSpeechcraftValidata;
|
||||
|
||||
/**
|
||||
@ -37,8 +37,11 @@ class StoreServiceSpeechcraft extends AuthController
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
@ -52,9 +55,8 @@ class StoreServiceSpeechcraft extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
* 显示创建资源表单页
|
||||
* @return mixed
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@ -63,7 +65,6 @@ class StoreServiceSpeechcraft extends AuthController
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
@ -80,18 +81,17 @@ class StoreServiceSpeechcraft extends AuthController
|
||||
$data['add_time'] = time();
|
||||
$data['kefu_id'] = 0;
|
||||
if ($this->services->count(['message' => $data['message']])) {
|
||||
return app('json')->fail('话术不能重复添加');
|
||||
return app('json')->fail(400269);
|
||||
}
|
||||
if ($this->services->save($data)) {
|
||||
return app('json')->success('创建话术成功');
|
||||
return app('json')->success(400270);
|
||||
} else {
|
||||
return app('json')->fail('创建话术失败');
|
||||
return app('json')->fail(400271);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
@ -99,16 +99,19 @@ class StoreServiceSpeechcraft extends AuthController
|
||||
{
|
||||
$info = $this->services->get($id);
|
||||
if (!$info) {
|
||||
return app('json')->fail('获取失败');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
return app('json')->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 显示编辑资源表单页
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
@ -117,7 +120,6 @@ class StoreServiceSpeechcraft extends AuthController
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
@ -134,31 +136,30 @@ class StoreServiceSpeechcraft extends AuthController
|
||||
$this->validate($data, StoreServiceSpeechcraftValidata::class);
|
||||
$message = $this->services->get(['message' => $data['message']]);
|
||||
if ($message && $message['id'] != $id) {
|
||||
return app('json')->fail('话术不能重复添加');
|
||||
return app('json')->fail(400269);
|
||||
}
|
||||
if ($this->services->update($id, $data)) {
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
} else {
|
||||
return app('json')->fail('修改失败');
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id || !($info = $this->services->get($id))) {
|
||||
return app('json')->fail('删除的话术不存在!');
|
||||
return app('json')->fail(400272);
|
||||
}
|
||||
if ($info->delete()) {
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
} else {
|
||||
return app('json')->fail('删除失败');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,13 +9,13 @@
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\application\wechat;
|
||||
namespace app\adminapi\controller\v1\kefu;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use think\facade\App;
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\message\service\StoreServiceSpeechcraftCateServices;
|
||||
use app\services\kefu\service\StoreServiceSpeechcraftCateServices;
|
||||
|
||||
/**
|
||||
* Class StoreServiceSpeechcraftCate
|
||||
@ -74,18 +74,18 @@ class StoreServiceSpeechcraftCate extends AuthController
|
||||
]);
|
||||
|
||||
if (!$data['name']) {
|
||||
return app('json')->fail('请输入分类名称');
|
||||
return app('json')->fail(400100);
|
||||
}
|
||||
|
||||
if ($this->services->count(['name' => $data['name'], 'type' => 1, 'owner_id' => 0])) {
|
||||
return app('json')->fail('分类已存在');
|
||||
return app('json')->fail(400101);
|
||||
}
|
||||
|
||||
$data['add_time'] = time();
|
||||
$data['type'] = 1;
|
||||
|
||||
$this->services->save($data);
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100021);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,17 +115,17 @@ class StoreServiceSpeechcraftCate extends AuthController
|
||||
[['sort', 'd'], 0],
|
||||
]);
|
||||
if (!$data['name']) {
|
||||
return app('json')->fail('请输入分类名称');
|
||||
return app('json')->fail(400100);
|
||||
}
|
||||
|
||||
$cateInfo = $this->services->get($id);
|
||||
if (!$cateInfo) {
|
||||
return app('json')->fail('修改的分类不存在');
|
||||
return app('json')->fail(400103);
|
||||
}
|
||||
$cateInfo->name = $data['name'];
|
||||
$cateInfo->sort = $data['sort'];
|
||||
$cateInfo->save();
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,12 +135,12 @@ class StoreServiceSpeechcraftCate extends AuthController
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if ($id == 0) return app('json')->fail('系统分类不能删除');
|
||||
if ($id == 0) return app('json')->fail(400273);
|
||||
$cateInfo = $this->services->get($id);
|
||||
if (!$cateInfo) {
|
||||
return app('json')->fail('删除的分类不存在');
|
||||
return app('json')->fail(400103);
|
||||
}
|
||||
$cateInfo->delete();
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -86,23 +86,23 @@ class StoreAdvance extends AuthController
|
||||
$storeSeckillService = app()->make(StoreSeckillServices::class);
|
||||
$res1 = $storeSeckillService->count(['product_id' => $data['product_id'], 'is_del' => 0, 'status' => 1, 'seckill_time' => 1]);
|
||||
if ($res1) {
|
||||
throw new AdminException('商品参与秒杀活动开启,无法开启预售');
|
||||
throw new AdminException(400506);
|
||||
}
|
||||
/** @var StoreBargainServices $storeBargainService */
|
||||
$storeBargainService = app()->make(StoreBargainServices::class);
|
||||
$res2 = $storeBargainService->count(['product_id' => $data['product_id'], 'is_del' => 0, 'status' => 1, 'bargain_time' => 1]);
|
||||
if ($res2) {
|
||||
throw new AdminException('商品参与砍价活动开启,无法开启预售');
|
||||
throw new AdminException(400506);
|
||||
}
|
||||
/** @var StoreCombinationServices $storeCombinationService */
|
||||
$storeCombinationService = app()->make(StoreCombinationServices::class);
|
||||
$res3 = $storeCombinationService->count(['product_id' => $data['product_id'], 'is_del' => 0, 'is_show' => 1, 'pinkIngTime' => 1]);
|
||||
if ($res3) {
|
||||
throw new AdminException('商品参与拼团活动开启,无法开启预售');
|
||||
throw new AdminException(400506);
|
||||
}
|
||||
}
|
||||
$this->services->saveData($id, $data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,9 +125,9 @@ class StoreAdvance extends AuthController
|
||||
{
|
||||
$res = $this->services->update($id, ['is_del' => 1]);
|
||||
if ($res) {
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
} else {
|
||||
return app('json')->fail('删除成功');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,11 +140,10 @@ class StoreAdvance extends AuthController
|
||||
public function setStatus($id, $status)
|
||||
{
|
||||
$res = $this->services->update($id, ['status' => $status]);
|
||||
$msg = $status == 1 ? '上架' : '下架';
|
||||
if ($res) {
|
||||
return app('json')->success($msg . '成功');
|
||||
return app('json')->success(100014);
|
||||
} else {
|
||||
return app('json')->fail($msg . '成功');
|
||||
return app('json')->fail(100015);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\marketing;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -36,9 +35,11 @@ class StoreBargain extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* 砍价列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -53,10 +54,9 @@ class StoreBargain extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
* 保存砍价商品
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save($id)
|
||||
{
|
||||
@ -92,20 +92,20 @@ class StoreBargain extends AuthController
|
||||
if ($data['section_time']) {
|
||||
[$start_time, $end_time] = $data['section_time'];
|
||||
if (strtotime($end_time) < time()) {
|
||||
return app('json')->fail('活动结束时间不能小于当前时间');
|
||||
return app('json')->fail(400507);
|
||||
}
|
||||
}
|
||||
$bragain = [];
|
||||
if ($id) {
|
||||
$bragain = $this->services->get((int)$id);
|
||||
if (!$bragain) {
|
||||
return app('json')->fail('数据不存在');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
}
|
||||
//限制编辑
|
||||
if ($data['copy'] == 0 && $bragain) {
|
||||
if ($bragain['stop_time'] < time()) {
|
||||
return app('json')->fail('活动已结束,请重新添加或复制');
|
||||
return app('json')->fail(400508);
|
||||
}
|
||||
}
|
||||
if ($data['copy'] == 1) {
|
||||
@ -113,14 +113,13 @@ class StoreBargain extends AuthController
|
||||
unset($data['copy']);
|
||||
}
|
||||
$this->services->saveData($id, $data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 获取详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
@ -129,10 +128,9 @@ class StoreBargain extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 删除砍价
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
@ -140,7 +138,7 @@ class StoreBargain extends AuthController
|
||||
/** @var StoreBargainUserServices $bargainUserService */
|
||||
$bargainUserService = app()->make(StoreBargainUserServices::class);
|
||||
$bargainUserService->userBargainStatusFail($id, true);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,7 +153,7 @@ class StoreBargain extends AuthController
|
||||
$bargainUserService = app()->make(StoreBargainUserServices::class);
|
||||
$bargainUserService->userBargainStatusFail($id, false);
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success($status == 0 ? '关闭成功' : '开启成功');
|
||||
return app('json')->success($status == 0 ? 100001 : 100007);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,4 +184,43 @@ class StoreBargain extends AuthController
|
||||
$list = $bargainUserHelpService->getHelpList($id);
|
||||
return app('json')->success(compact('list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价统计
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function bargainStatistics($id)
|
||||
{
|
||||
$data = $this->services->bargainStatistics($id);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价列表
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function bargainStatisticsList($id)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['real_name', ''],
|
||||
]);
|
||||
$data = $this->services->bargainStatisticsList($id, $where);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价订单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function bargainStatisticsOrder($id)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['real_name', ''],
|
||||
['status', '']
|
||||
]);
|
||||
return app('json')->success($this->services->bargainStatisticsOrder($id, $where));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\marketing;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -16,7 +15,6 @@ use app\services\activity\combination\StoreCombinationServices;
|
||||
use app\services\activity\combination\StorePinkServices;
|
||||
use think\facade\App;
|
||||
|
||||
|
||||
/**
|
||||
* 拼团管理
|
||||
* Class StoreCombination
|
||||
@ -109,48 +107,49 @@ class StoreCombination extends AuthController
|
||||
['postage', 0],//邮费
|
||||
['custom_form', ''],
|
||||
['virtual_type', 0],
|
||||
['is_commission', 0],
|
||||
['head_commission', 0],
|
||||
]);
|
||||
$this->validate($data, \app\adminapi\validate\marketing\StoreCombinationValidate::class, 'save');
|
||||
if ($data['section_time']) {
|
||||
[$start_time, $end_time] = $data['section_time'];
|
||||
if (strtotime($end_time) < time()) {
|
||||
return app('json')->fail('活动结束时间不能小于当前时间');
|
||||
return app('json')->fail(400507);
|
||||
}
|
||||
}
|
||||
$bragain = [];
|
||||
$combination = [];
|
||||
if ($id) {
|
||||
$bragain = $this->services->get((int)$id);
|
||||
if (!$bragain) {
|
||||
return app('json')->fail('数据不存在');
|
||||
$combination = $this->services->get((int)$id);
|
||||
if (!$combination) {
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
}
|
||||
//限制编辑
|
||||
if ($data['copy'] == 0 && $bragain) {
|
||||
if ($bragain['stop_time'] < time()) {
|
||||
return app('json')->fail('活动已结束,请重新添加或复制');
|
||||
if ($data['copy'] == 0 && $combination) {
|
||||
if ($combination['stop_time'] < time()) {
|
||||
return app('json')->fail(400508);
|
||||
}
|
||||
}
|
||||
if($data['num'] < $data['once_num']){
|
||||
return app('json')->fail('限制单次购买数量不能大于总购买数量');
|
||||
if ($data['num'] < $data['once_num']) {
|
||||
return app('json')->fail(400500);
|
||||
}
|
||||
if ($data['copy'] == 1) {
|
||||
$id = 0;
|
||||
unset($data['copy']);
|
||||
}
|
||||
$this->services->saveData($id, $data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 删除拼团
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$this->services->update($id, ['is_del' => 1]);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,10 +161,11 @@ class StoreCombination extends AuthController
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
$this->services->update($id, ['is_show' => $status]);
|
||||
return app('json')->success($status == 0 ? '关闭成功' : '开启成功');
|
||||
return app('json')->success($status == 0 ? 100014 : 100015);
|
||||
}
|
||||
|
||||
/**拼团列表
|
||||
/**
|
||||
* 拼团列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function combine_list()
|
||||
@ -180,7 +180,8 @@ class StoreCombination extends AuthController
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**拼团人列表
|
||||
/**
|
||||
* 拼团人列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function order_pink($id)
|
||||
@ -191,4 +192,41 @@ class StoreCombination extends AuthController
|
||||
return app('json')->success(compact('list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团统计
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function combinationStatistics($id)
|
||||
{
|
||||
$data = $this->services->combinationStatistics($id);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动参与人
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function combinationStatisticsList($id)
|
||||
{
|
||||
/** @var StorePinkServices $storePinkServices */
|
||||
$storePinkServices = app()->make(StorePinkServices::class);
|
||||
$list = $storePinkServices->systemPage(['cid' => $id]);
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团订单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function combinationStatisticsOrder($id)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['real_name', ''],
|
||||
['status', '']
|
||||
]);
|
||||
return app('json')->success($this->services->combinationStatisticsOrder($id, $where));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,153 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\marketing;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\activity\coupon\StoreCouponProductServices;
|
||||
use app\services\activity\coupon\StoreCouponService;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 优惠券制作
|
||||
* Class StoreCoupon
|
||||
* @package app\adminapi\controller\v1\marketing
|
||||
*/
|
||||
class StoreCoupon extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* StoreCoupon constructor.
|
||||
* @param App $app
|
||||
* @param StoreCouponService $service
|
||||
*/
|
||||
public function __construct(App $app, StoreCouponService $service)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->services = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优惠券模板列表
|
||||
* @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', 1],
|
||||
['title', ''],
|
||||
]);
|
||||
$data = $this->services->getList($where);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建添加模板表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
[$type] = $this->request->getMore(['type'], true);
|
||||
return app('json')->success($this->services->createForm($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存优惠券模板
|
||||
* @return mixed
|
||||
*/
|
||||
public function save(StoreCouponProductServices $services)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['title', ''],
|
||||
['image', ''],
|
||||
['category_id', ''],
|
||||
['coupon_price', ''],
|
||||
['use_min_price', ''],
|
||||
['coupon_time', ''],
|
||||
['sort', ''],
|
||||
['status', 0],
|
||||
['type', 0]
|
||||
]);
|
||||
$data['product_id'] = '';
|
||||
if ($data['type'] == 1) {
|
||||
$this->validate($data, \app\adminapi\validate\marketing\StoreCouponValidate::class, 'type');
|
||||
} elseif ($data['type'] == 2) {
|
||||
$this->validate($data, \app\adminapi\validate\marketing\StoreCouponValidate::class, 'product');
|
||||
$productIds = array_column($data['image'], 'product_id');
|
||||
$data['product_id'] = implode(',', $productIds);
|
||||
} else {
|
||||
$this->validate($data, \app\adminapi\validate\marketing\StoreCouponValidate::class, 'save');
|
||||
}
|
||||
$data['add_time'] = time();
|
||||
$this->services->save($data);
|
||||
return app('json')->success('添加优惠券成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除优惠券模板
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$data['is_del'] = 1;
|
||||
$this->services->update($id, $data);
|
||||
return app('json')->success('删除成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 立即失效优惠券模板
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function status($id)
|
||||
{
|
||||
$this->services->invalid($id);
|
||||
return app('json')->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布优惠券表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function issue($id)
|
||||
{
|
||||
return app('json')->success($this->services->createIssue($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存发布优惠券信息
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_issue($id)
|
||||
{
|
||||
list($_id, $coupon_title, $rangeTime, $count, $status, $is_permanent, $full_reduction, $is_give_subscribe, $is_full_give, $is_type) = $this->request->postMore([
|
||||
'id',
|
||||
['coupon_title', ''],
|
||||
['range_date', ['', '']],
|
||||
['count', 0],
|
||||
['status', 0],
|
||||
['is_permanent', 0],
|
||||
['full_reduction', 0],
|
||||
['is_give_subscribe', 0],
|
||||
['is_full_give', 0],
|
||||
['is_type', 0]
|
||||
], true);
|
||||
$this->services->upIssue($id, $_id, $coupon_title, $rangeTime, $count, $status, $is_permanent, $full_reduction, $is_give_subscribe, $is_full_give, $is_type);
|
||||
return app('json')->success('发布优惠劵成功!');
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -72,18 +72,8 @@ class StoreCouponIssue extends AuthController
|
||||
['sort', 0],
|
||||
['status', 0],
|
||||
]);
|
||||
if ($data['start_time'] && $data['start_use_time']) {
|
||||
if ($data['start_use_time'] < $data['start_time']) {
|
||||
return app('json')->fail('使用开始时间不能小于领取开始时间');
|
||||
}
|
||||
}
|
||||
if ($data['end_time'] && $data['end_use_time']) {
|
||||
if ($data['end_use_time'] < $data['end_time']) {
|
||||
return app('json')->fail('使用结束时间不能小于领取结束时间');
|
||||
}
|
||||
}
|
||||
$res = $this->services->saveCoupon($data);
|
||||
if ($res) return app('json')->success('添加成功!');
|
||||
if ($res) return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +85,7 @@ class StoreCouponIssue extends AuthController
|
||||
public function status($id, $status)
|
||||
{
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,7 +95,7 @@ class StoreCouponIssue extends AuthController
|
||||
*/
|
||||
public function copy($id = 0)
|
||||
{
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$info = $this->services->get($id);
|
||||
if ($info) $info = $info->toArray();
|
||||
if ($info['product_id'] != '') {
|
||||
@ -135,7 +125,7 @@ class StoreCouponIssue extends AuthController
|
||||
$storeProductService = app()->make(StoreProductCouponServices::class);
|
||||
//删除商品关联这个优惠券
|
||||
$storeProductService->delete(['issue_coupon_id' => $id]);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -29,8 +29,11 @@ class StoreCouponUser extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 发放列表
|
||||
* 用户领取记录
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -45,9 +48,7 @@ class StoreCouponUser extends AuthController
|
||||
|
||||
/**
|
||||
* 发放优惠券到指定个人
|
||||
* @param $id
|
||||
* @param $uid
|
||||
* @return \think\response\Json
|
||||
* @return mixed
|
||||
*/
|
||||
public function grant()
|
||||
{
|
||||
@ -55,20 +56,20 @@ class StoreCouponUser extends AuthController
|
||||
['id', 0],
|
||||
['uid', '']
|
||||
]);
|
||||
if (!$data['id']) return app('json')->fail('数据不存在!');
|
||||
if (!$data['id']) return app('json')->fail(100100);
|
||||
/** @var StoreCouponIssueServices $issueService */
|
||||
$issueService = app()->make(StoreCouponIssueServices::class);
|
||||
$coupon = $issueService->get($data['id']);
|
||||
if (!$coupon) {
|
||||
return app('json')->fail('数据不存在!');
|
||||
return app('json')->fail(100026);
|
||||
} else {
|
||||
$coupon = $coupon->toArray();
|
||||
}
|
||||
$user = explode(',', $data['uid']);
|
||||
if (!$issueService->setCoupon($coupon, $user))
|
||||
return app('json')->fail('发放失败,请稍候再试!');
|
||||
return app('json')->fail(100031);
|
||||
else
|
||||
return app('json')->success('发放成功!');
|
||||
return app('json')->success(100030);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\marketing;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -32,8 +31,10 @@ class StoreSeckill extends AuthController
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -67,7 +68,6 @@ class StoreSeckill extends AuthController
|
||||
[['title', 's'], ''],
|
||||
[['info', 's'], ''],
|
||||
[['unit_name', 's'], ''],
|
||||
// ['image', ''],
|
||||
['images', []],
|
||||
[['give_integral', 'd'], 0],
|
||||
['section_time', []],
|
||||
@ -89,45 +89,18 @@ class StoreSeckill extends AuthController
|
||||
['virtual_type', 0],
|
||||
]);
|
||||
$this->validate($data, \app\adminapi\validate\marketing\StoreSeckillValidate::class, 'save');
|
||||
if ($data['section_time']) {
|
||||
[$start_time, $end_time] = $data['section_time'];
|
||||
if (strtotime($end_time) + 86400 < time()) {
|
||||
return app('json')->fail('活动结束时间不能小于当前时间');
|
||||
}
|
||||
}
|
||||
$seckill = [];
|
||||
if ($id) {
|
||||
$seckill = $this->services->get((int)$id);
|
||||
if (!$seckill) {
|
||||
return app('json')->fail('数据不存在');
|
||||
}
|
||||
}
|
||||
//限制编辑
|
||||
if ($data['copy'] == 0 && $seckill) {
|
||||
if ($seckill['stop_time'] + 86400 < time()) {
|
||||
return app('json')->fail('活动已结束,请重新添加或复制');
|
||||
}
|
||||
}
|
||||
if ($data['num'] < $data['once_num']) {
|
||||
return app('json')->fail('限制单次购买数量不能大于总购买数量');
|
||||
}
|
||||
if ($data['copy'] == 1) {
|
||||
$id = 0;
|
||||
unset($data['copy']);
|
||||
}
|
||||
$this->services->saveData($id, $data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 删除秒杀
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->services->update($id, ['is_del' => 1]);
|
||||
/** @var StoreProductAttrValueServices $storeProductAttrValueServices */
|
||||
$storeProductAttrValueServices = app()->make(StoreProductAttrValueServices::class);
|
||||
@ -138,7 +111,7 @@ class StoreSeckill extends AuthController
|
||||
$cache = app()->make(CacheService::class);
|
||||
$cache->del($name);
|
||||
}
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,17 +123,53 @@ class StoreSeckill extends AuthController
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success($status == 0 ? '关闭成功' : '开启成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀时间段列表
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return mixed
|
||||
*/
|
||||
public function time_list()
|
||||
{
|
||||
$list['data'] = sys_data('routine_seckill_time');
|
||||
return app('json')->success(compact('list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀统计
|
||||
* @return mixed
|
||||
*/
|
||||
public function seckillStatistics($id)
|
||||
{
|
||||
$data = $this->services->seckillStatistics($id);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀参与人统计
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function seckillPeople($id)
|
||||
{
|
||||
[$keyword] = $this->request->getMore([
|
||||
['keyword', '']
|
||||
], true);
|
||||
return app('json')->success($this->services->seckillPeople($id, $keyword));
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀订单统计
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function seckillOrder($id)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['real_name', ''],
|
||||
['status', '']
|
||||
]);
|
||||
return app('json')->success($this->services->seckillOrder($id, $where));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,12 +10,10 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\marketing;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\user\UserBillServices;
|
||||
use think\facade\App;
|
||||
|
||||
|
||||
/**
|
||||
* 积分控制器
|
||||
* Class StoreCategory
|
||||
@ -36,6 +34,7 @@ class UserPoint extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分记录列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
|
||||
@ -2,21 +2,18 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\marketing\integral;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\activity\integral\StoreIntegralServices;
|
||||
use think\facade\App;
|
||||
|
||||
|
||||
/**
|
||||
* 积分商城管理
|
||||
* Class StoreCombination
|
||||
@ -50,11 +47,12 @@ class StoreIntegral extends AuthController
|
||||
$list = $this->services->systemPage($where);
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存商品
|
||||
* @param int $id
|
||||
*/
|
||||
public function save($id)
|
||||
public function save($id = 0)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
[['product_id', 'd'], 0],
|
||||
@ -72,39 +70,35 @@ class StoreIntegral extends AuthController
|
||||
['items', []],
|
||||
['copy', 0]
|
||||
]);
|
||||
|
||||
$this->validate($data, \app\adminapi\validate\marketing\StoreIntegralValidate::class, 'save');
|
||||
$bragain = [];
|
||||
if ($id) {
|
||||
$bragain = $this->services->get((int)$id);
|
||||
if (!$bragain) {
|
||||
return app('json')->fail('数据不存在');
|
||||
$integral = $this->services->get((int)$id);
|
||||
if (!$integral) {
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
}
|
||||
if ($data['num'] < $data['once_num']) {
|
||||
return app('json')->fail('限制单次购买数量不能大于总购买数量');
|
||||
}
|
||||
if ($data['copy'] == 1) {
|
||||
$id = 0;
|
||||
unset($data['copy']);
|
||||
}
|
||||
$this->services->saveData($id, $data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加商品
|
||||
* @return mixed
|
||||
*/
|
||||
public function batch_add(){
|
||||
public function batch_add()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['attrs', []],
|
||||
[['is_show', 'd'], 0]
|
||||
]);
|
||||
if(!$data['attrs']) return app('json')->fail('请选择提交的商品');
|
||||
$this->services->saveBatchData($data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
* @param $id
|
||||
@ -115,6 +109,7 @@ class StoreIntegral extends AuthController
|
||||
$info = $this->services->getInfo($id);
|
||||
return app('json')->success(compact('info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param $id
|
||||
@ -124,8 +119,9 @@ class StoreIntegral extends AuthController
|
||||
public function set_show($id, $is_show)
|
||||
{
|
||||
$this->services->update($id, ['is_show' => $is_show]);
|
||||
return app('json')->success($is_show == 0 ? '下架成功' : '上架成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
@ -134,9 +130,9 @@ class StoreIntegral extends AuthController
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->services->update($id, ['is_del' => 1]);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,7 +10,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\marketing\integral;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\serve\ServeServices;
|
||||
use app\services\activity\integral\{
|
||||
@ -97,12 +96,11 @@ class StoreIntegralOrder extends AuthController
|
||||
['ids', []],
|
||||
['where', []],
|
||||
], true);
|
||||
if (!count($ids)) return app('json')->fail('请选择需要删除的订单');
|
||||
if ($this->services->getOrderIdsCount($ids)) return app('json')->fail('您选择的的订单存在用户未删除的订单');
|
||||
if ($this->services->batchUpdate($ids, ['is_system_del' => 1])) {
|
||||
return app('json')->success('删除成功');
|
||||
if ($this->services->delOrders($ids)) {
|
||||
return app('json')->success(100002);
|
||||
} else {
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
return app('json')->fail('删除失败');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,20 +110,16 @@ class StoreIntegralOrder extends AuthController
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
if (!$id || !($orderInfo = $this->services->get($id)))
|
||||
return app('json')->fail('订单不存在');
|
||||
if (!$orderInfo->is_del)
|
||||
return app('json')->fail('订单用户未删除无法删除');
|
||||
$orderInfo->is_system_del = 1;
|
||||
if ($orderInfo->save())
|
||||
return app('json')->success('SUCCESS');
|
||||
else
|
||||
return app('json')->fail('ERROR');
|
||||
if ($this->services->delOrder($id)) {
|
||||
return app('json')->success(100002);
|
||||
} else {
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单发送货
|
||||
* @param $id 订单id
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_delivery($id)
|
||||
@ -149,31 +143,29 @@ class StoreIntegralOrder extends AuthController
|
||||
['fictitious_content', '']//虚拟发货内容
|
||||
]);
|
||||
$this->services->delivery((int)$id, $data);
|
||||
return app('json')->success('SUCCESS');
|
||||
return app('json')->success(100010);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 确认收货
|
||||
* @param $id 订单id
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function take_delivery($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$order = $this->services->get($id);
|
||||
if (!$order)
|
||||
return app('json')->fail('Data does not exist!');
|
||||
return app('json')->fail(100026);
|
||||
if ($order['status'] == 3)
|
||||
return app('json')->fail('不能重复收货!');
|
||||
return app('json')->fail(400114);
|
||||
if ($order['status'] == 2)
|
||||
$data['status'] = 3;
|
||||
else
|
||||
return app('json')->fail('请先发货或者送货!');
|
||||
return app('json')->fail(400115);
|
||||
|
||||
if (!$this->services->update($id, $data)) {
|
||||
return app('json')->fail('收货失败,请稍候再试!');
|
||||
return app('json')->fail(400116);
|
||||
} else {
|
||||
//增加收货订单状态
|
||||
/** @var StoreIntegralOrderStatusServices $statusService */
|
||||
@ -184,7 +176,7 @@ class StoreIntegralOrder extends AuthController
|
||||
'change_message' => '已收货',
|
||||
'change_time' => time()
|
||||
]);
|
||||
return app('json')->success('收货成功');
|
||||
return app('json')->success(400117);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,12 +188,12 @@ class StoreIntegralOrder extends AuthController
|
||||
public function order_info($id)
|
||||
{
|
||||
if (!$id || !($orderInfo = $this->services->get($id))) {
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(400118);
|
||||
}
|
||||
/** @var UserServices $services */
|
||||
$services = app()->make(UserServices::class);
|
||||
$userInfo = $services->get($orderInfo['uid']);
|
||||
if (!$userInfo) return app('json')->fail('用户信息不存在');
|
||||
if (!$userInfo) return app('json')->fail(400119);
|
||||
$userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
|
||||
$orderInfo = $this->services->tidyOrder($orderInfo->toArray());
|
||||
$userInfo = $userInfo->toArray();
|
||||
@ -216,9 +208,9 @@ class StoreIntegralOrder extends AuthController
|
||||
public function get_express($id, ExpressServices $services)
|
||||
{
|
||||
if (!$id || !($orderInfo = $this->services->get($id)))
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(400118);
|
||||
if ($orderInfo['delivery_type'] != 'express' || !$orderInfo['delivery_id'])
|
||||
return app('json')->fail('该订单不存在快递单号');
|
||||
return app('json')->fail(400120);
|
||||
|
||||
$cacheName = 'integral' . $orderInfo['order_id'] . $orderInfo['delivery_id'];
|
||||
|
||||
@ -237,7 +229,7 @@ class StoreIntegralOrder extends AuthController
|
||||
public function distribution($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(400118);
|
||||
}
|
||||
return app('json')->success($this->services->distributionForm((int)$id));
|
||||
}
|
||||
@ -249,10 +241,10 @@ class StoreIntegralOrder extends AuthController
|
||||
*/
|
||||
public function update_distribution($id)
|
||||
{
|
||||
$data = $this->request->postMore([['delivery_name', ''], ['delivery_id', '']]);
|
||||
if (!$id) return app('json')->fail('Data does not exist!');
|
||||
$data = $this->request->postMore([['delivery_name', ''], ['delivery_code', ''], ['delivery_id', '']]);
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->services->updateDistribution($id, $data);
|
||||
return app('json')->success('Modified success');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
|
||||
@ -264,18 +256,11 @@ class StoreIntegralOrder extends AuthController
|
||||
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('修改的订单不存在!');
|
||||
if ($this->services->remark($id, $data['remark'])) {
|
||||
return app('json')->success(100024);
|
||||
} else {
|
||||
return app('json')->fail(100025);
|
||||
}
|
||||
$order->remark = $data['remark'];
|
||||
if ($order->save()) {
|
||||
return app('json')->success('备注成功');
|
||||
} else
|
||||
return app('json')->fail('备注失败');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -285,7 +270,7 @@ class StoreIntegralOrder extends AuthController
|
||||
*/
|
||||
public function status(StoreIntegralOrderStatusServices $services, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($services->getStatusList(['oid' => $id])['list']);
|
||||
}
|
||||
|
||||
@ -296,16 +281,16 @@ class StoreIntegralOrder extends AuthController
|
||||
*/
|
||||
public function order_print($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$order = $this->services->get($id);
|
||||
if (!$order) {
|
||||
return app('json')->fail('订单没有查到,无法打印!');
|
||||
return app('json')->fail(400118);
|
||||
}
|
||||
$res = $this->services->orderPrint($order);
|
||||
if ($res) {
|
||||
return app('json')->success('打印成功');
|
||||
return app('json')->success(400121);
|
||||
} else {
|
||||
return app('json')->fail('打印失败');
|
||||
return app('json')->fail(400122);
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,7 +302,7 @@ class StoreIntegralOrder extends AuthController
|
||||
public function expr_temp(ServeServices $services, $com)
|
||||
{
|
||||
if (!$com) {
|
||||
return app('json')->fail('快递公司编号缺失');
|
||||
return app('json')->fail(400123);
|
||||
}
|
||||
$list = $services->express()->temp($com);
|
||||
return app('json')->success($list);
|
||||
@ -335,7 +320,7 @@ class StoreIntegralOrder extends AuthController
|
||||
|
||||
/**
|
||||
* 订单发货后打印电子面单
|
||||
* @param $orderId
|
||||
* @param $order_id
|
||||
* @param StoreOrderDeliveryServices $storeOrderDeliveryServices
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
@ -1,11 +1,22 @@
|
||||
<?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\adminapi\controller\v1\marketing\integral;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\activity\integral\StorePointRecordServices;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 积分记录
|
||||
*/
|
||||
class StorePointRecord extends AuthController
|
||||
{
|
||||
/**
|
||||
@ -41,10 +52,8 @@ class StorePointRecord extends AuthController
|
||||
[$mark] = $this->request->postMore([
|
||||
['mark', '']
|
||||
], true);
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if ($mark === '') return app('json')->fail('备注不能为空');
|
||||
$this->services->recordRemark($id, $mark);
|
||||
return app('json')->success('备注成功');
|
||||
return app('json')->success(100024);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -47,7 +47,6 @@ class LiveAnchor extends AuthController
|
||||
/**
|
||||
* 添加修改表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
@ -59,7 +58,6 @@ class LiveAnchor extends AuthController
|
||||
|
||||
/**
|
||||
* 保存标签表单数据
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
@ -71,21 +69,18 @@ class LiveAnchor extends AuthController
|
||||
['phone', ''],
|
||||
['cover_img', '']
|
||||
]);
|
||||
if (!$data['name'] = trim($data['name'])) return app('json')->fail('名称不能为空!');
|
||||
if (!$data['wechat'] = trim($data['wechat'])) return app('json')->fail('微信号不能为空!');
|
||||
if (!$data['phone'] = trim($data['phone'])) return app('json')->fail('手机号不能为空!');
|
||||
if (!check_phone($data['phone'])) return app('json')->fail('请输入正确手机号');
|
||||
if (!$data['cover_img'] = trim($data['cover_img'])) return app('json')->fail('请选择主播图像');
|
||||
$this->validate($data, \app\adminapi\validate\marketing\LiveAnchorValidate::class, 'save');
|
||||
$res = $this->services->save((int)$data['id'], $data);
|
||||
if ($res === true) {
|
||||
return app('json')->success('保存成功', ['auth' => false]);
|
||||
return app('json')->success(100000, ['auth' => false]);
|
||||
}else{
|
||||
return app('json')->fail(100006);
|
||||
}
|
||||
return app('json')->success('请先去小程序认证主播', $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete()
|
||||
@ -93,20 +88,22 @@ class LiveAnchor extends AuthController
|
||||
list($id) = $this->request->getMore([
|
||||
['id', 0],
|
||||
], true);
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->services->delAnchor((int)$id);
|
||||
return app('json')->success('刪除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置会员等级显示|隐藏
|
||||
*
|
||||
* @return json
|
||||
* @param string $id
|
||||
* @param string $is_show
|
||||
* @return mixed
|
||||
*/
|
||||
public function setShow($id = '', $is_show = '')
|
||||
{
|
||||
if ($is_show == '' || $id == '') return app('json')->fail('缺少参数');
|
||||
return app('json')->success($this->services->setShow((int)$id, (int)$is_show));
|
||||
if ($is_show == '' || $id == '') return app('json')->fail(100100);
|
||||
$this->services->setShow((int)$id, (int)$is_show);
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,6 +113,6 @@ class LiveAnchor extends AuthController
|
||||
public function syncAnchor()
|
||||
{
|
||||
$this->services->syncAnchor();
|
||||
return app('json')->success('同步成功');
|
||||
return app('json')->success(100038);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\marketing\live;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -33,6 +32,10 @@ class LiveGoods extends AuthController
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间商品列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$where = $this->request->postMore([
|
||||
@ -44,75 +47,115 @@ class LiveGoods extends AuthController
|
||||
return app('json')->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成直播商品
|
||||
* @return mixed
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
[$product_ids] = $this->request->postMore([
|
||||
['product_id', []]
|
||||
], true);
|
||||
if (!$product_ids) return app('json')->fail('请选择商品');
|
||||
return app('json')->success($this->services->create($product_ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传直播商品
|
||||
* @return mixed
|
||||
* @throws \EasyWeChat\Core\Exceptions\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
[$goods_info] = $this->request->postMore([
|
||||
['goods_info', []]
|
||||
], true);
|
||||
if (!$goods_info) return app('json')->fail('请选择商品');
|
||||
foreach ($goods_info as $goods) {
|
||||
if (!$goods['id']) return app('json')->fail('请选择商品');
|
||||
if (!$goods['store_name']) return app('json')->fail('请输入名称');
|
||||
if (!$goods['image']) return app('json')->fail('请选择背景图');
|
||||
if (!$goods['price']) return app('json')->fail('请输入直播价格');
|
||||
if ($goods['price'] <= 0) return app('json')->fail('直播价格必须大于0');
|
||||
$this->validate($goods, \app\adminapi\validate\marketing\LiveGoodsValidate::class, 'save');
|
||||
}
|
||||
$this->services->add($goods_info);
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
if (!$id)
|
||||
return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$goods = $this->services->get($id, ['*'], ['product']);
|
||||
return app('json')->success('ok', $goods ? $goods->toArray() : []);
|
||||
return app('json')->success($goods ? $goods->toArray() : []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步直播商品
|
||||
* @return mixed
|
||||
*/
|
||||
public function syncGoods()
|
||||
{
|
||||
$this->services->syncGoodStatus();
|
||||
return app('json')->success('同步成功');
|
||||
return app('json')->success(100038);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新提交审核
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function audit($id)
|
||||
{
|
||||
if (!$id)
|
||||
return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->services->audit((int)$id);
|
||||
return app('json')->success('提交审核成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回审核
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function resetAudit($id)
|
||||
{
|
||||
if (!$id)
|
||||
return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->services->resetAudit((int)$id);
|
||||
return app('json')->success('撤销成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态
|
||||
* @param int $id
|
||||
* @param $is_show
|
||||
* @return mixed
|
||||
*/
|
||||
public function setShow(int $id, $is_show)
|
||||
{
|
||||
if (!$id)
|
||||
return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->isShow($id, $is_show));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id)
|
||||
return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->services->delete($id);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\marketing\live;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -33,6 +32,10 @@ class LiveRoom extends AuthController
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$where = $this->request->postMore([
|
||||
@ -42,13 +45,21 @@ class LiveRoom extends AuthController
|
||||
return app('json')->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
if (!$id)
|
||||
return app('json')->fail('数据不存在');
|
||||
return app('json')->success('ok', $this->services->get((int)$id)->toArray());
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->get((int)$id)->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加直播间
|
||||
* @return mixed
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
@ -67,63 +78,74 @@ class LiveRoom extends AuthController
|
||||
['replay_status', 1],
|
||||
['sort', 0]
|
||||
]);
|
||||
if (!$data['name']) return app('json')->fail('请输入名称');
|
||||
if (!$data['cover_img']) return app('json')->fail('请选择背景图');
|
||||
if (!$data['share_img']) return app('json')->fail('请选择分享图');
|
||||
if (!$data['anchor_wechat']) return app('json')->fail('请选择主播');
|
||||
if (!$data['start_time'] || count($data['start_time']) != 2) return app('json')->fail('请选择直播开始、结束时间');
|
||||
if (!$data['phone'] || !check_phone($data['phone'])) return app('json')->fail('请输入正确手机号');
|
||||
[$data['start_time'], $data['end_time']] = $data['start_time'];
|
||||
$this->validate($data, \app\adminapi\validate\marketing\LiveRoomValidate::class, 'save');
|
||||
$this->services->add($data);
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加直播间商品
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function addGoods()
|
||||
{
|
||||
[$room_id, $goods_ids] = $this->request->postMore([
|
||||
['room_id', 0],
|
||||
['goods_ids', []]
|
||||
], true);
|
||||
if (!$room_id) return app('json')->fail('请选择直播间');
|
||||
if (!$goods_ids) return app('json')->fail('请选择商品');
|
||||
$this->services->exportGoods((int)$room_id, $goods_ids);
|
||||
return app('json')->success('添加商品成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交审核
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function apply($id)
|
||||
{
|
||||
[$status, $msg] = $this->request->postMore([
|
||||
['status', ''],
|
||||
['msg', '']
|
||||
], true);
|
||||
if (!$id)
|
||||
return app('json')->fail('数据不存在');
|
||||
$status = $status == 1 ? 1 : -1;
|
||||
if ($status == -1 && !$msg)
|
||||
return app('json')->fail('请输入理由');
|
||||
$this->services->apply((int)$id, $status, $msg);
|
||||
return app('json')->success('操作成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态
|
||||
* @param $id
|
||||
* @param $is_show
|
||||
* @return mixed
|
||||
*/
|
||||
public function setShow($id, $is_show)
|
||||
{
|
||||
if (!$id)
|
||||
return app('json')->fail('数据不存在');
|
||||
return app('json')->success($this->services->isShow((int)$id, $is_show));
|
||||
$this->services->isShow((int)$id, $is_show);
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除直播间
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id)
|
||||
return app('json')->fail('数据不存在');
|
||||
$this->services->delete($id);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步直播间
|
||||
* @return mixed
|
||||
*/
|
||||
public function syncRoom()
|
||||
{
|
||||
$this->services->syncRoomStatus();
|
||||
return app('json')->success('同步成功');
|
||||
return app('json')->success(100038);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -35,6 +35,10 @@ class LuckLottery extends AuthController
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 抽奖列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->postMore([
|
||||
@ -46,22 +50,42 @@ class LuckLottery extends AuthController
|
||||
return app('json')->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 抽奖活动详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数id');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->getlotteryInfo((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取详情
|
||||
* @param $factor
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function factorInfo($factor)
|
||||
{
|
||||
if (!$factor) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->getlotteryFactorInfo((int)$factor));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加抽奖
|
||||
* @return mixed
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
@ -86,27 +110,35 @@ class LuckLottery extends AuthController
|
||||
['prize', []]
|
||||
]);
|
||||
if (!$data['name']) {
|
||||
return app('json')->fail('请添加抽奖活动名称');
|
||||
return app('json')->fail(400501);
|
||||
}
|
||||
if ($data['is_content'] && !$data['content']) {
|
||||
return app('json')->fail('请添加抽奖描述等文案');
|
||||
return app('json')->fail(400502);
|
||||
}
|
||||
[$start, $end] = $data['period'];
|
||||
unset($data['period']);
|
||||
$data['start_time'] = $start ? strtotime($start) : 0;
|
||||
$data['end_time'] = $end ? strtotime($end) : 0;
|
||||
if ($data['start_time'] && $data['end_time'] && $data['end_time'] <= $data['start_time']) {
|
||||
return app('json')->fail('活动结束时间必须大于开始时间');
|
||||
return app('json')->fail(400503);
|
||||
}
|
||||
if (!$data['prize']) {
|
||||
return app('json')->fail('请添加奖品');
|
||||
return app('json')->fail(400504);
|
||||
}
|
||||
if (in_array($data['factor'], [1, 2]) && !$data['factor_num']) {
|
||||
return app('json')->fail('请填写消耗' . ($data['factor'] == '1' ? '积分' : '余额') . '数量');
|
||||
return app('json')->fail(400505);
|
||||
}
|
||||
return app('json')->success($this->services->add($data) ? '添加成功' : '添加失败');
|
||||
return app('json')->success($this->services->add($data) ? 100000 : 100006);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改抽奖
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
@ -131,52 +163,60 @@ class LuckLottery extends AuthController
|
||||
['prize', []]
|
||||
]);
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数id');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
if (!$data['name']) {
|
||||
return app('json')->fail('请添加抽奖活动名称');
|
||||
return app('json')->fail(400501);
|
||||
}
|
||||
[$start, $end] = $data['period'];
|
||||
unset($data['period']);
|
||||
$data['start_time'] = $start ? strtotime($start) : 0;
|
||||
$data['end_time'] = $end ? strtotime($end) : 0;
|
||||
if ($data['start_time'] && $data['end_time'] && $data['end_time'] <= $data['start_time']) {
|
||||
return app('json')->fail('活动结束时间必须大于开始时间');
|
||||
return app('json')->fail(400503);
|
||||
}
|
||||
if ($data['is_content'] && !$data['content']) {
|
||||
return app('json')->fail('请添加抽奖描述等文案');
|
||||
return app('json')->fail(400502);
|
||||
}
|
||||
if (!$data['prize']) {
|
||||
return app('json')->fail('请添加奖品');
|
||||
return app('json')->fail(400504);
|
||||
}
|
||||
if (in_array($data['factor'], [1, 2]) && !$data['factor_num']) {
|
||||
return app('json')->fail('请填写消耗' . ($data['factor'] == '1' ? '积分' : '余额') . '数量');
|
||||
return app('json')->fail(400505);
|
||||
}
|
||||
return app('json')->success($this->services->edit((int)$id, $data) ? '编辑成功' : '编辑失败');
|
||||
return app('json')->success($this->services->edit((int)$id, $data) ? 100001 : 100007);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $id
|
||||
* @throws \Exception
|
||||
* 删除抽奖
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
list($id) = $this->request->getMore([
|
||||
['id', 0],
|
||||
], true);
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100026);
|
||||
$this->services->delLottery((int)$id);
|
||||
return app('json')->success('刪除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置活动状态
|
||||
* @return json
|
||||
* @param string $id
|
||||
* @param string $status
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function setStatus($id = '', $status = '')
|
||||
{
|
||||
if ($status == '' || $id == '') return app('json')->fail('缺少参数');
|
||||
return app('json')->success($this->services->setStatus((int)$id, (int)$status) ? '上架成功' : '下架成功');
|
||||
if ($status == '' || $id == '') return app('json')->fail(100100);
|
||||
$this->services->setStatus((int)$id, (int)$status);
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -35,7 +35,10 @@ class LuckLotteryRecord extends AuthController
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 抽奖记录列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->postMore([
|
||||
@ -49,6 +52,14 @@ class LuckLotteryRecord extends AuthController
|
||||
return app('json')->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 中奖发货
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function deliver($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
@ -57,8 +68,9 @@ class LuckLotteryRecord extends AuthController
|
||||
['mark', ''],
|
||||
]);
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少ID');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->setDeliver((int)$id, $data) ? '处理成功' : '处理失败');
|
||||
$this->services->setDeliver((int)$id, $data);
|
||||
return app('json')->success($this->services->setDeliver((int)$id, $data) ? 100014 : 100015);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\v1\marketing\lottery;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\activity\lottery\LuckPrizeServices;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 抽奖奖品
|
||||
* Class LuckPrize
|
||||
* @package app\controller\admin\v1\marketing\lottery
|
||||
*/
|
||||
class LuckPrize extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* LuckPrize constructor.
|
||||
* @param App $app
|
||||
* @param LuckPrizeServices $services
|
||||
*/
|
||||
public function __construct(App $app, LuckPrizeServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['type', 1],
|
||||
['lottery_id', 0],
|
||||
['name', ''],
|
||||
['prompt', ''],
|
||||
['image', ''],
|
||||
['chance', 1],
|
||||
['total', 1],
|
||||
['couon_id', 0],
|
||||
['product_id', 0],
|
||||
['unique', ''],
|
||||
['num', 1]
|
||||
]);
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数id');
|
||||
}
|
||||
if (!$data['lottery_id']) {
|
||||
return app('json')->fail('缺少抽奖活动id');
|
||||
}
|
||||
return app('json')->success($this->services->edit((int)$id, $data) ? '编辑成功' : '编辑失败');
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -35,8 +35,11 @@ class SystemStore extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取门店列表1
|
||||
* 门店列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -80,7 +83,7 @@ class SystemStore extends AuthController
|
||||
public function select_address()
|
||||
{
|
||||
$key = sys_config('tengxun_map_key');
|
||||
if (!$key) return app('json')->fail('请前往设置->系统设置->第三方接口设置 配置腾讯地图KEY');
|
||||
if (!$key) return app('json')->fail(400124);
|
||||
return app('json')->success(compact('key'));
|
||||
}
|
||||
|
||||
@ -88,23 +91,24 @@ class SystemStore extends AuthController
|
||||
* 设置单个门店是否显示
|
||||
* @param string $is_show
|
||||
* @param string $id
|
||||
* @return json
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_show($is_show = '', $id = '')
|
||||
{
|
||||
($is_show == '' || $id == '') && app('json')->fail('缺少参数');
|
||||
($is_show == '' || $id == '') && app('json')->fail(100100);
|
||||
$res = $this->services->update((int)$id, ['is_show' => (int)$is_show]);
|
||||
if ($res) {
|
||||
return app('json')->success($is_show == 1 ? '设置显示成功' : '设置隐藏成功');
|
||||
return app('json')->success(100014);
|
||||
} else {
|
||||
return app('json')->fail($is_show == 1 ? '设置显示失败' : '设置隐藏失败');
|
||||
return app('json')->fail(100015);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存修改门店信息
|
||||
* param int $id
|
||||
* */
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save($id = 0)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
@ -123,7 +127,7 @@ class SystemStore extends AuthController
|
||||
$data['address'] = implode(',', $data['address']);
|
||||
$data['latlng'] = explode(',', $data['latlng']);
|
||||
if (!isset($data['latlng'][0]) || !isset($data['latlng'][1])) {
|
||||
return app('json')->fail('请选择门店位置');
|
||||
return app('json')->fail(400125);
|
||||
}
|
||||
$data['latitude'] = $data['latlng'][0];
|
||||
$data['longitude'] = $data['latlng'][1];
|
||||
@ -134,32 +138,33 @@ class SystemStore extends AuthController
|
||||
$data['image'] = $site_url . $data['image'];
|
||||
}
|
||||
$this->services->saveStore((int)$id, $data);
|
||||
return app('json')->success('操作成功!');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除恢复门店
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$storeInfo = $this->services->get($id);
|
||||
if (!$storeInfo) {
|
||||
return app('json')->fail('数据不存在');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
if ($storeInfo->is_del == 1) {
|
||||
$storeInfo->is_del = 0;
|
||||
if (!$storeInfo->save())
|
||||
return app('json')->fail('恢复失败,请稍候再试!');
|
||||
return app('json')->fail(100041);
|
||||
else
|
||||
return app('json')->success('恢复门店成功!');
|
||||
return app('json')->success(100040);
|
||||
} else {
|
||||
$storeInfo->is_del = 1;
|
||||
if (!$storeInfo->save())
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else
|
||||
return app('json')->success('删除门店成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -37,6 +37,9 @@ class SystemStoreStaff extends AuthController
|
||||
/**
|
||||
* 获取店员列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -48,6 +51,7 @@ class SystemStoreStaff extends AuthController
|
||||
|
||||
/**
|
||||
* 门店列表
|
||||
* @param SystemStoreServices $services
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
@ -62,6 +66,9 @@ class SystemStoreStaff extends AuthController
|
||||
* 店员新增表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@ -72,6 +79,9 @@ class SystemStoreStaff extends AuthController
|
||||
* 店员修改表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
@ -83,6 +93,8 @@ class SystemStoreStaff extends AuthController
|
||||
|
||||
/**
|
||||
* 保存店员信息
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save($id = 0)
|
||||
{
|
||||
@ -96,13 +108,12 @@ class SystemStoreStaff extends AuthController
|
||||
['verify_status', 1],
|
||||
['status', 1],
|
||||
]);
|
||||
|
||||
if (!$id) {
|
||||
if ($data['image'] == '') {
|
||||
return app('json')->fail('请选择用户');
|
||||
return app('json')->fail(400250);
|
||||
}
|
||||
if ($this->services->count(['uid' => $data['uid']])) {
|
||||
return app('json')->fail('添加的核销员用户已存在!');
|
||||
if ($this->services->count(['uid' => $data['image']['uid']])) {
|
||||
return app('json')->fail(400126);
|
||||
}
|
||||
$data['uid'] = $data['image']['uid'];
|
||||
$data['avatar'] = $data['image']['image'];
|
||||
@ -110,32 +121,32 @@ class SystemStoreStaff extends AuthController
|
||||
$data['avatar'] = $data['image'];
|
||||
}
|
||||
if ($data['uid'] == 0) {
|
||||
return app('json')->fail('请选择用户');
|
||||
return app('json')->fail(400250);
|
||||
}
|
||||
if ($data['store_id'] == '') {
|
||||
return app('json')->fail('请选择所属提货点');
|
||||
return app('json')->fail(400127);
|
||||
}
|
||||
if ($data['staff_name'] == ''){
|
||||
return app('json')->fail('请填写核销员名称');
|
||||
return app('json')->fail(400128);
|
||||
}
|
||||
if ($data['phone'] == ''){
|
||||
return app('json')->fail('请填写核销员电话');
|
||||
return app('json')->fail(400129);
|
||||
}
|
||||
unset($data['image']);
|
||||
if ($id) {
|
||||
$res = $this->services->update($id, $data);
|
||||
if ($res) {
|
||||
return app('json')->success('编辑成功');
|
||||
return app('json')->success(100001);
|
||||
} else {
|
||||
return app('json')->fail('编辑失败');
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
} else {
|
||||
$data['add_time'] = time();
|
||||
$res = $this->services->save($data);
|
||||
if ($res) {
|
||||
return app('json')->success('核销员添加成功');
|
||||
return app('json')->success(400130);
|
||||
} else {
|
||||
return app('json')->fail('核销员添加失败,请稍后再试');
|
||||
return app('json')->fail(400131);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -149,26 +160,27 @@ class SystemStoreStaff extends AuthController
|
||||
public function set_show($is_show = '', $id = '')
|
||||
{
|
||||
if ($is_show == '' || $id == '') {
|
||||
app('json')->fail('缺少参数');
|
||||
app('json')->fail(100100);
|
||||
}
|
||||
$res = $this->services->update($id, ['status' => (int)$is_show]);
|
||||
if ($res) {
|
||||
return app('json')->success($is_show == 1 ? '开启成功' : '关闭成功');
|
||||
return app('json')->success(100014);
|
||||
} else {
|
||||
return app('json')->fail($is_show == 1 ? '开启失败' : '关闭失败');
|
||||
return app('json')->fail(100015);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店员
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -11,7 +11,7 @@
|
||||
namespace app\adminapi\controller\v1\notification\sms;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\message\sms\SmsAdminServices;
|
||||
use app\services\yihaotong\SmsAdminServices;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
@ -40,17 +40,18 @@ class SmsAdmin extends AuthController
|
||||
public function captcha()
|
||||
{
|
||||
if (!request()->isPost()) {
|
||||
return app('json')->fail('发送失败');
|
||||
return app('json')->fail(100031);
|
||||
}
|
||||
$phone = request()->param('phone');
|
||||
if (!trim($phone)) {
|
||||
return app('json')->fail('请填写手机号');
|
||||
return app('json')->fail(400132);
|
||||
}
|
||||
return app('json')->success($this->services->captcha($phone));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改/注册短信平台账号
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
@ -63,13 +64,13 @@ class SmsAdmin extends AuthController
|
||||
['sign', ''],
|
||||
], true);
|
||||
$signLen = mb_strlen(trim($sign));
|
||||
if (!strlen(trim($account))) return app('json')->fail('请填写账号');
|
||||
if (!strlen(trim($password))) return app('json')->fail('请填写密码');
|
||||
if (!$signLen) return app('json')->fail('请填写短信签名');
|
||||
if ($signLen > 8) return app('json')->fail('短信签名最长为8位');
|
||||
if (!strlen(trim($code))) return app('json')->fail('请填写验证码');
|
||||
if (!strlen(trim($url))) return app('json')->fail('请填写域名');
|
||||
if (!strlen(trim($account))) return app('json')->fail(400133);
|
||||
if (!strlen(trim($password))) return app('json')->fail(400134);
|
||||
if (!$signLen) return app('json')->fail(400135);
|
||||
if ($signLen > 8) return app('json')->fail(400136);
|
||||
if (!strlen(trim($code))) return app('json')->fail(400137);
|
||||
if (!strlen(trim($url))) return app('json')->fail(400138);
|
||||
$status = $this->services->register($account, $password, $url, $phone, $code, $sign);
|
||||
return app('json')->success('短信平台:' . $status['msg']);
|
||||
return app('json')->success($status['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,7 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\notification\sms;
|
||||
|
||||
use app\services\message\sms\SmsAdminServices;
|
||||
use app\services\yihaotong\SmsAdminServices;
|
||||
use app\services\serve\ServeServices;
|
||||
use crmeb\services\CacheService;
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -35,10 +35,10 @@ class SmsConfig extends AuthController
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存短信配置
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function save_basics()
|
||||
{
|
||||
@ -50,15 +50,17 @@ class SmsConfig extends AuthController
|
||||
$this->validate(['sms_account' => $account, 'sms_token' => $token], \app\adminapi\validate\notification\SmsConfigValidate::class);
|
||||
|
||||
if ($this->services->login($account, $token)) {
|
||||
return app('json')->success('登录成功');
|
||||
return app('json')->success(400139);
|
||||
} else {
|
||||
return app('json')->fail('账号或密码错误');
|
||||
return app('json')->fail(400140);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测登录
|
||||
* @param ServeServices $services
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function is_login(ServeServices $services)
|
||||
{
|
||||
@ -105,14 +107,15 @@ class SmsConfig extends AuthController
|
||||
if ($res) {
|
||||
$this->services->updateSmsConfig('', '');
|
||||
CacheService::clear();
|
||||
return app('json')->success('退出成功');
|
||||
return app('json')->success(100042);
|
||||
} else {
|
||||
return app('json')->fail('退出失败');
|
||||
return app('json')->fail(100043);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信发送记录
|
||||
* @param ServeServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function record(ServeServices $services)
|
||||
@ -126,6 +129,7 @@ class SmsConfig extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登陆的短信账号信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function data()
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,7 +10,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\notification\sms;
|
||||
|
||||
use crmeb\exceptions\AdminException;
|
||||
use app\adminapi\controller\AuthController;
|
||||
use crmeb\services\{sms\Sms};
|
||||
|
||||
@ -26,21 +25,25 @@ class SmsPay extends AuthController
|
||||
*/
|
||||
protected $smsHandle;
|
||||
|
||||
/**
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
$this->smsHandle = new Sms('yunxin', [
|
||||
$this->smsHandle = new Sms('yihaotong', [
|
||||
'sms_account' => sys_config('sms_account'),
|
||||
'sms_token' => sys_config('sms_token'),
|
||||
'site_url' => sys_config('site_url')
|
||||
]);
|
||||
if (!$this->smsHandle->isLogin()) {
|
||||
throw new AdminException('请先填写短息配置');
|
||||
return app('json')->fail(400141);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号信息
|
||||
* 获取账号信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function number()
|
||||
{
|
||||
@ -53,7 +56,8 @@ class SmsPay extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付套餐
|
||||
* 获取支付套餐
|
||||
* @return mixed
|
||||
*/
|
||||
public function price()
|
||||
{
|
||||
@ -68,6 +72,7 @@ class SmsPay extends AuthController
|
||||
|
||||
/**
|
||||
* 获取支付码
|
||||
* @return mixed
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -11,7 +11,6 @@
|
||||
namespace app\adminapi\controller\v1\notification\sms;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\services\sms\Sms;
|
||||
|
||||
/**
|
||||
@ -26,21 +25,25 @@ class SmsPublicTemp extends AuthController
|
||||
*/
|
||||
protected $smsHandle;
|
||||
|
||||
/**
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
$this->smsHandle = new Sms('yunxin', [
|
||||
$this->smsHandle = new Sms('yihaotong', [
|
||||
'sms_account' => sys_config('sms_account'),
|
||||
'sms_token' => sys_config('sms_token'),
|
||||
'site_url' => sys_config('site_url')
|
||||
]);
|
||||
if (!$this->smsHandle->isLogin()) {
|
||||
throw new AdminException('请先填写短息配置');
|
||||
return app('json')->fail(400141);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步获取公共模板列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -71,5 +74,4 @@ class SmsPublicTemp extends AuthController
|
||||
$templateList['data']['data'] = $arr;
|
||||
return app('json')->success($templateList['data']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -21,7 +21,10 @@ use think\facade\App;
|
||||
*/
|
||||
class SmsTemplateApply extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param App $app
|
||||
* @param ServeServices $services
|
||||
*/
|
||||
public function __construct(App $app, ServeServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
@ -30,6 +33,7 @@ class SmsTemplateApply extends AuthController
|
||||
|
||||
/**
|
||||
* 异步获取模板列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -61,9 +65,8 @@ class SmsTemplateApply extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return string
|
||||
* 显示创建资源表单页
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
@ -73,6 +76,7 @@ class SmsTemplateApply extends AuthController
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
@ -82,12 +86,12 @@ class SmsTemplateApply extends AuthController
|
||||
['type', 0]
|
||||
]);
|
||||
if (!strlen(trim($data['title']))) {
|
||||
return app('json')->fail('请输入模板名称');
|
||||
return app('json')->fail(400142);
|
||||
}
|
||||
if (!strlen(trim($data['content']))) {
|
||||
return app('json')->fail('请输入模板内容');
|
||||
return app('json')->fail(400143);
|
||||
}
|
||||
$this->services->sms()->apply($data['title'], $data['content'], $data['type']);
|
||||
return app('json')->success('申请成功');
|
||||
return app('json')->success(100027);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -12,13 +12,11 @@ namespace app\adminapi\controller\v1\order;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\order\DeliveryServiceServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\user\UserWechatuserServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 客服管理
|
||||
* 配送员管理
|
||||
* Class StoreService
|
||||
* @package app\admin\controller\store
|
||||
*/
|
||||
@ -36,31 +34,17 @@ class DeliveryService extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* 配送员列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return app('json')->success($this->services->getServiceList([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create(UserWechatuserServices $services)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['nickname', ''],
|
||||
['data', '', '', 'time'],
|
||||
['type', '', '', 'user_type'],
|
||||
]);
|
||||
[$list, $count] = $services->getWhereUserList($where, 'u.nickname,u.uid,u.avatar as headimgurl,w.subscribe,w.province,w.country,w.city,w.sex');
|
||||
return app('json')->success(compact('list', 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加客服表单
|
||||
* @return mixed
|
||||
@ -71,8 +55,9 @@ class DeliveryService extends AuthController
|
||||
return app('json')->success($this->services->create());
|
||||
}
|
||||
|
||||
/*
|
||||
* 保存新建的资源
|
||||
/**
|
||||
* 保存配送员
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
@ -84,42 +69,16 @@ class DeliveryService extends AuthController
|
||||
['nickname', ''],
|
||||
['status', 1],
|
||||
]);
|
||||
if ($data['image'] == '') return app('json')->fail('请选择用户');
|
||||
$data['uid'] = $data['image']['uid'];
|
||||
/** @var UserServices $userService */
|
||||
$userService = app()->make(UserServices::class);
|
||||
$userInfo = $userService->get($data['uid']);
|
||||
if ($data['phone'] == '' && !$userInfo['phone']) {
|
||||
throw new AdminException('该用户没有绑定手机号,请手动填写');
|
||||
}
|
||||
$data['phone'] = $userInfo['phone'];
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail('请输入正确的手机号!');
|
||||
}
|
||||
|
||||
if ($data['nickname'] == '') $data['nickname'] = $userInfo['nickname'];
|
||||
$data['avatar'] = $data['image']['image'];
|
||||
if ($this->services->count(['uid' => $data['uid']])) {
|
||||
return app('json')->fail('配送员已存在!');
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone']])) {
|
||||
return app('json')->fail('同一个手机号的配送员只能添加一个!');
|
||||
}
|
||||
unset($data['image']);
|
||||
$data['add_time'] = time();
|
||||
$res = $this->services->save($data);
|
||||
if ($res) {
|
||||
return app('json')->success('配送员添加成功');
|
||||
} else {
|
||||
return app('json')->fail('配送员添加失败,请稍后再试');
|
||||
}
|
||||
|
||||
$this->services->saveDeliveryService($data);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 编辑表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
@ -127,10 +86,9 @@ class DeliveryService extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
* 修改配送员
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
@ -140,38 +98,22 @@ class DeliveryService extends AuthController
|
||||
['phone', ''],
|
||||
['status', 1],
|
||||
]);
|
||||
$delivery = $this->services->get((int)$id);
|
||||
if (!$delivery) {
|
||||
return app('json')->fail('数据不存在');
|
||||
}
|
||||
if ($data["nickname"] == '') {
|
||||
return app('json')->fail("配送员名称不能为空!");
|
||||
}
|
||||
if (!$data['phone']) {
|
||||
return app('json')->fail("手机号不能为空!");
|
||||
}
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail('请输入正确的手机号!');
|
||||
}
|
||||
if ($delivery['phone'] != $data['phone'] && $this->services->count(['phone' => $data['phone']])) {
|
||||
return app('json')->fail('同一个手机号的配送员只能添加一个!');
|
||||
}
|
||||
$this->services->update($id, $data);
|
||||
return app('json')->success('修改成功!');
|
||||
|
||||
$this->services->updateDeliveryService((int)$id, $data);
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* 删除配送员
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,13 +124,14 @@ class DeliveryService extends AuthController
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
if ($status == '' || $id == 0) return app('json')->fail(100100);
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
*获取所有配送员列表
|
||||
* 获取所有配送员列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_delivery_list()
|
||||
{
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\v1\order;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
@ -18,6 +17,7 @@ use crmeb\utils\Canvas;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 线下收银
|
||||
* Class OtherOrder
|
||||
* @package app\adminapi\controller\v1\order
|
||||
*/
|
||||
@ -34,8 +34,8 @@ class OtherOrder extends AuthController
|
||||
$this->services = $service;
|
||||
}
|
||||
|
||||
|
||||
/**线下收银
|
||||
/**
|
||||
* 线下收银订单列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
@ -54,8 +54,10 @@ class OtherOrder extends AuthController
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/** 获取线下二维码
|
||||
/**
|
||||
* 线下收银二维码
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function offline_scan()
|
||||
{
|
||||
|
||||
@ -1,18 +1,31 @@
|
||||
<?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\adminapi\controller\v1\order;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\Request;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\wechat\WechatUserServices;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 退款订单
|
||||
* Class RefundOrder
|
||||
* @package app\adminapi\controller\v1\order
|
||||
*/
|
||||
class RefundOrder extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* RefundOrder constructor.
|
||||
* @param App $app
|
||||
@ -28,9 +41,6 @@ class RefundOrder extends AuthController
|
||||
/**
|
||||
* 退款订单列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getRefundList()
|
||||
{
|
||||
@ -64,30 +74,23 @@ class RefundOrder extends AuthController
|
||||
public function agreeExpress($id)
|
||||
{
|
||||
$this->services->agreeExpress($id);
|
||||
return app('json')->success('操作成功');
|
||||
return app('json')->success(100010);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改备注
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function remark($id)
|
||||
{
|
||||
$data = $this->request->postMore([['remark', '']]);
|
||||
if (!$data['remark'])
|
||||
return app('json')->fail('请输入要备注的内容');
|
||||
if (!$id)
|
||||
return app('json')->fail('缺少参数');
|
||||
[$remark] = $this->request->postMore([['remark', '']],true);
|
||||
|
||||
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('备注失败');
|
||||
$this->services->updateRemark((int)$id, $remark);
|
||||
return app('json')->success(100024);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,16 +101,19 @@ class RefundOrder extends AuthController
|
||||
*/
|
||||
public function refund($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('Data does not exist!');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->refundOrderForm((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
* 订单退款(产品)
|
||||
* @param Request $request
|
||||
* @param StoreOrderServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function refundPrice(Request $request, StoreOrderServices $services, $id)
|
||||
{
|
||||
@ -116,21 +122,21 @@ class RefundOrder extends AuthController
|
||||
['type', 1]
|
||||
]);
|
||||
if (!$id) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$orderRefund = $this->services->get($id);
|
||||
if (!$orderRefund) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
if ($orderRefund['is_cancel'] == 1) {
|
||||
return app('json')->fail('用户已取消申请');
|
||||
return app('json')->fail(400118);
|
||||
}
|
||||
$order = $services->get((int)$orderRefund['store_order_id']);
|
||||
if (!$order) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
if (!in_array($orderRefund['refund_type'], [1, 5])) {
|
||||
return app('json')->fail('售后订单状态不支持该操作');
|
||||
return app('json')->fail(400144);
|
||||
}
|
||||
|
||||
if ($data['type'] == 1) {
|
||||
@ -143,24 +149,24 @@ class RefundOrder extends AuthController
|
||||
//拒绝退款
|
||||
if ($type == 2) {
|
||||
$this->services->refuseRefund((int)$id, $data, $orderRefund);
|
||||
return app('json')->successful('修改退款状态成功!');
|
||||
return app('json')->success(400145);
|
||||
} else {
|
||||
//0元退款
|
||||
if ($orderRefund['refund_price'] == 0 && in_array($orderRefund['refund_type'], [1, 5])) {
|
||||
$refund_price = 0;
|
||||
} else {
|
||||
if (!$data['refund_price']) {
|
||||
return app('json')->fail('请输入退款金额');
|
||||
return app('json')->fail(400146);
|
||||
}
|
||||
if ($orderRefund['refund_price'] == $orderRefund['refunded_price']) {
|
||||
return app('json')->fail('已退完支付金额!不能再退款了');
|
||||
return app('json')->fail(400147);
|
||||
}
|
||||
$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('退款金额大于支付金额,请修改退款金额');
|
||||
return app('json')->fail(400148);
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,14 +177,19 @@ class RefundOrder extends AuthController
|
||||
mt_srand();
|
||||
$refund_data['refund_id'] = $order['order_id'] . rand(100, 999);
|
||||
}
|
||||
($order['pid'] > 0) ? $refund_data['order_id'] = $services->value(['id'=>(int)$order['pid']],'order_id') : $refund_data['order_id'] = $order['order_id'];
|
||||
/** @var WechatUserServices $wechatUserServices */
|
||||
$wechatUserServices = app()->make(WechatUserServices::class);
|
||||
$refund_data['open_id'] = $wechatUserServices->uidToOpenid((int)$order['uid'],'routine') ?? '';
|
||||
$refund_data['refund_no'] = $orderRefund['order_id'];
|
||||
//修改订单退款状态
|
||||
unset($data['refund_price']);
|
||||
if ($this->services->agreeRefund($id, $refund_data)) {
|
||||
$this->services->update($id, $data);
|
||||
return app('json')->success('退款成功');
|
||||
return app('json')->success(400149);
|
||||
} else {
|
||||
$this->services->storeProductOrderRefundYFasle((int)$id, $refund_price);
|
||||
return app('json')->fail('退款失败');
|
||||
return app('json')->fail(400150);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -191,31 +202,22 @@ class RefundOrder extends AuthController
|
||||
*/
|
||||
public function noRefund($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('Data does not exist!');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->noRefundForm((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单不退款
|
||||
* @param StoreOrderRefundServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function refuseRefund($id)
|
||||
{
|
||||
if (!$id || !($orderRefundInfo = $this->services->get($id)))
|
||||
return app('json')->fail('订单不存在');
|
||||
[$refund_reason] = $this->request->postMore([['refund_reason', '']], true);
|
||||
if (!$refund_reason) {
|
||||
return app('json')->fail('请输入不退款原因');
|
||||
}
|
||||
$refundData = [
|
||||
'refuse_reason' => $refund_reason,
|
||||
'refund_type' => 3,
|
||||
'refunded_time' => time()
|
||||
];
|
||||
//拒绝退款处理
|
||||
$this->services->refuseRefund((int)$id, $refundData, $orderRefundInfo);
|
||||
return app('json')->success('Modified success');
|
||||
$this->services->refuse($id, $refund_reason);
|
||||
return app('json')->success(100010);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,7 +10,6 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\order;
|
||||
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\adminapi\validate\order\StoreOrderValidate;
|
||||
use app\services\serve\ServeServices;
|
||||
@ -62,8 +61,11 @@ class StoreOrder extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
* 订单列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function lst()
|
||||
{
|
||||
@ -86,12 +88,11 @@ class StoreOrder extends AuthController
|
||||
|
||||
/**
|
||||
* 核销码核销
|
||||
* @param $code 核销码
|
||||
* @param int $confirm 确认核销 0=确认,1=核销
|
||||
* @param StoreOrderWriteOffServices $services
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function write_order(StoreOrderWriteOffServices $services)
|
||||
{
|
||||
@ -99,12 +100,12 @@ class StoreOrder extends AuthController
|
||||
['code', ''],
|
||||
['confirm', 0]
|
||||
], true);
|
||||
if (!$code) return app('json')->fail('Lack of write-off code');
|
||||
if (!$code) return app('json')->fail(100100);
|
||||
$orderInfo = $services->writeOffOrder($code, (int)$confirm);
|
||||
if ($confirm == 0) {
|
||||
return app('json')->success('验证成功', $orderInfo);
|
||||
return app('json')->success(400151, $orderInfo);
|
||||
}
|
||||
return app('json')->success('Write off successfully');
|
||||
return app('json')->success(400152);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,39 +121,41 @@ class StoreOrder extends AuthController
|
||||
{
|
||||
$orderInfo = $this->services->getOne(['order_id' => $order_id, 'is_del' => 0]);
|
||||
if ($orderInfo->shipping_type != 2 && $orderInfo->delivery_type != 'send') {
|
||||
return app('json')->fail('核销订单未查到!');
|
||||
return app('json')->fail(400153);
|
||||
} else {
|
||||
if (!$orderInfo->verify_code) {
|
||||
return app('json')->fail('Lack of write-off code');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$orderInfo = $services->writeOffOrder($orderInfo->verify_code, 1);
|
||||
if ($orderInfo) {
|
||||
return app('json')->success('Write off successfully');
|
||||
return app('json')->success(400151);
|
||||
} else {
|
||||
return app('json')->fail('核销失败!');
|
||||
return app('json')->fail(400154);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改支付金额等
|
||||
* 订单改价表单
|
||||
* @param $id
|
||||
* @return mixed|\think\response\Json|void
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('Data does not exist!');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->updateForm($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改订单
|
||||
* 订单改价
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('Missing order ID');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$data = $this->request->postMore([
|
||||
['order_id', ''],
|
||||
['total_price', 0],
|
||||
@ -164,11 +167,11 @@ class StoreOrder extends AuthController
|
||||
|
||||
$this->validate($data, StoreOrderValidate::class);
|
||||
|
||||
if ($data['total_price'] < 0) return app('json')->fail('Please enter the total price');
|
||||
if ($data['pay_price'] < 0) return app('json')->fail('Please enter the actual payment amount');
|
||||
if ($data['total_price'] < 0) return app('json')->fail(400155);
|
||||
if ($data['pay_price'] < 0) return app('json')->fail(400155);
|
||||
|
||||
$this->services->updateOrder((int)$id, $data);
|
||||
return app('json')->success('Modified success');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,13 +197,13 @@ class StoreOrder extends AuthController
|
||||
[$ids] = $this->request->postMore([
|
||||
['ids', []],
|
||||
], true);
|
||||
if (!count($ids)) return app('json')->fail('请选择需要删除的订单');
|
||||
if (!count($ids)) return app('json')->fail(400156);
|
||||
if ($this->services->getOrderIdsCount($ids))
|
||||
return app('json')->fail('您选择的的订单存在用户未删除的订单');
|
||||
return app('json')->fail(400157);
|
||||
if ($this->services->batchUpdate($ids, ['is_system_del' => 1]))
|
||||
return app('json')->success('SUCCESS');
|
||||
return app('json')->success(100002);
|
||||
else
|
||||
return app('json')->fail('ERROR');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,19 +214,20 @@ class StoreOrder extends AuthController
|
||||
public function del($id)
|
||||
{
|
||||
if (!$id || !($orderInfo = $this->services->get($id)))
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(400118);
|
||||
if (!$orderInfo->is_del)
|
||||
return app('json')->fail('订单用户未删除无法删除');
|
||||
return app('json')->fail(400157);
|
||||
$orderInfo->is_system_del = 1;
|
||||
if ($orderInfo->save())
|
||||
return app('json')->success('SUCCESS');
|
||||
return app('json')->success(100002);
|
||||
else
|
||||
return app('json')->fail('ERROR');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单发送货
|
||||
* @param $id 订单id
|
||||
* @param $id
|
||||
* @param StoreOrderDeliveryServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_delivery($id, StoreOrderDeliveryServices $services)
|
||||
@ -247,12 +251,13 @@ class StoreOrder extends AuthController
|
||||
['fictitious_content', '']//虚拟发货内容
|
||||
]);
|
||||
$services->delivery((int)$id, $data);
|
||||
return app('json')->success('SUCCESS');
|
||||
return app('json')->success(100010);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单拆单发送货
|
||||
* @param $id 订单id
|
||||
* @param $id
|
||||
* @param StoreOrderDeliveryServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function split_delivery($id, StoreOrderDeliveryServices $services)
|
||||
@ -278,18 +283,18 @@ class StoreOrder extends AuthController
|
||||
['cart_ids', []]
|
||||
]);
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少发货ID');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
if (!$data['cart_ids']) {
|
||||
return app('json')->fail('请选择发货商品');
|
||||
return app('json')->fail(400158);
|
||||
}
|
||||
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('请重新选择发货商品,或发货件数');
|
||||
return app('json')->fail(400159);
|
||||
}
|
||||
}
|
||||
$services->splitDelivery((int)$id, $data);
|
||||
return app('json')->success('SUCCESS');
|
||||
return app('json')->success(100010);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,7 +306,7 @@ class StoreOrder extends AuthController
|
||||
public function split_cart_info($id, StoreOrderCartInfoServices $services)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少发货ID');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($services->getSplitCartList((int)$id));
|
||||
}
|
||||
@ -313,7 +318,7 @@ class StoreOrder extends AuthController
|
||||
public function split_order($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少订单ID');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->getSplitOrderList(['pid' => $id, 'is_system_del' => 0], ['*'], ['split', 'pink', 'invoice']));
|
||||
}
|
||||
@ -327,24 +332,24 @@ class StoreOrder extends AuthController
|
||||
*/
|
||||
public function take_delivery(StoreOrderTakeServices $services, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$order = $this->services->get($id);
|
||||
if (!$order)
|
||||
return app('json')->fail('Data does not exist!');
|
||||
return app('json')->fail(400118);
|
||||
if ($order['status'] == 2)
|
||||
return app('json')->fail('不能重复收货!');
|
||||
return app('json')->fail(400114);
|
||||
if ($order['paid'] == 1 && $order['status'] == 1)
|
||||
$data['status'] = 2;
|
||||
else if ($order['pay_type'] == 'offline')
|
||||
$data['status'] = 2;
|
||||
else
|
||||
return app('json')->fail('请先发货或者送货!');
|
||||
return app('json')->fail(400115);
|
||||
|
||||
if (!$this->services->update($id, $data)) {
|
||||
return app('json')->fail('收货失败,请稍候再试!');
|
||||
return app('json')->fail(400116);
|
||||
} else {
|
||||
$services->storeProductOrderUserTakeDelivery($order);
|
||||
return app('json')->success('收货成功');
|
||||
return app('json')->success(400117);
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,7 +379,7 @@ class StoreOrder extends AuthController
|
||||
public function refund(StoreOrderRefundServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($services->refundOrderForm((int)$id));
|
||||
}
|
||||
@ -394,27 +399,27 @@ class StoreOrder extends AuthController
|
||||
['type', 1]
|
||||
]);
|
||||
if (!$id) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$order = $this->services->get($id);
|
||||
if (!$order) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
return app('json')->fail(400118);
|
||||
}
|
||||
//0元退款
|
||||
if ($order['pay_price'] == 0 && in_array($order['refund_status'], [0, 1])) {
|
||||
$refund_price = 0;
|
||||
} else {
|
||||
if ($order['pay_price'] == $order['refund_price']) {
|
||||
return app('json')->fail('已退完支付金额!不能再退款了');
|
||||
return app('json')->fail(400147);
|
||||
}
|
||||
if (!$data['refund_price']) {
|
||||
return app('json')->fail('请输入退款金额');
|
||||
return app('json')->fail(400146);
|
||||
}
|
||||
$refund_price = $data['refund_price'];
|
||||
$data['refund_price'] = bcadd($data['refund_price'], $order['refund_price'], 2);
|
||||
$bj = bccomp((string)$order['pay_price'], (string)$data['refund_price'], 2);
|
||||
if ($bj < 0) {
|
||||
return app('json')->fail('退款金额大于支付金额,请修改退款金额');
|
||||
return app('json')->fail(400148);
|
||||
}
|
||||
}
|
||||
if ($data['type'] == 1) {
|
||||
@ -435,10 +440,10 @@ class StoreOrder extends AuthController
|
||||
//修改订单退款状态
|
||||
if ($this->services->update($id, $data)) {
|
||||
$services->storeProductOrderRefundY($data, $order, $refund_price);
|
||||
return app('json')->success('退款成功');
|
||||
return app('json')->success(400149);
|
||||
} else {
|
||||
$services->storeProductOrderRefundYFasle((int)$id, $refund_price);
|
||||
return app('json')->fail('退款失败');
|
||||
return app('json')->fail(400150);
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,12 +455,12 @@ class StoreOrder extends AuthController
|
||||
public function order_info($id)
|
||||
{
|
||||
if (!$id || !($orderInfo = $this->services->get($id))) {
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(400118);
|
||||
}
|
||||
/** @var UserServices $services */
|
||||
$services = app()->make(UserServices::class);
|
||||
$userInfo = $services->get($orderInfo['uid']);
|
||||
if (!$userInfo) return app('json')->fail('用户信息不存在');
|
||||
if (!$userInfo) return app('json')->fail(400119);
|
||||
$userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
|
||||
$userInfo['spread_name'] = '无';
|
||||
if ($userInfo['spread_uid']) {
|
||||
@ -494,9 +499,9 @@ class StoreOrder extends AuthController
|
||||
public function get_express($id, ExpressServices $services)
|
||||
{
|
||||
if (!$id || !($orderInfo = $this->services->get($id)))
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(400118);
|
||||
if ($orderInfo['delivery_type'] != 'express' || !$orderInfo['delivery_id'])
|
||||
return app('json')->fail('该订单不存在快递单号');
|
||||
return app('json')->fail(400120);
|
||||
|
||||
$cacheName = $orderInfo['order_id'] . $orderInfo['delivery_id'];
|
||||
|
||||
@ -516,7 +521,7 @@ class StoreOrder extends AuthController
|
||||
public function distribution(StoreOrderDeliveryServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($services->distributionForm((int)$id));
|
||||
}
|
||||
@ -528,10 +533,10 @@ class StoreOrder extends AuthController
|
||||
*/
|
||||
public function update_distribution(StoreOrderDeliveryServices $services, $id)
|
||||
{
|
||||
$data = $this->request->postMore([['delivery_name', ''], ['delivery_id', '']]);
|
||||
if (!$id) return app('json')->fail('Data does not exist!');
|
||||
$data = $this->request->postMore([['delivery_name', ''], ['delivery_code', ''], ['delivery_id', '']]);
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$services->updateDistribution($id, $data);
|
||||
return app('json')->success('Modified success');
|
||||
return app('json')->success(100010);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -542,7 +547,7 @@ class StoreOrder extends AuthController
|
||||
*/
|
||||
public function no_refund(StoreOrderRefundServices $services, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('Data does not exist!');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($services->noRefundForm((int)$id));
|
||||
}
|
||||
|
||||
@ -555,10 +560,10 @@ class StoreOrder extends AuthController
|
||||
public function update_un_refund(StoreOrderRefundServices $services, $id)
|
||||
{
|
||||
if (!$id || !($orderInfo = $this->services->get($id)))
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(400118);
|
||||
[$refund_reason] = $this->request->postMore([['refund_reason', '']], true);
|
||||
if (!$refund_reason) {
|
||||
return app('json')->fail('请输入不退款原因');
|
||||
return app('json')->fail(400113);
|
||||
}
|
||||
$orderInfo->refund_reason = $refund_reason;
|
||||
$orderInfo->refund_status = 0;
|
||||
@ -577,7 +582,7 @@ class StoreOrder extends AuthController
|
||||
$services->storeProductOrderRefundNo((int)$id, $refund_reason);
|
||||
//提醒推送
|
||||
event('notice.notice', [['orderInfo' => $orderInfo], 'send_order_refund_no_status']);
|
||||
return app('json')->success('Modified success');
|
||||
return app('json')->success(100010);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -587,12 +592,12 @@ class StoreOrder extends AuthController
|
||||
*/
|
||||
public function pay_offline(OrderOfflineServices $services, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$res = $services->orderOffline((int)$id);
|
||||
if ($res) {
|
||||
return app('json')->success('Modified success');
|
||||
return app('json')->success(100010);
|
||||
} else {
|
||||
return app('json')->fail('Modification failed');
|
||||
return app('json')->fail(100005);
|
||||
}
|
||||
}
|
||||
|
||||
@ -605,7 +610,7 @@ class StoreOrder extends AuthController
|
||||
public function refund_integral(StoreOrderRefundServices $services, $id)
|
||||
{
|
||||
if (!$id)
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(100100);
|
||||
return app('json')->success($services->refundIntegralForm((int)$id));
|
||||
}
|
||||
|
||||
@ -618,29 +623,29 @@ class StoreOrder extends AuthController
|
||||
{
|
||||
[$back_integral] = $this->request->postMore([['back_integral', 0]], true);
|
||||
if (!$id || !($orderInfo = $this->services->get($id))) {
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(400118);
|
||||
}
|
||||
if ($orderInfo->is_del) {
|
||||
return app('json')->fail('订单已删除无法退积分');
|
||||
return app('json')->fail(400160);
|
||||
}
|
||||
if ($back_integral <= 0) {
|
||||
return app('json')->fail('请输入积分');
|
||||
return app('json')->fail(400161);
|
||||
}
|
||||
if ($orderInfo['use_integral'] == $orderInfo['back_integral']) {
|
||||
return app('json')->fail('已退完积分!不能再积分了');
|
||||
return app('json')->fail(400162);
|
||||
}
|
||||
|
||||
$data['back_integral'] = bcadd((string)$back_integral, (string)$orderInfo['back_integral'], 2);
|
||||
$bj = bccomp((string)$orderInfo['use_integral'], (string)$data['back_integral'], 2);
|
||||
if ($bj < 0) {
|
||||
return app('json')->fail('退积分大于支付积分,请修改退积分');
|
||||
return app('json')->fail(400163);
|
||||
}
|
||||
//积分退款处理
|
||||
$orderInfo->back_integral = $data['back_integral'];
|
||||
if ($services->refundIntegral($orderInfo, $back_integral)) {
|
||||
return app('json')->success('退积分成功');
|
||||
return app('json')->success(400164);
|
||||
} else {
|
||||
return app('json')->fail('退积分失败');
|
||||
return app('json')->fail(400165);
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,18 +658,18 @@ class StoreOrder extends AuthController
|
||||
{
|
||||
$data = $this->request->postMore([['remark', '']]);
|
||||
if (!$data['remark'])
|
||||
return app('json')->fail('请输入要备注的内容');
|
||||
return app('json')->fail(400106);
|
||||
if (!$id)
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
|
||||
if (!$order = $this->services->get($id)) {
|
||||
return app('json')->fail('修改的订单不存在!');
|
||||
return app('json')->fail(400118);
|
||||
}
|
||||
$order->remark = $data['remark'];
|
||||
if ($order->save()) {
|
||||
return app('json')->success('备注成功');
|
||||
return app('json')->success(100024);
|
||||
} else
|
||||
return app('json')->fail('备注失败');
|
||||
return app('json')->fail(100025);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -674,7 +679,7 @@ class StoreOrder extends AuthController
|
||||
*/
|
||||
public function status(StoreOrderStatusServices $services, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($services->getStatusList(['oid' => $id])['list']);
|
||||
}
|
||||
|
||||
@ -685,16 +690,13 @@ class StoreOrder extends AuthController
|
||||
*/
|
||||
public function order_print($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
$order = $this->services->get($id);
|
||||
if (!$order) {
|
||||
return app('json')->fail('订单没有查到,无法打印!');
|
||||
}
|
||||
$res = $this->services->orderPrint($order, $order->cart_id);
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
|
||||
$res = $this->services->orderPrint($id);
|
||||
if ($res) {
|
||||
return app('json')->success('打印成功');
|
||||
return app('json')->success(100010);
|
||||
} else {
|
||||
return app('json')->fail('打印失败');
|
||||
return app('json')->fail(100005);
|
||||
}
|
||||
}
|
||||
|
||||
@ -706,7 +708,7 @@ class StoreOrder extends AuthController
|
||||
public function expr_temp(ServeServices $services, $com)
|
||||
{
|
||||
if (!$com) {
|
||||
return app('json')->fail('快递公司编号缺失');
|
||||
return app('json')->fail(400123);
|
||||
}
|
||||
$list = $services->express()->temp($com);
|
||||
return app('json')->success($list);
|
||||
@ -718,6 +720,9 @@ class StoreOrder extends AuthController
|
||||
public function express_temp(ServeServices $services)
|
||||
{
|
||||
$data = $this->request->getMore([['com', '']]);
|
||||
if (!$data['com']) {
|
||||
return app('json')->fail(400123);
|
||||
}
|
||||
$tpd = $services->express()->temp($data['com']);
|
||||
return app('json')->success($tpd['data']);
|
||||
}
|
||||
|
||||
@ -76,20 +76,20 @@ class StoreOrderInvoice extends AuthController
|
||||
*/
|
||||
public function set_invoice($id = '')
|
||||
{
|
||||
if ($id == '') return app('json')->fail('缺少参数');
|
||||
if ($id == '') return app('json')->fail(100100);
|
||||
$data = $this->request->postMore([
|
||||
['is_invoice', 0],
|
||||
['invoice_number', 0],
|
||||
['remark', '']
|
||||
]);
|
||||
if ($data['is_invoice'] == 1 && !$data['invoice_number']) {
|
||||
return app('json')->fail('请填写开票号');
|
||||
return app('json')->fail(400166);
|
||||
}
|
||||
if ($data['invoice_number'] && !preg_match('/^\d{8,10}$/', $data['invoice_number'])) {
|
||||
return app('json')->fail('请填写正确的开票号');
|
||||
return app('json')->fail(400167);
|
||||
}
|
||||
$this->services->setInvoice((int)$id, $data);
|
||||
return app('json')->success('设置成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,13 +100,13 @@ class StoreOrderInvoice extends AuthController
|
||||
public function orderInfo(StoreProductServices $productServices, StoreOrderServices $orderServices, $id)
|
||||
{
|
||||
if (!$id || !($orderInfo = $orderServices->get($id))) {
|
||||
return app('json')->fail('订单不存在');
|
||||
return app('json')->fail(400118);
|
||||
}
|
||||
/** @var UserServices $services */
|
||||
$services = app()->make(UserServices::class);
|
||||
$userInfo = $services->get($orderInfo['uid']);
|
||||
if (!$userInfo) {
|
||||
return app('json')->fail('用户信息不存在');
|
||||
return app('json')->fail(400119);
|
||||
}
|
||||
$userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
|
||||
$userInfo['spread_name'] = '';
|
||||
|
||||
@ -109,6 +109,6 @@ class CopyTaobao extends AuthController
|
||||
['attrs', []]
|
||||
]);
|
||||
$this->services->save($data);
|
||||
return app('json')->success('生成商品成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,9 +85,9 @@ class StoreCategory extends AuthController
|
||||
*/
|
||||
public function set_show($is_show = '', $id = '')
|
||||
{
|
||||
if ($is_show == '' || $id == '') return app('json')->fail('缺少参数');
|
||||
if ($is_show == '' || $id == '') return app('json')->fail(100100);
|
||||
$this->service->setShow($id, $is_show);
|
||||
return app('json')->success($is_show == 1 ? '显示成功' : '隐藏成功');
|
||||
return app('json')->success($is_show == 1 ? 100003 : 100004);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,11 +114,8 @@ class StoreCategory extends AuthController
|
||||
['sort', 0],
|
||||
['is_show', 0]
|
||||
]);
|
||||
if (!$data['cate_name']) {
|
||||
return app('json')->fail('请输入分类名称');
|
||||
}
|
||||
$this->service->createData($data);
|
||||
return app('json')->success('添加分类成功!');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,11 +144,9 @@ class StoreCategory extends AuthController
|
||||
['sort', 0],
|
||||
['is_show', 0]
|
||||
]);
|
||||
if (!$data['cate_name']) {
|
||||
return app('json')->fail('请输入分类名称');
|
||||
}
|
||||
|
||||
$this->service->editData($id, $data);
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,6 +157,6 @@ class StoreCategory extends AuthController
|
||||
public function delete($id)
|
||||
{
|
||||
$this->service->del((int)$id);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ use app\services\other\CacheServices;
|
||||
use app\services\product\product\StoreCategoryServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use crmeb\services\FileService;
|
||||
use crmeb\services\UploadService;
|
||||
use app\services\other\UploadService;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
@ -98,7 +98,7 @@ class StoreProduct extends AuthController
|
||||
['type', 0]
|
||||
]);
|
||||
$services->setDbCache($this->adminId . '_product_data', $data, 68400);
|
||||
return app('json')->success();
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,7 +109,7 @@ class StoreProduct extends AuthController
|
||||
public function deleteCacheData(CacheServices $services)
|
||||
{
|
||||
$services->delectDbCache($this->adminId . '_product_data');
|
||||
return app('json')->success();
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +137,7 @@ class StoreProduct extends AuthController
|
||||
public function set_show($is_show = '', $id = '')
|
||||
{
|
||||
$this->service->setShow([$id], $is_show);
|
||||
return app('json')->success($is_show == 1 ? '上架成功' : '下架成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,9 +149,8 @@ class StoreProduct extends AuthController
|
||||
[$ids] = $this->request->postMore([
|
||||
['ids', []]
|
||||
], true);
|
||||
if (empty($ids)) return app('json')->fail('请选择需要上架的商品');
|
||||
$this->service->setShow($ids, 1);
|
||||
return app('json')->success('上架成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,9 +162,8 @@ class StoreProduct extends AuthController
|
||||
[$ids] = $this->request->postMore([
|
||||
['ids', []]
|
||||
], true);
|
||||
if (empty($ids)) return app('json')->fail('请选择需要下架的商品');
|
||||
$this->service->setShow($ids, 0);
|
||||
return app('json')->success('下架成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,9 +235,12 @@ class StoreProduct extends AuthController
|
||||
['custom_form', []],//自定义表单
|
||||
['type', 0],
|
||||
['is_copy', 0],//是否是复制商品
|
||||
['is_limit', 0],//是否限购
|
||||
['limit_type', 0],//限购类型
|
||||
['limit_num', 0]//限购数量
|
||||
]);
|
||||
$this->service->save((int)$id, $data);
|
||||
return app('json')->success('添加商品成功!');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -342,7 +343,7 @@ class StoreProduct extends AuthController
|
||||
{
|
||||
$upload = UploadService::init();
|
||||
$re = $upload->getTempKeys();
|
||||
return $re ? app('json')->success($re) : app('json')->fail($upload->getError());
|
||||
return $re ? app('json')->success($re) : app('json')->fail(100016);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -355,7 +356,7 @@ class StoreProduct extends AuthController
|
||||
public function check_activity($id)
|
||||
{
|
||||
$this->service->checkActivity($id);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
public function import_card()
|
||||
@ -363,7 +364,7 @@ class StoreProduct extends AuthController
|
||||
$data = $this->request->getMore([
|
||||
['file', ""]
|
||||
]);
|
||||
if (!$data['file']) return app('json')->fail('请上传文件');
|
||||
if (!$data['file']) return app('json')->fail(400168);
|
||||
$file = public_path() . substr($data['file'], 1);
|
||||
/** @var FileService $readExcelService */
|
||||
$readExcelService = app()->make(FileService::class);
|
||||
|
||||
@ -55,7 +55,7 @@ class StoreProductReply extends AuthController
|
||||
public function delete($id)
|
||||
{
|
||||
$this->services->del($id);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,7 +69,7 @@ class StoreProductReply extends AuthController
|
||||
['content', '']
|
||||
], true);
|
||||
$this->services->setReply($id, $content);
|
||||
return app('json')->success('回复成功!');
|
||||
return app('json')->success(400169);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,6 +107,6 @@ class StoreProductReply extends AuthController
|
||||
}
|
||||
$this->validate(['product_id' => $data['product_id'], 'nickname' => $data['nickname'], 'avatar' => $data['avatar'], 'comment' => $data['comment'], 'product_score' => $data['product_score'], 'service_score' => $data['service_score']], \app\adminapi\validate\product\StoreProductReplyValidate::class, 'save');
|
||||
$this->services->saveReply($data);
|
||||
return app('json')->success('添加成功!');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ class StoreProductRule extends AuthController
|
||||
['spec', []]
|
||||
]);
|
||||
$this->services->save($id, $data);
|
||||
return app('json')->success('保存成功!');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,6 +82,6 @@ class StoreProductRule extends AuthController
|
||||
['ids', '']
|
||||
], true);
|
||||
$this->services->del((string)$ids);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ namespace app\adminapi\controller\v1\serve;
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\adminapi\validate\serve\ServeValidata;
|
||||
use app\Request;
|
||||
use app\services\message\sms\SmsAdminServices;
|
||||
use app\services\yihaotong\SmsAdminServices;
|
||||
use crmeb\services\CacheService;
|
||||
use app\services\serve\ServeServices;
|
||||
use think\facade\App;
|
||||
@ -82,9 +82,9 @@ class Login extends AuthController
|
||||
$res = $this->services->user()->register($data);
|
||||
if ($res) {
|
||||
$services->updateSmsConfig($data['account'], md5($data['account'] . md5($data['password'])));
|
||||
return app('json')->success('注册成功');
|
||||
return app('json')->success(400170);
|
||||
} else {
|
||||
return app('json')->fail('注册失败');
|
||||
return app('json')->fail(400171);
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,9 +109,9 @@ class Login extends AuthController
|
||||
CacheService::clear();
|
||||
CacheService::redisHandler()->set('sms_account', $account);
|
||||
$services->updateSmsConfig($account, $password);
|
||||
return app('json')->success('登录成功', $res);
|
||||
return app('json')->success(400139, $res);
|
||||
} else {
|
||||
return app('json')->fail('登录失败');
|
||||
return app('json')->fail(400172);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ class Serve extends AuthController
|
||||
if ($res) {
|
||||
return app('json')->success($res);
|
||||
} else {
|
||||
return app('json')->fail('获取套餐列表失败');
|
||||
return app('json')->fail(400173);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,19 +81,19 @@ class Serve extends AuthController
|
||||
['pay_type', ''],
|
||||
]);
|
||||
$openInfo = $this->services->user()->getUser();
|
||||
if (!$openInfo) app('json')->fail('获取支付码失败');
|
||||
if (!$openInfo) app('json')->fail(400174);
|
||||
switch ($data['type']) {
|
||||
case "sms" :
|
||||
if (!$openInfo['sms']['open']) return app('json')->fail('请先开通短信服务');
|
||||
if (!$openInfo['sms']['open']) return app('json')->fail(400175);
|
||||
break;
|
||||
case "query" :
|
||||
if (!$openInfo['query']['open']) return app('json')->fail('请先开通物流查询服务');
|
||||
if (!$openInfo['query']['open']) return app('json')->fail(400176);
|
||||
break;
|
||||
case "dump" :
|
||||
if (!$openInfo['dump']['open']) return app('json')->fail('请先开通电子面单打印服务');
|
||||
if (!$openInfo['dump']['open']) return app('json')->fail(400177);
|
||||
break;
|
||||
case "copy" :
|
||||
if (!$openInfo['copy']['open']) return app('json')->fail('请先开通商品采集服务');
|
||||
if (!$openInfo['copy']['open']) return app('json')->fail(400178);
|
||||
break;
|
||||
}
|
||||
$this->validate($data, MealValidata::class);
|
||||
@ -102,7 +102,7 @@ class Serve extends AuthController
|
||||
if ($res) {
|
||||
return app('json')->success($res);
|
||||
} else {
|
||||
return app('json')->fail('获取支付码失败');
|
||||
return app('json')->fail(400174);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ class Serve extends AuthController
|
||||
$systemConfigService = app()->make(SystemConfigServices::class);
|
||||
$systemConfigService->saveExpressInfo($data);
|
||||
$this->services->express()->open();
|
||||
return app('json')->success('开通成功');
|
||||
return app('json')->success(100044);
|
||||
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ class Serve extends AuthController
|
||||
$this->services->express()->open();
|
||||
}
|
||||
|
||||
return app('json')->success('开通成功');
|
||||
return app('json')->success(100044);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,7 +189,7 @@ class Serve extends AuthController
|
||||
$data['password'] = md5($data['password']);
|
||||
$this->services->user()->modify($data);
|
||||
CacheService::redisHandler()->delete('sms_account');
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,6 +208,6 @@ class Serve extends AuthController
|
||||
|
||||
$this->services->user()->modifyPhone($data);
|
||||
CacheService::redisHandler()->delete('sms_account');
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,10 +43,10 @@ class Sms extends AuthController
|
||||
public function openServe(string $sign)
|
||||
{
|
||||
if (!$sign) {
|
||||
return app('json')->fail('请设置短信签名');
|
||||
return app('json')->fail(400179);
|
||||
}
|
||||
$this->services->sms()->setSign($sign)->open();
|
||||
return app('json')->success('开通成功');
|
||||
return app('json')->success(100044);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,10 +65,10 @@ class Sms extends AuthController
|
||||
$this->validate(['phone' => $phone], ServeValidata::class, 'phone');
|
||||
|
||||
if (!$sign) {
|
||||
return app('json')->fail('请设置短信签名');
|
||||
return app('json')->fail(400179);
|
||||
}
|
||||
$this->services->sms()->modify($sign, $phone, $code);
|
||||
return app('json')->success('修改短信签名成功');
|
||||
return app('json')->success(400180);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,7 +99,7 @@ class Sms extends AuthController
|
||||
], true);
|
||||
|
||||
if (!$title || !$content || !$type) {
|
||||
return app('json')->success('请填写申请模板内容');
|
||||
return app('json')->success(400143);
|
||||
}
|
||||
return app('json')->success($this->services->sms()->apply($title, $content, (int)$type));
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ class ShippingTemplates extends AuthController
|
||||
$temp['sort'] = $data['sort'];
|
||||
$temp['add_time'] = time();
|
||||
$this->services->save((int)$id, $temp, $data);
|
||||
return app('json')->success('添加成功!');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,10 +92,10 @@ class ShippingTemplates extends AuthController
|
||||
[['id', 'd'], 0],
|
||||
], true);
|
||||
if ($id == 1) {
|
||||
return app('json')->fail('默认模板不能删除');
|
||||
return app('json')->fail(400181);
|
||||
} else {
|
||||
$this->services->detete($id);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ class SystemAdmin extends AuthController
|
||||
|
||||
$data['level'] = $this->adminInfo['level'] + 1;
|
||||
$this->services->create($data);
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +90,7 @@ class SystemAdmin extends AuthController
|
||||
public function edit($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('管理员信息读取失败');
|
||||
return app('json')->fail(400182);
|
||||
}
|
||||
|
||||
return app('json')->success($this->services->updateForm($this->adminInfo['level'] + 1, (int)$id));
|
||||
@ -115,9 +115,9 @@ class SystemAdmin extends AuthController
|
||||
$this->validate($data, \app\adminapi\validate\setting\SystemAdminValidata::class, 'update');
|
||||
|
||||
if ($this->services->save((int)$id, $data)) {
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
} else {
|
||||
return app('json')->fail('修改失败');
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,11 +128,11 @@ class SystemAdmin extends AuthController
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('删除失败,缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
if ($this->services->update((int)$id, ['is_del' => 1, 'status' => 0]))
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
else
|
||||
return app('json')->fail('删除失败');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +144,7 @@ class SystemAdmin extends AuthController
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
$this->services->update((int)$id, ['status' => $status]);
|
||||
return app('json')->success($status == 0 ? '关闭成功' : '开启成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,12 +170,12 @@ class SystemAdmin extends AuthController
|
||||
['conf_pwd', ''],
|
||||
]);
|
||||
if(!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/',$data['new_pwd'])){
|
||||
return app('json')->fail('设置的密码过于简单(不小于六位包含数字字母)');
|
||||
return app('json')->fail(400183);
|
||||
}
|
||||
if ($this->services->updateAdmin($this->adminId, $data))
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
else
|
||||
return app('json')->fail('修改失败');
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -30,7 +30,7 @@ class SystemAgreement extends AuthController
|
||||
*/
|
||||
public function getAgreement($type)
|
||||
{
|
||||
if (!$type) return app('json')->fail('协议类型不存在');
|
||||
if (!$type) return app('json')->fail(400184);
|
||||
$info = $this->services->getAgreementBytype($type);
|
||||
return app('json')->success($info);
|
||||
}
|
||||
@ -49,6 +49,6 @@ class SystemAgreement extends AuthController
|
||||
]);
|
||||
$data['status'] = 1;
|
||||
$this->services->saveAgreement($data, $data['id']);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,12 +90,12 @@ class SystemCity extends AuthController
|
||||
$data['level'] = $data['level'] + 1;
|
||||
$data['city_id'] = intval($this->services->getCityIdMax() + 1);
|
||||
$this->services->save($data);
|
||||
return app('json')->success('添加城市成功!');
|
||||
return app('json')->success(100000);
|
||||
} else {
|
||||
unset($data['level']);
|
||||
unset($data['parent_id']);
|
||||
$this->services->update($data['id'], $data);
|
||||
return app('json')->success('修改城市成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ class SystemCity extends AuthController
|
||||
[['city_id', 'd'], 0]
|
||||
], true);
|
||||
$this->services->deleteCity($id);
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,9 +136,9 @@ class SystemCity extends AuthController
|
||||
$res = CacheService::delete('tree_city_list');
|
||||
$res = $res && CacheService::delete('CITY_LIST');
|
||||
if ($res) {
|
||||
return app('json')->success('清除成功!');
|
||||
return app('json')->success(400185);
|
||||
} else {
|
||||
return app('json')->fail('清除失败或缓存未生成!');
|
||||
return app('json')->fail(400186);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ class SystemConfig extends AuthController
|
||||
['status', -1]
|
||||
]);
|
||||
if (!$where['tab_id']) {
|
||||
return app('json')->fail('参数错误');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
if ($where['status'] == -1) {
|
||||
unset($where['status']);
|
||||
@ -92,24 +92,24 @@ class SystemConfig extends AuthController
|
||||
['sort', 0],
|
||||
['status', 0]
|
||||
]);
|
||||
if (!$data['info']) return app('json')->fail('请输入配置名称');
|
||||
if (!$data['menu_name']) return app('json')->fail('请输入字段名称');
|
||||
if (!$data['desc']) return app('json')->fail('请输入配置简介');
|
||||
if (!$data['info']) return app('json')->fail(400274);
|
||||
if (!$data['menu_name']) return app('json')->fail(400275);
|
||||
if (!$data['desc']) return app('json')->fail(400276);
|
||||
if ($data['sort'] < 0) {
|
||||
$data['sort'] = 0;
|
||||
}
|
||||
if ($data['type'] == 'text') {
|
||||
if (!$data['width']) return app('json')->fail('请输入文本框的宽度');
|
||||
if ($data['width'] <= 0) return app('json')->fail('请输入正确的文本框的宽度');
|
||||
if (!$data['width']) return app('json')->fail(400277);
|
||||
if ($data['width'] <= 0) return app('json')->fail(400278);
|
||||
}
|
||||
if ($data['type'] == 'textarea') {
|
||||
if (!$data['width']) return app('json')->fail('请输入多行文本框的宽度');
|
||||
if (!$data['high']) return app('json')->fail('请输入多行文本框的高度');
|
||||
if ($data['width'] < 0) return app('json')->fail('请输入正确的多行文本框的宽度');
|
||||
if ($data['high'] < 0) return app('json')->fail('请输入正确的多行文本框的宽度');
|
||||
if (!$data['width']) return app('json')->fail(400279);
|
||||
if (!$data['high']) return app('json')->fail(400280);
|
||||
if ($data['width'] < 0) return app('json')->fail(400281);
|
||||
if ($data['high'] < 0) return app('json')->fail(400282);
|
||||
}
|
||||
if ($data['type'] == 'radio' || $data['type'] == 'checkbox') {
|
||||
if (!$data['parameter']) return app('json')->fail('请输入配置参数');
|
||||
if (!$data['parameter']) return app('json')->fail(400283);
|
||||
$this->services->valiDateRadioAndCheckbox($data);
|
||||
}
|
||||
$data['value'] = json_encode($data['value']);
|
||||
@ -120,7 +120,7 @@ class SystemConfig extends AuthController
|
||||
$this->services->save($data);
|
||||
}
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('添加配置成功!');
|
||||
return app('json')->success(400284);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,7 +132,7 @@ class SystemConfig extends AuthController
|
||||
public function read($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('参数错误,请重新打开');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$info = $this->services->getReadList((int)$id);
|
||||
return app('json')->success(compact('info'));
|
||||
@ -181,12 +181,12 @@ class SystemConfig extends AuthController
|
||||
['status', 0]
|
||||
]);
|
||||
if (!$this->services->get($id)) {
|
||||
return app('json')->fail('编辑的记录不存在!');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
$data['value'] = json_encode($data['value']);
|
||||
$this->services->update($id, $data);
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,10 +198,10 @@ class SystemConfig extends AuthController
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else {
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,11 +214,11 @@ class SystemConfig extends AuthController
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) {
|
||||
return app('json')->fail('参数错误');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,7 +228,7 @@ class SystemConfig extends AuthController
|
||||
{
|
||||
$tabId = $this->request->param('tab_id', 1);
|
||||
if (!$tabId) {
|
||||
return app('json')->fail('参数错误');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$url = $request->baseUrl();
|
||||
return app('json')->success($this->services->getConfigForm($url, $tabId));
|
||||
@ -256,24 +256,27 @@ class SystemConfig extends AuthController
|
||||
if (isset($post['upload_type'])) {
|
||||
$this->services->checkThumbParam($post);
|
||||
}
|
||||
if (isset($post['extract_type']) && !count($post['extract_type'])) {
|
||||
return app('json')->fail(400753);
|
||||
}
|
||||
if (isset($post['store_brokerage_binding_status'])) {
|
||||
$this->services->checkBrokerageBinding($post);
|
||||
}
|
||||
if (isset($post['store_brokerage_ratio']) && isset($post['store_brokerage_two'])) {
|
||||
$num = $post['store_brokerage_ratio'] + $post['store_brokerage_two'];
|
||||
if ($num > 100) {
|
||||
return app('json')->fail('一二级返佣比例不能大于100%');
|
||||
return app('json')->fail(400285);
|
||||
}
|
||||
}
|
||||
if (isset($post['spread_banner'])) {
|
||||
$num = count($post['spread_banner']);
|
||||
if ($num > 5) {
|
||||
return app('json')->fail('分销海报不能多于5张');
|
||||
return app('json')->fail(400286);
|
||||
}
|
||||
}
|
||||
if (isset($post['user_extract_min_price'])) {
|
||||
if (!preg_match('/[0-9]$/', $post['user_extract_min_price'])) {
|
||||
return app('json')->fail('提现最低金额只能为数字!');
|
||||
return app('json')->fail(400287);
|
||||
}
|
||||
}
|
||||
if (isset($post['wss_open'])) {
|
||||
@ -281,15 +284,28 @@ class SystemConfig extends AuthController
|
||||
}
|
||||
if (isset($post['store_brokerage_price']) && $post['store_brokerage_statu'] == 3) {
|
||||
if ($post['store_brokerage_price'] === '') {
|
||||
return app('json')->fail('满额分销最低金额不能为空!');
|
||||
return app('json')->fail(400288);
|
||||
}
|
||||
if ($post['store_brokerage_price'] < 0) {
|
||||
return app('json')->fail('满额分销最低金额不能小于0!');
|
||||
return app('json')->fail(400289);
|
||||
}
|
||||
}
|
||||
if (isset($post['store_brokerage_binding_time']) && $post['store_brokerage_binding_status'] == 2) {
|
||||
if (!preg_match("/^[0-9][0-9]*$/", $post['store_brokerage_binding_time'])) {
|
||||
return app('json')->fail('绑定有效期请填写正整数!');
|
||||
return app('json')->fail(400290);
|
||||
}
|
||||
}
|
||||
if (isset($post['uni_brokerage_price']) && $post['uni_brokerage_price'] < 0) {
|
||||
return app('json')->fail(400756);
|
||||
}
|
||||
if (isset($post['day_brokerage_price_upper']) && $post['day_brokerage_price_upper'] < -1) {
|
||||
return app('json')->fail(400757);
|
||||
}
|
||||
if( isset($post['pay_new_weixin_open']) && (bool)$post['pay_new_weixin_open'])
|
||||
{
|
||||
if(empty($post['pay_new_weixin_mchid']))
|
||||
{
|
||||
return app('json')->fail(400763);
|
||||
}
|
||||
}
|
||||
if (isset($post['weixin_ckeck_file'])) {
|
||||
@ -315,7 +331,7 @@ class SystemConfig extends AuthController
|
||||
}
|
||||
}
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
|
||||
}
|
||||
|
||||
@ -366,4 +382,17 @@ class SystemConfig extends AuthController
|
||||
}
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取版本号信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
$version = get_crmeb_version();
|
||||
return app('json')->success([
|
||||
'version' => $version,
|
||||
'label' => 19
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,9 +75,9 @@ class SystemConfigTab extends AuthController
|
||||
['sort', 0],
|
||||
['pid', 0],
|
||||
]);
|
||||
if (!$data['title']) return app('json')->fail('请输入按钮名称');
|
||||
if (!$data['title']) return app('json')->fail(400291);
|
||||
$this->services->save($data);
|
||||
return app('json')->success('添加配置分类成功!');
|
||||
return app('json')->success(400292);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,10 +119,10 @@ class SystemConfigTab extends AuthController
|
||||
['sort', 0],
|
||||
['pid', 0],
|
||||
]);
|
||||
if (!$data['title']) return app('json')->fail('请输入分类昵称');
|
||||
if (!$data['eng_title']) return app('json')->fail('请输入分类字段');
|
||||
if (!$data['title']) return app('json')->fail(400291);
|
||||
if (!$data['eng_title']) return app('json')->fail(400275);
|
||||
$this->services->update($id, $data);
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,12 +134,12 @@ class SystemConfigTab extends AuthController
|
||||
public function delete(SystemConfigServices $services, $id)
|
||||
{
|
||||
if ($services->count(['tab_id' => $id])) {
|
||||
return app('json')->fail('存在下级配置,无法删除!');
|
||||
return app('json')->fail(400293);
|
||||
}
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,9 +151,9 @@ class SystemConfigTab extends AuthController
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) {
|
||||
return app('json')->fail('参数错误');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,10 +74,10 @@ class SystemGroup extends AuthController
|
||||
|
||||
//数据组名称判断
|
||||
if (!$params['name']) {
|
||||
return app('json')->fail('请输入数据组名称!');
|
||||
return app('json')->fail(400187);
|
||||
}
|
||||
if (!$params['config_name']) {
|
||||
return app('json')->fail('请输入配置名称!');
|
||||
return app('json')->fail(400274);
|
||||
}
|
||||
$data["name"] = $params['name'];
|
||||
$data["config_name"] = $params['config_name'];
|
||||
@ -85,7 +85,7 @@ class SystemGroup extends AuthController
|
||||
$data["cate_id"] = $params['cate_id'];
|
||||
//字段信息判断
|
||||
if (!count($params['typelist']))
|
||||
return app('json')->fail('字段至少存在一个!');
|
||||
return app('json')->fail(400294);
|
||||
else {
|
||||
$validate = ["name", "type", "title", "description"];
|
||||
foreach ($params["typelist"] as $key => $value) {
|
||||
@ -100,7 +100,7 @@ class SystemGroup extends AuthController
|
||||
$data["fields"] = json_encode($data["fields"]);
|
||||
$this->services->save($data);
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('添加数据组成功!');
|
||||
return app('json')->success(400295);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,12 +153,12 @@ class SystemGroup extends AuthController
|
||||
]);
|
||||
|
||||
//数据组名称判断
|
||||
if (!$params['name']) return app('json')->fail('请输入数据组名称!');
|
||||
if (!$params['config_name']) return app('json')->fail('请输入配置名称!');
|
||||
if (!$params['name']) return app('json')->fail(400187);
|
||||
if (!$params['config_name']) return app('json')->fail(400274);
|
||||
//判断ID是否存在,存在就是编辑,不存在就是添加
|
||||
if (!$id) {
|
||||
if ($this->services->count(['config_name' => $params['config_name']])) {
|
||||
return app('json')->fail('数据关键字已存在!');
|
||||
return app('json')->fail(400296);
|
||||
}
|
||||
}
|
||||
$data["name"] = $params['name'];
|
||||
@ -167,13 +167,13 @@ class SystemGroup extends AuthController
|
||||
$data["cate_id"] = $params['cate_id'];
|
||||
//字段信息判断
|
||||
if (!count($params['typelist']))
|
||||
return app('json')->fail('字段至少存在一个!');
|
||||
return app('json')->fail(400294);
|
||||
else {
|
||||
$validate = ["name", "type", "title", "description"];
|
||||
foreach ($params["typelist"] as $key => $value) {
|
||||
foreach ($value as $name => $field) {
|
||||
if (empty($field["value"]) && in_array($name, $validate))
|
||||
return app('json')->fail("字段" . ($key + 1) . ":" . $field["placeholder"] . "不能为空!");
|
||||
return app('json')->fail(400297);
|
||||
else
|
||||
$data["fields"][$key][$name] = $field["value"];
|
||||
}
|
||||
@ -182,7 +182,7 @@ class SystemGroup extends AuthController
|
||||
$data["fields"] = json_encode($data["fields"]);
|
||||
$this->services->update($id, $data);
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('编辑数据组成功!');
|
||||
return app('json')->success(400295);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,10 +194,10 @@ class SystemGroup extends AuthController
|
||||
public function delete($id, SystemGroupDataServices $services)
|
||||
{
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else {
|
||||
$services->delete($id, 'gid');
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ class SystemGroupData extends AuthController
|
||||
['gid', 0],
|
||||
['config_name', '']
|
||||
], true);
|
||||
if (!$gid && !$config_name) return $this->fail('参数错误');
|
||||
if (!$gid && !$config_name) return app('json')->fail(100100);
|
||||
if (!$gid) {
|
||||
$gid = $services->value(['config_name' => $config_name], 'id');
|
||||
}
|
||||
@ -65,7 +65,7 @@ class SystemGroupData extends AuthController
|
||||
['status', ''],
|
||||
['config_name', '']
|
||||
]);
|
||||
if (!$where['gid'] && !$where['config_name']) return app('json')->fail('参数错误');
|
||||
if (!$where['gid'] && !$where['config_name']) return app('json')->fail(100100);
|
||||
if (!$where['gid']) {
|
||||
$where['gid'] = $group->value(['config_name' => $where['config_name']], 'id');
|
||||
}
|
||||
@ -82,10 +82,10 @@ class SystemGroupData extends AuthController
|
||||
{
|
||||
$gid = $this->request->param('gid/d');
|
||||
if ($this->services->isGroupGidSave($gid, 4, 'index_categy_images')) {
|
||||
return app('json')->fail('不能大于四个!');
|
||||
return app('json')->fail(400298);
|
||||
}
|
||||
if ($this->services->isGroupGidSave($gid, 7, 'sign_day_num')) {
|
||||
return app('json')->fail('签到天数配置不能大于7天');
|
||||
return app('json')->fail(400299);
|
||||
}
|
||||
return app('json')->success($this->services->createForm($gid));
|
||||
}
|
||||
@ -105,11 +105,11 @@ class SystemGroupData extends AuthController
|
||||
foreach ($groupDatas as $groupData) {
|
||||
$groupData = json_decode($groupData, true);
|
||||
if (isset($groupData['order_status']['value']) && $groupData['order_status']['value'] == $params['order_status']) {
|
||||
return app('json')->fail('已存在请不要重复添加');
|
||||
return app('json')->fail(400188);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->checkSeckillTime($services, $gid, $params);
|
||||
$this->services->checkSeckillTime($services, $gid, $params);
|
||||
$this->checkSign($services, $gid, $params);
|
||||
$fields = json_decode($group['fields'], true) ?? [];
|
||||
$value = [];
|
||||
@ -117,7 +117,7 @@ class SystemGroupData extends AuthController
|
||||
foreach ($fields as $index => $field) {
|
||||
if ($key == $field["title"]) {
|
||||
if ($param == "")
|
||||
return app('json')->fail($field["name"] . "不能为空!");
|
||||
return app('json')->fail(400297);
|
||||
else {
|
||||
$value[$key]["type"] = $field["type"];
|
||||
$value[$key]["value"] = $param;
|
||||
@ -134,7 +134,7 @@ class SystemGroupData extends AuthController
|
||||
];
|
||||
$this->services->save($data);
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('添加数据成功!');
|
||||
return app('json')->success(400189);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,7 +158,7 @@ class SystemGroupData extends AuthController
|
||||
{
|
||||
$gid = $this->request->param('gid/d');
|
||||
if (!$gid) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->updateForm((int)$gid, (int)$id));
|
||||
}
|
||||
@ -175,14 +175,14 @@ class SystemGroupData extends AuthController
|
||||
$groupData = $this->services->get($id);
|
||||
$fields = $services->getValueFields((int)$groupData["gid"]);
|
||||
$params = request()->post();
|
||||
$this->checkSeckillTime($services, $groupData["gid"], $params, $id);
|
||||
$this->services->checkSeckillTime($services, $groupData["gid"], $params, $id);
|
||||
$this->checkSign($services, $groupData["gid"], $params);
|
||||
$value = [];
|
||||
foreach ($params as $key => $param) {
|
||||
foreach ($fields as $index => $field) {
|
||||
if ($key == $field["title"]) {
|
||||
if ($param == '')
|
||||
return app('json')->fail($field["name"] . "不能为空!");
|
||||
return app('json')->fail(400297);
|
||||
else {
|
||||
$value[$key]["type"] = $field["type"];
|
||||
$value[$key]["value"] = $param;
|
||||
@ -197,7 +197,7 @@ class SystemGroupData extends AuthController
|
||||
];
|
||||
$this->services->update($id, $data);
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,10 +209,10 @@ class SystemGroupData extends AuthController
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else {
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,54 +224,13 @@ class SystemGroupData extends AuthController
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
if ($status == '' || $id == 0) return app('json')->fail(100100);
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查秒杀时间段
|
||||
* @param SystemGroupServices $services
|
||||
* @param $gid
|
||||
* @param $params
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function checkSeckillTime(SystemGroupServices $services, $gid, $params, $id = 0)
|
||||
{
|
||||
$name = $services->value(['id' => $gid], 'config_name');
|
||||
if ($name == 'routine_seckill_time') {
|
||||
if ($params['time'] == '') {
|
||||
throw new AdminException('请输入开始时间');
|
||||
}
|
||||
if (!$params['continued']) {
|
||||
throw new AdminException('请输入持续时间');
|
||||
}
|
||||
if (!preg_match('/^(\d|1\d|2[0-3])$/', $params['time'])) {
|
||||
throw new AdminException('请输入0-23点之前的整点数');
|
||||
}
|
||||
if (!preg_match('/^([1-9]|1\d|2[0-4])$/', $params['continued'])) {
|
||||
throw new AdminException('请输入1-24点之前的持续时间');
|
||||
}
|
||||
if (($params['time'] + $params['continued']) > 24) throw new AdminException('开始时间+持续时间不能大于24小时');
|
||||
$list = $this->services->getColumn(['gid' => $gid], 'value', 'id');
|
||||
if ($id) unset($list[$id]);
|
||||
$times = $time = [];
|
||||
foreach ($list as $item) {
|
||||
$info = json_decode($item, true);
|
||||
for ($i = 0; $i < $info['continued']['value']; $i++) {
|
||||
$times[] = $info['time']['value'] + $i;
|
||||
}
|
||||
}
|
||||
for ($i = 0; $i < $params['continued']; $i++) {
|
||||
$time[] = $params['time'] + $i;
|
||||
}
|
||||
foreach ($time as $v) {
|
||||
if (in_array($v, $times)) throw new AdminException('时段已占用');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查签到配置
|
||||
@ -286,10 +245,10 @@ class SystemGroupData extends AuthController
|
||||
$name = $services->value(['id' => $gid], 'config_name');
|
||||
if ($name == 'sign_day_num') {
|
||||
if (!$params['sign_num']) {
|
||||
throw new AdminException('请输入签到赠送积分');
|
||||
throw new AdminException(400196);
|
||||
}
|
||||
if (!preg_match('/^\+?[1-9]\d*$/', $params['sign_num'])) {
|
||||
throw new AdminException('请输入大于等于0的整数');
|
||||
throw new AdminException(400197);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -316,17 +275,17 @@ class SystemGroupData extends AuthController
|
||||
/** @var CacheServices $cache */
|
||||
$cache = app()->make(CacheServices::class);
|
||||
$cache->setDbCache('kf_adv', $content);
|
||||
return app('json')->success('设置成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
public function saveAll()
|
||||
{
|
||||
$params = request()->post();
|
||||
if (!isset($params['config_name']) || !isset($params['data'])) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$this->services->saveAllData($params['data'], $params['config_name']);
|
||||
return app('json')->success('添加数据成功!');
|
||||
return app('json')->success(400295);
|
||||
}
|
||||
|
||||
|
||||
@ -352,6 +311,6 @@ class SystemGroupData extends AuthController
|
||||
/** @var CacheServices $cache */
|
||||
$cache = app()->make(CacheServices::class);
|
||||
$cache->setDbCache('user_agreement', $content);
|
||||
return app('json')->success('设置成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,12 +88,12 @@ class SystemMenus extends AuthController
|
||||
]);
|
||||
|
||||
if (!$data['menu_name'])
|
||||
return app('json')->fail('请填写按钮名称');
|
||||
return app('json')->fail(400198);
|
||||
$data['path'] = implode('/', $data['path']);
|
||||
if ($this->services->save($data)) {
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100021);
|
||||
} else {
|
||||
return app('json')->fail('添加失败');
|
||||
return app('json')->fail(100022);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ class SystemMenus extends AuthController
|
||||
{
|
||||
|
||||
if (!$id) {
|
||||
return app('json')->fail('数据不存在');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
return app('json')->success($this->services->find((int)$id));
|
||||
}
|
||||
@ -119,7 +119,7 @@ class SystemMenus extends AuthController
|
||||
public function edit($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少修改参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->updateMenus((int)$id));
|
||||
}
|
||||
@ -132,7 +132,7 @@ class SystemMenus extends AuthController
|
||||
public function update($id)
|
||||
{
|
||||
if (!$id || !($menu = $this->services->get($id)))
|
||||
return app('json')->fail('数据不存在');
|
||||
return app('json')->fail(100026);
|
||||
$data = $this->request->postMore([
|
||||
'menu_name',
|
||||
'controller',
|
||||
@ -155,12 +155,12 @@ class SystemMenus extends AuthController
|
||||
['is_show_path', 0],
|
||||
]);
|
||||
if (!$data['menu_name'])
|
||||
return app('json')->fail('请输入按钮名称');
|
||||
return app('json')->fail(400198);
|
||||
$data['path'] = implode('/', $data['path']);
|
||||
if ($this->services->update($id, $data))
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
else
|
||||
return app('json')->fail('修改失败');
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,13 +172,13 @@ class SystemMenus extends AuthController
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('参数错误,请重新打开');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
|
||||
if (!$this->services->delete((int)$id)) {
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
} else {
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,15 +190,15 @@ class SystemMenus extends AuthController
|
||||
public function show($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('参数错误,请重新打开');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
|
||||
[$show] = $this->request->postMore([['is_show', 0]], true);
|
||||
|
||||
if ($this->services->update($id, ['is_show' => $show])) {
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
} else {
|
||||
return app('json')->fail('修改失败');
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ class SystemNotification extends AuthController
|
||||
['type', ''],
|
||||
['id', 0]
|
||||
]);
|
||||
if (!$where['id']) return app('json')->fail('参数错误');
|
||||
if (!$where['id']) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->getNotInfo($where));
|
||||
}
|
||||
|
||||
@ -87,12 +87,12 @@ class SystemNotification extends AuthController
|
||||
['routine_id', ''],
|
||||
['mark', ''],
|
||||
]);
|
||||
if (!$data['id']) return app('json')->fail('参数错误');
|
||||
if (!$data['id']) return app('json')->fail(100100);
|
||||
if ($this->services->saveData($data)) {
|
||||
CacheService::delete('NOTCE_'. $data['mark']);
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
} else {
|
||||
return app('json')->fail('修改失败,请稍候再试!');
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,10 +103,10 @@ class SystemNotification extends AuthController
|
||||
*/
|
||||
public function set_status($type, $status, $id)
|
||||
{
|
||||
if ($type == '' || $status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
if ($type == '' || $status == '' || $id == 0) return app('json')->fail(100100);
|
||||
$this->services->update($id, [$type => $status]);
|
||||
$res = $this->services->getOneNotce(['id'=>$id]);
|
||||
CacheService::delete('NOTCE_'.$res->mark);
|
||||
return app('json')->success($status == 1 ? '开启成功' : '关闭成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
}
|
||||
|
||||
129
crmeb/app/adminapi/controller/v1/setting/SystemOutAccount.php
Normal file
129
crmeb/app/adminapi/controller/v1/setting/SystemOutAccount.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\setting;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\outapi\validate\StoreOutAccountValidate;
|
||||
use app\services\out\LoginServices;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 对外接口账户
|
||||
* Class SystemOutAccount
|
||||
* @package app\adminapi\controller\v1\setting
|
||||
*/
|
||||
class SystemOutAccount extends AuthController
|
||||
{
|
||||
/**
|
||||
* 构造方法
|
||||
* SystemOut constructor.
|
||||
* @param App $app
|
||||
* @param LoginServices $services
|
||||
*/
|
||||
public function __construct(App $app, LoginServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 账号信息
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['name', '', ''],
|
||||
['status', ''],
|
||||
]);
|
||||
return app('json')->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param string $status
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_status($id = '', $status = '')
|
||||
{
|
||||
if ($status == '' || $id == '') return $this->fail('缺少参数');
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success($status == 1 ? '开启成功' : '关闭成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if ($id == '') return $this->fail('缺少参数');
|
||||
$this->services->update($id, ['is_del' => 1]);
|
||||
return app('json')->success('删除成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
[['appid', 's'], ''],
|
||||
[['appsecret', 's'], ''],
|
||||
[['title', 's'], ''],
|
||||
]);
|
||||
$this->validate($data, StoreOutAccountValidate::class, 'save');
|
||||
if ($this->services->getOne(['appid' => $data['appid']])) return app('json')->fail('账号重复');
|
||||
if (!$data['appsecret']) {
|
||||
unset($data['appsecret']);
|
||||
} else {
|
||||
$data['appsecret'] = password_hash($data['appsecret'], PASSWORD_DEFAULT);
|
||||
}
|
||||
$data['add_time'] = time();
|
||||
if (!$this->services->save($data)) {
|
||||
return app('json')->fail('添加失败');
|
||||
} else {
|
||||
return app('json')->success('添加成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id = '')
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
[['appsecret', 's'], ''],
|
||||
[['title', 's'], ''],
|
||||
]);
|
||||
|
||||
$this->validate($data, StoreOutAccountValidate::class, 'update');
|
||||
if (!$data['appsecret']) {
|
||||
unset($data['appsecret']);
|
||||
} else {
|
||||
$data['appsecret'] = password_hash($data['appsecret'], PASSWORD_DEFAULT);
|
||||
}
|
||||
if (!$this->services->getOne(['id' => $id])) return app('json')->fail('没有此账号');
|
||||
|
||||
$res = $this->services->update($id, $data);
|
||||
if (!$res) {
|
||||
return app('json')->fail('修改失败');
|
||||
} else {
|
||||
return app('json')->success('修改成功!');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@
|
||||
namespace app\adminapi\controller\v1\setting;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\system\admin\SystemAdminServices;
|
||||
use app\services\system\admin\SystemRoleServices;
|
||||
use app\services\system\SystemMenusServices;
|
||||
use think\facade\App;
|
||||
@ -70,19 +71,19 @@ class SystemRole extends AuthController
|
||||
['status', 0],
|
||||
['checked_menus', [], '', 'rules']
|
||||
]);
|
||||
if (!$data['role_name']) return app('json')->fail('请输入身份名称');
|
||||
if (!$data['role_name']) return app('json')->fail(400220);
|
||||
if (!is_array($data['rules']) || !count($data['rules']))
|
||||
return app('json')->fail('请选择最少一个权限');
|
||||
return app('json')->fail(400221);
|
||||
$data['rules'] = implode(',', $data['rules']);
|
||||
if ($id) {
|
||||
if (!$this->services->update($id, $data)) return app('json')->fail('修改失败!');
|
||||
if (!$this->services->update($id, $data)) return app('json')->fail(100007);
|
||||
\think\facade\Cache::clear();
|
||||
return app('json')->success('修改成功!');
|
||||
return app('json')->success(100001);
|
||||
} else {
|
||||
$data['level'] = $this->adminInfo['level'] + 1;
|
||||
if (!$this->services->save($data)) return app('json')->fail('添加身份失败!');
|
||||
if (!$this->services->save($data)) return app('json')->fail(400223);
|
||||
\think\facade\Cache::clear();
|
||||
return app('json')->success('添加身份成功!');
|
||||
return app('json')->success(400222);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +97,7 @@ class SystemRole extends AuthController
|
||||
{
|
||||
$role = $this->services->get($id);
|
||||
if (!$role) {
|
||||
return app('json')->fail('修改的规格不存在');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$menus = $services->getMenus($this->adminInfo['level'] == 0 ? [] : $this->adminInfo['roles']);
|
||||
return app('json')->success(['role' => $role->toArray(), 'menus' => $menus]);
|
||||
@ -104,17 +105,20 @@ class SystemRole extends AuthController
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
* @param SystemAdminServices $adminServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
public function delete(SystemAdminServices $adminServices, $id)
|
||||
{
|
||||
if ($adminServices->checkRoleUse($id)) {
|
||||
return app('json')->fail(400754);
|
||||
}
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
return app('json')->fail(100008);
|
||||
else {
|
||||
\think\facade\Cache::clear();
|
||||
return app('json')->success('删除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,18 +131,18 @@ class SystemRole extends AuthController
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$role = $this->services->get($id);
|
||||
if (!$role) {
|
||||
return app('json')->fail('没有查到此身份');
|
||||
return app('json')->fail(400199);
|
||||
}
|
||||
$role->status = $status;
|
||||
if ($role->save()) {
|
||||
\think\facade\Cache::clear();
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
} else {
|
||||
return app('json')->fail('修改失败');
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ namespace app\adminapi\controller\v1\setting;
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\system\config\SystemConfigServices;
|
||||
use app\services\system\config\SystemStorageServices;
|
||||
use crmeb\services\UploadService;
|
||||
use app\services\other\UploadService;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ class SystemStorage extends AuthController
|
||||
public function create($type)
|
||||
{
|
||||
if (!$type) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
return app('json')->success($this->services->getFormStorage((int)$type));
|
||||
}
|
||||
@ -101,7 +101,7 @@ class SystemStorage extends AuthController
|
||||
|
||||
$this->services->saveConfig((int)$type, $data);
|
||||
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,7 +111,7 @@ class SystemStorage extends AuthController
|
||||
public function synch($type)
|
||||
{
|
||||
$this->services->synchronization((int)$type);
|
||||
return app('json')->success('同步成功');
|
||||
return app('json')->success(100038);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,7 +132,7 @@ class SystemStorage extends AuthController
|
||||
$type = (int)$type;
|
||||
if ($type === 4) {
|
||||
if (!$data['appid'] && !sys_config('tengxun_appid')) {
|
||||
return app('json')->fail('缺少APPID');
|
||||
return app('json')->fail(400224);
|
||||
}
|
||||
}
|
||||
if (!$data['accessKey']) {
|
||||
@ -140,7 +140,7 @@ class SystemStorage extends AuthController
|
||||
}
|
||||
$this->services->saveStorage((int)$type, $data);
|
||||
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100021);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,13 +152,13 @@ class SystemStorage extends AuthController
|
||||
public function status(SystemConfigServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
|
||||
$info = $this->services->get($id);
|
||||
$info->status = 1;
|
||||
if (!$info->domain) {
|
||||
return app('json')->fail('请先设置空间域名');
|
||||
return app('json')->fail(400225);
|
||||
}
|
||||
// $services->update('upload_type', ['value' => json_encode($info->type)], 'menu_name');
|
||||
\crmeb\services\CacheService::clear();
|
||||
@ -176,7 +176,7 @@ class SystemStorage extends AuthController
|
||||
$this->services->update(['type' => $info->type], ['status' => 0]);
|
||||
$info->save();
|
||||
});
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,10 +204,10 @@ class SystemStorage extends AuthController
|
||||
['ca', '']
|
||||
]);
|
||||
if (!$domain) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
if (strstr($domain, 'https://') === false && strstr($domain, 'http://') === false) {
|
||||
return app('json')->fail('格式错误,请输入格式为:http://域名');
|
||||
return app('json')->fail(400226);
|
||||
|
||||
}
|
||||
// if (strstr($domain, 'https://') !== false && !$data['pri']) {
|
||||
@ -216,7 +216,7 @@ class SystemStorage extends AuthController
|
||||
|
||||
$this->services->updateDomain($id, $domain);
|
||||
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,13 +230,13 @@ class SystemStorage extends AuthController
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
|
||||
if ($this->services->deleteStorage($id)) {
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
} else {
|
||||
return app('json')->fail('删除失败');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,14 +250,14 @@ class SystemStorage extends AuthController
|
||||
{
|
||||
$status = $this->services->count(['type' => $type, 'status' => 1]);
|
||||
if (!$status && $type != 1) {
|
||||
return app('json')->success('未有正在使用的存储空间');
|
||||
return app('json')->success(400227);
|
||||
}
|
||||
$services->update('upload_type', ['value' => json_encode($type)], 'menu_name');
|
||||
\crmeb\services\CacheService::clear();
|
||||
if ($type != 1) {
|
||||
$msg = '切换云存储成功,请检查是否开启使用了存储空间!';
|
||||
$msg = 400228;
|
||||
} else {
|
||||
$msg = '切换本地存储成功';
|
||||
$msg = 400229;
|
||||
}
|
||||
return app('json')->success($msg);
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ class FlowStatistic extends AuthController
|
||||
['mark', '']
|
||||
]);
|
||||
$this->services->setMark($id, $data);
|
||||
return app('json')->success('备注成功!');
|
||||
return app('json')->success(100024);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -73,6 +73,6 @@ class AppVersion extends AuthController
|
||||
$id = $data['id'];
|
||||
unset($data['id']);
|
||||
$this->services->versionSave($id, $data);
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100021);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ class Clear extends AuthController
|
||||
public function refresh_cache()
|
||||
{
|
||||
$this->services->refresCache();
|
||||
return app('json')->success('数据缓存刷新成功!');
|
||||
return app('json')->success(400302);
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ class Clear extends AuthController
|
||||
public function delete_log()
|
||||
{
|
||||
$this->services->deleteLog();
|
||||
return app('json')->success('数据缓存刷新成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ class SystemClearData extends AuthController
|
||||
return $this->wechatuserData();
|
||||
break;
|
||||
default:
|
||||
return app('json')->fail('参数有误');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ class SystemClearData extends AuthController
|
||||
/** @var SystemAttachmentServices $services */
|
||||
$services = app()->make(SystemAttachmentServices::class);
|
||||
$services->delete(2, 'module_type');
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
//清除回收站商品
|
||||
@ -103,7 +103,7 @@ class SystemClearData extends AuthController
|
||||
/** @var StoreProductServices $services */
|
||||
$services = app()->make(StoreProductServices::class);
|
||||
$services->delete(1, 'is_del');
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,7 +123,7 @@ class SystemClearData extends AuthController
|
||||
|
||||
], true);
|
||||
$this->services->delDirAndFile('./public/uploads/store/comment');
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +138,7 @@ class SystemClearData extends AuthController
|
||||
'store_product_rule', 'store_seckill', 'store_product', 'store_visit', 'store_product_log', 'category', 'delivery_service',
|
||||
'live_anchor', 'live_goods', 'live_room', 'live_room_goods', 'store_product_coupon'
|
||||
], true);
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,7 +148,7 @@ class SystemClearData extends AuthController
|
||||
public function categoryData()
|
||||
{
|
||||
$this->services->clearData(['store_category'], true);
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,7 +160,7 @@ class SystemClearData extends AuthController
|
||||
$this->services->clearData(['store_order', 'store_order_cart_info', 'store_order_status', 'store_pink',
|
||||
'store_cart', 'store_order_status', 'other_order', 'other_order_status', 'store_order_invoice'
|
||||
], true);
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,7 +173,7 @@ class SystemClearData extends AuthController
|
||||
'store_service', 'store_service_log', 'store_service_record', 'store_service_feedback', 'store_service_speechcraft'
|
||||
], true);
|
||||
$this->services->delDirAndFile('./public/uploads/store/service');
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,7 +187,7 @@ class SystemClearData extends AuthController
|
||||
'wechat_news_category'
|
||||
], true);
|
||||
$this->services->delDirAndFile('./public/uploads/wechat');
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,7 +200,7 @@ class SystemClearData extends AuthController
|
||||
'system_attachment', 'system_attachment_category'
|
||||
], true);
|
||||
$this->services->delDirAndFile('./public/uploads/');
|
||||
return app('json')->success('清除上传文件成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,7 +212,7 @@ class SystemClearData extends AuthController
|
||||
$this->services->clearData([
|
||||
'user', 'wechat_user'
|
||||
], true);
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
//清除内容分类
|
||||
@ -221,7 +221,7 @@ class SystemClearData extends AuthController
|
||||
$this->services->clearData([
|
||||
'article_category', 'article', 'article_content'
|
||||
], true);
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
//清除系统记录
|
||||
@ -230,7 +230,7 @@ class SystemClearData extends AuthController
|
||||
$this->services->clearData([
|
||||
'system_notice_admin', 'system_log'
|
||||
], true);
|
||||
return app('json')->success('清除数据成功!');
|
||||
return app('json')->success(100046);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,10 +243,10 @@ class SystemClearData extends AuthController
|
||||
['url', '']
|
||||
], true);
|
||||
if (!$url)
|
||||
return app('json')->fail('请输入需要更换的域名');
|
||||
return app('json')->fail(400304);
|
||||
if (!verify_domain($url))
|
||||
return app('json')->fail('域名不合法');
|
||||
return app('json')->fail(400305);
|
||||
$this->services->replaceSiteUrl($url);
|
||||
return app('json')->success('替换成功!');
|
||||
return app('json')->success(400306);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class SystemDatabackup extends AuthController
|
||||
{
|
||||
$tables = $this->request->param('tables', '', 'htmlspecialchars');
|
||||
$res = $this->services->getDbBackup()->optimize($tables);
|
||||
return app('json')->success($res ? '优化成功' : '优化失败');
|
||||
return app('json')->success($res ? 100047 : 100048);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +70,7 @@ class SystemDatabackup extends AuthController
|
||||
{
|
||||
$tables = $this->request->param('tables', '', 'htmlspecialchars');
|
||||
$res = $this->services->getDbBackup()->repair($tables);
|
||||
return app('json')->success($res ? '修复成功' : '修复失败');
|
||||
return app('json')->success($res ? 100049 : 100050);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +80,7 @@ class SystemDatabackup extends AuthController
|
||||
{
|
||||
$tables = $this->request->param('tables', '', 'htmlspecialchars');
|
||||
$data = $this->services->backup($tables);
|
||||
return app('json')->success($data ? '备份失败' . $data : '备份成功');
|
||||
return app('json')->success(100051);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,7 +98,7 @@ class SystemDatabackup extends AuthController
|
||||
{
|
||||
$filename = intval(request()->post('filename'));
|
||||
$files = $this->services->getDbBackup()->delFile($filename);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,35 +116,35 @@ class SystemDatabackup extends AuthController
|
||||
$list = $db->getFile('timeverif', $time);
|
||||
if (is_array($list)) {
|
||||
session::set('backup_list', $list);
|
||||
return app('json')->success('初始化完成!', array('part' => 1, 'start' => 0));
|
||||
return app('json')->success(400307, array('part' => 1, 'start' => 0));
|
||||
} else {
|
||||
return app('json')->fail('备份文件可能已经损坏,请检查!');
|
||||
return app('json')->fail(400308);
|
||||
}
|
||||
} else if (is_numeric($part) && is_numeric($start) && $part && $start) {
|
||||
$list = session::get('backup_list');
|
||||
$start = $db->setFile($list)->import($start);
|
||||
if (false === $start) {
|
||||
return app('json')->fail('还原数据出错!');
|
||||
return app('json')->fail(400309);
|
||||
} elseif (0 === $start) {
|
||||
if (isset($list[++$part])) {
|
||||
$data = array('part' => $part, 'start' => 0);
|
||||
return app('json')->success("正在还原...#{$part}", $data);
|
||||
return app('json')->success(400310, $data);
|
||||
} else {
|
||||
session::delete('backup_list');
|
||||
return app('json')->success('还原完成!');
|
||||
return app('json')->success(400311);
|
||||
}
|
||||
} else {
|
||||
$data = array('part' => $part, 'start' => $start[0]);
|
||||
if ($start[1]) {
|
||||
$rate = floor(100 * ($start[0] / $start[1]));
|
||||
return app('json')->success("正在还原...#{$part}({$rate}%)", $data);
|
||||
return app('json')->success(400310, $data);
|
||||
} else {
|
||||
$data['gz'] = 1;
|
||||
return app('json')->success("正在还原...#{$part}", $data);
|
||||
return app('json')->success(400310, $data);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return app('json')->fail('参数错误!');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -124,10 +124,10 @@ class User extends AuthController
|
||||
]);
|
||||
if ($data['phone']) {
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail('手机号码格式不正确');
|
||||
return app('json')->fail(400252);
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone'], 'is_del' => 0])) {
|
||||
return app('json')->fail('手机号已经存在不能添加相同的手机号用户');
|
||||
return app('json')->fail(400314);
|
||||
}
|
||||
if (trim($data['real_name']) != '') {
|
||||
$data['nickname'] = $data['real_name'];
|
||||
@ -136,14 +136,14 @@ class User extends AuthController
|
||||
}
|
||||
}
|
||||
if ($data['card_id']) {
|
||||
if (!check_card($data['card_id'])) return app('json')->fail('请输入正确的身份证');
|
||||
if (!check_card($data['card_id'])) return app('json')->fail(400315);
|
||||
}
|
||||
if ($data['pwd']) {
|
||||
if (!$data['true_pwd']) {
|
||||
return app('json')->fail('请输入确认密码');
|
||||
return app('json')->fail(400263);
|
||||
}
|
||||
if ($data['pwd'] != $data['true_pwd']) {
|
||||
return app('json')->fail('两次输入的密码不一致');
|
||||
return app('json')->fail(400264);
|
||||
}
|
||||
$data['pwd'] = md5($data['pwd']);
|
||||
} else {
|
||||
@ -172,10 +172,10 @@ class User extends AuthController
|
||||
$res = $this->services->saveGiveLevel((int)$userInfo->uid, (int)$data['level']);
|
||||
}
|
||||
if (!$res) {
|
||||
throw new ValidateException('保存添加用户失败');
|
||||
return app('json')->fail(100006);
|
||||
}
|
||||
});
|
||||
return app('json')->success('添加成功');
|
||||
return app('json')->success(100021);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,7 +199,7 @@ class User extends AuthController
|
||||
* */
|
||||
public function give_level($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->giveLevel((int)$id));
|
||||
}
|
||||
|
||||
@ -210,11 +210,11 @@ class User extends AuthController
|
||||
* */
|
||||
public function save_give_level($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
list($level_id) = $this->request->postMore([
|
||||
['level_id', 0],
|
||||
], true);
|
||||
return app('json')->success($this->services->saveGiveLevel((int)$id, (int)$level_id) ? '赠送成功' : '赠送失败');
|
||||
return app('json')->success($this->services->saveGiveLevel((int)$id, (int)$level_id) ? 400218 : 400219);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,7 +224,7 @@ class User extends AuthController
|
||||
* */
|
||||
public function give_level_time($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->giveLevelTime((int)$id));
|
||||
}
|
||||
|
||||
@ -235,11 +235,11 @@ class User extends AuthController
|
||||
* */
|
||||
public function save_give_level_time($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
list($days) = $this->request->postMore([
|
||||
['days', 0],
|
||||
], true);
|
||||
return app('json')->success($this->services->saveGiveLevelTime((int)$id, (int)$days) ? '赠送成功' : '赠送失败');
|
||||
return app('json')->success($this->services->saveGiveLevelTime((int)$id, (int)$days) ? 400218 : 400219);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,8 +249,8 @@ class User extends AuthController
|
||||
*/
|
||||
public function del_level($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
return app('json')->success($this->services->cleanUpLevel((int)$id) ? '清除成功' : '清除失败');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->cleanUpLevel((int)$id) ? 400185 : 400186);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -267,7 +267,7 @@ class User extends AuthController
|
||||
list($uids) = $this->request->postMore([
|
||||
['uids', []],
|
||||
], true);
|
||||
if (!$uids) return app('json')->fail('缺少参数');
|
||||
if (!$uids) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->setGroup($uids));
|
||||
}
|
||||
|
||||
@ -282,10 +282,10 @@ class User extends AuthController
|
||||
['group_id', 0],
|
||||
['uids', ''],
|
||||
], true);
|
||||
if (!$uids) return app('json')->fail('缺少参数');
|
||||
if (!$group_id) return app('json')->fail('请选择分组');
|
||||
if (!$uids) return app('json')->fail(100100);
|
||||
if (!$group_id) return app('json')->fail(400316);
|
||||
$uids = explode(',', $uids);
|
||||
return app('json')->success($this->services->saveSetGroup($uids, (int)$group_id) ? '设置分组成功' : '设置分组失败或无改动');
|
||||
return app('json')->success($this->services->saveSetGroup($uids, (int)$group_id) ? 100014 : 100015);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,7 +302,7 @@ class User extends AuthController
|
||||
['uids', []],
|
||||
], true);
|
||||
$uid = implode(',', $uids);
|
||||
if (!$uid) return app('json')->fail('缺少参数');
|
||||
if (!$uid) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->setLabel($uids));
|
||||
}
|
||||
|
||||
@ -316,10 +316,10 @@ class User extends AuthController
|
||||
['label_id', []],
|
||||
['uids', ''],
|
||||
], true);
|
||||
if (!$uids) return app('json')->fail('缺少参数');
|
||||
if (!$lables) return app('json')->fail('请选择标签');
|
||||
if (!$uids) return app('json')->fail(100100);
|
||||
if (!$lables) return app('json')->fail(400317);
|
||||
$uids = explode(',', $uids);
|
||||
return app('json')->success($this->services->saveSetLabel($uids, $lables) ? '设置标签成功' : '设置标签失败');
|
||||
return app('json')->success($this->services->saveSetLabel($uids, $lables) ? 100014 : 100015);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,7 +330,7 @@ class User extends AuthController
|
||||
*/
|
||||
public function edit_other($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100026);
|
||||
return app('json')->success($this->services->editOther((int)$id));
|
||||
}
|
||||
|
||||
@ -347,12 +347,12 @@ class User extends AuthController
|
||||
['integration_status', 0],
|
||||
['integration', 0],
|
||||
]);
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$data['adminId'] = $this->adminId;
|
||||
$data['money'] = (string)$data['money'];
|
||||
$data['integration'] = (string)$data['integration'];
|
||||
$data['is_other'] = true;
|
||||
return app('json')->success($this->services->updateInfo($id, $data) ? '修改成功' : '修改失败');
|
||||
return app('json')->success($this->services->updateInfo($id, $data) ? 100001 : 100007);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -365,7 +365,7 @@ class User extends AuthController
|
||||
// if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
// UserModel::where(['uid' => $id])->update(['status' => $status]);
|
||||
|
||||
return app('json')->success($status == 0 ? '禁用成功' : '解禁成功');
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -375,7 +375,7 @@ class User extends AuthController
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->edit($id));
|
||||
}
|
||||
|
||||
@ -401,29 +401,29 @@ class User extends AuthController
|
||||
['true_pwd'],
|
||||
['spread_open', 1]
|
||||
]);
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
if ($data['phone']) {
|
||||
if (!preg_match("/^1[3456789]\d{9}$/", $data['phone'])) return app('json')->fail('手机号码格式不正确');
|
||||
if (!preg_match("/^1[3456789]\d{9}$/", $data['phone'])) return app('json')->fail(400252);
|
||||
}
|
||||
if ($data['card_id']) {
|
||||
if (!check_card($data['card_id'])) return app('json')->fail('请输入正确的身份证');
|
||||
if (!check_card($data['card_id'])) return app('json')->fail(400315);
|
||||
}
|
||||
if ($data['pwd']) {
|
||||
if (!$data['true_pwd']) {
|
||||
return app('json')->fail('请输入确认密码');
|
||||
return app('json')->fail(400263);
|
||||
}
|
||||
if ($data['pwd'] != $data['true_pwd']) {
|
||||
return app('json')->fail('两次输入的密码不一致');
|
||||
return app('json')->fail(400264);
|
||||
}
|
||||
$data['pwd'] = md5($data['pwd']);
|
||||
} else {
|
||||
unset($data['pwd']);
|
||||
}
|
||||
unset($data['true_pwd']);
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
$data['adminId'] = $this->adminId;
|
||||
$data['money'] = (string)$data['money'];
|
||||
$data['integration'] = (string)$data['integration'];
|
||||
return app('json')->success($this->services->updateInfo($id, $data) ? '修改成功' : '修改失败');
|
||||
return app('json')->success($this->services->updateInfo($id, $data) ? 100001 : 100007);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -437,7 +437,7 @@ class User extends AuthController
|
||||
['type', ''],
|
||||
]);
|
||||
$id = (int)$id;
|
||||
if ($data['type'] == '') return app('json')->fail('缺少参数');
|
||||
if ($data['type'] == '') return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->oneUserInfo($id, $data['type']));
|
||||
}
|
||||
|
||||
@ -448,7 +448,7 @@ class User extends AuthController
|
||||
public function syncWechatUsers()
|
||||
{
|
||||
$this->services->syncWechatUsers();
|
||||
return app('json')->success('加入消息队列成功,正在异步执行中');
|
||||
return app('json')->success(400318);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -44,16 +44,16 @@ class UserCancel extends AuthController
|
||||
['mark', ''],
|
||||
], true);
|
||||
$this->services->serMark($id, $mark);
|
||||
return app('json')->success('备注成功');
|
||||
return app('json')->success(100024);
|
||||
}
|
||||
|
||||
public function agreeCancel($id)
|
||||
{
|
||||
return app('json')->success('注销成功');
|
||||
return app('json')->success(400319);
|
||||
}
|
||||
|
||||
public function refuseCancel($id)
|
||||
{
|
||||
return app('json')->success('拒绝注销');
|
||||
return app('json')->success(400320);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,10 +65,10 @@ class UserGroup extends AuthController
|
||||
['group_name', ''],
|
||||
]);
|
||||
if (!$data['group_name']) {
|
||||
return app('json')->fail('请输入分组名称');
|
||||
return app('json')->fail(400321);
|
||||
}
|
||||
$this->services->save((int)$data['id'], $data);
|
||||
return app('json')->success('提交成功!');
|
||||
return app('json')->success(100017);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +81,7 @@ class UserGroup extends AuthController
|
||||
$data = $this->request->getMore([
|
||||
['id', 0],
|
||||
]);
|
||||
if (!$data['id']) return app('json')->fail('数据不存在');
|
||||
if (!$data['id']) return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->delGroup((int)$data['id']));
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,9 +70,9 @@ class UserLabel extends AuthController
|
||||
['label_cate', 0],
|
||||
['label_name', ''],
|
||||
]);
|
||||
if (!$data['label_name'] = trim($data['label_name'])) return app('json')->fail('会员标签不能为空!');
|
||||
if (!$data['label_name'] = trim($data['label_name'])) return app('json')->fail(400322);
|
||||
$this->services->save((int)$data['id'], $data);
|
||||
return app('json')->success('保存成功');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,9 +85,9 @@ class UserLabel extends AuthController
|
||||
list($id) = $this->request->getMore([
|
||||
['id', 0],
|
||||
], true);
|
||||
if (!$id) return app('json')->fail('数据不存在');
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
$this->services->delLabel((int)$id);
|
||||
return app('json')->success('刪除成功!');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,12 +113,12 @@ class UserLabel extends AuthController
|
||||
['un_label_ids', []]
|
||||
], true);
|
||||
if (!count($labels) && !count($unLabelIds)) {
|
||||
return app('json')->fail('缺少标签id');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
if ($services->setUserLable($uid, $labels) && $services->unUserLabel($uid, $unLabelIds)) {
|
||||
return app('json')->success('设置成功');
|
||||
return app('json')->success(100014);
|
||||
} else {
|
||||
return app('json')->fail('设置失败');
|
||||
return app('json')->fail(100015);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -76,14 +76,14 @@ class UserLabelCate extends AuthController
|
||||
$this->validate($data, UserLabeCateValidata::class);
|
||||
|
||||
if ($this->services->count(['name' => $data['name']])) {
|
||||
return app('json')->fail('分类已经存在,请勿重复添加');
|
||||
return app('json')->fail(400101);
|
||||
}
|
||||
$data['type'] = 0;
|
||||
if ($this->services->save($data)) {
|
||||
$this->services->deleteCateCache();
|
||||
return app('json')->success('保存分类成功');
|
||||
return app('json')->success(100000);
|
||||
} else {
|
||||
return app('json')->fail('保存分类失败');
|
||||
return app('json')->fail(100006);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,11 +96,11 @@ class UserLabelCate extends AuthController
|
||||
public function read($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少标签分类id');
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
$info = $this->services->get($id);
|
||||
if (!$info) {
|
||||
return app('json')->fail('获取标签分类失败');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
return app('json')->success($info->toArray());
|
||||
}
|
||||
@ -134,9 +134,9 @@ class UserLabelCate extends AuthController
|
||||
|
||||
if ($this->services->update($id, $data)) {
|
||||
$this->services->deleteCateCache();
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
} else {
|
||||
return app('json')->fail('修改失败');
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,17 +149,17 @@ class UserLabelCate extends AuthController
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id || !($info = $this->services->get($id))) {
|
||||
return app('json')->fail('删除的数据不存在');
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
/** @var $labelService $labelservice */
|
||||
$labelService = app()->make(UserLabelServices::class);
|
||||
$count = $labelService->getCount(['label_cate' => $id]);
|
||||
if($count) return app('json')->fail('该分类下有标签,请先删除标签');
|
||||
if($count) return app('json')->fail(400323);
|
||||
if ($info->delete()) {
|
||||
$this->services->deleteCateCache();
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
} else {
|
||||
return app('json')->fail('删除失败');
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user