mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-04-15 01:50:07 +00:00
更新4.6.0版本
This commit is contained in:
parent
af57ed70ad
commit
ac1681888a
17
.gitignore
vendored
17
.gitignore
vendored
@ -1,16 +1,21 @@
|
||||
/.git
|
||||
/.idea
|
||||
/crmeb/.constant
|
||||
*.log
|
||||
*.DS_Store
|
||||
/crmeb/runtime/cache
|
||||
/crmeb/runtime/log
|
||||
/crmeb/runtime/session
|
||||
/crmeb/runtime/temp
|
||||
/crmeb/public/install.lock
|
||||
/crmeb/public/uploads
|
||||
*.log
|
||||
/crmeb/public/install/install.lock
|
||||
#/crmeb/.env
|
||||
/crmeb/timer.pid
|
||||
/crmeb/workerman.pid
|
||||
/crmeb/runtime/timer.pid
|
||||
/crmeb/runtime/workerman.pid
|
||||
/docker-compose/mysql/data/
|
||||
/docker-compose/mysql/log/
|
||||
/docker-compose/nginx/log/
|
||||
/template/admin/dist/
|
||||
/template/admin/.idea/
|
||||
/template/admin/node_modules/
|
||||
/template/uni-app/node_modules/
|
||||
/template/uni-app/unpackage/
|
||||
/template/uni-app/.hbuilderx/
|
||||
|
||||
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
|
||||
239
README.md
239
README.md
@ -1,64 +1,67 @@
|
||||
.jpg")
|
||||
<p align="center" >
|
||||

|
||||
<div align="center" >
|
||||
<img src="https://images.gitee.com/uploads/images/2021/1109/164354_0aafe3d2_892944.gif" />
|
||||
</p>
|
||||
</div>
|
||||
<div align="center">
|
||||
|
||||
<h3 align="center"> 码云开源项目php语言排名前三的开源GVP项目!</h3>
|
||||
支持免费商用的PHP **多语言** 商城系统
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
CRMEB打通版是一款全开源支持免费商用的PHP单商户商城系统;
|
||||
|
||||
CRMEB技术团队(官网:www.crmeb.com)历经5年时间匠心之作!系统采用前后端分离技术,基于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>
|
||||
<div align="center" >
|
||||
<a href="http://www.crmeb.com">
|
||||
<img src="https://img.shields.io/badge/Licence-GPL3.0-green.svg?style=flat" />
|
||||
</a>
|
||||
<a href="http://www.crmeb.com">
|
||||
<img src="https://img.shields.io/badge/Edition-4.5-blue.svg" />
|
||||
</a>
|
||||
<a href="https://gitee.com/ZhongBangKeJi/CRMEB/repository/archive/master.zip">
|
||||
<img src="https://img.shields.io/badge/Download-150m-red.svg" />
|
||||
</a>
|
||||
<a href='https://gitee.com/ZhongBangKeJi/CRMEB/stargazers'>
|
||||
<img src='https://gitee.com/ZhongBangKeJi/CRMEB/badge/star.svg?theme=gvp' alt='star'></img>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
####
|
||||
|
||||
<div align="center">
|
||||
|
||||
[官网](https://www.crmeb.com/) |
|
||||
[在线体验](http://v4.crmeb.net/admin/) |
|
||||
[帮助文档](https://doc.crmeb.com/single/crmeb_v4) |
|
||||
[技术社区](https://www.crmeb.com/ask/)
|
||||
|
||||
[comment]: <> ([宽屏预览](https://gitee.com/ZhongBangKeJi/CRMEB/blob/master/README.md))
|
||||
|
||||
</div>
|
||||
<div align="center" >
|
||||
<a href="https://gitee.com/ZhongBangKeJi/CRMEB/blob/master/README.md">宽 屏 预 览</a>
|
||||
</div>
|
||||
|
||||
### 介绍
|
||||
CRMEB打通版是历经6年时间匠心之作!系统全开源可商用,包含小程序商城、H5商城、公众号商城、PC商城、App,多种分销模式、拼团、砍价、秒杀、优惠券、抽奖、积分、会员等级、小程序直播、页面DIY,前后端分离全部100%开源。方便二开,更有详细使用文档、接口文档、数据字典、二开文档/视频教程。为开发者赋能,助力企业发展、国家富强,致力于打造最受欢迎的商城项目
|
||||
|
||||
CRMEB开源商城Java版:https://gitee.com/ZhongBangKeJi/crmeb_java
|
||||
|
||||
### 系统亮点
|
||||
~~~
|
||||
多 语 言:后台随时配置语言包,移动端支持多语言切换;
|
||||
高 性 能:redis缓存、队列、长连接、多种云储存、支持集群部署;
|
||||
个 性 UI:多种风格切换、支持DIY各种首页/专题页面
|
||||
前后端分离:后端TP6,管理端iviewui,移动端uniapp;
|
||||
代码规范:遵循PSR-2命名规范、Restful标准接口、代码严格分层、注释齐全、统一错误码;
|
||||
权限管理:内置强大灵活的权限管理,可以控制到每一个菜单;
|
||||
开发配置:低代码增加配置、系统组合数据模块;
|
||||
二开效率:PHP快速生成表单、内置所有事件、后台在线编辑器、代码注释齐全、完整接口文档;
|
||||
快速上手:详细帮助文档、接口文档、数据库字典、代码注释、一键安装;
|
||||
系统安全:系统操作日志、系统生产日志、文件校验、数据备份;
|
||||
系统功能:请看帮助文档 https://doc.crmeb.com/single/crmeb_v4/1758
|
||||
用户体验:等您来评!
|
||||
~~~
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
:fa-th-list: [官网地址](https://www.crmeb.com)
|
||||
| [服务市场](https://s.crmeb.com)
|
||||
| [系统功能](https://gitee.com/ZhongBangKeJi/CRMEB#%E7%B3%BB%E7%BB%9F%E5%8A%9F%E8%83%BD)
|
||||
| [系统演示](https://gitee.com/ZhongBangKeJi/CRMEB#%E7%B3%BB%E7%BB%9F%E6%BC%94%E7%A4%BA)
|
||||
| [使用手册](https://doc.crmeb.com/web/single/crmeb_v4/998)
|
||||
| [二开手册](https://gitee.com/ZhongBangKeJi/CRMEB/wikis/%E5%BA%8F%E8%A8%80?sort_id=4100490)
|
||||
| [论坛地址](https://q.crmeb.com)
|
||||
| [TP6开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content)
|
||||
| [推荐服务器](https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=dligum2z)
|
||||
| [留言评论](https://gitee.com/ZhongBangKeJi/CRMEB#%E7%89%88%E6%9D%83%E4%BF%A1%E6%81%AF)
|
||||
- - -
|
||||
|
||||
## 相关文档
|
||||
|
||||
系统功能:<a href="https://doc.crmeb.com/web/single/crmeb_v4/1758" target="_blank">功能清单</a>
|
||||
|
||||
系统脑图:<a href="https://doc.crmeb.com/web/single/crmeb_v4/1756" target="_blank">思维脑图</a>
|
||||
|
||||
接口文档:<a href="https://doc.crmeb.com/web/single/crmeb_v4/1760" target="_blank">在线接口</a>
|
||||
|
||||
目录结构:<a href="https://doc.crmeb.com/web/single/crmeb_v4/1129" target="_blank">目录结构</a>
|
||||
|
||||
数据字典:<a href="https://doc.crmeb.com/web/single/crmeb_v4/1130" target="_blank">数据字典</a>
|
||||
|
||||
安装教程:<a href="https://doc.crmeb.com/web/single/crmeb_v4/892" target="_blank">安装教程</a>
|
||||
|
||||
二开教程:<a href="https://ke.qq.com/course/4125326?tuin=5e252c1" target="_blank">CRMEB Uniapp前端二开视频教程 点击学习</a>
|
||||
|
||||
二开文档:<a href="https://gitee.com/ZhongBangKeJi/CRMEB-Min/wikis/%E5%BA%8F%E8%A8%80?sort_id=3303670" target="_blank">二开文档</a>
|
||||
|
||||
技术交流社区:<a href="https://q.crmeb.com" target="_blank">https://q.crmeb.com
|
||||
|
||||
#### 不懂服务器?不懂技术?无法解决高并发?想数据私有化?还想后期定制开发?
|
||||
|
||||
推荐云部署版一键解决以上所有问题,超低价格低至 :collision: 9.9元/年,点击了解 https://saas.crmeb.com/saas-home-software-detail-50042-s-y.html
|
||||
|
||||
#### 推荐服务器(虚拟空间不支持)
|
||||
|
||||
服务器环境推荐要求:<a href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=dligum2z" target="_blank"> 查看 </a>
|
||||
### 运行环境
|
||||
|
||||
```
|
||||
Nignx/Apache/IIS
|
||||
@ -68,95 +71,87 @@ Redis
|
||||
```
|
||||
|
||||
|
||||
推荐使用bt宝塔面板,简单易用,服务器推荐阿里云ecs或腾讯云cvm 云服务器。
|
||||
> 温馨提示:虚拟空间不支持,推荐使用bt宝塔面板,服务器推荐阿里云ecs或腾讯云cvm 云服务器:<a href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=dligum2z" target="_blank"> 查看 </a>
|
||||
|
||||
|
||||
### 系统演示
|
||||
|
||||
### 官方技术交流群
|
||||

|
||||
### CRMEB官方论坛:https://q.crmeb.com
|
||||

|
||||
|
||||
技术交流、安装搭建问题、系统建议反馈 欢迎光临CRMEB官方论坛!
|
||||
管理后台: http://v4.crmeb.net/admin 账号:demo 密码:crmeb.com
|
||||
|
||||
提交BUG、产品建议反馈 欢迎参与:https://q.crmeb.com/?categoryId=147
|
||||
H5端:http://v4.crmeb.net/(移动端打开)
|
||||
|
||||
PC端:http://v4.crmeb.net/(电脑端打开)
|
||||
|
||||
APP下载:http://app.crmeb.cn/bzv (苹果手机直接在APP Store里搜索CRMEB下载)
|
||||
|
||||
---
|
||||
|
||||
#### 体验云部署
|
||||
不懂服务器?不懂技术?无法解决高并发?想数据私有化?还想后期定制开发?
|
||||
|
||||
推荐云部署版一键超低价格低至 :collision: 9.9元/年,解决以上所有问题<a href='https://saas.crmeb.com/saas-home-software-detail-50043-s-y.html' target='_blank'>点击了解 </a>
|
||||
|
||||
---
|
||||
|
||||
### 官方论坛
|
||||
|
||||
|
||||
## 技术亮点
|
||||
~~~
|
||||
1.自主研发独立客服系统;
|
||||
2.管理端页面使用iviewUI开发;
|
||||
3.PHPExcel数据导出,导出表格更加美观,可视;
|
||||
4.EasyWeChat部署微信开发,微信接入更加快捷,简单;
|
||||
5.使用强大的workerman实现定时任务和长连接;
|
||||
6.内置强大灵活的权限管理,可以控制到每一个菜单;
|
||||
7.内置组合数据,系统配置,管理碎片化数据;
|
||||
8.客户端完善的交互效果和动画;
|
||||
9.对接公众号和小程序,并且数据同步;
|
||||
10.后台应用form-builder PHP快速生成现代化表单;
|
||||
11.高频数据缓存支持高并发;
|
||||
12.数据备份和恢复让数据更安全;
|
||||
13.Restful标准接口、前后端分离,内部预留钩子,二次开发更方便;
|
||||
14.长连接减少CPU及内存使用及网络堵塞,减少请求响应时长;
|
||||
15.支持队列降低流量高峰,解除耦合,高可用;
|
||||
16.一键安装自动检查系统环境一键安装;
|
||||
17.移动端使用uni-app进行开发,方便编译成各种格式的代码;
|
||||
18.严格代码规范,层次分明
|
||||
~~~
|
||||
产品BUG、优化建议,欢迎社区反馈:https://www.crmeb.com/ask/thread/list?id=147
|
||||
|
||||
## 页面展示
|
||||
|
||||
### 页面展示
|
||||
(页面仅展示部分UI)
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
### <a href='http://s.crmeb.com/goods_detail/728' target='_blank'>点击查看高清版全套UI设计图</a>
|
||||
|
||||
<div align="center">
|
||||
<a href='http://s.crmeb.com/goods_detail/739' target='_blank'>点击查看高清版全套UI设计图</a>
|
||||
</div>
|
||||
|
||||
|
||||
## 系统演示
|
||||
### 推荐项目(欢迎合作,QQ:763569752 )
|
||||
|
||||

|
||||
| 项目名称 | 关注量 | 项目介绍 |
|
||||
| ------------ | ------------ | ------------ |
|
||||
| [](https://gitee.com/ZhongBangKeJi/CRMChat) | [](https://gitee.com/ZhongBangKeJi/CRMChat/stargazers) | CRMChat客服系统,支持接入各种渠道. |
|
||||
| [](https://gitee.com/ZhongBangKeJi/crmeb_java) | [](https://gitee.com/ZhongBangKeJi/crmeb_java/stargazers) | JAVA版开源商城. |
|
||||
| [](https://gitee.com/xaboy/form-builder) | [](https://gitee.com/xaboy/form-builder/stargazers) | PHP表单生成器,快速生成现代化的form表单。 |
|
||||
| [](https://gitee.com/layui/layui-vue) | [](https://gitee.com/layui/layui-vue/stargazers) | layui-vue(谐音:类UI)是一套Vue3.0 的桌面端组件库. |
|
||||
| [](https://gitee.com/ntdgg/tpflow) | [](https://gitee.com/ntdgg/tpflow/stargazers) | TpFlow工作流引擎是一套规范化的流程管理系统,基于业务而驱动系统生命力的一套引擎. |
|
||||
|
||||
演示站: http://v4.crmeb.net/admin
|
||||
### 贡献支持
|
||||
开源不易,以下如果有需要,请支持一下,感谢您的支持,让我们更多动力!
|
||||
|
||||
账号:demo
|
||||
|
||||
密码:crmeb.com
|
||||
|
||||
#### CRMEB云部署快速体验完整功能 <a href='https://saas.crmeb.com/' target='_blank'>【点击体验】</a>
|
||||
|
||||
|
||||
## 程序下载
|
||||
|
||||
老版本v3.2.9 下载(功能全,后台非前后端分离,适合新手二开)
|
||||
```
|
||||
git clone -b v3.2.9 https://gitee.com/ZhongBangKeJi/CRMEB.git
|
||||
```
|
||||
|
||||
## 推荐项目
|
||||
|
||||
:star: CRMChat客服系统: https://gitee.com/ZhongBangKeJi/CRMChat
|
||||
|
||||
JAVA版商城:https://gitee.com/ZhongBangKeJi/crmeb_java
|
||||
|
||||
知识付费:https://gitee.com/ZhongBangKeJi/crmeb_zzff_class
|
||||
|
||||
|
||||
## 特别鸣谢
|
||||
|
||||
排名不分先后,感谢这些软件的开发者:thinkphp、iview、vue、mysql、redis、uniapp、echarts、tree-table-vue、swiper、form-create等,如有遗漏请联系我!
|
||||
|
||||
## 参与开发
|
||||
[](https://www.crmeb.com/index/criteria)
|
||||
|
||||
### 感谢参与开发者
|
||||
感谢大神们提交代码(排名不分先后)
|
||||
|
||||
### @yizhisamoye,@bys1123,@xaboy,@youngxj0,@jacklincheung,@392256866,@sxsea
|
||||
@yizhisamoye,@bys1123,@xaboy,@youngxj0,@jacklincheung,@392256866,@sxsea
|
||||
|
||||
欢迎反馈问题 [反馈问题](https://gitee.com/ZhongBangKeJi/CRMEB/issues)。
|
||||
|
||||
欢迎提交代码 [提交代码](https://gitee.com/ZhongBangKeJi/CRMEB/pulls)。
|
||||
|
||||
## 开源版使用须知
|
||||
### 特别鸣谢
|
||||
|
||||
排名不分先后,感谢这些软件的开发者:thinkphp、iview、vue、mysql、redis、uniapp、echarts、tree-table-vue、swiper、form-create等,如有遗漏请联系我!
|
||||
|
||||
### 核心开发团队
|
||||
产品:木子刀客
|
||||
|
||||
技术:聆听、等风来、xaboy、吴汐、最后一片叶、旺仔、小小、娜娜、归来仍是少年
|
||||
|
||||
UI:xy-yyds、LXT
|
||||
|
||||
测试:夏天、绵绵羊、。ws
|
||||
|
||||
### 使用须知
|
||||
|
||||
1.允许用于个人学习、毕业设计、教学案例、公益事业、商业使用;
|
||||
|
||||
@ -164,8 +159,7 @@ JAVA版商城:https://gitee.com/ZhongBangKeJi/crmeb_java
|
||||
|
||||
3.禁止将本项目的代码和资源进行任何形式的出售,产生的一切任何后果责任由侵权者自负。
|
||||
|
||||
## 版权信息
|
||||
|
||||
### 版权信息
|
||||
|
||||
本项目包含的第三方源码和二进制文件之版权信息另行标注。
|
||||
|
||||
@ -175,11 +169,6 @@ All rights reserved。
|
||||
|
||||
CRMEB® 商标和著作权所有者为西安众邦网络科技有限公司。
|
||||
|
||||

|
||||
[](http://s.crmeb.com/goods_detail/730)
|
||||
[](http://s.crmeb.com/goods_detail/728)
|
||||
[](http://s.crmeb.com/goods_detail/729)
|
||||
[](http://s.crmeb.com/goods_detail/711)
|
||||
|
||||
---
|
||||
[返回顶部 :fa-arrow-circle-up: ](https://gitee.com/ZhongBangKeJi/CRMEB#%E9%A1%B9%E7%9B%AE%E4%BB%8B%E7%BB%8D)
|
||||
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
define('INSTALL_DATE',1567993973);
|
||||
define('SERIALNUMBER','BaoWxF');
|
||||
1
crmeb/.env
Executable file
1
crmeb/.env
Executable file
@ -0,0 +1 @@
|
||||
APP_DEBUG = false
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME =
HOSTPORT = 3306
USERNAME =
PASSWORD =
DATABASE =
PREFIX = eb_
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
[REDIS]
REDIS_HOSTNAME =
PORT = 6379
REDIS_PASSWORD =
SELECT = 0
[QUEUE]
QUEUE_NAME =
|
||||
@ -1 +1 @@
|
||||
APP_DEBUG = true
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = test
USERNAME = username
PASSWORD = password
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
|
||||
APP_DEBUG = false
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME =
HOSTPORT = 3306
USERNAME =
PASSWORD =
DATABASE =
PREFIX = eb_
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
[REDIS]
REDIS_HOSTNAME =
PORT = 6379
REDIS_PASSWORD =
SELECT = 0
[QUEUE]
QUEUE_NAME =
|
||||
@ -1,2 +1,5 @@
|
||||
version=CRMEB-KY v4.4.3
|
||||
version_code=443
|
||||
version=CRMEB-KY v4.6.0
|
||||
version_code=460
|
||||
platform=gitee
|
||||
app_id=ze7x9rxsv09l6pvsyo
|
||||
app_key=fuF7U9zaybLa5gageVQzxtxQMFnvU2OI
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
版权所有 (c)2017-2027,西安众邦网络科技有限公司 保留所有权利。
|
||||
感谢您选择CrmEb开源客户管理+电商系统(简称CRMEB),CRMEB是国内最稳定、最强大、最先进的互联网电商平台解决方案之一,CRMEB基于 PHP + MySQL 的技术,采用ThinkPHP5.0框架开发。
|
||||
感谢您选择CRMEB开源客户管理+电商系统(简称CRMEB),CRMEB是国内稳定、功能强大、技术先进的互联网电商平台解决方案之一,CRMEB基于 PHP + MySQL 的技术,采用ThinkPHP5.0框架开发。
|
||||
为了使你正确并合法的使用本软件,请你在使用前务必阅读清楚下面的协议条款:
|
||||
本授权协议适用且仅适用于CRMEB任何版本,CRMEB官方对本授权协议的最终解释权和修改权。
|
||||
|
||||
@ -7,10 +7,10 @@
|
||||
1、您可以在完全遵守本最终用户授权协议的基础上,将本软件应用于非商业用途,而不必支付软件版权授权费用。
|
||||
2、您可以在协议规定的约束和限制范围内修改 CRMEB 源代码或界面风格以适应您的网站要求。
|
||||
3、您拥有使用本软件构建的网站全部内容所有权,并独立承担与这些内容的相关法律义务。
|
||||
4、获得商业授权之后,您可以将本软件应用于商业用途,同时依据所购买的授权类型中确定的技术支持内容。商业授权用户享有反映和提出意见的权力,相关意见将被作为首要考虑,但没有一定被采纳的承诺或保证。
|
||||
4、您可以将本软件应用于商业用途,但必须保留版权,去版权需要申请。
|
||||
|
||||
二、协议许可的权利和限制
|
||||
1、未获商业授权之前,不得删除网站底部及相应的官方版权信息和链接。购买商业授权请联系西安众邦网络科技有限公司了解最新说明。CRMEB著作权已在中华人民共和国国家版权局注册(中国国家版权局著作权登记号 2018SR024463),著作权受到法律和国际公约保护。
|
||||
1、未获去版权授权之前,不得删除网站底部及相应的官方版权信息和链接。购买商业授权请联系西安众邦网络科技有限公司了解最新说明。CRMEB著作权已在中华人民共和国国家版权局注册(中国国家版权局著作权登记号 2018SR024463),著作权受到法律和国际公约保护。
|
||||
2、未经官方许可,不得对本软件或与之关联的商业授权进行出租、出售、抵押或发放子许可证。
|
||||
3、不管你的网站是否整体使用 CRMEB ,还是部份栏目使用 CRMEB,在你使用了 CRMEB 的网站主页上必须加上 CRMEB 官方网址(www.crmeb.com)的链接。
|
||||
4、未经官方许可,禁止在 CRMEB 的整体或任何部分基础上以发展任何派生版本、修改版本或第三方版本用于重新分发。
|
||||
@ -18,11 +18,12 @@
|
||||
|
||||
三、有限担保和免责声明
|
||||
1、本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。
|
||||
2、用户出于自愿而使用本软件,您必须了解使用本软件的风险,在尚未购买产品技术服务之前,我们不承诺对免费用户提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任。
|
||||
3、电子文本形式的授权协议如同双方书面签署的协议一样,具有完全的和等同的法律效力。您一旦开始确认本协议并安装 CRMEB,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权力的同时,受到相关的约束和限制。协议许可范围以外的行为,将直接违反本授权协议并构成侵权,我们有权随时终止授权,责令停止损害,并保留追究相关责任的权力。
|
||||
2、本软件提供源代码,您在使用过程中产生的责任与西安众邦网络科技有限公司无关。
|
||||
3、用户出于自愿而使用本软件,您必须了解使用本软件的风险,在尚未购买产品技术服务之前,我们不承诺对免费用户提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任。
|
||||
4、电子文本形式的授权协议如同双方书面签署的协议一样,具有完全的和等同的法律效力。您一旦开始确认本协议并安装 CRMEB,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权力的同时,受到相关的约束和限制。协议许可范围以外的行为,将直接违反本授权协议并构成侵权,我们有权随时终止授权,责令停止损害,并保留追究相关责任的权力。
|
||||
|
||||
协议发布时间: 2017年8月01日
|
||||
版本最新更新: 2022年3月28日 By CRMEB
|
||||
版本最新更新: 2022年6月15日 By CRMEB
|
||||
|
||||
CRMEB官方网站:http://www.crmeb.com
|
||||
CRMEB演示站:http://demo.crmeb.com
|
||||
|
||||
@ -1,34 +1,7 @@
|
||||
CRMEB v4.x
|
||||
CRMEB v4.5 后端程序目录
|
||||
===============
|
||||
|
||||
> 运行环境要求PHP7.1+。
|
||||
|
||||
## 主要特性
|
||||
|
||||
### 开源无加密
|
||||
源码开源无加密,有详细的代码注释,有完整系统手册
|
||||
### TP6框架
|
||||
使用最新的 ThinkPHP 6.0框架开发
|
||||
### 前端采用Vue CLI框架
|
||||
前端使用Vue CLI框架nodejs打包,页面加载更流畅,用户体验更好
|
||||
### 标准接口
|
||||
标准接口、前后端分离,二次开发更方便
|
||||
### 支持队列
|
||||
降低流量高峰,解除耦合,高可用
|
||||
### 长连接
|
||||
减少CPU及内存使用及网络堵塞,减少请求响应时长
|
||||
### 无缝事件机制
|
||||
行为扩展更方便,方便二次开发
|
||||
### 后台快速生成表单
|
||||
后台应用form-builder 无需写页面快速增删改查
|
||||
### 数据表格导出
|
||||
PHPExcel数据导出,导出表格更加美观可视;
|
||||
### 数据统计分析
|
||||
后台使用ECharts图表统计,实现用户、产品、订单、资金等统计分析
|
||||
### 强大的后台权限管理
|
||||
后台多种角色、多重身份权限管理,权限可以控制到每一步操作
|
||||
### 一件安装
|
||||
自动检查系统环境一键安装
|
||||
> 运行环境要求PHP7.1-7.4。
|
||||
|
||||
## 安装
|
||||
|
||||
@ -43,12 +16,12 @@ PHPExcel数据导出,导出表格更加美观可视;
|
||||
3.域名/index.php?s=/admin
|
||||
公众号和H5首页访问地址:
|
||||
1.域名/
|
||||
提示:正常访问是第一中模式,第一种访问不了请检测[URL重写](http://help.crmeb.net/895486)是否配置好
|
||||
|
||||
安装过程中请牢记您的账号密码!
|
||||
|
||||
## 重新安装
|
||||
1. 清除数据库
|
||||
2. 删除/public/install/install.lock 文件
|
||||
2. 删除/public/install.lock 文件
|
||||
|
||||
## 手动安装
|
||||
1.创建数据库,倒入数据库文件
|
||||
@ -86,6 +59,15 @@ SELECT = 0 #数据库
|
||||
4.后台登录:
|
||||
http://域名/admin
|
||||
默认账号:admin 密码:crmeb.com
|
||||
## 消息队列
|
||||
```sh
|
||||
php think queue:listen --queue
|
||||
```
|
||||
|
||||
## 消息队列
|
||||
```sh
|
||||
php think queue:listen --queue
|
||||
```
|
||||
|
||||
## 定时任务
|
||||
在自动收货,库存预警等功能使用到
|
||||
@ -94,39 +76,31 @@ php think timer [ status ] [ --d ]
|
||||
```
|
||||
参数
|
||||
- status: 状态
|
||||
- start: 启动
|
||||
- stop: 关闭
|
||||
- restart: 重启
|
||||
- start: 启动
|
||||
- stop: 关闭
|
||||
- restart: 重启
|
||||
- --d : 后台执行
|
||||
|
||||
## 长连接服务
|
||||
在h5聊天,后台管理员消息通知等功能使用到
|
||||
```sh
|
||||
php think workerman [ status ] [ server ] [ --d ]
|
||||
php think workerman [ status ] [ --d ]
|
||||
```
|
||||
windows环境下需要分三步执行
|
||||
```sh
|
||||
# 内部通讯服务
|
||||
php think workerman start channel
|
||||
# h5端聊天服务
|
||||
php think workerman start chat
|
||||
# 后台管理员通知
|
||||
php think workerman start admin
|
||||
php think workerman start --d
|
||||
```
|
||||
参数
|
||||
- status: 状态
|
||||
- start: 启动
|
||||
- stop: 关闭
|
||||
- restart: 重启
|
||||
- server: 服务 (windows)
|
||||
- channel: 内部通讯
|
||||
- chat: h5
|
||||
- admin: 后台
|
||||
|
||||
- start: 启动
|
||||
- stop: 关闭
|
||||
- restart: 重启
|
||||
- --d : 后台执行
|
||||
|
||||
## 文档
|
||||
|
||||
[使用手册](https://help.crmeb.net)
|
||||
[使用手册](https://doc.crmeb.com)
|
||||
[TP6开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content)
|
||||
|
||||
|
||||
@ -139,7 +113,7 @@ php think workerman start admin
|
||||
|
||||
本项目包含的第三方源码和二进制文件之版权信息另行标注。
|
||||
|
||||
版权所有Copyright © 2017-2019 by CRMEB (http://www.crmeb.com)
|
||||
版权所有Copyright © 2017-2022 by CRMEB (http://www.crmeb.com)
|
||||
|
||||
All rights reserved。
|
||||
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
@ -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,19 +29,26 @@ class Request extends \think\Request
|
||||
{
|
||||
use Macroable;
|
||||
|
||||
/**
|
||||
* 不过滤变量名
|
||||
* @var array
|
||||
*/
|
||||
protected $except = ['menu_path', 'api_url', 'unique_auth', 'description', 'custom_form', 'content'];
|
||||
|
||||
/**
|
||||
* 获取请求的数据
|
||||
* @param array $params
|
||||
* @param bool $suffix
|
||||
* @param bool $filter
|
||||
* @return array
|
||||
*/
|
||||
public function more(array $params, bool $suffix = false): array
|
||||
public function more(array $params, bool $suffix = false, bool $filter = true): array
|
||||
{
|
||||
$p = [];
|
||||
$i = 0;
|
||||
foreach ($params as $param) {
|
||||
if (!is_array($param)) {
|
||||
$p[$suffix == true ? $i++ : $param] = $this->param($param);
|
||||
$p[$suffix == true ? $i++ : $param] = $this->filterWord(is_string($this->param($param)) ? trim($this->param($param)) : $this->param($param), $filter && !in_array($param, $this->except));
|
||||
} else {
|
||||
if (!isset($param[1])) $param[1] = null;
|
||||
if (!isset($param[2])) $param[2] = '';
|
||||
@ -52,32 +59,65 @@ class Request extends \think\Request
|
||||
$name = is_array($param[1]) ? $param[0] . '/a' : $param[0];
|
||||
$keyName = $param[0];
|
||||
}
|
||||
$p[$suffix == true ? $i++ : ($param[3] ?? $keyName)] = $this->param($name, $param[1], $param[2]);
|
||||
$p[$suffix == true ? $i++ : ($param[3] ?? $keyName)] = $this->filterWord(is_string($this->param($name, $param[1], $param[2])) ? trim($this->param($name, $param[1], $param[2])) : $this->param($name, $param[1], $param[2]), $filter && !in_array($keyName, $this->except));
|
||||
}
|
||||
}
|
||||
return $p;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤接受的参数
|
||||
* @param $str
|
||||
* @param bool $filter
|
||||
* @return array|mixed|string|string[]
|
||||
*/
|
||||
public function filterWord($str, bool $filter = true)
|
||||
{
|
||||
if (!$str || !$filter) return $str;
|
||||
// 把数据过滤
|
||||
$farr = [
|
||||
"/<(\\/?)(script|i?frame|style|html|body|title|link|meta|object|\\?|\\%)([^>]*?)>/isU",
|
||||
"/(<[^>]*)on[a-zA-Z]+\s*=([^>]*>)/isU",
|
||||
"/select|join|where|drop|like|modify|rename|insert|update|table|database|alter|truncate|\'|\/\*|\.\.\/|\.\/|union|into|load_file|outfile/is"
|
||||
];
|
||||
if (is_array($str)) {
|
||||
foreach ($str as &$v) {
|
||||
if (is_array($v)) {
|
||||
foreach ($v as &$vv) {
|
||||
if (!is_array($vv)) $vv = preg_replace($farr, '', $vv);
|
||||
}
|
||||
} else {
|
||||
$v = preg_replace($farr, '', $v);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$str = preg_replace($farr, '', $str);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取get参数
|
||||
* @param array $params
|
||||
* @param bool $suffix
|
||||
* @param bool $filter
|
||||
* @return array
|
||||
*/
|
||||
public function getMore(array $params, bool $suffix = false): array
|
||||
public function getMore(array $params, bool $suffix = false, bool $filter = true): array
|
||||
{
|
||||
return $this->more($params, $suffix);
|
||||
return $this->more($params, $suffix, $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取post参数
|
||||
* @param array $params
|
||||
* @param bool $suffix
|
||||
* @param bool $filter
|
||||
* @return array
|
||||
*/
|
||||
public function postMore(array $params, bool $suffix = false): array
|
||||
public function postMore(array $params, bool $suffix = false, bool $filter = true): array
|
||||
{
|
||||
return $this->more($params, $suffix);
|
||||
return $this->more($params, $suffix, $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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,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");
|
||||
@ -80,20 +78,18 @@ class AdminApiExceptionHandle extends Handle
|
||||
public function render($request, Throwable $e): Response
|
||||
{
|
||||
$massageData = Env::get('app_debug', false) ? [
|
||||
'message' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : [];
|
||||
$message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了';
|
||||
// 添加自定义异常处理机制
|
||||
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($e->getMessage(), $massageData);
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||
} else {
|
||||
return app('json')->code(200)->make(400, $e->getMessage(), $massageData);
|
||||
return app('json')->fail($message, $massageData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
@ -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,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)
|
||||
{
|
||||
|
||||
@ -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,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(),
|
||||
'label' => 19,
|
||||
'domain_name' => $host,
|
||||
'label' => 34,
|
||||
'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,
|
||||
'label' => 19,
|
||||
'domain_name' => $host,
|
||||
'label' => 34,
|
||||
'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' => 34,
|
||||
'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' => $res['data']['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_image'
|
||||
], [
|
||||
'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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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,6 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use crmeb\services\CacheService;
|
||||
use think\facade\App;
|
||||
use crmeb\utils\Captcha;
|
||||
use app\services\system\admin\SystemAdminServices;
|
||||
@ -47,6 +48,34 @@ class Login extends AuthController
|
||||
return app()->make(Captcha::class)->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function ajcaptcha()
|
||||
{
|
||||
$captchaType = $this->request->get('captchaType');
|
||||
return app('json')->success(aj_captcha_create($captchaType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次验证
|
||||
* @return mixed
|
||||
*/
|
||||
public function ajcheck()
|
||||
{
|
||||
[$token, $pointJson, $captchaType] = $this->request->postMore([
|
||||
['token', ''],
|
||||
['pointJson', ''],
|
||||
['captchaType', ''],
|
||||
], true);
|
||||
try {
|
||||
aj_captcha_check_one($captchaType, $token, $pointJson);
|
||||
return app('json')->success();
|
||||
} catch (\Throwable $e) {
|
||||
return app('json')->fail(400336);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 登陆
|
||||
* @return mixed
|
||||
@ -56,17 +85,34 @@ class Login extends AuthController
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
[$account, $password, $imgcode] = $this->request->postMore([
|
||||
'account', 'pwd', ['imgcode', '']
|
||||
[$account, $password, $key, $captchaVerification, $captchaType] = $this->request->postMore([
|
||||
'account',
|
||||
'pwd',
|
||||
['key', ''],
|
||||
['captchaVerification', ''],
|
||||
['captchaType', '']
|
||||
], true);
|
||||
|
||||
if (!app()->make(Captcha::class)->check($imgcode)) {
|
||||
return app('json')->fail('验证码错误,请重新输入');
|
||||
if ($captchaVerification != '') {
|
||||
try {
|
||||
aj_captcha_check_two($captchaType, $captchaVerification);
|
||||
} catch (\Throwable $e) {
|
||||
return app('json')->fail(400336);
|
||||
}
|
||||
}
|
||||
|
||||
$this->validate(['account' => $account, 'pwd' => $password], \app\adminapi\validate\setting\SystemAdminValidata::class, 'get');
|
||||
|
||||
return app('json')->success($this->services->login($account, $password, 'admin'));
|
||||
$result = $this->services->login($account, $password, 'admin', $key);
|
||||
if (!$result) {
|
||||
$num = CacheService::redisHandler()->get('login_captcha',1);
|
||||
if ($num > 1) {
|
||||
return app('json')->fail(400140, ['login_captcha' => 1]);
|
||||
}
|
||||
CacheService::redisHandler()->set('login_captcha', $num + 1, 60);
|
||||
return app('json')->fail(400140, ['login_captcha' => 0]);
|
||||
}
|
||||
CacheService::redisHandler()->delete('login_captcha');
|
||||
return app('json')->success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
@ -6,13 +6,11 @@
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use crmeb\services\UploadService;
|
||||
|
||||
class Test
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
742
crmeb/app/adminapi/controller/UpgradeController.php
Normal file
742
crmeb/app/adminapi/controller/UpgradeController.php
Normal file
@ -0,0 +1,742 @@
|
||||
<?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;
|
||||
|
||||
use app\Request;
|
||||
use app\services\order\StoreOrderCartInfoServices;
|
||||
use app\services\order\StoreOrderCreateServices;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\system\UpgradeServices;
|
||||
use app\services\user\UserBillServices;
|
||||
use app\services\user\UserBrokerageServices;
|
||||
use app\services\user\UserMoneyServices;
|
||||
use app\services\user\UserBrokerageFrozenServices;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class UpgradeController
|
||||
{
|
||||
/**
|
||||
* @var UpgradeServices
|
||||
*/
|
||||
private $services;
|
||||
|
||||
/**
|
||||
* UpgradeController constructor.
|
||||
* @param UpgradeServices $services
|
||||
*/
|
||||
public function __construct(UpgradeServices $services)
|
||||
{
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级程序页面
|
||||
* @param Request $request
|
||||
* @return \think\response\View
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data = $this->upData();
|
||||
$Title = "CRMEB升级程序";
|
||||
$Powered = "Powered by CRMEB";
|
||||
|
||||
//获取当前版本号
|
||||
$version_now = $this->getversion('.version')['version'];
|
||||
$version_new = $data['new_version'];
|
||||
$isUpgrade = true;
|
||||
$executeIng = false;
|
||||
|
||||
return view('/upgrade/step1', [
|
||||
'title' => $Title,
|
||||
'powered' => $Powered,
|
||||
'version_now' => $version_now,
|
||||
'version_new' => $version_new,
|
||||
'isUpgrade' => json_encode($isUpgrade),
|
||||
'executeIng' => json_encode($executeIng),
|
||||
'next' => 1,
|
||||
'action' => 'upgrade'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前版本号
|
||||
* @return array
|
||||
*/
|
||||
public function getversion($str)
|
||||
{
|
||||
$version_arr = [];
|
||||
$curent_version = @file(app()->getRootPath() . $str);
|
||||
|
||||
foreach ($curent_version as $val) {
|
||||
list($k, $v) = explode('=', $val);
|
||||
$version_arr[$k] = $v;
|
||||
}
|
||||
return $version_arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入升级过程
|
||||
* @param string $field
|
||||
* @param int $n
|
||||
* @return bool
|
||||
*/
|
||||
public function setIsUpgrade(string $field, int $n = 0)
|
||||
{
|
||||
$upgrade = parse_ini_file(public_path('upgrade') . '.upgrade');
|
||||
if ($n) {
|
||||
if (!is_array($upgrade)) {
|
||||
$upgrade = [];
|
||||
}
|
||||
$string = '';
|
||||
foreach ($upgrade as $key => $item) {
|
||||
$string .= $key . '=' . $item . "\r\n";
|
||||
}
|
||||
$string .= $field . '=' . $n . "\r\n";
|
||||
file_put_contents(public_path('upgrade') . '.upgrade', $string);
|
||||
return true;
|
||||
} else {
|
||||
if (!is_array($upgrade)) {
|
||||
return false;
|
||||
}
|
||||
return isset($upgrade[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
public function upgrade(Request $request)
|
||||
{
|
||||
list($sleep, $page, $prefix) = $request->getMore([
|
||||
['sleep', 0],
|
||||
['page', 1],
|
||||
['prefix', 'eb_'],
|
||||
], true);
|
||||
$data = $this->upData();
|
||||
$code_now = $this->getversion('.version')['version_code'];
|
||||
if ($data['new_code'] == $code_now) {
|
||||
return app('json')->success(['sleep' => -1]);
|
||||
}
|
||||
$sql_arr = [];
|
||||
foreach ($data['update_sql'] as $items) {
|
||||
if ($items['code'] > $code_now) {
|
||||
$sql_arr[] = $items;
|
||||
}
|
||||
}
|
||||
//sql 执行完成,开始执行修改数据
|
||||
if (!isset($sql_arr[$sleep])) {
|
||||
// $limit = 100;
|
||||
// if (!$this->setIsUpgrade('money')) {
|
||||
// $res = $this->handleMoney((int)$sleep, (int)$page, (int)$limit);
|
||||
// return app('json')->success($res);
|
||||
// } elseif (!$this->setIsUpgrade('brokerage')) {
|
||||
// $res = $this->handleBrokerage((int)$sleep, (int)$page, (int)$limit);
|
||||
// return app('json')->success($res);
|
||||
// } elseif (!$this->setIsUpgrade('orderRefund')) {
|
||||
// $res = $this->handleOrderRefund((int)$sleep, (int)$page, (int)$limit);
|
||||
// return app('json')->success($res);
|
||||
// } else {
|
||||
// file_put_contents(app()->getRootPath() . '.version', "version=" . $data['new_version'] . "\nversion_code=" . $data['new_code']);
|
||||
// return app('json')->success(['sleep' => -1]);
|
||||
// }
|
||||
// $limit = 100;
|
||||
// if (!$this->setIsUpgrade('cartInfo')) {
|
||||
// $res = $this->handleCartInfo((int)$sleep, (int)$page, (int)$limit);
|
||||
// return app('json')->success($res);
|
||||
// } else {
|
||||
// file_put_contents(app()->getRootPath() . '.version', "version=" . $data['new_version'] . "\nversion_code=" . $data['new_code'] . "\napp_id=ze7x9rxsv09l6pvsyo" . "\napp_key=fuF7U9zaybLa5gageVQzxtxQMFnvU2OI");
|
||||
// $this->services->generateSignature();
|
||||
// return app('json')->success(['sleep' => -1]);
|
||||
// }
|
||||
file_put_contents(app()->getRootPath() . '.version', "version=" . $data['new_version'] . "\nversion_code=" . $data['new_code'] . "\nplatform=CRMEB\napp_id=ze7x9rxsv09l6pvsyo" . "\napp_key=fuF7U9zaybLa5gageVQzxtxQMFnvU2OI");
|
||||
$this->services->generateSignature();
|
||||
return app('json')->success(['sleep' => -1]);
|
||||
}
|
||||
$sql = $sql_arr[$sleep];
|
||||
Db::startTrans();
|
||||
try {
|
||||
if ($sql['type'] == 1) {
|
||||
if (isset($sql['findSql']) && $sql['findSql']) {
|
||||
$table = $prefix . $sql['table'];
|
||||
$findSql = str_replace('@table', $table, $sql['findSql']);
|
||||
if (!empty(Db::query($findSql))) {
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表已存在';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
if (isset($sql['sql']) && $sql['sql']) {
|
||||
$upSql = $sql['sql'];
|
||||
$upSql = str_replace('@table', $table, $upSql);
|
||||
Db::execute($upSql);
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表添加成功';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
} elseif ($sql['type'] == 2) {
|
||||
if (isset($sql['findSql']) && $sql['findSql']) {
|
||||
$table = $prefix . $sql['table'];
|
||||
$findSql = str_replace('@table', $table, $sql['findSql']);
|
||||
if (empty(Db::query($findSql))) {
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表不存在';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
if (isset($sql['sql']) && $sql['sql']) {
|
||||
$upSql = $sql['sql'];
|
||||
$upSql = str_replace('@table', $table, $upSql);
|
||||
Db::execute($upSql);
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表删除成功';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
} elseif ($sql['type'] == 3) {
|
||||
if (isset($sql['findSql']) && $sql['findSql']) {
|
||||
$table = $prefix . $sql['table'];
|
||||
$findSql = str_replace('@table', $table, $sql['findSql']);
|
||||
if (!empty(Db::query($findSql))) {
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表中' . $sql['field'] . '已存在';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
if (isset($sql['sql']) && $sql['sql']) {
|
||||
$upSql = $sql['sql'];
|
||||
$upSql = str_replace('@table', $table, $upSql);
|
||||
Db::execute($upSql);
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表中' . $sql['field'] . '字段添加成功';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
} elseif ($sql['type'] == 4) {
|
||||
if (isset($sql['findSql']) && $sql['findSql']) {
|
||||
$table = $prefix . $sql['table'];
|
||||
$findSql = str_replace('@table', $table, $sql['findSql']);
|
||||
if (empty(Db::query($findSql))) {
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表中' . $sql['field'] . '不存在';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
if (isset($sql['sql']) && $sql['sql']) {
|
||||
$upSql = $sql['sql'];
|
||||
$upSql = str_replace('@table', $table, $upSql);
|
||||
Db::execute($upSql);
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表中' . $sql['field'] . '字段修改成功';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
} elseif ($sql['type'] == 5) {
|
||||
if (isset($sql['findSql']) && $sql['findSql']) {
|
||||
$table = $prefix . $sql['table'];
|
||||
$findSql = str_replace('@table', $table, $sql['findSql']);
|
||||
if (empty(Db::query($findSql))) {
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表中' . $sql['field'] . '不存在';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
if (isset($sql['sql']) && $sql['sql']) {
|
||||
$upSql = $sql['sql'];
|
||||
$upSql = str_replace('@table', $table, $upSql);
|
||||
Db::execute($upSql);
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表中' . $sql['field'] . '字段删除成功';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
} elseif ($sql['type'] == 6) {
|
||||
$table = $prefix . $sql['table'] ?? '';
|
||||
$whereTable = $prefix . $sql['whereTable'] ?? '';
|
||||
if (isset($sql['findSql']) && $sql['findSql']) {
|
||||
$findSql = str_replace('@table', $table, $sql['findSql']);
|
||||
if (!empty(Db::query($findSql))) {
|
||||
$item['table'] = $prefix . $sql['table'];
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表中此数据已存在';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
if (isset($sql['sql']) && $sql['sql']) {
|
||||
$upSql = $sql['sql'];
|
||||
$upSql = str_replace('@table', $table, $upSql);
|
||||
if (isset($sql['whereSql']) && $sql['whereSql']) {
|
||||
$whereSql = str_replace('@whereTable', $whereTable, $sql['whereSql']);
|
||||
$tabId = Db::query($whereSql)[0]['tabId'] ?? 0;
|
||||
if (!$tabId) {
|
||||
$item['table'] = $whereTable;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = '查询父类ID不存在';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
$upSql = str_replace('@tabId', $tabId, $upSql);
|
||||
}
|
||||
if (Db::execute($upSql)) {
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = '数据添加成功';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
} elseif ($sql['type'] == 7) {
|
||||
$table = $prefix . $sql['table'] ?? '';
|
||||
$whereTable = $prefix . $sql['whereTable'] ?? '';
|
||||
if (isset($sql['findSql']) && $sql['findSql']) {
|
||||
$findSql = str_replace('@table', $table, $sql['findSql']);
|
||||
if (empty(Db::query($findSql))) {
|
||||
$item['table'] = $prefix . $sql['table'];
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . '表中此数据不存在';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
if (isset($sql['sql']) && $sql['sql']) {
|
||||
$upSql = $sql['sql'];
|
||||
$upSql = str_replace('@table', $table, $upSql);
|
||||
if (isset($sql['whereSql']) && $sql['whereSql']) {
|
||||
$whereSql = str_replace('@whereTable', $whereTable, $sql['whereSql']);
|
||||
$tabId = Db::query($whereSql)[0]['tabId'] ?? 0;
|
||||
if (!$tabId) {
|
||||
$item['table'] = $whereTable;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = '查询父类ID不存在';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
$upSql = str_replace('@tabId', $tabId, $upSql);
|
||||
}
|
||||
if (Db::execute($upSql)) {
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = '数据修改成功';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
} elseif ($sql['type'] == 8) {
|
||||
|
||||
} elseif ($sql['type'] == -1) {
|
||||
$table = $prefix . $sql['table'];
|
||||
if (isset($sql['sql']) && $sql['sql']) {
|
||||
$upSql = $sql['sql'];
|
||||
$upSql = str_replace('@table', $table, $upSql);
|
||||
if (isset($sql['new_table']) && $sql['new_table']) {
|
||||
$new_table = $prefix . $sql['new_table'];
|
||||
$upSql = str_replace('@new_table', $new_table, $upSql);
|
||||
}
|
||||
Db::execute($upSql);
|
||||
$item['table'] = $table;
|
||||
$item['status'] = 1;
|
||||
$item['error'] = $table . ' sql执行成功';
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
Db::commit();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$item['table'] = $prefix . $sql['table'];
|
||||
$item['status'] = 0;
|
||||
$item['sleep'] = $sleep + 1;
|
||||
$item['add_time'] = date('Y-m-d H:i:s', time());
|
||||
$item['error'] = $e->getMessage();
|
||||
Db::rollBack();
|
||||
return app('json')->success($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理历史余额数据
|
||||
* @param int $sleep
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return mixed
|
||||
*/
|
||||
public function handleMoney(int $sleep = 1, int $page = 1, int $limit = 100)
|
||||
{
|
||||
/** @var UserBillServices $userBillServics */
|
||||
$userBillServics = app()->make(UserBillServices::class);
|
||||
$where = ['category' => 'now_money', 'type' => ['pay_product', 'pay_product_refund', 'system_add', 'system_sub', 'recharge', 'lottery_use', 'lottery_add']];
|
||||
$list = $userBillServics->getList($where, '*', $page, $limit, [], 'id asc');
|
||||
if ($list) {
|
||||
$allData = $data = [];
|
||||
foreach ($list as $item) {
|
||||
$data = [
|
||||
'uid' => $item['uid'],
|
||||
'link_id' => $item['link_id'],
|
||||
'pm' => $item['pm'],
|
||||
'title' => $item['title'],
|
||||
'type' => $item['type'],
|
||||
'number' => $item['number'],
|
||||
'balance' => $item['balance'],
|
||||
'mark' => $item['mark'],
|
||||
'add_time' => strtotime($item['add_time']),
|
||||
];
|
||||
$allData[] = $data;
|
||||
}
|
||||
if ($allData) {
|
||||
/** @var UserMoneyServices $userMoneyServices */
|
||||
$userMoneyServices = app()->make(UserMoneyServices::class);
|
||||
$userMoneyServices->saveAll($allData);
|
||||
}
|
||||
$info['table'] = 'user_money';
|
||||
$info['status'] = 1;
|
||||
$info['error'] = '余额数据更新成功';
|
||||
$info['sleep'] = $sleep + 1;
|
||||
$info['page'] = $page + 1;
|
||||
$info['add_time'] = date('Y-m-d H:i:s', time());
|
||||
return $info;
|
||||
} else {
|
||||
$this->setIsUpgrade('money', 1);
|
||||
$info['table'] = 'user_money';
|
||||
$info['status'] = 1;
|
||||
$info['error'] = '余额数据更新成功';
|
||||
$info['sleep'] = $sleep + 1;
|
||||
$info['page'] = 1;
|
||||
$info['add_time'] = date('Y-m-d H:i:s', time());
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理历史佣金数据
|
||||
* @param int $sleep
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return mixed
|
||||
*/
|
||||
public function handleBrokerage(int $sleep = 1, int $page = 1, int $limit = 100)
|
||||
{
|
||||
/** @var UserBillServices $userBillServics */
|
||||
$userBillServics = app()->make(UserBillServices::class);
|
||||
$where = ['category' => ['', 'now_money'], 'type' => ['brokerage', 'brokerage_user', 'extract', 'refund', 'extract_fail']];
|
||||
$list = $userBillServics->getList($where, '*', $page, $limit, [], 'id asc');
|
||||
if ($list) {
|
||||
$allData = $data = [];
|
||||
/** @var $brokerageFrozenServices */
|
||||
$brokerageFrozenServices = app()->make(UserBrokerageFrozenServices::class);
|
||||
$frozenList = $brokerageFrozenServices->getColumn([['uill_id', 'in', array_column($list, 'id')], ['frozen_time', '>', time()]], 'uill_id,frozen_time', 'uill_id');
|
||||
foreach ($list as $item) {
|
||||
if (in_array($item['type'], ['brokerage_user', 'extract', 'refund', 'extract_fail'])) {
|
||||
$type = $item['type'];
|
||||
} else {
|
||||
if (strpos($item['mark'], '二级')) {
|
||||
$type = 'two_brokerage';
|
||||
} else {
|
||||
$type = 'one_brokerage';
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'uid' => $item['uid'],
|
||||
'link_id' => $item['link_id'],
|
||||
'pm' => $item['pm'],
|
||||
'title' => $item['title'],
|
||||
'type' => $type,
|
||||
'number' => $item['number'],
|
||||
'balance' => $item['balance'],
|
||||
'mark' => $item['mark'],
|
||||
'frozen_time' => $frozenList[$item['id']]['frozen_time'] ?? 0,
|
||||
'add_time' => strtotime($item['add_time']),
|
||||
];
|
||||
$allData[] = $data;
|
||||
}
|
||||
if ($allData) {
|
||||
/** @var UserBrokerageServices $userBrokerageServices */
|
||||
$userBrokerageServices = app()->make(UserBrokerageServices::class);
|
||||
$userBrokerageServices->saveAll($allData);
|
||||
}
|
||||
$info['table'] = 'user_brokerage';
|
||||
$info['status'] = 1;
|
||||
$info['error'] = '佣金数据更新成功';
|
||||
$info['sleep'] = $sleep + 1;
|
||||
$info['page'] = $page + 1;
|
||||
$info['add_time'] = date('Y-m-d H:i:s', time());
|
||||
return $info;
|
||||
} else {
|
||||
$this->setIsUpgrade('brokerage', 1);
|
||||
$info['table'] = 'user_brokerage';
|
||||
$info['status'] = 1;
|
||||
$info['error'] = '佣金数据更新成功';
|
||||
$info['sleep'] = $sleep + 1;
|
||||
$info['page'] = 1;
|
||||
$info['add_time'] = date('Y-m-d H:i:s', time());
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理历史退款数据
|
||||
* @param int $sleep
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function handleOrderRefund(int $sleep = 1, int $page = 1, int $limit = 100)
|
||||
{
|
||||
/** @var StoreOrderServices $storeOrderServices */
|
||||
$storeOrderServices = app()->make(StoreOrderServices::class);
|
||||
$list = $storeOrderServices->getSplitOrderList(['refund_status' => [1, 2], ['refund_type' => [1, 2, 4, 5, 6]]], ['*'], [], $page, $limit, 'id asc');
|
||||
$allData = $refundOrderData = [];
|
||||
if ($list) {
|
||||
/** @var StoreOrderCreateServices $storeOrderCreateServices */
|
||||
$storeOrderCreateServices = app()->make(StoreOrderCreateServices::class);
|
||||
/** @var StoreOrderCartInfoServices $storeOrderCartInfoServices */
|
||||
$storeOrderCartInfoServices = app()->make(StoreOrderCartInfoServices::class);
|
||||
$time = time();
|
||||
foreach ($list as $order) {
|
||||
//生成退款订单
|
||||
$refundOrderData['uid'] = $order['uid'];
|
||||
$refundOrderData['store_id'] = $order['store_id'];
|
||||
$refundOrderData['store_order_id'] = $order['id'];
|
||||
$refundOrderData['order_id'] = $storeOrderCreateServices->getNewOrderId('');
|
||||
$refundOrderData['refund_num'] = $order['total_num'];
|
||||
$refundOrderData['refund_type'] = $order['refund_type'];
|
||||
$refundOrderData['refund_price'] = $order['pay_price'];
|
||||
$refundOrderData['refunded_price'] = 0;
|
||||
$refundOrderData['refund_explain'] = $order['refund_reason_wap_explain'];
|
||||
$refundOrderData['refund_img'] = $order['refund_reason_wap_img'];
|
||||
$refundOrderData['refund_reason'] = $order['refund_reason_wap'];
|
||||
$refundOrderData['refund_express'] = $order['refund_express'];
|
||||
$refundOrderData['refunded_time'] = $order['refund_type'] == 6 ? $order['refund_reason_time'] : 0;
|
||||
$refundOrderData['add_time'] = $order['refund_reason_time'];
|
||||
$cartInfos = $storeOrderCartInfoServices->getCartColunm(['oid' => $order['id']], 'id,cart_id,cart_num,cart_info');
|
||||
foreach ($cartInfos as &$cartInfo) {
|
||||
$cartInfo['cart_info'] = is_string($cartInfo['cart_info']) ? json_decode($cartInfo['cart_info'], true) : $cartInfo['cart_info'];
|
||||
}
|
||||
$refundOrderData['cart_info'] = json_encode(array_column($cartInfos, 'cart_info'));
|
||||
$allData[] = $refundOrderData;
|
||||
}
|
||||
if ($allData) {
|
||||
/** @var StoreOrderRefundServices $storeOrderRefundServices */
|
||||
$storeOrderRefundServices = app()->make(StoreOrderRefundServices::class);
|
||||
$storeOrderRefundServices->saveAll($allData);
|
||||
}
|
||||
$info['table'] = 'store_order_refund';
|
||||
$info['status'] = 1;
|
||||
$info['error'] = '退款数据更新成功';
|
||||
$info['sleep'] = $sleep + 1;
|
||||
$info['page'] = $page + 1;
|
||||
$info['add_time'] = date('Y-m-d H:i:s', time());
|
||||
return $info;
|
||||
} else {
|
||||
$this->setIsUpgrade('orderRefund', 1);
|
||||
$info['table'] = 'store_order_refund';
|
||||
$info['status'] = 1;
|
||||
$info['error'] = '退款数据更新成功';
|
||||
$info['sleep'] = $sleep + 1;
|
||||
$info['page'] = 1;
|
||||
$info['add_time'] = date('Y-m-d H:i:s', time());
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新订单商品表
|
||||
* @param int $sleep
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return array
|
||||
*/
|
||||
public function handleCartInfo(int $sleep = 1, int $page = 1, int $limit = 100)
|
||||
{
|
||||
/** @var StoreOrderCartInfoServices $storeOrderCartInfoServices */
|
||||
$storeOrderCartInfoServices = app()->make(StoreOrderCartInfoServices::class);
|
||||
$list = $storeOrderCartInfoServices->selectList(['uid' => 0], 'id,oid', $page, $limit)->toArray();
|
||||
$allData = $cartData = [];
|
||||
if ($list) {
|
||||
/** @var StoreOrderServices $storeOrderServices */
|
||||
$storeOrderServices = app()->make(StoreOrderServices::class);
|
||||
$uids = $storeOrderServices->getColumn([['id','in',array_column($list,'oid')]],'uid','id');
|
||||
foreach ($list as $cart) {
|
||||
$cartData['id'] = $cart['id'];
|
||||
$cartData['uid'] = $uids[$cart['oid']] ?? 0;
|
||||
$allData[] = $cartData;
|
||||
}
|
||||
if ($allData) {
|
||||
$storeOrderCartInfoServices->saveAll($allData);
|
||||
}
|
||||
$info['table'] = 'store_order_cart_info';
|
||||
$info['status'] = 1;
|
||||
$info['error'] = '订单商品数据更新成功';
|
||||
$info['sleep'] = $sleep + 1;
|
||||
$info['page'] = $page + 1;
|
||||
} else {
|
||||
$this->setIsUpgrade('cartInfo', 1);
|
||||
$info['table'] = 'store_order_cart_info';
|
||||
$info['status'] = 1;
|
||||
$info['error'] = '订单商品数据更新成功';
|
||||
$info['sleep'] = $sleep + 1;
|
||||
$info['page'] = 1;
|
||||
}
|
||||
$info['add_time'] = date('Y-m-d H:i:s', time());
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 升级数据
|
||||
* @return mixed
|
||||
*/
|
||||
public function upData()
|
||||
{
|
||||
$data['new_version'] = 'CRMEB-BZ v4.6.0';
|
||||
$data['new_code'] = 460;
|
||||
$data['update_sql'] = [];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function upgradeList()
|
||||
{
|
||||
return app('json')->success($this->services->getUpgradeList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 可升级列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function upgradeableList()
|
||||
{
|
||||
return app('json')->success($this->services->getUpgradeableList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 可升级列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function agreement()
|
||||
{
|
||||
return app('json')->success($this->services->getAgreement());
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载升级包
|
||||
* @param $packageKey
|
||||
* @return mixed
|
||||
*/
|
||||
public function download($packageKey)
|
||||
{
|
||||
if (empty($packageKey)) {
|
||||
return app('json')->fail(100100);
|
||||
}
|
||||
|
||||
$this->services->packageDownload($packageKey);
|
||||
return app('json')->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级进度
|
||||
* @return mixed
|
||||
*/
|
||||
public function progress()
|
||||
{
|
||||
$result = $this->services->getProgress();
|
||||
return app('json')->success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取升级状态
|
||||
* @return mixed
|
||||
*/
|
||||
public function upgradeStatus()
|
||||
{
|
||||
$data = $this->services->getUpgradeStatus();
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级记录
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function upgradeLogList()
|
||||
{
|
||||
$data = $this->services->getUpgradeLogList();
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出备份
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function export($id, $type)
|
||||
{
|
||||
if (!$id || !$type) {
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
return app('json')->success($this->services->export((int)$id, $type));
|
||||
}
|
||||
}
|
||||
@ -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) {
|
||||
@ -222,8 +226,11 @@ class AgentManage extends AuthController
|
||||
$spreadInfo->save();
|
||||
$userInfo->spread_uid = $spreadUid;
|
||||
$userInfo->spread_time = time();
|
||||
$userInfo->division_id = $spreadInfo->division_id;
|
||||
$userInfo->agent_id = $spreadInfo->agent_id;
|
||||
$userInfo->is_staff = $spreadInfo->is_staff;
|
||||
$userInfo->save();
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -233,8 +240,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 +256,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 +275,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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -10,17 +10,17 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\controller\v1\application\routine;
|
||||
|
||||
use app\jobs\notice\SyncMessageJob;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\message\TemplateMessageServices;
|
||||
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 +42,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,77 +52,19 @@ 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' => '请检查小程序所属类目',
|
||||
];
|
||||
$list = MiniProgramService::getSubscribeTemplateList();
|
||||
foreach ($list->data as $v) {
|
||||
MiniProgramService::delSubscribeTemplate($v['priTmplId']);
|
||||
}
|
||||
if ($all['list']) {
|
||||
$time = time();
|
||||
foreach ($all['list'] as $template) {
|
||||
if ($template['tempkey']) {
|
||||
if (!isset($template['kid'])) {
|
||||
return app('json')->fail('数据库模版表(template_message)缺少字段:kid');
|
||||
}
|
||||
if (isset($template['kid']) && $template['kid']) {
|
||||
continue;
|
||||
}
|
||||
$works = [];
|
||||
try {
|
||||
$works = MiniProgramService::getSubscribeTemplateKeyWords($template['tempkey']);
|
||||
} 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()]);
|
||||
}
|
||||
$errData[1] = '获取关键词列表失败:' . $wechatErr->getMessage();
|
||||
}
|
||||
$kid = [];
|
||||
if ($works) {
|
||||
$works = array_combine(array_column($works, 'name'), $works);
|
||||
$content = is_array($template['content']) ? $template['content'] : explode("\n", $template['content']);
|
||||
foreach ($content as $c) {
|
||||
$name = explode('{{', $c)[0] ?? '';
|
||||
if ($name && isset($works[$name])) {
|
||||
$kid[] = $works[$name]['kid'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($kid && isset($template['kid']) && !$template['kid']) {
|
||||
$tempid = '';
|
||||
try {
|
||||
$tempid = MiniProgramService::addSubscribeTemplate($template['tempkey'], $kid, $template['name']);
|
||||
} 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()]);
|
||||
}
|
||||
$errData[2] = '添加订阅消息模版失败:' . $wechatErr->getMessage();
|
||||
}
|
||||
if ($tempid != $template['tempid']) {
|
||||
$this->services->update($template['id'], ['tempid' => $tempid, 'kid' => json_encode($kid), 'add_time' => $time], 'id');
|
||||
}
|
||||
}
|
||||
}
|
||||
SyncMessageJob::dispatchDo('SyncSubscribe', [$template]);
|
||||
}
|
||||
}
|
||||
$msg = $errData ? implode('\n', $errData) : '同步成功';
|
||||
return app('json')->success($msg);
|
||||
return app('json')->success(100038);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,7 +77,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 +154,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', '');
|
||||
@ -382,12 +177,12 @@ class RoutineTemplate extends AuthController
|
||||
$qrcode = app()->make(QrcodeServices::class);
|
||||
$resForever = $qrcode->qrCodeForever(0, 'code');
|
||||
if ($resForever) {
|
||||
$resCode = MiniProgramService::qrcodeService()->appCodeUnlimit($resForever->id, '', 280);
|
||||
$resCode = MiniProgramService::appCodeUnlimitService($resForever->id, '', 280);
|
||||
$res = ['res' => $resCode, 'id' => $resForever->id];
|
||||
} 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,307 +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\controller\AuthController;
|
||||
use app\services\kefu\LoginServices;
|
||||
use app\services\message\service\StoreServiceLogServices;
|
||||
use app\services\message\service\StoreServiceServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\user\UserWechatuserServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\services\CacheService;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 客服管理
|
||||
* Class StoreService
|
||||
* @package app\admin\controller\store
|
||||
*/
|
||||
class StoreService extends AuthController
|
||||
{
|
||||
/**
|
||||
* StoreService constructor.
|
||||
* @param App $app
|
||||
* @param StoreServiceServices $services
|
||||
*/
|
||||
public function __construct(App $app, StoreServiceServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
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,w.user_type');
|
||||
return app('json')->success(compact('list', 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加客服表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
return app('json')->success($this->services->create());
|
||||
}
|
||||
|
||||
/*
|
||||
* 保存新建的资源
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['image', ''],
|
||||
['uid', 0],
|
||||
['avatar', ''],
|
||||
['customer', ''],
|
||||
['notify', ''],
|
||||
['phone', ''],
|
||||
['account', ''],
|
||||
['password', ''],
|
||||
['true_password', ''],
|
||||
['phone', ''],
|
||||
['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'] == '') {
|
||||
if (!$userInfo['phone']) {
|
||||
throw new AdminException('该用户没有绑定手机号,请手动填写');
|
||||
} else {
|
||||
$data['phone'] = $userInfo['phone'];
|
||||
}
|
||||
} else {
|
||||
if (!check_phone($data['phone'])) {
|
||||
throw new AdminException('请输入正确的手机号');
|
||||
}
|
||||
}
|
||||
if ($data['nickname'] == '') $data['nickname'] = $userInfo['nickname'];
|
||||
$data['avatar'] = $data['image']['image'];
|
||||
if ($this->services->count(['uid' => $data['uid']])) {
|
||||
return app('json')->fail('客服已存在!');
|
||||
}
|
||||
unset($data['image']);
|
||||
$data['add_time'] = time();
|
||||
if (!$data['account']) {
|
||||
return app('json')->fail('请输入账号');
|
||||
}
|
||||
if (!preg_match('/^[a-zA-Z0-9]{4,30}$/', $data['account'])) {
|
||||
return app('json')->fail('账号必须为数字或者字母的组合4-30位');
|
||||
}
|
||||
if (!$data['password']) {
|
||||
return app('json')->fail('请输入密码');
|
||||
}
|
||||
if (!preg_match('/^[0-9a-z_$]{6,20}$/i', $data['password'])) {
|
||||
return app('json')->fail('密码必须为数字或者字母的组合6-20位');
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone']])) {
|
||||
return app('json')->fail('该手机号的客服已存在!');
|
||||
}
|
||||
if ($this->services->count(['account' => $data['account']])) {
|
||||
return app('json')->fail('该客服账号已存在!');
|
||||
}
|
||||
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||
$res = $this->services->save($data);
|
||||
if ($res) {
|
||||
return app('json')->success('客服添加成功');
|
||||
} else {
|
||||
return app('json')->fail('客服添加失败,请稍后再试');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return app('json')->success($this->services->edit((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['avatar', ''],
|
||||
['nickname', ''],
|
||||
['account', ''],
|
||||
['phone', ''],
|
||||
['status', 1],
|
||||
['notify', 1],
|
||||
['customer', 1],
|
||||
['password', ''],
|
||||
['true_password', ''],
|
||||
]);
|
||||
$customer = $this->services->get((int)$id);
|
||||
if (!$customer) {
|
||||
return app('json')->fail('数据不存在');
|
||||
}
|
||||
if ($data["nickname"] == '') {
|
||||
return app('json')->fail("客服名称不能为空!");
|
||||
}
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail('请输入正确的手机号');
|
||||
}
|
||||
if ($customer['phone'] != $data['phone'] && $this->services->count(['phone' => $data['phone']])) {
|
||||
return app('json')->fail('该手机号的客服已存在!');
|
||||
}
|
||||
if ($data['password']) {
|
||||
if (!preg_match('/^[0-9a-z_$]{6,16}$/i', $data['password'])) {
|
||||
return app('json')->fail('密码必须为数字或者字母的组合');
|
||||
}
|
||||
if (!$data['true_password']) {
|
||||
return app('json')->fail('请输入确认密码');
|
||||
}
|
||||
if ($data['password'] != $data['true_password']) {
|
||||
return app('json')->fail('两次输入的密码不正确');
|
||||
}
|
||||
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||
} else {
|
||||
unset($data['password']);
|
||||
}
|
||||
$this->services->update($id, $data);
|
||||
return app('json')->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail('删除失败,请稍候再试!');
|
||||
else
|
||||
return app('json')->success('删除成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_status(UserServices $services, $id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) return app('json')->fail('参数错误');
|
||||
$info = $this->services->get($id, ['status', 'uid']);
|
||||
if (!$services->count(['uid' => $info['uid']])) {
|
||||
$info->status = 1;
|
||||
$info->save();
|
||||
return app('json')->fail('用户不存在,客服将强制禁止登录');
|
||||
}
|
||||
$info->status = $status;
|
||||
$info->save();
|
||||
return app('json')->success($status == 0 ? '隐藏成功' : '显示成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天记录
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function chat_user($id)
|
||||
{
|
||||
$uid = $this->services->value(['id' => $id], 'uid');
|
||||
if (!$uid) {
|
||||
return app('json')->fail('数据不存在!');
|
||||
}
|
||||
return app('json')->success($this->services->getChatUser((int)$uid));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 聊天记录
|
||||
* @param StoreServiceLogServices $services
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function chat_list(StoreServiceLogServices $services)
|
||||
{
|
||||
$data = $this->request->getMore([
|
||||
['uid', 0],
|
||||
['to_uid', 0],
|
||||
['id', 0]
|
||||
]);
|
||||
if ($data['uid']) {
|
||||
CacheService::set('admin_chat_list' . $this->adminId, $data);
|
||||
}
|
||||
$data = CacheService::get('admin_chat_list' . $this->adminId);
|
||||
if ($data['uid']) {
|
||||
$where = [
|
||||
'chat' => [$data['uid'], $data['to_uid']],
|
||||
];
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
$list = $services->getChatLogList($where);
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服登录
|
||||
* @param LoginServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function keufLogin(LoginServices $services, $id)
|
||||
{
|
||||
$serviceInfo = $services->get($id);
|
||||
if (!$serviceInfo) {
|
||||
return app('json')->fail('登录的客服不存在');
|
||||
}
|
||||
if (!$serviceInfo->account || !$serviceInfo->password) {
|
||||
return app('json')->fail('请先填写客服账号和密码再尝试进入客服平台');
|
||||
}
|
||||
return app('json')->success($services->authLogin($serviceInfo->account));
|
||||
}
|
||||
|
||||
}
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -11,15 +11,11 @@
|
||||
namespace app\adminapi\controller\v1\application\wechat;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\jobs\notice\SyncMessageJob;
|
||||
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 +24,6 @@ use think\facade\Cache;
|
||||
*/
|
||||
class WechatTemplate extends AuthController
|
||||
{
|
||||
protected $cacheTag = '_system_wechat';
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* WechatTemplate constructor.
|
||||
@ -42,166 +36,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,51 +46,16 @@ 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)
|
||||
{
|
||||
//删除已有模版
|
||||
$all = $this->services->getTemplateList(['status' => 1, 'type' => 1]);
|
||||
$list = WechatService::getPrivateTemplates();
|
||||
foreach ($list->template_list as $v) {
|
||||
WechatService::deleleTemplate($v['template_id']);
|
||||
}
|
||||
|
||||
foreach ($tempall['list'] as $temp)
|
||||
{
|
||||
//添加模版消息
|
||||
$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]);
|
||||
}
|
||||
foreach ($all['list'] as $template) {
|
||||
SyncMessageJob::dispatchDo('SyncWechat', [$template]);
|
||||
}
|
||||
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(100038);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -625,10 +624,11 @@ class Diy extends AuthController
|
||||
['value', []],
|
||||
['video_link', '']
|
||||
]);
|
||||
if ($data['type'] == '') $data['type'] = 'pic';
|
||||
/** @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)
|
||||
{
|
||||
@ -107,42 +96,56 @@ class Express extends AuthController
|
||||
['account', ''],
|
||||
['key', ''],
|
||||
['net_name', ''],
|
||||
['courier_name', ''],
|
||||
['customer_name', ''],
|
||||
['code_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);
|
||||
}
|
||||
if ($expressInfo['check_man'] == 1 && !$data['courier_name']) {
|
||||
return app('json')->fail(500001);
|
||||
}
|
||||
if ($expressInfo['partner_name'] == 1 && !$data['customer_name']) {
|
||||
return app('json')->fail(500002);
|
||||
}
|
||||
if ($expressInfo['is_code'] == 1 && !$data['code_name']) {
|
||||
return app('json')->fail(500003);
|
||||
}
|
||||
$expressInfo->account = $data['account'];
|
||||
$expressInfo->key = $data['key'];
|
||||
$expressInfo->net_name = $data['net_name'];
|
||||
$expressInfo->courier_name = $data['courier_name'];
|
||||
$expressInfo->customer_name = $data['customer_name'];
|
||||
$expressInfo->code_name = $data['code_name'];
|
||||
$expressInfo->sort = $data['sort'];
|
||||
$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 +156,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 +168,6 @@ class Express extends AuthController
|
||||
public function syncExpress()
|
||||
{
|
||||
$this->services->syncExpress();
|
||||
return app('json')->success('同步成功');
|
||||
return app('json')->success(100038);
|
||||
}
|
||||
}
|
||||
|
||||
312
crmeb/app/adminapi/controller/v1/kefu/StoreService.php
Normal file
312
crmeb/app/adminapi/controller/v1/kefu/StoreService.php
Normal file
@ -0,0 +1,312 @@
|
||||
<?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\kefu;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\kefu\LoginServices;
|
||||
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;
|
||||
use crmeb\services\CacheService;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 客服管理
|
||||
* Class StoreService
|
||||
* @package app\admin\controller\store
|
||||
*/
|
||||
class StoreService extends AuthController
|
||||
{
|
||||
/**
|
||||
* StoreService constructor.
|
||||
* @param App $app
|
||||
* @param StoreServiceServices $services
|
||||
*/
|
||||
public function __construct(App $app, StoreServiceServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
* @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([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页
|
||||
* @param UserWechatuserServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
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,w.user_type,u.is_del');
|
||||
return app('json')->success(compact('list', 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加客服表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
return app('json')->success($this->services->create());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['image', ''],
|
||||
['uid', 0],
|
||||
['avatar', ''],
|
||||
['customer', ''],
|
||||
['notify', ''],
|
||||
['phone', ''],
|
||||
['account', ''],
|
||||
['password', ''],
|
||||
['true_password', ''],
|
||||
['phone', ''],
|
||||
['nickname', ''],
|
||||
['status', 1],
|
||||
]);
|
||||
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(400251);
|
||||
} else {
|
||||
$data['phone'] = $userInfo['phone'];
|
||||
}
|
||||
} else {
|
||||
if (!check_phone($data['phone'])) {
|
||||
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(400253);
|
||||
}
|
||||
unset($data['image']);
|
||||
$data['add_time'] = time();
|
||||
if (!$data['account']) {
|
||||
return app('json')->fail(400254);
|
||||
}
|
||||
if (!preg_match('/^[a-zA-Z0-9]{4,30}$/', $data['account'])) {
|
||||
return app('json')->fail(400255);
|
||||
}
|
||||
if (!$data['password']) {
|
||||
return app('json')->fail(400256);
|
||||
}
|
||||
if (!preg_match('/^[0-9a-z_$]{6,20}$/i', $data['password'])) {
|
||||
return app('json')->fail(400257);
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone']])) {
|
||||
return app('json')->fail(400258);
|
||||
}
|
||||
if ($this->services->count(['account' => $data['account']])) {
|
||||
return app('json')->fail(400259);
|
||||
}
|
||||
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||
$res = $this->services->save($data);
|
||||
if ($res) {
|
||||
return app('json')->success(400260);
|
||||
} else {
|
||||
return app('json')->fail(400261);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return app('json')->success($this->services->edit((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['avatar', ''],
|
||||
['nickname', ''],
|
||||
['account', ''],
|
||||
['phone', ''],
|
||||
['status', 1],
|
||||
['notify', 1],
|
||||
['customer', 1],
|
||||
['password', ''],
|
||||
['true_password', ''],
|
||||
]);
|
||||
$customer = $this->services->get((int)$id);
|
||||
if (!$customer) {
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
if ($data["nickname"] == '') {
|
||||
return app('json')->fail(400262);
|
||||
}
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail(400252);
|
||||
}
|
||||
if ($customer['phone'] != $data['phone'] && $this->services->count(['phone' => $data['phone']])) {
|
||||
return app('json')->fail(400258);
|
||||
}
|
||||
if ($data['password']) {
|
||||
if (!preg_match('/^[0-9a-z_$]{6,16}$/i', $data['password'])) {
|
||||
return app('json')->fail(400257);
|
||||
}
|
||||
if (!$data['true_password']) {
|
||||
return app('json')->fail(400263);
|
||||
}
|
||||
if ($data['password'] != $data['true_password']) {
|
||||
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(100001);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->services->delete($id))
|
||||
return app('json')->fail(100008);
|
||||
else
|
||||
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(100100);
|
||||
$info = $this->services->get($id, ['status', 'uid']);
|
||||
if (!$services->count(['uid' => $info['uid']])) {
|
||||
$info->status = 1;
|
||||
$info->save();
|
||||
return app('json')->fail(400265);
|
||||
}
|
||||
$info->status = $status;
|
||||
$info->save();
|
||||
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 chat_user($id)
|
||||
{
|
||||
$uid = $this->services->value(['id' => $id], 'uid');
|
||||
if (!$uid) {
|
||||
return app('json')->fail(100026);
|
||||
}
|
||||
return app('json')->success($this->services->getChatUser((int)$uid));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 聊天记录
|
||||
* @param StoreServiceLogServices $services
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function chat_list(StoreServiceLogServices $services)
|
||||
{
|
||||
$data = $this->request->getMore([
|
||||
['uid', 0],
|
||||
['to_uid', 0],
|
||||
['id', 0]
|
||||
]);
|
||||
if ($data['uid']) {
|
||||
CacheService::set('admin_chat_list' . $this->adminId, $data);
|
||||
}
|
||||
$data = CacheService::get('admin_chat_list' . $this->adminId);
|
||||
if ($data['uid']) {
|
||||
$where = [
|
||||
'chat' => [$data['uid'], $data['to_uid']],
|
||||
];
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
$list = $services->getChatLogList($where);
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服登录
|
||||
* @param LoginServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function keufLogin(LoginServices $services, $id)
|
||||
{
|
||||
$serviceInfo = $services->get($id);
|
||||
if (!$serviceInfo) {
|
||||
return app('json')->fail(400266);
|
||||
}
|
||||
if (!$serviceInfo->account || !$serviceInfo->password) {
|
||||
return app('json')->fail(400267);
|
||||
}
|
||||
return app('json')->success($services->authLogin($serviceInfo->account));
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,18 +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\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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,19 +2,19 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 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\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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,20 +2,20 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 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\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,15 +208,15 @@ 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'];
|
||||
|
||||
$data['delivery_name'] = $orderInfo['delivery_name'];
|
||||
$data['delivery_id'] = $orderInfo['delivery_id'];
|
||||
$data['result'] = $services->query($cacheName, $orderInfo['delivery_id'], $orderInfo['delivery_code'] ?? null);
|
||||
$data['result'] = $services->query($cacheName, $orderInfo['delivery_id'], $orderInfo['delivery_code'] ?? null, $orderInfo['user_phone']);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
@ -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,45 +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'] == '') {
|
||||
if (!$userInfo['phone']) {
|
||||
throw new AdminException('该用户没有绑定手机号,请手动填写');
|
||||
} else {
|
||||
$data['phone'] = $userInfo['phone'];
|
||||
}
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
@ -130,10 +86,9 @@ class DeliveryService extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
* 修改配送员
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
@ -143,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,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()
|
||||
{
|
||||
@ -40,6 +50,7 @@ class RefundOrder extends AuthController
|
||||
['refund_type', 0]
|
||||
]);
|
||||
$where['is_cancel'] = 0;
|
||||
$where['is_system_del'] = 0;
|
||||
return app('json')->success($this->services->refundList($where));
|
||||
}
|
||||
|
||||
@ -64,30 +75,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 +102,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 +123,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 +150,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 +178,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 +203,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,23 @@ 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');
|
||||
else
|
||||
return app('json')->fail('ERROR');
|
||||
if ($orderInfo->save()) {
|
||||
/** @var StoreOrderRefundServices $refundServices */
|
||||
$refundServices = app()->make(StoreOrderRefundServices::class);
|
||||
$refundServices->update(['store_order_id' => $id], ['is_system_del' => 1]);
|
||||
return app('json')->success(100002);
|
||||
} else
|
||||
return app('json')->fail(100008);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单发送货
|
||||
* @param $id 订单id
|
||||
* @param $id
|
||||
* @param StoreOrderDeliveryServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_delivery($id, StoreOrderDeliveryServices $services)
|
||||
@ -247,12 +254,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 +286,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 +309,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 +321,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 +335,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 +382,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 +402,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 +443,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 +458,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']) {
|
||||
@ -481,7 +489,7 @@ class StoreOrder extends AuthController
|
||||
$orderInfo['_store_name'] = $storeServices->value(['id' => $orderInfo['store_id']], 'name');
|
||||
} else
|
||||
$orderInfo['_store_name'] = '';
|
||||
$orderInfo['spread_name'] = $services->value(['uid'=>$orderInfo['spread_uid']],'nickname') ?? '无';
|
||||
$orderInfo['spread_name'] = $services->value(['uid' => $orderInfo['spread_uid']], 'nickname') ?? '无';
|
||||
$userInfo = $userInfo->toArray();
|
||||
return app('json')->success(compact('orderInfo', 'userInfo'));
|
||||
}
|
||||
@ -494,15 +502,15 @@ 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'];
|
||||
|
||||
$data['delivery_name'] = $orderInfo['delivery_name'];
|
||||
$data['delivery_id'] = $orderInfo['delivery_id'];
|
||||
$data['result'] = $services->query($cacheName, $orderInfo['delivery_id'], $orderInfo['delivery_code'] ?? null);
|
||||
$data['result'] = $services->query($cacheName, $orderInfo['delivery_id'], $orderInfo['delivery_code'] ?? null, $orderInfo['user_phone']);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
@ -516,7 +524,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 +536,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 +550,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 +563,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 +585,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 +595,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 +613,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 +626,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 +661,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 +682,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 +693,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 +711,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 +723,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']);
|
||||
}
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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'] = '';
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -109,6 +109,6 @@ class CopyTaobao extends AuthController
|
||||
['attrs', []]
|
||||
]);
|
||||
$this->services->save($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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,7 +292,8 @@ class StoreProduct extends AuthController
|
||||
['type', 1],
|
||||
['is_live', 0],
|
||||
['is_new', ''],
|
||||
['is_virtual', -1]
|
||||
['is_virtual', -1],
|
||||
['is_presale', -1]
|
||||
]);
|
||||
$where['is_show'] = 1;
|
||||
$where['is_del'] = 0;
|
||||
@ -341,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -354,19 +356,47 @@ class StoreProduct extends AuthController
|
||||
public function check_activity($id)
|
||||
{
|
||||
$this->service->checkActivity($id);
|
||||
return app('json')->success('删除成功');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入卡密
|
||||
* @return mixed
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
*/
|
||||
public function import_card()
|
||||
{
|
||||
$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);
|
||||
$cardData = $readExcelService->readExcel($file);
|
||||
return app('json')->success($cardData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品批量设置
|
||||
* @return mixed
|
||||
*/
|
||||
public function batchSetting()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['ids', []],
|
||||
['cate_id', []],
|
||||
['logistics', []],
|
||||
['freight', 2],
|
||||
['postage', 0],
|
||||
['temp_id', 1],
|
||||
['give_integral', 0],
|
||||
['coupon_ids', []],
|
||||
['label_id', []],
|
||||
['recommend', []],
|
||||
['type', 0]
|
||||
]);
|
||||
$this->service->batchSetting($data);
|
||||
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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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));
|
||||
}
|
||||
|
||||
105
crmeb/app/adminapi/controller/v1/setting/LangCode.php
Normal file
105
crmeb/app/adminapi/controller/v1/setting/LangCode.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?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\setting;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\system\lang\LangCodeServices;
|
||||
use think\facade\App;
|
||||
|
||||
class LangCode extends AuthController
|
||||
{
|
||||
/**
|
||||
* @param App $app
|
||||
* @param LangCodeServices $services
|
||||
*/
|
||||
public function __construct(App $app, LangCodeServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取语言列表
|
||||
* @return mixed
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function langCodeList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['is_admin', 0],
|
||||
['type_id', 0],
|
||||
['code', ''],
|
||||
['remarks', '']
|
||||
]);
|
||||
return app('json')->success($this->services->langCodeList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取语言详情
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function langCodeInfo()
|
||||
{
|
||||
[$code] = $this->request->getMore([
|
||||
['code', ''],
|
||||
], true);
|
||||
return app('json')->success($this->services->langCodeInfo($code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增编辑语言
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function langCodeSave()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['is_admin', 0],
|
||||
['code', ''],
|
||||
['remarks', ''],
|
||||
['edit', 0],
|
||||
['list', []]
|
||||
]);
|
||||
$this->services->langCodeSave($data);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除语言
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function langCodeDel($id)
|
||||
{
|
||||
$this->services->langCodeDel($id);
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
|
||||
/**
|
||||
* 机器翻译
|
||||
* @return mixed
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function langCodeTranslate()
|
||||
{
|
||||
[$text] = $this->request->postMore([
|
||||
['text', '']
|
||||
], true);
|
||||
if ($text == '') return app('json')->fail(100100);
|
||||
return app('json')->success($this->services->langCodeTranslate($text));
|
||||
}
|
||||
}
|
||||
79
crmeb/app/adminapi/controller/v1/setting/LangCountry.php
Normal file
79
crmeb/app/adminapi/controller/v1/setting/LangCountry.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?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\setting;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\system\lang\LangCountryServices;
|
||||
use think\facade\App;
|
||||
|
||||
class LangCountry extends AuthController
|
||||
{
|
||||
/**
|
||||
* @param App $app
|
||||
* @param LangCountryServices $services
|
||||
*/
|
||||
public function __construct(App $app, LangCountryServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 国家语言列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function langCountryList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['keyword', ''],
|
||||
]);
|
||||
return app('json')->success($this->services->langCountryList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置国家语言类型表单
|
||||
* @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 langCountryForm($id)
|
||||
{
|
||||
return app('json')->success($this->services->langCountryForm($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 地区语言修改
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function langCountrySave($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['code', ''],
|
||||
['type_id', 0],
|
||||
]);
|
||||
$this->services->langCountrySave($id, $data);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
public function langCountryDel($id)
|
||||
{
|
||||
$this->services->langCountryDel($id);
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
95
crmeb/app/adminapi/controller/v1/setting/LangType.php
Normal file
95
crmeb/app/adminapi/controller/v1/setting/LangType.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?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\setting;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\services\system\lang\LangTypeServices;
|
||||
use crmeb\services\CacheService;
|
||||
use think\facade\App;
|
||||
|
||||
class LangType extends AuthController
|
||||
{
|
||||
/**
|
||||
* @param App $app
|
||||
* @param LangTypeServices $services
|
||||
*/
|
||||
public function __construct(App $app, LangTypeServices $services)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取语言类型列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function langTypeList()
|
||||
{
|
||||
$where['is_del'] = 0;
|
||||
return app('json')->success($this->services->langTypeList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加语言类型表单
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function langTypeForm(int $id = 0)
|
||||
{
|
||||
return app('json')->success($this->services->langTypeForm($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存语言类型
|
||||
* @return mixed
|
||||
*/
|
||||
public function langTypeSave()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['id', 0],
|
||||
['language_name', ''],
|
||||
['file_name', ''],
|
||||
['is_default', 0],
|
||||
['status', 0]
|
||||
]);
|
||||
$this->services->langTypeSave($data);
|
||||
CacheService::redisHandler()->delete('lang_type_data');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改语言类型状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function langTypeStatus($id, $status)
|
||||
{
|
||||
$this->services->langTypeStatus($id, $status);
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除语言类型
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function langTypeDel(int $id = 0)
|
||||
{
|
||||
$this->services->langTypeDel($id);
|
||||
CacheService::redisHandler()->delete('lang_type_data');
|
||||
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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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,30 @@ 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);
|
||||
}
|
||||
/**
|
||||
* 修改当前登陆admin的文件管理密码
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_file_password()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['file_pwd', ''],
|
||||
['conf_file_pwd', ''],
|
||||
]);
|
||||
if(!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/',$data['file_pwd'])){
|
||||
return app('json')->fail(400183);
|
||||
}
|
||||
if ($this->services->setFilePassword($this->adminId, $data))
|
||||
return app('json')->success(100001);
|
||||
else
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -27,7 +27,7 @@ class SystemCity extends AuthController
|
||||
* 构造方法
|
||||
* SystemCity constructor.
|
||||
* @param App $app
|
||||
* @param SystemStoreServices $services
|
||||
* @param SystemCityServices $services
|
||||
*/
|
||||
public function __construct(App $app, SystemCityServices $services)
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,12 +133,11 @@ class SystemCity extends AuthController
|
||||
*/
|
||||
public function clean_cache()
|
||||
{
|
||||
$res = CacheService::delete('tree_city_list');
|
||||
$res = $res && CacheService::delete('CITY_LIST');
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,6 +12,7 @@ namespace app\adminapi\controller\v1\setting;
|
||||
|
||||
use app\adminapi\controller\AuthController;
|
||||
use app\Request;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\system\config\SystemConfigServices;
|
||||
use app\services\system\config\SystemConfigTabServices;
|
||||
use think\facade\App;
|
||||
@ -47,7 +48,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 +93,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 +121,7 @@ class SystemConfig extends AuthController
|
||||
$this->services->save($data);
|
||||
}
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('添加配置成功!');
|
||||
return app('json')->success(400284);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,7 +133,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 +182,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 +199,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 +215,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 +229,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 +257,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,17 +285,38 @@ 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['pay_wechat_type'])) {
|
||||
// /** @var StoreOrderServices $orderServices */
|
||||
// $orderServices = app()->make(StoreOrderServices::class);
|
||||
// if ($post['pay_wechat_type'] != -1 && $orderServices->count()) {
|
||||
// return app('json')->fail('支付接口类型已经选择,不能再次进行切换,切换后会导致无法退款等问题。');
|
||||
// }
|
||||
// }
|
||||
|
||||
if (isset($post['weixin_ckeck_file'])) {
|
||||
$from = public_path() . $post['weixin_ckeck_file'];
|
||||
$to = public_path() . array_reverse(explode('/', $post['weixin_ckeck_file']))[0];
|
||||
@ -306,6 +331,9 @@ class SystemConfig extends AuthController
|
||||
@copy($from, $toHome);
|
||||
@copy($from, $toPublic);
|
||||
}
|
||||
if(isset($post['reward_integral']) || isset($post['reward_money'])) {
|
||||
if($post['reward_integral'] < 0 || $post['reward_money'] < 0) return app('json')->fail(400558);
|
||||
}
|
||||
foreach ($post as $k => $v) {
|
||||
$config_one = $this->services->getOne(['menu_name' => $k]);
|
||||
if ($config_one) {
|
||||
@ -315,7 +343,7 @@ class SystemConfig extends AuthController
|
||||
}
|
||||
}
|
||||
\crmeb\services\CacheService::clear();
|
||||
return app('json')->success('修改成功');
|
||||
return app('json')->success(100001);
|
||||
|
||||
}
|
||||
|
||||
@ -366,4 +394,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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
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