删除多余文件

This commit is contained in:
liaofei 2019-12-11 09:42:50 +08:00
parent 1521e55eef
commit 7b6c458d8e
9 changed files with 65 additions and 574 deletions

View File

@ -4,7 +4,6 @@ namespace app\admin\controller\article;
use app\admin\controller\AuthController;
use crmeb\services\UtilService as Util;
use crmeb\services\PHPTreeService as Phptree;
use crmeb\services\JsonService as Json;
use crmeb\services\UploadService as Upload;
use app\admin\model\article\ArticleCategory as ArticleCategoryModel;
@ -28,22 +27,12 @@ class Article extends AuthController
public function index()
{
$where = Util::getMore([
['title',''],
['cid','']
],$this->request);
$pid = $this->request->param('pid');
$this->assign('where',$where);
['title', ''],
['cid', $this->request->param('pid', '')]
], $this->request);
$this->assign('where', $where);
$where['merchant'] = 0;//区分是管理员添加的图文显示 0 还是 商户添加的图文显示 1
$cateList = ArticleCategoryModel::getArticleCategoryList();
$tree = [];
//获取分类列表
if(count($cateList)){
$tree = Phptree::makeTreeForHtml($cateList);
if($pid){
$pids = Util::getChildrenPid($tree,$pid);
$where['cid'] = ltrim($pid.$pids);
}
}
$tree = sort_list_tier(ArticleCategoryModel::getArticleCategoryList());
$this->assign(compact('tree'));
$this->assign(ArticleModel::getAll($where));
return $this->fetch();
@ -56,7 +45,8 @@ class Article extends AuthController
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function create(){
public function create()
{
$id = $this->request->param('id');
$cid = $this->request->param('cid');
$news = [];
@ -71,26 +61,26 @@ class Article extends AuthController
$news['synopsis'] = '';
$news['url'] = '';
$news['cid'] = [];
$select = 0;
if($id){
$news = ArticleModel::where('n.id',$id)->alias('n')->field('n.*,c.content')->join('ArticleContent c','c.nid=n.id','left')->find();
if(!$news) return $this->failed('数据不存在!');
$news['cid'] = explode(',',$news['cid']);
$select = 0;
if ($id) {
$news = ArticleModel::where('n.id', $id)->alias('n')->field('n.*,c.content')->join('ArticleContent c', 'c.nid=n.id', 'left')->find();
if (!$news) return $this->failed('数据不存在!');
$news['cid'] = explode(',', $news['cid']);
}
if($cid && in_array($cid, ArticleCategoryModel::getArticleCategoryInfo(0,'id'))){
if ($cid && in_array($cid, ArticleCategoryModel::getArticleCategoryInfo(0, 'id'))) {
$all = ArticleCategoryModel::getArticleCategoryInfo($cid);
$select = 1;
}
if(!$select){
if (!$select) {
$list = ArticleCategoryModel::getTierList();
foreach ($list as $menu){
$all[$menu['id']] = $menu['html'].$menu['title'];
foreach ($list as $menu) {
$all[$menu['id']] = $menu['html'] . $menu['title'];
}
}
$this->assign('all',$all);
$this->assign('news',$news);
$this->assign('cid',$cid);
$this->assign('select',$select);
$this->assign('all', $all);
$this->assign('news', $news);
$this->assign('cid', $cid);
$this->assign('select', $select);
return $this->fetch();
}
@ -98,20 +88,22 @@ class Article extends AuthController
* 上传图文图片
* @return \think\response\Json
*/
public function upload_image(){
$res = Upload::instance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']);
if(!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']);
return Json::successful('上传成功!',['url'=>$res['dir']]);
public function upload_image()
{
$res = Upload::instance()->setUploadPath('wechat/image/' . date('Ymd'))->image($_POST['file']);
if (!is_array($res)) return Json::fail($res);
SystemAttachment::attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 5, $res['image_type'], $res['time']);
return Json::successful('上传成功!', ['url' => $res['dir']]);
}
/**
* 添加和修改图文
*/
public function add_new(){
public function add_new()
{
$data = Util::postMore([
['id',0],
['cid',[]],
['id', 0],
['cid', []],
'title',
'author',
'image_input',
@ -119,47 +111,47 @@ class Article extends AuthController
'synopsis',
'share_title',
'share_synopsis',
['visit',0],
['sort',0],
['visit', 0],
['sort', 0],
'url',
['is_banner',0],
['is_hot',0],
['status',1],]);
$data['cid'] = implode(',',$data['cid']);
['is_banner', 0],
['is_hot', 0],
['status', 1],]);
$data['cid'] = implode(',', $data['cid']);
$content = $data['content'];
unset($data['content']);
if($data['id']){
if ($data['id']) {
$id = $data['id'];
unset($data['id']);
$res = false;
ArticleModel::beginTrans();
$res1 = ArticleModel::edit($data,$id,'id');
$res2 = ArticleModel::setContent($id,$content);
if($res1 && $res2){
$res1 = ArticleModel::edit($data, $id, 'id');
$res2 = ArticleModel::setContent($id, $content);
if ($res1 && $res2) {
$res = true;
}
ArticleModel::checkTrans($res);
if($res)
return Json::successful('修改图文成功!',$id);
if ($res)
return Json::successful('修改图文成功!', $id);
else
return Json::fail('修改图文失败,您并没有修改什么!',$id);
}else{
return Json::fail('修改图文失败,您并没有修改什么!', $id);
} else {
$data['add_time'] = time();
$data['admin_id'] = $this->adminId;
$res = false;
ArticleModel::beginTrans();
$res1 = ArticleModel::create($data);
$res2 = false;
if($res1)
$res2 = ArticleModel::setContent($res1->id,$content);
if($res1 && $res2){
if ($res1)
$res2 = ArticleModel::setContent($res1->id, $content);
if ($res1 && $res2) {
$res = true;
}
ArticleModel::checkTrans($res);
if($res)
return Json::successful('添加图文成功!',$res1->id);
if ($res)
return Json::successful('添加图文成功!', $res1->id);
else
return Json::successful('添加图文失败!',$res1->id);
return Json::successful('添加图文失败!', $res1->id);
}
}
@ -171,17 +163,18 @@ class Article extends AuthController
public function delete($id)
{
$res = ArticleModel::del($id);
if(!$res)
if (!$res)
return Json::fail('删除失败,请稍候再试!');
else
return Json::successful('删除成功!');
}
public function merchantIndex(){
public function merchantIndex()
{
$where = Util::getMore([
['title','']
],$this->request);
$this->assign('where',$where);
['title', '']
], $this->request);
$this->assign('where', $where);
$where['cid'] = input('cid');
$where['merchant'] = 1;//区分是管理员添加的图文显示 0 还是 商户添加的图文显示 1
$this->assign(ArticleModel::getAll($where));
@ -194,7 +187,7 @@ class Article extends AuthController
*/
public function relation($id = 0)
{
$this->assign('id',$id);
$this->assign('id', $id);
return $this->fetch();
}
@ -204,23 +197,24 @@ class Article extends AuthController
*/
public function edit_article($id = 0)
{
if(!$id) return Json::fail('缺少参数');
if (!$id) return Json::fail('缺少参数');
list($product_id) = Util::postMore([
['product_id',0]
],$this->request,true);
if(ArticleModel::edit(['product_id'=>$product_id],['id'=>$id]))
['product_id', 0]
], $this->request, true);
if (ArticleModel::edit(['product_id' => $product_id], ['id' => $id]))
return Json::successful('保存成功');
else
return Json::fail('保存失败');
}
/**
* 取消绑定的产品id
* @param int $id
*/
public function unrelation($id = 0)
{
if(!$id) return Json::fail('缺少参数');
if(ArticleModel::edit(['product_id'=>0],$id))
if (!$id) return Json::fail('缺少参数');
if (ArticleModel::edit(['product_id' => 0], $id))
return Json::successful('取消关联成功!');
else
return Json::fail('取消失败');

View File

@ -15,6 +15,7 @@ use app\models\routine\RoutineTemplate;
use app\models\store\StoreOrderCartInfo;
use app\models\user\User;
use crmeb\services\YLYService;
use think\facade\Log;
use think\facade\Route;
/** 消息通知静态类

View File

@ -1,26 +0,0 @@
<?php
/**
* Created by CRMEB.
* User: 136327134@qq.com
* Date: 2019/4/12 11:19
*/
namespace crmeb\services;
/**
* 错误码统一存放类
* Class ApiErrorCode
* @package crmeb\services
*/
class ApiErrorCode
{
const SUCCESS = [200,'SUCCESS'];
const ERROR = [400,'操作失败'];
const ERR_LOGIN = [40010,'登陆过期'];
}

View File

@ -1,112 +0,0 @@
<?php
/**
* Created by CRMEB.
* User: 136327134@qq.com
* Date: 2019/4/12 11:19
*/
namespace crmeb\services;
/*
* Api 日志和系统字段整合
* class ApiLogs
* */
use think\Exception;
use think\Log;
class ApiLogs
{
// +----------------------------------------------------------------------
// | 缓存前缀配置区域
// +----------------------------------------------------------------------
//ACCESS_TOKEN缓存前缀
const ACCESS_TOKEN_PREFIX='AccessToken:';
//api info 缓存前缀
const AB_API_INFO='eb_ApiInfo:';
//未支付订单取消
const ORDER_UNPAID_PAGE='order_unpaid_page';
// +----------------------------------------------------------------------
// | 缓存时间配置区域
// +----------------------------------------------------------------------
//缓存时间
const EXPIRE=86400;
// +----------------------------------------------------------------------
// | 系统预设字段明配置区域
// +----------------------------------------------------------------------
//access-token验证字段
const ACCESS_TOKEN="access-token";
//Api版本字段
const API_VERSION='version';
//用户token验证字段
const USER_TOKEN='user-token';
//系统预设日志
protected static $logInfo=null;
/*
* 获取本类所有常量配置
* @param string $code 常量名
* @return array | string
* */
public static function getConstants($code='') {
$oClass = new \ReflectionClass(__CLASS__);
$stants=$oClass->getConstants();
if($code) return isset($stants[$code]) ? $stants[$code] : '';
else return $stants;
}
/*
* 错误日志记录
*
* */
public static function recodeErrorLog(Exception $exception)
{
$data=[
'code'=>$exception->getCode(),
'msg'=>$exception->getMessage(),
'file'=>$exception->getFile(),
'line'=>$exception->getLine(),
];
$log="[{$data['code']}] {$data['msg']} [{$data['file']} : {$data['line']}]";
self::writeLog($log,'e');
}
/*
* 记录日志
* $param string $contentlog 日志内容
* $param string $typeLog 日志类型
* $param string $dirLog 日志目录
* */
public static function writeLog($contentlog='',$typeLog='',$dirLog='ebapi')
{
Log::init([
'type' => 'File',
'path' => LOG_PATH.($dirLog ? $dirLog.'/' : '')
]);
if($contentlog==='') $contentlog=self::$logInfo;
if($contentlog===null) return false;
if(is_array($contentlog)) $contentlog=var_export($contentlog,true);
if(is_object($contentlog)) $contentlog=var_export($contentlog,true);
switch (strtoupper($typeLog)){
case 'SQL':case 'S':
Log::sql($contentlog);
break;
case 'ERROR':case 'E':
Log::error($contentlog);
break;
case 'INFO':case 'I':
Log::info($contentlog);
break;
case 'NOTICE':case 'N':
Log::notice($contentlog);
break;
case 'ALERT':case 'A':
Log::alert($contentlog);
break;
case 'LOG':case 'L':
Log::log($contentlog);
break;
}
}
}

View File

@ -1,85 +0,0 @@
<?php
namespace crmeb\services;
use app\models\store\StoreBargain;
use app\models\store\StoreCart;
use app\models\store\StoreCombination;
use app\models\store\StoreProduct;
use app\models\store\StoreSeckill;
use app\models\store\StoreService;
use app\models\user\WechatUser;
use think\facade\Log;
/**
* 客服消息推送
* Class CustomerService
* @package crmeb\services
*/
class CustomerService
{
/**
* 订单支付成功后给客服发送客服消息
* @param $order
* @param int $type 1 公众号 0 小程序
* @return string
*/
public static function sendOrderPaySuccessCustomerService($order, $type = 0)
{
$serviceOrderNotice = StoreService::getStoreServiceOrderNotice();
if (count($serviceOrderNotice)) {
foreach ($serviceOrderNotice as $key => &$item) {
$userInfo = WechatUser::get($item);
if ($userInfo) {
$userInfo = $userInfo->toArray();
if ($userInfo['subscribe'] && $userInfo['openid']) {
$orderStatus = StoreService::orderServiceStatus($userInfo['uid']);
if ($orderStatus) {
// 统计管理开启 推送图文消息
$head = '订单提醒 订单号:' . $order['order_id'];
$url = SystemConfigService::get('site_url') . '/customer/orderdetail/' . $order['order_id'];
$description = '';
$image = SystemConfigService::get('site_logo');
if (isset($order['seckill_id']) && $order['seckill_id'] > 0) {
$description .= '秒杀产品:' . StoreSeckill::getProductField($order['seckill_id'], 'title');
$image = StoreSeckill::getProductField($order['seckill_id'], 'image');
} else if (isset($order['combination_id']) && $order['combination_id'] > 0) {
$description .= '拼团产品:' . StoreCombination::getCombinationField($order['combination_id'], 'title');
$image = StoreCombination::getCombinationField($order['combination_id'], 'image');
} else if (isset($order['bargain_id']) && $order['bargain_id'] > 0) {
$description .= '砍价产品:' . StoreBargain::getBargainField($order['bargain_id'], 'title');
$image = StoreBargain::getBargainField($order['bargain_id'], 'image');
} else {
$productIds = StoreCart::getCartIdsProduct((array)$order['cart_id']);
$storeProduct = StoreProduct::getProductStoreNameOrImage($productIds);
if (count($storeProduct)) {
foreach ($storeProduct as $value) {
$description .= $value['store_name'] . ' ';
$image = $value['image'];
}
}
}
$message = WechatService::newsMessage($head, $description, $url, $image);
try {
WechatService::staffService()->message($message)->to($userInfo['openid'])->send();
} catch (\Exception $e) {
Log::error($userInfo['nickname'] . '发送失败' . $e->getMessage());
}
} else {
// 推送文字消息
$head = "客服提醒:亲,您有一个新订单 \r\n订单单号:{$order['order_id']}\r\n支付金额:¥{$order['pay_price']}\r\n备注信息:{$order['mark']}\r\n订单来源:小程序";
if ($type) $head = "客服提醒:亲,您有一个新订单 \r\n订单单号:{$order['order_id']}\r\n支付金额:¥{$order['pay_price']}\r\n备注信息:{$order['mark']}\r\n订单来源:公众号";
try {
WechatService::staffService()->message($head)->to($userInfo['openid'])->send();
} catch (\Exception $e) {
Log::error($userInfo['nickname'] . '发送失败' . $e->getMessage());
}
}
}
}
}
}
}
}

View File

@ -1,58 +0,0 @@
<?php
/**
*
* @author: xaboy<365615158@qq.com>
* @day: 2018/01/23
*/
namespace crmeb\services;
class ExportService
{
public static function exportCsv($list,$filename,$header = [],$br = '_'){
$tableStr = count($header) > 0 ? '"'.implode('","',$header).'"'.PHP_EOL : '';
$tableStr .= self::tidyCsvStr($list,str_repeat($br,99));
ob_end_clean();
ob_start();
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=".$filename.".csv");
header('Content-Type:application/download');
exit(iconv('UTF-8',"GB2312//IGNORE",$tableStr));
}
private static function tidyCsvStr($list,$br = '')
{
$tableStr = '';
foreach ($list as $row){
if(is_array($row)){
$max = 1;
foreach ($row as $k=>$item){
if(is_array($item)){
if($max < ($l = count($item))) $max = $l;
} else
$row[$k] = [$item];
}
for($i = 0; $i<=$max; $i++){
$exportRow = [];
if($max == $i){
if($br == '')
continue;
else
$exportRow = array_fill(0,count($row),$br);
}else{
foreach ($row as $item){
$exportRow[] = isset($item[$i]) && !empty($item[$i]) ? $item[$i] : ' ';
}
}
$tableStr .= '"'.implode('","',$exportRow).'"," "'.PHP_EOL;
}
$tableStr = rtrim($tableStr,PHP_EOL);
}else{
$tableStr .= implode('',['"',$row,'"',',']);
}
$tableStr .= PHP_EOL;
}
return $tableStr;
}
}

View File

@ -1,94 +0,0 @@
<?php
/**
*
* @author: xaboy<365615158@qq.com>
* @day: 2017/11/24
*/
namespace crmeb\services;
class HookService
{
/**
* 监听有返回结果的行为
* @param $tag
* @param $params
* @param null $extra
* @param bool $once
* @return mixed
*/
public static function resultListen($tag, $params, $extra = null, $once = false,$behavior = null)
{
self::beforeListen($tag,$params,$extra,false,$behavior);
return self::listen($tag,$params,$extra,$once,$behavior);
}
/**
* 监听后置行为
* @param $tag
* @param $params
* @param null $extra
*/
public static function afterListen($tag, $params, $extra = null, $once = false, $behavior = null)
{
try{
return self::listen($tag.'_after',$params,$extra,$once,$behavior);
}catch (\Exception $e){}
}
public static function beforeListen($tag,$params,$extra = null, $once = false, $behavior = null)
{
try{
return self::listen($tag.'_before',$params,$extra,$once,$behavior);
}catch (\Exception $e){}
}
/**
* 监听行为
* @param $tag
* @param $params
* @param null $extra
* @param bool $once
* @return mixed
*/
public static function listen($tag, $params, $extra = null, $once = false, $behavior = null)
{
// if($behavior && method_exists($behavior,Loader::parseName($tag,1,false))) self::add($tag,$behavior);
// return Hook::listen($tag,$params,$extra,$once);
}
/**
* 添加前置行为
* @param $tag
* @param $behavior
* @param bool $first
*/
public static function addBefore($tag, $behavior, $first = false)
{
self::add($tag.'_before',$behavior,$first);
}
/**
* 添加后置行为
* @param $tag
* @param $behavior
* @param bool $first
*/
public static function addAfter($tag, $behavior, $first = false)
{
self::add($tag.'_after',$behavior,$first);
}
/**
* 添加行为
* @param $tag
* @param $behavior
* @param bool $first
*/
public static function add($tag, $behavior, $first = false)
{
Hook::add($tag,$behavior,$first);
}
}

View File

@ -1,104 +0,0 @@
<?php
namespace crmeb\services;
/**
* @name PHPTree
* @author crazymus < QQ:291445576 >
* @des PHP生成树形结构,无限多级分类
* @version 1.2.0
* @Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
* @updated 2015-08-26
*/
class PHPTreeService
{
protected static $config = array(
/* 主键 */
'primary_key' => 'id',
/* 父键 */
'parent_key' => 'pid',
/* 展开属性 */
'expanded_key' => 'expanded',
/* 叶子节点属性 */
'leaf_key' => 'leaf',
/* 孩子节点属性 */
'children_key' => 'children',
/* 是否展开子节点 */
'expanded' => false
);
/* 结果集 */
protected static $result = array();
/* 层次暂存 */
protected static $level = array();
/**
* @name 生成树形结构
* @param array 二维数组
* @return mixed 多维数组
*/
public static function makeTree($data, $options = array())
{
$dataset = self::buildData($data, $options);
$r = self::makeTreeCore(0, $dataset, 'normal');
return $r;
}
/* 生成线性结构, 便于HTML输出, 参数同上 */
public static function makeTreeForHtml($data, $options = array())
{
$dataset = self::buildData($data, $options);
$r = self::makeTreeCore(0, $dataset, 'linear');
return $r;
}
/* 格式化数据, 私有方法 */
private static function buildData($data, $options)
{
$config = array_merge(self::$config, $options);
self::$config = $config;
extract($config);
$r = array();
foreach ($data as $item) {
$id = $item[$primary_key];
$parent_id = $item[$parent_key];
$r[$parent_id][$id] = $item;
}
return $r;
}
/* 生成树核心, 私有方法 */
private static function makeTreeCore($index, $data, $type = 'linear')
{
extract(self::$config);
foreach ($data[$index] as $id => $item) {
if ($type == 'normal') {
if (isset($data[$id])) {
$item[$expanded_key] = self::$config['expanded'];
$item[$children_key] = self::makeTreeCore($id, $data, $type);
} else {
$item[$leaf_key] = true;
}
$r[] = $item;
} else if ($type == 'linear') {
$parent_id = $item[$parent_key];
self::$level[$id] = $index == 0 ? 0 : self::$level[$parent_id] + 1;
$item['level'] = self::$level[$id];
self::$result[] = $item;
if (isset($data[$id])) {
self::makeTreeCore($id, $data, $type);
}
$r = self::$result;
}
}
return $r;
}
}
?>

View File

@ -1,25 +0,0 @@
<?php
/**
* Created by CRMEB.
* Copyright (c) 2017~2019 http://www.crmeb.com All rights reserved.
* Author: liaofei <136327134@qq.com>
* Date: 2019/4/3 16:36
*/
namespace crmeb\services;
use crmeb\traits\LogicTrait;
/** 模版消息类
* Class Template
* @package crmeb\services
*/
class Template
{
use LogicTrait;
protected $providers=[
'routine_two'=>ProgramTemplateService::class,
];
}