init
This commit is contained in:
commit
23a57c9625
|
|
@ -0,0 +1,39 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=homestead
|
||||
DB_USERNAME=homestead
|
||||
DB_PASSWORD=secret
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
* text=auto
|
||||
*.css linguist-vendored
|
||||
*.scss linguist-vendored
|
||||
*.js linguist-vendored
|
||||
CHANGELOG.md export-ignore
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/node_modules
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
/.idea
|
||||
/.vscode
|
||||
/.vagrant
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
.env
|
||||
upload/
|
||||
/config/host.php
|
||||
/config/nav.php
|
||||
/config/gateway.php
|
||||
/paylogs/*
|
||||
/datasql/*
|
||||
/config/merchant.php
|
||||
/config/merchant_ratio.php
|
||||
/public/index.html
|
||||
.user.ini
|
||||
/storage/collect/
|
||||
/storage/collect/*
|
||||
/storage/logs/*
|
||||
/app/certs/
|
||||
up.sh
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<title>404</title>
|
||||
<style>
|
||||
body{
|
||||
background-color:#444;
|
||||
font-size:14px;
|
||||
}
|
||||
h3{
|
||||
font-size:60px;
|
||||
color:#eee;
|
||||
text-align:center;
|
||||
padding-top:30px;
|
||||
font-weight:normal;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3>404,您请求的文件不存在!</h3>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,593 @@
|
|||
<?php
|
||||
|
||||
namespace App\Classc;
|
||||
|
||||
use Intervention\Image\Facades\Image;
|
||||
|
||||
/**
|
||||
* Created by phpstorm.
|
||||
* User: kongqi
|
||||
* Date: 2017/4/6
|
||||
* Time: 18:25
|
||||
*/
|
||||
class AnyUpload
|
||||
{
|
||||
private $fileField; //文件域名
|
||||
private $file; //文件上传对象
|
||||
private $base64; //文件上传对象
|
||||
private $config; //配置信息
|
||||
private $oriName; //原始文件名
|
||||
private $fileName; //新文件名
|
||||
private $fullName; //完整文件名,即从当前配置目录开始的URL
|
||||
private $filePath; //完整文件名,即从当前配置目录开始的URL
|
||||
private $fileSize; //文件大小
|
||||
private $fileType; //文件类型
|
||||
private $height = 0;
|
||||
private $width = 0;
|
||||
private $stateInfo; //上传状态信息,
|
||||
private $stateMap = array( //上传状态映射表,国际化用户需考虑此处数据的国际化
|
||||
"SUCCESS", //上传成功标记,在UEditor中内不可改变,否则flash判断会出错
|
||||
"文件大小超出 upload_max_filesize 限制",
|
||||
"文件大小超出 MAX_FILE_SIZE 限制",
|
||||
"文件未被完整上传",
|
||||
"没有文件被上传",
|
||||
"上传文件为空",
|
||||
"ERROR_TMP_FILE" => "临时文件错误",
|
||||
"ERROR_TMP_FILE_NOT_FOUND" => "找不到临时文件",
|
||||
"ERROR_SIZE_EXCEED" => "文件大小超出网站限制",
|
||||
"ERROR_TYPE_NOT_ALLOWED" => "文件类型不允许上传",
|
||||
"ERROR_CREATE_DIR" => "目录创建失败",
|
||||
"ERROR_DIR_NOT_WRITEABLE" => "目录没有写权限",
|
||||
"ERROR_FILE_MOVE" => "文件保存时出错",
|
||||
"ERROR_FILE_NOT_FOUND" => "找不到上传文件",
|
||||
"ERROR_WRITE_CONTENT" => "写入文件内容错误",
|
||||
"ERROR_UNKNOWN" => "未知错误",
|
||||
"ERROR_DEAD_LINK" => "链接不可用",
|
||||
"ERROR_HTTP_LINK" => "链接不是http链接",
|
||||
"ERROR_HTTP_CONTENTTYPE" => "链接contentType不正确",
|
||||
"INVALID_URL" => "非法 URL",
|
||||
"INVALID_IP" => "非法 IP"
|
||||
);
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
//$this->stateMap['ERROR_TYPE_NOT_ALLOWED'] = iconv('unicode', 'utf-8', $this->stateMap['ERROR_TYPE_NOT_ALLOWED']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileField 表单名称
|
||||
* @param array $config 配置项
|
||||
* @param bool $base64 是否解析base64编码,可省略。若开启,则$fileField代表的是base64编码的字符串表单名
|
||||
*/
|
||||
public function config($fileField = 'file', $config, $type = "upload"){
|
||||
|
||||
$this->fileField = $fileField;
|
||||
$this->config = $config;//获得配置信息
|
||||
$this->type = $type;//上传类型
|
||||
if ($type == "remote") {
|
||||
$this->saveRemote();
|
||||
}
|
||||
if ($type == "avatar") {
|
||||
$this->saveAvatar();
|
||||
} else if ($type == "base64") {
|
||||
$this->upBase64();
|
||||
} else {
|
||||
$this->upFile();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//压缩图片
|
||||
public function createThumb($info)
|
||||
{
|
||||
$file = $this->filePath;
|
||||
$quality = 100;
|
||||
$img = Image::make($file);
|
||||
//如果存在则设置固定大小
|
||||
|
||||
if (isset($info['w']) && isset($info['h'])) {
|
||||
$img->resize($info['w'], $info['h']);
|
||||
} elseif (isset($info['w'])) {
|
||||
//判断是否>
|
||||
if ($img->width() < $info['w']) {
|
||||
return false;
|
||||
}
|
||||
$img->widen($info['w']);
|
||||
} elseif (isset($info['h'])) {
|
||||
//判断是否>
|
||||
if ($img->height() < $info['h']) {
|
||||
return false;
|
||||
}
|
||||
$img->heighten(isset($info['h']));
|
||||
|
||||
|
||||
}
|
||||
$img->save($file, $quality);
|
||||
sleep(1);
|
||||
return $img->response('', $quality);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件的主处理方法
|
||||
* @return mixed
|
||||
*/
|
||||
private function upFile()
|
||||
{
|
||||
$file = $this->file = $_FILES[$this->fileField];
|
||||
if (!$file) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_FILE_NOT_FOUND");
|
||||
return;
|
||||
}
|
||||
if ($this->file['error']) {
|
||||
$this->stateInfo = $this->getStateInfo($file['error']);
|
||||
return;
|
||||
} else if (!file_exists($file['tmp_name'])) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_TMP_FILE_NOT_FOUND");
|
||||
return;
|
||||
} else if (!is_uploaded_file($file['tmp_name'])) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_TMPFILE");
|
||||
return;
|
||||
}
|
||||
|
||||
$this->oriName = $file['name'];
|
||||
$this->fileSize = $file['size'];
|
||||
|
||||
|
||||
|
||||
//检查是否不允许的文件格式
|
||||
|
||||
if (!$this->checkType()) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_TYPE_NOT_ALLOWED");
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fileType = $this->getFileExt();//获得文件类型
|
||||
$this->fullName = $this->getFullName();//获得新的文件名
|
||||
$this->filePath = $this->getFilePath();
|
||||
$this->fileName = $this->getFileName();
|
||||
$dirname = dirname($this->filePath);
|
||||
|
||||
//检查文件大小是否超出限制
|
||||
if (!$this->checkSize()) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_SIZE_EXCEED");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//创建目录失败
|
||||
if (!file_exists($dirname) && !mkdir($dirname, 0777, true)) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_CREATE_DIR");
|
||||
|
||||
return;
|
||||
} else if (!is_writeable($dirname)) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_DIR_NOT_WRITEABLE");
|
||||
return;
|
||||
}
|
||||
|
||||
//移动文件
|
||||
if (!(move_uploaded_file($file["tmp_name"], $this->filePath) && file_exists($this->filePath))) { //移动失败
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_FILE_MOVE");
|
||||
} else {
|
||||
//如果存在要压缩比例
|
||||
if (isset($this->config['thumbs'])) {
|
||||
$this->createThumbs($this->config['thumbs']);
|
||||
}
|
||||
$this->stateInfo = $this->stateMap[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理base64编码的图片上传
|
||||
* @return mixed
|
||||
*/
|
||||
private function upBase64()
|
||||
{
|
||||
$base64Data = trim($this->fileField);//$_POST[$this->fileField];
|
||||
$type = "base64.jpg";
|
||||
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64Data, $result)) {
|
||||
$img = base64_decode(str_replace($result[1], '', $base64Data));
|
||||
$type = "base64." . $result[2];
|
||||
}
|
||||
//$img = base64_decode($base64Data);
|
||||
//echo $img ;
|
||||
$this->oriName = $type;
|
||||
$this->fileSize = strlen($img);
|
||||
$this->fileType = $this->getFileExt();
|
||||
$this->fullName = $this->getFullName();
|
||||
$this->filePath = $this->getFilePath();
|
||||
$this->fileName = $this->getFileName();
|
||||
$dirname = dirname($this->filePath);
|
||||
|
||||
//检查文件大小是否超出限制
|
||||
if (!$this->checkSize()) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_SIZE_EXCEED");
|
||||
return;
|
||||
}
|
||||
|
||||
//创建目录失败
|
||||
if (!file_exists($dirname) && !mkdir($dirname, 0777, true)) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_CREATE_DIR");
|
||||
return;
|
||||
} else if (!is_writeable($dirname)) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_DIR_NOT_WRITEABLE");
|
||||
return;
|
||||
};
|
||||
//移动文件
|
||||
if (!(file_put_contents($this->filePath, $img) && file_exists($this->filePath))) { //移动失败
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_WRITE_CONTENT");
|
||||
} else { //移动成功
|
||||
$this->stateInfo = $this->stateMap[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取远程图片
|
||||
* @return mixed
|
||||
*/
|
||||
private function saveRemote()
|
||||
{
|
||||
$imgUrl = htmlspecialchars($this->fileField);
|
||||
$imgUrl = str_replace("&", "&", $imgUrl);
|
||||
|
||||
//http开头验证
|
||||
if (strpos($imgUrl, "http") !== 0) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_HTTP_LINK");
|
||||
return;
|
||||
}
|
||||
|
||||
preg_match('/(^https*:\/\/[^:\/]+)/', $imgUrl, $matches);
|
||||
$host_with_protocol = count($matches) > 1 ? $matches[1] : '';
|
||||
|
||||
// 判断是否是合法 url
|
||||
if (!filter_var($host_with_protocol, FILTER_VALIDATE_URL)) {
|
||||
$this->stateInfo = $this->getStateInfo("INVALID_URL");
|
||||
return;
|
||||
}
|
||||
|
||||
preg_match('/^https*:\/\/(.+)/', $host_with_protocol, $matches);
|
||||
$host_without_protocol = count($matches) > 1 ? $matches[1] : '';
|
||||
|
||||
// 此时提取出来的可能是 ip 也有可能是域名,先获取 ip
|
||||
$ip = gethostbyname($host_without_protocol);
|
||||
// 判断是否是私有 ip
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) {
|
||||
$this->stateInfo = $this->getStateInfo("INVALID_IP");
|
||||
return;
|
||||
}
|
||||
|
||||
//获取请求头并检测死链
|
||||
$heads = get_headers($imgUrl, 1);
|
||||
if (!(stristr($heads[0], "200") && stristr($heads[0], "OK"))) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_DEAD_LINK");
|
||||
return;
|
||||
}
|
||||
//格式验证(扩展名验证和Content-Type验证)
|
||||
$fileType = strtolower(strrchr($imgUrl, '.'));
|
||||
if (!in_array($fileType, $this->config['allowFiles']) || !isset($heads['Content-Type']) || !stristr($heads['Content-Type'], "image")) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_HTTP_CONTENTTYPE");
|
||||
return;
|
||||
}
|
||||
|
||||
//打开输出缓冲区并获取远程图片
|
||||
ob_start();
|
||||
$context = stream_context_create(
|
||||
array('http' => array(
|
||||
'follow_location' => false // don't follow redirects
|
||||
))
|
||||
);
|
||||
readfile($imgUrl, false, $context);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
preg_match("/[\/]([^\/]*)[\.]?[^\.\/]*$/", $imgUrl, $m);
|
||||
|
||||
$this->oriName = $m ? $m[1] : "";
|
||||
$this->fileSize = strlen($img);
|
||||
$this->fileType = $this->getFileExt();
|
||||
$this->fullName = $this->getFullName();
|
||||
$this->filePath = $this->getFilePath();
|
||||
$this->fileName = $this->getFileName();
|
||||
$dirname = dirname($this->filePath);
|
||||
|
||||
//检查文件大小是否超出限制
|
||||
if (!$this->checkSize()) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_SIZE_EXCEED");
|
||||
return;
|
||||
}
|
||||
|
||||
//创建目录失败
|
||||
if (!file_exists($dirname) && !mkdir($dirname, 0777, true)) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_CREATE_DIR");
|
||||
return;
|
||||
} else if (!is_writeable($dirname)) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_DIR_NOT_WRITEABLE");
|
||||
return;
|
||||
}
|
||||
|
||||
//移动文件
|
||||
if (!(file_put_contents($this->filePath, $img) && file_exists($this->filePath))) { //移动失败
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_WRITE_CONTENT");
|
||||
} else { //移动成功
|
||||
$this->stateInfo = $this->stateMap[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function saveAvatar()
|
||||
{
|
||||
$imgUrl = htmlspecialchars($this->fileField);
|
||||
$imgUrl = str_replace("&", "&", $imgUrl);
|
||||
|
||||
//http开头验证
|
||||
if (strpos($imgUrl, "http") !== 0) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_HTTP_LINK");
|
||||
return;
|
||||
}
|
||||
|
||||
preg_match('/(^https*:\/\/[^:\/]+)/', $imgUrl, $matches);
|
||||
$host_with_protocol = count($matches) > 1 ? $matches[1] : '';
|
||||
|
||||
// 判断是否是合法 url
|
||||
if (!filter_var($host_with_protocol, FILTER_VALIDATE_URL)) {
|
||||
$this->stateInfo = $this->getStateInfo("INVALID_URL");
|
||||
return;
|
||||
}
|
||||
|
||||
preg_match('/^https*:\/\/(.+)/', $host_with_protocol, $matches);
|
||||
$host_without_protocol = count($matches) > 1 ? $matches[1] : '';
|
||||
|
||||
// 此时提取出来的可能是 ip 也有可能是域名,先获取 ip
|
||||
$ip = gethostbyname($host_without_protocol);
|
||||
// 判断是否是私有 ip
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) {
|
||||
$this->stateInfo = $this->getStateInfo("INVALID_IP");
|
||||
return;
|
||||
}
|
||||
|
||||
//获取请求头并检测死链
|
||||
$heads = get_headers($imgUrl, 1);
|
||||
if (!(stristr($heads[0], "200") && stristr($heads[0], "OK"))) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_DEAD_LINK");
|
||||
return;
|
||||
}
|
||||
|
||||
//打开输出缓冲区并获取远程图片
|
||||
ob_start();
|
||||
$context = stream_context_create(
|
||||
array('http' => array(
|
||||
'follow_location' => false // don't follow redirects
|
||||
))
|
||||
);
|
||||
readfile($imgUrl, false, $context);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
preg_match("/[\/]([^\/]*)[\.]?[^\.\/]*$/", $imgUrl, $m);
|
||||
|
||||
$this->oriName = $m ? $m[1] : "";
|
||||
$this->fileSize = strlen($img);
|
||||
$this->fileType = $this->getFileExt();
|
||||
$this->fullName = $this->getFullName() . '.jpg';
|
||||
$this->filePath = $this->getFilePath();
|
||||
$this->fileName = $this->getFileName();
|
||||
$dirname = dirname($this->filePath);
|
||||
|
||||
//检查文件大小是否超出限制
|
||||
if (!$this->checkSize()) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_SIZE_EXCEED");
|
||||
return;
|
||||
}
|
||||
|
||||
//创建目录失败
|
||||
if (!file_exists($dirname) && !mkdir($dirname, 0777, true)) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_CREATE_DIR");
|
||||
return;
|
||||
} else if (!is_writeable($dirname)) {
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_DIR_NOT_WRITEABLE");
|
||||
return;
|
||||
}
|
||||
|
||||
//移动文件
|
||||
if (!(file_put_contents($this->filePath, $img) && file_exists($this->filePath))) { //移动失败
|
||||
$this->stateInfo = $this->getStateInfo("ERROR_WRITE_CONTENT");
|
||||
} else { //移动成功
|
||||
$this->stateInfo = $this->stateMap[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传错误检查
|
||||
* @param $errCode
|
||||
* @return string
|
||||
*/
|
||||
private function getStateInfo($errCode)
|
||||
{
|
||||
return !$this->stateMap[$errCode] ? $this->stateMap["ERROR_UNKNOWN"] : $this->stateMap[$errCode];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件扩展名
|
||||
* @return string
|
||||
*/
|
||||
private function getFileExt()
|
||||
{
|
||||
return strtolower(strrchr($this->oriName, '.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名文件
|
||||
* @return string
|
||||
*/
|
||||
private function getFullName()
|
||||
{
|
||||
$this->extToType();
|
||||
//替换日期事件
|
||||
$t = (time());
|
||||
$d = explode('-', date("Y-y-m-d-H-i-s"));
|
||||
$format = $this->config["pathFormat"];
|
||||
$format = str_replace("{yyyy}", $d[0], $format);
|
||||
$format = str_replace("{yy}", $d[1], $format);
|
||||
$format = str_replace("{mm}", $d[2], $format);
|
||||
$format = str_replace("{dd}", $d[3], $format);
|
||||
$format = str_replace("{hh}", $d[4], $format);
|
||||
$format = str_replace("{ii}", $d[5], $format);
|
||||
$format = str_replace("{ss}", $d[6], $format);
|
||||
if (isset($this->config['nameMd5'])) {
|
||||
$t = md5($t);
|
||||
}
|
||||
$format = str_replace("{time}", $t, $format);
|
||||
//过滤文件名的非法自负,并替换文件名
|
||||
$oriName = substr($this->oriName, 0, strrpos($this->oriName, '.'));
|
||||
$oriName = preg_replace("/[\|\?\"\<\>\/\*\\\\]+/", '', $oriName);
|
||||
|
||||
$format = str_replace("{filename}", $oriName, $format);
|
||||
|
||||
//替换随机字符串
|
||||
$randNum = mt_rand(1, 100000);
|
||||
|
||||
if (preg_match("/\{rand\:([\d]*)\}/i", $format, $matches)) {
|
||||
$format = preg_replace("/\{rand\:[\d]*\}/i", substr($randNum, 0, $matches[1]), $format);
|
||||
}
|
||||
|
||||
$ext = $this->getFileExt();
|
||||
$filename = ($format) . $ext;
|
||||
|
||||
/**/
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件名
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return substr($this->filePath, strrpos($this->filePath, '/') + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件完整路径
|
||||
* @return string
|
||||
*/
|
||||
private function getFilePath()
|
||||
{
|
||||
$fullname = $this->fullName;
|
||||
$rootPath = $_SERVER['DOCUMENT_ROOT'];
|
||||
|
||||
if (substr($fullname, 0, 1) != '/') {
|
||||
$fullname = '/' . $fullname;
|
||||
}
|
||||
|
||||
return $rootPath . $fullname;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件类型检测
|
||||
* @return bool
|
||||
*/
|
||||
private function checkType()
|
||||
{
|
||||
return in_array($this->getFileExt(), $this->config["allowFiles"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件大小检测
|
||||
* @return bool
|
||||
*/
|
||||
private function checkSize()
|
||||
{
|
||||
return $this->fileSize <= ($this->config["maxSize"]);
|
||||
}
|
||||
|
||||
private function getImageWH()
|
||||
{
|
||||
|
||||
if ($this->config['fileType'] == 'image') {
|
||||
$info = getimagesize($this->filePath);
|
||||
if (count($info) > 0) {
|
||||
$this->width = $info[0];
|
||||
$this->height = $info[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前上传成功文件的各项信息
|
||||
* @return array
|
||||
*/
|
||||
public function getFileInfo()
|
||||
{
|
||||
$this->getImageWH();
|
||||
|
||||
return array(
|
||||
"state" => $this->stateInfo,
|
||||
'success' => $this->stateInfo == 'SUCCESS' ? "1" : "0",
|
||||
"path" => $this->fullName,
|
||||
"filename" => $this->fileName,
|
||||
'tmpname' => $this->oriName,
|
||||
"abpath" => $this->filePath,
|
||||
"ext" => $this->fileType,
|
||||
'type' => $this->config['fileType'],
|
||||
"width" => $this->width,
|
||||
"height" => $this->height,
|
||||
"size" => round($this->fileSize / 1024),
|
||||
"sizepx" => $this->size(),
|
||||
'deletepath' => $this->deletePath(),
|
||||
'oss_url' => ''
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
public function extToType()
|
||||
{
|
||||
$file_suffix = [
|
||||
"image" => [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
|
||||
"vedio" => [".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
|
||||
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".wav", ".mid"],
|
||||
'zip' => ['.zip', '.tar.gz', '.rar', '.tar', ".7z", ".bz2", '.gz'],
|
||||
'mp3' => ['.mp3'],
|
||||
'office' => [".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt"],
|
||||
|
||||
];
|
||||
if (in_array($this->getFileExt(), $file_suffix['image'])) {
|
||||
$this->config['pathFormat'] = str_replace('file', 'image', $this->config['pathFormat']);
|
||||
$this->config['fileType'] = 'image';
|
||||
} elseif (in_array($this->getFileExt(), $file_suffix['vedio'])) {
|
||||
$this->config['pathFormat'] = str_replace('file', 'vedio', $this->config['pathFormat']);
|
||||
$this->config['fileType'] = 'vedio';
|
||||
} elseif (in_array($this->getFileExt(), $file_suffix['zip'])) {
|
||||
$this->config['pathFormat'] = str_replace('file', 'zip', $this->config['pathFormat']);
|
||||
$this->config['fileType'] = 'zip';
|
||||
} elseif (in_array($this->getFileExt(), $file_suffix['mp3'])) {
|
||||
$this->config['pathFormat'] = str_replace('file', 'mp3', $this->config['pathFormat']);
|
||||
$this->config['fileType'] = 'mp3';
|
||||
} elseif (in_array($this->getFileExt(), $file_suffix['office'])) {
|
||||
$this->config['pathFormat'] = str_replace('file', 'office', $this->config['pathFormat']);
|
||||
$this->config['fileType'] = 'office';
|
||||
} else {
|
||||
$this->config['fileType'] = 'file';
|
||||
}
|
||||
}
|
||||
|
||||
public function deletePath()
|
||||
{
|
||||
return str_replace("\\", "/", public_path()) . $this->fullName;
|
||||
}
|
||||
|
||||
public function size()
|
||||
{
|
||||
$size = $this->fileSize;
|
||||
$units = array(' B', ' KB', ' MB', ' GB', ' TB');
|
||||
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
|
||||
return round($size, 2) . $units[$i];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Classc;
|
||||
|
||||
|
||||
trait ScenicTrait
|
||||
{
|
||||
public static function bootScenicTrait()
|
||||
{
|
||||
static::deleting(function ($model) {
|
||||
if (method_exists($model, 'isForceDeleting') && ! $model->isForceDeleting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$model->tags()->detach();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
namespace App\Classc;
|
||||
|
||||
use App\Services\SearchServices;
|
||||
|
||||
trait SearchScopeTrait
|
||||
{
|
||||
public function scopeSearch($query,array $arr, $where = 2)
|
||||
{
|
||||
|
||||
if(count($arr)<=0){
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($arr as $k => $v) {
|
||||
|
||||
if ($where == 1) {
|
||||
$where_value = 1;
|
||||
} elseif($where == 3) {
|
||||
if(empty(trim($v['value'])))
|
||||
{
|
||||
$where_value=0;
|
||||
|
||||
}else
|
||||
{
|
||||
$where_value=1;
|
||||
}
|
||||
|
||||
if($v['value']=='0')
|
||||
{
|
||||
$where_value=1;
|
||||
}
|
||||
|
||||
|
||||
}else
|
||||
{
|
||||
if(empty(trim($v['value'])))
|
||||
{
|
||||
$where_value=0;
|
||||
|
||||
}else
|
||||
{
|
||||
$where_value=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($where_value==1) {
|
||||
if($v['value']=='' && $v['value']!=0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ($v['type'] == '=') {
|
||||
|
||||
$query->where($k, $v['value']);
|
||||
|
||||
}
|
||||
if ($v['type'] == 'in') {
|
||||
$query->whereIn($k, $v['value']);
|
||||
|
||||
}
|
||||
if ($v['type'] == '>') {
|
||||
$query->where($k,'>' ,$v['value']);
|
||||
|
||||
}
|
||||
if ($v['type'] == '>=') {
|
||||
$query->where($k,'>=' ,$v['value']);
|
||||
|
||||
}
|
||||
if ($v['type'] == '<>') {
|
||||
$query->where($k,'<>' ,$v['value']);
|
||||
|
||||
}
|
||||
if ($v['type'] == '<') {
|
||||
$query->where($k,'<' ,$v['value']);
|
||||
|
||||
}
|
||||
if ($v['type'] == '<=') {
|
||||
$query->where($k,'<=' ,$v['value']);
|
||||
|
||||
}
|
||||
if ($v['type'] == 'between') {
|
||||
$query->whereBetween($k,$v['value']);
|
||||
|
||||
}
|
||||
if ($v['type'] == 'raw') {
|
||||
//dd($v['value'][0]);
|
||||
|
||||
$query->whereRaw($v['value'][0],[$v['value'][1]]);
|
||||
|
||||
}
|
||||
if ($v['type'] == 'like') {
|
||||
$query->whereRaw($k . ' like ?', ["%" . $v['value'] . "%"]);
|
||||
|
||||
}
|
||||
if ($v['type'] == 'likesql') {
|
||||
$query->whereRaw($v['value']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public static function getList($is_checked = 1, $field = '')
|
||||
{
|
||||
if (!$is_checked) {
|
||||
if ($field == 'keyvalue') {
|
||||
return self::pluck('name', 'id');
|
||||
}
|
||||
return self::get();
|
||||
}
|
||||
return self::where('is_checked', 1)->get();
|
||||
}
|
||||
public function getCheckNameAttribute()
|
||||
{
|
||||
$arr=['不通过','通过'];
|
||||
|
||||
return $arr[$this->is_checked];
|
||||
}
|
||||
public static function getSearchModel($model,$data,$type=''){
|
||||
// print_r($data);
|
||||
$search= new SearchServices($model,$data,$type);
|
||||
return $search->getModel();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
<?php
|
||||
|
||||
namespace App\Classc;
|
||||
|
||||
use App\Models\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Auth;
|
||||
use AnyUpload;
|
||||
|
||||
class UploadFile
|
||||
{
|
||||
public static function config($type = 'images')
|
||||
{
|
||||
$config = [
|
||||
'fileType' => $type,
|
||||
'nameMd5' => 'md5',
|
||||
"maxSize" => 204800000, /* 上传大小限制,单位B */
|
||||
"compressEnable" => true, /* 是否压缩图片,默认是true */
|
||||
"urlPrefix" => "", /* 图片访问路径前缀 */
|
||||
"pathFormat" => config('adconfig.upload_path') . "/images/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
];
|
||||
switch ($type) {
|
||||
case 'image':
|
||||
$config['allowFiles'] = [".png", ".jpg", ".jpeg", ".gif", ".bmp"];
|
||||
break;
|
||||
case 'zip':
|
||||
$config['allowFiles'] = ['zip', ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2"];
|
||||
$config['maxSize'] = 52428800;//50M
|
||||
$config['pathFormat'] = config('adconfig.upload_path') . "/zips/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
break;
|
||||
case
|
||||
'file':
|
||||
$config['allowFiles'] = [
|
||||
".png", ".jpg", ".jpeg", ".gif", ".bmp",
|
||||
".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".wmv",
|
||||
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
|
||||
".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
|
||||
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml", ".psd", ".ai", ".cdr",
|
||||
".cer", ".p12",".pem"
|
||||
];
|
||||
$config['pathFormat'] = config('adconfig.upload_path') . "/files/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
break;
|
||||
case 'vedio':
|
||||
$config['allowFiles'] = [".mp4"];
|
||||
$config['pathFormat'] = config('adconfig.upload_path') . "/vedios/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
break;
|
||||
case 'excel':
|
||||
$config['allowFiles'] = [
|
||||
".xls", ".xlsx"
|
||||
];
|
||||
$config['pathFormat'] = config('adconfig.upload_path') . "/excels/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
break;
|
||||
default:
|
||||
$config['allowFiles'] = [".png", ".jpg", ".jpeg", ".gif", ".bmp"];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function remote($filename = "file", $type = 'image', $is_oss = '', $uptype)
|
||||
{
|
||||
$config = self::config($type);
|
||||
$up = AnyUpload::config($filename, $config, $uptype);
|
||||
$result = AnyUpload::getFileInfo();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function uploadBase64($filename = "file", $is_oss = '', $source = 'admin')
|
||||
{
|
||||
$config = self::config('image');
|
||||
$up = AnyUpload::config($filename, $config, 'base64');
|
||||
$result = $up->getFileInfo();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public static function addFileDb($result, $type = 'admin')
|
||||
{
|
||||
//存如数据库
|
||||
if ($type == 'user') {
|
||||
$create_id = 0;
|
||||
$create_type = 'user';
|
||||
} else {
|
||||
$create_id = 1;//admin('id');
|
||||
$create_type = 'admin';
|
||||
}
|
||||
$data = [
|
||||
'oss_type' => $result['oss_type'],
|
||||
'path' => $result['path'],
|
||||
'filename' => $result['filename'],
|
||||
'size' => $result['size'],
|
||||
'tmp' => $result['tmpname'],
|
||||
'user_id' => $create_id,
|
||||
'user_type' => $create_type,
|
||||
'type' => $result['type']
|
||||
];
|
||||
return File::add($data);
|
||||
}
|
||||
|
||||
public static function addOss($aburl, $url)
|
||||
{
|
||||
$r = Storage::put($url, file_get_contents($aburl));
|
||||
return $r;
|
||||
}
|
||||
|
||||
public static function upload($filename = "file", $type = 'image', $method = 'image', $thumbs = [], $is_oss = false)
|
||||
{
|
||||
|
||||
$config = self::config($type);
|
||||
//判断是否压缩图片,
|
||||
if (count($thumbs) > 0) {
|
||||
$config['thumbs'] = $thumbs;
|
||||
}
|
||||
//dd($config);
|
||||
$up = AnyUpload::config($filename, $config, $method);
|
||||
$result = AnyUpload::getFileInfo();
|
||||
if ($result['success'] == 1) {
|
||||
$result['oss_type'] = 'local';
|
||||
$is_oss = $is_oss ? $is_oss : config('adconfig.is_oss');
|
||||
//如果是OSS
|
||||
if ($is_oss == 1) {
|
||||
$result['oss_type'] = 'oss';
|
||||
if (self::addOss($result['abpath'], $result['path'])) {
|
||||
self::deleteLocalFile($result['path'], 0);//删除自己路径
|
||||
$result['oss_url'] = Storage::url($result['path']);
|
||||
}
|
||||
|
||||
}
|
||||
self::addFileDb($result);//入库
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function uploadUser($filename = "file", $type = 'image', $method = 'image', $thumbs = [], $is_oss = false)
|
||||
{
|
||||
|
||||
$config = self::config($type);
|
||||
//判断是否压缩图片,
|
||||
if (count($thumbs) > 0) {
|
||||
$config['thumbs'] = $thumbs;
|
||||
}
|
||||
|
||||
$up = AnyUpload::config($filename, $config, $method);
|
||||
$result = $up->getFileInfo();
|
||||
if ($result['success'] == 1) {
|
||||
$result['storage'] = 1;
|
||||
if ($method != 'avatar') {
|
||||
self::addFileDb($result, 'user');//入库
|
||||
}
|
||||
|
||||
$is_oss = $is_oss ? $is_oss : config('website.is_oss');
|
||||
//如果是OSS
|
||||
if ($is_oss == 1) {
|
||||
$result['storage'] = 2;
|
||||
if (self::addOss($result['abpath'], $result['path'])) {
|
||||
self::deleteLocalFile($result['path'], 0);//删除自己路径
|
||||
$result['oss_url'] = Storage::url($result['path']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function deleteLocalFile($filepath, $del_db = 1)
|
||||
{
|
||||
if (is_array($filepath)) {
|
||||
foreach ($filepath as $v) {
|
||||
self::deleteLocalFile($v);
|
||||
}
|
||||
}
|
||||
$ofilename = $filepath;
|
||||
//附加前缀
|
||||
$filepath = str_replace("\\", "/", public_path()) . $filepath;
|
||||
if (is_dir($filepath)) {
|
||||
return false;
|
||||
} elseif (file_exists($filepath)) {
|
||||
$r = unlink($filepath);
|
||||
if ($r) {
|
||||
if ($del_db) {
|
||||
File::where('path', $ofilename)->delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function deleteOssFile($filepath)
|
||||
{
|
||||
$filepath = is_array($filepath) ? $filepath : [$filepath];
|
||||
$r = Storage::delete($filepath);
|
||||
if ($r) {
|
||||
//从数据库里面删除
|
||||
File::whereIn('path', $filepath)->delete();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function deleteFile($url = '', $is_oss = 0)
|
||||
{
|
||||
$is_oss = $is_oss ? $is_oss : config('adconfig.is_oss');
|
||||
if ($is_oss) {
|
||||
return self::deleteOssFile($url);
|
||||
} else {
|
||||
return self::deleteLocalFile($url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
<?php
|
||||
namespace App\Classc;
|
||||
|
||||
use App\Models\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Auth;
|
||||
use AnyUpload;
|
||||
class UploadShopFile
|
||||
{
|
||||
public static function config($type = 'images')
|
||||
{
|
||||
$path=config('adconfig.upload_path').'/shop'.admin_shop('id').'';
|
||||
$config = [
|
||||
'fileType' => $type,
|
||||
'nameMd5'=>'md5',
|
||||
"maxSize" => 204800000, /* 上传大小限制,单位B */
|
||||
"compressEnable" => true, /* 是否压缩图片,默认是true */
|
||||
"urlPrefix" => "", /* 图片访问路径前缀 */
|
||||
"pathFormat" => $path . "/images/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
];
|
||||
switch ($type) {
|
||||
case 'image':
|
||||
$config['allowFiles'] = [".png", ".jpg", ".jpeg", ".gif", ".bmp"];
|
||||
break;
|
||||
case 'zip':
|
||||
$config['allowFiles'] = ['zip', ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2"];
|
||||
$config['maxSize']=52428800;//50M
|
||||
$config['pathFormat'] = $path . "/zips/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
break;
|
||||
case
|
||||
'file':
|
||||
$config['allowFiles'] = [
|
||||
".png", ".jpg", ".jpeg", ".gif", ".bmp",
|
||||
".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".wmv",
|
||||
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
|
||||
".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
|
||||
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml",".psd",".ai",".cdr"
|
||||
];
|
||||
$config['pathFormat'] = $path . "/files/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
break;
|
||||
case 'vedio':
|
||||
$config['allowFiles'] = [".mp4"];
|
||||
$config['pathFormat'] = $path . "/vedios/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
break;
|
||||
case 'excel':
|
||||
$config['allowFiles'] = [
|
||||
".xls", ".xlsx"
|
||||
];
|
||||
$config['pathFormat'] = $path . "/excels/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
|
||||
break;
|
||||
default:
|
||||
$config['allowFiles'] = [".png", ".jpg", ".jpeg", ".gif", ".bmp"];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $config;
|
||||
}
|
||||
public static function remote($filename = "file", $type = 'image', $is_oss = '', $uptype){
|
||||
$config = self::config($type);
|
||||
$up = AnyUpload::config($filename, $config,$uptype);
|
||||
$result = AnyUpload::getFileInfo();
|
||||
return $result;
|
||||
}
|
||||
public static function uploadBase64($filename="file",$is_oss='',$source='admin'){
|
||||
$config = self::config('image');
|
||||
$up = AnyUpload::config($filename, $config,'base64');
|
||||
$result = $up->getFileInfo();
|
||||
return $result;
|
||||
|
||||
}
|
||||
public static function addFileDb($result,$type='user'){
|
||||
//存如数据库
|
||||
if($type=='user')
|
||||
{
|
||||
$create_id=admin_shop('id');
|
||||
$create_type='user';
|
||||
}else
|
||||
{
|
||||
$create_id=1;//admin('id');
|
||||
$create_type='admin';
|
||||
}
|
||||
$data = [
|
||||
'oss_type' => $result['oss_type'],
|
||||
'path' => $result['path'],
|
||||
'filename' => $result['filename'],
|
||||
'size' => $result['size'],
|
||||
'tmp' => $result['tmpname'],
|
||||
'user_id'=>$create_id,
|
||||
'user_type'=>$create_type,
|
||||
'type'=>$result['type'],
|
||||
'create_type'=>'adminshop',
|
||||
'screen_type'=>$result['screen_type']
|
||||
];
|
||||
return File::add($data);
|
||||
}
|
||||
|
||||
public static function addOss($aburl,$url){
|
||||
$r=Storage::put($url, file_get_contents($aburl));
|
||||
return $r;
|
||||
}
|
||||
public static function upload($filename = "file", $type = 'image',$method='image',$screen_type='',$thumbs=[], $is_oss =false)
|
||||
{
|
||||
|
||||
$config = self::config($type);
|
||||
//判断是否压缩图片,
|
||||
if(count($thumbs)>0)
|
||||
{
|
||||
$config['thumbs']=$thumbs;
|
||||
}
|
||||
//dd($config);
|
||||
AnyUpload::config($filename, $config,$method);
|
||||
$result = AnyUpload::getFileInfo();
|
||||
$result['screen_type']=$screen_type;
|
||||
if ($result['success']==1) {
|
||||
$result['oss_type']='local';
|
||||
$is_oss=$is_oss?$is_oss:config('adconfig.is_oss');
|
||||
//如果是OSS
|
||||
if ($is_oss == 1) {
|
||||
$result['oss_type']='oss';
|
||||
if(self::addOss($result['abpath'],$result['path'])){
|
||||
self::deleteLocalFile($result['path'],0);//删除自己路径
|
||||
$result['oss_url']=Storage::url($result['path']);
|
||||
}
|
||||
|
||||
}
|
||||
self::addFileDb($result);//入库
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public static function uploadUser($filename = "file", $type = 'image',$method='image',$thumbs=[], $is_oss =false)
|
||||
{
|
||||
|
||||
$config = self::config($type);
|
||||
//判断是否压缩图片,
|
||||
if(count($thumbs)>0)
|
||||
{
|
||||
$config['thumbs']=$thumbs;
|
||||
}
|
||||
|
||||
$up = AnyUpload::config($filename, $config,$method);
|
||||
$result = $up->getFileInfo();
|
||||
if ($result['success']==1) {
|
||||
$result['storage']=1;
|
||||
if($method!='avatar')
|
||||
{
|
||||
self::addFileDb($result,'user');//入库
|
||||
}
|
||||
|
||||
$is_oss=$is_oss?$is_oss:config('website.is_oss');
|
||||
//如果是OSS
|
||||
if ($is_oss == 1) {
|
||||
$result['storage']=2;
|
||||
if(self::addOss($result['abpath'],$result['path'])){
|
||||
self::deleteLocalFile($result['path'],0);//删除自己路径
|
||||
$result['oss_url']=Storage::url($result['path']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public static function deleteLocalFile($filepath,$del_db=1){
|
||||
if(is_array($filepath))
|
||||
{
|
||||
foreach ($filepath as $v)
|
||||
{
|
||||
self::deleteLocalFile($v);
|
||||
}
|
||||
}
|
||||
$ofilename=$filepath;
|
||||
//附加前缀
|
||||
$filepath=str_replace("\\","/",public_path()).$filepath;
|
||||
if (is_dir($filepath)) {
|
||||
return false;
|
||||
} elseif (file_exists($filepath)) {
|
||||
$r = unlink($filepath);
|
||||
if ($r) {
|
||||
if($del_db)
|
||||
{
|
||||
File::where('path',$ofilename)->delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public static function deleteOssFile($filepath){
|
||||
$filepath=is_array($filepath)?$filepath:[$filepath];
|
||||
$r=Storage::delete($filepath);
|
||||
if($r)
|
||||
{
|
||||
//从数据库里面删除
|
||||
File::whereIn('path',$filepath)->delete();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function deleteFile($url='',$is_oss=0)
|
||||
{
|
||||
$is_oss=$is_oss?$is_oss:config('adconfig.is_oss');
|
||||
if($is_oss)
|
||||
{
|
||||
return self::deleteOssFile($url);
|
||||
}else
|
||||
{
|
||||
return self::deleteLocalFile($url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
namespace App\Classc;
|
||||
use Validator;
|
||||
|
||||
trait ValidationTrait {
|
||||
|
||||
public function verify($input, $config)
|
||||
{
|
||||
$arr = config('validation.'.$config);
|
||||
|
||||
$rules = $name = $message = [];
|
||||
|
||||
foreach ($arr as $key => $val)
|
||||
{
|
||||
$rules[$key] = $val['rules'];
|
||||
$name[$key] = $val['name'];
|
||||
if (isset($val['message']) && is_array($val['message']) && !empty($val['message']))
|
||||
{
|
||||
foreach($val['message'] as $k => $v)
|
||||
{
|
||||
|
||||
$message[$key.'.'.$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$validator = Validator::make(
|
||||
$input->all(),
|
||||
$rules,
|
||||
$message,
|
||||
$name
|
||||
);
|
||||
|
||||
return $validator;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace App\Classc;
|
||||
|
||||
|
||||
class WxBizDataCrypt
|
||||
{
|
||||
private $appid;
|
||||
private $sessionKey;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param $sessionKey string 用户在小程序登录后获取的会话密钥
|
||||
* @param $appid string 小程序的appid
|
||||
*/
|
||||
public function __construct( $appid, $sessionKey)
|
||||
{
|
||||
$this->sessionKey = $sessionKey;
|
||||
$this->appid = $appid;
|
||||
}
|
||||
public function error($code)
|
||||
{
|
||||
switch ($code) {
|
||||
case 'IllegalAesKey':
|
||||
# code...
|
||||
return '-41001';
|
||||
break;
|
||||
case 'IllegalIv':
|
||||
# code...
|
||||
return '-41002';
|
||||
break;
|
||||
case 'IllegalBuffer':
|
||||
# code...
|
||||
return '-41003';
|
||||
break;
|
||||
case 'DecodeBase64Error':
|
||||
# code...
|
||||
return '-41004';
|
||||
break;
|
||||
case 'OK':
|
||||
# code...
|
||||
return '0';
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检验数据的真实性,并且获取解密后的明文.
|
||||
* @param $encryptedData string 加密的用户数据
|
||||
* @param $iv string 与用户数据一同返回的初始向量
|
||||
* @param $data string 解密后的原文
|
||||
*
|
||||
* @return int 成功0,失败返回对应的错误码
|
||||
*/
|
||||
public function decryptData( $encryptedData, $iv, &$data )
|
||||
{
|
||||
|
||||
if (strlen($this->sessionKey) != 24) {
|
||||
|
||||
|
||||
return $this->error('IllegalAesKey');
|
||||
}
|
||||
$aesKey=base64_decode($this->sessionKey);
|
||||
|
||||
|
||||
if (strlen($iv) != 24) {
|
||||
|
||||
return $this->error('IllegalIv');
|
||||
}
|
||||
$aesIV=base64_decode($iv);
|
||||
|
||||
$aesCipher=base64_decode($encryptedData);
|
||||
|
||||
$result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
|
||||
|
||||
$dataObj=json_decode( $result );
|
||||
if( $dataObj == NULL )
|
||||
{
|
||||
|
||||
|
||||
return $this->error('IllegalBuffer');
|
||||
}
|
||||
if( $dataObj->watermark->appid != $this->appid )
|
||||
{
|
||||
|
||||
return $this->error('IllegalBuffer');
|
||||
|
||||
}
|
||||
$data = $result;
|
||||
return $this->error('OK');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Models\CouponCard;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
class CouponCardEvent
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public $active_id;
|
||||
public $number;
|
||||
public function __construct(CouponCard $card,$number)
|
||||
{
|
||||
//找到活动
|
||||
$this->active_id=$card->active_id;
|
||||
$this->number=$number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
class Event
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
class SendSmsEvent
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public $config;
|
||||
public $tpl_id;
|
||||
public $screen;
|
||||
public function __construct($config)
|
||||
{
|
||||
$this->config=$config;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
|
||||
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
if ($exception instanceof \Illuminate\Http\Exceptions\PostTooLargeException) {
|
||||
return ['error'=>1,'msg'=>'上传数据太大,请上传符合固定的尺寸大小'];
|
||||
}
|
||||
// if ($exception instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
|
||||
// return ['error'=>1,'msg'=>'非法请求'];
|
||||
// }
|
||||
// if ($exception instanceof \Symfony\Component\Debug\Exception\FatalThrowableError) {
|
||||
// return ['error'=>1,'msg'=>'非法请求'];
|
||||
// }
|
||||
|
||||
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class AnyUploadFacades extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'anyupload';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class PayServiceFacades extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'pay_services';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Admin;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
|
||||
class AdminController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '管理员'
|
||||
];
|
||||
}
|
||||
public function indexData(){
|
||||
|
||||
return $this->shareData();
|
||||
}
|
||||
public function shareData($show='')
|
||||
{
|
||||
$permissions = Role::where('guard_name',$this->guard_name)->get();
|
||||
return ['role'=>$permissions];
|
||||
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'account' => 'required|unique:admins,account',
|
||||
'password' =>'required',
|
||||
'mobile' =>'required',
|
||||
'realname' =>'required',
|
||||
];
|
||||
}
|
||||
return [
|
||||
'account' => 'required|unique:admins,account,' . $id,
|
||||
'mobile' =>'required',
|
||||
'realname' =>'required'
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
'name.required' => ':attribute必填',
|
||||
'permissions.required' => '权限规则必填',
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Admin();
|
||||
}
|
||||
public function saveAfter($request,$model,$id='')
|
||||
{
|
||||
$roles = $request->input('roles');
|
||||
if($id)
|
||||
{
|
||||
// 检查是否某个角色被选中
|
||||
if (isset($roles)) {
|
||||
$model->roles()->sync($roles);
|
||||
//$admin->syncRoles($roles);
|
||||
}else
|
||||
{
|
||||
$model->roles()->detach(); // 如果没有选择任何与用户关联的角色则将之前关联角色解除
|
||||
}
|
||||
}else
|
||||
{
|
||||
|
||||
if (!empty($roles)) { // 如果选择了角色
|
||||
// 检查是否某个角色被选中
|
||||
$role_r = Role::whereIn('id', $roles)->pluck('id');
|
||||
$model->assignRole($role_r); //Assigning role to user
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
protected function postDataDb($request,$id=''){
|
||||
|
||||
$data=$request->all();
|
||||
if(!$request->input('password'))
|
||||
{
|
||||
unset($data['password']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$mobile = $request->input('mobile', '');
|
||||
$account = $request->input('account', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
$role=$request->input('role','');
|
||||
|
||||
$search_arr=[
|
||||
'mobile'=>[
|
||||
'type'=>'like',
|
||||
'value'=>$mobile
|
||||
],
|
||||
'account'=>[
|
||||
'type'=>'like',
|
||||
'value'=>$account
|
||||
]
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
if($role)
|
||||
{
|
||||
|
||||
$model=$model->whereHas('roles', function ($query) use($role) {
|
||||
$query->where('id', $role);
|
||||
});
|
||||
}
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['roles_name']=$v->roles()->pluck('name');
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Validator;
|
||||
|
||||
class AdminPermissionController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '权限'
|
||||
];
|
||||
|
||||
}
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'cnname' => 'required|unique:permissions,name',
|
||||
'name' => 'required'
|
||||
];
|
||||
}
|
||||
return [
|
||||
'cnname' => 'required|unique:permissions,name,' . $id,
|
||||
'name' => 'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
'name.required' => ':attribute必填',
|
||||
'url.required' => '路径必填',
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Permission();
|
||||
}
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$key = $request->input('search', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
if ($key != '') {
|
||||
$model = $model->whereRaw('name like ?', ['%' . $key . '%']);
|
||||
}
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get()->toArray();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v['id']]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v['id']]);
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class AdminRoleController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '角色'
|
||||
];
|
||||
}
|
||||
public function shareData($show='')
|
||||
{
|
||||
$permissions = Permission::where('guard_name',$this->guard_name)->get();
|
||||
return ['permission'=>$permissions];
|
||||
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required|unique:roles,name',
|
||||
'permissions' =>'required',
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required|unique:roles,name,' . $id,
|
||||
'permissions' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
'name.required' => ':attribute必填',
|
||||
'permissions.required' => '权限规则必填',
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Role();
|
||||
}
|
||||
public function saveAfter($request,$model,$id='')
|
||||
{
|
||||
$permissions = $request->input('permissions');
|
||||
if($id)
|
||||
{
|
||||
$p_all = Permission::where('guard_name',$this->guard_name)->pluck('id');//获取所有权限
|
||||
$p = Permission::whereIn('id', $permissions)->pluck('id');
|
||||
|
||||
//移除
|
||||
$model->revokePermissionTo($p_all);
|
||||
//附加
|
||||
$model->givePermissionTo($p);
|
||||
}else
|
||||
{
|
||||
|
||||
$p = Permission::whereIn('id', $permissions)->pluck('id');
|
||||
$model->givePermissionTo($p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$key = $request->input('search', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
if ($key != '') {
|
||||
$model = $model->whereRaw('name like ?', ['%' . $key . '%']);
|
||||
}
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('permissions')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['perssions']=$v->permissions()->pluck('name');
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,307 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Area;
|
||||
use App\Models\DrawMoney;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Order;
|
||||
use App\Models\Shop;
|
||||
use App\Models\ShopServer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Ixudra\Curl\Facades\Curl;
|
||||
|
||||
class ApiController extends BaseController
|
||||
{
|
||||
//
|
||||
public function index($type, $name, Request $request)
|
||||
{
|
||||
|
||||
switch ($type) {
|
||||
case 'map':
|
||||
return $this->map($name);
|
||||
break;
|
||||
case 'area':
|
||||
return $this->area($request);
|
||||
break;
|
||||
case 'user':
|
||||
return $this->uerList($name, $request);
|
||||
break;
|
||||
case 'shop':
|
||||
return $this->shopList($name, $request);
|
||||
break;
|
||||
case 'shop_and_user':
|
||||
return $this->shopUserAndList($name, $request);
|
||||
break;
|
||||
case 'merchant':
|
||||
return $this->merchantList($name, $request);
|
||||
break;
|
||||
case 'create_key':
|
||||
return $this->createKey($request);
|
||||
break;
|
||||
case 'orderMp3':
|
||||
return $this->orderCheck($request);
|
||||
break;
|
||||
case 'draw':
|
||||
return $this->orderDraw($request);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function orderCheck()
|
||||
{
|
||||
//120
|
||||
$vedio = [];
|
||||
$pay = Order::whereIn('pay_type', config('adconfig.guma_type'))->where('pay_status', 0)->where('status',0)->get();
|
||||
$config_type=config('adconfig.pay_type');
|
||||
$mp3_str='';
|
||||
if (count($pay)) {
|
||||
foreach ($pay as $k => $v) {
|
||||
$str=$mp3_str.=$config_type[$v->pay_type].'充值'.$v->order_money.'元';
|
||||
$data = [
|
||||
'type' => 'tns',
|
||||
'spd' => '5',
|
||||
'pit' => '5'
|
||||
, 'vol' => '5'
|
||||
, 'per' => '0'
|
||||
,'tex'=>$str
|
||||
];
|
||||
|
||||
$vedio[]=[
|
||||
'mp3'=>'http://tts.baidu.com/text2audio?lan=zh&per=4&spd=5&pit=5&type=tns&ie=UTF-8&text='.urlencode($str),
|
||||
'msg'=>$str,
|
||||
'error'=>0
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$data=[
|
||||
'error'=>0,
|
||||
'msg'=>$mp3_str,
|
||||
'data'=>$vedio
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
public function orderDraw()
|
||||
{
|
||||
//120
|
||||
$vedio = [];
|
||||
$pay = DrawMoney::where('status',0)->get();
|
||||
|
||||
$mp3_str='';
|
||||
if (count($pay)) {
|
||||
foreach ($pay as $k => $v) {
|
||||
$str=$mp3_str.='商户提现'.$v->draw_money;
|
||||
|
||||
|
||||
$vedio[]=[
|
||||
'mp3'=>'http://tts.baidu.com/text2audio?lan=zh&per=4&spd=5&pit=5&type=tns&ie=UTF-8&text='.urlencode($str),
|
||||
'msg'=>$str,
|
||||
'error'=>0
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$data=[
|
||||
'error'=>0,
|
||||
'msg'=>$mp3_str,
|
||||
'data'=>$vedio
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function createKey(Request $request)
|
||||
{
|
||||
if ($request->input('type_name') == 'appkey') {
|
||||
$number = date('YmdHis') . str_random(6);
|
||||
|
||||
}
|
||||
if ($request->input('type_name') == 'token') {
|
||||
$number = str_random(32);
|
||||
|
||||
}
|
||||
return response(['error' => 0, 'msg' => '生成成功', 'number' => $number]);
|
||||
}
|
||||
|
||||
public function map($name)
|
||||
{
|
||||
$this->setViewPath('map', $name);
|
||||
return $this->display();
|
||||
}
|
||||
|
||||
public function area($request)
|
||||
{
|
||||
$input_type = $request->input('input_type', 'option');
|
||||
$select_id = $request->input('select_id', '');
|
||||
$list = Area::where('parent_id', $request->input('id', 0))->pluck('name', 'id')->toArray();
|
||||
$html_str = '';
|
||||
switch ($input_type) {
|
||||
case 'option':
|
||||
$html_str = ' <option value=""></option>';
|
||||
foreach ($list as $k => $v) {
|
||||
$html_str .= '<option ' . ($select_id == $k ? "selected" : "") . ' value="' . $k . '">' . $v . '</option>';
|
||||
}
|
||||
return ['data' => $html_str];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function uerList($name, Request $request)
|
||||
{
|
||||
$json = $request->input('json');
|
||||
|
||||
if ($json) {
|
||||
|
||||
return $this->apiJson(new User(), 'user', $request);
|
||||
}
|
||||
|
||||
$this->setViewPath('user', 'index');
|
||||
|
||||
return $this->display(['group_type' => $name]);
|
||||
}
|
||||
|
||||
protected function merchantList($name, Request $request)
|
||||
{
|
||||
$json = $request->input('json');
|
||||
$level = $request->input('level');
|
||||
if ($json) {
|
||||
if ($level == 2) {
|
||||
$level_arr = [
|
||||
1
|
||||
];
|
||||
} else {
|
||||
$level_arr = [
|
||||
1, 2
|
||||
];
|
||||
}
|
||||
return $this->apiJson((new Merchant())->whereIn('level', $level_arr), 'merchant', $request);
|
||||
}
|
||||
|
||||
$this->setViewPath('merchant', 'index');
|
||||
|
||||
return $this->display(['group_type' => $name, 'level' => $level]);
|
||||
}
|
||||
|
||||
protected function shopUserAndList($name, Request $request)
|
||||
{
|
||||
$json = $request->input('json');
|
||||
|
||||
if ($json) {
|
||||
|
||||
return $this->apiJson(new Shop(), 'shop', $request);
|
||||
}
|
||||
|
||||
$this->setViewPath('shop_and_user', 'index');
|
||||
|
||||
return $this->display(['group_type' => $name,]);
|
||||
}
|
||||
|
||||
protected function shopServerList($name, Request $request)
|
||||
{
|
||||
$json = $request->input('json');
|
||||
|
||||
if ($json) {
|
||||
|
||||
return $this->apiJson(new ShopServer(), 'shop_server', $request);
|
||||
}
|
||||
|
||||
$this->setViewPath('shop_server', 'index');
|
||||
|
||||
return $this->display(['group_type' => $name]);
|
||||
}
|
||||
|
||||
public function parseJson($type, $result)
|
||||
{
|
||||
$narr = [];
|
||||
switch ($type) {
|
||||
case 'user':
|
||||
foreach ($result as $k => $v) {
|
||||
$v['sex'] = config('adconfig.sex')[$v['sex']];
|
||||
$v['thumb'] = picurl($v['thumb']);
|
||||
$v['type_name'] = config('adconfig.user_group')[$v['type']];
|
||||
$narr[] = $v;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
foreach ($result as $k => $v) {
|
||||
if (isset($v['thumb'])) {
|
||||
$v['thumb'] = picurl($v['thumb']);
|
||||
}
|
||||
$narr[] = $v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $narr;
|
||||
}
|
||||
|
||||
public function parseSearch($type, $request)
|
||||
{
|
||||
|
||||
$search_arr = [];
|
||||
switch ($type) {
|
||||
case 'user':
|
||||
$name = $request->input('name', '');
|
||||
$search_arr = [
|
||||
'type' => [
|
||||
'type' => '=',
|
||||
'value' => $request->input('group_type') == 'all' ? '' : $request->input('group_type')
|
||||
],
|
||||
'name' => [
|
||||
'type' => 'likesql',
|
||||
'value' => $name ? "nickname like '%" . $name . "%' or mobile like '%" . $name . "%' or real_name like '%" . $name . "%'" : ""
|
||||
]
|
||||
|
||||
];
|
||||
break;
|
||||
case 'merchant':
|
||||
$name = $request->input('name', '');
|
||||
$search_arr = [
|
||||
|
||||
'name' => [
|
||||
'type' => 'likesql',
|
||||
'value' => $name ? "realname like '%" . $name . "%' or mobile like '%" . $name . "%' or realname like '%" . $name . "%'" : ""
|
||||
]
|
||||
|
||||
];
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
return $search_arr;
|
||||
}
|
||||
|
||||
public function apiJson($model, $type, Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$search_arr = $this->parseSearch($type, $request);
|
||||
$model = $model;
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = [];
|
||||
$narr = $this->parseJson($type, $result);
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Category;
|
||||
use App\Models\NoticeArticle;
|
||||
use App\Models\Sms;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ArticleController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '文章内容'
|
||||
];
|
||||
}
|
||||
|
||||
public function postDataDb($request, $id = '')
|
||||
{
|
||||
$data=$request->all();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'content' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
'content' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Article();
|
||||
}
|
||||
public function content($id){
|
||||
//单页内容设置
|
||||
$category=Category::find($id);
|
||||
//判断是否已经有内容
|
||||
$article=$this->setModel()->where('category_id',$id)->first();
|
||||
|
||||
$data['category']=$category;
|
||||
$data['article']=[];
|
||||
if($article)
|
||||
{
|
||||
$data['article']=$article->toArray();
|
||||
}
|
||||
return $this->display($data);
|
||||
}
|
||||
public function contentPost(Request $request){
|
||||
$data=[
|
||||
'name'=>$request->input('name'),
|
||||
'content'=>$request->input('content'),
|
||||
'category_id'=>$request->input('category_id')
|
||||
];
|
||||
$modle=$this->setModel()::where('category_id',$request->category_id)->first();
|
||||
if($modle)
|
||||
{
|
||||
$r=$modle->update($data);
|
||||
|
||||
|
||||
}else
|
||||
{
|
||||
$r=$this->setModel()::create($data);
|
||||
}
|
||||
if($r)
|
||||
{
|
||||
|
||||
|
||||
$result=1;
|
||||
$msg_str='内容更新成功';
|
||||
}else
|
||||
{
|
||||
$result=0;
|
||||
$msg_str='内容更新失败';
|
||||
}
|
||||
$this->insertLog($msg_str);
|
||||
return response()->json([
|
||||
'error'=>$result?0:1,
|
||||
'msg'=>$msg_str
|
||||
]);
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['show_url']=action($this->route['controller_name'] . '@show', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['user_name']=$v->user->real_name;
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BankController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '银行列表'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Bank();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'sort');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['thumb']=picurl($v['thumb']);
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\BankTransfer;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BankTransferController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '固码收款'
|
||||
];
|
||||
}
|
||||
public function shareData($id = '')
|
||||
{
|
||||
return ['pay_type'=>config('adconfig.transfer_type')];
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new BankTransfer();
|
||||
}
|
||||
|
||||
public function apiJsonData($result, $total, $debug = 0, $request)
|
||||
{
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['thumb']=picurl($v['thumb']);
|
||||
$v['type_name']=config('adconfig.transfer_type')[$v['type']];
|
||||
$narr[] = $v;
|
||||
}
|
||||
return $narr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Banner;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BannerController extends BaseDefaultController
|
||||
{
|
||||
//
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => 'Banner'
|
||||
];
|
||||
}
|
||||
public function indexData(){
|
||||
|
||||
return ['type'=>config('adconfig.banner_type')];
|
||||
}
|
||||
public function shareData($show='')
|
||||
{
|
||||
return ['type'=>config('adconfig.banner_type')];
|
||||
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'url' => 'required',
|
||||
'name' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'url' => 'required',
|
||||
'name' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Banner();
|
||||
}
|
||||
|
||||
protected function postDataDb($request,$id=''){
|
||||
|
||||
$data=$request->all();
|
||||
if(!$request->input('password'))
|
||||
{
|
||||
unset($data['password']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$type = $request->input('type', '1');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
$role=$request->input('role','');
|
||||
|
||||
$search_arr=[
|
||||
'type'=>[
|
||||
'type'=>'=',
|
||||
'value'=>$type
|
||||
]
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['type']=config('adconfig.banner_type')[$v['type']];
|
||||
$v['thumb']=picurl($v['thumb']);
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,509 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Models\AdminLog;
|
||||
use App\Services\SearchServices;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Route;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Validator;
|
||||
use AnyUpload;
|
||||
use DB;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
//
|
||||
const ADMIN_BLADE_DIR='admin.';
|
||||
public $title='';
|
||||
public $route=[];
|
||||
public $pages=[];
|
||||
public $model;
|
||||
public $share_view=[];
|
||||
public $guard_name='admin';
|
||||
public $dblast_id='';
|
||||
public $adminModel='App\Models\Admin';
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$route_arr=explode('@', Route::currentRouteAction());
|
||||
$this->route['controller_name']='\\'.$route_arr[0];
|
||||
$this->route['action_name']=$route_arr[1];
|
||||
$this->route['controller_base']=str_replace('Controller','',str_replace('App\\Http\\Controllers\\Admin\\','',$route_arr[0]));
|
||||
$this->route['blade']=self::ADMIN_BLADE_DIR.strtolower($this->route['controller_base']).'.'.$this->route['action_name'];
|
||||
$this->share_view['controller']="\\".$this->route['controller_name'];
|
||||
|
||||
$this->title=ucwords($this->route['action_name']);
|
||||
$this->share_view['title']=$this->title;
|
||||
$this->setPagesInfo();
|
||||
//$this->handleUrl();
|
||||
$this->getTable();
|
||||
$this->share_view['action_name']=$this->route['action_name'];
|
||||
$this->share_view['page']=$this->pages;
|
||||
|
||||
$this->shareView();
|
||||
|
||||
|
||||
|
||||
|
||||
// $this->checkPermission();
|
||||
|
||||
|
||||
}
|
||||
public function alertError($error_str,$status=1){
|
||||
return response()->json( ['error'=>$status,'msg'=>$error_str,'type'=>'validator']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证规则
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function checkRule($id='')
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置表单验证错误信息
|
||||
* @return array
|
||||
*/
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局返回表单错误消息
|
||||
* @param $error
|
||||
* @return array
|
||||
*/
|
||||
protected function formError($error){
|
||||
$error=$error->all();
|
||||
if(count($error)<=0) return [];
|
||||
$error_str='';
|
||||
foreach($error as $k=>$v)
|
||||
{
|
||||
|
||||
$error_str.=$v."*<br/>";
|
||||
|
||||
}
|
||||
return ['error'=>1,'msg'=>$error_str,'type'=>'validator'];
|
||||
|
||||
|
||||
}
|
||||
public function errorJosn($msg){
|
||||
return ['error'=>1,'msg'=>$msg];
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局检测表单是否错误,如果又返回错误数组,否则空数组
|
||||
* @param $request
|
||||
* @param string $id
|
||||
* @return array
|
||||
*/
|
||||
protected function validatorForm($request,$id=''){
|
||||
$validator = Validator::make($request->all(), $this->checkRule($id),$this->setErrorMsg());
|
||||
if($validator->fails()) {
|
||||
if($request->ajax() || $request->wantsJson())
|
||||
{
|
||||
|
||||
|
||||
return $validator->errors();
|
||||
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
//附加验证
|
||||
protected function extendValidate($request,$model,$id){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置创建数据键值对
|
||||
* @param $obj
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
protected function setDbKeyValue($obj,$data){
|
||||
$fileds=$this->getField();
|
||||
foreach ($data as $field=>$v)
|
||||
{
|
||||
if(in_array($field,$fileds)){
|
||||
$v=is_null($v)?'':$v;
|
||||
$obj->$field = trim($v);
|
||||
}
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局创建和更新操作返回消息
|
||||
* @param $result
|
||||
* @param $request
|
||||
* @param string $id
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function saveMessage($result,$request,$id=''){
|
||||
|
||||
$type=$id?'更新':'创建';
|
||||
if($request->method()=='DELETE')
|
||||
{
|
||||
$type='删除';
|
||||
}
|
||||
|
||||
$msg_type=$result?'成功':'失败';
|
||||
$msg_str=$this->pages['name'].$type.$msg_type;
|
||||
if($result)
|
||||
{
|
||||
$this->insertLog($msg_str);
|
||||
}
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
return response()->json([
|
||||
'error'=>$result?0:1,
|
||||
'msg'=>$msg_str
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
protected function insertLog($msg){
|
||||
AdminLog::addLog($msg);
|
||||
}
|
||||
|
||||
protected function backMessage( $data=[],$success,$request_type,$type)
|
||||
{
|
||||
$return_arr=[];
|
||||
$type_str=$request_type=='edit'?'更新':'创建';
|
||||
if($type=='ajax')
|
||||
{
|
||||
if($success)
|
||||
{
|
||||
$return_arr['error']=0;
|
||||
$return_arr['msg']=$type_str.'成功';
|
||||
}else
|
||||
{
|
||||
$return_arr['error']=1;
|
||||
$return_arr['msg']=$type_str.'失败,请重新操作';
|
||||
}
|
||||
}
|
||||
return $return_arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 共享视图资源
|
||||
* @return mixed
|
||||
*/
|
||||
public function shareView(){
|
||||
|
||||
return view()->share($this->share_view);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function setPageName($name){
|
||||
$data=$this->pages;
|
||||
$data['name']=$name;
|
||||
|
||||
|
||||
view()->share('page',$data);
|
||||
}
|
||||
/**
|
||||
* 设置页面标题
|
||||
* @param string $title
|
||||
*/
|
||||
protected function setTitle($title=''){
|
||||
$title=$title?$title:$this->pages['name'];
|
||||
view()->share('title',$title?$title:$this->title);
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面page设置
|
||||
*/
|
||||
protected function setPagesInfo(){
|
||||
$this->pages=[
|
||||
'name'=>''
|
||||
];
|
||||
|
||||
}
|
||||
/**
|
||||
* 改变自动获取blade
|
||||
* @param $path
|
||||
* @param int $cover 是否完全覆盖
|
||||
* @param int $is_seft 是否在当前的控制下目录
|
||||
* @return string
|
||||
*/
|
||||
protected function setViewPath($path='',$filename='',$cover=0,$is_seft=1)
|
||||
{
|
||||
if($cover){
|
||||
return $this->route['blade']=$path;
|
||||
}
|
||||
if($is_seft==0)
|
||||
{
|
||||
return $this->route['blade']=self::ADMIN_BLADE_DIR.$path;
|
||||
}
|
||||
if($filename!='')
|
||||
{
|
||||
$this->route['action_name']=$filename;
|
||||
}
|
||||
if($path)
|
||||
{
|
||||
$this->route['action_name']=$path.".".$this->route['action_name'];
|
||||
}
|
||||
return $this->route['blade']=self::ADMIN_BLADE_DIR.strtolower($this->route['controller_base']).'.'.$this->route['action_name'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得当前的模型的字段列表
|
||||
* @param $model
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getField(){
|
||||
$table=$this->getTable();
|
||||
$data=Schema::getColumnListing($table);
|
||||
if(array_key_exists('id', $data))
|
||||
{
|
||||
unset($data['id']);
|
||||
}
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得table
|
||||
* @return string
|
||||
*/
|
||||
protected function getTable(){
|
||||
if(gettype($this->setModel())!='object')
|
||||
{
|
||||
|
||||
$table='';
|
||||
}else
|
||||
{
|
||||
$table=$this->setModel()->getTable();
|
||||
}
|
||||
|
||||
$this->share_view['table_name']=$table;
|
||||
$this->shareView();
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 本页面操作的模型
|
||||
*/
|
||||
protected function setModel(){
|
||||
|
||||
}
|
||||
protected function getShow($id){
|
||||
$show=$this->setModel()->find($id);
|
||||
if(!$show)
|
||||
{
|
||||
return abort(404);
|
||||
}
|
||||
view()->share('show',$show);
|
||||
|
||||
return $this->display($this->shareData($show));
|
||||
}
|
||||
/**
|
||||
* 输出视图
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function display($data=[]){
|
||||
|
||||
return view($this->route['blade'],$data);
|
||||
}
|
||||
|
||||
public function jsonDebug($json){
|
||||
print_r($json);
|
||||
|
||||
return '';
|
||||
}
|
||||
public function setDbLastId($result,$obj){
|
||||
if($result) {
|
||||
$this->dblast_id=$obj->id;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected function saveAfter($request,$model,$id=''){
|
||||
|
||||
}
|
||||
protected function postDataDb($request,$id=''){
|
||||
return $request->all();
|
||||
}
|
||||
protected function searchKey($model,$arr,$where=1){
|
||||
if(empty($arr))
|
||||
{
|
||||
return $model;
|
||||
}
|
||||
return $model->search($arr,$where);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function indexData(){
|
||||
$this->setTitle();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//共享创建和编辑数据
|
||||
protected function shareData($id=''){
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function checkValueData(){
|
||||
$filed_arr=[];
|
||||
$value=0;
|
||||
if(count($filed_arr)<=0){
|
||||
return false;
|
||||
}
|
||||
return ['fields'=>$filed_arr,'value'=>$value];
|
||||
}
|
||||
public function checkOnValue($data, $handel_arr, $value = 0)
|
||||
{
|
||||
$handel_data=$this->checkValueData();
|
||||
if($handel_data)
|
||||
{
|
||||
$handel_arr=$handel_data['fields']+$handel_arr;
|
||||
$value=$handel_data['value'];
|
||||
}
|
||||
|
||||
if (count($handel_arr) <= 0) {
|
||||
return $data;
|
||||
}
|
||||
foreach ($handel_arr as $k => $v) {
|
||||
if (array_key_exists($v, $data)) {
|
||||
continue;
|
||||
}
|
||||
$data[$v] = $value;
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 创建和更新操作
|
||||
* @param $request
|
||||
* @param $model
|
||||
* @param string $id
|
||||
* @return array|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function saveData($request,$model,$id=''){
|
||||
$error=$this->validatorForm($request,$id);
|
||||
if(count($error)>0){
|
||||
return $this->formError($error);
|
||||
};
|
||||
$extend_checked=$this->extendValidate($request,$model,$id);
|
||||
if(is_array($extend_checked))
|
||||
{
|
||||
return response()->json($extend_checked);
|
||||
}
|
||||
//设置请求参数
|
||||
$data=$this->postDataDb($request,$id);
|
||||
//设置is_checkd不选择的时候为0
|
||||
if($id)
|
||||
{
|
||||
if(in_array('is_checked',$this->getField()))
|
||||
{
|
||||
//$data=$this->checkOnValue($data,['is_checked'],0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$model=$this->setDbKeyValue($model,$data);
|
||||
|
||||
$begin=isset($data['begindb'])?$data['begindb']:0;
|
||||
if($begin!=0)
|
||||
{
|
||||
|
||||
DB::beginTransaction();
|
||||
$result=$model->save();
|
||||
$this->setDbLastId($result,$model);
|
||||
$after_result=$this->saveAfter($request,$model,$id);
|
||||
if($result && $after_result)
|
||||
{
|
||||
DB::commit();
|
||||
}else
|
||||
{
|
||||
DB::rollback();
|
||||
}
|
||||
}else
|
||||
{
|
||||
$result=$model->save();
|
||||
$this->setDbLastId($result,$model);
|
||||
$this->saveAfter($request,$model,$id);
|
||||
}
|
||||
|
||||
return $this->saveMessage($result,$request,$id);
|
||||
}
|
||||
public function jsonMsg($error,$str){
|
||||
return response()->json(['error'=>$error,'msg'=>$str]);
|
||||
}
|
||||
/*********基本控制器资源设置*********/
|
||||
/**
|
||||
* 设置相关操作,比如链表
|
||||
* @param $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function apiSetModelRel($model){
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* 设置关联数据等操作
|
||||
* @param $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function apiSetResult($model){
|
||||
return $model;
|
||||
}
|
||||
public function setApiSearchParam($data){
|
||||
return $data;
|
||||
}
|
||||
public function searchType(){
|
||||
return '';
|
||||
}
|
||||
public function getSearchModel($data,$type=''){
|
||||
|
||||
$model=new SearchServices($this->setModel(),$data,$this->searchType());
|
||||
// dd(SearchServices::$where);
|
||||
return $model->getModel();
|
||||
}
|
||||
public function returnJson($total,$narr,$debug){
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BaseDefaultController extends BaseController
|
||||
{
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
$this->setTitle();
|
||||
return $this->display($this->indexData());
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$permission = $this->setModel();
|
||||
return $this->saveData($request,$permission);
|
||||
|
||||
}
|
||||
public function show($id)
|
||||
{
|
||||
return $this->getShow($id);
|
||||
}
|
||||
public function create(){
|
||||
return $this->display($this->shareData());
|
||||
}
|
||||
public function edit($id){
|
||||
return $this->getShow($id);
|
||||
}
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$model = $this->setModel();
|
||||
$model = $model->findOrFail($id);
|
||||
return $this->saveData($request,$model,$id);
|
||||
|
||||
}
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
|
||||
//如果开始没有数据,直接返回空的
|
||||
if(!$this->setModel())
|
||||
{
|
||||
$json= [
|
||||
"status" => 1,
|
||||
'code' => 1,
|
||||
'msg' => '暂无数据',
|
||||
'count' => 0,
|
||||
'data' => []
|
||||
];
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
$model=$this->getSearchModel($this->setApiSearchParam($request->all()));
|
||||
|
||||
$model=$this->apiSetModelRel($model);
|
||||
$total = $model->count();
|
||||
//是否是否关联数据等操作
|
||||
$model=$this->apiSetResult($model);
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();
|
||||
|
||||
//显示内容设置
|
||||
$arr_data= $this->apiJsonData($result,$total,$debug,$request);
|
||||
return $this->returnJson($total,$arr_data,$debug);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BaseTypeController extends BaseController
|
||||
{
|
||||
//
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$group_type=request()->group_type;
|
||||
view()->share('group_type',$group_type);
|
||||
$this->setViewPath($group_type);
|
||||
}
|
||||
|
||||
public function index($group_type)
|
||||
{
|
||||
$this->setTitle();
|
||||
return $this->display($this->indexData());
|
||||
}
|
||||
public function apiJson($group_type,Request $request){
|
||||
$json = [
|
||||
'total' => 0,
|
||||
'code'=>0,
|
||||
'rows' => []
|
||||
];
|
||||
return response($json);
|
||||
}
|
||||
|
||||
public function store($group_type,Request $request)
|
||||
{
|
||||
$permission = $this->setModel();
|
||||
return $this->saveData($request,$permission);
|
||||
|
||||
}
|
||||
public function create($group_type){
|
||||
return $this->display($this->shareData());
|
||||
}
|
||||
public function edit($group_type,$id){
|
||||
return $this->getShow($id);
|
||||
}
|
||||
public function update($group_type, $id,Request $request)
|
||||
{
|
||||
$model = $this->setModel();
|
||||
$model = $model->findOrFail($id);
|
||||
return $this->saveData($request,$model,$id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class CategoryController extends BaseTypeController
|
||||
{
|
||||
//
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$arr=config('adconfig.category_group');
|
||||
|
||||
|
||||
$this->pages = [
|
||||
'name' => $arr[request()->group_type]
|
||||
];
|
||||
}
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new Category();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson($group_type,Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'sort');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
'type'=>[
|
||||
'type'=>'=',
|
||||
'value'=>$group_type
|
||||
]
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['group_type'=>$group_type,'id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['group_type'=>$group_type,'id' => $v->id]);
|
||||
$v['content']=action( 'Admin\ArticleController@content', ['id' => $v->id]);
|
||||
|
||||
$v['thumb']=picurl($v['thumb']);
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class CollectController extends BaseDefaultController
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,300 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\BankRel;
|
||||
use App\Models\DrawMoney;
|
||||
use App\Models\HandeDoLog;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantCommission;
|
||||
use App\Models\MerchantMoneyLog;
|
||||
use App\Models\MerchantRatio;
|
||||
use App\Models\MerchantWallet;
|
||||
use App\Models\Order;
|
||||
use App\Services\SearchServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class DrawMoneyController extends BaseDefaultController
|
||||
{
|
||||
//
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '申请提现'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
|
||||
return ['status' => DrawMoney::drawStatus(), 'merchant' => Merchant::get()];
|
||||
}
|
||||
|
||||
public function shareData($show = '')
|
||||
{
|
||||
if ($show) {
|
||||
$merchant_id = $show->merchant_id;
|
||||
//商户钱包信息
|
||||
$data['wallte'] = MerchantWallet::where('merchant_id', $merchant_id)->first();
|
||||
//该商户支付交易结算总额
|
||||
$data['order_total_money'] = Order::getMerchantTotalMoney($merchant_id);
|
||||
//推广总佣金
|
||||
$data['commisson_money'] = MerchantCommission::getMoneyTotal($merchant_id);
|
||||
//推广结算成功佣金
|
||||
$data['commisson_ok_money'] = MerchantCommission::getMoneyTotal($merchant_id, 1);
|
||||
//申请提现资金
|
||||
$data['draw_money_wait_number'] = $this->setModel()::getDrawMoney(['status_in' => [0, 2]]);
|
||||
//今天冻结结算资金
|
||||
$day_seizure = $this->daySeizure($merchant_id);
|
||||
$data['today_money'] = $day_seizure['day_total_money'];
|
||||
$data['day_seizure_money'] = $day_seizure['day_seizure_money'];
|
||||
//完成提现总额
|
||||
$data['draw_money_ok_total'] = DrawMoney::getDrawMoney(['status' => 1, 'merchant_id' => $merchant_id]);
|
||||
//提现次数
|
||||
$data['draw_info'] = $this->getDrawMoneyStatus($merchant_id);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//已经申请提现多少,冻结资金+已提现金额未处理=综合总金额
|
||||
public function getWaitDrawMoney()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//提现次数
|
||||
public function getDrawMoneyStatus($merchant_id)
|
||||
{
|
||||
//提现总额今天
|
||||
$data['draw_total'] = $this->setModel()::where('merchant_id', $merchant_id)->whereRaw('DATE_FORMAT(created_at,"%Y-%m-%d") =? ', [date('Y-m-d')])->sum('draw_money');
|
||||
$data['draw_number'] = $this->setModel()::where('merchant_id', $merchant_id)->whereRaw('DATE_FORMAT(created_at,"%Y-%m-%d") =? ', [date('Y-m-d')])->count('*');
|
||||
return $data;
|
||||
}
|
||||
|
||||
//每天扣押款
|
||||
public function daySeizure($merchant_id)
|
||||
{
|
||||
|
||||
//统计今天成就结算总额
|
||||
$to_day_total_money = Order::getMerchantTotalToDayMoney($merchant_id, 1);
|
||||
$day_seizure_money = 0;
|
||||
//每天押款多少比率
|
||||
if ($to_day_total_money > 0) {
|
||||
$day_seizure_ratio = Merchant::getDayDrawRatio($merchant_id);
|
||||
$day_seizure_money = round($to_day_total_money * $day_seizure_ratio / 100, 2);
|
||||
}
|
||||
return ['day_total_money' => $to_day_total_money, 'day_seizure_money' => $day_seizure_money];
|
||||
}
|
||||
|
||||
|
||||
protected function extendValidate($request, $model, $id)
|
||||
{
|
||||
//检查是否金额对的上
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
'draw_money.required' => '提现金额不能为空',
|
||||
'money.required' => '到账金额不能为空',
|
||||
'fee_money.required' => '手续费不能为空',
|
||||
'bank_realname.required' => '收款人不能为空',
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new DrawMoney();
|
||||
}
|
||||
|
||||
public function checkSelf($show)
|
||||
{
|
||||
|
||||
if ($show->model_id != $this->getMerchantId() && $show->model_type == 'merchant') {
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postDataDb($request, $id = '')
|
||||
{
|
||||
$data = $request->all();
|
||||
//1是成功,3是失败
|
||||
if (in_array($request->input('status'), [3, 1])) {
|
||||
//提现处理时间
|
||||
$data['success_at'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
$data['admin_name'] = admin('realname');
|
||||
$data['admin_id'] = admin('id');
|
||||
|
||||
$data['begindb'] = 1;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
|
||||
//取得最后的一次日志记录
|
||||
$draw_log = HandeDoLog::getLastLog('draw_money', $model->id);
|
||||
|
||||
if (empty($draw_log)) {
|
||||
|
||||
//插入日志
|
||||
$do_r = HandeDoLog::insertLog('draw_money', $model->id, $request->input('status'), '提现操作');
|
||||
//1表示提现成功
|
||||
if ($do_r->do_value == 1) {
|
||||
//提现成功,更新钱包的提现金额
|
||||
$waller_r = MerchantWallet::moneyIncr($model->merchant_id, $model->draw_money, 'draw_money');
|
||||
return $waller_r;
|
||||
}
|
||||
//如果是提现失败
|
||||
if ($do_r->do_value == 3) {
|
||||
//提现失败,更新钱包的提现金额
|
||||
$money_log = MerchantMoneyLog::drawMoney($model->merchant_id, $model->draw_money, '提现失败,撤回资金', $model->id);
|
||||
//增加钱包余额
|
||||
$waller_r = MerchantWallet::moneyIncr($model->merchant_id, $model->draw_money);
|
||||
if ($waller_r && $money_log) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
//如果已经有处理过
|
||||
//判断最近这次处理是什么类型
|
||||
if ($draw_log['do_value'] == 1) {
|
||||
//已经提现成功,不给操作,返回false;
|
||||
return false;
|
||||
}
|
||||
//未处理和正在处理都是返回空的真
|
||||
if (in_array($draw_log['do_value'], [0, 2])) {
|
||||
//准备处理
|
||||
if ($request->input('status') == 1) {
|
||||
//提现成功,更新钱包的提现金额
|
||||
$waller_r = MerchantWallet::moneyIncr($model->merchant_id, $model->draw_money, 'draw_money');
|
||||
return $waller_r;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//提现失败
|
||||
if ($draw_log['do_value'] == 3) {
|
||||
//已经提现成功,不给操作,返回false
|
||||
$money_log = MerchantMoneyLog::drawMoney($model->merchant_id, $model->draw_money, '提现失败,撤回资金', $model->id);
|
||||
//增加钱包余额
|
||||
$waller_r = MerchantWallet::moneyIncr($model->merchant_id, $model->draw_money);
|
||||
if ($waller_r && $money_log) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search = new SearchServices($model, $request->all(), 'draw_money');
|
||||
$model = $search->getModel();
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->with(['merchants'=>function($query){
|
||||
$query->with(['froms'=>function($query2){
|
||||
$query2->with('froms');
|
||||
}]);
|
||||
}])->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
//找出merchant_id
|
||||
$merchant_id=[];
|
||||
foreach ($result as $k => $v) {
|
||||
$merchant_id[]=$v->merchant_id;
|
||||
}
|
||||
//查找费率表
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url'] = action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url'] = action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['draw_type_name'] = $v->DrawTypeName;
|
||||
$v['merchant_name'] = $v->merchants['name'];
|
||||
$v['show_url'] = admin_url('DrawMoney', 'show', ['id' => $v->id]);
|
||||
$v['merchant_ratio']=$v->merchants['ratio'];
|
||||
$v['next_ratio']=$v->merchants['froms']['ratio'];
|
||||
$v['next_next_ratio']=$v->merchants['froms']['froms']['ratio'];
|
||||
$v['merchant_level']=$v->merchants['level'];
|
||||
$v['yl_money']=0;
|
||||
//原始交易金额
|
||||
$origin_money=$v['draw_money']/(1000-$v['merchant_ratio'])*1000;
|
||||
$v['origin_money']=round($origin_money,2);
|
||||
//3级,代理,股东
|
||||
|
||||
//商户
|
||||
if($v['next_ratio']=='' && $v['next_next_ratio']=='')
|
||||
{
|
||||
//提现金额/1-费率*100=原始金额*盈利费率=最低盈利金额
|
||||
$v['yl_money']= $v['origin_money']*(($v['merchant_ratio']-7)/1000);
|
||||
}elseif( $v['next_ratio'] && $v['next_next_ratio']=='')
|
||||
{
|
||||
$v['yl_money']= $v['origin_money']*(($v['next_ratio']-7)/1000);
|
||||
}else
|
||||
{
|
||||
$v['yl_money']= $v['origin_money']*(($v['next_next_ratio']-7)/1000);
|
||||
}
|
||||
$v['yl_money']=round( $v['yl_money'],2);
|
||||
$text_class = '';
|
||||
if ($v['status'] == 1) {
|
||||
$text_class = "text-grep";
|
||||
}
|
||||
if ($v['status'] == 3) {
|
||||
$text_class = "text-danger";
|
||||
}
|
||||
$v['status_name_tpl'] = '<span class="' . $text_class . '">' . $v->StatusName . '</span>';
|
||||
$narr[] = $v;
|
||||
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\DrawSet;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class DrawSetController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '提现费率'
|
||||
];
|
||||
}
|
||||
|
||||
public function shareData($id = '')
|
||||
{
|
||||
return [
|
||||
'draw_type'=>config('adconfig.draw_type')
|
||||
];
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'start_money' => 'required',
|
||||
'end_money' => 'required',
|
||||
'money'=> 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'start_money' => 'required',
|
||||
'end_money' => 'required',
|
||||
'money'=> 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new DrawSet();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'start_money');
|
||||
$order_type = $request->input('order', 'asc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['draw_type_name']=$v->DrawTypeName;
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Excel;
|
||||
use DB;
|
||||
|
||||
class ExcelController extends BaseController
|
||||
{
|
||||
public function index($type, Request $request)
|
||||
{
|
||||
switch ($type) {
|
||||
|
||||
case 'import':
|
||||
return $this->import($request);
|
||||
break;
|
||||
case 'importpost':
|
||||
return $this->importPost($request);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
$this->setViewPath('import', 'index');
|
||||
return $this->display();
|
||||
}
|
||||
|
||||
//任意导入
|
||||
public function importPost(Request $request)
|
||||
{
|
||||
$table = $request->input('table');
|
||||
$delete_all = $request->input('del');
|
||||
$file = $request->input('file');
|
||||
$file = dir_linux(public_path()) . $file;
|
||||
$results = Excel::selectSheetsByIndex(0)->load($file, function ($reader) {
|
||||
})->get()->toArray();
|
||||
if (count($results) > 0) {
|
||||
$data = $results;
|
||||
if ($delete_all) {
|
||||
DB::table($table)->delete();
|
||||
}
|
||||
|
||||
$r = DB::table($table)->insert($data);
|
||||
if ($r) {
|
||||
|
||||
return $this->saveMessage($r,$request);
|
||||
}
|
||||
} else {
|
||||
return $this->saveMessage(0,$request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\File;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Classc\UploadFile;
|
||||
|
||||
class FileUploadController extends BaseController
|
||||
{
|
||||
//
|
||||
public function handle($type,Request $request){
|
||||
if($type=='upload')
|
||||
{
|
||||
return $this->upload($request);
|
||||
}
|
||||
if($type=='list')
|
||||
{
|
||||
return $this->getList($request);
|
||||
}
|
||||
if($type=='only_one')
|
||||
{
|
||||
$this->setViewPath('','handle_only');
|
||||
return $this->getList($request);
|
||||
}
|
||||
if($type=='api')
|
||||
{
|
||||
return $this->getApi($request);
|
||||
}
|
||||
}
|
||||
protected function upload($request){
|
||||
$files = $request->input('files', 'file');
|
||||
$type=$request->input('uptype','image');
|
||||
$method = $request->input('method', 'upload');
|
||||
$r = UploadFile::upload($files, $type, $method);
|
||||
|
||||
if($type!='image')
|
||||
{
|
||||
$r['view_img']=____('file.jpg');
|
||||
}else
|
||||
{
|
||||
$r['view_img']=$r['path'];
|
||||
}
|
||||
|
||||
return response()->json($r);
|
||||
}
|
||||
protected function getList($request){
|
||||
return $this->display([]);
|
||||
}
|
||||
protected function getApi($request){
|
||||
$type = $request->input('uptype','');
|
||||
$is_oss = $request->input('is_oss', false);
|
||||
$offset = $request->input('offset', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$key = $request->input('search', '');
|
||||
|
||||
$model = new File();
|
||||
if ($type) {
|
||||
$model = $model->where('type', $type);
|
||||
}
|
||||
$total = $model->where('user_type', 'admin')->count();
|
||||
|
||||
$data = $model->where('user_type', 'admin')->skip($offset)->take($pagesize)->orderBy('id', 'desc')->get()->toArray();
|
||||
$str = '';
|
||||
$uindex = 0;
|
||||
foreach ($data as $key => $v) {
|
||||
$pic_url = $v['path'];
|
||||
$is_oss = $is_oss ? $is_oss : config('adconfig.is_oss');
|
||||
$v['oss'] = '';
|
||||
$img_html='<img data-type="'.$v['type'].'" src="' . $v['path']. '" class="" title="' . $v['tmp']. '" alt="" > ';
|
||||
if ($is_oss) {
|
||||
if (Storage::exists($pic_url)) {
|
||||
$pic_url = Storage::url($v['path']);
|
||||
$v['oss'] = Storage::url($v['path']);
|
||||
}
|
||||
|
||||
}
|
||||
if ($v['type'] != 'image') {
|
||||
|
||||
$img_html=' <video class="upload_img" src="'.$v['path'].'" data-type="'.$v['type'].'" data-src="' . $v['path']. '" controls="controls" style="width: 100%;"></video>';
|
||||
}
|
||||
|
||||
|
||||
$str .= '<div class="layui-upload-img item layui-inline " data-size="'.$v['size'].'.kb" data-tmpname="'.$v['tmp'].'" data-type="'.$v['type'].'" data-src="' . $v['path']. '"> ' .$img_html .
|
||||
'<p class="layui-">' . $v['tmp']. '</p> </div>';
|
||||
$uindex++;
|
||||
}
|
||||
|
||||
$list = array(
|
||||
'total' => $total,
|
||||
'contents' => $str,
|
||||
'pagesize' => $pagesize
|
||||
);
|
||||
$debug = $request->input('debug', 0);
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($list);
|
||||
}
|
||||
return response()->json($list);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\Gateway;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class GatewayController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
|
||||
$this->pages = [
|
||||
'name' => '支付通道'
|
||||
];
|
||||
}
|
||||
public function postDataDb($request, $id = '')
|
||||
{
|
||||
$data=$request->all();
|
||||
if($data['cert_private_type']==2)
|
||||
{
|
||||
$data['cert_key']= $data['cert_key2'];
|
||||
unset($data['cert_key2']);
|
||||
}
|
||||
if($data['cert_pub_type']==2)
|
||||
{
|
||||
$data['cert_pub']= $data['cert_pub2'];
|
||||
unset($data['cert_pub2']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
//'app_id'=> 'required',
|
||||
'ename'=> 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
//'app_id'=> 'required',
|
||||
'ename'=> 'required'
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
'app_id.required'=>'appid不能为空'
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function shareData($id = '')
|
||||
{
|
||||
$data=[
|
||||
'pay_client'=>config('adconfig.pay_client'),'pay_type'=>config('adconfig.pay_type')
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
public function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
write_gateway();//写入配置文件
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new Gateway();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'client_type');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['thumb']=picurl($v['thumb']);
|
||||
$v['client_type_name']=$v->client_type_name;
|
||||
$v['ratio_name']=$v->ratio_name;
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\Gateway;
|
||||
use App\Models\GatewayWind;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class GatewayWindController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '风控设置'
|
||||
];
|
||||
}
|
||||
|
||||
public function shareData($id = '')
|
||||
{
|
||||
return ['payway'=>Gateway::get()];
|
||||
}
|
||||
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'max_total' => 'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'max_total' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
'max_total.required'=>'每天交易总额'
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new GatewayWind();
|
||||
}
|
||||
public function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
if($model->day==date('Y-m-d')){
|
||||
//如果交易总额小于最低限额,则开启,否认关闭
|
||||
if($model->amount_total<=$model->max_total)
|
||||
{
|
||||
//开启这个通道
|
||||
Gateway::where('id',$model->gateway_id)->update(['is_checked'=>1]);
|
||||
|
||||
}else
|
||||
{
|
||||
Gateway::where('id',$model->gateway_id)->update(['is_checked'=>0]);
|
||||
|
||||
}
|
||||
write_gateway();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('pays')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['thumb']=picurl($v['thumb']);
|
||||
$v['gateway_name']=$v->pays['name'].'('.$v->pays['mch_id'].')';
|
||||
$v['gateway_type']=config('adconfig.pay_client')[$v->pays['client_type']];
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Category;
|
||||
use App\Models\Good;
|
||||
use App\Models\NoticeArticle;
|
||||
use App\Models\Sms;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class GoodsController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '产品服务'
|
||||
];
|
||||
}
|
||||
public function shareData($id = '')
|
||||
{
|
||||
return ['type'=>Category::getType('server')];
|
||||
}
|
||||
|
||||
public function postDataDb($request, $id = '')
|
||||
{
|
||||
$data=$request->all();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'money' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
'money' =>'required'
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Good();
|
||||
}
|
||||
public function content($id){
|
||||
//单页内容设置
|
||||
$category=Category::find($id);
|
||||
//判断是否已经有内容
|
||||
$article=$this->setModel()->where('category_id',$id)->first();
|
||||
|
||||
$data['category']=$category;
|
||||
$data['article']=[];
|
||||
if($article)
|
||||
{
|
||||
$data['article']=$article->toArray();
|
||||
}
|
||||
return $this->display($data);
|
||||
}
|
||||
public function contentPost(Request $request){
|
||||
$data=[
|
||||
'name'=>$request->input('name'),
|
||||
'content'=>$request->input('content'),
|
||||
'category_id'=>$request->input('category_id')
|
||||
];
|
||||
$modle=$this->setModel()::where('category_id',$request->category_id)->first();
|
||||
if($modle)
|
||||
{
|
||||
$r=$modle->update($data);
|
||||
|
||||
|
||||
}else
|
||||
{
|
||||
$r=$this->setModel()::create($data);
|
||||
}
|
||||
if($r)
|
||||
{
|
||||
|
||||
|
||||
$result=1;
|
||||
$msg_str='内容更新成功';
|
||||
}else
|
||||
{
|
||||
$result=0;
|
||||
$msg_str='内容更新失败';
|
||||
}
|
||||
$this->insertLog($msg_str);
|
||||
return response()->json([
|
||||
'error'=>$result?0:1,
|
||||
'msg'=>$msg_str
|
||||
]);
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['show_url']=action($this->route['controller_name'] . '@show', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['category_name']=$v->categorys->name;
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Events\CouponCardEvent;
|
||||
use App\Models\CouponCard;
|
||||
use App\Models\Scenic;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use App\Models\AdminLog;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Event;
|
||||
use Ixudra\Curl\Facades\Curl;
|
||||
|
||||
class HandleController extends BaseController
|
||||
{
|
||||
public function handle($type, Request $request)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'del':
|
||||
return $this->delete($request);
|
||||
break;
|
||||
case 'edit':
|
||||
return $this->editField($request);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 软删除开启
|
||||
* @param $table
|
||||
* @return int
|
||||
*/
|
||||
public function deletType($table)
|
||||
{
|
||||
|
||||
switch ($table) {
|
||||
case 'merchants':
|
||||
case 'gateways':
|
||||
case 'gateway_winds':
|
||||
//商户开启软删除
|
||||
return 1;
|
||||
case 'servers':
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function editField(Request $request)
|
||||
{
|
||||
$table = $request->input('table'); // 表名
|
||||
$id_name = $request->input('id_name', 'id'); // 表主键id名
|
||||
$id_value = $request->input('id_value'); // 表主键id值
|
||||
$field = $request->input('field'); // 修改哪个字段
|
||||
$value = $request->input('value'); // 修改字段值
|
||||
if ($table == '' or $id_name == '' or $id_value == '' or $field == '' or $value == '') {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '参数不正确'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
$model = DB::table($table)->where($id_name, $id_value)->update([$field => $value]);
|
||||
|
||||
if ($table == 'gateways') {
|
||||
write_gateway();//更新支付通道信息
|
||||
}
|
||||
if ($table == 'merchants') {
|
||||
write_merchant();//更新商户信息
|
||||
}
|
||||
|
||||
if ($model) {
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'msg' => '设置成功'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
} else {
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'msg' => '设置失败'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
}
|
||||
|
||||
private function send2ZhanxinDel(){
|
||||
// $data = [];
|
||||
// $chanxinconfig = config('qrcodeurl.zhanxin');
|
||||
// Curl::to($chanxinconfig['baseurl'] . $chanxinconfig['del'])->witData($data)->post();
|
||||
}
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$type_id = $request->input('type_id', 'id');
|
||||
$table = $request->input('table');
|
||||
$handle_str = $request->input('handle_str');
|
||||
if ($table == '') {
|
||||
$table = $request->input('model');
|
||||
}
|
||||
$rdel = $this->deletType($table);
|
||||
|
||||
if ($id == '') {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '编号不能为空',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
if ($table == '') {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '没有选择数据表',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
$id_arr = explode(",", $id);
|
||||
if (count($id_arr) <= 0) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '编号不能为空',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
$result = DB::table($table)->whereIn($type_id, $id_arr);
|
||||
|
||||
$this->eventCustom($table, $id_arr);
|
||||
|
||||
if ($rdel) {
|
||||
$result = $result->update(['deleted_at' => date('Y-m-d H:i:s', time())]);
|
||||
} else {
|
||||
$result = $result->delete();
|
||||
|
||||
}
|
||||
|
||||
if ($result && $this->deleteCustom($table, $id_arr)) {
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
$this->insertLog($handle_str . '删除 ID:' . implode('、', $id_arr));
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'msg' => '删除成功',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
DB::rollBack();
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '删除失败',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function deleteCustom($table, $id)
|
||||
{
|
||||
switch ($table) {
|
||||
case 'merchants_bak':
|
||||
//商户需要删除费率表
|
||||
$r = DB::table('merchant_ratios')->whereIn('merchant_id', $id)->delete();
|
||||
$money_r = DB::table('merchant_wallets')->whereIn('merchant_id', $id)->delete();
|
||||
return $r && $money_r;
|
||||
break;
|
||||
case 'merchants':
|
||||
write_merchant();//更新商户信息
|
||||
break;
|
||||
case 'gateways':
|
||||
write_gateway();//更新通道信息
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function eventCustom($table, $id)
|
||||
{
|
||||
switch ($table) {
|
||||
|
||||
case 'merchants':
|
||||
//更新商户汇率表
|
||||
write_merchant_ratio();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Services\DateServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\SystemUpdateLog;
|
||||
|
||||
class HomeController extends BaseController
|
||||
{
|
||||
public function index(){
|
||||
$this->setTitle('网站后台');
|
||||
if(is_mobile_client())
|
||||
{
|
||||
//$this->setViewPath('','mobile');
|
||||
return redirect()->action('Admin\HomeController@console');
|
||||
}
|
||||
return $this->display();
|
||||
}
|
||||
public function console(){
|
||||
$data=[];
|
||||
$data['day_before_7']=DateServices::decrDay('',6);
|
||||
$data['update_log']=SystemUpdateLog::where('type','system')->limit(10)->orderBy('id','desc')->get();
|
||||
|
||||
//DateServices::diffDay('2019-01-02','2019-01-05');
|
||||
|
||||
return $this->display($data);
|
||||
}
|
||||
public function online($id){
|
||||
$this->setViewPath('','online');
|
||||
|
||||
$data=[
|
||||
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
public function showNotice($id,$request){
|
||||
$this->setViewPath('','notice');
|
||||
$notice=NoticeArticle::find($id);
|
||||
$data=[
|
||||
'show'=>$notice
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
public function show($type,$id,Request $request){
|
||||
return $this->$type($id,$request);
|
||||
}
|
||||
|
||||
public function password($id){
|
||||
$this->setViewPath('','password');
|
||||
|
||||
$data=[
|
||||
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
public function update($method,Request $request){
|
||||
|
||||
return $this->$method($request);
|
||||
}
|
||||
public function passwordUpdate($request){
|
||||
$error=$this->validatorForm($request,'password');
|
||||
if(count($error)>0){
|
||||
return $this->formError($error);
|
||||
};
|
||||
$user=admin();
|
||||
$password=$request->input('password');
|
||||
$old_password=$request->input('old_password');
|
||||
if (!Hash::check($old_password, $user->password)) {
|
||||
return $this->alertError('旧密码不对');
|
||||
}
|
||||
$user->password=$password;
|
||||
if($user->save())
|
||||
{
|
||||
return $this->alertError('修改密码成功',0);
|
||||
}
|
||||
return $this->alertError('修改密码失败',1);
|
||||
|
||||
}
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
return [
|
||||
'password' => 'required|confirmed',
|
||||
'old_password' => 'required'
|
||||
];
|
||||
}
|
||||
public function setErrorMsg()
|
||||
{
|
||||
return [
|
||||
'old_password'=>'旧密码'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\AdminLog;
|
||||
use App\Models\Sms;
|
||||
use App\Models\SmsLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class LogController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '操作日志'
|
||||
];
|
||||
}
|
||||
|
||||
public function shareData($show='')
|
||||
{
|
||||
return $this->indexData();
|
||||
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'tpl_id' => 'required|unique:sms,tpl_id',
|
||||
'ename' => 'required|unique:sms,ename',
|
||||
'content' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
'tpl_id' =>'required|unique:sms,tpl_id,' . $id,
|
||||
'ename' =>'required|unique:sms,ename,' . $id,
|
||||
'content' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new AdminLog();
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$type = $request->input('type', '1');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
$role=$request->input('role','');
|
||||
|
||||
$search_arr=[
|
||||
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr,2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('users')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
|
||||
$v['admin_name']=$v->users->real_name;
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Validator;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/admin/home/';
|
||||
|
||||
public function username()
|
||||
{
|
||||
return 'account';
|
||||
}
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('admin');
|
||||
}
|
||||
|
||||
protected function sendFailedLoginResponse(Request $request)
|
||||
{
|
||||
return (['error' => 1, 'msg' => trans('auth.failed')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
//$this->middleware('admin')->except('logout');
|
||||
}
|
||||
|
||||
protected function formError($error)
|
||||
{
|
||||
$error = $error->all();
|
||||
if (count($error) <= 0) return [];
|
||||
$error_str = '';
|
||||
foreach ($error as $k => $v) {
|
||||
|
||||
$error_str .= $v . "*<br/>";
|
||||
|
||||
}
|
||||
return response()->json(['error' => 1, 'msg' => $error_str, 'type' => 'validator']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//跳转地址登陆
|
||||
public function redirectTo()
|
||||
{
|
||||
return redirect()->to(admin_url('Home'));
|
||||
}
|
||||
|
||||
public function authenticated()
|
||||
{
|
||||
return response()->json(['error' => 0, 'msg' => '登录成功']);
|
||||
}
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
|
||||
if (Auth::guard('admin')->check()) {
|
||||
return redirect()->to(admin_url('Home'));
|
||||
}
|
||||
return view('admin.auth.login', ['title' => '管理系统']);
|
||||
}
|
||||
|
||||
protected function validatorForm($request)
|
||||
{
|
||||
$is_mobile = 0;
|
||||
$message_data = [
|
||||
$this->username() . '.required' => '请输入账号',
|
||||
'password.required' => '请输入密码',
|
||||
];
|
||||
$check_data =
|
||||
[
|
||||
$this->username() => 'required|string',
|
||||
'password' => 'required|string',
|
||||
];
|
||||
|
||||
|
||||
$validator = Validator::make($request->all(), $check_data, $message_data);
|
||||
if ($validator->fails()) {
|
||||
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
|
||||
return $validator->errors();
|
||||
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function sendLockoutResponse(Request $request)
|
||||
{
|
||||
$seconds = $this->limiter()->availableIn(
|
||||
$this->throttleKey($request)
|
||||
);
|
||||
return response()->json(['error' => 1, 'msg' => '登陆失败次数过多,请稍后重试' . $seconds]);
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$whtelist = config('whitelist.login');
|
||||
$ip = $request->getClientIp();
|
||||
if (!in_array($ip, $whtelist)) {
|
||||
return response()->json(['error' => 1, 'msg' => 'err']);
|
||||
}
|
||||
|
||||
$error = $this->validatorForm($request);
|
||||
if (count($error) > 0) {
|
||||
return $this->formError($error);
|
||||
};
|
||||
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
||||
// the login attempts for this application. We'll key this by the username and
|
||||
// the IP address of the client making these requests into this application.
|
||||
//确定用户是否有太多失败的登录尝试。
|
||||
if ($this->hasTooManyLoginAttempts($request)) {
|
||||
$this->fireLockoutEvent($request);
|
||||
|
||||
//太多次返回的信息
|
||||
return $this->sendLockoutResponse($request);
|
||||
}
|
||||
|
||||
|
||||
if ($this->attemptLogin($request)) {
|
||||
//通过之后响应
|
||||
return $this->sendLoginResponse($request);
|
||||
}
|
||||
|
||||
//增加登陆尝试次数,默认尝试增加1次
|
||||
$this->incrementLoginAttempts($request);
|
||||
|
||||
|
||||
return $this->sendFailedLoginResponse($request);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$this->guard()->logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
|
||||
return $this->loggedOut($request) ?: redirect()->route('admin.login');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\AdminLog;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantCommission;
|
||||
use App\Models\MerchantMoneyLog;
|
||||
use App\Models\Sms;
|
||||
use App\Models\SmsLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class MerchantCommissionController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$title = request()->input('title','代理佣金');
|
||||
|
||||
$this->pages = [
|
||||
'name' => $title
|
||||
];
|
||||
}
|
||||
public function indexData()
|
||||
{
|
||||
$status=config('adconfig.commission_status');
|
||||
return ['status'=>$status,'merchant'=>Merchant::get()];
|
||||
}
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
}
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new MerchantCommission();
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$merchant_id = $request->input('merchant_id', '');
|
||||
$from_merchant_id = $request->input('from_merchant_id', '');
|
||||
$order_sn = $request->input('order_sn', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$status = $request->input('status', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$day=$request->input('day','');
|
||||
|
||||
$month=$request->input('month','');
|
||||
|
||||
$time=$request->input('time','');
|
||||
$start_at='';
|
||||
$end_at='';
|
||||
if($time)
|
||||
{
|
||||
$time=str_replace('~',',',$time);
|
||||
$time=explode(",",$time);
|
||||
$start_at=isset($time[0])?$time[0]:'';
|
||||
$end_at=isset($time[1])?$time[1]:'';
|
||||
$month='';
|
||||
}
|
||||
if($status!='')
|
||||
{
|
||||
$model=$model->where('status',$status);
|
||||
}
|
||||
//天
|
||||
if($day!='')
|
||||
{
|
||||
if($day<=0)
|
||||
{
|
||||
$day_at=(new Date($day."day"))->format('Y-m-d');
|
||||
$start_at=$day_at.' 00:00:00';
|
||||
if($day==-1)
|
||||
{
|
||||
$end_at=$day_at.' 23:59:59';
|
||||
}else
|
||||
{
|
||||
$end_at=(new Date('0 day'))->format('Y-m-d').' 23:59:59';
|
||||
}
|
||||
$month='';
|
||||
}
|
||||
}
|
||||
//月
|
||||
if($month!='')
|
||||
{
|
||||
$date=date('Y-m-d H:i:s',strtotime($month.'month'));
|
||||
$month_at=get_month($date);
|
||||
if(count($month_at)>0)
|
||||
{
|
||||
|
||||
$start_at=$month_at[0];
|
||||
if($month==0 || $month=='-1')
|
||||
{
|
||||
$end_at=$month_at[1];
|
||||
}else
|
||||
{
|
||||
$end_at=get_month('',1,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//时间范围
|
||||
if($start_at)
|
||||
{
|
||||
$model=$model->whereRaw('(order_at>=? and order_at<=? )',[($start_at),($end_at)]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$search_arr = [
|
||||
'merchant_id' => [
|
||||
'value' => $merchant_id,
|
||||
'type' => '='
|
||||
],
|
||||
'order_sn' => [
|
||||
'value' => $order_sn,
|
||||
'type' => '='
|
||||
],
|
||||
'from_merchant_id'=>[
|
||||
'value'=>$from_merchant_id,
|
||||
'type'=>'='
|
||||
]
|
||||
|
||||
];
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('merchants','fromMerchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['status_name'] = $v->status_name;
|
||||
$v['name']=$v->merchants->name;
|
||||
$v['tname']=$v->fromMerchants['name'];
|
||||
$v['ratio']=($v['ratio']/10).'%';
|
||||
$v['show_url']=admin_url('Order','show',['id'=>$v->order_id]);
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,482 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\BankRel;
|
||||
use App\Models\DrawMoney;
|
||||
use App\Models\Gateway;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantRatio;
|
||||
use App\Models\MerchantWallet;
|
||||
use App\Models\Order;
|
||||
use App\Models\Server;
|
||||
use App\Services\SearchServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class MerchantController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '商户'
|
||||
];
|
||||
}
|
||||
|
||||
public function shareData($id = '')
|
||||
{
|
||||
write_merchant_ratio();
|
||||
$gateways = Gateway::where('is_checked', 1)->orderBy('ename', 'desc')->orderBy('client_type', 'desc')->get();//
|
||||
$arr = [];
|
||||
if (count($gateways) > 0) {
|
||||
foreach ($gateways as $k => $v) {
|
||||
$arr[$v->ename]['name']=config('adconfig.pay_type')[$v->ename];
|
||||
$arr[$v->ename]['data'][]=$v;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//上级是否存在
|
||||
$from_id = \request()->input('from_id');
|
||||
$from_name = '';
|
||||
if ($from_id) {
|
||||
//
|
||||
$uobj = Merchant::find($from_id);
|
||||
$from_name = $uobj['name'] ?: '';
|
||||
}
|
||||
return [
|
||||
'gateways' => $arr,
|
||||
'level' => config('adconfig.merchant_level'),
|
||||
'bank' => Bank::where(['is_checked' => 1])->pluck('name', 'id'),
|
||||
'draw_type' => config('adconfig.draw_type'),
|
||||
'from_id' => $from_id,
|
||||
'from_name' => $from_name
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required|unique:merchants|max:255',
|
||||
|
||||
//'ratio' => 'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required',
|
||||
|
||||
//'ratio' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function extendValidate($request, $model, $id)
|
||||
{
|
||||
$level = $request->input('level');
|
||||
$from_id = $request->input('from_id');
|
||||
|
||||
//禁止使用qq
|
||||
/* if (stripos($request->input('email'), '@qq.com')) {
|
||||
return $this->errorJosn('禁止使用QQ邮箱');
|
||||
}*/
|
||||
|
||||
if ($from_id) {
|
||||
//等级判断股东下不能再有上级
|
||||
if ($level == 1) {
|
||||
return $this->errorJosn('股东下不能再有上级');
|
||||
}
|
||||
//判断上级费率,不能低于
|
||||
$proxy = Merchant::find($request->input('from_id'));
|
||||
if ($request->input('ratio') <= $proxy->ratio) {
|
||||
return $this->errorJosn('设置费率,不能低于上级费率:' . $proxy->ratio);
|
||||
}
|
||||
//股东不能再添加股东
|
||||
//代理不能再添加代理
|
||||
if ($level == $proxy->level) {
|
||||
return $this->errorJosn('同级别是不能再添加同级别的');
|
||||
}
|
||||
//身份低的不能添加高的
|
||||
if ($level < $proxy->level) {
|
||||
return $this->errorJosn('身份等级不匹配,可能是代理或股东是不能再添加代理或股东的');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if ($id) {
|
||||
|
||||
if ($id == $request->input('from_id')) {
|
||||
return $this->errorJosn('不能是自己');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function postDataDb($request, $id = '')
|
||||
{
|
||||
$data = $request->all();
|
||||
if (!$id) {
|
||||
$data['app_key'] = date('YmdHis') . str_random(6);
|
||||
$data['token'] = str_random(32);
|
||||
}
|
||||
//如果上级代理不是0,则需要计算上级代理的费率
|
||||
if ($data['from_id'] != 0) {
|
||||
$proxy = Merchant::find($data['from_id']);
|
||||
$data['next_ratio'] = $proxy->ratio;//上级代理费率
|
||||
}
|
||||
if (!$request->input('password')) {
|
||||
unset($data['password']);
|
||||
} else {
|
||||
$data['origin_password'] = $data['password'];
|
||||
}
|
||||
|
||||
if (isset($data['gateways'])) {
|
||||
$data['gateways_id'] = implode(",", $data['gateways']);
|
||||
}else
|
||||
{
|
||||
$data['gateways_id']=0;
|
||||
}
|
||||
//全部不选则为0
|
||||
if(isset($data['all_waygate']))
|
||||
{
|
||||
if($data['all_waygate']==1)
|
||||
{
|
||||
$data['gateways_id']=0;
|
||||
}
|
||||
}
|
||||
//添加的时候需要开启
|
||||
if (!$id) {
|
||||
$data['begindb'] = 1;//开启事务
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function updateMerchantRatio($merchant)
|
||||
{
|
||||
//取得费率表信息
|
||||
$ratio = MerchantRatio::where('merchant_id', $merchant->id)->where('is_self', 1)->first();
|
||||
|
||||
//判断上级是否有上级
|
||||
$upObj = Merchant::find($merchant->from_id);
|
||||
$hierarchy = 1;//默认1级,表示顶级
|
||||
if ($upObj) {
|
||||
|
||||
if ($upObj->from_id != 0) {
|
||||
$hierarchy = 3;
|
||||
} else {
|
||||
//没有上级,则只有2级别
|
||||
$hierarchy = 2;
|
||||
}
|
||||
}
|
||||
//层级不一样了,判断谁的层级高一点
|
||||
//全部删除,重新添加
|
||||
MerchantRatio::where('merchant_id', $merchant->id)->delete();
|
||||
//重新添加
|
||||
|
||||
|
||||
//判断层级
|
||||
if ($hierarchy == 3) {
|
||||
//3级关系级别
|
||||
return MerchantRatio::addDefault($merchant->from_id, $merchant->id, $merchant->ratio);
|
||||
} elseif ($hierarchy == 2) {
|
||||
//代理级别
|
||||
if($merchant->level==2)
|
||||
{
|
||||
//代理级别
|
||||
return MerchantRatio::addProxyLevel($merchant->from_id, $merchant->id, $merchant->ratio);
|
||||
}else
|
||||
{
|
||||
//商户级别
|
||||
return MerchantRatio::add($merchant->from_id, $merchant->level, 2, $merchant->id, $merchant->ratio);
|
||||
}
|
||||
} elseif ($hierarchy == 1) {
|
||||
//普通级别
|
||||
return MerchantRatio::add(0, $merchant->level, 1, $merchant->id, $merchant->ratio);
|
||||
}
|
||||
|
||||
/* //判断层级是否一样且父没有更换,如果是的话,只需要更新,无需删除和添加操作
|
||||
if($hierarchy==$ratio->hierarchy && $merchant->from_id==$ratio->parent_id)
|
||||
{
|
||||
|
||||
MerchantRatio::where('merchant_id',$merchant->id)->update(['hierarchy'=>$hierarchy,'ratio'=>$merchant->ratio,'parent_id'=>$merchant->from_id,'level'=>$merchant->level]);//
|
||||
}else
|
||||
{
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
//$this->insertBank($request->input('bank'),$model->id,$id);
|
||||
|
||||
//创建钱包记录
|
||||
$this->crateWallte($request, $model);
|
||||
|
||||
//判断等级,
|
||||
$level = $request->input('level');
|
||||
$from_id = $request->input('from_id');
|
||||
//添加操作
|
||||
if ($id) {
|
||||
//更新
|
||||
//当前的身份等级
|
||||
$this->updateMerchantRatio($model);
|
||||
|
||||
} else {
|
||||
//上级ID存在
|
||||
if ($from_id) {
|
||||
//等级判断
|
||||
if ($level == 2) {
|
||||
//代理级别添加
|
||||
return MerchantRatio::addProxyLevel($from_id, $model->id, $request->input('ratio'));
|
||||
}
|
||||
//如果添加是商户
|
||||
if ($level == 3) {
|
||||
return MerchantRatio::addDefault($from_id, $model->id, $model->ratio);
|
||||
}
|
||||
} else {
|
||||
//普通用户,普通代理,普通股东
|
||||
return MerchantRatio::add(0, $level, 1, $model->id, $request->input('ratio'));
|
||||
}
|
||||
}
|
||||
write_merchant();//写入配置文件
|
||||
//写入费率信息
|
||||
write_merchant_ratio();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function crateWallte(Request $request, $model)
|
||||
{
|
||||
$obj = new MerchantWallet();
|
||||
//判断是否存在,如果存在不需要再创建
|
||||
$has = $obj->where('merchant_id', $model->id)->first();
|
||||
if (!$has) {
|
||||
MerchantWallet::firstOrCreate(['merchant_id' => $model->id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function insertBank($arr, $id = '', $is_del = 0)
|
||||
{
|
||||
if (count($arr) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$insert_m_data = [];
|
||||
if ($is_del) {
|
||||
//删除之前的
|
||||
BankRel::where(['model_id' => $id, 'model_type' => 'merchant', 'is_default' => 1])->delete();
|
||||
}
|
||||
//插入关联表
|
||||
$insert_m_data = $arr;
|
||||
$insert_m_data['model_id'] = $id;
|
||||
$insert_m_data['model_type'] = 'merchant';
|
||||
$insert_m_data['is_default'] = 1;
|
||||
|
||||
BankRel::insert($insert_m_data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new Merchant();
|
||||
}
|
||||
|
||||
protected function getShow($id)
|
||||
{
|
||||
$show = $this->setModel()->find($id);
|
||||
if (!$show) {
|
||||
return abort(404);
|
||||
}
|
||||
view()->share('show', $show);
|
||||
|
||||
//申请提现资金
|
||||
$data['draw_money_wait_number'] = DrawMoney::getDrawMoney(['status_in' => [0, 2]]);
|
||||
$day_seizure = $this->daySeizure($id);
|
||||
$data['today_money'] = $day_seizure['day_total_money'];
|
||||
$data['day_seizure_money'] = $day_seizure['day_seizure_money'];
|
||||
$data = $data + $this->shareData();
|
||||
return $this->display($data);
|
||||
}
|
||||
|
||||
//每天扣押款
|
||||
public function daySeizure($merchant_id)
|
||||
{
|
||||
//统计今天成就结算总额
|
||||
$to_day_total_money = Order::getMerchantTotalToDayMoney($merchant_id, 1);
|
||||
$day_seizure_money = 0;
|
||||
//每天押款多少比率
|
||||
if ($to_day_total_money > 0) {
|
||||
$day_seizure_ratio = config_cache('draw_config.draw_day_money_ratio') ? config_cache('draw_config.draw_day_money_ratio') : 0;
|
||||
$day_seizure_money = round($to_day_total_money * $day_seizure_ratio / 100, 2);
|
||||
}
|
||||
return ['day_total_money' => $to_day_total_money, 'day_seizure_money' => $day_seizure_money];
|
||||
}
|
||||
|
||||
public function createGroupBtn($id, $prev_id, $level, $msg, $color = 'default')
|
||||
{
|
||||
return '<button class="layui-btn layui-btn-sm layui-btn-' . $color . '" lay-event="soso" data-id="' . $id . '" data-pid="' . $prev_id . '" data-level="' . $level . '"> ' . $msg . ' </button>';
|
||||
}
|
||||
|
||||
public function createGroupBackBtn($id, $prev_id, $level, $msg, $color = 'default')
|
||||
{
|
||||
return '<button class="layui-btn layui-btn-sm layui-btn-' . $color . '" lay-event="soso" data-id="' . $id . '" data-pid="' . $prev_id . '" data-level="' . $level . '"> ' . $msg . ' </button>';
|
||||
}
|
||||
|
||||
public function createGroupAddBtn($id, $msg, $color = 'danger')
|
||||
{
|
||||
return '<button class="layui-btn layui-btn-sm layui-btn-' . $color . '" lay-event="add" data-id="' . $id . '" > ' . $msg . ' </button>';
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
|
||||
$param = $request->all();
|
||||
$prev_id = $request->input('prev_id', 0);
|
||||
$level = $request->input('level', '');
|
||||
|
||||
//搜索集合地
|
||||
$search = (new SearchServices($this->setModel(), $param));
|
||||
$model = $search->getList();
|
||||
$total = $model->count();
|
||||
$result = $model->with(['wallets', 'froms' => function ($query) {
|
||||
//再来嵌套一个
|
||||
$query->with('froms');
|
||||
}])->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url'] = action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url'] = action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['show_url'] = action($this->route['controller_name'] . '@show', ['id' => $v->id]);
|
||||
/* $v['bank_name']=$v->getDefaultBank['name'];
|
||||
$v['bank_account']=$v->getDefaultBank['account'];
|
||||
$v['bank_realname']=$v->getDefaultBank['realname'];*/
|
||||
$v['money'] = $v->wallets['money'];
|
||||
$v['draw_money'] = $v->wallets['draw_money'];
|
||||
$v['other_money'] = $v->wallets['other_money'];
|
||||
$v['total_money'] = $v->wallets['total_money'];
|
||||
$v['check_status_name2'] = $v->check_status != 1 ? '<span class="text-red">' . $v->CheckStatusName . '</span>' : $v->CheckStatusName;
|
||||
|
||||
$v['name_tpl'] = $v->name;
|
||||
$from_name = '';
|
||||
if ($v->froms['name']) {
|
||||
$from_name = '<p class="text-blue ">上级:' . $v->froms['name'] . '</p>';
|
||||
if ($v->froms['froms']['name']) {
|
||||
$from_name .= '<p class="text-color-lvse">顶级:' . $v->froms['froms']['name'] . '</p>';
|
||||
}
|
||||
}
|
||||
$btn = '';
|
||||
$back_id = $prev_id;
|
||||
if ($v->level == 3) {
|
||||
$level = $v->level - 1;
|
||||
}
|
||||
if ($v->level == 2) {
|
||||
$back_id = 0;
|
||||
}
|
||||
$back_btn = $this->createGroupBackBtn($back_id, $v->from_id, $level, '返回');
|
||||
//全部列表不显示按钮
|
||||
if (!$request->input('is_all')) {
|
||||
if (!$v->from_id) {
|
||||
$back_btn = '';
|
||||
}
|
||||
//股东上面才有上下级
|
||||
if ($v->level == 1) {
|
||||
$btn = '<div class="layui-btn-group">' . $this->createGroupBtn($v->id, $v->from_id, 2, '下级代理') . $back_btn
|
||||
. $this->createGroupBtn($v->id, $v->from_id, 3, '下级商户') . $this->createGroupAddBtn($v->id, '添加下级') . '</div>';
|
||||
}
|
||||
if ($v->level == 2) {
|
||||
|
||||
$btn = '<div class="layui-btn-group">' . $this->createGroupBtn($v->id, $v->from_id, 3, '下级商户') . $back_btn . $this->createGroupAddBtn($v->id, '添加下级') . '
|
||||
|
||||
</div>';
|
||||
}
|
||||
if ($v->level == 3) {
|
||||
if ($v->from_id) {
|
||||
$btn = '<div class="layui-btn-group">' . $back_btn . '
|
||||
|
||||
</div>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$color = 'layui-bg-green';
|
||||
if ($v->level == 1) {
|
||||
$color = 'layui-bg-cyan';
|
||||
} elseif ($v->level == 2) {
|
||||
$color = 'layui-bg-blue';
|
||||
}
|
||||
$v['level_name_label'] = '<span class="layui-badge ' . $color . '">' . $v->levelName . '</span> ';
|
||||
$v['name'] = '<p>' . $v->name . '</p>' . $from_name . '<p>邮箱:' . $v->email . '</p>' . $btn;
|
||||
|
||||
$v['post_check_url'] = action($this->route['controller_name'] . '@checkHandle', ['id' => $v->id]);
|
||||
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"pid" => $prev_id,
|
||||
"level" => $level,
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
public function checkHandle($id, Request $request)
|
||||
{
|
||||
$value = $request->input('value');
|
||||
$data = [
|
||||
'check_status' => $value
|
||||
];
|
||||
$r = $this->setModel()::where('id', $id)->update($data);
|
||||
if ($r) {
|
||||
|
||||
//更新
|
||||
write_merchant();
|
||||
$this->insertLog('审核商户申请状态,状态设置为', $value);
|
||||
return $this->jsonMsg(0, '审核操作成功');
|
||||
} else {
|
||||
$this->insertLog('审核商户申请状态,状态设置为', $value);
|
||||
return $this->jsonMsg(1, '审核操作失败');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class MerchantLogController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '商户日志'
|
||||
];
|
||||
}
|
||||
public function indexData()
|
||||
{
|
||||
$merchant = Merchant::get();
|
||||
return ['merchant' => $merchant];
|
||||
}
|
||||
|
||||
public function shareData($show = '')
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new MerchantLog();
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$merchant_id = $request->input('merchant_id', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
|
||||
$search_arr = [
|
||||
'merchant_id' => [
|
||||
'type' => '=',
|
||||
'value' => $merchant_id
|
||||
]
|
||||
|
||||
|
||||
];
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
|
||||
$v['admin_name'] = $v->merchants['name'];
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\AdminLog;
|
||||
use App\Models\MerchantMoneyLog;
|
||||
use App\Models\Sms;
|
||||
use App\Models\SmsLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class MerchantMoneyLogController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$title = request()->input('title');
|
||||
|
||||
$this->pages = [
|
||||
'name' => $title
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
}
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new MerchantMoneyLog();
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$type = $request->input('type', '1');
|
||||
$id = $request->input('id', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
|
||||
$search_arr = [
|
||||
|
||||
'merchant_id' => [
|
||||
'value' => $id,
|
||||
'type' => '='
|
||||
]
|
||||
|
||||
];
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['type_name'] = $v->type_name;
|
||||
$v['name']=$v->merchants->name;
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantOrder;
|
||||
use App\Models\Order;
|
||||
use App\Services\OrderStatisServices;
|
||||
use App\Services\SearchServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class MerchantOrderController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '商户推广订单'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->setTitle();
|
||||
|
||||
return $this->display($this->indexData());
|
||||
}
|
||||
|
||||
|
||||
protected function postDataDb($request,$id='')
|
||||
{
|
||||
$data = $request->all();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
$type = [
|
||||
'order_status'=>[1=>'交易完成',0=>'未支付'],
|
||||
'pay_status' => config('adconfig.pay_status'),
|
||||
'merchant'=>Merchant::get()
|
||||
];
|
||||
return $type;
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$show = $this->setModel()->find($id);
|
||||
|
||||
|
||||
//($pictrue);
|
||||
|
||||
|
||||
return $this->display(['show' => $show ]);
|
||||
}
|
||||
|
||||
|
||||
public function shareData($show = '')
|
||||
{
|
||||
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new MerchantOrder();
|
||||
}
|
||||
public function apiSetModelRel($model)
|
||||
{
|
||||
return $model->with('merchants','merchants2','gateways');
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
|
||||
$param=$request->all();
|
||||
|
||||
|
||||
|
||||
$search =(new SearchServices($this->setModel(),$param));
|
||||
// $search->setTimeType('order');
|
||||
// dump($search->echoWhere());
|
||||
$model=$search->getList();
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['pay_type_name']=config('adconfig.pay_type')[$v['gateway_type']];
|
||||
$v['server_name']=$v->merchants['name'];
|
||||
$v['merchants2_name']=$v->merchants2['name'];
|
||||
$v['order_status_name']=config('adconfig.order_status')[$v['status']];
|
||||
|
||||
$v['show_url'] = $v->order_show_url;
|
||||
$v['gateway_name']=$v->gateways['name'];
|
||||
$v['gateway_mch_id']=$v->gateways['mch_id'];
|
||||
$v['gateway_method_name']=array_key_exists($v['gateway_method'],config('adconfig.pay_client'))?config('adconfig.pay_client')[$v['gateway_method']]:'未知';
|
||||
$v['order_status_name2']=$v->OrderStatusName2;
|
||||
$v['ewm_info']='<p>备注:'.$v->ewm_mark.'</p>'.'<p>账号:'.(($v->ewm_account)?($v->ewm_account):'无').'</p>';
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
public function checkStatus(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
return $this->getShow($id);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Banner;
|
||||
use App\Models\Nav;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class NavController extends BaseDefaultController
|
||||
{
|
||||
//
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '导航'
|
||||
];
|
||||
}
|
||||
public function indexData(){
|
||||
|
||||
|
||||
|
||||
return ['type'=>config('adconfig.nav_type')];
|
||||
}
|
||||
public function shareData($show='')
|
||||
{
|
||||
return ['type'=>config('adconfig.nav_type')];
|
||||
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'url' => 'required',
|
||||
'name' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'url' => 'required',
|
||||
'name' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Nav();
|
||||
}
|
||||
|
||||
protected function postDataDb($request,$id=''){
|
||||
|
||||
$data=$request->all();
|
||||
if(!$request->input('password'))
|
||||
{
|
||||
unset($data['password']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
//写入避免查询数据库文件
|
||||
//写入避免查询数据库文件
|
||||
$nav=$this->setModel()::orderBy('sort','desc')->orderBy('id','desc')->get()->toArray();
|
||||
$arr=[];
|
||||
if(count($nav)>0)
|
||||
{
|
||||
foreach ($nav as $k=>$v)
|
||||
{
|
||||
$arr[$v['type']][]=$v;
|
||||
}
|
||||
|
||||
}
|
||||
$file=to_linux_path(config_path()).'/nav.php';
|
||||
$content="<?php\n return ".var_export($arr,true)."\n?>";
|
||||
file_put_contents($file,$content);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$type = $request->input('type', '1');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
$role=$request->input('role','');
|
||||
|
||||
$search_arr=[
|
||||
'type'=>[
|
||||
'type'=>'=',
|
||||
'value'=>$type
|
||||
]
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['type']=config('adconfig.nav_type')[$v['type']];
|
||||
$v['thumb']=picurl($v['thumb']);
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\NoticeArticle;
|
||||
use App\Models\Sms;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class NoticeArticleController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '系统公告'
|
||||
];
|
||||
}
|
||||
public function indexData(){
|
||||
|
||||
return ['type'=>config('adconfig.sms_type')];
|
||||
}
|
||||
public function shareData($show='')
|
||||
{
|
||||
return $this->indexData();
|
||||
|
||||
}
|
||||
public function postDataDb($request, $id = '')
|
||||
{
|
||||
$data=$request->all();
|
||||
$data['user_id']=admin('id');
|
||||
$data['user_type']='admin';
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'content' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
'content' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new NoticeArticle();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['show_url']=action($this->route['controller_name'] . '@show', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['user_name']=$v->user->realname;
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Gateway;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Order;
|
||||
use App\Services\OrderStatisServices;
|
||||
use App\Services\SearchServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class OrderController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '订单'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->setTitle();
|
||||
$location=request()->input('location');
|
||||
if($location)
|
||||
{
|
||||
$this->setPageName('本站订单');
|
||||
$this->setViewPath('','location');
|
||||
}
|
||||
return $this->display($this->indexData());
|
||||
}
|
||||
|
||||
|
||||
protected function postDataDb($request,$id='')
|
||||
{
|
||||
$data = $request->all();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
$type = [
|
||||
'pay_status' => config('adconfig.pay_status'),
|
||||
'order_status'=>config('adconfig.order_status'),
|
||||
'payfor_status'=>config('adconfig.payfor_status'),
|
||||
'order_notify'=>config('adconfig.order_notify'),
|
||||
'merchant'=>Merchant::get(),
|
||||
'gateway'=>Gateway::where('is_checked',1)->get()
|
||||
];
|
||||
return $type;
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$show = $this->setModel()->find($id);
|
||||
|
||||
|
||||
//($pictrue);
|
||||
|
||||
|
||||
return $this->display(['show' => $show ]);
|
||||
}
|
||||
|
||||
|
||||
public function shareData($show = '')
|
||||
{
|
||||
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new Order();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type_desc = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
|
||||
$guma=$request->input('guma');
|
||||
|
||||
|
||||
$param=$request->all();
|
||||
$param['out']=1;
|
||||
$location=$request->input('location');
|
||||
$order_type='order';
|
||||
if($location)
|
||||
{
|
||||
$order_type='order_self';
|
||||
}
|
||||
if($guma)
|
||||
{
|
||||
$param['guma']=1;
|
||||
}
|
||||
$search =(new SearchServices($this->setModel(),$param,$order_type));
|
||||
// $search->setTimeType('order');
|
||||
// dump($search->echoWhere());
|
||||
$model=$search->getList();
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('users','merchants','gateways')->orderBy($order_id, $order_type_desc)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['pay_type_name']=config('adconfig.pay_type')[$v['pay_type']]??'未知';
|
||||
$v['server_name']=$v->merchants['name'];
|
||||
$v['order_status_name']=config('adconfig.order_status')[$v['status']];
|
||||
$v['notify_status_name']=config('adconfig.order_notify')[$v['notify_status']];
|
||||
//$v['payfor_status_name']=config('adconfig.payfor_status')[$v['pay_status']];
|
||||
$v['update_pay_url']=admin_url('OrderHandleApi','handle',['order_id'=>$v->id,'type'=>'pay']);
|
||||
$v['update_pay_post_url']=admin_url('OrderHandleApi','handlePost',['order_id'=>$v->id,'type'=>'payUpdate']);
|
||||
$v['update_notify_url']=admin_url('OrderHandleApi','handlePost',['order_id'=>$v->id,'type'=>'notifyPost']);
|
||||
//$v['update_payfor_url']=admin_url('OrderHandleApi','handle',['order_id'=>$v->id,'type'=>'payfor']);
|
||||
//$v['update_payfor_post_url']=admin_url('OrderHandleApi','handlePost',['order_id'=>$v->id,'type'=>'payforUpdate']);
|
||||
$v['show_url'] = $v->order_show_url;
|
||||
$v['gateway_name']=$v->gateways['name'];
|
||||
$v['gateway_mch_id']=$v->gateways['mch_id'];
|
||||
$v['gateway_username']=$v->gateways['username'];
|
||||
$v['gateway_bank_name']='<p>'.$v->gateways['bank_name'].'</p>';
|
||||
|
||||
$v['gateway_method_name']=array_key_exists($v['gateway_method'],config('adconfig.pay_client'))?config('adconfig.pay_client')[$v['gateway_method']]:'未知';
|
||||
$v['order_status_name2']=$v->OrderStatusName2;
|
||||
$v['ewm_info']='';
|
||||
if(in_array($v['pay_type'],config('adconfig.guma_type')))
|
||||
{
|
||||
$v['ewm_info']='<p>备注:'.($v->ewm_mark??'无').'</p>'.'<p>账号:'.(($v->ewm_account)?($v->ewm_account):'无').'</p>';
|
||||
|
||||
}
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
public function checkStatus(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
return $this->getShow($id);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class OrderController2 extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '订单'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
protected function postDataDb($request, $id = '')
|
||||
{
|
||||
$data = $request->all();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
$type = [
|
||||
'pay_status' => config('adconfig.pay_status'),
|
||||
'order_status' => config('adconfig.order_status'),
|
||||
'payfor_status' => config('adconfig.payfor_status'),
|
||||
'order_notify' => config('adconfig.order_notify')
|
||||
];
|
||||
return $type;
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$show = $this->setModel()->find($id);
|
||||
|
||||
|
||||
//($pictrue);
|
||||
|
||||
|
||||
return $this->display(['show' => $show]);
|
||||
}
|
||||
|
||||
|
||||
public function shareData($show = '')
|
||||
{
|
||||
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new Order();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$order_sn = $request->input('order_sn', '');
|
||||
$out_trade_no = $request->input('out_trade_no', '');
|
||||
$pay_order_sn = $request->input('pay_order_sn', '');
|
||||
$user_id = $request->input('user_id', '');
|
||||
$out_user_id = $request->input('out_user_id', '');
|
||||
|
||||
|
||||
$pay_status = $request->input('pay_status', '');
|
||||
$notify_status = $request->input('notify_status', '');
|
||||
$out_notify_status = $request->input('out_notify_status', '');
|
||||
$success_status = $request->input('success_status', '');
|
||||
|
||||
$day = $request->input('day', '');
|
||||
|
||||
$month = $request->input('month', '');
|
||||
|
||||
$time = $request->input('time', '');
|
||||
$start_at = '';
|
||||
$end_at = '';
|
||||
if ($time) {
|
||||
$time = str_replace('~', ',', $time);
|
||||
$time = explode(",", $time);
|
||||
$start_at = isset($time[0]) ? $time[0] : '';
|
||||
$end_at = isset($time[1]) ? $time[1] : '';
|
||||
$month = '';
|
||||
}
|
||||
|
||||
|
||||
$merchant_id = $request->input('merchant_id', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$status = $request->input('status', '');
|
||||
$model = $this->setModel();
|
||||
$search_arr = [
|
||||
'order_sn' => [
|
||||
'type' => '=',
|
||||
'value' => $order_sn
|
||||
],
|
||||
'out_trade_no' => [
|
||||
'type' => '=',
|
||||
'value' => $out_trade_no
|
||||
],
|
||||
'pay_order_sn' => [
|
||||
'type' => '=',
|
||||
'value' => $pay_order_sn
|
||||
],
|
||||
'local_user_id' => [
|
||||
'type' => '=',
|
||||
'value' => $user_id
|
||||
],
|
||||
'out_user_id' => [
|
||||
'type' => '=',
|
||||
'value' => $out_user_id
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
$search_arr2 = [
|
||||
'pay_status' => [
|
||||
'type' => '=',
|
||||
'value' => $pay_status
|
||||
],
|
||||
'notify_status' => [
|
||||
'type' => '=',
|
||||
'value' => $notify_status
|
||||
],
|
||||
'out_notify_status' => [
|
||||
'type' => '=',
|
||||
'value' => $out_notify_status
|
||||
],
|
||||
|
||||
'merchant_id' => [
|
||||
'type' => '=',
|
||||
'value' => $merchant_id
|
||||
]
|
||||
|
||||
|
||||
];
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
$model = $this->searchKey($model, $search_arr2, 1);
|
||||
|
||||
if ($status != '') {
|
||||
$model = $model->where('status', $status);
|
||||
}
|
||||
//天
|
||||
if ($day != '') {
|
||||
if ($day <= 0) {
|
||||
$day_at = (new Date($day . "day"))->format('Y-m-d');
|
||||
$start_at = $day_at . ' 00:00:00';
|
||||
if ($day == -1) {
|
||||
$end_at = $day_at . ' 23:59:59';
|
||||
} else {
|
||||
$end_at = (new Date('0 day'))->format('Y-m-d') . ' 23:59:59';
|
||||
}
|
||||
}
|
||||
$month = '';
|
||||
}
|
||||
//月
|
||||
if ($month != '') {
|
||||
$date = date('Y-m-d H:i:s', strtotime($month . 'month'));
|
||||
$month_at = get_month($date);
|
||||
if (count($month_at) > 0) {
|
||||
|
||||
$start_at = $month_at[0];
|
||||
if ($month == 0 || $month == '-1') {
|
||||
$end_at = $month_at[1];
|
||||
} else {
|
||||
$end_at = get_month('', 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//时间范围
|
||||
if ($start_at) {
|
||||
$model = $model->whereRaw('(order_at>=? and order_at<=?) or (pay_ok_at>=? and pay_ok_at<=?)', [($start_at), ($end_at), ($start_at), ($end_at)]);
|
||||
}
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('users', 'merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['pay_type_name'] = config('adconfig.pay_type')[$v['pay_type']];
|
||||
$v['server_name'] = $v->merchants['name'];
|
||||
$v['order_status_name'] = config('adconfig.order_status')[$v['status']];
|
||||
$v['notify_status_name'] = config('adconfig.order_notify')[$v['notify_status']];
|
||||
//$v['payfor_status_name']=config('adconfig.payfor_status')[$v['pay_status']];
|
||||
$v['update_pay_url'] = admin_url('OrderHandleApi', 'handle', ['order_id' => $v->id, 'type' => 'pay']);
|
||||
$v['update_pay_post_url'] = admin_url('OrderHandleApi', 'handlePost', ['order_id' => $v->id, 'type' => 'payUpdate']);
|
||||
$v['update_notify_url'] = admin_url('OrderHandleApi', 'handlePost', ['order_id' => $v->id, 'type' => 'notifyPost']);
|
||||
//$v['update_payfor_url']=admin_url('OrderHandleApi','handle',['order_id'=>$v->id,'type'=>'payfor']);
|
||||
//$v['update_payfor_post_url']=admin_url('OrderHandleApi','handlePost',['order_id'=>$v->id,'type'=>'payforUpdate']);
|
||||
$v['show_url'] = $v->order_show_url;
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
public function checkStatus(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
return $this->getShow($id);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,466 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Jobs\NotifyOrderJob;
|
||||
use App\Models\Gateway;
|
||||
use App\Models\GatewayWind;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantCommission;
|
||||
use App\Models\MerchantMoneyLog;
|
||||
use App\Models\MerchantWallet;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderHandleLog;
|
||||
use App\Models\PayForLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Ixudra\Curl\Facades\Curl;
|
||||
use PayServices;
|
||||
use App\Models\SystemCommission;
|
||||
|
||||
class OrderHandleApiController extends BaseController
|
||||
{
|
||||
|
||||
|
||||
public $input_status;
|
||||
public $order_id;
|
||||
public $orderObj;
|
||||
public $userObj;
|
||||
public $serverObj;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
parent::__construct();
|
||||
//通过之后再获取
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->input_status = $request->status;
|
||||
$this->order_id = $request->order_id;
|
||||
$this->orderObj = Order::find($this->order_id);
|
||||
if ($this->orderObj->merchant_id != 0) {
|
||||
$this->serverObj = $this->orderObj->merchants;
|
||||
}
|
||||
view()->share('order_id', $this->order_id);
|
||||
view()->share('order', $this->orderObj);
|
||||
return $next($request);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function handle($order_id, $type, Request $request)
|
||||
{
|
||||
|
||||
return $this->$type($request);
|
||||
}
|
||||
|
||||
public function handlePost($order_id, $type, Request $request)
|
||||
{
|
||||
return $this->$type($request);
|
||||
}
|
||||
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
|
||||
return response()->json(['error' => 1, 'msg' => '该方法不存在']);
|
||||
}
|
||||
|
||||
//更新支付订单
|
||||
public function pay(Request $request)
|
||||
{
|
||||
$this->setViewPath('', 'pay');
|
||||
$data = [
|
||||
'pay_type' => config('adconfig.pay_type')
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
|
||||
public function payUpdate(Request $request)
|
||||
{
|
||||
//更新订单支付,支付类型,支付时间,支付状态,订单状态,写入更新操作日志
|
||||
if ($request->input('pay_time') == '' || $request->input('pay_price') == '') {
|
||||
return $this->msg(['error' => 1, 'msg' => '请填写必要参数']);
|
||||
}
|
||||
|
||||
|
||||
//更新订单
|
||||
$order = $this->orderObj;
|
||||
$order->pay_ok_at = $request->input('pay_time');//支付时间
|
||||
$order->pay_money = $request->input('pay_price');//支付金额
|
||||
$order->pay_type = $request->input('pay_type');
|
||||
|
||||
// $pay_rate=($request->input('pay_price')*$this->serverObj->ratio)/1000;
|
||||
if($order->pay_status==1)
|
||||
{
|
||||
return $this->msg(['error' => 1, 'msg' => '已经支付']);
|
||||
}
|
||||
$order->pay_status = 1;
|
||||
|
||||
|
||||
|
||||
//最后金额计算,这里提交订单的时候就计算了,所以注释掉
|
||||
// $order->total_money=$request->input('pay_price')-$pay_rate;
|
||||
//$order->ratio=$this->serverObj->ratio;
|
||||
//手续费
|
||||
//$order->pay_rate=$pay_rate;
|
||||
//原价
|
||||
//本站也回调更新
|
||||
$order->notify_status = 1;//
|
||||
$order->status = 2;//订单状态:已支付,待回调
|
||||
$r = $order->save();
|
||||
|
||||
|
||||
if ($r) {
|
||||
if ($order->merchant_id != 0) {
|
||||
//后台确认支付的,需要判断是否有代理,如果有代理需要给佣金
|
||||
|
||||
//判断是否有股东佣金
|
||||
|
||||
if ($order->top_money != 0 || $order->next_ratio != 0) {
|
||||
//如果有,再来判断订单的商户上级商户是否还有上级
|
||||
$top_id = Merchant::find($this->serverObj->from_id);
|
||||
//3级
|
||||
if ($top_id->from_id != 0) {
|
||||
//代理上面的股东
|
||||
//给股东算佣金
|
||||
$merchant_data = [
|
||||
'merchant_id' => $order->merchant_id,
|
||||
'from_merchant_id' => $top_id->from_id,
|
||||
'gateway_id' => $order->gateway_id,
|
||||
'order_id' => $order->id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'order_money' => $order->order_money,
|
||||
'pay_money' => $order->pay_money,
|
||||
'money' => $order->top_money,
|
||||
'ratio' => $order->top_ratio,//返点
|
||||
'name' => $this->serverObj->name . '的订单佣金',
|
||||
'order_at' => $order->order_at,
|
||||
'pay_ok_at' => $order->pay_ok_at,
|
||||
'status' => '2',//佣金状态,改为处理中,结算时是按后台结算
|
||||
];
|
||||
$this->merchantCommission($merchant_data, $top_id->from_id);//股东商户佣金写入
|
||||
//推广上级佣金写入
|
||||
$merchant_data = [
|
||||
'merchant_id' => $order->merchant_id,
|
||||
'from_merchant_id' => $this->serverObj->from_id,
|
||||
'gateway_id' => $order->gateway_id,
|
||||
'order_id' => $order->id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'order_money' => $order->order_money,
|
||||
'pay_money' => $order->pay_money,
|
||||
'money' => $order->next_money,
|
||||
'ratio' => $order->next_ratio,//返点
|
||||
'name' => $this->serverObj->name . '的订单佣金',
|
||||
'order_at' => $order->order_at,
|
||||
'pay_ok_at' => $order->pay_ok_at,
|
||||
'status' => '2',//佣金状态,改为处理中,结算时是按后台结算
|
||||
];
|
||||
$this->merchantCommission($merchant_data, $this->serverObj->from_id);//推广商户佣金写入
|
||||
} else {
|
||||
//推广上级佣金写入
|
||||
$merchant_data = [
|
||||
'merchant_id' => $order->merchant_id,
|
||||
'from_merchant_id' => $this->serverObj->from_id,
|
||||
'gateway_id' => $order->gateway_id,
|
||||
'order_id' => $order->id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'order_money' => $order->order_money,
|
||||
'pay_money' => $order->pay_money,
|
||||
'money' => $order->next_money,
|
||||
'ratio' => $order->next_ratio,//返点
|
||||
'name' => $this->serverObj->name . '的订单佣金',
|
||||
'order_at' => $order->order_at,
|
||||
'pay_ok_at' => $order->pay_ok_at,
|
||||
'status' => '2',//佣金状态,改为处理中,结算时是按后台结算
|
||||
];
|
||||
$this->merchantCommission($merchant_data, $this->serverObj->from_id);//推广商户佣金写入
|
||||
}
|
||||
//2级的时候
|
||||
}
|
||||
|
||||
$ysytem_pate = $order->system_ratio * $order->pay_money / 1000;
|
||||
//写入平台佣金
|
||||
$sys_data = [
|
||||
'merchant_id' => $order->merchant_id,
|
||||
'gateway_id' => $order->gateway_id,
|
||||
'order_id' => $order->id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'order_money' => $order->order_money,
|
||||
'pay_money' => $order->pay_money,
|
||||
'payfor_money' => $order->total_money,
|
||||
'money' => $ysytem_pate,
|
||||
'ratio' => $order->system_ratio,//系统佣金比率
|
||||
'name' => $order->merchant_name . '的订单佣金',
|
||||
'order_at' => $order->order_at,
|
||||
'pay_ok_at' => $order->pay_ok_at,
|
||||
'gateway_money' => $order->gateway_money,//通道扣除费用金额
|
||||
'gateway_ratio' => $order->gateway_ratio,//通道扣点
|
||||
'final_money' => $order->final_money,//最后盈利金额
|
||||
'final_ratio' => $order->final_ratio,//最后盈利扣点
|
||||
'status' => '1',
|
||||
];
|
||||
$this->debugLog('写入平台佣金:', $sys_data);
|
||||
$this->systemCommission($sys_data);//平台佣金
|
||||
|
||||
//资金变动
|
||||
$this->addMerchantMoneyLog($order->total_money, $order->pay_money);
|
||||
|
||||
}
|
||||
//写入日志
|
||||
$this->orderHandleLog(['from_status' => 0, 'to_status' => 2, 'name' => '完成订单支付操作'], $this->order_id);
|
||||
//回调队列
|
||||
//队列回调加入
|
||||
NotifyOrderJob::dispatch($order,1)->onQueue('order_notify');
|
||||
//风控
|
||||
$gateway=Gateway::find($order->gateway_id);
|
||||
$this->gategoryWind($gateway,$order->pay_money);
|
||||
|
||||
|
||||
return $this->msg(['error' => 0, 'msg' => '操作成功']);
|
||||
}
|
||||
return $this->msg(['error' => 1, 'msg' => '操作失败']);
|
||||
|
||||
}
|
||||
//支付风控写入
|
||||
public function gategoryWind($gateway,$money)
|
||||
{
|
||||
$gateway_id=$gateway->id;
|
||||
$gateway_name=$gateway->name.'('.$gateway->mch_id.')';
|
||||
//风控
|
||||
$obj = new GatewayWind();
|
||||
$has = GatewayWind::where(['gateway_id' => $gateway_id, 'day' => date('Y-m-d')])->first();
|
||||
|
||||
if ($has) {
|
||||
|
||||
$now_money = $money + $has->amount_total;
|
||||
$has->increment('amount_total', $money);//增加金额
|
||||
|
||||
//判断金额是否大于最大的限额,如果是,则更新通道并且关闭
|
||||
if ($now_money >= $has->max_total) {
|
||||
//更新通道为关闭,并且时系统设置
|
||||
Gateway::where('id', $gateway_id)->update(['is_checked' => 0, 'is_system_close' => 1]);
|
||||
write_gateway();//写入文件
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$obj->day = date('Y-m-d');
|
||||
$obj->gateway_name =$gateway_name;//通道
|
||||
$obj->amount_total = $money;
|
||||
$obj->gateway_id = $gateway_id;
|
||||
$obj->save();
|
||||
$this->debugLog('风控完成写入成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//推广商户佣金写入
|
||||
public function merchantCommission($data, $mid)
|
||||
{
|
||||
|
||||
return MerchantCommission::getOrCreate($data, ['order_id' => $this->orderObj->id, 'merchant_id' => $mid]);
|
||||
}
|
||||
|
||||
//商户钱包写入
|
||||
public function addMerchantWallet($trans_money, $money)
|
||||
{
|
||||
|
||||
return MerchantWallet::addWallte($this->orderObj->merchant_id, $trans_money, $money);
|
||||
}
|
||||
|
||||
//资金变动交易写入
|
||||
public function addMerchantMoneyLog($money, $pay_money)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
$r = MerchantMoneyLog::addMoney($this->orderObj, $money);
|
||||
if ($r) {
|
||||
//插入钱包变动
|
||||
$w_r=$this->addMerchantWallet($pay_money, $money);
|
||||
if($w_r)
|
||||
{
|
||||
DB::commit();
|
||||
}else{
|
||||
DB::rollBack();
|
||||
}
|
||||
}else
|
||||
{
|
||||
DB::rollBack();
|
||||
}
|
||||
}
|
||||
|
||||
public function msg($arr)
|
||||
{
|
||||
return response()->json($arr);
|
||||
}
|
||||
|
||||
//系统佣金写入
|
||||
public function systemCommission($data)
|
||||
{
|
||||
return SystemCommission::getOrCreate($data, ['order_id' => $this->orderObj->id]);
|
||||
}
|
||||
|
||||
|
||||
public function notifyPost(Request $request)
|
||||
{
|
||||
//发送curl过去
|
||||
$order_info = $this->orderObj->infos;
|
||||
if ($order_info) {
|
||||
$notify_url = $order_info->notify_url;//回调地址
|
||||
//签名计算
|
||||
$data = [
|
||||
'app_id' => $this->serverObj->app_key,
|
||||
'token' => $this->serverObj->token,
|
||||
'money' => $this->orderObj->order_money,
|
||||
'return_url' => $order_info->return_url,
|
||||
'notify_url' => $order_info->notify_url,
|
||||
'out_trade_sn' => $this->orderObj->out_trade_sn
|
||||
];
|
||||
//dump($data);
|
||||
//回调携带参数回去
|
||||
//返回付款金额,原来充值金额,本站订单号,支付流水号,原网站订单号,附加消息原样返回
|
||||
$notify_data = [
|
||||
'pay_money' => $this->orderObj->pay_money,
|
||||
'money' => $this->orderObj->order_money,
|
||||
'order_sn' => $this->orderObj->order_sn,
|
||||
'out_trade_sn' => $this->orderObj->out_trade_sn,
|
||||
'pay_order_sn' => $this->orderObj->pay_order_sn,
|
||||
// 'sign' => PayServices::sign($data, 1),
|
||||
'sign' => md5($this->serverObj->token . $order_info->sign . 'pay_money=' . $this->orderObj->pay_money . 'pay_status=' . $this->orderObj->pay_status),
|
||||
'attch' => $order_info->attach,
|
||||
'pay_status' => $this->orderObj->pay_status,
|
||||
'return_url' => $order_info->return_url,
|
||||
'notify_url' => $order_info->notify_url
|
||||
];
|
||||
//dd($notify_data);
|
||||
Log::channel('pay_order')->info('总后台手动回调信息', $notify_data);
|
||||
if (!$notify_url) {
|
||||
return response(['error' => 1, 'msg' => '回调失败,缺少回调地址', 'back' => '']);
|
||||
}
|
||||
|
||||
//发送curl
|
||||
$r = Curl::to($notify_url)->withData($notify_data)->post();
|
||||
//返回success表示回调成功
|
||||
//dump(gettype($r));
|
||||
|
||||
if ($r == 'success') {
|
||||
|
||||
DB::beginTransaction();
|
||||
//更新订单
|
||||
$this->orderObj->out_notify_status = 1;
|
||||
$this->orderObj->status = 1;
|
||||
$or = $this->orderObj->save();
|
||||
|
||||
//
|
||||
$order_info->notify_data = json_encode($notify_data);
|
||||
$order_info->notify_status = $r;
|
||||
$lr = $order_info->save();
|
||||
if ($lr && $or) {
|
||||
//写入日志
|
||||
$this->orderHandleLog(['from_status' => 2, 'to_status' => 3, 'name' => '外站回调成功'], $this->order_id);
|
||||
DB::commit();
|
||||
return response(['error' => 0, 'msg' => '回调成功', 'back' => $r]);
|
||||
}
|
||||
DB::rollBack();
|
||||
$this->orderHandleLog(['from_status' => 2, 'to_status' => 3, 'name' => '外站回调失败'], $this->order_id);
|
||||
return response(['error' => 1, 'msg' => '对方回调成功,本站更新失败', 'back' => $r]);
|
||||
} else {
|
||||
|
||||
return response(['error' => 1, 'msg' => '回调失败,外部没有返回success', 'back' => $r, 'sign_data' => $data, 'url' => $notify_url, 'notify_data' => $notify_data]);
|
||||
}
|
||||
|
||||
}
|
||||
return response(['error' => 1, 'msg' => '回调失败,缺少回调地址', 'back' => '']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//结算该笔订单
|
||||
public function payFor()
|
||||
{
|
||||
$this->setViewPath('', 'payfor');
|
||||
$status = config('adconfig.payfor_status');
|
||||
unset($status[0]);
|
||||
$data = [
|
||||
'status' => $status
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
|
||||
//结算提交
|
||||
public function PayForUpdate(Request $request)
|
||||
{
|
||||
if ($request->input('pay_time') == '') {
|
||||
return $this->msg(['error' => 1, 'msg' => '请填写必要参数']);
|
||||
}
|
||||
$status = $request->input('status');
|
||||
DB::beginTransaction();
|
||||
//更新订单
|
||||
$order = $this->orderObj;
|
||||
$order->success_status = $status;//结算状态
|
||||
$order->success_at = $request->input('pay_time');//结算时间
|
||||
$order->status = 1;
|
||||
|
||||
$r = $order->save();
|
||||
//如果结算为失败则不添加到结算日志里面
|
||||
|
||||
//写入结算日志
|
||||
$pay_for_data = [
|
||||
'status' => $status,
|
||||
'order_sn' => $order->order_sn,
|
||||
'money' => $order->total_money,
|
||||
'mark' => $request->input('mark'),
|
||||
'success_at' => $request->input('pay_time'),
|
||||
'out_trade_sn' => $order->out_trade_sn
|
||||
];
|
||||
$log_r = $this->payForLog($pay_for_data);
|
||||
if ($log_r && $r) {
|
||||
DB::commit();
|
||||
$this->orderHandleLog(['from_status' => 3, 'to_status' => 1, 'name' => '结算操作'], $this->order_id);
|
||||
return response(['error' => 0, 'msg' => '结算操作成功', 'back' => '']);
|
||||
}
|
||||
DB::rollBack();
|
||||
return response(['error' => 1, 'msg' => '结算操作失败', 'back' => '']);
|
||||
|
||||
}
|
||||
|
||||
//结算日志
|
||||
public function payForLog($config)
|
||||
{
|
||||
$log = new PayForLog();
|
||||
$log->order_id = $this->order_id;
|
||||
|
||||
foreach ($config as $k => $v) {
|
||||
$log->$k = $v;
|
||||
}
|
||||
$log->admin_id = admin('id');
|
||||
$log->admin_name = admin('account');
|
||||
$r = $log->save();
|
||||
if ($r) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//订单操作日志
|
||||
public function orderHandleLog($config)
|
||||
{
|
||||
$log = new OrderHandleLog();
|
||||
foreach ($config as $k => $v) {
|
||||
$log->$k = $v;
|
||||
}
|
||||
$log->order_id = $this->order_id;
|
||||
$log->handle_user_id = admin('id');//
|
||||
$log->handle_user_name = admin('account');//
|
||||
$log->handle_user_type = 'admin';//
|
||||
$r = $log->save();
|
||||
$this->insertLog('操作订单,行为是' . $config['name']);
|
||||
if ($r) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,274 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Order;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class PayForController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '订单结算'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
protected function postDataDb($request,$id='')
|
||||
{
|
||||
$data = $request->all();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
$type = [
|
||||
'server'=>Merchant::pluck('name','id')
|
||||
];
|
||||
return $type;
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$show = $this->setModel()->find($id);
|
||||
|
||||
$show->pay_type_name = $show->pay_type ? config('adconfig.pay_type')[$show->pay_type] : '未支付';
|
||||
$log = $show->logs->pluck('created_at', 'to_status')->toArray();
|
||||
|
||||
$logistics = count($show->logistics)>0 ? $show->logistics->first()->toArray() : [];
|
||||
$comment=$show->comments?$show->comments->first():[];
|
||||
|
||||
|
||||
$pictrue = $show->pictures;
|
||||
if ($show->pictures) {
|
||||
$pictrue->thumbs = $pictrue->thumbs ? json_decode(urldecode($pictrue->thumbs), true) : [];
|
||||
$pictrue->user_thumbs = $pictrue->user_thumbs ? json_decode(urldecode($pictrue->user_thumbs), true) : [];
|
||||
$pictrue->look_thumbs = $pictrue->look_thumbs ? json_decode(urldecode($pictrue->look_thumbs), true) : [];
|
||||
}
|
||||
|
||||
|
||||
//($pictrue);
|
||||
|
||||
|
||||
return $this->display(['show' => $show, 'logs' => $log,
|
||||
'pictrue' => $pictrue, 'logistics' => $logistics,'comment'=>$comment]);
|
||||
}
|
||||
|
||||
|
||||
public function shareData($show = '')
|
||||
{
|
||||
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new Order();
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$order_sn = $request->input('order_sn', '');
|
||||
$server_sn = $request->input('server_sn', '');
|
||||
$pay_order_sn = $request->input('pay_order_sn', '');
|
||||
$user_id = $request->input('user_id', '');
|
||||
$out_user_id = $request->input('out_user_id', '');
|
||||
|
||||
|
||||
$pay_status = $request->input('pay_status', '');
|
||||
$notify_status = $request->input('notify_status', '');
|
||||
$out_notify_status = $request->input('out_notify_status', '');
|
||||
$success_status = $request->input('success_status', '');
|
||||
|
||||
$day=$request->input('day','');
|
||||
|
||||
$month=$request->input('month','');
|
||||
|
||||
$time=$request->input('time','');
|
||||
$start_at='';
|
||||
$end_at='';
|
||||
if($time)
|
||||
{
|
||||
$time=str_replace('~',',',$time);
|
||||
$time=explode(",",$time);
|
||||
$start_at=isset($time[0])?$time[0]:'';
|
||||
$end_at=isset($time[1])?$time[1]:'';
|
||||
$month='';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$server_id = $request->input(' server_id', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$status = $request->input('status', '');
|
||||
$model = $this->setModel();
|
||||
$search_arr = [
|
||||
'order_sn' => [
|
||||
'type' => '=',
|
||||
'value' => $order_sn
|
||||
],
|
||||
'server_sn' => [
|
||||
'type' => '=',
|
||||
'value' => $server_sn
|
||||
],
|
||||
'pay_order_sn' => [
|
||||
'type' => '=',
|
||||
'value' => $pay_order_sn
|
||||
],
|
||||
'local_user_id' => [
|
||||
'type' => '=',
|
||||
'value' => $user_id
|
||||
],
|
||||
'out_user_id' => [
|
||||
'type' => '=',
|
||||
'value' => $out_user_id
|
||||
],
|
||||
'server_id' => [
|
||||
'type' => '=',
|
||||
'value' => $server_id
|
||||
],
|
||||
'pay_status' => [
|
||||
'type' => '=',
|
||||
'value' =>$pay_status
|
||||
],
|
||||
'notify_status' => [
|
||||
'type' => '=',
|
||||
'value' =>$notify_status
|
||||
],
|
||||
'out_notify_status' => [
|
||||
'type' => '=',
|
||||
'value' =>$out_notify_status
|
||||
],
|
||||
'success_status' => [
|
||||
'type' => '=',
|
||||
'value' =>$success_status
|
||||
]
|
||||
|
||||
|
||||
];
|
||||
$search_arr2 = [
|
||||
'pay_status' => [
|
||||
'type' => '=',
|
||||
'value' =>$pay_status
|
||||
],
|
||||
'notify_status' => [
|
||||
'type' => '=',
|
||||
'value' =>$notify_status
|
||||
],
|
||||
'out_notify_status' => [
|
||||
'type' => '=',
|
||||
'value' =>$out_notify_status
|
||||
],
|
||||
'success_status' => [
|
||||
'type' => '=',
|
||||
'value' =>$success_status
|
||||
]
|
||||
|
||||
|
||||
];
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
$model = $this->searchKey($model, $search_arr2, 1);
|
||||
|
||||
if($status!='')
|
||||
{
|
||||
$model=$model->where('status',$status);
|
||||
}
|
||||
//天
|
||||
if($day!='')
|
||||
{
|
||||
if($day<=0)
|
||||
{
|
||||
$day_at=(new Date($day."day"))->format('Y-m-d');
|
||||
$start_at=$day_at.' 00:00:00';
|
||||
if($day==-1)
|
||||
{
|
||||
$end_at=$day_at.' 23:59:59';
|
||||
}else
|
||||
{
|
||||
$end_at=(new Date('0 day'))->format('Y-m-d').' 23:59:59';
|
||||
}
|
||||
|
||||
$month='';
|
||||
}
|
||||
}
|
||||
//月
|
||||
if($month!='')
|
||||
{
|
||||
$date=date('Y-m-d H:i:s',strtotime($month.'month'));
|
||||
$month_at=get_month($date);
|
||||
if(count($month_at)>0)
|
||||
{
|
||||
|
||||
$start_at=$month_at[0];
|
||||
if($month==0 || $month=='-1')
|
||||
{
|
||||
$end_at=$month_at[1];
|
||||
}else
|
||||
{
|
||||
$end_at=get_month('',1,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//时间范围
|
||||
if($start_at)
|
||||
{
|
||||
$model=$model->whereRaw('(pay_ok_at>=? and pay_ok_at<=?)',[($start_at),($end_at)]);
|
||||
}
|
||||
|
||||
|
||||
$model=$model->selectRaw(
|
||||
'DATE_FORMAT(pay_ok_at,"%Y-%m-%d") as pay_at,
|
||||
sum(order_money) as order_money, sum(pay_money)
|
||||
as pay_money, sum(total_money) as total_money, sum(pay_rate) as pay_rate, CONCAT_WS("%",ROUND(ratio/10,1),"") as ratio,merchant_id,merchant_name'
|
||||
)->groupBy('pay_ok_at')->groupBy('merchant_id');
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('users','merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['show_url'] = $v->order_show_url;
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
public function checkStatus(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
return $this->getShow($id);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
|
||||
class PhpOfficeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
$filename = to_linux_path(public_path()) . '/phpoffice/world903599685.xlsx';
|
||||
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
|
||||
$reader->setReadDataOnly(true);
|
||||
$spreadsheet = $reader->load($filename);
|
||||
|
||||
dump($spreadsheet);
|
||||
}
|
||||
|
||||
public function index2()
|
||||
{
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->setCellValue('A1', 'Hello World !');
|
||||
$sheet->setCellValue(
|
||||
'A4',
|
||||
'=IF(A3, CONCATENATE(A1, " ", A2), CONCATENATE(A2, " ", A1))'
|
||||
);
|
||||
$sheet->getCell('B8')
|
||||
->setValue('Some value');
|
||||
// Get the current date/time and convert to an Excel date/time
|
||||
$dateTimeNow = time();
|
||||
$excelDateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($dateTimeNow);
|
||||
$cellValue = $sheet->getCell('A4')->getValue();
|
||||
$sheet->setCellValueByColumnAndRow(1, 5, 'PhpSpreadsheet');
|
||||
dump($cellValue);
|
||||
$sheet->setCellValue(
|
||||
'A6',
|
||||
$excelDateValue
|
||||
);
|
||||
$sheet->setCellValue(
|
||||
'A9',
|
||||
'0124578'
|
||||
);
|
||||
echo date('Y-m-d H:i:s');
|
||||
$sheet->getStyle('A6')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(
|
||||
'yyyy-mm-dd'
|
||||
);
|
||||
$sheet->setCellValueExplicit(
|
||||
'A8',
|
||||
"01513789642",
|
||||
\PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING
|
||||
);
|
||||
/*$sheet->getStyle('A9')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(
|
||||
'0000000'
|
||||
);*/
|
||||
|
||||
$dataArray = $sheet
|
||||
->rangeToArray(
|
||||
'A4:A6', // The worksheet range that we want to retrieve
|
||||
NULL, // Value that should be returned for empty cells
|
||||
TRUE, // Should formulas be calculated (the equivalent of getCalculatedValue() for each cell)
|
||||
TRUE, // Should values be formatted (the equivalent of getFormattedValue() for each cell)
|
||||
1 // Should the array be indexed by cell row and cell column
|
||||
);
|
||||
dump($dataArray);
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$filename = to_linux_path(public_path()) . '/phpoffice/world' . mt_rand(1000, 999999999) . '.xlsx';
|
||||
$writer->save($filename);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Sms;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class SmsController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '短信'
|
||||
];
|
||||
}
|
||||
public function indexData(){
|
||||
|
||||
return ['type'=>config('adconfig.sms_type')];
|
||||
}
|
||||
public function shareData($show='')
|
||||
{
|
||||
return $this->indexData();
|
||||
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'tpl_id' => 'required|unique:sms,tpl_id',
|
||||
'ename' => 'required|unique:sms,ename',
|
||||
'content' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
'tpl_id' =>'required|unique:sms,tpl_id,' . $id,
|
||||
'ename' =>'required|unique:sms,ename,' . $id,
|
||||
'content' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Sms();
|
||||
}
|
||||
public function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
//写入文件
|
||||
$sms=Sms::pluck('tpl_id','ename')->toArray();
|
||||
$file=to_linux_path(config_path()).'/smscode.php';
|
||||
$content="<?php\n return ".var_export($sms,true)."\n?>";
|
||||
file_put_contents($file,$content);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$type = $request->input('type', '1');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
$role=$request->input('role','');
|
||||
|
||||
$search_arr=[
|
||||
'type'=>[
|
||||
'type'=>'=',
|
||||
'value'=>$type
|
||||
]
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr,2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['type']=config('adconfig.sms_type')[$v['type']];
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Sms;
|
||||
use App\Models\SmsLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class SmsLogController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '短信日志'
|
||||
];
|
||||
}
|
||||
public function indexData(){
|
||||
|
||||
return ['type'=>config('adconfig.sms_type')];
|
||||
}
|
||||
public function shareData($show='')
|
||||
{
|
||||
return $this->indexData();
|
||||
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'tpl_id' => 'required|unique:sms,tpl_id',
|
||||
'ename' => 'required|unique:sms,ename',
|
||||
'content' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
'tpl_id' =>'required|unique:sms,tpl_id,' . $id,
|
||||
'ename' =>'required|unique:sms,ename,' . $id,
|
||||
'content' =>'required',
|
||||
'type' =>'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new SmsLog();
|
||||
}
|
||||
public function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
//写入文件
|
||||
$sms=Sms::pluck('tpl_id','ename')->toArray();
|
||||
$file=to_linux_path(config_path()).'/smscode.php';
|
||||
$content="<?php\n return ".var_export($sms,true)."\n?>";
|
||||
file_put_contents($file,$content);
|
||||
|
||||
}
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$type = $request->input('type', '1');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
$role=$request->input('role','');
|
||||
|
||||
$search_arr=[
|
||||
'type'=>[
|
||||
'type'=>'=',
|
||||
'value'=>$type
|
||||
]
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr,2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
// $v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
//$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Services\DateServices;
|
||||
use App\Services\DrawMoneyStatisServices;
|
||||
use App\Services\MerchantStatisServices;
|
||||
use App\Services\OrderStatisServices;
|
||||
use App\Services\SystemCommissionStatisServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class StatisController extends BaseController
|
||||
{
|
||||
//
|
||||
public function index($type, $method, Request $request)
|
||||
{
|
||||
|
||||
switch ($type) {
|
||||
case 'order':
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method($request);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
public function orderIndexStatis2($request)
|
||||
{
|
||||
$system_commiss = new SystemCommissionStatisServices();
|
||||
$data['prev_month_final_commiss'] = $system_commiss->getSum(['month' => 0, 'status' => 1], 'final_money');
|
||||
}
|
||||
public function orderIndexStatis($request)
|
||||
{
|
||||
$month = $request->input('month', 0);
|
||||
|
||||
$order = new OrderStatisServices();
|
||||
//月订单支付总额
|
||||
$data['month_order_money'] = $order->getSum(['month' => $month], 'order_money');
|
||||
//全部订单支付总额
|
||||
$data['month_order_all_money'] = $order->getSum([], 'order_money');
|
||||
//月成功支付总额,已经支付判断,不判断是否交易成功
|
||||
$data['month_order_ok_money'] = $order->getSum(['month' => $month, 'pay_status' => 1], 'pay_money');
|
||||
//全部成功支付总额,已经支付判断,不判断是否交易成功
|
||||
$data['month_order_ok_all_money'] = $order->getSum(['pay_status' => 1], 'pay_money');
|
||||
|
||||
//月结算总额
|
||||
$data['month_order_payfor_money'] = $order->getSum(['month' => $month, 'pay_status' => 1], 'total_money');
|
||||
|
||||
|
||||
//全部结算总额
|
||||
$data['month_order_payfor_all_money'] = $order->getSum(['pay_status' => 1], 'total_money');
|
||||
//今日结算
|
||||
$today_info = $order->getSumArr(['day' => 0, 'pay_status' => 1], ['total_money', 'final_money']);
|
||||
//dd($today_info);
|
||||
//今日盈利
|
||||
$data['day_payfor_money'] = $today_info['total_money'] ? $today_info['total_money'] : 0;
|
||||
$data['day_profit_money'] = $today_info['final_money'] ? $today_info['final_money'] : 0;
|
||||
//昨天盈利
|
||||
$yesterday_info = $order->getSumArr(['day' => -1, 'pay_status' => 1], ['total_money', 'final_money']);
|
||||
$data['yesterday_payfor_money'] = $yesterday_info['total_money'] ? $yesterday_info['total_money'] : 0;
|
||||
$data['yesterday_profit_money'] = $yesterday_info['final_money'] ? $yesterday_info['final_money'] : 0;
|
||||
|
||||
//今日提现申请
|
||||
$draw = new DrawMoneyStatisServices();
|
||||
$data['day_draw_money'] = $draw->getSum(['day' => 0, 'status_in' => [0, 2]], 'draw_money');
|
||||
|
||||
//提现手续费收入
|
||||
$data['day_draw_fee_money'] = $draw->getSum(['statut' => 1], 'fee_money');
|
||||
|
||||
|
||||
$system_commiss = new SystemCommissionStatisServices();
|
||||
|
||||
|
||||
$system_commiss_month = $system_commiss->getSumArr(['month' => $month, 'status' => 1], ['final_money', 'gateway_money']);
|
||||
|
||||
$data['prev_month_final_commiss'] = $system_commiss->getSum(['month' => -1, 'status' => 1], 'final_money');
|
||||
|
||||
$data['month_sys_commiss'] = money_str(sprintf("%.2f", (array_sum($system_commiss_month))));
|
||||
$system_commiss_all = $system_commiss->getSumArr(['status' => 1], ['final_money', 'gateway_money']);
|
||||
$data['month_sys_all_commiss'] = money_str(sprintf("%.2f", (array_sum($system_commiss_all))));
|
||||
//纯收入查询
|
||||
$data['month_final_commiss'] = money_str($system_commiss_month['final_money']);
|
||||
$data['month_final_all_commiss'] = money_str($system_commiss_all['final_money']);
|
||||
//支付宝扣除
|
||||
|
||||
$data['month_zf_commiss'] = money_str($system_commiss_month['gateway_money']);
|
||||
$data['month_zf_all_commiss'] = money_str($system_commiss_all['gateway_money']);
|
||||
|
||||
|
||||
return $this->jsonFormat($data, $request);
|
||||
}
|
||||
|
||||
//商户信息
|
||||
public function merchantStatis($request)
|
||||
{
|
||||
//商户信息
|
||||
$merchant = new MerchantStatisServices();
|
||||
$data['merchant_proxy_number'] = $merchant->getNumber(['level' => 2]);
|
||||
$data['merchant_gudong_number'] = $merchant->getNumber(['level' => 1]);
|
||||
//全部
|
||||
$data['merchant_number'] = $merchant->getNumber(['level' => 3]);
|
||||
//等待审核
|
||||
$data['merchant_wait_number'] = $merchant->getNumber(['check_status' => 2]);
|
||||
return $this->jsonFormat($data, $request);
|
||||
}
|
||||
|
||||
//提现申请
|
||||
public function drawStatis($request)
|
||||
{
|
||||
//商户信息
|
||||
$draw = new DrawMoneyStatisServices();
|
||||
$data['draw_number'] = $draw->getNumber(['status' => 0]);
|
||||
//全部
|
||||
|
||||
return $this->jsonFormat($data, $request);
|
||||
}
|
||||
|
||||
//活跃订单商户
|
||||
public function topOrderNumber($request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$data['pay_status'] = 1;
|
||||
$order = new OrderStatisServices();
|
||||
$total = $order->topMerchantNumber($data);
|
||||
|
||||
return $this->jsonFormat($total, $request);
|
||||
|
||||
}
|
||||
|
||||
//失败率订单商户
|
||||
public function successFailNumber($request)
|
||||
{
|
||||
$date = DateServices::today();
|
||||
|
||||
$data = DB::select("select t.merchant_name,t.merchant_id,t.total,t.created_at ,t.order_money,
|
||||
(select sum(p.order_money) from orders p where p.merchant_id=t.merchant_id and pay_status='1' and created_at>='" . $date['start_at'] . "' and created_at <='" . $date['end_at'] . "') as ok_money,
|
||||
(select count(p.pay_status) from orders p where p.merchant_id=t.merchant_id and pay_status='1' and created_at>='" . $date['start_at'] . "' and created_at <='" . $date['end_at'] . "')as ok_total from
|
||||
(select count(pay_status) as total,sum(order_money)as order_money,merchant_id,merchant_name,created_at from orders where created_at>='" . $date['start_at'] . "' and created_at <='" . $date['end_at'] . "' group by merchant_id) t ORDER BY order_money desc");
|
||||
|
||||
return $this->jsonFormat($data, $request);
|
||||
|
||||
}
|
||||
|
||||
//订单量+资金
|
||||
public function dayOrderNumber($request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$order = new OrderStatisServices();
|
||||
|
||||
|
||||
$time = $request->input('timeDay');
|
||||
$time = str_replace('~', ',', $time);
|
||||
$time = explode(",", $time);
|
||||
$start_at = isset($time[0]) ? $time[0] : '';
|
||||
$end_at = isset($time[1]) ? $time[1] : '';
|
||||
|
||||
|
||||
if ($start_at) {
|
||||
|
||||
$days = DateServices::diffDay($end_at, $start_at);
|
||||
|
||||
for ($i = 0; $i <= $days; $i++) {
|
||||
$put['x'][] = DateServices::incrDay($start_at, $i);
|
||||
}
|
||||
}
|
||||
$put['order'] = $this->dayOrderNumberDoing($put['x'], $order->dayOrderNumber($data));
|
||||
|
||||
$put['order_pay'] = $this->dayOrderNumberDoing($put['x'], $order->dayOrderNumber($data + ['pay_status' => 1]));
|
||||
|
||||
$put['order_ok'] = $this->dayOrderNumberDoing($put['x'], $order->dayOrderNumber($data + ['status' => 1]));
|
||||
//$put['order_fail']=$this->dayOrderNumberDoing($put['x'],$order->dayOrderNumber($data+['pay_status'=>0]));
|
||||
//dd($put);
|
||||
|
||||
return $this->jsonFormat($put, $request);
|
||||
}
|
||||
|
||||
public function dayOrderNumberDoing($days, $data)
|
||||
{
|
||||
|
||||
$arr = [];
|
||||
|
||||
foreach ($days as $k => $v) {
|
||||
$arr['number'][$v] = 0;
|
||||
$arr['order_money'][$v] = 0;
|
||||
$arr['pay_money'][$v] = 0;
|
||||
$arr['total_money'][$v] = 0;
|
||||
|
||||
}
|
||||
if (count($data) >= 0) {
|
||||
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
|
||||
|
||||
if (in_array($v['day'], $days)) {
|
||||
$arr['number'][$v['day']] = $v['number'];
|
||||
$arr['order_money'][$v['day']] = $v['order_money'];
|
||||
$arr['pay_money'][$v['day']] = $v['pay_money'];
|
||||
$arr['total_money'][$v['day']] = $v['total_money'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$narr['detail'] = $data;
|
||||
$narr['echart'] = $arr;
|
||||
return $narr;
|
||||
}
|
||||
|
||||
public function jsonFormat($msg, $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['error' => 0, 'data' => $msg]);
|
||||
}
|
||||
return (['error' => 0, 'data' => $msg]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\SystemCommission;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class SystemCommissionController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
|
||||
|
||||
$this->pages = [
|
||||
'name' => '平台佣金'
|
||||
];
|
||||
}
|
||||
public function indexData()
|
||||
{
|
||||
$status=config('adconfig.commission_status');
|
||||
return ['status'=>$status,'merchant'=>Merchant::get()];
|
||||
}
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
}
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new SystemCommission();
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$merchant_id = $request->input('merchant_id', '');
|
||||
$order_sn = $request->input('order_sn', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$status = $request->input('status', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$day=$request->input('day','');
|
||||
|
||||
$month=$request->input('month','');
|
||||
|
||||
$time=$request->input('time','');
|
||||
$start_at='';
|
||||
$end_at='';
|
||||
if($time)
|
||||
{
|
||||
$time=str_replace('~',',',$time);
|
||||
$time=explode(",",$time);
|
||||
$start_at=isset($time[0])?$time[0]:'';
|
||||
$end_at=isset($time[1])?$time[1]:'';
|
||||
$month='';
|
||||
}
|
||||
if($status!='')
|
||||
{
|
||||
$model=$model->where('status',$status);
|
||||
}
|
||||
//天
|
||||
if($day!='')
|
||||
{
|
||||
if($day<=0)
|
||||
{
|
||||
$day_at=(new Date($day."day"))->format('Y-m-d');
|
||||
$start_at=$day_at.' 00:00:00';
|
||||
if($day==-1)
|
||||
{
|
||||
$end_at=$day_at.' 23:59:59';
|
||||
}else
|
||||
{
|
||||
$end_at=(new Date('0 day'))->format('Y-m-d').' 23:59:59';
|
||||
}
|
||||
|
||||
$month='';
|
||||
}
|
||||
}
|
||||
//月
|
||||
if($month!='')
|
||||
{
|
||||
$date=date('Y-m-d H:i:s',strtotime($month.'month'));
|
||||
$month_at=get_month($date);
|
||||
if(count($month_at)>0)
|
||||
{
|
||||
|
||||
$start_at=$month_at[0];
|
||||
if($month==0 || $month=='-1')
|
||||
{
|
||||
$end_at=$month_at[1];
|
||||
}else
|
||||
{
|
||||
$end_at=get_month('',1,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//时间范围
|
||||
if($start_at)
|
||||
{
|
||||
$model=$model->whereRaw('(order_at>=? and order_at<=? )',[($start_at),($end_at)]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$search_arr = [
|
||||
'merchant_id' => [
|
||||
'value' => $merchant_id,
|
||||
'type' => '='
|
||||
],
|
||||
'order_sn' => [
|
||||
'value' => $order_sn,
|
||||
'type' => '='
|
||||
]
|
||||
|
||||
];
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['status_name'] = $v->status_name;
|
||||
$v['name']=$v->merchants['name'];
|
||||
$v['show_url']=admin_url('Order','show',['id'=>$v['order_id']]);
|
||||
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\SystemUpdateLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class SystemUpdateLogController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '系统更新日志'
|
||||
];
|
||||
}
|
||||
public function indexData()
|
||||
{
|
||||
$data=config('adconfig.system_log_type');
|
||||
return ['system_log_type'=>$data];
|
||||
}
|
||||
|
||||
public function shareData($id = '')
|
||||
{
|
||||
$data=config('adconfig.system_log_type');
|
||||
return ['system_log_type'=>$data];
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new SystemUpdateLog();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
$type = $request->input('type', '');
|
||||
|
||||
$search_arr=[
|
||||
'type'=>[
|
||||
'type'=>'=',
|
||||
'value'=>$type
|
||||
]
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr,2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['type_name']=$v->type_name;
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class TagsController extends BaseTypeController
|
||||
{
|
||||
//
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$arr=config('adconfig.tags_group');
|
||||
|
||||
|
||||
$this->pages = [
|
||||
'name' => $arr[request()->group_type]
|
||||
];
|
||||
}
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new Tag();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson($group_type,Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'sort');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
'type'=>[
|
||||
'type'=>'=',
|
||||
'value'=>$group_type
|
||||
]
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['group_type'=>$group_type,'id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['group_type'=>$group_type,'id' => $v->id]);
|
||||
|
||||
$v['thumb']=picurl($v['thumb']);
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\BankRel;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserController extends BaseDefaultController
|
||||
{
|
||||
//
|
||||
public function setPagesInfo()
|
||||
{
|
||||
|
||||
|
||||
$this->pages = [
|
||||
'name' => '会员'
|
||||
];
|
||||
|
||||
}
|
||||
public function indexData()
|
||||
{
|
||||
|
||||
return ['merchant'=>Merchant::get()];
|
||||
}
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'nickname' => 'required',
|
||||
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'nickname' => 'required'
|
||||
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new User();
|
||||
}
|
||||
protected function postDataDb($request,$id=''){
|
||||
$data=$request->all();
|
||||
$data['ip']=$request->getClientIp();
|
||||
|
||||
if(!$request->input('password'))
|
||||
{
|
||||
unset($data['password']);
|
||||
}else
|
||||
{
|
||||
$data['password']=Hash::make($data['password']);
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$merchant_id = $request->input('merchant_id', '');
|
||||
$user_id = $request->input('user_id', '');
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
'merchant_id'=>[
|
||||
'type'=>'=',
|
||||
'value'=>$merchant_id
|
||||
],
|
||||
'user_id'=>[
|
||||
'type'=>'likesql',
|
||||
'value'=>$user_id?"id like '%".$user_id."%' or from_user_id like '%".$user_id."%' or nickname like '%".$user_id."%'":""
|
||||
]
|
||||
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr,2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->with('merchants')->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['merchant_name']=$v->merchants->name;
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Config;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Cache;
|
||||
|
||||
class WebSiteController extends BaseDefaultController
|
||||
{
|
||||
//
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '网站配置'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
|
||||
$type=request()->input('type','config');
|
||||
$this->setViewPath('',$type);
|
||||
|
||||
$config=$type.'_config';
|
||||
|
||||
if($type=='draw')
|
||||
{
|
||||
$this->title='提现条件';
|
||||
}
|
||||
if($type=='config')
|
||||
{
|
||||
$this->title='网站设置';
|
||||
$config='config';
|
||||
}
|
||||
|
||||
|
||||
$config=config_cache($config);
|
||||
// dump($config);
|
||||
$this->setTitle();
|
||||
|
||||
return $this->display($config);
|
||||
}
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'ename' => 'required|unique:permissions,name',
|
||||
'content' => 'required',
|
||||
'type' => 'required',
|
||||
'name' => 'required',
|
||||
];
|
||||
}
|
||||
return [
|
||||
'ename' => 'required|unique:permissions,name,' . $id,
|
||||
'content' => 'required',
|
||||
'type' => 'required',
|
||||
'name' => 'required',
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new Config();
|
||||
}
|
||||
public function store(Request $request)
|
||||
{
|
||||
$config_name=$request->input('config_name','config');
|
||||
config_cache($config_name,$request->all());
|
||||
if(Cache::has($config_name))
|
||||
{
|
||||
return $this->saveMessage(1,$request,'');
|
||||
}
|
||||
return $this->saveMessage(0,$request,'');
|
||||
|
||||
}
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\Gateway;
|
||||
use App\Models\UploadQrcode;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ZhanxinController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
|
||||
$this->pages = [
|
||||
'name' => '展信支付'
|
||||
];
|
||||
}
|
||||
public function postDataDb($request, $id = '')
|
||||
{
|
||||
$data=$request->all();
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'username' => 'required',
|
||||
'introduce' => 'required',
|
||||
//'app_id'=> 'required',
|
||||
];
|
||||
}
|
||||
return [
|
||||
'username' => 'required',
|
||||
'introduce' => 'required',
|
||||
//'app_id'=> 'required',
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function shareData($id = '')
|
||||
{
|
||||
$data=[
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
public function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
// write_gateway();//写入配置文件
|
||||
|
||||
}
|
||||
|
||||
//通道写入文件
|
||||
function write_gateway()
|
||||
{
|
||||
$arr = [];
|
||||
$config2 = \App\Models\UploadQrcode::get()->toArray();
|
||||
$config2 = data_to_key($config2, 'id');
|
||||
$data['config'] = $config2;
|
||||
$data = $data + $arr;
|
||||
|
||||
$file = to_linux_path(config_path()) . '/gateway.php';
|
||||
$content = "<?php\n return " . var_export($data, true) . "\n?>";
|
||||
file_put_contents($file, $content);
|
||||
}
|
||||
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
$upload= new UploadQrcode(['upload_user'=>admin('id')]);
|
||||
return $upload;
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'client_type');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy('id', $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['thumb']=picurl($v['thumb']);
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Route;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public function msg($data){
|
||||
if(request()->ajax())
|
||||
{
|
||||
return response()->json($data);
|
||||
}
|
||||
return $this->htmlAlert($data);
|
||||
|
||||
}
|
||||
public function htmlAlert($data){
|
||||
echo '<script>alert("'.$data['msg'].'");window.history.back()</script>';
|
||||
}
|
||||
public function json($data){
|
||||
$debug=\request()->input('debug');
|
||||
if($debug)
|
||||
{
|
||||
dd($data);
|
||||
}
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderInfo;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OrderApiController extends BaseController
|
||||
{
|
||||
//
|
||||
public function checkPay(Request $request)
|
||||
{
|
||||
$order_sn = $request->input('order_sn');
|
||||
Log::channel('pay_order')->info('查询订单'.json_encode($request->input()), $request->input());
|
||||
if (!$order_sn) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '订单不存在',
|
||||
'backurl' => '',
|
||||
];
|
||||
} else {
|
||||
//查询这个订单是否已经支付
|
||||
$order = Order::where('order_sn', $order_sn)->first();
|
||||
if ($order['pay_status'] == 1) {
|
||||
$backurl = route('web.user.index');
|
||||
//判断是否是商户id
|
||||
if ($order->merchant_id == 0) {
|
||||
$backurl = route('web.user.index');
|
||||
} else {
|
||||
//判断外站
|
||||
//取得订单信息
|
||||
$order_info = OrderInfo::where('order_id', $order['id'])->first();
|
||||
$return_url = $order_info->return_url;
|
||||
$merchant = get_merchant($order_info->app_id);//取得商户
|
||||
//发送回调
|
||||
//发送签名过去,组装信息
|
||||
$notify_data = [
|
||||
'pay_money' => $order->pay_money,
|
||||
'money' => $order->order_money,
|
||||
'order_sn' => $order->order_sn,
|
||||
'out_trade_sn' => $order->out_trade_sn,
|
||||
'pay_order_sn' => $order->pay_order_sn,
|
||||
// 'sign' => md5($merchant['token'] . $order_info->sign),
|
||||
'sign' => md5($merchant['token'] . $order_info->sign . 'pay_money=' . $order->pay_money . 'pay_status=' . $order->pay_status),
|
||||
'attch' => $order_info->attach,
|
||||
'pay_status' => $order->pay_status,
|
||||
'return_url' => $order_info->return_url,
|
||||
'notify_url' => $order_info->notify_url,
|
||||
];
|
||||
$backurl = arr_to_url($return_url, $notify_data);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'msg' => '支付成功',
|
||||
'backurl' => $backurl,
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '等待支付',
|
||||
'backurl' => '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->json($data);
|
||||
}
|
||||
|
||||
public function cancleOrder(Request $request)
|
||||
{
|
||||
$order_sn = $request->input('order_sn');
|
||||
if (!$order_sn) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '订单不存在',
|
||||
'backurl' => '',
|
||||
];
|
||||
} else {
|
||||
//查询这个订单是否已经支付
|
||||
//只能取消30分钟前的订单
|
||||
$date_at = date('Y-m-d H:i:s', strtotime('-30 minute'));
|
||||
$order = Order::where('order_sn', $order_sn)->where('order_at', '>=', $date_at)->first();
|
||||
if (empty($order)) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '订单不存在',
|
||||
'backurl' => '',
|
||||
];
|
||||
return $this->json($data);
|
||||
}
|
||||
if ($order['pay_status'] == 1) {
|
||||
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '支付成功',
|
||||
'backurl' => route('web.pay.scan.return', ['order_sn' => $order->order_sn]),
|
||||
];
|
||||
} else {
|
||||
//进行取消订单
|
||||
$order->status = 4;//取消订单
|
||||
$r = $order->save();
|
||||
if ($r) {
|
||||
$order_info = OrderInfo::where('order_id', $order->id)->first();
|
||||
$url_info = parse_url($order_info->return_url);
|
||||
$backurl = '';
|
||||
if (isset($url_info['scheme'])) {
|
||||
$backurl = $url_info['scheme'] . '://';
|
||||
}
|
||||
if (isset($url_info['host'])) {
|
||||
$backurl .= $url_info['host'];
|
||||
}
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'msg' => '取消订单成功',
|
||||
'backurl' => $backurl,
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->json($data);
|
||||
}
|
||||
|
||||
public function updateOrder(Request $request)
|
||||
{
|
||||
$mark = $request->input('pay_mark');
|
||||
$pay_account = $request->input('pay_account');
|
||||
$order_sn = $request->input('order_sn');
|
||||
if (!$order_sn) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '订单不存在',
|
||||
'backurl' => '',
|
||||
];
|
||||
return $this->json($data);
|
||||
}
|
||||
$date_at = date('Y-m-d H:i:s', strtotime('-30 minute'));
|
||||
$order = Order::where('order_sn', $order_sn)->where('order_at', '>=', $date_at)->first();
|
||||
if (empty($order)) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '订单不存在',
|
||||
'backurl' => '',
|
||||
];
|
||||
return $this->json($data);
|
||||
}
|
||||
if($order->ewm_mark || $order->ewm_account)
|
||||
{
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '你已经提交过',
|
||||
'backurl' => '',
|
||||
];
|
||||
return $this->json($data);
|
||||
}
|
||||
//xieru
|
||||
$order->ewm_mark = $mark;
|
||||
$order->ewm_account = $pay_account;
|
||||
$r = $order->save();
|
||||
if ($r) {
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'msg' => '提交成功,请等待系统确认',
|
||||
'backurl' => '',
|
||||
];
|
||||
return $this->json($data);
|
||||
}
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '提交失败,请重试',
|
||||
'backurl' => '',
|
||||
];
|
||||
return $this->json($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
public function login(Request $request)
|
||||
{
|
||||
$this->validateLogin($request);
|
||||
|
||||
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
||||
// the login attempts for this application. We'll key this by the username and
|
||||
// the IP address of the client making these requests into this application.
|
||||
if ($this->hasTooManyLoginAttempts($request)) {
|
||||
$this->fireLockoutEvent($request);
|
||||
return $this->sendLockoutResponse($request);
|
||||
}
|
||||
|
||||
if ($this->attemptLogin($request)) {
|
||||
return $this->sendLoginResponse($request);
|
||||
}
|
||||
|
||||
// If the login attempt was unsuccessful we will increment the number of attempts
|
||||
// to login and redirect the user back to the login form. Of course, when this
|
||||
// user surpasses their maximum number of attempts they will get locked out.
|
||||
$this->incrementLoginAttempts($request);
|
||||
|
||||
return $this->sendFailedLoginResponse($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'nickname' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'nickname' => $data['nickname'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Collect;
|
||||
|
||||
|
||||
|
||||
use App\Models\MerchantLog;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Route;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Validator;
|
||||
use AnyUpload;
|
||||
use DB;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
//
|
||||
const ADMIN_BLADE_DIR='collect.';
|
||||
public $title='采集';
|
||||
public $route=[];
|
||||
public $pages=[];
|
||||
public $model;
|
||||
public $share_view=[];
|
||||
public $guard_name='';
|
||||
public $dblast_id='';
|
||||
public $merchant_id;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$route_arr=explode('@', Route::currentRouteAction());
|
||||
$this->route['controller_name']='\\'.$route_arr[0];
|
||||
$this->route['action_name']=$route_arr[1];
|
||||
$this->route['controller_base']=str_replace('Controller','',str_replace('App\\Http\\Controllers\\Collect\\','',$route_arr[0]));
|
||||
$this->route['blade']=self::ADMIN_BLADE_DIR.strtolower($this->route['controller_base']).'.'.$this->route['action_name'];
|
||||
$this->share_view['controller']="\\".$this->route['controller_name'];
|
||||
|
||||
$this->title=ucwords($this->route['action_name']);
|
||||
$this->share_view['title']=$this->title;
|
||||
//$this->handleUrl();
|
||||
$this->getTable();
|
||||
$this->share_view['action_name']=$this->route['action_name'];
|
||||
$this->share_view['page']=$this->pages;
|
||||
$this->setTitle('采集');
|
||||
$this->shareView();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function alertError($error_str,$status=1){
|
||||
return response()->json( ['error'=>$status,'msg'=>$error_str,'type'=>'validator']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 共享视图资源
|
||||
* @return mixed
|
||||
*/
|
||||
public function shareView(){
|
||||
|
||||
return view()->share($this->share_view);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置页面标题
|
||||
* @param string $title
|
||||
*/
|
||||
protected function setTitle($title=''){
|
||||
$title=$title?$title:$this->pages['name'];
|
||||
$this->share_view['title']=$title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 改变自动获取blade
|
||||
* @param $path
|
||||
* @param int $cover 是否完全覆盖
|
||||
* @param int $is_seft 是否在当前的控制下目录
|
||||
* @return string
|
||||
*/
|
||||
protected function setViewPath($path='',$filename='',$cover=0,$is_seft=1)
|
||||
{
|
||||
if($cover){
|
||||
return $this->route['blade']=$path;
|
||||
}
|
||||
if($is_seft==0)
|
||||
{
|
||||
return $this->route['blade']=self::ADMIN_BLADE_DIR.$path;
|
||||
}
|
||||
if($filename!='')
|
||||
{
|
||||
$this->route['action_name']=$filename;
|
||||
}
|
||||
if($path)
|
||||
{
|
||||
return $this->route['blade']=self::ADMIN_BLADE_DIR.$this->route['action_name']=$path.".".$this->route['action_name'];
|
||||
}
|
||||
return $this->route['blade']=self::ADMIN_BLADE_DIR.strtolower($this->route['controller_base']).'.'.$this->route['action_name'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得table
|
||||
* @return string
|
||||
*/
|
||||
protected function getTable(){
|
||||
if(gettype($this->setModel())!='object')
|
||||
{
|
||||
$table='';
|
||||
}else
|
||||
{
|
||||
$table=$this->setModel()->getTable();
|
||||
}
|
||||
$this->share_view['table_name']=$table;
|
||||
$this->shareView();
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 本页面操作的模型
|
||||
*/
|
||||
protected function setModel(){
|
||||
|
||||
}
|
||||
|
||||
protected function getShow($id){
|
||||
$show=$this->setModel()->find($id);
|
||||
if(!$show)
|
||||
{
|
||||
return abort(404);
|
||||
}
|
||||
view()->share('show',$show);
|
||||
|
||||
return $this->display($this->shareData($show));
|
||||
}
|
||||
/**
|
||||
* 输出视图
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function display($data=[]){
|
||||
|
||||
return view($this->route['blade'],$data);
|
||||
}
|
||||
|
||||
public function jsonDebug($json){
|
||||
print_r($json);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
public function indexData(){
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
//共享创建和编辑数据
|
||||
protected function shareData($id=''){
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function errorJosn($msg){
|
||||
return ['error'=>1,'msg'=>$msg];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function jsonMsg($error,$str){
|
||||
return response()->json(['error'=>$error,'msg'=>$str]);
|
||||
}
|
||||
/*********基本控制器资源设置*********/
|
||||
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
|
||||
return abort('401',$method.'方法不存在');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Collect;
|
||||
|
||||
use App\Models\MerchantCommission;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class MerchantCommissionController extends BaseController
|
||||
{
|
||||
//
|
||||
public function index(){
|
||||
$time=config_cache('corn_config.merchant_time');
|
||||
$number=config_cache('corn_config.merchant_update_number');
|
||||
$data=[
|
||||
'time'=>60*$time,
|
||||
'title'=>'商户佣金采集结算',
|
||||
'page_name'=>'商户佣金自动结算采集'
|
||||
];
|
||||
//自动采集
|
||||
|
||||
$data['count']=MerchantCommission::autoStatus($number);
|
||||
return $this->display($data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Collect;
|
||||
|
||||
use App\Models\MerchantCommission;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class OrderController extends BaseController
|
||||
{
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
$time = config_cache('corn_config.order_time');
|
||||
$number = config_cache('corn_config.order_nopay_number');
|
||||
$data = [
|
||||
'time' => 60 * $time,
|
||||
'title' => '订单自动删除未支付',
|
||||
'page_name' => '订单自动删除未支付',
|
||||
];
|
||||
//自动采集
|
||||
$data['count'] = Order::autoDeleteNopay($number, ['day_before' => -1]);
|
||||
|
||||
$this->setViewPath('common', 'index', 0);
|
||||
return $this->display($data);
|
||||
}
|
||||
|
||||
public function cancleOrder()
|
||||
{
|
||||
|
||||
$time = 17;
|
||||
|
||||
$data = [
|
||||
'time' => 60 * $time,
|
||||
'title' => '订单自动取消未支付',
|
||||
'page_name' => '订单自动取消未支付',
|
||||
'html' => ''
|
||||
];
|
||||
//自动删除30分钟前订单
|
||||
$data['count'] = Order::autoCancleNopay( ['minute' => $time]);
|
||||
$this->setViewPath('common', 'index', 0);
|
||||
return $this->display($data);
|
||||
|
||||
}
|
||||
|
||||
//定时回调给外站
|
||||
public function notify(Request $request)
|
||||
{
|
||||
|
||||
$notify_number = $request->input('number', 2);
|
||||
$time = config_cache_default('corn_config.merchant_notify_time', 10);
|
||||
|
||||
$number = config_cache_default('corn_config.merchant_notify_time_number', 20);
|
||||
|
||||
$data = [
|
||||
'time' => $time,
|
||||
'title' => '定时回调给商户',
|
||||
'page_name' => '定时回调给商户',
|
||||
];
|
||||
$order = Order::with(['merchants', 'users', 'infos'])->where(['out_notify_status' => 0, 'pay_status' => 1])->where('notify_number', '<=', $notify_number)->limit($number)->get();
|
||||
$data['count'] = Order::with(['merchants', 'users', 'infos'])->where(['out_notify_status' => 0, 'pay_status' => 1])->where('notify_number', '<=', $notify_number)->count();
|
||||
$log = [];
|
||||
$html = '';
|
||||
foreach ($order as $k => $v) {
|
||||
$r = Order::notifyMerchant($v, 'obj');
|
||||
$result = $r;
|
||||
$html .= 'Order id:' . $v->id . '---,回调状态' . ($result['error'] == 0 ? '成功' : '失败');
|
||||
$html .= $result['msg'];
|
||||
$html .= '<br>';
|
||||
|
||||
}
|
||||
|
||||
//插入日志
|
||||
$data['html'] = $html;
|
||||
$this->setViewPath('common', 'index', 0);
|
||||
return $this->display($data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,277 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\Area;
|
||||
use App\Models\DrawMoney;
|
||||
use App\Models\DrawSet;
|
||||
use App\Models\MerchantMoneyLog;
|
||||
use App\Models\MerchantWallet;
|
||||
use App\Models\Order;
|
||||
use App\Models\Shop;
|
||||
use App\Models\ShopServer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ApiController extends BaseController
|
||||
{
|
||||
//
|
||||
public function index($type, $name, Request $request)
|
||||
{
|
||||
|
||||
switch ($type) {
|
||||
case 'draw_money_fee':
|
||||
return $this->drawMoneyFee($request);
|
||||
break;
|
||||
case 'draw_money_list':
|
||||
return $this->drawMoneyTop($request);
|
||||
break;
|
||||
case 'money_log_list':
|
||||
return $this->moneyLog($request);
|
||||
break;
|
||||
case 'update_order_fail_number':
|
||||
return $this->updateOrderWallter($request);
|
||||
break;
|
||||
case 'create_key':
|
||||
return $this->createKey($request);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 计算提现手续费
|
||||
*/
|
||||
public function drawMoneyFee($request)
|
||||
{
|
||||
//搜索费率
|
||||
$draw_money = $request->input('draw_money');
|
||||
$draw_type = $request->input('draw_type');
|
||||
$max_fee = DrawSet::where('draw_type', $draw_type)->whereRaw('start_money <= ? and end_money >= ?', [$draw_money, $draw_money])->first();
|
||||
$data['money'] = empty($max_fee) ? 0 : $max_fee['money'];
|
||||
//判断是否在这个范围,如果没有判断是否大于最多的那个end_money,如果大于,取得最后一个
|
||||
if (empty($max_fee)) {
|
||||
//$data['money']=DrawSet::max('money');//最大的手续费
|
||||
//如果没有设置的话,则按0.3%计算
|
||||
$radio = config_cache('draw_config.draw_money_ratio');
|
||||
$ratio = is_null($radio) || $radio == '' ? '0.3' : $radio;
|
||||
$data['money'] = $draw_money * $ratio / 100;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function drawMoneyTop($request)
|
||||
{
|
||||
$draw_money = DrawMoney::where(['merchant_id' => $this->getMerchantId()])->limit(10)->orderBy('id', 'desc')->get();
|
||||
$data = [];
|
||||
if (count($draw_money) > 0) {
|
||||
foreach ($draw_money as $k => $v) {
|
||||
$v['status_name'] = $v->status_name;
|
||||
$data[] = $v;
|
||||
}
|
||||
}
|
||||
return $this->jsonFormat($data, $request);
|
||||
}
|
||||
|
||||
public function moneyLog($request)
|
||||
{
|
||||
$draw_money = MerchantMoneyLog::where(['merchant_id' => $this->getMerchantId()])->limit(10)->orderBy('id', 'desc')->get();
|
||||
$data = [];
|
||||
if (count($draw_money) > 0) {
|
||||
foreach ($draw_money as $k => $v) {
|
||||
|
||||
$data[] = $v;
|
||||
}
|
||||
}
|
||||
return $this->jsonFormat($data, $request);
|
||||
}
|
||||
|
||||
//未支付数量
|
||||
public function updateOrderWallter($request)
|
||||
{
|
||||
//更新没有支付订单数量
|
||||
$order_no_pay = Order::where(['merchant_id' => $this->getMerchantId(), 'pay_status' => 0])->count('id');
|
||||
$r = MerchantWallet::where(['merchant_id' => $this->getMerchantId()])->update([
|
||||
'trans_fail_number' => $order_no_pay
|
||||
]);
|
||||
$data['number'] = $order_no_pay;
|
||||
return $this->jsonFormat($data, $request);
|
||||
}
|
||||
|
||||
public function jsonFormat($msg, $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['error' => 0, 'data' => $msg]);
|
||||
}
|
||||
return (['error' => 0, 'data' => $msg]);
|
||||
}
|
||||
|
||||
public function area($request)
|
||||
{
|
||||
$input_type = $request->input('input_type', 'option');
|
||||
$select_id = $request->input('select_id', '');
|
||||
$list = Area::where('parent_id', $request->input('id', 0))->pluck('name', 'id')->toArray();
|
||||
$html_str = '';
|
||||
switch ($input_type) {
|
||||
case 'option':
|
||||
$html_str = ' <option value=""></option>';
|
||||
foreach ($list as $k => $v) {
|
||||
$html_str .= '<option ' . ($select_id == $k ? "selected" : "") . ' value="' . $k . '">' . $v . '</option>';
|
||||
}
|
||||
return ['data' => $html_str];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function uerList($name, Request $request)
|
||||
{
|
||||
$json = $request->input('json');
|
||||
|
||||
if ($json) {
|
||||
|
||||
return $this->apiJson(new User(), 'user', $request);
|
||||
}
|
||||
|
||||
$this->setViewPath('user', 'index');
|
||||
|
||||
return $this->display(['group_type' => $name]);
|
||||
}
|
||||
|
||||
protected function shopList($name, Request $request)
|
||||
{
|
||||
$json = $request->input('json');
|
||||
|
||||
if ($json) {
|
||||
|
||||
return $this->apiJson(new Shop(), 'shop', $request);
|
||||
}
|
||||
|
||||
$this->setViewPath('shop', 'index');
|
||||
|
||||
return $this->display(['group_type' => $name,]);
|
||||
}
|
||||
|
||||
protected function shopUserAndList($name, Request $request)
|
||||
{
|
||||
$json = $request->input('json');
|
||||
|
||||
if ($json) {
|
||||
|
||||
return $this->apiJson(new Shop(), 'shop', $request);
|
||||
}
|
||||
|
||||
$this->setViewPath('shop_and_user', 'index');
|
||||
|
||||
return $this->display(['group_type' => $name,]);
|
||||
}
|
||||
|
||||
protected function shopServerList($name, Request $request)
|
||||
{
|
||||
$json = $request->input('json');
|
||||
|
||||
if ($json) {
|
||||
$model = new ShopServer();
|
||||
$model = $model->where('shop_id', $this->getShopId());
|
||||
return $this->apiJson($model, 'shop_server', $request);
|
||||
}
|
||||
|
||||
$this->setViewPath('shop_server', 'index');
|
||||
|
||||
return $this->display(['group_type' => $name]);
|
||||
}
|
||||
|
||||
public function parseJson($type, $result)
|
||||
{
|
||||
$narr = [];
|
||||
switch ($type) {
|
||||
case 'user':
|
||||
foreach ($result as $k => $v) {
|
||||
$v['sex'] = config('adconfig.sex')[$v['sex']];
|
||||
$v['thumb'] = picurl($v['thumb']);
|
||||
$v['type_name'] = config('adconfig.user_group')[$v['type']];
|
||||
$narr[] = $v;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
foreach ($result as $k => $v) {
|
||||
$v['thumb'] = picurl($v['thumb']);
|
||||
$narr[] = $v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $narr;
|
||||
}
|
||||
|
||||
public function parseSearch($type, $request)
|
||||
{
|
||||
|
||||
$search_arr = [];
|
||||
switch ($type) {
|
||||
case 'user':
|
||||
$name = $request->input('name', '');
|
||||
$search_arr = [
|
||||
'type' => [
|
||||
'type' => '=',
|
||||
'value' => $request->input('group_type') == 'all' ? '' : $request->input('group_type')
|
||||
],
|
||||
'name' => [
|
||||
'type' => 'likesql',
|
||||
'value' => $name ? "nickname like '%" . $name . "%' or mobile like '%" . $name . "%' or real_name like '%" . $name . "%'" : ""
|
||||
]
|
||||
|
||||
];
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
return $search_arr;
|
||||
}
|
||||
|
||||
public function apiJson($model, $type, Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$search_arr = $this->parseSearch($type, $request);
|
||||
$model = $model;
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
$narr = $this->parseJson($type, $result);
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
public function createKey(Request $request)
|
||||
{
|
||||
if ($request->input('type_name') == 'appkey') {
|
||||
$number = date('YmdHis') . str_random(6);
|
||||
|
||||
}
|
||||
if ($request->input('type_name') == 'token') {
|
||||
$number = str_random(32);
|
||||
|
||||
}
|
||||
return response(['error' => 0, 'msg' => '生成成功', 'number' => $number]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\BankRel;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BankRelController extends BaseDefaultController
|
||||
{
|
||||
//
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '提现银行'
|
||||
];
|
||||
}
|
||||
|
||||
public function shareData($id = '')
|
||||
{
|
||||
return ['bank'=>Bank::where(['is_checked'=>1])->orderBy('sort','desc')->orderBy('id','desc')->pluck('name','id')];
|
||||
}
|
||||
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'account' => 'required',
|
||||
'realname' => 'required',
|
||||
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
'account' => 'required',
|
||||
'realname' => 'required'
|
||||
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new BankRel();
|
||||
}
|
||||
|
||||
public function checkSelf($show){
|
||||
|
||||
if($show->model_id!=$this->getMerchantId() && $show->model_type=='merchant')
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function postDataDb($request, $id = '')
|
||||
{
|
||||
$data=$request->all();
|
||||
$data['model_type']='merchant';
|
||||
$data['model_id']=$this->getMerchantId();
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
'model_type'=>[
|
||||
'type'=>'=',
|
||||
'value'=>'merchant'
|
||||
],
|
||||
'model_id'=>[
|
||||
'type'=>'=',
|
||||
'value'=>$this->getMerchantId()
|
||||
]
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['default_name']=$v->is_default==1?'<span class="text-red">是</span>':'否';
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,536 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantLog;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Route;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Validator;
|
||||
use AnyUpload;
|
||||
use DB;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
//
|
||||
const ADMIN_BLADE_DIR = 'merchant.';
|
||||
public $title = '';
|
||||
public $route = [];
|
||||
public $pages = [];
|
||||
public $model;
|
||||
public $share_view = [];
|
||||
public $guard_name = 'merchant';
|
||||
public $dblast_id = '';
|
||||
public $merchant_id;
|
||||
public $store_model;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$route_arr = explode('@', Route::currentRouteAction());
|
||||
$this->route['controller_name'] = '\\' . $route_arr[0];
|
||||
$this->route['action_name'] = $route_arr[1];
|
||||
$this->route['controller_base'] = str_replace('Controller', '', str_replace('App\\Http\\Controllers\\Merchant\\', '', $route_arr[0]));
|
||||
$this->route['blade'] = self::ADMIN_BLADE_DIR . strtolower($this->route['controller_base']) . '.' . $this->route['action_name'];
|
||||
$this->share_view['controller'] = "\\" . $this->route['controller_name'];
|
||||
|
||||
$this->title = ucwords($this->route['action_name']);
|
||||
$this->share_view['title'] = $this->title;
|
||||
$this->setPagesInfo();
|
||||
//$this->handleUrl();
|
||||
$this->getTable();
|
||||
$this->share_view['action_name'] = $this->route['action_name'];
|
||||
$this->share_view['page'] = $this->pages;
|
||||
$this->setTitle('商户后台');
|
||||
|
||||
$this->shareView();
|
||||
|
||||
}
|
||||
|
||||
public function getMerchantId()
|
||||
{
|
||||
return $this->merchant_id = merchant()->id;
|
||||
}
|
||||
|
||||
public function isProxy()
|
||||
{
|
||||
if (merchant('level') != 3) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function dayDrawRatio()
|
||||
{
|
||||
return Merchant::getDayDrawRatio($this->getMerchantId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证规则
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function checkRule($id = '')
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置表单验证错误信息
|
||||
* @return array
|
||||
*/
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局返回表单错误消息
|
||||
* @param $error
|
||||
* @return array
|
||||
*/
|
||||
protected function formError($error)
|
||||
{
|
||||
$error = $error->all();
|
||||
if (count($error) <= 0) return [];
|
||||
$error_str = '';
|
||||
foreach ($error as $k => $v) {
|
||||
|
||||
$error_str .= $v . "*<br/>";
|
||||
|
||||
}
|
||||
return ['error' => 1, 'msg' => $error_str, 'type' => 'validator'];
|
||||
|
||||
}
|
||||
|
||||
public function alertError($error_str, $status = 1)
|
||||
{
|
||||
return response()->json(['error' => $status, 'msg' => $error_str, 'type' => 'validator']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局检测表单是否错误,如果又返回错误数组,否则空数组
|
||||
* @param $request
|
||||
* @param string $id
|
||||
* @return array
|
||||
*/
|
||||
protected function validatorForm($request, $id = '')
|
||||
{
|
||||
$validator = Validator::make($request->all(), $this->checkRule($id), $this->setErrorMsg());
|
||||
if ($validator->fails()) {
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
|
||||
|
||||
return $validator->errors();
|
||||
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置创建数据键值对
|
||||
* @param $obj
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
protected function setDbKeyValue($obj, $data)
|
||||
{
|
||||
$fileds = $this->getField();
|
||||
foreach ($data as $field => $v) {
|
||||
if (in_array($field, $fileds)) {
|
||||
$v = is_null($v) ? '' : $v;
|
||||
$obj->$field = trim($v);
|
||||
}
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局创建和更新操作返回消息
|
||||
* @param $result
|
||||
* @param $request
|
||||
* @param string $id
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function saveMessage($result, $request, $id = '')
|
||||
{
|
||||
|
||||
$type = $id ? '更新' : '创建';
|
||||
if ($request->method() == 'DELETE') {
|
||||
$type = '删除';
|
||||
}
|
||||
|
||||
$msg_type = $result ? '成功' : '失败';
|
||||
$msg_str = $this->pages['name'] . $type . $msg_type;
|
||||
$log_msg_str = $this->pages['name'] . 'ID:' . $this->dblast_id . ',' . $type . $msg_type;
|
||||
//$msg_log_str=$this->pages['name'].'ID:'.$this->dblast_id.','.$type.$msg_type;
|
||||
if ($result) {
|
||||
$this->insertLog($log_msg_str);
|
||||
}
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
$data = [
|
||||
'error' => $result ? 0 : 1,
|
||||
'msg' => $msg_str
|
||||
];
|
||||
$data=$this->addOutData($id)+$data;
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function addOutData($id='')
|
||||
{
|
||||
$model=$this->store_model;
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function insertLog($msg)
|
||||
{
|
||||
MerchantLog::addLog($msg);
|
||||
}
|
||||
|
||||
protected function backMessage($data = [], $success, $request_type, $type)
|
||||
{
|
||||
$return_arr = [];
|
||||
$type_str = $request_type == 'edit' ? '更新' : '创建';
|
||||
if ($type == 'ajax') {
|
||||
if ($success) {
|
||||
$return_arr['error'] = 0;
|
||||
$return_arr['msg'] = $type_str . '成功';
|
||||
} else {
|
||||
$return_arr['error'] = 1;
|
||||
$return_arr['msg'] = $type_str . '失败,请重新操作';
|
||||
}
|
||||
}
|
||||
return $return_arr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 共享视图资源
|
||||
* @return mixed
|
||||
*/
|
||||
public function shareView()
|
||||
{
|
||||
|
||||
return view()->share($this->share_view);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置页面标题
|
||||
* @param string $title
|
||||
*/
|
||||
protected function setTitle($title = '')
|
||||
{
|
||||
$title = $title ? $title : $this->pages['name'];
|
||||
$this->share_view['title'] = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面page设置
|
||||
*/
|
||||
protected function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => ''
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变自动获取blade
|
||||
* @param $path
|
||||
* @param int $cover 是否完全覆盖
|
||||
* @param int $is_seft 是否在当前的控制下目录
|
||||
* @return string
|
||||
*/
|
||||
protected function setViewPath($path = '', $filename = '', $cover = 0, $is_seft = 1)
|
||||
{
|
||||
if ($cover) {
|
||||
return $this->route['blade'] = $path;
|
||||
}
|
||||
if ($is_seft == 0) {
|
||||
return $this->route['blade'] = self::ADMIN_BLADE_DIR . $path;
|
||||
}
|
||||
if ($filename != '') {
|
||||
$this->route['action_name'] = $filename;
|
||||
}
|
||||
if ($path) {
|
||||
$this->route['action_name'] = $path . "." . $this->route['action_name'];
|
||||
}
|
||||
return $this->route['blade'] = self::ADMIN_BLADE_DIR . strtolower($this->route['controller_base']) . '.' . $this->route['action_name'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得当前的模型的字段列表
|
||||
* @param $model
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getField()
|
||||
{
|
||||
$table = $this->getTable();
|
||||
$data = Schema::getColumnListing($table);
|
||||
if (array_key_exists('id', $data)) {
|
||||
unset($data['id']);
|
||||
}
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得table
|
||||
* @return string
|
||||
*/
|
||||
protected function getTable()
|
||||
{
|
||||
if (gettype($this->setModel()) != 'object') {
|
||||
|
||||
$table = '';
|
||||
} else {
|
||||
$table = $this->setModel()->getTable();
|
||||
}
|
||||
|
||||
$this->share_view['table_name'] = $table;
|
||||
$this->shareView();
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 本页面操作的模型
|
||||
*/
|
||||
protected function setModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function checkSelf($show)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getShow($id)
|
||||
{
|
||||
$show = $this->setModel()->find($id);
|
||||
//检查是否是自己的不
|
||||
if (!$this->checkSelf($show)) {
|
||||
return $this->noSelfMsg();
|
||||
}
|
||||
if ($show->shop)
|
||||
if (!$show) {
|
||||
return abort(404);
|
||||
}
|
||||
view()->share('show', $show);
|
||||
|
||||
return $this->display($this->shareData($show));
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出视图
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function display($data = [])
|
||||
{
|
||||
|
||||
return view($this->route['blade'], $data);
|
||||
}
|
||||
|
||||
public function jsonDebug($json)
|
||||
{
|
||||
print_r($json);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function setDbLastId($result, $obj)
|
||||
{
|
||||
if ($result) {
|
||||
$this->dblast_id = $obj->id;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function postDataDb($request, $id = '')
|
||||
{
|
||||
return $request->all();
|
||||
}
|
||||
|
||||
protected function searchKey($model, $arr, $where = 1)
|
||||
{
|
||||
if (empty($arr)) {
|
||||
return $model;
|
||||
}
|
||||
return $model->search($arr, $where);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
//共享创建和编辑数据
|
||||
protected function shareData($id = '')
|
||||
{
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function checkValueData()
|
||||
{
|
||||
$filed_arr = [];
|
||||
$value = 0;
|
||||
if (count($filed_arr) <= 0) {
|
||||
return false;
|
||||
}
|
||||
return ['fields' => $filed_arr, 'value' => $value];
|
||||
}
|
||||
|
||||
public function checkOnValue($data, $handel_arr, $value = 0)
|
||||
{
|
||||
$handel_data = $this->checkValueData();
|
||||
if ($handel_data) {
|
||||
$handel_arr = $handel_data['fields'] + $handel_arr;
|
||||
$value = $handel_data['value'];
|
||||
}
|
||||
|
||||
if (count($handel_arr) <= 0) {
|
||||
return $data;
|
||||
}
|
||||
foreach ($handel_arr as $k => $v) {
|
||||
if (array_key_exists($v, $data)) {
|
||||
continue;
|
||||
}
|
||||
$data[$v] = $value;
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function errorJosn($msg)
|
||||
{
|
||||
return ['error' => 1, 'msg' => $msg];
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否有更新权限
|
||||
*/
|
||||
public function checkUpdatePermission($model)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//附加验证
|
||||
protected function extendValidate($request, $model, $id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建和更新操作
|
||||
* @param $request
|
||||
* @param $model
|
||||
* @param string $id
|
||||
* @return array|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function saveData($request, $model, $id = '')
|
||||
{
|
||||
$error = $this->validatorForm($request, $id);
|
||||
if (count($error) > 0) {
|
||||
return $this->formError($error);
|
||||
};
|
||||
$extend_checked = $this->extendValidate($request, $model, $id);
|
||||
if (is_array($extend_checked)) {
|
||||
return response()->json($extend_checked);
|
||||
}
|
||||
//设置请求参数
|
||||
$data = $this->postDataDb($request, $id);
|
||||
//设置is_checkd不选择的时候为0
|
||||
if ($id) {
|
||||
// if(in_array('is_checked',$this->getField()))
|
||||
// {
|
||||
// $data=$this->checkOnValue($data,['is_checked'],0);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
$model = $this->setDbKeyValue($model, $data);
|
||||
|
||||
$begin = isset($data['begindb']) ? $data['begindb'] : 0;
|
||||
|
||||
if ($begin != 0) {
|
||||
|
||||
DB::beginTransaction();
|
||||
$this->store_model = $model;
|
||||
$result = $model->save();
|
||||
$this->setDbLastId($result, $model);
|
||||
$after_result = $this->saveAfter($request, $model, $id);
|
||||
|
||||
if ($result && $after_result) {
|
||||
$result = 1;
|
||||
DB::commit();
|
||||
$this->beginAfter($request, $model, $data);
|
||||
} else {
|
||||
$result = 0;
|
||||
DB::rollback();
|
||||
}
|
||||
} else {
|
||||
$this->store_model = $model;
|
||||
$result = $model->save();
|
||||
$this->setDbLastId($result, $model);
|
||||
$this->saveAfter($request, $model, $id);
|
||||
}
|
||||
|
||||
return $this->saveMessage($result, $request, $id);
|
||||
}
|
||||
|
||||
public function beginAfter($request, $model, $data = [])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function jsonMsg($error, $str)
|
||||
{
|
||||
return response()->json(['error' => $error, 'msg' => $str]);
|
||||
}
|
||||
|
||||
/*********基本控制器资源设置*********/
|
||||
public function noSelfMsg()
|
||||
{
|
||||
if (\request()->ajax() || \request()->wantsJson()) {
|
||||
return response()->json(['error' => '1', 'msg' => '非法操作数据']);
|
||||
}
|
||||
return abort(401, '非法操作数据');
|
||||
}
|
||||
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
|
||||
return abort('401', $method . '方法不存在');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\MerchantRatio;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BaseDefaultController extends BaseController
|
||||
{
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
|
||||
return $this->display($this->indexData());
|
||||
}
|
||||
public function apiJson(Request $request){
|
||||
$json = [
|
||||
'total' => 0,
|
||||
'rows' => []
|
||||
];
|
||||
return response($json);
|
||||
}
|
||||
public function store(Request $request)
|
||||
{
|
||||
$permission = $this->setModel();
|
||||
return $this->saveData($request,$permission);
|
||||
|
||||
}
|
||||
public function show($id)
|
||||
{
|
||||
return $this->getShow($id);
|
||||
}
|
||||
public function create(){
|
||||
return $this->display($this->shareData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看和编辑都需要设置这个,还有更新
|
||||
* @param $show
|
||||
* @return bool
|
||||
*/
|
||||
public function checkSelf($show){
|
||||
|
||||
//
|
||||
|
||||
$pids=MerchantRatio::where('merchant_id', $show->id)->pluck('parent_id')->toArray();
|
||||
|
||||
|
||||
|
||||
if(in_array($this->getMerchantId(),$pids))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function edit($id){
|
||||
|
||||
return $this->getShow($id);
|
||||
}
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$model = $this->setModel();
|
||||
$model = $model->findOrFail($id);
|
||||
//检查是否是自己的不
|
||||
if(!$this->checkSelf($model)){
|
||||
return abort(404);
|
||||
}
|
||||
return $this->saveData($request,$model,$id);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BaseOnlyController extends BaseController
|
||||
{
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$permission = $this->setModel();
|
||||
return $this->saveData($request,$permission);
|
||||
}
|
||||
public function show($id)
|
||||
{
|
||||
return $this->getShow($id);
|
||||
}
|
||||
public function create(){
|
||||
return $this->display($this->shareData());
|
||||
}
|
||||
public function edit($id){
|
||||
return $this->getShow($id);
|
||||
}
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$model = $this->setModel();
|
||||
$model = $model->findOrFail($id);
|
||||
return $this->saveData($request,$model,$id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BaseTypeController extends BaseController
|
||||
{
|
||||
//
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$group_type=request()->group_type;
|
||||
view()->share('group_type',$group_type);
|
||||
$this->setViewPath($group_type);
|
||||
}
|
||||
|
||||
public function index($group_type)
|
||||
{
|
||||
return $this->display($this->indexData());
|
||||
}
|
||||
public function apiJson($group_type,Request $request){
|
||||
$json = [
|
||||
'total' => 0,
|
||||
'code'=>0,
|
||||
'rows' => []
|
||||
];
|
||||
return response($json);
|
||||
}
|
||||
|
||||
public function store($group_type,Request $request)
|
||||
{
|
||||
$permission = $this->setModel();
|
||||
return $this->saveData($request,$permission);
|
||||
|
||||
}
|
||||
public function create($group_type){
|
||||
return $this->display($this->shareData());
|
||||
}
|
||||
public function edit($group_type,$id){
|
||||
return $this->getShow($id);
|
||||
}
|
||||
public function update($group_type, $id,Request $request)
|
||||
{
|
||||
$model = $this->setModel();
|
||||
$model = $model->findOrFail($id);
|
||||
return $this->saveData($request,$model,$id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,308 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\MerchantCommission;
|
||||
use Ixudra\Curl\Facades\Curl;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Models\Bank;
|
||||
use App\Models\BankRel;
|
||||
use App\Models\DrawMoney;
|
||||
use App\Models\MerchantMoneyLog;
|
||||
use App\Models\MerchantWallet;
|
||||
use App\Models\Order;
|
||||
use App\Services\SearchServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\DrawMoneyShipped;
|
||||
|
||||
class DrawMoneyController extends BaseDefaultController
|
||||
{
|
||||
//
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '提现申请'
|
||||
];
|
||||
}
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
|
||||
return ['status' => config('adconfig.draw_money_status')];
|
||||
}
|
||||
|
||||
public function shareData($id = '')
|
||||
{
|
||||
$wallte = merchant()->wallets;//钱包信息
|
||||
|
||||
//可用总额=订单总额-提现成功总额
|
||||
//订单总额
|
||||
$order_total_money = Order::merchantTotalMoney(merchant('id'));
|
||||
//提现总额:提现申请,提现审核中,提现完成,提现的金额咯。
|
||||
$draw_total_money = DrawMoney::merchantDrawMoney(merchant('id'));
|
||||
|
||||
//成功结算的佣金金额
|
||||
$commmission_total_money = MerchantCommission::getMoneyTotal(merchant('id'), 1);
|
||||
|
||||
//账号余额=订单结算总额 + 佣金结算完成总额 - 提现总额
|
||||
|
||||
$use_money = round($order_total_money + $commmission_total_money - $draw_total_money, 2);
|
||||
|
||||
|
||||
$draw_info = $this->getDrawMoneyStatus();
|
||||
$day_seizure = $this->daySeizure();
|
||||
|
||||
return [
|
||||
'use_money' => $use_money,
|
||||
'draw_limit' => $this->drawTimeLimit(),
|
||||
'day_seizure' => $day_seizure,
|
||||
'day_seizure_ratio' => $this->dayDrawRatio(),
|
||||
'draw_info' => $draw_info, 'wallte' => $wallte,
|
||||
'bank' => BankRel::where(['is_checked' => 1, 'model_id' => $this->getMerchantId(), 'model_type' => 'merchant'])->get()
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function drawTimeLimit()
|
||||
{
|
||||
//提现时间限制
|
||||
$draw_time_limit = config_cache('draw_config.draw_time_limit');
|
||||
$draw_time_limit = explode('-', $draw_time_limit);
|
||||
if (empty($draw_time_limit)) {
|
||||
$draw_time_limit = [
|
||||
9, 20
|
||||
];
|
||||
}
|
||||
|
||||
//当前时间,
|
||||
$time = date('H');
|
||||
|
||||
if ($time >= $draw_time_limit[0] and $time <= $draw_time_limit[1]) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//每天扣押款
|
||||
public function daySeizure()
|
||||
{
|
||||
//统计今天成就结算总额
|
||||
$to_day_total_money = Order::getMerchantTotalToDayMoney($this->getMerchantId(), 1);
|
||||
$day_seizure_money = 0;
|
||||
//每天押款多少比率
|
||||
if ($to_day_total_money > 0) {
|
||||
$day_seizure_ratio = $this->dayDrawRatio(); //config_cache('draw_config.draw_day_money_ratio') ? config_cache('draw_config.draw_day_money_ratio') : 0;
|
||||
$day_seizure_money = round($to_day_total_money * $day_seizure_ratio / 100, 2);
|
||||
}
|
||||
return ['day_total_money' => $to_day_total_money, 'day_seizure_money' => $day_seizure_money];
|
||||
}
|
||||
|
||||
public function getDrawMoneyStatus()
|
||||
{
|
||||
//提现总额今天
|
||||
$data['draw_total'] = $this->setModel()::where('merchant_id', $this->getMerchantId())->whereRaw('DATE_FORMAT(created_at,"%Y-%m-%d") =? ', [date('Y-m-d')])->sum('draw_money');
|
||||
$data['draw_number'] = $this->setModel()::where('merchant_id', $this->getMerchantId())->whereRaw('DATE_FORMAT(created_at,"%Y-%m-%d") =? ', [date('Y-m-d')])->count('*');
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function extendValidate($request, $model, $id)
|
||||
{
|
||||
if(!config_cache('draw_config.draw_open')){
|
||||
return $this->errorJosn('系统关闭了提现功能,请联系我们');
|
||||
}
|
||||
//检查是否金额对的上
|
||||
$data = $request->all();
|
||||
$day_seizure = $this->daySeizure();
|
||||
//提现余额是否大于可用余额
|
||||
//提现金额
|
||||
$day_moeny = $day_seizure['day_seizure_money'];
|
||||
//提现金额+冻结资金,如果大于钱包余额
|
||||
if ($data['draw_money'] + $day_moeny > merchant()->wallets['money']) {
|
||||
return $this->errorJosn('可用余额不足');
|
||||
}
|
||||
//单笔提款金额不能少于
|
||||
if ($data['draw_money'] < floatval(config_cache('draw_config.draw_min_money'))) {
|
||||
return $this->errorJosn('单笔提款金额不能少于' . config_cache('draw_config.draw_min_money'));
|
||||
}
|
||||
//单笔提款金额不能大于
|
||||
if ($data['draw_money'] > floatval(config_cache('draw_config.draw_max_money'))) {
|
||||
return $this->errorJosn('单笔提款金额不能大于' . config_cache('draw_config.draw_max_money'));
|
||||
}
|
||||
//次数
|
||||
$draw_info = $this->getDrawMoneyStatus();
|
||||
//每天提款次数
|
||||
$max_number = config_cache('draw_config.draw_day_max_money');
|
||||
if (($draw_info['draw_number'] + 1) > $max_number) {
|
||||
return $this->errorJosn('超过今天最大提款次数');
|
||||
}
|
||||
|
||||
//每天提款时间限制
|
||||
$draw_time_limit = $this->drawTimeLimit();
|
||||
if (!$draw_time_limit) {
|
||||
return $this->errorJosn('现在不是提现时间');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'draw_money' => 'required',
|
||||
|
||||
'fee_money' => 'required',
|
||||
'bank_realname' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'draw_money' => 'required',
|
||||
'fee_money' => 'required',
|
||||
'bank_realname' => 'required',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
'draw_money.required' => '提现金额不能为空',
|
||||
'money.required' => '到账金额不能为空',
|
||||
'fee_money.required' => '手续费不能为空',
|
||||
'bank_realname.required' => '收款人不能为空',
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new DrawMoney();
|
||||
}
|
||||
|
||||
public function checkSelf($show)
|
||||
{
|
||||
|
||||
if ($show->model_id != $this->getMerchantId() && $show->model_type == 'merchant') {
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postDataDb($request, $id = '')
|
||||
{
|
||||
$data = $request->all();
|
||||
|
||||
$data['merchant_id'] = $this->getMerchantId();
|
||||
//提现手续费,提现资金,到账资金
|
||||
$data['money'] = $data['draw_money'] - $data['fee_money'];
|
||||
$data['status'] = 0;//等待处理
|
||||
$data['begindb'] = 1;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
//事务类型
|
||||
//提现成功需要减去账号金额,发生资金变动
|
||||
$waller_r = MerchantWallet::moneyDecr($this->getMerchantId(), $model->draw_money);
|
||||
//自己变动插入
|
||||
$money_log = MerchantMoneyLog::drawMoney($this->getMerchantId(), '-' . $model->draw_money, '提现申请', $model->id);
|
||||
|
||||
if ($waller_r && $money_log) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//发送邮件提醒
|
||||
public function beginAfter($request, $model, $data = [])
|
||||
{
|
||||
|
||||
$data=[
|
||||
'id'=>$model->id,
|
||||
'name'=>merchant('name'),
|
||||
'draw_money'=>$data['draw_money'],
|
||||
'money'=>$data['money'],
|
||||
'fee_money'=>$data['fee_money'],
|
||||
'bank_name'=>$data['bank_name'],
|
||||
'bank_account'=>$data['bank_account'],
|
||||
'bank_realname'=>$data['bank_realname'],
|
||||
'bank_source'=>$data['bank_source'],
|
||||
'created_at'=>date('Y-m-d H:i:s')
|
||||
];
|
||||
if(config_cache('draw_config.draw_email'))
|
||||
{
|
||||
Mail::to(config_cache('draw_config.draw_email'))->send(new DrawMoneyShipped($data));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$data = $request->all();
|
||||
$data['merchant_id'] = $this->getMerchantId();
|
||||
$search = new SearchServices($model, $data, 'draw_money');
|
||||
$model = $search->getModel();
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url'] = action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url'] = action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['draw_type_name'] = $v->DrawTypeName;
|
||||
$text_class = '';
|
||||
if ($v['status'] == 1) {
|
||||
$text_class = "text-grep";
|
||||
}
|
||||
if ($v['status'] == 3) {
|
||||
$text_class = "text-danger";
|
||||
}
|
||||
//查看原因
|
||||
$why='';
|
||||
if($v['status']==3)
|
||||
{
|
||||
$why='<span class="btn btn-xs btn-primary" lay-event="tips" data-title="查看原因" data-content="'.($v['mark'] ?: '没有内容').'">查看原因</span>';
|
||||
|
||||
}
|
||||
|
||||
$v['status_name_tpl'] = '<span class="' . $text_class . '">' . $v->StatusName . '</span> '.$why;
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\File;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Classc\UploadShopFile;
|
||||
|
||||
class FileUploadController extends BaseController
|
||||
{
|
||||
//
|
||||
public function handle($type,Request $request){
|
||||
if($type=='upload')
|
||||
{
|
||||
return $this->upload($request);
|
||||
}
|
||||
if($type=='list')
|
||||
{
|
||||
return $this->getList($request);
|
||||
}
|
||||
if($type=='only_one')
|
||||
{
|
||||
$this->setViewPath('','handle_only');
|
||||
return $this->getList($request);
|
||||
}
|
||||
if($type=='api')
|
||||
{
|
||||
return $this->getApi($request);
|
||||
}
|
||||
}
|
||||
protected function upload($request){
|
||||
$files = $request->input('files', 'file');
|
||||
$type=$request->input('uptype','image');
|
||||
$method = $request->input('method', 'upload');
|
||||
$screen_type = $request->input('screen_type', '');
|
||||
$r = UploadShopFile::upload($files, $type, $method,$screen_type);
|
||||
return response()->json($r);
|
||||
}
|
||||
protected function getList($request){
|
||||
return $this->display([]);
|
||||
}
|
||||
protected function getApi($request){
|
||||
$type = $request->input('uptype','');
|
||||
$is_oss = $request->input('is_oss', false);
|
||||
$offset = $request->input('offset', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$key = $request->input('search', '');
|
||||
$screen_type = $request->input('screen_type', '');
|
||||
|
||||
$model = new File();
|
||||
if ($type) {
|
||||
$model = $model->where('type', $type);
|
||||
}
|
||||
$model=$model->where('user_id',admin_shop('id'));
|
||||
$model=$model->where('create_type','adminshop')->where('user_type', 'user');
|
||||
|
||||
if($screen_type)
|
||||
{
|
||||
$model=$model->where('screen_type',$screen_type);
|
||||
}
|
||||
|
||||
$total = $model->count();
|
||||
|
||||
$data = $model->skip($offset)->take($pagesize)->orderBy('id', 'desc')->get()->toArray();
|
||||
$str = '';
|
||||
$uindex = 0;
|
||||
foreach ($data as $key => $v) {
|
||||
$pic_url = $v['path'];
|
||||
$is_oss = $is_oss ? $is_oss : config('adconfig.is_oss');
|
||||
$v['oss'] = '';
|
||||
$img_html='<img data-type="'.$v['type'].'" src="' . $v['path']. '" class="" title="' . $v['tmp']. '" alt="" > ';
|
||||
if ($is_oss) {
|
||||
if (Storage::exists($pic_url)) {
|
||||
$pic_url = Storage::url($v['path']);
|
||||
$v['oss'] = Storage::url($v['path']);
|
||||
}
|
||||
|
||||
}
|
||||
if ($v['type'] != 'image') {
|
||||
|
||||
$img_html=' <video class="upload_img" src="'.$v['path'].'" data-type="'.$v['type'].'" data-src="' . $v['path']. '" controls="controls" style="width: 100%;"></video>';
|
||||
}
|
||||
|
||||
|
||||
$str .= '<div class="layui-upload-img item layui-inline " data-size="'.$v['size'].'.kb" data-tmpname="'.$v['tmp'].'" data-type="'.$v['type'].'" data-src="' . $v['path']. '"> ' .$img_html .
|
||||
'<p class="layui-">' . $v['tmp']. '</p> </div>';
|
||||
$uindex++;
|
||||
}
|
||||
|
||||
$list = array(
|
||||
'total' => $total,
|
||||
'contents' => $str,
|
||||
'pagesize' => $pagesize
|
||||
);
|
||||
$debug = $request->input('debug', 0);
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($list);
|
||||
}
|
||||
return response()->json($list);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,271 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Events\CouponCardEvent;
|
||||
use App\Models\Activity;
|
||||
use App\Models\BankRel;
|
||||
use App\Models\CouponCard;
|
||||
use App\Models\MerchantRatio;
|
||||
use App\Models\Scenic;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Event;
|
||||
|
||||
class HandleController extends BaseController
|
||||
{
|
||||
public function allowTable()
|
||||
{
|
||||
return ['merchants', 'bank_rels'];
|
||||
}
|
||||
|
||||
public function handle($type, Request $request)
|
||||
{
|
||||
$table = $request->input('table'); // 表名
|
||||
//运行更新和删除的操作数据表
|
||||
if (!in_array($table, $this->allowTable())) {
|
||||
return $this->noSelfMsg();
|
||||
}
|
||||
switch ($type) {
|
||||
case 'del':
|
||||
return $this->delete($request);
|
||||
break;
|
||||
case 'edit':
|
||||
return $this->editField($request);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function editField(Request $request)
|
||||
{
|
||||
$table = $request->input('table'); // 表名
|
||||
$id_name = $request->input('id_name', 'id'); // 表主键id名
|
||||
$id_value = $request->input('id_value'); // 表主键id值
|
||||
$field = $request->input('field'); // 修改哪个字段
|
||||
$value = $request->input('value'); // 修改字段值
|
||||
if ($table == '' or $id_name == '' or $id_value == '' or $field == '' or $value == '') {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '参数不正确'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
//验证是否自己的信息
|
||||
if (!$this->checkSelfUser($id_value, $id_name, $table)) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '非法操作别人数据'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
$model = DB::table($table)->where($id_name, $id_value)->update([$field => $value]);
|
||||
if ($table == 'merchants') {
|
||||
write_merchant();//更新商户信息
|
||||
}
|
||||
|
||||
if ($model) {
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'msg' => '设置成功'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
} else {
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'msg' => '设置失败'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 软删除开启
|
||||
* @param $table
|
||||
* @return int
|
||||
*/
|
||||
public function deletType($table)
|
||||
{
|
||||
switch ($table) {
|
||||
case 'shops':
|
||||
return 1;
|
||||
case 'shop_servers':
|
||||
return 1;
|
||||
case 'under_orders':
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$type_id = $request->input('type_id', 'id');
|
||||
$table = $request->input('table');
|
||||
$handle_str = $request->input('handle_str');
|
||||
if ($table == '') {
|
||||
$table = $request->input('model');
|
||||
}
|
||||
$rdel = $this->deletType($table);
|
||||
|
||||
if ($id == '') {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '编号不能为空',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
if ($table == '') {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '没有选择数据表',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
$id_arr = explode(",", $id);
|
||||
if (count($id_arr) <= 0) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '编号不能为空',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
/* if (count($id_arr) >= 2) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '商户版本不支持批量删除操作',
|
||||
'type'=>'del'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}*/
|
||||
//验证是否自己的信息
|
||||
if (!$this->checkSelfUser($id, 'id', $table)) {
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '非法操作别人数据'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
$result = DB::table($table)->whereIn($type_id, $id_arr);
|
||||
|
||||
//删除条件附加
|
||||
$result = $this->whereDelete($result, $table);
|
||||
|
||||
if ($rdel) {
|
||||
$result = $result->update(['deleted_at' => date('Y-m-d H:i:s', time())]);
|
||||
} else {
|
||||
|
||||
|
||||
$result = $result->delete();
|
||||
|
||||
}
|
||||
//删除事务
|
||||
if ($result && $this->deleteCustom($table, $id_arr)) {
|
||||
|
||||
DB::commit();
|
||||
$this->eventCustom($table, $id_arr);
|
||||
$this->afterUpdate($table, $result, $id_arr);
|
||||
|
||||
$this->insertLog($handle_str . '删除 ID:' . implode('、', $id_arr));
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'msg' => '删除成功',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
DB::rollBack();
|
||||
$data = [
|
||||
'error' => 1,
|
||||
'msg' => '删除失败',
|
||||
'type' => 'del'
|
||||
|
||||
];
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function deleteCustom($table, $id)
|
||||
{
|
||||
switch ($table) {
|
||||
case 'admins':
|
||||
return DB::table('model_has_roles')->where('model_type', 'admin')->whereIn('model_id', $id)->delete();
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function eventCustom($table, $id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function afterUpdate($table, $result, $id_arr)
|
||||
{
|
||||
switch ($table) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否自己信息,不然不给修改
|
||||
* @param $id
|
||||
* @param $table
|
||||
* @param string $checkid
|
||||
*/
|
||||
function checkSelfUser($id, $id_name, $table)
|
||||
{
|
||||
switch ($table) {
|
||||
case 'merchants':
|
||||
// $has=DB::table($table)->where($id_name,$id)->where('from_id',$this->getMerchantId())->count();
|
||||
$has = MerchantRatio::where('parent_id', $this->getMerchantId())->count();
|
||||
if ($has <= 0) return false;
|
||||
break;
|
||||
case 'bank_rels':
|
||||
$has = BankRel::where($id_name,$id)->where('model_id', $this->getMerchantId())->count();
|
||||
if ($has <= 0) return false;
|
||||
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除条件附加
|
||||
* @param $model_obj
|
||||
*/
|
||||
public function whereDelete($model_obj, $table)
|
||||
{
|
||||
switch ($table) {
|
||||
/* case 'coupon_cards':
|
||||
$model_obj=$model_obj->where('create_user_type','user')->where('create_user_id',admin_shop('id'));
|
||||
break;
|
||||
case 'activities':
|
||||
$model_obj=$model_obj->where('create_user_type','user')->where('create_user_id',admin_shop('id'));
|
||||
break;*/
|
||||
}
|
||||
return $model_obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\DrawMoney;
|
||||
use App\Models\MerchantWallet;
|
||||
use App\Models\NoticeArticle;
|
||||
use App\Models\Order;
|
||||
use App\Services\SearchServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Hash;
|
||||
|
||||
class HomeController extends BaseController
|
||||
{
|
||||
public function index(){
|
||||
|
||||
if(is_mobile_client())
|
||||
{
|
||||
$this->setViewPath('','mobile');
|
||||
return redirect()->action('Merchant\HomeController@console');
|
||||
}
|
||||
|
||||
|
||||
return $this->display();
|
||||
}
|
||||
public function console(){
|
||||
|
||||
$notice=NoticeArticle::limit(10)->get();
|
||||
$draw_money=DrawMoney::merchantDrawMoneyOk(merchant('id'));
|
||||
//昨天订单结算总额
|
||||
|
||||
$yesterday=new SearchServices(new Order(),['day'=>-1,'merchant_id'=>merchant('id'),'pay_status'=>1],'order');
|
||||
$yesterday=$yesterday->totalSum('total_money');
|
||||
$today_money=new SearchServices(new Order(),['day'=>0,'merchant_id'=>merchant('id'),'pay_status'=>1],'order');
|
||||
$today_money=$today_money->totalSum('total_money');
|
||||
//昨天冻结
|
||||
$dratio=$this->dayDrawRatio();
|
||||
$dratio=$dratio ?$dratio: 0;
|
||||
$dong_money=$yesterday * $dratio /100;
|
||||
//$this->updateOrderWallter();
|
||||
$data=[
|
||||
'notice'=>$notice,
|
||||
'wallets'=>merchant()->wallets,
|
||||
'draw_money'=>$draw_money,
|
||||
'yesterday'=>$yesterday,
|
||||
'today_money'=>$today_money,
|
||||
'dong_money'=>$dong_money
|
||||
];
|
||||
|
||||
return $this->display($data);
|
||||
}
|
||||
public function online($id){
|
||||
$this->setViewPath('','online');
|
||||
|
||||
$data=[
|
||||
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
public function updateOrderWallter(){
|
||||
//更新没有支付订单数量
|
||||
$order_no_pay=Order::where(['merchant_id'=>$this->getMerchantId(),'pay_status'=>0])->count('id');
|
||||
MerchantWallet::where(['merchant_id'=>$this->getMerchantId()])->update([
|
||||
'trans_fail_number'=>$order_no_pay
|
||||
]);
|
||||
}
|
||||
public function showNotice($id,$request){
|
||||
$this->setViewPath('','notice');
|
||||
$notice=NoticeArticle::find($id);
|
||||
$data=[
|
||||
'show'=>$notice
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
public function show($type,$id,Request $request){
|
||||
return $this->$type($id,$request);
|
||||
}
|
||||
public function api($id){
|
||||
$this->setViewPath('','api');
|
||||
|
||||
$data=[
|
||||
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
public function spread($id){
|
||||
$this->setViewPath('','spread');
|
||||
|
||||
$data=[
|
||||
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
|
||||
public function password($id){
|
||||
$this->setViewPath('','password');
|
||||
|
||||
$data=[
|
||||
|
||||
];
|
||||
return $this->display($data);
|
||||
}
|
||||
public function update($method,Request $request){
|
||||
|
||||
return $this->$method($request);
|
||||
}
|
||||
public function passwordUpdate($request){
|
||||
$error=$this->validatorForm($request,'password');
|
||||
if(count($error)>0){
|
||||
return $this->formError($error);
|
||||
};
|
||||
$user=merchant();
|
||||
$password=$request->input('password');
|
||||
$old_password=$request->input('old_password');
|
||||
if (!Hash::check($old_password, $user->password)) {
|
||||
return $this->alertError('旧密码不对');
|
||||
}
|
||||
$user->password=$password;
|
||||
$user->origin_password=$password;
|
||||
if($user->save())
|
||||
{
|
||||
return $this->alertError('修改密码成功',0);
|
||||
}
|
||||
return $this->alertError('修改密码失败',1);
|
||||
|
||||
}
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
return [
|
||||
'password' => 'required|confirmed',
|
||||
'old_password' => 'required'
|
||||
];
|
||||
}
|
||||
public function setErrorMsg()
|
||||
{
|
||||
return [
|
||||
'old_password'=>'旧密码'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
|
||||
|
||||
use App\Models\MerchantLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class LogController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '操作日志'
|
||||
];
|
||||
}
|
||||
|
||||
public function shareData($show='')
|
||||
{
|
||||
return $this->indexData();
|
||||
|
||||
}
|
||||
|
||||
public function checkRule( $id='')
|
||||
{
|
||||
|
||||
}
|
||||
public function setErrorMsg(){
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
public function setModel()
|
||||
{
|
||||
return new MerchantLog();
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$type = $request->input('type', '1');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$search_arr=[
|
||||
'merchant_id'=>[
|
||||
'type'=>'=',
|
||||
'value'=>merchant('id')
|
||||
]
|
||||
|
||||
|
||||
];
|
||||
$model=$this->searchKey($model,$search_arr,2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
|
||||
$v['admin_name']=$v->merchants['name'];
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SendCode;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Validator;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/merchant/admin/home/';
|
||||
|
||||
public $guard = 'merchant';
|
||||
|
||||
public function username()
|
||||
{
|
||||
return 'email';
|
||||
}
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard($this->guard);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局返回表单错误消息
|
||||
* @param $error
|
||||
* @return array
|
||||
*/
|
||||
protected function formError($error)
|
||||
{
|
||||
$error = $error->all();
|
||||
if (count($error) <= 0) return [];
|
||||
$error_str = '';
|
||||
foreach ($error as $k => $v) {
|
||||
|
||||
$error_str .= $v . "*<br/>";
|
||||
|
||||
}
|
||||
return response()->json(['error' => 1, 'msg' => $error_str, 'type' => 'validator']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//跳转地址登陆
|
||||
public function redirectTo()
|
||||
{
|
||||
return redirect()->to(admin_merchant_url('Home'));
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$this->guard($this->guard)->logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
|
||||
return redirect()->action('Merchant\LoginController@showLoginForm');
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function sendFailedLoginResponse(Request $request)
|
||||
{
|
||||
return (['error' => 1, 'msg' => trans('auth.failed')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
if (Auth::guard($this->guard)->check()) {
|
||||
return redirect()->to(admin_merchant_url('Home'));
|
||||
}
|
||||
return view('merchant.auth.login', ['title' => config('merchant_admin.name')]);
|
||||
}
|
||||
|
||||
protected function credentials(Request $request)
|
||||
{
|
||||
return $request->only($this->username(), 'password');
|
||||
}
|
||||
|
||||
protected function attemptLogin(Request $request)
|
||||
{
|
||||
$data = $this->credentials($request);
|
||||
|
||||
$r = $this->guard()->attempt(
|
||||
$data, $request->filled('remember')
|
||||
);
|
||||
if ($r) {
|
||||
//更新操作
|
||||
$admin = \Illuminate\Support\Facades\Auth::guard($this->guard)->user();
|
||||
$admin->last_time = date('Y-m-d H:i:s');
|
||||
$admin->last_number = $admin->last_number + 1;
|
||||
$admin->ip = $request->getClientIp();
|
||||
$admin->save();
|
||||
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
protected function sendLockoutResponse(Request $request)
|
||||
{
|
||||
$seconds = $this->limiter()->availableIn(
|
||||
$this->throttleKey($request)
|
||||
);
|
||||
return response()->json(['error' => 1, 'msg' => '登陆失败次数过多,请稍后重试' . $seconds]);
|
||||
}
|
||||
|
||||
protected function validatorForm($request)
|
||||
{
|
||||
$is_mobile = 0;
|
||||
$message_data = [
|
||||
'email.required' => '请输入邮箱',
|
||||
'password.required' => '请输入密码',
|
||||
];
|
||||
$check_data =
|
||||
[
|
||||
$this->username() => [
|
||||
'required', 'email'
|
||||
|
||||
],
|
||||
'password' => 'required',
|
||||
];
|
||||
if ($is_mobile) {
|
||||
$check_data =
|
||||
[
|
||||
$this->username() => [
|
||||
'required',
|
||||
'regex:/^1\d{10}$/'
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$validator = Validator::make($request->all(), $check_data, $message_data);
|
||||
if ($validator->fails()) {
|
||||
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
|
||||
return $validator->errors();
|
||||
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public function authenticated()
|
||||
{
|
||||
return response()->json(['error' => 0, 'msg' => '登陆成功']);
|
||||
}
|
||||
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
|
||||
$error = $this->validatorForm($request);
|
||||
if (count($error) > 0) {
|
||||
return $this->formError($error);
|
||||
};
|
||||
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
||||
// the login attempts for this application. We'll key this by the username and
|
||||
// the IP address of the client making these requests into this application.
|
||||
//确定用户是否有太多失败的登录尝试。
|
||||
if ($this->hasTooManyLoginAttempts($request)) {
|
||||
$this->fireLockoutEvent($request);
|
||||
|
||||
//太多次返回的信息
|
||||
return $this->sendLockoutResponse($request);
|
||||
}
|
||||
|
||||
|
||||
if ($this->attemptLogin($request)) {
|
||||
//通过之后响应
|
||||
return $this->sendLoginResponse($request);
|
||||
}
|
||||
|
||||
//增加登陆尝试次数,默认尝试增加1次
|
||||
$this->incrementLoginAttempts($request);
|
||||
|
||||
|
||||
return $this->sendFailedLoginResponse($request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\AdminLog;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantCommission;
|
||||
use App\Models\MerchantMoneyLog;
|
||||
use App\Models\Sms;
|
||||
use App\Models\SmsLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class MerchantCommissionController extends BaseDefaultController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct();
|
||||
$this->middleware('proxy');
|
||||
}
|
||||
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$title = request()->input('title');
|
||||
|
||||
$this->pages = [
|
||||
'name' => $title
|
||||
];
|
||||
}
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
$status = config('adconfig.commission_status');
|
||||
return ['status' => $status, 'merchant' => Merchant::where('from_id', $this->getMerchantId())->get()];
|
||||
}
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
}
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new MerchantCommission();
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$merchant_id = $request->input('merchant_id', '');
|
||||
$from_merchant_id = $this->getMerchantId();//$request->input('from_merchant_id', '');
|
||||
$order_sn = $request->input('order_sn', '');
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$status = $request->input('status', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$day = $request->input('day', '');
|
||||
|
||||
$month = $request->input('month', '');
|
||||
|
||||
$time = $request->input('time', '');
|
||||
$start_at = '';
|
||||
$end_at = '';
|
||||
if ($time) {
|
||||
$time = str_replace('~', ',', $time);
|
||||
$time = explode(",", $time);
|
||||
$start_at = isset($time[0]) ? $time[0] : '';
|
||||
$end_at = isset($time[1]) ? $time[1] : '';
|
||||
$month = '';
|
||||
}
|
||||
if ($status != '') {
|
||||
$model = $model->where('status', $status);
|
||||
}
|
||||
//天
|
||||
if ($day != '') {
|
||||
if ($day <= 0) {
|
||||
$day_at = (new Date($day . "day"))->format('Y-m-d');
|
||||
$start_at = $day_at . ' 00:00:00';
|
||||
if ($day == -1) {
|
||||
$end_at = $day_at . ' 23:59:59';
|
||||
} else {
|
||||
$end_at = (new Date('0 day'))->format('Y-m-d') . ' 23:59:59';
|
||||
}
|
||||
$month = '';
|
||||
}
|
||||
}
|
||||
//月
|
||||
if ($month != '') {
|
||||
$date = date('Y-m-d H:i:s', strtotime($month . 'month'));
|
||||
$month_at = get_month($date);
|
||||
if (count($month_at) > 0) {
|
||||
|
||||
$start_at = $month_at[0];
|
||||
if ($month == 0 || $month == '-1') {
|
||||
$end_at = $month_at[1];
|
||||
} else {
|
||||
$end_at = get_month('', 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//时间范围
|
||||
if ($start_at) {
|
||||
$model = $model->whereRaw('(order_at>=? and order_at<=? )', [($start_at), ($end_at)]);
|
||||
}
|
||||
|
||||
|
||||
$search_arr = [
|
||||
'merchant_id' => [
|
||||
'value' => $merchant_id,
|
||||
'type' => '='
|
||||
],
|
||||
'order_sn' => [
|
||||
'value' => $order_sn,
|
||||
'type' => '='
|
||||
],
|
||||
'from_merchant_id' => [
|
||||
'value' => $from_merchant_id,
|
||||
'type' => '='
|
||||
]
|
||||
|
||||
];
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['status_name'] = $v->status_name;
|
||||
$v['name'] = $v->merchants->name;
|
||||
$v['ratio'] = ($v['ratio'] / 10) . '%';
|
||||
$v['show_url'] = admin_merchant_url('Order', 'show', ['id' => $v->order_id]);
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,391 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\Bank;
|
||||
use App\Models\BankRel;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantRatio;
|
||||
use App\Models\MerchantWallet;
|
||||
use App\Models\Server;
|
||||
use App\Services\SearchServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class MerchantController extends BaseDefaultController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct();
|
||||
$this->middleware('proxy');
|
||||
}
|
||||
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '商户'
|
||||
];
|
||||
}
|
||||
|
||||
public function shareData($id = '')
|
||||
{
|
||||
$level = config('adconfig.merchant_level');
|
||||
if (merchant('level') == 1) {
|
||||
unset($level[1]);
|
||||
}
|
||||
if (merchant('level') == 2) {
|
||||
unset($level[1]);
|
||||
unset($level[2]);
|
||||
}
|
||||
return ['level' => $level, 'bank' => Bank::where(['is_checked' => 1])->pluck('name', 'id'), 'draw_type' => config('adconfig.draw_type')];
|
||||
}
|
||||
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
if (!$id) {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email|unique:merchants|max:255',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function extendValidate($request, $model, $id)
|
||||
{
|
||||
$level = $request->input('level');
|
||||
$from_id = $request->input('from_id');
|
||||
|
||||
//判断身份
|
||||
$proxy = merchant();
|
||||
if ($level <= $proxy->level) {
|
||||
return $this->errorJosn('你不能添加高于或等于你的等级商户');
|
||||
}
|
||||
|
||||
|
||||
if ($request->input('ratio') <= $proxy->ratio) {
|
||||
return $this->errorJosn('设置费率,不能低于您的费率:' . $proxy->ratio);
|
||||
}
|
||||
|
||||
|
||||
//如果已经审核了。则不给修改
|
||||
if ($id) {
|
||||
if ($model->check_status != 2) {
|
||||
return $this->errorJosn('你不能操作已经审核过的商户');
|
||||
}
|
||||
if ($model->from_id != $proxy->id) {
|
||||
return $this->errorJosn('您不能操作其他人的商户');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getCheckStatusOn($level)
|
||||
{
|
||||
if ($level == 1) {
|
||||
return config_cache('merchant_config.merchant_gudong_check');
|
||||
}
|
||||
if ($level == 2) {
|
||||
return config_cache('merchant_config.merchant_daili_check');
|
||||
}
|
||||
}
|
||||
|
||||
protected function postDataDb($request, $id = '')
|
||||
{
|
||||
$data = $request->all();
|
||||
if (!$id) {
|
||||
//总后台生成
|
||||
$data['app_key'] = date('YmdHis') . str_random(6);
|
||||
$data['token'] = str_random(32);
|
||||
}
|
||||
//等待总后台审核
|
||||
//是否
|
||||
|
||||
$data['check_status'] = $this->getCheckStatusOn(\merchant('level')) ? 2 : 1;
|
||||
$proxy = merchant();
|
||||
$data['from_id'] = $proxy->id;
|
||||
$data['next_ratio'] = $proxy->ratio;//上级代理费率
|
||||
|
||||
if (!$request->input('password')) {
|
||||
unset($data['password']);
|
||||
} else {
|
||||
$data['origin_password'] = $data['password'];
|
||||
}
|
||||
//开启事务
|
||||
//添加的时候需要开启
|
||||
if (!$id) {
|
||||
$data['begindb'] = 1;//开启事务
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function updateMerchantRatio($merchant)
|
||||
{
|
||||
//取得费率表信息
|
||||
$ratio = MerchantRatio::where('merchant_id', $merchant->id)->where('is_self', 1)->first();
|
||||
|
||||
//判断上级是否有上级
|
||||
$upObj = Merchant::find($merchant->from_id);
|
||||
$hierarchy = 1;//默认1级,表示顶级
|
||||
if ($upObj) {
|
||||
|
||||
if ($upObj->from_id != 0) {
|
||||
$hierarchy = 3;
|
||||
} else {
|
||||
//没有上级,则只有2级别
|
||||
$hierarchy = 2;
|
||||
}
|
||||
}
|
||||
//层级不一样了,判断谁的层级高一点
|
||||
//全部删除,重新添加
|
||||
MerchantRatio::where('merchant_id', $merchant->id)->delete();
|
||||
//重新添加
|
||||
|
||||
|
||||
//判断层级
|
||||
if ($hierarchy == 3) {
|
||||
//3级关系级别
|
||||
return MerchantRatio::addDefault($merchant->from_id, $merchant->id, $merchant->ratio);
|
||||
} elseif ($hierarchy == 2) {
|
||||
//代理级别
|
||||
if($merchant->level==2)
|
||||
{
|
||||
//代理级别
|
||||
return MerchantRatio::addProxyLevel($merchant->from_id, $merchant->id, $merchant->ratio);
|
||||
}else
|
||||
{
|
||||
//商户级别
|
||||
return MerchantRatio::add($merchant->from_id, $merchant->level, 2, $merchant->id, $merchant->ratio);
|
||||
}
|
||||
} elseif ($hierarchy == 1) {
|
||||
//普通级别
|
||||
return MerchantRatio::add(0, $merchant->level, 1, $merchant->id, $merchant->ratio);
|
||||
}
|
||||
|
||||
/* //判断层级是否一样且父没有更换,如果是的话,只需要更新,无需删除和添加操作
|
||||
if($hierarchy==$ratio->hierarchy && $merchant->from_id==$ratio->parent_id)
|
||||
{
|
||||
|
||||
MerchantRatio::where('merchant_id',$merchant->id)->update(['hierarchy'=>$hierarchy,'ratio'=>$merchant->ratio,'parent_id'=>$merchant->from_id,'level'=>$merchant->level]);//
|
||||
}else
|
||||
{
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function saveAfter($request, $model, $id = '')
|
||||
{
|
||||
|
||||
//创建钱包记录
|
||||
$this->crateWallte($request, $model);
|
||||
//判断等级,
|
||||
$level = $request->input('level');
|
||||
$from_id = merchant('id');
|
||||
//添加操作
|
||||
if ($id) {
|
||||
//更新
|
||||
//当前的身份等级
|
||||
$this->updateMerchantRatio($model);
|
||||
|
||||
} else {
|
||||
//上级ID存在
|
||||
if ($from_id) {
|
||||
//等级判断
|
||||
if ($level == 2) {
|
||||
//代理级别添加
|
||||
return MerchantRatio::addProxyLevel($from_id, $model->id, $request->input('ratio'));
|
||||
}
|
||||
//如果添加是商户
|
||||
if ($level == 3) {
|
||||
return MerchantRatio::addDefault($from_id, $model->id, $model->ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
write_merchant();//写入配置文件
|
||||
//写入费率信息
|
||||
write_merchant_ratio();
|
||||
|
||||
}
|
||||
|
||||
public function crateWallte(Request $request, $model)
|
||||
{
|
||||
$obj = new MerchantWallet();
|
||||
//判断是否存在,如果存在不需要再创建
|
||||
$has = $obj->where('merchant_id', $model->id)->first();
|
||||
if (!$has) {
|
||||
MerchantWallet::firstOrCreate(['merchant_id' => $model->id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function insertBank($arr, $id = '', $is_del = 0)
|
||||
{
|
||||
if (count($arr) <= 0) {
|
||||
return false;
|
||||
}
|
||||
$insert_m_data = [];
|
||||
if ($is_del) {
|
||||
//删除之前的
|
||||
BankRel::where(['model_id' => $id, 'model_type' => 'merchant', 'is_default' => 1])->delete();
|
||||
}
|
||||
//插入关联表
|
||||
$insert_m_data = $arr;
|
||||
$insert_m_data['model_id'] = $id;
|
||||
$insert_m_data['model_type'] = 'merchant';
|
||||
$insert_m_data['is_default'] = 1;
|
||||
BankRel::insert($insert_m_data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new Merchant();
|
||||
}
|
||||
|
||||
public function createGroupBtn($id, $prev_id, $level, $msg, $color = 'default')
|
||||
{
|
||||
return '<button class="layui-btn layui-btn-sm layui-btn-' . $color . '" lay-event="soso" data-id="' . $id . '" data-pid="' . $prev_id . '" data-level="' . $level . '"> ' . $msg . ' </button>';
|
||||
}
|
||||
|
||||
public function createGroupBackBtn($id, $prev_id, $level, $msg, $color = 'default')
|
||||
{
|
||||
return '<button class="layui-btn layui-btn-sm layui-btn-' . $color . '" lay-event="soso" data-id="' . $id . '" data-pid="' . $prev_id . '" data-level="' . $level . '"> ' . $msg . ' </button>';
|
||||
}
|
||||
|
||||
public function createGroupAddBtn($id, $msg, $color = 'danger')
|
||||
{
|
||||
return '<button class="layui-btn layui-btn-sm layui-btn-' . $color . '" lay-event="add" data-id="' . $id . '" > ' . $msg . ' </button>';
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
|
||||
|
||||
$param = $request->all();
|
||||
|
||||
$param['id_in'] = Merchant::subAllMerchant(merchant('id'));
|
||||
|
||||
$prev_id = $request->input('prev_id', 0);
|
||||
$level = $request->input('level', '');
|
||||
//搜索集合地
|
||||
$search = (new SearchServices($this->setModel(), $param));
|
||||
$model = $search->getList();
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->with(['wallets', 'froms' => function ($query) {
|
||||
//再来嵌套一个
|
||||
$query->with('froms');
|
||||
}])->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url'] = action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url'] = action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['show_url'] = action($this->route['controller_name'] . '@show', ['id' => $v->id]);
|
||||
|
||||
$v['draw_money'] = $v->wallets['draw_money'];
|
||||
$v['other_money'] = $v->wallets['other_money'];
|
||||
$v['total_money'] = $v->wallets['total_money'];
|
||||
$v['money'] = $v->wallets['money'];
|
||||
$v['check_status_name2'] = $v->check_status != 1 ? '<span class="text-red">' . $v->CheckStatusName . '</span>' : $v->CheckStatusName;
|
||||
|
||||
$v['name_tpl'] = $v->name;
|
||||
$from_name = '';
|
||||
if ($v->froms['name'] != merchant('name')) {
|
||||
$from_name = '<p class="text-blue ">上级:' . $v->froms['name'] . '</p>';
|
||||
if ($v->froms['froms']['name']) {
|
||||
$from_name .= '<p class="text-color-lvse">顶级:' . $v->froms['froms']['name'] . '</p>';
|
||||
}
|
||||
}
|
||||
$btn = '';
|
||||
$back_id = $prev_id;
|
||||
if ($v->level == 3) {
|
||||
$level = $v->level - 1;
|
||||
}
|
||||
if ($v->level == 2) {
|
||||
$back_id = 0;
|
||||
}
|
||||
$back_btn = $this->createGroupBackBtn($back_id, $v->from_id, $level, '返回');
|
||||
//全部列表不显示按钮
|
||||
if (!$request->input('is_all')) {
|
||||
if ($v->from_id == \merchant('id')) {
|
||||
$back_btn = '';
|
||||
}
|
||||
//股东上面才有上下级
|
||||
if ($v->level == 1) {
|
||||
$btn = '<div class="layui-btn-group">' . $this->createGroupBtn($v->id, $v->from_id, 2, '下级代理') . $back_btn . '</div>';
|
||||
}
|
||||
if ($v->level == 2) {
|
||||
|
||||
$btn = '<div class="layui-btn-group">' . $this->createGroupBtn($v->id, $v->from_id, 3, '下级商户') . $back_btn . '
|
||||
|
||||
</div>';
|
||||
}
|
||||
if ($v->level == 3) {
|
||||
if ($v->from_id) {
|
||||
$btn = '<div class="layui-btn-group">' . $back_btn . '
|
||||
|
||||
</div>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$color = 'layui-bg-green';
|
||||
if ($v->level == 1) {
|
||||
$color = 'layui-bg-cyan';
|
||||
} elseif ($v->level == 2) {
|
||||
$color = 'layui-bg-blue';
|
||||
}
|
||||
$v['level_name_label'] = '<span class="layui-badge ' . $color . '">' . $v->levelName . '</span> ';
|
||||
$v['name'] = '<p>' . $v->name . '</p>' . $from_name . '<p>邮箱:' . $v->email . '</p>' . $btn;
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"pid" => $prev_id,
|
||||
"level" => $level,
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\AdminLog;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\MerchantMoneyLog;
|
||||
use App\Models\MerchantRatio;
|
||||
use App\Models\Sms;
|
||||
use App\Models\SmsLog;
|
||||
use App\Services\SearchServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class MerchantMoneyLogController extends BaseDefaultController
|
||||
{
|
||||
|
||||
public function setPagesInfo()
|
||||
{
|
||||
|
||||
|
||||
$this->pages = [
|
||||
'name' => '资金变动'
|
||||
];
|
||||
}
|
||||
public function indexData()
|
||||
{
|
||||
return ['type'=>config('adconfig.money_log_type')];
|
||||
}
|
||||
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
}
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new MerchantMoneyLog();
|
||||
}
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$type = $request->input('type', '');
|
||||
$merchant_id = $request->input('merchant_id');
|
||||
|
||||
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
//是否查看下级
|
||||
$sub_show=$request->input('sub_show');
|
||||
if($sub_show!=1)
|
||||
{
|
||||
|
||||
//不是下级查看,就是查看自己的
|
||||
$merchant_id = $this->getMerchantId();
|
||||
}else{
|
||||
//是否是代理,下级是否属于这个上级,如果属于给权限,如果没有,则返回自己的
|
||||
if ($this->isProxy()) {
|
||||
$sub_id_arr=Merchant::subAllMerchant($this->getMerchantId());
|
||||
if(!in_array($merchant_id,$sub_id_arr))
|
||||
{
|
||||
$merchant_id = $this->getMerchantId();
|
||||
}
|
||||
}else
|
||||
{
|
||||
$merchant_id = $this->getMerchantId();
|
||||
}
|
||||
}
|
||||
$model=$model->where('merchant_id',$merchant_id);
|
||||
|
||||
$search_arr = [
|
||||
'type' => [
|
||||
'value' => $type,
|
||||
'type' => '='
|
||||
]
|
||||
|
||||
|
||||
];
|
||||
$model = $this->searchKey($model, $search_arr, 2);
|
||||
$search=new SearchServices($model,$request->all());
|
||||
$model=$search->getModel();
|
||||
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['type_name'] = $v->type_name;
|
||||
$v['name'] = $v->merchants->name;
|
||||
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\MerchantRegist;
|
||||
use App\Services\SearchServices;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class MerchantRegistController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '推广注册列表'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
protected function postDataDb($request,$id='')
|
||||
{
|
||||
$data = $request->all();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
|
||||
$this->pages = [
|
||||
'name' => '订单'
|
||||
];
|
||||
$type = [
|
||||
'pay_status' => config('adconfig.pay_status'),
|
||||
'order_status'=>config('adconfig.order_status'),
|
||||
'payfor_status'=>config('adconfig.payfor_status'),
|
||||
'order_notify'=>config('adconfig.order_notify'),
|
||||
'merchant'=>Merchant::whereIn('id',Merchant::subAllMerchant(\merchant('id')))->get()
|
||||
];
|
||||
return $type;
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$show = $this->setModel()->find($id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//($pictrue);
|
||||
|
||||
|
||||
return $this->display(['show' => $show ]);
|
||||
}
|
||||
|
||||
|
||||
public function shareData($show = '')
|
||||
{
|
||||
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new MerchantRegist();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
if(merchant('level')==3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
|
||||
|
||||
$param=$request->all();
|
||||
|
||||
$search =(new SearchServices($model,$param));
|
||||
|
||||
$model=$search->getList();
|
||||
$model=$model->where('from_merchant_id',$this->getMerchantId());
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
|
||||
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
|
||||
$status=[
|
||||
1=>'<span class="layui-badge layui-bg-green">注册成功</span>',
|
||||
0=>'未支付或注册失败'
|
||||
];
|
||||
$v['status_name']=$status[$v->status];
|
||||
$level=config('adconfig.merchant_level');
|
||||
$v['level_name']='<span class="layui-btn layui-btn-sm '.($v->level==2?'layui-btn-danger':'').'">'.$level[$v->level].'</span>';
|
||||
$v['ratio']=($v['ratio']/10).'%';
|
||||
$v['type_name']=$v->type==1?'<span class="text-red">注册费</span>':'注册费率';
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
public function checkStatus(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
return $this->getShow($id);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\MerchantRegistToken;
|
||||
use App\Services\SearchServices;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Jenssegers\Date\Date;
|
||||
use Yansongda\Supports\Str;
|
||||
|
||||
class MerchantRegistTokenController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '注册推广'
|
||||
];
|
||||
|
||||
}
|
||||
public function checkRule($id = '')
|
||||
{
|
||||
|
||||
return [
|
||||
'type' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
'draw_money.required' => '提现金额不能为空',
|
||||
'money.required' => '到账金额不能为空',
|
||||
'fee_money.required' => '手续费不能为空',
|
||||
'bank_realname.required' => '收款人不能为空',
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
protected function postDataDb($request,$id='')
|
||||
{
|
||||
if(merchant('level')==3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$data = $request->all();
|
||||
$data['merchant_id']=merchant('id');
|
||||
$data['regist_token']=date('YmdHis').Str::random(20);
|
||||
if($data['type']==1)
|
||||
{
|
||||
$merchant_regist_has_ratio=config_cache_default('merchant_config.merchant_regist_has_ratio',10);
|
||||
$data['ratio']=merchant('ratio')+$merchant_regist_has_ratio;
|
||||
}else
|
||||
{
|
||||
$ratio=config_cache_default('merchant_config.merchant_regist_min_ratio',20);
|
||||
$data['ratio']=merchant('ratio')+$ratio;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
public function addOutData($id='')
|
||||
{
|
||||
$model=$this->store_model;
|
||||
|
||||
return [
|
||||
'url'=>route('web.merchant.regist',['token'=>$model->regist_token])
|
||||
];
|
||||
}
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
|
||||
$this->pages = [
|
||||
'name' => '订单'
|
||||
];
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$show = $this->setModel()->find($id);
|
||||
|
||||
//($pictrue);
|
||||
|
||||
|
||||
return $this->display(['show' => $show ]);
|
||||
}
|
||||
|
||||
|
||||
public function shareData($show = '')
|
||||
{
|
||||
|
||||
|
||||
$money=config_cache_default('merchant_config.merchant_regist_money_list');
|
||||
$money=explode("\n",$money);
|
||||
$money=is_array($money)?$money:[];
|
||||
$ratio=config_cache_default('merchant_config.merchant_regist_min_ratio',20);
|
||||
$merchant_regist_has_ratio=config_cache_default('merchant_config.merchant_regist_has_ratio',10);
|
||||
|
||||
//最低注册金额
|
||||
$min_money=config_cache_default('merchant_config.merchant_regist_min_money',500);
|
||||
return [
|
||||
'money'=>$money,
|
||||
'ratio'=>$ratio,
|
||||
'min_money'=>$min_money,
|
||||
'merchant_regist_has_ratio'=>$merchant_regist_has_ratio
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new MerchantRegistToken();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function checkStatus(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
return $this->getShow($id);
|
||||
|
||||
}
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$model=$model->where('merchant_id',$this->getMerchantId());
|
||||
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
||||
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
||||
$v['type_name']=$v->type==1?'<span class="text-red">注册费</span>':'注册费率';
|
||||
$v['money_info']=$v->type==1?$v->money:($v->ratio/10).'%';
|
||||
$v['url']=route('web.merchant.regist',['token'=>$v->regist_token]);
|
||||
$level=config('adconfig.merchant_level');
|
||||
$v['level_name']='<span class="layui-btn layui-btn-sm '.($v->level==2?'layui-btn-danger':'').'">'.$level[$v->level].'</span>';
|
||||
$v['ratio']=($v['ratio']/10).'%';
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
"status"=>1,
|
||||
'code'=>$total>0?0:1,
|
||||
'msg'=>$total>0?'请求数据成功':'暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Services\SearchServices;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class OrderController extends BaseDefaultController
|
||||
{
|
||||
public function setPagesInfo()
|
||||
{
|
||||
$this->pages = [
|
||||
'name' => '我的订单'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
protected function postDataDb($request,$id='')
|
||||
{
|
||||
$data = $request->all();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function indexData()
|
||||
{
|
||||
|
||||
$this->pages = [
|
||||
'name' => '订单'
|
||||
];
|
||||
$type = [
|
||||
'pay_status' => config('adconfig.pay_status'),
|
||||
'order_status'=>config('adconfig.order_status'),
|
||||
'payfor_status'=>config('adconfig.payfor_status'),
|
||||
'order_notify'=>config('adconfig.order_notify'),
|
||||
'merchant'=>Merchant::whereIn('id',Merchant::subAllMerchant(\merchant('id')))->get()
|
||||
];
|
||||
return $type;
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$show = $this->setModel()->find($id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//($pictrue);
|
||||
|
||||
|
||||
return $this->display(['show' => $show ]);
|
||||
}
|
||||
|
||||
|
||||
public function shareData($show = '')
|
||||
{
|
||||
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function setModel()
|
||||
{
|
||||
return new Order();
|
||||
}
|
||||
|
||||
|
||||
public function apiJson(Request $request)
|
||||
{
|
||||
$offset = $request->input('page', 1);
|
||||
$pagesize = $request->input('limit', 1);
|
||||
$offset = ($offset - 1) * $pagesize;
|
||||
$order_id = $request->input('sort', 'id');
|
||||
$order_type = $request->input('order', 'desc');
|
||||
$debug = $request->input('debug', 0);
|
||||
$model = $this->setModel();
|
||||
|
||||
$agent=$request->input('agent',0);
|
||||
|
||||
$param=$request->all();
|
||||
$search =(new SearchServices($model,$param,'order_merchant'));
|
||||
|
||||
$model=$search->getList();
|
||||
if($this->isProxy())
|
||||
{
|
||||
if($agent)
|
||||
{
|
||||
|
||||
$model=$model->whereIn('merchant_id',Merchant::subAllMerchant($this->getMerchantId()));
|
||||
}else
|
||||
{
|
||||
$model=$model->where('merchant_id',$this->getMerchantId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$model=$model->where('merchant_id',$this->getMerchantId());
|
||||
}
|
||||
$total = $model->count();
|
||||
$result = $model->skip($offset)->with('users','merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
||||
|
||||
|
||||
$narr = array();
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
$v['pay_type_name']=config('adconfig.pay_type')[$v['pay_type']];
|
||||
$v['server_name']=$v->merchants['name'];
|
||||
$v['order_status_name']=config('adconfig.order_status')[$v['status']];
|
||||
$v['notify_status_name']=config('adconfig.order_notify')[$v['notify_status']];
|
||||
//$v['payfor_status_name']=config('adconfig.payfor_status')[$v['success_status']];
|
||||
$v['update_notify_url']=admin_merchant_url('OrderHandleApi','handlePost',['order_id'=>$v->id,'type'=>'notifyPost','agent'=>$agent]);
|
||||
$v['show_url'] = $v->order_show_url2;
|
||||
$v['gateway_method_name']=array_key_exists($v['gateway_method'],config('adconfig.pay_client'))?config('adconfig.pay_client')[$v['gateway_method']]:'未知';
|
||||
$v['level']=merchant('level');
|
||||
$narr[] = $v;
|
||||
}
|
||||
$json = [
|
||||
|
||||
"status" => 1,
|
||||
'code' => $total > 0 ? 0 : 1,
|
||||
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
||||
'count' => $total,
|
||||
'data' => $narr
|
||||
];
|
||||
|
||||
if ($debug) {
|
||||
return $this->jsonDebug($json);
|
||||
}
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
public function checkStatus(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
return $this->getShow($id);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderHandleLog;
|
||||
use App\Models\PayForLog;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Ixudra\Curl\Facades\Curl;
|
||||
use PayServices;
|
||||
use function PHPSTORM_META\type;
|
||||
|
||||
class OrderHandleApiController extends BaseController
|
||||
{
|
||||
|
||||
|
||||
public $input_status;
|
||||
public $order_id;
|
||||
public $orderObj;
|
||||
public $userObj;
|
||||
public $serverObj;
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
parent::__construct();
|
||||
//通过之后再获取
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->input_status=$request->status;
|
||||
$this->order_id=$request->order_id;
|
||||
$this->orderObj=Order::find($this->order_id);
|
||||
if($this->orderObj->merchant_id!=0)
|
||||
{
|
||||
$this->serverObj=$this->orderObj->merchants;
|
||||
}
|
||||
view()->share('order_id',$this->order_id);
|
||||
view()->share('order',$this->orderObj);
|
||||
return $next($request);
|
||||
});
|
||||
|
||||
}
|
||||
public function handle($order_id,$type,Request $request){
|
||||
|
||||
return $this->$type($request);
|
||||
}
|
||||
public function handlePost($order_id,$type,Request $request){
|
||||
return $this->$type($request);
|
||||
}
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
|
||||
return response()->json(['error'=>1,'msg'=>'该方法不存在']);
|
||||
}
|
||||
|
||||
|
||||
public function msg($arr)
|
||||
{
|
||||
return response()->json($arr);
|
||||
}
|
||||
|
||||
|
||||
public function notifyPost(Request $request){
|
||||
//发送curl过去
|
||||
$order_info=$this->orderObj->infos;
|
||||
$agent=$request->input('agent',0);
|
||||
if($agent==1)
|
||||
{
|
||||
//如果不存在
|
||||
if(!in_array($order_info->merchant_id,merchant()->mySubMerchant()))
|
||||
{
|
||||
return $this->errorJosn('不能操作其他人的订单');
|
||||
}
|
||||
|
||||
}else
|
||||
{
|
||||
|
||||
if($order_info->merchant_id!=$this->getMerchantId())
|
||||
{
|
||||
return $this->errorJosn('不能操作其他人的订单');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if($order_info)
|
||||
{
|
||||
$notify_url=$order_info->notify_url;//回调地址
|
||||
//签名计算
|
||||
$data=[
|
||||
'app_id'=>$this->serverObj->app_key,
|
||||
'token'=>$this->serverObj->token,
|
||||
'money'=>$this->orderObj->order_money,
|
||||
'return_url'=>$order_info->return_url,
|
||||
'notify_url'=>$order_info->notify_url,
|
||||
'out_trade_sn'=>$this->orderObj->out_trade_sn
|
||||
];
|
||||
//dump($data);
|
||||
//回调携带参数回去
|
||||
//返回付款金额,原来充值金额,本站订单号,支付流水号,原网站订单号,附加消息原样返回
|
||||
$notify_data=[
|
||||
'pay_money'=>$this->orderObj->pay_money,
|
||||
'money'=>$this->orderObj->order_money,
|
||||
'order_sn'=>$this->orderObj->order_sn,
|
||||
'out_trade_sn'=>$this->orderObj->out_trade_sn,
|
||||
'pay_order_sn'=>$this->orderObj->pay_order_sn,
|
||||
// 'sign'=>PayServices::sign($data,1),
|
||||
'sign' => md5($this->serverObj->token . $order_info->sign . 'pay_money=' . $this->orderObj->pay_money . 'pay_status=' . $this->orderObj->pay_status),
|
||||
'attch'=>$order_info->attach,
|
||||
'pay_status' => $this->orderObj->pay_status,
|
||||
'return_url'=>$order_info->return_url,
|
||||
'notify_url'=>$order_info->notify_url
|
||||
];
|
||||
Log::channel('pay_order')->info('merchant手动回调信息', $notify_data);
|
||||
//dd($notify_data);
|
||||
if(!$notify_url)
|
||||
{
|
||||
return response(['error'=>1,'msg'=>'回调失败,缺少回调地址','back'=>'']);
|
||||
}
|
||||
|
||||
//发送curl
|
||||
$r=Curl::to($notify_url)->withData($notify_data)->post();
|
||||
//返回success表示回调成功
|
||||
|
||||
//dump(gettype($r));
|
||||
|
||||
if($r=='success')
|
||||
{
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
//更新订单
|
||||
$this->orderObj->out_notify_status=1;
|
||||
$this->orderObj->status=1;
|
||||
$or=$this->orderObj->save();
|
||||
|
||||
//
|
||||
$order_info->notify_data=json_encode($notify_data);
|
||||
$order_info->notify_status=$r;
|
||||
$lr=$order_info->save();
|
||||
if($lr && $or)
|
||||
{
|
||||
//写入日志
|
||||
$this->orderHandleLog(['from_status' => 2, 'to_status' => 1,'name'=>'外站回调成功'], $this->order_id);
|
||||
DB::commit();
|
||||
return response(['error'=>0,'msg'=>'回调成功','back'=>$r]);
|
||||
}
|
||||
DB::rollBack();
|
||||
$this->orderHandleLog(['from_status' => 2, 'to_status' => 1,'name'=>'外站回调失败'], $this->order_id);
|
||||
return response(['error'=>1,'msg'=>'对方回调成功,本站更新失败','back'=>$r]);
|
||||
}else
|
||||
{
|
||||
|
||||
return response(['error'=>1,'msg'=>'回调失败,外部没有返回success','back'=>$r,'sign_data'=>$data,'url'=>$notify_url,'notify_data'=>$notify_data]);
|
||||
}
|
||||
|
||||
}
|
||||
return response(['error'=>1,'msg'=>'回调失败,缺少回调地址','back'=>'']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//结算日志
|
||||
public function payForLog($config){
|
||||
$log=new PayForLog();
|
||||
$log->order_id = $this->order_id;
|
||||
|
||||
foreach ($config as $k => $v) {
|
||||
$log->$k = $v;
|
||||
}
|
||||
$log->admin_id=admin('id');
|
||||
$log->admin_name=admin('account');
|
||||
$r = $log->save();
|
||||
if ($r) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
//订单操作日志
|
||||
public function orderHandleLog($config){
|
||||
$log = new OrderHandleLog();
|
||||
foreach ($config as $k => $v) {
|
||||
$log->$k = $v;
|
||||
}
|
||||
$log->order_id = $this->order_id;
|
||||
$log->handle_user_id = merchant('id');//
|
||||
$log->handle_user_name =merchant('name');//
|
||||
$log->handle_user_type ='merchant';//
|
||||
$r = $log->save();
|
||||
$this->insertLog('操作订单,行为是'.$config['name']);
|
||||
if ($r) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Merchant;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Services\OrderStatisServices;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class StatisController extends BaseController
|
||||
{
|
||||
public function index($type,Request $request){
|
||||
switch ($type)
|
||||
{
|
||||
case 'order';
|
||||
$order=new OrderStatisServices($this->getMerchantId(),$request);
|
||||
$order->echoWhere();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pay;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderInfo;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ApiPayController extends BaseController
|
||||
{
|
||||
public $order;
|
||||
public function scanOrderBack(Request $request){
|
||||
//返回给商户
|
||||
$order_sn=$request->input('order_sn');
|
||||
if(!$order_sn)
|
||||
{
|
||||
return $this->msg(['error'=>1,'msg'=>'缺少参数']);
|
||||
}
|
||||
$this->order = Order::where('order_sn', $order_sn)->first();
|
||||
if ($this->order['pay_status'] == 1) {
|
||||
//判断是否是商户id
|
||||
if ($this->order->merchant_id == 0) {
|
||||
return redirect()->route('web.user.index');
|
||||
}
|
||||
//返回参数,订单编号,签名
|
||||
|
||||
//判断外站
|
||||
//取得订单信息
|
||||
$order_info = OrderInfo::where('order_id', $this->order->id)->first();
|
||||
$return_url = $order_info->return_url;
|
||||
$merchant = get_merchant($order_info->app_id);//取得商户
|
||||
//发送回调
|
||||
//发送签名过去,组装信息
|
||||
$notify_data = [
|
||||
'pay_money' => $this->order->pay_money,
|
||||
'money' => $this->order->order_money,
|
||||
'order_sn' => $this->order->order_sn,
|
||||
'out_trade_sn' => $this->order->out_trade_sn,
|
||||
'pay_order_sn' => $this->order->pay_order_sn,
|
||||
'sign' => md5($merchant['token'] . $order_info->sign . 'pay_money=' . $this->order->pay_money . 'pay_status=' . $this->order->pay_status),
|
||||
'attch' => $order_info->attach,
|
||||
'return_url' => $order_info->return_url,
|
||||
'pay_status' => $this->order->pay_status,
|
||||
'notify_url' => $order_info->notify_url
|
||||
];
|
||||
return redirect()->away(arr_to_url($return_url, $notify_data));
|
||||
} else {
|
||||
return '未支付';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pay;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
//
|
||||
public $debug = 1;
|
||||
public function debugLog($str = '', $arr = [])
|
||||
{
|
||||
if ($str) {
|
||||
if ($this->debug) {
|
||||
Log::info($str, $arr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public function msg($data){
|
||||
if(request()->ajax())
|
||||
{
|
||||
return response()->json($data);
|
||||
}
|
||||
return $this->htmlAlert($data);
|
||||
|
||||
}
|
||||
public function htmlAlert($data){
|
||||
echo '<script>alert("'.$data['msg'].'");window.history.back()</script>';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pay;
|
||||
|
||||
use App\ServicePay\PayApiProvidesTrait;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PayController extends BaseController
|
||||
{
|
||||
use PayApiProvidesTrait;
|
||||
public $pay_service;
|
||||
|
||||
/**
|
||||
* 同步回调
|
||||
* @param $type 支付类型:支付宝,微信
|
||||
* @param Request $request
|
||||
*/
|
||||
public function returnNotify($type, Request $request)
|
||||
{
|
||||
$this->setPayService($type);
|
||||
return $this->pay_service->notify(1, $type, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步回调
|
||||
* @param $type支付类型:支付宝,微信
|
||||
* @param Request $request
|
||||
*/
|
||||
public function notify($type, Request $request)
|
||||
{
|
||||
$this->setPayService($type);
|
||||
return $this->pay_service->notify(0, $type, $request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class AboutController extends BaseController
|
||||
{
|
||||
//
|
||||
public function index($type,Request $request){
|
||||
$page=Category::where('ename',$type)->first();
|
||||
|
||||
//取得内容
|
||||
$data=[
|
||||
'page'=>$page
|
||||
];
|
||||
$this->setTitle($page->name,$page->seo_keyword,$page->seo_keyword);
|
||||
$this->setViewPath('',$type);
|
||||
return $this->display($data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Route;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
//
|
||||
const ADMIN_BLADE_DIR = 'web.';
|
||||
public $title = '';
|
||||
public $route = [];
|
||||
public $pages = [];
|
||||
public $model;
|
||||
public $share_view = [];
|
||||
public $debug = 1;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$route_arr = explode('@', Route::currentRouteAction());
|
||||
$this->route['controller_name'] = '\\' . $route_arr[0];
|
||||
$this->route['action_name'] = $route_arr[1];
|
||||
$this->route['controller_base'] = str_replace('Controller', '', str_replace('App\\Http\\Controllers\\Web\\', '', $route_arr[0]));
|
||||
$this->route['blade'] = self::ADMIN_BLADE_DIR . strtolower($this->route['controller_base']) . '.' . $this->route['action_name'];
|
||||
$this->share_view['controller'] = "\\" . $this->route['controller_name'];
|
||||
$this->title = ucwords($this->route['action_name']);
|
||||
$this->share_view['title'] = $this->title;
|
||||
$this->share_view['action_name'] = $this->route['action_name'];
|
||||
$style_path = '/style/web/';
|
||||
$style_path = asset($style_path);
|
||||
|
||||
$this->share_view['style_path'] = $style_path;
|
||||
|
||||
|
||||
$this->shareView();
|
||||
|
||||
}
|
||||
public function msg($data){
|
||||
if(request()->ajax())
|
||||
{
|
||||
return response()->json($data);
|
||||
}
|
||||
return $this->htmlAlert($data);
|
||||
|
||||
}
|
||||
public function htmlAlert($data){
|
||||
echo '<script>alert("'.$data['msg'].'");window.history.back()</script>';
|
||||
}
|
||||
|
||||
public function debugLog($str = '', $arr = [])
|
||||
{
|
||||
if ($str) {
|
||||
if ($this->debug) {
|
||||
Log::info($str, $arr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setTitle($title, $keyword, $description)
|
||||
{
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'keyword' => $keyword,
|
||||
'description' => $description,
|
||||
];
|
||||
return $this->setShareView($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证规则
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function checkRule($id = '')
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置表单验证错误信息
|
||||
* @return array
|
||||
*/
|
||||
public function setErrorMsg()
|
||||
{
|
||||
$messages = [
|
||||
|
||||
];
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局返回表单错误消息
|
||||
* @param $error
|
||||
* @return array
|
||||
*/
|
||||
protected function formError($error)
|
||||
{
|
||||
$error = $error->all();
|
||||
if (count($error) <= 0) return [];
|
||||
$error_str = '';
|
||||
foreach ($error as $k => $v) {
|
||||
|
||||
$error_str .= $v . "*\n";
|
||||
|
||||
}
|
||||
return ['error' => 1, 'msg' => $error_str, 'type' => 'validator'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function alertError($error_str, $status = 1)
|
||||
{
|
||||
return response()->json(['error' => $status, 'msg' => $error_str, 'type' => 'validator']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局检测表单是否错误,如果又返回错误数组,否则空数组
|
||||
* @param $request
|
||||
* @param string $id
|
||||
* @return array
|
||||
*/
|
||||
protected function validatorForm($request, $id = '')
|
||||
{
|
||||
$validator = Validator::make($request->all(), $this->checkRule($id), $this->setErrorMsg());
|
||||
if ($validator->fails()) {
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
return $validator->errors();
|
||||
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置创建数据键值对
|
||||
* @param $obj
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
protected function setDbKeyValue($obj, $data)
|
||||
{
|
||||
$fileds = $this->getField();
|
||||
foreach ($data as $field => $v) {
|
||||
if (in_array($field, $fileds)) {
|
||||
$v = is_null($v) ? '' : $v;
|
||||
$obj->$field = trim($v);
|
||||
}
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 共享视图资源
|
||||
* @return mixed
|
||||
*/
|
||||
public function shareView()
|
||||
{
|
||||
$data = $this->share_view;
|
||||
return view()->share($data);
|
||||
|
||||
}
|
||||
|
||||
public function setShareView($data)
|
||||
{
|
||||
return view()->share($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变自动获取blade
|
||||
* @param $path
|
||||
* @param int $cover 是否完全覆盖
|
||||
* @param int $is_seft 是否在当前的控制下目录
|
||||
* @return string
|
||||
*/
|
||||
protected function setViewPath($path = '', $filename = '', $cover = 0, $is_seft = 1)
|
||||
{
|
||||
if ($cover) {
|
||||
return $this->route['blade'] = $path;
|
||||
}
|
||||
if ($is_seft == 0) {
|
||||
return $this->route['blade'] = self::ADMIN_BLADE_DIR . $path;
|
||||
}
|
||||
if ($filename != '') {
|
||||
$this->route['action_name'] = $filename;
|
||||
}
|
||||
if ($path) {
|
||||
$this->route['action_name'] = $path . "." . $this->route['action_name'];
|
||||
}
|
||||
return $this->route['blade'] = self::ADMIN_BLADE_DIR . strtolower($this->route['controller_base']) . '.' . $this->route['action_name'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 本页面操作的模型
|
||||
*/
|
||||
protected function setModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function checkSelf($show)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getShow($id)
|
||||
{
|
||||
$show = $this->setModel()->find($id);
|
||||
|
||||
|
||||
if (!$show) {
|
||||
return abort(404);
|
||||
}
|
||||
view()->share('show', $show);
|
||||
|
||||
return $this->display($this->shareData($show));
|
||||
}
|
||||
|
||||
//共享创建和编辑数据
|
||||
protected function shareData($id = '')
|
||||
{
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return $this->getShow($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出视图
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function display($data = [])
|
||||
{
|
||||
|
||||
return view($this->route['blade'], $data);
|
||||
}
|
||||
|
||||
public function jsonDebug($json)
|
||||
{
|
||||
print_r($json);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function searchKey($model, $arr, $where = 1)
|
||||
{
|
||||
return $model->search($arr, $where);
|
||||
|
||||
}
|
||||
|
||||
public function jsonMsg($error, $str)
|
||||
{
|
||||
return response()->json(['error' => $error, 'msg' => $str]);
|
||||
}
|
||||
|
||||
/*********基本控制器资源设置*********/
|
||||
public function noSelfMsg()
|
||||
{
|
||||
if (\request()->ajax() || \request()->wantsJson()) {
|
||||
return response()->json(['error' => '1', 'msg' => '非法操作数据']);
|
||||
}
|
||||
return abort(401, '非法操作数据');
|
||||
}
|
||||
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
|
||||
return abort('401', $method . '方法不存在');
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue