Commit 52604edb authored by liaofei's avatar liaofei
Browse files

更新3.2版本

No related merge requests found
Showing with 869 additions and 547 deletions
+869 -547
<?php
define('INSTALL_DATE',1576029123);
define('SERIALNUMBER','Xwdc05');
\ No newline at end of file
define('INSTALL_DATE',1578360044);
define('SERIALNUMBER','N2L6Px');
\ No newline at end of file
APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = localhost HOSTPORT = 3306 USERNAME = gitee_crmeb_net PASSWORD = 'F2X5aBXaZb8aMxXw' DATABASE = gitee_crmeb_net PREFIX = eb_ CHARSET = utf8 DEBUG = true [LANG] default_lang = zh-cn
\ No newline at end of file
APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = crmeb_v3_2 USERNAME = root PASSWORD = 123456 HOSTPORT = 3306 CHARSET = utf8 DEBUG = true [LANG] default_lang = zh-cn [FILESYSTEM] FILESIZE = 2097152
\ No newline at end of file
......
APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 192.168.0.108 DATABASE = www_crmeb32_net USERNAME = www_crmeb32_net PASSWORD = BEknpBWesr HOSTPORT = 3306 CHARSET = utf8 DEBUG = true [LANG] default_lang = zh-cn
\ No newline at end of file
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
\ No newline at end of file
......
/.idea
/.vscode
*.log
/.env
**/*.pid
runtime/
install.lock
public/uploads
public/nginx.htaccess
public/index.html
public/live-logo.gif
version=CRMEB-KYDT v3.1.3
version=CRMEB-DT v3.2.7
version_code=134
\ No newline at end of file
版权所有 (c)2017-2027,西安众邦网络科技有限公司 保留所有权利。
感谢您选择CrmEb开源客户管理+电商系统(简称CRMEB),CRMEB是国内最稳定、最强大、最先进的互联网电商平台解决方案之一,CRMEB基于 PHP + MySQL 的技术,采用ThinkPHP5.0框架开发。
为了使你正确并合法的使用本软件,请你在使用前务必阅读清楚下面的协议条款:
本授权协议适用且仅适用于CRMEB任何版本,CRMEB官方对本授权协议的最终解释权和修改权。
一、协议许可的权利
1、您可以在完全遵守本最终用户授权协议的基础上,将本软件应用于非商业用途,而不必支付软件版权授权费用。
2、您可以在协议规定的约束和限制范围内修改 CRMEB 源代码或界面风格以适应您的网站要求。
3、您拥有使用本软件构建的网站全部内容所有权,并独立承担与这些内容的相关法律义务。
4、获得商业授权之后,您可以将本软件应用于商业用途,同时依据所购买的授权类型中确定的技术支持内容。商业授权用户享有反映和提出意见的权力,相关意见将被作为首要考虑,但没有一定被采纳的承诺或保证。
二、协议许可的权利和限制
1、未获商业授权之前,不得删除网站底部及相应的官方版权信息和链接。购买商业授权请联系西安众邦网络科技有限公司了解最新说明。CRMEB著作权已在中华人民共和国国家版权局注册(中国国家版权局著作权登记号 2018SR024463),著作权受到法律和国际公约保护。
2、未经官方许可,不得对本软件或与之关联的商业授权进行出租、出售、抵押或发放子许可证。
3、不管你的网站是否整体使用 CRMEB ,还是部份栏目使用 CRMEB,在你使用了 CRMEB 的网站主页上必须加上 CRMEB 官方网址(www.crmeb.com)的链接。
4、未经官方许可,禁止在 CRMEB 的整体或任何部分基础上以发展任何派生版本、修改版本或第三方版本用于重新分发。
5、如果您未能遵守本协议的条款,您的授权将被终止,所被许可的权利将被收回,并承担相应法律责任。
三、有限担保和免责声明
1、本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。
2、用户出于自愿而使用本软件,您必须了解使用本软件的风险,在尚未购买产品技术服务之前,我们不承诺对免费用户提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任。
3、电子文本形式的授权协议如同双方书面签署的协议一样,具有完全的和等同的法律效力。您一旦开始确认本协议并安装 CRMEB,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权力的同时,受到相关的约束和限制。协议许可范围以外的行为,将直接违反本授权协议并构成侵权,我们有权随时终止授权,责令停止损害,并保留追究相关责任的权力。
协议发布时间: 2017年8月01日
版本最新更新: 2019年8月15日 By CRMEB
CRMEB官方网站:http://www.crmeb.com
CRMEB演示站:http://demo.crmeb.com
-----------------------------------------------------
运营团队: 众邦科技
电 话: 400-8888-794
邮 箱: admin@xazbkj.com
网 址: http://www.xazbkj.com
\ No newline at end of file
CRMEB 3.0
===============
> 运行环境要求PHP7.1+。
## 主要特性
### 开源无加密
源码开源无加密,有详细的代码注释,有完整系统手册
### TP6框架
使用最新的 ThinkPHP 6.0框架开发
### 前端采用Vue CLI框架
前端使用Vue CLI框架nodejs打包,页面加载更流畅,用户体验更好
### 标准接口
标准接口、前后端分离,二次开发更方便
### 支持队列
降低流量高峰,解除耦合,高可用
### 长连接
减少CPU及内存使用及网络堵塞,减少请求响应时长
### 无缝事件机制
行为扩展更方便,方便二次开发
### 后台快速生成表单
后台应用form-builder 无需写页面快速增删改查
### 数据表格导出
PHPExcel数据导出,导出表格更加美观可视;
### 数据统计分析
后台使用ECharts图表统计,实现用户、产品、订单、资金等统计分析
### 强大的后台权限管理
后台多种角色、多重身份权限管理,权限可以控制到每一步操作
### 一件安装
自动检查系统环境一键安装
## 安装
## 一键安装
上传你的代码,站点入口目录设置/public
在浏览器中输入你的域名或IP(例如:www.yourdomain.com),
安装程序会自动执行安装。期间系统会提醒你输入数据库信息以完成安装,安装完成后建议删除install目录下index.php文件或将其改名。
后台访问地址:
1.域名/admin
2.域名/index.php/admin
3.域名/index.php?s=/admin
公众号和H5首页访问地址:
1.域名/
提示:正常访问是第一中模式,第一种访问不了请检测[URL重写](http://help.crmeb.net/895486)是否配置好
安装过程中请牢记您的账号密码!
## 重新安装
1. 清除数据库
2. 删除/public/install/install.lock 文件
## 手动安装
1.创建数据库,倒入数据库文件
数据库文件目录/public/install/crmeb.sql
2.修改数据库连接文件
配置文件路径/.env
~~~
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
~~~
3.修改目录权限(linux系统)777
/public
/runtime
4.后台登录:
http://域名/admin
默认账号:admin 密码:crmeb.com
## 定时任务
在自动收货,库存预警等功能使用到
```sh
php think timer [ status ] [ --d ]
```
参数
- status: 状态
- start: 启动
- stop: 关闭
- restart: 重启
- --d : 后台执行
## 长连接服务
在h5聊天,后台管理员消息通知等功能使用到
```sh
php think workerman [ status ] [ server ] [ --d ]
```
windows环境下需要分三步执行
```sh
# 内部通讯服务
php think workerman start channel
# h5端聊天服务
php think workerman start chat
# 后台管理员通知
php think workerman start admin
```
参数
- status: 状态
- start: 启动
- stop: 关闭
- restart: 重启
- server: 服务 (windows)
- channel: 内部通讯
- chat: h5
- admin: 后台
- --d : 后台执行
## 文档
[使用手册](https://help.crmeb.net)
[TP6开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content)
## 参与开发
请参阅 [CRMEB](https://github.com/crmeb/CRMEB)
## 版权信息
本项目包含的第三方源码和二进制文件之版权信息另行标注。
版权所有Copyright © 2017-2019 by CRMEB (http://www.crmeb.com)
All rights reserved。
CRMEB® 商标和著作权所有者为西安众邦网络科技有限公司。
......@@ -10,110 +10,137 @@
// +----------------------------------------------------------------------
// 应用公共文件
/**
* 格式化属性
* @param $arr
* @return array
*/
function attrFormat($arr){
$data = [];
$res = [];
if(count($arr) > 1){
for ($i=0; $i < count($arr)-1; $i++) {
if($i == 0) $data = $arr[$i]['detail'];
//替代变量1
$rep1 = [];
foreach ($data as $v) {
foreach ($arr[$i+1]['detail'] as $g) {
//替代变量2
$rep2 = ($i!=0?'':$arr[$i]['value']."_").$v."-".$arr[$i+1]['value']."_".$g;
$tmp[] = $rep2;
if($i==count($arr)-2){
foreach (explode('-', $rep2) as $k => $h) {
//替代变量3
$rep3 = explode('_', $h);
//替代变量4
$rep4['detail'][$rep3[0]] = isset($rep3[1]) ? $rep3[1] : '';
if (!function_exists('attr_format')) {
/**
* 格式化属性
* @param $arr
* @return array
*/
function attr_format($arr)
{
$data = [];
$res = [];
$count = count($arr);
if ($count > 1) {
for ($i = 0; $i < $count - 1; $i++) {
if ($i == 0) $data = $arr[$i]['detail'];
//替代变量1
$rep1 = [];
foreach ($data as $v) {
foreach ($arr[$i + 1]['detail'] as $g) {
//替代变量2
$rep2 = ($i != 0 ? '' : $arr[$i]['value'] . '_$_') . $v . '-$-' . $arr[$i + 1]['value'] . '_$_' . $g;
$tmp[] = $rep2;
if ($i == $count - 2) {
foreach (explode('-$-', $rep2) as $k => $h) {
//替代变量3
$rep3 = explode('_$_', $h);
//替代变量4
$rep4['detail'][$rep3[0]] = isset($rep3[1]) ? $rep3[1] : '';
}
if($count == count($rep4['detail']))
$res[] = $rep4;
}
$res[] = $rep4;
}
}
$data = isset($tmp) ? $tmp : [];
}
$data = isset($tmp) ? $tmp : [];
}
}else{
$dataArr = [];
foreach ($arr as $k=>$v){
foreach ($v['detail'] as $kk=>$vv){
$dataArr[$kk] = $v['value'].'_'.$vv;
$res[$kk]['detail'][$v['value']] = $vv;
} else {
$dataArr = [];
foreach ($arr as $k => $v) {
foreach ($v['detail'] as $kk => $vv) {
$dataArr[$kk] = $v['value'] . '_' . $vv;
$res[$kk]['detail'][$v['value']] = $vv;
}
}
$data[] = implode('-', $dataArr);
}
$data[] = implode('-',$dataArr);
return [$data, $res];
}
return [$data,$res];
}
/**
* 格式化月份
* @param string $time
* @param int $ceil
* @return array
*/
function getMonth($time='',$ceil=0){
if(empty($time)){
$firstday = date("Y-m-01",time());
$lastday = date("Y-m-d",strtotime("$firstday +1 month -1 day"));
}else if($time=='n'){
if($ceil!=0)
$season = ceil(date('n') /3)-$ceil;
else
$season = ceil(date('n') /3);
$firstday=date('Y-m-01',mktime(0,0,0,($season - 1) *3 +1,1,date('Y')));
$lastday=date('Y-m-t',mktime(0,0,0,$season * 3,1,date('Y')));
}else if($time=='y'){
$firstday=date('Y-01-01');
$lastday=date('Y-12-31');
}else if($time=='h'){
$firstday = date('Y-m-d', strtotime('this week +'.$ceil.' day')) . ' 00:00:00';
$lastday = date('Y-m-d', strtotime('this week +'.($ceil+1).' day')) . ' 23:59:59';
if (!function_exists('get_month')) {
/**
* 格式化月份
* @param string $time
* @param int $ceil
* @return array
*/
function get_month($time = '', $ceil = 0)
{
if (empty($time)) {
$firstday = date("Y-m-01", time());
$lastday = date("Y-m-d", strtotime("$firstday +1 month -1 day"));
} else if ($time == 'n') {
if ($ceil != 0)
$season = ceil(date('n') / 3) - $ceil;
else
$season = ceil(date('n') / 3);
$firstday = date('Y-m-01', mktime(0, 0, 0, ($season - 1) * 3 + 1, 1, date('Y')));
$lastday = date('Y-m-t', mktime(0, 0, 0, $season * 3, 1, date('Y')));
} else if ($time == 'y') {
$firstday = date('Y-01-01');
$lastday = date('Y-12-31');
} else if ($time == 'h') {
$firstday = date('Y-m-d', strtotime('this week +' . $ceil . ' day')) . ' 00:00:00';
$lastday = date('Y-m-d', strtotime('this week +' . ($ceil + 1) . ' day')) . ' 23:59:59';
}
return array($firstday, $lastday);
}
return array($firstday,$lastday);
}
/**删除目录下所有文件
* @param $path 目录或者文件路径
* @param string $ext
* @return bool
*/
function clearfile($path,$ext = '*.log')
{
$files = (array) glob($path.DS.'*');
foreach ($files as $path) {
if (is_dir($path)) {
$matches = glob($path . '/'.$ext);
if (is_array($matches)) {
array_map('unlink', $matches);
if (!function_exists('clearfile')) {
/**删除目录下所有文件
* @param $path 目录或者文件路径
* @param string $ext
* @return bool
*/
function clearfile($path, $ext = '*.log')
{
$files = (array)glob($path . DS . '*');
foreach ($files as $path) {
if (is_dir($path)) {
$matches = glob($path . '/' . $ext);
if (is_array($matches)) {
array_map('unlink', $matches);
}
rmdir($path);
} else {
unlink($path);
}
rmdir($path);
}
return true;
}
}
if (!function_exists('get_this_class_methods')) {
/**获取当前类方法
* @param $class
* @return array
*/
function get_this_class_methods($class, $unarray = [])
{
$arrayall = get_class_methods($class);
if ($parent_class = get_parent_class($class)) {
$arrayparent = get_class_methods($parent_class);
$arraynow = array_diff($arrayall, $arrayparent);//去除父级的
} else {
unlink($path);
$arraynow = $arrayall;
}
return array_diff($arraynow, $unarray);//去除无用的
}
return true;
}
/**获取当前类方法
* @param $class
* @return array
*/
function get_this_class_methods($class,$unarray = []) {
$arrayall = get_class_methods($class);
if ($parent_class = get_parent_class($class)) {
$arrayparent = get_class_methods($parent_class);
$arraynow = array_diff($arrayall, $arrayparent);//去除父级的
} else {
$arraynow = $arrayall;
if (!function_exists('verify_domain')) {
/**
* 验证域名是否合法
* @param string $domain
* @return bool
*/
function verify_domain(string $domain): bool
{
$res = "/^(?=^.{3,255}$)(http(s)?:\/\/)(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*$/";
if (preg_match($res, $domain))
return true;
else
return false;
}
return array_diff($arraynow, $unarray);//去除无用的
}
......@@ -28,7 +28,7 @@ class AdminException extends Handle
return app('json')->make(422, $e->getError());
}
if ($e instanceof \Exception && request()->isAjax()) {
return app('json')->fail(['code' => $e->getCode(), 'message' => $e->getMessage(), 'file' => $e->getFile()]);
return app('json')->fail($e->getMessage(), ['code' => $e->getCode(), 'line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]);
}
return parent::render($request, $e);
......
......@@ -32,40 +32,40 @@ class AuthController extends SystemBasic
*/
protected $auth = [];
protected $skipLogController = ['index','common'];
protected $skipLogController = ['index', 'common'];
protected function initialize()
{
parent::initialize();
if(!SystemAdmin::hasActiveAdmin()) return $this->redirect(Url::buildUrl('login/index')->suffix(false)->build());
try{
if (!SystemAdmin::hasActiveAdmin()) return $this->redirect(Url::buildUrl('login/index')->suffix(false)->build());
try {
$adminInfo = SystemAdmin::activeAdminInfoOrFail();
}catch (\Exception $e){
return $this->failed(SystemAdmin::getErrorInfo($e->getMessage()),Url::buildUrl('login/index')->suffix(false)->build());
} catch (\Exception $e) {
return $this->failed(SystemAdmin::getErrorInfo($e->getMessage()), Url::buildUrl('login/index')->suffix(false)->build());
}
$this->adminInfo = $adminInfo;
$this->adminId = $adminInfo['id'];
$this->getActiveAdminInfo();
$this->auth = SystemAdmin::activeAdminAuthOrFail();
$this->adminInfo->level === 0 || $this->checkAuth();
$this->assign('_admin',$this->adminInfo);
$this->assign('_admin', $this->adminInfo);
$type = 'system';
event('AdminVisit',[$this->adminInfo,$type]);
event('AdminVisit', [$this->adminInfo, $type]);
}
protected function checkAuth($action = null,$controller = null,$module = null,array $route = [])
protected function checkAuth($action = null, $controller = null, $module = null, array $route = [])
{
static $allAuth = null;
if($allAuth === null) $allAuth = SystemRole::getAllAuth();
if($module === null) $module = app('http')->getName();
if($controller === null) $controller = $this->request->controller();
if($action === null) $action = $this->request->action();
if(!count($route)) $route = $this->request->route();
if(in_array(strtolower($controller),$this->skipLogController,true)) return true;
$nowAuthName = SystemMenus::getAuthName($action,$controller,$module,$route);
$baseNowAuthName = SystemMenus::getAuthName($action,$controller,$module,[]);
if((in_array($nowAuthName,$allAuth) && !in_array($nowAuthName,$this->auth)) || (in_array($baseNowAuthName,$allAuth) && !in_array($baseNowAuthName,$this->auth)))
if ($allAuth === null) $allAuth = SystemRole::getAllAuth();
if ($module === null) $module = app('http')->getName();
if ($controller === null) $controller = $this->request->controller();
if ($action === null) $action = $this->request->action();
if (!count($route)) $route = $this->request->route();
if (in_array(strtolower($controller), $this->skipLogController, true)) return true;
$nowAuthName = SystemMenus::getAuthName($action, $controller, $module, $route);
$baseNowAuthName = SystemMenus::getAuthName($action, $controller, $module, []);
if ((in_array($nowAuthName, $allAuth) && !in_array($nowAuthName, $this->auth)) || (in_array($baseNowAuthName, $allAuth) && !in_array($baseNowAuthName, $this->auth)))
exit($this->failed('没有权限访问!'));
return true;
}
......@@ -79,7 +79,7 @@ class AuthController extends SystemBasic
{
$adminId = $this->adminId;
$adminInfo = SystemAdmin::getValidAdminInfoOrFail($adminId);
if(!$adminInfo) $this->failed(SystemAdmin::getErrorInfo('请登陆!'));
if (!$adminInfo) $this->failed(SystemAdmin::getErrorInfo('请登陆!'));
$this->adminInfo = $adminInfo;
SystemAdmin::setLoginInfo($adminInfo);
return $adminInfo;
......
......@@ -2,18 +2,12 @@
namespace app\admin\controller;
use app\admin\model\store\StoreProduct;
use app\admin\model\system\SystemConfig;
use app\admin\model\system\SystemMenus;
use app\admin\model\system\SystemRole;
use app\admin\model\order\StoreOrder as StoreOrderModel;//订单
use app\admin\model\user\User;
use app\admin\model\user\UserExtract as UserExtractModel;//分销
use app\admin\model\user\User as UserModel;//用户
use app\admin\model\store\StoreProductReply as StoreProductReplyModel;//评论
use app\admin\model\store\StoreProduct as ProductModel;//产品
use FormBuilder\Json;
use think\facade\Config;
use app\admin\model\order\StoreOrder as StoreOrderModel;//订单
use app\admin\model\system\{SystemConfig, SystemMenus, SystemRole};
use app\admin\model\user\{User, UserExtract as UserExtractModel, User as UserModel};
use app\admin\model\store\{StoreProduct, StoreProductReply as StoreProductReplyModel, StoreProduct as ProductModel};
/**
* 首页控制器
......@@ -29,6 +23,7 @@ class Index extends AuthController
$adminInfo = $this->adminInfo->toArray();
$roles = explode(',', $adminInfo['roles']);
$site_logo = SystemConfig::getOneConfig('menu_name', 'site_logo')->toArray();
$this->assign([
'menuList' => SystemMenus::menuList(),
'site_logo' => json_decode($site_logo['value'], true),
......@@ -52,13 +47,15 @@ class Index extends AuthController
$topData['orderDeliveryNum'] = StoreOrderModel::where('status', 0)
->where('paid', 1)
->where('refund_status', 0)
->where('shipping_type', 1)
->where('is_del', 0)
->count();
//退换货订单数
$topData['orderRefundNum'] = StoreOrderModel::where('paid', 1)
->where('refund_status', 'IN', '1')
->count();
//库存预警
$replenishment_num = SystemConfig::getConfigValue('store_stock') > 0 ? SystemConfig::getConfigValue('store_stock') : 20;//库存预警界限
$replenishment_num = sys_config('store_stock') > 0 ? sys_config('store_stock') : 20;//库存预警界限
$topData['stockProduct'] = StoreProduct::where('stock', '<=', $replenishment_num)->where('is_show', 1)->where('is_del', 0)->count();
//待处理提现
$topData['treatedExtract'] = UserExtractModel::where('status', 0)->count();
......@@ -148,17 +145,19 @@ class Index extends AuthController
header('Content-type:text/json');
$cycle = $this->request->param('cycle') ?: 'thirtyday';//默认30天
$datalist = [];
$where = ['is_del' => 0, 'paid' => 1, 'refund_status' => 0];
switch ($cycle) {
case 'thirtyday':
$datebefor = date('Y-m-d', strtotime('-30 day'));
$dateafter = date('Y-m-d');
$datebefor = date('Y-m-d 00:00:00', strtotime('-30 day'));
$dateafter = date('Y-m-d 23:59:59');
//上期
$pre_datebefor = date('Y-m-d', strtotime('-60 day'));
$pre_dateafter = date('Y-m-d', strtotime('-30 day'));
for ($i = -30; $i < 0; $i++) {
for ($i = -30; $i < 1; $i++) {
$datalist[date('m-d', strtotime($i . ' day'))] = date('m-d', strtotime($i . ' day'));
}
$order_list = StoreOrderModel::where('add_time', 'between time', [$datebefor, $dateafter])
->where($where)
->field("FROM_UNIXTIME(add_time,'%m-%d') as day,count(*) as count,sum(pay_price) as price")
->group("FROM_UNIXTIME(add_time, '%Y%m%d')")
->order('add_time asc')
......@@ -196,6 +195,7 @@ class Index extends AuthController
$chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series, 'data' => $data['count']];//分类2值
//统计总数上期
$pre_total = StoreOrderModel::where('add_time', 'between time', [$pre_datebefor, $pre_dateafter])
->where($where)
->field("count(*) as count,sum(pay_price) as price")
->find();
if ($pre_total) {
......@@ -208,21 +208,22 @@ class Index extends AuthController
}
//统计总数
$total = StoreOrderModel::where('add_time', 'between time', [$datebefor, $dateafter])
->where($where)
->field("count(*) as count,sum(pay_price) as price")
->find();
if ($total) {
$cha_count = intval($pre_total['count']) - intval($total['count']);
$pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
//$pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
$chartdata['cycle']['count'] = [
'data' => $total['count'] ?: 0,
'percent' => round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
'percent' => intval($pre_total['count']) == 0 ? 100 : round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
'is_plus' => $cha_count > 0 ? -1 : ($cha_count == 0 ? 0 : 1)
];
$cha_price = round($pre_total['price'], 2) - round($total['price'], 2);
$pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
//$pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
$chartdata['cycle']['price'] = [
'data' => $total['price'] ?: 0,
'percent' => round(abs($cha_price) / $pre_total['price'] * 100, 2),
'percent' => (intval($pre_total['price']) == 0 || !$pre_total['price'] || $pre_total['price'] == 0.00) ? 100 : round(abs($cha_price) / $pre_total['price'] * 100, 2),
'is_plus' => $cha_price > 0 ? -1 : ($cha_price == 0 ? 0 : 1)
];
}
......@@ -230,9 +231,10 @@ class Index extends AuthController
break;
case 'week':
$weekarray = array(['周日'], ['周一'], ['周二'], ['周三'], ['周四'], ['周五'], ['周六']);
$datebefor = date('Y-m-d', strtotime('-1 week Monday'));
$dateafter = date('Y-m-d', strtotime('-1 week Sunday'));
$datebefor = date('Y-m-d 00:00:00)', strtotime('-1 week Monday'));
$dateafter = date('Y-m-d 23:59:59', strtotime('-1 week Sunday'));
$order_list = StoreOrderModel::where('add_time', 'between time', [$datebefor, $dateafter])
->where($where)
->field("FROM_UNIXTIME(add_time,'%w') as day,count(*) as count,sum(pay_price) as price")
->group("FROM_UNIXTIME(add_time, '%Y%m%e')")
->order('add_time asc')
......@@ -242,9 +244,10 @@ class Index extends AuthController
foreach ($order_list as $k => $v) {
$new_order_list[$v['day']] = $v;
}
$now_datebefor = date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600));
$now_dateafter = date('Y-m-d', strtotime("+1 day"));
$now_datebefor = date('Y-m-d 00:00:00', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600));
$now_dateafter = date('Y-m-d 23:59:59', strtotime("+1 day"));
$now_order_list = StoreOrderModel::where('add_time', 'between time', [$now_datebefor, $now_dateafter])
->where($where)
->field("FROM_UNIXTIME(add_time,'%w') as day,count(*) as count,sum(pay_price) as price")
->group("FROM_UNIXTIME(add_time, '%Y%m%e')")
->order('add_time asc')
......@@ -294,6 +297,7 @@ class Index extends AuthController
//统计总数上期
$pre_total = StoreOrderModel::where('add_time', 'between time', [$datebefor, $dateafter])
->where($where)
->field("count(*) as count,sum(pay_price) as price")
->find();
if ($pre_total) {
......@@ -306,21 +310,22 @@ class Index extends AuthController
}
//统计总数
$total = StoreOrderModel::where('add_time', 'between time', [$now_datebefor, $now_dateafter])
->where($where)
->field("count(*) as count,sum(pay_price) as price")
->find();
if ($total) {
$cha_count = intval($pre_total['count']) - intval($total['count']);
$pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
//$pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
$chartdata['cycle']['count'] = [
'data' => $total['count'] ?: 0,
'percent' => round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
'percent' => intval($pre_total['count']) == 0 ? 100 : round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
'is_plus' => $cha_count > 0 ? -1 : ($cha_count == 0 ? 0 : 1)
];
$cha_price = round($pre_total['price'], 2) - round($total['price'], 2);
$pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
//$pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
$chartdata['cycle']['price'] = [
'data' => $total['price'] ?: 0,
'percent' => round(abs($cha_price) / $pre_total['price'] * 100, 2),
'percent' => (intval($pre_total['price']) == 0 || !$pre_total['price'] || $pre_total['price'] == 0.00) ? 100 : round(abs($cha_price) / $pre_total['price'] * 100, 2),
'is_plus' => $cha_price > 0 ? -1 : ($cha_price == 0 ? 0 : 1)
];
}
......@@ -329,9 +334,10 @@ class Index extends AuthController
case 'month':
$weekarray = array('01' => ['1'], '02' => ['2'], '03' => ['3'], '04' => ['4'], '05' => ['5'], '06' => ['6'], '07' => ['7'], '08' => ['8'], '09' => ['9'], '10' => ['10'], '11' => ['11'], '12' => ['12'], '13' => ['13'], '14' => ['14'], '15' => ['15'], '16' => ['16'], '17' => ['17'], '18' => ['18'], '19' => ['19'], '20' => ['20'], '21' => ['21'], '22' => ['22'], '23' => ['23'], '24' => ['24'], '25' => ['25'], '26' => ['26'], '27' => ['27'], '28' => ['28'], '29' => ['29'], '30' => ['30'], '31' => ['31']);
$datebefor = date('Y-m-01', strtotime('-1 month'));
$dateafter = date('Y-m-d', strtotime(date('Y-m-01')));
$datebefor = date('Y-m-01 00:00:00', strtotime('-1 month'));
$dateafter = date('Y-m-d 23:59:59', strtotime(date('Y-m-01')));
$order_list = StoreOrderModel::where('add_time', 'between time', [$datebefor, $dateafter])
->where($where)
->field("FROM_UNIXTIME(add_time,'%d') as day,count(*) as count,sum(pay_price) as price")
->group("FROM_UNIXTIME(add_time, '%Y%m%e')")
->order('add_time asc')
......@@ -341,9 +347,10 @@ class Index extends AuthController
foreach ($order_list as $k => $v) {
$new_order_list[$v['day']] = $v;
}
$now_datebefor = date('Y-m-01');
$now_dateafter = date('Y-m-d', strtotime("+1 day"));
$now_datebefor = date('Y-m-01 00:00:00');
$now_dateafter = date('Y-m-d 23:59:59', strtotime("+1 day"));
$now_order_list = StoreOrderModel::where('add_time', 'between time', [$now_datebefor, $now_dateafter])
->where($where)
->field("FROM_UNIXTIME(add_time,'%d') as day,count(*) as count,sum(pay_price) as price")
->group("FROM_UNIXTIME(add_time, '%Y%m%e')")
->order('add_time asc')
......@@ -394,6 +401,7 @@ class Index extends AuthController
//统计总数上期
$pre_total = StoreOrderModel::where('add_time', 'between time', [$datebefor, $dateafter])
->where($where)
->field("count(*) as count,sum(pay_price) as price")
->find();
if ($pre_total) {
......@@ -406,21 +414,22 @@ class Index extends AuthController
}
//统计总数
$total = StoreOrderModel::where('add_time', 'between time', [$now_datebefor, $now_dateafter])
->where($where)
->field("count(*) as count,sum(pay_price) as price")
->find();
if ($total) {
$cha_count = intval($pre_total['count']) - intval($total['count']);
$pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
//$pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
$chartdata['cycle']['count'] = [
'data' => $total['count'] ?: 0,
'percent' => round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
'percent' => intval($pre_total['count']) == 0 ? 100 : round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
'is_plus' => $cha_count > 0 ? -1 : ($cha_count == 0 ? 0 : 1)
];
$cha_price = round($pre_total['price'], 2) - round($total['price'], 2);
$pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
//$pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
$chartdata['cycle']['price'] = [
'data' => $total['price'] ?: 0,
'percent' => round(abs($cha_price) / $pre_total['price'] * 100, 2),
'percent' => (intval($pre_total['price']) == 0 || !$pre_total['price'] || $pre_total['price'] == 0.00) ? 100 : round(abs($cha_price) / $pre_total['price'] * 100, 2),
'is_plus' => $cha_price > 0 ? -1 : ($cha_price == 0 ? 0 : 1)
];
}
......@@ -428,9 +437,10 @@ class Index extends AuthController
break;
case 'year':
$weekarray = array('01' => ['一月'], '02' => ['二月'], '03' => ['三月'], '04' => ['四月'], '05' => ['五月'], '06' => ['六月'], '07' => ['七月'], '08' => ['八月'], '09' => ['九月'], '10' => ['十月'], '11' => ['十一月'], '12' => ['十二月']);
$datebefor = date('Y-01-01', strtotime('-1 year'));
$dateafter = date('Y-12-31', strtotime('-1 year'));
$datebefor = date('Y-01-01 00:00:00', strtotime('-1 year'));
$dateafter = date('Y-12-31 23:59:59', strtotime('-1 year'));
$order_list = StoreOrderModel::where('add_time', 'between time', [$datebefor, $dateafter])
->where($where)
->field("FROM_UNIXTIME(add_time,'%m') as day,count(*) as count,sum(pay_price) as price")
->group("FROM_UNIXTIME(add_time, '%Y%m')")
->order('add_time asc')
......@@ -440,9 +450,10 @@ class Index extends AuthController
foreach ($order_list as $k => $v) {
$new_order_list[$v['day']] = $v;
}
$now_datebefor = date('Y-01-01');
$now_dateafter = date('Y-m-d');
$now_datebefor = date('Y-01-01 00:00:00');
$now_dateafter = date('Y-m-d 23:59:59');
$now_order_list = StoreOrderModel::where('add_time', 'between time', [$now_datebefor, $now_dateafter])
->where($where)
->field("FROM_UNIXTIME(add_time,'%m') as day,count(*) as count,sum(pay_price) as price")
->group("FROM_UNIXTIME(add_time, '%Y%m')")
->order('add_time asc')
......@@ -492,6 +503,7 @@ class Index extends AuthController
//统计总数上期
$pre_total = StoreOrderModel::where('add_time', 'between time', [$datebefor, $dateafter])
->where($where)
->field("count(*) as count,sum(pay_price) as price")
->find();
if ($pre_total) {
......@@ -504,21 +516,22 @@ class Index extends AuthController
}
//统计总数
$total = StoreOrderModel::where('add_time', 'between time', [$now_datebefor, $now_dateafter])
->where($where)
->field("count(*) as count,sum(pay_price) as price")
->find();
if ($total) {
$cha_count = intval($pre_total['count']) - intval($total['count']);
$pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
//$pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
$chartdata['cycle']['count'] = [
'data' => $total['count'] ?: 0,
'percent' => round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
'percent' => intval($pre_total['count']) == 0 ? 100 : round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
'is_plus' => $cha_count > 0 ? -1 : ($cha_count == 0 ? 0 : 1)
];
$cha_price = round($pre_total['price'], 2) - round($total['price'], 2);
$pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
//$pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
$chartdata['cycle']['price'] = [
'data' => $total['price'] ?: 0,
'percent' => round(abs($cha_price) / $pre_total['price'] * 100, 2),
'percent' => (intval($pre_total['price']) == 0 || !$pre_total['price'] || $pre_total['price'] == 0.00) ? 100 : round(abs($cha_price) / $pre_total['price'] * 100, 2),
'is_plus' => $cha_price > 0 ? -1 : ($cha_price == 0 ? 0 : 1)
];
}
......@@ -575,7 +588,7 @@ class Index extends AuthController
header('Content-type:text/json');
$data = [];
$data['ordernum'] = StoreOrderModel::statusByWhere(1)->count();//待发货
$replenishment_num = SystemConfig::getConfigValue('store_stock') > 0 ? SystemConfig::getConfigValue('store_stock') : 2;//库存预警界限
$replenishment_num = sys_config('store_stock') > 0 ? sys_config('store_stock') : 2;//库存预警界限
$data['inventory'] = ProductModel::where('stock', '<=', $replenishment_num)->where('is_show', 1)->where('is_del', 0)->count();//库存
$data['commentnum'] = StoreProductReplyModel::where('is_reply', 0)->count();//评论
$data['reflectnum'] = UserExtractModel::where('status', 0)->count();;//提现
......
......@@ -24,7 +24,7 @@ class SystemBasic extends BaseController
protected function failedNotice($msg = '操作失败', $backUrl = 0, $info = '', $duration = 3)
{
$type = 'error';
$this->assign(compact('msg','backUrl','info','duration','type'));
$this->assign(compact('msg', 'backUrl', 'info', 'duration', 'type'));
return $this->fetch('public/notice');
}
......@@ -37,7 +37,7 @@ class SystemBasic extends BaseController
*/
protected function failedNoticeLast($msg = '操作失败', $backUrl = 0, $info = '')
{
return $this->failedNotice($msg,$backUrl,$info,0);
return $this->failedNotice($msg, $backUrl, $info, 0);
}
/**
......@@ -48,10 +48,10 @@ class SystemBasic extends BaseController
* @param int $duration 持续时间
* @return mixed
*/
protected function successfulNotice($msg = '操作成功',$backUrl = 0,$info = '',$duration = 3)
protected function successfulNotice($msg = '操作成功', $backUrl = 0, $info = '', $duration = 3)
{
$type = 'success';
$this->assign(compact('msg','backUrl','info','duration','type'));
$this->assign(compact('msg', 'backUrl', 'info', 'duration', 'type'));
return $this->fetch('public/notice');
}
......@@ -62,9 +62,9 @@ class SystemBasic extends BaseController
* @param string $title
* @return mixed
*/
protected function successfulNoticeLast($msg = '操作成功',$backUrl = 0,$info = '')
protected function successfulNoticeLast($msg = '操作成功', $backUrl = 0, $info = '')
{
return $this->successfulNotice($msg,$backUrl,$info,0);
return $this->successfulNotice($msg, $backUrl, $info, 0);
}
/**
......@@ -74,10 +74,10 @@ class SystemBasic extends BaseController
*/
protected function failed($msg = '哎呀…亲…您访问的页面出现错误', $url = 0)
{
if($this->request->isAjax()){
exit(JsonService::fail($msg,$url)->getContent());
}else{
$this->assign(compact('msg','url'));
if ($this->request->isAjax()) {
exit(JsonService::fail($msg, $url)->getContent());
} else {
$this->assign(compact('msg', 'url'));
exit($this->fetch('public/error'));
}
}
......@@ -89,13 +89,14 @@ class SystemBasic extends BaseController
*/
protected function successful($msg, $url = 0)
{
if($this->request->isAjax()){
exit(JsonService::successful($msg,$url)->getContent());
}else{
$this->assign(compact('msg','url'));
if ($this->request->isAjax()) {
exit(JsonService::successful($msg, $url)->getContent());
} else {
$this->assign(compact('msg', 'url'));
exit($this->fetch('public/success'));
}
}
/**异常抛出
* @param $name
*/
......
<?php
namespace app\admin\controller;
use app\admin\model\system\SystemCity;
use crmeb\services\ExpressService;
use crmeb\services\HttpService;
use crmeb\services\JsonService;
use crmeb\utils\Queue;
use think\facade\Db;
use think\facade\Queue as QueueJob;
class Test
{
public function index($page = 1, $limit = 50, $level = 0)
{
// var_dump(is_file('uploads/981_1_user.jpg'));
// $appCode = '4a5b910fc344434cacb2edd36e0e56aa';
// $list = ExpressService::query('75341495702624');
// dump($list);
// $data = [];
// foreach ($list['data'] as $item) {
// $data[] = [
// 'level' => $item['level'],
// 'parent_id' => $item['parent_id'],
// 'area_code' => $item['area_code'],
// 'name' => $item['name'],
// 'merger_name' => $item['merger_name'],
// 'lng' => $item['lng'],
// 'lat' => $item['lat'],
// 'city_id' => $item['id'],
// ];
// }
// $res = SystemCity::insertAll($data);
// return JsonService::successful(['count' => $res]);
$sql = Db::name('system_menus')->whereIn('paid', function ($query) {
$query->name('system_menus')->where('menu_name', '评论管理')->find();
})->fetchSql(true)->delete();
var_dump($sql);
}
}
\ No newline at end of file
......@@ -6,12 +6,15 @@ use app\admin\controller\AuthController;
use app\admin\model\order\StoreOrder;
use app\admin\model\system\SystemAttachment;
use app\admin\model\user\User;
use app\admin\model\wechat\WechatUser as UserModel;
use app\models\routine\RoutineQrcode;
use app\models\user\UserBill;
use crmeb\services\JsonService;
use crmeb\services\UploadService;
use crmeb\services\UtilService as Util;
use app\admin\model\wechat\WechatUser as UserModel;
use app\models\routine\{
RoutineCode, RoutineQrcode
};
use crmeb\services\{
JsonService, QrcodeService, UtilService as Util
};
use crmeb\services\upload\Upload;
/**
* 分销商管理控制器
......@@ -26,17 +29,18 @@ class AgentManage extends AuthController
*/
public function index()
{
$this->assign('year', getMonth());
$this->assign('store_brokerage_statu', sysConfig('store_brokerage_statu'));
$this->assign('year', get_month());
$this->assign('store_brokerage_statu', sys_config('store_brokerage_statu'));
return $this->fetch();
}
/**
* 分销员列表
*/
public function get_spread_list()
{
$where = Util::getMore([
['nickname', ''],
['start_time', ''],
['end_time', ''],
['sex', ''],
['excel', ''],
['subscribe', ''],
......@@ -44,10 +48,14 @@ class AgentManage extends AuthController
['page', 1],
['limit', 20],
['user_type', ''],
['data', '']
]);
return JsonService::successlayui(UserModel::agentSystemPage($where));
}
/**
* 分销员列表头部数据统计
*/
public function get_badge()
{
$where = Util::postMore([
......@@ -66,22 +74,25 @@ class AgentManage extends AuthController
{
if ($uid == '') return $this->failed('参数错误');
$this->assign('uid', $uid ?: 0);
$this->assign('year', getMonth());
$this->assign('year', get_month());
return $this->fetch();
}
/*
* 统计推广订单
* 统计推广订单页面
* @param int $uid
* */
public function stair_order($uid = 0)
{
if ($uid == '') return $this->failed('参数错误');
$this->assign('uid', $uid ?: 0);
$this->assign('year', getMonth());
$this->assign('year', get_month());
return $this->fetch();
}
/**
* 统计推广订单列表
*/
public function get_stair_order_list()
{
$where = Util::getMore([
......@@ -95,6 +106,9 @@ class AgentManage extends AuthController
return JsonService::successlayui(UserModel::getStairOrderList($where));
}
/**
* 统计推广订单列表头部统计数据
*/
public function get_stair_order_badge()
{
$where = Util::getMore([
......@@ -213,11 +227,23 @@ class AgentManage extends AuthController
$name = $userInfo['uid'] . '_' . $userInfo['is_promoter'] . '_user.jpg';
$imageInfo = SystemAttachment::getInfo($name, 'name');
if (!$imageInfo) {
$res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', '');
$res = RoutineCode::getShareCode($uid, 'spread', '', '');
if (!$res) throw new \think\Exception('二维码生成失败');
$imageInfo = UploadService::instance()->setUploadPath('routine/spread/code')->imageStream($name, $res['res']);
if (!is_array($imageInfo)) return $imageInfo;
SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time']);
$upload_type = sys_config('upload_type', 1);
$upload = new Upload((int)$upload_type, [
'accessKey' => sys_config('accessKey'),
'secretKey' => sys_config('secretKey'),
'uploadUrl' => sys_config('uploadUrl'),
'storageName' => sys_config('storage_name'),
'storageRegion' => sys_config('storage_region'),
]);
$info = $upload->to('routine/spread/code')->validate()->stream($res['res'], $name);
if ($info === false) {
return $upload->getError();
}
$imageInfo = $upload->getUploadInfo();
$imageInfo['image_type'] = $upload_type;
SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
RoutineQrcode::setRoutineQrcodeFind($res['id'], ['status' => 1, 'time' => time(), 'qrcode_url' => $imageInfo['dir']]);
$urlCode = $imageInfo['dir'];
} else $urlCode = $imageInfo['att_dir'];
......@@ -229,7 +255,7 @@ class AgentManage extends AuthController
* */
public function wechant_code($uid)
{
$qr_code = \crmeb\services\QrcodeService::getForeverQrcode('spread', $uid);
$qr_code = QrcodeService::getForeverQrcode('spread', $uid);
if (isset($qr_code['url']))
return ['code_src' => $qr_code['url']];
else
......@@ -248,11 +274,23 @@ class AgentManage extends AuthController
$name = $userInfo['uid'] . '_' . $userInfo['is_promoter'] . '_user.jpg';
$imageInfo = SystemAttachment::getInfo($name, 'name');
if (!$imageInfo) {
$res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', '');
$res = RoutineCode::getShareCode($uid, 'spread', '', '');
if (!$res) return JsonService::fail('二维码生成失败');
$imageInfo = UploadService::instance()->setUploadPath('routine/spread/code')->imageStream($name, $res['res']);
if (!is_array($imageInfo)) return JsonService::fail($imageInfo);
SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time']);
$upload_type = sys_config('upload_type', 1);
$upload = new Upload((int)$upload_type, [
'accessKey' => sys_config('accessKey'),
'secretKey' => sys_config('secretKey'),
'uploadUrl' => sys_config('uploadUrl'),
'storageName' => sys_config('storage_name'),
'storageRegion' => sys_config('storage_region'),
]);
$info = $upload->to('routine/spread/code')->validate()->stream($res['res'], $name);
if ($info === false) {
return $upload->getError();
}
$imageInfo = $upload->getUploadInfo();
$imageInfo['image_type'] = $upload_type;
SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
RoutineQrcode::setRoutineQrcodeFind($res['id'], ['status' => 1, 'time' => time(), 'qrcode_url' => $imageInfo['dir']]);
$urlCode = $imageInfo['dir'];
} else $urlCode = $imageInfo['att_dir'];
......@@ -262,10 +300,10 @@ class AgentManage extends AuthController
}
}
/**
/*
* 解除单个用户的推广权限
* @param int $uid
*/
* */
public function delete_spread($uid = 0)
{
if (!$uid) return JsonService::fail('缺少参数');
......@@ -275,9 +313,9 @@ class AgentManage extends AuthController
return JsonService::fail('解除失败');
}
/**
/*
* 清除推广人
*/
* */
public function empty_spread($uid = 0)
{
if (!$uid) return JsonService::fail('缺少参数');
......@@ -299,7 +337,7 @@ class AgentManage extends AuthController
->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']);
$v['add_time'] = $v['add_time'] ? date('Y-m-d H:i:s', $v['add_time']) : '';
}
$this->assign('list', $list);
return $this->fetch();
......
......@@ -3,12 +3,13 @@
namespace app\admin\controller\article;
use app\admin\controller\AuthController;
use crmeb\services\UtilService as Util;
use crmeb\services\JsonService as Json;
use crmeb\services\UploadService as Upload;
use app\admin\model\article\ArticleCategory as ArticleCategoryModel;
use app\admin\model\article\Article as ArticleModel;
use app\admin\model\system\SystemAttachment;
use crmeb\services\{
UtilService as Util, JsonService as Json
};
use app\admin\model\article\{
ArticleCategory as ArticleCategoryModel, Article as ArticleModel
};
/**
* 图文管理
......@@ -28,7 +29,7 @@ class Article extends AuthController
{
$where = Util::getMore([
['title', ''],
['cid', $this->request->param('pid', '')]
['cid', $this->request->param('pid', '')],
], $this->request);
$this->assign('where', $where);
$where['merchant'] = 0;//区分是管理员添加的图文显示 0 还是 商户添加的图文显示 1
......@@ -66,6 +67,7 @@ class Article extends AuthController
$news = ArticleModel::where('n.id', $id)->alias('n')->field('n.*,c.content')->join('ArticleContent c', 'c.nid=n.id', 'left')->find();
if (!$news) return $this->failed('数据不存在!');
$news['cid'] = explode(',', $news['cid']);
$news['content'] = htmlspecialchars_decode($news['content']);
}
if ($cid && in_array($cid, ArticleCategoryModel::getArticleCategoryInfo(0, 'id'))) {
$all = ArticleCategoryModel::getArticleCategoryInfo($cid);
......
......@@ -2,67 +2,54 @@
namespace app\admin\controller\article;
use think\facade\Route as Url;
use app\admin\controller\AuthController;
use app\admin\model\system\SystemAttachment;
use crmeb\services\FormBuilder as Form;
use crmeb\services\UtilService as Util;
use crmeb\services\JsonService as Json;
use crmeb\services\UploadService as Upload;
use think\facade\Route as Url;
use app\admin\model\article\ArticleCategory as ArticleCategoryModel;
use app\admin\model\article\Article as ArticleModel;
use app\admin\model\article\{ArticleCategory as ArticleCategoryModel,Article as ArticleModel};
use crmeb\services\{FormBuilder as Form,UtilService as Util,JsonService as Json};
/**
* 文章分类管理 控制器
* */
class ArticleCategory extends AuthController
{
/**
* 分类管理
* */
public function index(){
$where = Util::getMore([
['status',''],
['title',''],
],$this->request);
$this->assign('where',$where);
$this->assign(ArticleCategoryModel::systemPage($where));
return $this->fetch();
}
public function index()
{
$where = Util::getMore([
['status', ''],
['title', ''],
], $this->request);
$this->assign('where', $where);
$this->assign(ArticleCategoryModel::systemPage($where));
return $this->fetch();
}
/**
* 添加分类管理
* */
public function create(){
public function create()
{
$f = array();
$f[] = Form::select('pid','父级id')->setOptions(function(){
$f[] = Form::select('pid', '父级id')->setOptions(function () {
$list = ArticleCategoryModel::getTierList();
$menus[] = ['value'=>0,'label'=>'顶级分类'];
foreach ($list as $menu){
$menus[] = ['value'=>$menu['id'],'label'=>$menu['html'].$menu['title']];
$menus[] = ['value' => 0, 'label' => '顶级分类'];
foreach ($list as $menu) {
$menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['title']];
}
return $menus;
})->filterable(1);
$f[] = Form::input('title','分类名称');
$f[] = Form::input('intr','分类简介')->type('textarea');
// $f[] = Form::select('new_id','图文列表')->setOptions(function(){
// $list = ArticleModel::getNews();
// $options = [];
// foreach ($list as $id=>$roleName){
// $options[] = ['label'=>$roleName,'value'=>$id];
// }
// return $options;
// })->multiple(1)->filterable(1);
$f[] = Form::frameImageOne('image','分类图片',Url::buildUrl('admin/widget.images/index',array('fodder'=>'image')))->icon('image')->width('100%')->height('500px');
$f[] = Form::number('sort','排序',0);
$f[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>0,'label'=>'隐藏']]);
$form = Form::make_post_form('添加分类',$f,Url::buildUrl('save'));
$f[] = Form::input('title', '分类名称');
$f[] = Form::input('intr', '分类简介')->type('textarea');
$f[] = Form::frameImageOne('image', '分类图片', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')))->icon('image')->width('100%')->height('500px');
$f[] = Form::number('sort', '排序', 0);
$f[] = Form::radio('status', '状态', 1)->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
$form = Form::make_post_form('添加分类', $f, Url::buildUrl('save'));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
......@@ -71,80 +58,69 @@ class ArticleCategory extends AuthController
/**
* s上传图片
* */
public function upload(){
public function upload()
{
$res = Upload::instance()->setUploadPath('article')->image('file');
if(!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']);
return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]);
if (!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 5, $res['image_type'], $res['time']);
return Json::successful('图片上传成功!', ['name' => $res['name'], 'url' => path_to_url($res['thumb_path'])]);
}
/**
* 保存分类管理
* */
public function save(){
public function save()
{
$data = Util::postMore([
'title',
'pid',
'intr',
['new_id',[]],
['image',[]],
['sort',0],
['new_id', []],
['image', []],
['sort', 0],
'status',]);
if(!$data['title']) return Json::fail('请输入分类名称');
if(count($data['image']) != 1) return Json::fail('请选择分类图片,并且只能上传一张');
if($data['sort'] < 0) return Json::fail('排序不能是负数');
if (!$data['title']) return Json::fail('请输入分类名称');
if (count($data['image']) != 1) return Json::fail('请选择分类图片,并且只能上传一张');
if ($data['sort'] < 0) return Json::fail('排序不能是负数');
$data['add_time'] = time();
$data['image'] = $data['image'][0];
$new_id = $data['new_id'];
unset($data['new_id']);
$res = ArticleCategoryModel::create($data);
if(!ArticleModel::saveBatchCid($res['id'],implode(',',$new_id))) return Json::fail('文章列表添加失败');
if (!ArticleModel::saveBatchCid($res['id'], implode(',', $new_id))) return Json::fail('文章列表添加失败');
return Json::successful('添加分类成功!');
}
/**
* 修改分类
* */
public function edit($id){
if(!$id) return $this->failed('参数错误');
public function edit($id)
{
if (!$id) return $this->failed('参数错误');
$article = ArticleCategoryModel::get($id)->getData();
if(!$article) return Json::fail('数据不存在!');
if (!$article) return Json::fail('数据不存在!');
$f = array();
$f[] = Form::select('pid','父级id',(string)$article['pid'])->setOptions(function(){
$f[] = Form::select('pid', '父级id', (string)$article['pid'])->setOptions(function () {
$list = ArticleCategoryModel::getTierList();
$menus[] = ['value'=>0,'label'=>'顶级分类'];
foreach ($list as $menu){
$menus[] = ['value'=>$menu['id'],'label'=>$menu['html'].$menu['title']];
$menus[] = ['value' => 0, 'label' => '顶级分类'];
foreach ($list as $menu) {
$menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['title']];
}
return $menus;
})->filterable(1);
$f[] = Form::input('title','分类名称',$article['title']);
$f[] = Form::input('intr','分类简介',$article['intr'])->type('textarea');
// $f[] = Form::select('new_id','图文列表',explode(',',$article->getData('new_id')))->setOptions(function(){
// $list = ArticleModel::getNews();
// $options = [];
// foreach ($list as $id=>$roleName){
// $options[] = ['label'=>$roleName,'value'=>$id];
// }
// return $options;
// })->multiple(1)->filterable(1);
$f[] = Form::frameImageOne('image','分类图片',Url::buildUrl('admin/widget.images/index',array('fodder'=>'image')),$article['image'])->icon('image')->width('100%')->height('500px');
$f[] = Form::number('sort','排序',0);
$f[] = Form::radio('status','状态',$article['status'])->options([['value'=>1,'label'=>'显示'],['value'=>0,'label'=>'隐藏']]);
$form = Form::make_post_form('编辑分类',$f,Url::buildUrl('update',array('id'=>$id)));
$f[] = Form::input('title', '分类名称', $article['title']);
$f[] = Form::input('intr', '分类简介', $article['intr'])->type('textarea');
$f[] = Form::frameImageOne('image', '分类图片', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')), $article['image'])->icon('image')->width('100%')->height('500px');
$f[] = Form::number('sort', '排序', $article['sort']);
$f[] = Form::radio('status', '状态', $article['status'])->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
$form = Form::make_post_form('编辑分类', $f, Url::buildUrl('update', array('id' => $id)));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
public function update($id)
{
$data = Util::postMore([
......@@ -152,17 +128,17 @@ class ArticleCategory extends AuthController
'title',
'intr',
// ['new_id',[]],
['image',[]],
['sort',0],
['image', []],
['sort', 0],
'status',]);
if(!$data['title']) return Json::fail('请输入分类名称');
if(count($data['image']) != 1) return Json::fail('请选择分类图片,并且只能上传一张');
if($data['sort'] < 0) return Json::fail('排序不能是负数');
if (!$data['title']) return Json::fail('请输入分类名称');
if (count($data['image']) != 1) return Json::fail('请选择分类图片,并且只能上传一张');
if ($data['sort'] < 0) return Json::fail('排序不能是负数');
$data['image'] = $data['image'][0];
if(!ArticleCategoryModel::get($id)) return Json::fail('编辑的记录不存在!');
if (!ArticleCategoryModel::get($id)) return Json::fail('编辑的记录不存在!');
// if(!ArticleModel::saveBatchCid($id,implode(',',$data['new_id']))) return Json::fail('文章列表添加失败');
// unset($data['new_id']);
ArticleCategoryModel::edit($data,$id);
ArticleCategoryModel::edit($data, $id);
return Json::successful('修改成功!');
}
......@@ -172,7 +148,7 @@ class ArticleCategory extends AuthController
public function delete($id)
{
$res = ArticleCategoryModel::delArticleCategory($id);
if(!$res)
if (!$res)
return Json::fail(ArticleCategoryModel::getErrorInfo('删除失败,请稍候再试!'));
else
return Json::successful('删除成功!');
......
......@@ -3,12 +3,15 @@
namespace app\admin\controller\article;
use app\admin\controller\AuthController;
use crmeb\services\UtilService as Util;
use crmeb\services\JsonService as Json;
use crmeb\services\UploadService as Upload;
use app\admin\model\article\ArticleCategory as ArticleCategoryModel;
use app\admin\model\article\Article as ArticleModel;
use app\admin\model\system\SystemAttachment;
use app\admin\model\wechat\WechatNews as WechatNewsModel;
use crmeb\services\{
UtilService as Util, JsonService as Json
};
use app\admin\model\article\{
Article as ArticleModel, ArticleCategory as ArticleCategoryModel
};
use crmeb\services\upload\Upload;
/**
* 图文管理
......@@ -24,15 +27,15 @@ class WechatNews extends AuthController
public function index($cid = 0)
{
$where = Util::getMore([
['title','']
],$this->request);
if($cid)
['title', '']
], $this->request);
if ($cid)
$where['cid'] = $cid;
else
$where['cid'] = '';
$this->assign('where',$where);
$this->assign('where', $where);
$where['merchant'] = 0;//区分是管理员添加的图文显示 0 还是 商户添加的图文显示 1
$this->assign('cid',$cid);
$this->assign('cid', $cid);
$this->assign(ArticleModel::getAll($where));
return $this->fetch();
}
......@@ -41,7 +44,8 @@ class WechatNews extends AuthController
* 展示页面 添加和删除
* @return mixed
*/
public function create(){
public function create()
{
$id = input('id');
$cid = input('cid');
$news = array();
......@@ -53,34 +57,33 @@ class WechatNews extends AuthController
$news['synopsis'] = '';
$news['url'] = '';
$news['cid'] = array();
if($id){
$news = \app\admin\model\wechat\WechatNews::where('n.id',$id)->alias('n')->field('n.*,c.content')->join('wechat_news_content c','c.nid=n.id')->find();
if(!$news) return $this->failedNotice('数据不存在!');
$news['cid'] = explode(',',$news['cid']);
// dump($news);
if ($id) {
$news = WechatNewsModel::where('n.id', $id)->alias('n')->field('n.*,c.content')->join('wechat_news_content c', 'c.nid=n.id')->find();
if (!$news) return $this->failedNotice('数据不存在!');
$news['cid'] = explode(',', $news['cid']);
}
$all = array();
$select = 0;
if(!$cid)
$select = 0;
if (!$cid)
$cid = '';
else {
if($id){
$all = ArticleCategoryModel::where('id',$cid)->where('hidden','<>',0)->column('title','id');
if ($id) {
$all = ArticleCategoryModel::where('id', $cid)->where('hidden', '<>', 0)->column('title', 'id');
$select = 1;
}else{
$all = ArticleCategoryModel::where('id',$cid)->column('title','id');
} else {
$all = ArticleCategoryModel::where('id', $cid)->column('title', 'id');
$select = 1;
}
}
if(empty($all)){
if (empty($all)) {
$all = ArticleCategoryModel::getField();//新闻分类
$select = 0;
$select = 0;
}
$this->assign('all',$all);
$this->assign('news',$news);
$this->assign('cid',$cid);
$this->assign('select',$select);
$this->assign('all', $all);
$this->assign('news', $news);
$this->assign('cid', $cid);
$this->assign('select', $select);
return $this->fetch();
}
......@@ -88,20 +91,34 @@ class WechatNews extends AuthController
* 上传图文图片
* @return \think\response\Json
*/
public function upload_image(){
$res = Upload::instance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']);
if(!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']);
return Json::successful('上传成功!',['url'=>$res['thumb_path']]);
public function upload_image()
{
$uploadType = (int)sys_config('upload_type', 1);
$upload = new Upload($uploadType, [
'accessKey' => sys_config('accessKey'),
'secretKey' => sys_config('secretKey'),
'uploadUrl' => sys_config('uploadUrl'),
'storageName' => sys_config('storage_name'),
'storageRegion' => sys_config('storage_region'),
]);
$resInfo = $upload->to('wechat/image/' . date('Ymd'))->validate()->move($this->request->post('file'));
if ($resInfo === false) {
return Json::fail($upload->getError());
}
$res = $upload->getUploadInfo();
$res['image_type'] = $uploadType;
SystemAttachment::attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 5, $res['image_type'], $res['time']);
return Json::successful('上传成功!', ['url' => $res['thumb_path']]);
}
/**
* 添加和修改图文
*/
public function add_new(){
public function add_new()
{
$data = Util::postMore([
['id',0],
['cid',[]],
['id', 0],
['cid', []],
'title',
'author',
'image_input',
......@@ -109,47 +126,45 @@ class WechatNews extends AuthController
'synopsis',
'share_title',
'share_synopsis',
['visit',0],
['sort',0],
['visit', 0],
['sort', 0],
'url',
['status',1],]);
$data['cid'] = implode(',',$data['cid']);
['status', 1],]);
$data['cid'] = implode(',', $data['cid']);
$content = $data['content'];
unset($data['content']);
if($data['id']){
if ($data['id']) {
$id = $data['id'];
unset($data['id']);
ArticleModel::beginTrans();
$res1 = ArticleModel::edit($data,$id,'id');
$res2 = ArticleModel::setContent($id,$content);
if($res1 && $res2)
$res1 = ArticleModel::edit($data, $id, 'id');
$res2 = ArticleModel::setContent($id, $content);
if ($res1 && $res2)
$res = true;
else
$res =false;
// dump($res);
// exit();
$res = false;
ArticleModel::checkTrans($res);
if($res)
return Json::successful('修改图文成功!',$id);
if ($res)
return Json::successful('修改图文成功!', $id);
else
return Json::fail('修改图文失败!',$id);
}else{
return Json::fail('修改图文失败!', $id);
} else {
$data['add_time'] = time();
$data['admin_id'] = $this->adminId;
ArticleModel::beginTrans();
$res1 = ArticleModel::create($data);
$res2 = false;
if($res1)
$res2 = ArticleModel::setContent($res1->id,$content);
if($res1 && $res2)
if ($res1)
$res2 = ArticleModel::setContent($res1->id, $content);
if ($res1 && $res2)
$res = true;
else
$res =false;
$res = false;
ArticleModel::checkTrans($res);
if($res)
return Json::successful('添加图文成功!',$res1->id);
if ($res)
return Json::successful('添加图文成功!', $res1->id);
else
return Json::successful('添加图文失败!',$res1->id);
return Json::successful('添加图文失败!', $res1->id);
}
}
......@@ -161,17 +176,18 @@ class WechatNews extends AuthController
public function delete($id)
{
$res = ArticleModel::del($id);
if(!$res)
if (!$res)
return Json::fail('删除失败,请稍候再试!');
else
return Json::successful('删除成功!');
}
public function merchantIndex(){
public function merchantIndex()
{
$where = Util::getMore([
['title','']
],$this->request);
$this->assign('where',$where);
['title', '']
], $this->request);
$this->assign('where', $where);
$where['cid'] = input('cid');
$where['merchant'] = 1;//区分是管理员添加的图文显示 0 还是 商户添加的图文显示 1
$this->assign(ArticleModel::getAll($where));
......
......@@ -8,12 +8,9 @@
namespace app\admin\controller\finance;
use app\admin\controller\AuthController;
use app\admin\model\user\UserBill;
use crmeb\services\JsonService as Json;
use app\admin\model\user\{User,UserBill};
use app\admin\model\finance\FinanceModel;
use crmeb\services\UtilService as Util;
use crmeb\services\FormBuilder as Form;
use app\admin\model\user\User;
use crmeb\services\{UtilService as Util,JsonService as Json};
/**
* 微信充值记录
......@@ -21,46 +18,49 @@ use app\admin\model\user\User;
* @package app\admin\controller\user
*/
class Finance extends AuthController
{
/**
* 显示资金记录
*/
public function bill(){
$list=UserBill::where('type','not in',['gain','system_sub','deduction','sign'])
->where('category','not in','integral')
->field(['title','type'])
public function bill()
{
$list = UserBill::where('type', 'not in', ['gain', 'system_sub', 'deduction', 'sign'])
->where('category', 'not in', 'integral')
->field(['title', 'type'])
->group('type')
->distinct(true)
->select()
->toArray();
$this->assign('selectList',$list);
$this->assign('selectList', $list);
return $this->fetch();
}
/**
* 显示资金记录ajax列表
*/
public function billlist(){
public function billlist()
{
$where = Util::getMore([
['start_time',''],
['end_time',''],
['nickname',''],
['limit',20],
['page',1],
['type',''],
['start_time', ''],
['end_time', ''],
['nickname', ''],
['limit', 20],
['page', 1],
['type', ''],
]);
return Json::successlayui(FinanceModel::getBillList($where));
}
/**
*保存资金监控的excel表格
*/
public function save_bell_export(){
public function save_bell_export()
{
$where = Util::getMore([
['start_time',''],
['end_time',''],
['nickname',''],
['type',''],
['start_time', ''],
['end_time', ''],
['nickname', ''],
['type', ''],
]);
FinanceModel::SaveExport($where);
}
......@@ -68,23 +68,25 @@ class Finance extends AuthController
/**
* 显示佣金记录
*/
public function commission_list(){
$this->assign('is_layui',true);
public function commission_list()
{
$this->assign('is_layui', true);
return $this->fetch();
}
/**
* 佣金记录异步获取
*/
public function get_commission_list(){
$get=Util::getMore([
['page',1],
['limit',20],
['nickname',''],
['price_max',''],
['price_min',''],
['order',''],
['excel',''],
public function get_commission_list()
{
$get = Util::getMore([
['page', 1],
['limit', 20],
['nickname', ''],
['price_max', ''],
['price_min', ''],
['order', ''],
['excel', ''],
]);
return Json::successlayui(User::getCommissionList($get));
}
......@@ -92,31 +94,36 @@ class Finance extends AuthController
/**
* 显示操作记录
*/
public function index3(){
public function index3()
{
}
/**
* 佣金详情
*/
public function content_info($uid=''){
if($uid=='') return $this->failed('缺少参数');
$this->assign('userinfo',User::getUserinfo($uid));
$this->assign('uid',$uid);
public function content_info($uid = '')
{
if ($uid == '') return $this->failed('缺少参数');
$this->assign('userinfo', User::getUserinfo($uid));
$this->assign('uid', $uid);
return $this->fetch();
}
/**
* 佣金提现记录个人列表
*/
public function get_extract_list($uid=''){
if($uid=='') return Json::fail('缺少参数');
$where=Util::getMore([
['page',1],
['limit',20],
['start_time',''],
['end_time',''],
['nickname','']
public function get_extract_list($uid = '')
{
if ($uid == '') return Json::fail('缺少参数');
$where = Util::getMore([
['page', 1],
['limit', 20],
['start_time', ''],
['end_time', ''],
['nickname', '']
]);
return Json::successlayui(UserBill::getExtrctOneList($where,$uid));
return Json::successlayui(UserBill::getExtrctOneList($where, $uid));
}
}
......
......@@ -5,14 +5,14 @@
* Date: 2018-03-03
* Time: 16:37
*/
namespace app\admin\controller\finance;
use app\admin\controller\AuthController;
use crmeb\services\FormBuilder as Form;
use app\admin\model\user\UserExtract as UserExtractModel;
use crmeb\services\JsonService;
use crmeb\services\UtilService as Util;
use think\facade\Route as Url;
use crmeb\services\JsonService;
use app\admin\model\user\UserExtract as UserExtractModel;
use crmeb\services\{UtilService as Util, FormBuilder as Form};
/**
* 用户提现管理
......@@ -21,71 +21,74 @@ use think\facade\Route as Url;
*/
class UserExtract extends AuthController
{
public function index(){
$where = Util::getMore([
['status',''],
['nickname',''],
['extract_type',''],
['nireid',''],
['date',''],
],$this->request);
$limitTimeList = [
'today'=>implode(' - ',[date('Y/m/d'),date('Y/m/d',strtotime('+1 day'))]),
'week'=>implode(' - ',[
date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)),
date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600))
]),
'month'=>implode(' - ',[date('Y/m').'/01',date('Y/m').'/'.date('t')]),
'quarter'=>implode(' - ',[
date('Y').'/'.(ceil((date('n'))/3)*3-3+1).'/01',
date('Y').'/'.(ceil((date('n'))/3)*3).'/'.date('t',mktime(0,0,0,(ceil((date('n'))/3)*3),1,date('Y')))
]),
'year'=>implode(' - ',[
date('Y').'/01/01',date('Y/m/d',strtotime(date('Y').'/01/01 + 1year -1 day'))
])
];
$this->assign('where',$where);
$this->assign('limitTimeList',$limitTimeList);
$this->assign(UserExtractModel::extractStatistics());
$this->assign(UserExtractModel::systemPage($where));
return $this->fetch();
}
public function edit($id){
if(!$id) return $this->failed('数据不存在');
public function index()
{
$where = Util::getMore([
['status', ''],
['nickname', ''],
['extract_type', ''],
['nireid', ''],
['date', ''],
], $this->request);
$limitTimeList = [
'today' => implode(' - ', [date('Y/m/d'), date('Y/m/d', strtotime('+1 day'))]),
'week' => implode(' - ', [
date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)),
date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600))
]),
'month' => implode(' - ', [date('Y/m') . '/01', date('Y/m') . '/' . date('t')]),
'quarter' => implode(' - ', [
date('Y') . '/' . (ceil((date('n')) / 3) * 3 - 3 + 1) . '/01',
date('Y') . '/' . (ceil((date('n')) / 3) * 3) . '/' . date('t', mktime(0, 0, 0, (ceil((date('n')) / 3) * 3), 1, date('Y')))
]),
'year' => implode(' - ', [
date('Y') . '/01/01', date('Y/m/d', strtotime(date('Y') . '/01/01 + 1year -1 day'))
])
];
$this->assign('where', $where);
$this->assign('limitTimeList', $limitTimeList);
$this->assign(UserExtractModel::extractStatistics());
$this->assign(UserExtractModel::systemPage($where));
return $this->fetch();
}
public function edit($id)
{
if (!$id) return $this->failed('数据不存在');
$UserExtract = UserExtractModel::get($id);
if(!$UserExtract) return JsonService::fail('数据不存在!');
if (!$UserExtract) return JsonService::fail('数据不存在!');
$f = array();
$f[] = Form::input('real_name','姓名',$UserExtract['real_name']);
$f[] = Form::number('extract_price','提现金额',$UserExtract['extract_price'])->precision(2);
if($UserExtract['extract_type']=='alipay'){
$f[] = Form::input('alipay_code','支付宝账号',$UserExtract['alipay_code']);
}else if($UserExtract['extract_type']=='weixin'){
$f[] = Form::input('wechat','微信号',$UserExtract['wechat']);
}else{
$f[] = Form::input('bank_code','银行卡号',$UserExtract['bank_code']);
$f[] = Form::input('bank_address','开户行',$UserExtract['bank_address']);
$f[] = Form::input('real_name', '姓名', $UserExtract['real_name']);
$f[] = Form::number('extract_price', '提现金额', $UserExtract['extract_price'])->precision(2);
if ($UserExtract['extract_type'] == 'alipay') {
$f[] = Form::input('alipay_code', '支付宝账号', $UserExtract['alipay_code']);
} else if ($UserExtract['extract_type'] == 'weixin') {
$f[] = Form::input('wechat', '微信号', $UserExtract['wechat']);
} else {
$f[] = Form::input('bank_code', '银行卡号', $UserExtract['bank_code']);
$f[] = Form::input('bank_address', '开户行', $UserExtract['bank_address']);
}
$f[] = Form::input('mark','备注',$UserExtract['mark'])->type('textarea');
$form = Form::make_post_form('编辑',$f,Url::buildUrl('update',array('id'=>$id)));
$f[] = Form::input('mark', '备注', $UserExtract['mark'])->type('textarea');
$form = Form::make_post_form('编辑', $f, Url::buildUrl('update', array('id' => $id)));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
public function update($id)
{
$UserExtract = UserExtractModel::get($id);
if(!$UserExtract) return JsonService::fail('数据不存在!');
if($UserExtract['extract_type']=='alipay'){
if (!$UserExtract) return JsonService::fail('数据不存在!');
if ($UserExtract['extract_type'] == 'alipay') {
$data = Util::postMore([
'real_name',
'mark',
'extract_price',
'alipay_code',
]);
if(!$data['real_name']) return JsonService::fail('请输入姓名');
if($data['extract_price']<=-1) return JsonService::fail('请输入提现金额');
if(!$data['alipay_code']) return JsonService::fail('请输入支付宝账号');
}else if($UserExtract['extract_type']=='weixin'){
if (!$data['real_name']) return JsonService::fail('请输入姓名');
if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
if (!$data['alipay_code']) return JsonService::fail('请输入支付宝账号');
} else if ($UserExtract['extract_type'] == 'weixin') {
$data = Util::postMore([
'real_name',
'mark',
......@@ -93,9 +96,9 @@ class UserExtract extends AuthController
'wechat',
]);
// if(!$data['real_name']) return JsonService::fail('请输入姓名');
if($data['extract_price']<=-1) return JsonService::fail('请输入提现金额');
if(!$data['wechat']) return JsonService::fail('请输入微信账号');
}else{
if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
if (!$data['wechat']) return JsonService::fail('请输入微信账号');
} else {
$data = Util::postMore([
'real_name',
'extract_price',
......@@ -103,45 +106,47 @@ class UserExtract extends AuthController
'bank_code',
'bank_address',
]);
if(!$data['real_name']) return JsonService::fail('请输入姓名');
if($data['extract_price']<=-1) return JsonService::fail('请输入提现金额');
if(!$data['bank_code']) return JsonService::fail('请输入银行卡号');
if(!$data['bank_address']) return JsonService::fail('请输入开户行');
if (!$data['real_name']) return JsonService::fail('请输入姓名');
if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
if (!$data['bank_code']) return JsonService::fail('请输入银行卡号');
if (!$data['bank_address']) return JsonService::fail('请输入开户行');
}
if(!UserExtractModel::edit($data,$id))
if (!UserExtractModel::edit($data, $id))
return JsonService::fail(UserExtractModel::getErrorInfo('修改失败'));
else
return JsonService::successful('修改成功!');
}
public function fail($id)
{
if(!UserExtractModel::be(['id'=>$id,'status'=>0])) return JsonService::fail('操作记录不存在或状态错误!');
$fail_msg =request()->post();
$extract=UserExtractModel::get($id);
if(!$extract) return JsonService::fail('操作记录不存在!');
if($extract->status==1) return JsonService::fail('已经提现,错误操作');
if($extract->status==-1) return JsonService::fail('您的提现申请已被拒绝,请勿重复操作!');
$res = UserExtractModel::changeFail($id,$fail_msg['message']);
if($res){
if (!UserExtractModel::be(['id' => $id, 'status' => 0])) return JsonService::fail('操作记录不存在或状态错误!');
$fail_msg = request()->post();
$extract = UserExtractModel::get($id);
if (!$extract) return JsonService::fail('操作记录不存在!');
if ($extract->status == 1) return JsonService::fail('已经提现,错误操作');
if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝,请勿重复操作!');
$res = UserExtractModel::changeFail($id, $fail_msg['message']);
if ($res) {
return JsonService::successful('操作成功!');
}else{
} else {
return JsonService::fail('操作失败!');
}
}
public function succ($id)
{
if(!UserExtractModel::be(['id'=>$id,'status'=>0]))
if (!UserExtractModel::be(['id' => $id, 'status' => 0]))
return JsonService::fail('操作记录不存在或状态错误!');
UserExtractModel::beginTrans();
$extract=UserExtractModel::get($id);
if(!$extract) return JsonService::fail('操作记录不存!');
if($extract->status == 1) return JsonService::fail('您已提现,请勿重复提现!');
if($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝!');
$extract = UserExtractModel::get($id);
if (!$extract) return JsonService::fail('操作记录不存!');
if ($extract->status == 1) return JsonService::fail('您已提现,请勿重复提现!');
if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝!');
$res = UserExtractModel::changeSuccess($id);
if($res){
if ($res) {
UserExtractModel::commitTrans();
return JsonService::successful('操作成功!');
}else{
} else {
UserExtractModel::rollbackTrans();
return JsonService::fail('操作失败!');
}
......
<?php
namespace app\admin\controller\finance;
use app\admin\controller\AuthController;
use app\admin\model\user\User;
use app\admin\model\user\UserRecharge as UserRechargeModel;
use app\admin\model\user\{User, UserRecharge as UserRechargeModel};
use app\models\routine\RoutineTemplate;
use app\models\user\UserBill;
use crmeb\services\JsonService;
use crmeb\services\MiniProgramService;
use crmeb\services\UtilService;
use crmeb\services\WechatService;
use crmeb\services\UtilService as Util;
use crmeb\services\JsonService as Json;
use app\models\user\{UserBill, WechatUser as WechatUserWap};
use crmeb\services\{JsonService,
MiniProgramService,
WechatService,
UtilService as Util,
FormBuilder as Form,
WechatTemplateService};
use think\facade\Route as Url;
use crmeb\services\FormBuilder as Form;
use crmeb\services\WechatTemplateService;
use app\models\user\WechatUser as WechatUserWap;
/**
* 微信充值记录
* Class UserRecharge
......@@ -25,112 +24,118 @@ class UserRecharge extends AuthController
/**
* 显示操作记录
*/
public function index(){
$this->assign( 'year',getMonth());
public function index()
{
$this->assign('year', get_month());
return $this->fetch();
}
public function get_user_recharge_list(){
$where = UtilService::getMore([
['data',''],
['paid',''],
['page',1],
['limit',20],
['nickname',''],
['excel',''],
public function get_user_recharge_list()
{
$where = Util::getMore([
['data', ''],
['paid', ''],
['page', 1],
['limit', 20],
['nickname', ''],
['excel', ''],
]);
return JsonService::successlayui(UserRechargeModel::getUserRechargeList($where));
}
public function delect($id = 0){
if(!$id) return JsonService::fail('缺少参数');
public function delect($id = 0)
{
if (!$id) return JsonService::fail('缺少参数');
$rechargInfo = UserRechargeModel::get($id);
if($rechargInfo->paid) return JsonService::fail('已支付的订单记录无法删除');
if(UserRechargeModel::del($id))
if ($rechargInfo->paid) return JsonService::fail('已支付的订单记录无法删除');
if (UserRechargeModel::del($id))
return JsonService::successful('删除成功');
else
return JsonService::fail('删除失败');
}
public function get_badge(){
$where = UtilService::getMore([
['data',''],
['paid',''],
['nickname',''],
public function get_badge()
{
$where = Util::getMore([
['data', ''],
['paid', ''],
['nickname', ''],
]);
return JsonService::successful(UserRechargeModel::getDataList($where));
}
/**退款
* @param $id
* @return mixed|void
*/
public function edit($id){
if(!$id) return $this->failed('数据不存在');
public function edit($id)
{
if (!$id) return $this->failed('数据不存在');
$UserRecharge = UserRechargeModel::get($id);
if(!$UserRecharge) return Json::fail('数据不存在!');
if($UserRecharge['paid'] == 1){
if (!$UserRecharge) return JsonService::fail('数据不存在!');
if ($UserRecharge['paid'] == 1) {
$f = array();
$f[] = Form::input('order_id','退款单号',$UserRecharge->getData('order_id'))->disabled(1);
$f[] = Form::number('refund_price','退款金额',$UserRecharge->getData('price'))->precision(2)->min(0)->max($UserRecharge->getData('price'));
$f[] = Form::input('order_id', '退款单号', $UserRecharge->getData('order_id'))->disabled(1);
$f[] = Form::number('refund_price', '退款金额', $UserRecharge->getData('price'))->precision(2)->min(0)->max($UserRecharge->getData('price'));
$jsContent = <<<SCRIPT
parent.SuccessFun();
parent.layer.close(parent.layer.getFrameIndex(window.name));
SCRIPT;
$form = Form::make_post_form('编辑',$f,Url::buildUrl('updateRefundY',array('id'=>$id)),$jsContent);
$form = Form::make_post_form('编辑', $f, Url::buildUrl('updateRefundY', array('id' => $id)), $jsContent);
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
else return Json::fail('数据不存在!');
} else return JsonService::fail('数据不存在!');
}
/**
* 退款更新
* @param $id
*/
public function updateRefundY($id){
public function updateRefundY($id)
{
$data = Util::postMore([
'refund_price',
]);
if(!$id) return $this->failed('数据不存在');
if (!$id) return $this->failed('数据不存在');
$UserRecharge = UserRechargeModel::get($id);
if(!$UserRecharge) return Json::fail('数据不存在!');
if($UserRecharge['price'] == $UserRecharge['refund_price']) return Json::fail('已退完支付金额!不能再退款了');
if(!$data['refund_price']) return Json::fail('请输入退款金额');
if (!$UserRecharge) return JsonService::fail('数据不存在!');
if ($UserRecharge['price'] == $UserRecharge['refund_price']) return JsonService::fail('已退完支付金额!不能再退款了');
if (!$data['refund_price']) return JsonService::fail('请输入退款金额');
$refund_price = $data['refund_price'];
$data['refund_price'] = bcadd($data['refund_price'],$UserRecharge['refund_price'],2);
$bj = bccomp((float)$UserRecharge['price'],(float)$data['refund_price'],2);
if($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额');
$data['refund_price'] = bcadd($data['refund_price'], $UserRecharge['refund_price'], 2);
$bj = bccomp((float)$UserRecharge['price'], (float)$data['refund_price'], 2);
if ($bj < 0) return JsonService::fail('退款金额大于支付金额,请修改退款金额');
$refund_data['pay_price'] = $UserRecharge['price'];
$refund_data['refund_price'] = $refund_price;
// $refund_data['refund_account']='REFUND_SOURCE_RECHARGE_FUNDS';
try{
$recharge_type = UserRechargeModel::where('order_id',$UserRecharge['order_id'])->value('recharge_type');
if($recharge_type == 'weixin'){
WechatService::payOrderRefund($UserRecharge['order_id'],$refund_data);
}else{
MiniProgramService::payOrderRefund($UserRecharge['order_id'],$refund_data);
try {
$recharge_type = UserRechargeModel::where('order_id', $UserRecharge['order_id'])->value('recharge_type');
if ($recharge_type == 'weixin') {
WechatService::payOrderRefund($UserRecharge['order_id'], $refund_data);
} else {
MiniProgramService::payOrderRefund($UserRecharge['order_id'], $refund_data);
}
}catch(\Exception $e){
return Json::fail($e->getMessage());
} catch (\Exception $e) {
return JsonService::fail($e->getMessage());
}
UserRechargeModel::edit($data,$id);
User::bcDec($UserRecharge['uid'],'now_money',$refund_price,'uid');
switch (strtolower($UserRecharge['recharge_type'])){
UserRechargeModel::edit($data, $id);
User::bcDec($UserRecharge['uid'], 'now_money', $refund_price, 'uid');
switch (strtolower($UserRecharge['recharge_type'])) {
case 'weixin':
WechatTemplateService::sendTemplate(WechatUserWap::where('uid',$UserRecharge['uid'])->value('openid'),WechatTemplateService::ORDER_REFUND_STATUS, [
'first'=>'亲,您充值的金额已退款,本次退款'.
$data['refund_price'].'金额',
'keyword1'=>$UserRecharge['order_id'],
'keyword2'=>$UserRecharge['price'],
'keyword3'=>date('Y-m-d H:i:s',$UserRecharge['add_time']),
'remark'=>'点击查看订单详情'
],Url::buildUrl('/user/bill/2')->suffix(false)->build());
WechatTemplateService::sendTemplate(WechatUserWap::where('uid', $UserRecharge['uid'])->value('openid'), WechatTemplateService::ORDER_REFUND_STATUS, [
'first' => '亲,您充值的金额已退款,本次退款' .
$data['refund_price'] . '金额',
'keyword1' => $UserRecharge['order_id'],
'keyword2' => $UserRecharge['price'],
'keyword3' => date('Y-m-d H:i:s', $UserRecharge['add_time']),
'remark' => '点击查看订单详情'
], Url::buildUrl('/user/bill/2')->suffix(false)->build());
break;
case 'routine':
RoutineTemplate::sendRechargeSuccess($UserRecharge,$data['refund_price']);
RoutineTemplate::sendRechargeSuccess($UserRecharge, $data['refund_price']);
break;
}
UserBill::expend('系统退款',$UserRecharge['uid'],'now_money','user_recharge_refund',$refund_price,$id,$UserRecharge['price'],'退款给用户'.$refund_price.'元');
return Json::successful('退款成功!');
UserBill::expend('系统退款', $UserRecharge['uid'], 'now_money', 'user_recharge_refund', $refund_price, $id, $UserRecharge['price'], '退款给用户' . $refund_price . '元');
return JsonService::successful('退款成功!');
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment