diff --git a/application/admin/common.php b/application/admin/common.php
index 90f292c1..3c137dcf 100644
--- a/application/admin/common.php
+++ b/application/admin/common.php
@@ -10,50 +10,7 @@
// +----------------------------------------------------------------------
// 应用公共文件
-/**
- * 获取用户名称
- * @param $uid
- * @return mixed
- */
-function getUserNickname($uid){
- return \app\admin\model\user\User::where('uid',$uid)->value('nickname');
-}
-/**
- * 获取产品名称
- * @param $id
- * @return mixed
- */
-function getProductName($id){
- return \app\admin\model\store\StoreProduct::where('id',$id)->value('store_name');
-}
-
-/**
- * 获取拼团名称
- * @param $id
- * @return mixed
- */
-function getCombinationTitle($id){
- return \app\admin\model\store\StoreCombination::where('id',$id)->value('title');
-}
-
-/**
- * 获取订单编号
- * @param $id
- */
-function getOrderId($id){
- return \app\admin\model\order\StoreOrder::where('id',$id)->value('order_id');
-}
-
-
-/**
- * 根据用户uid获取订单数
- * @param $uid
- * @return int|string
- */
-function getOrderCount($uid){
- return \app\admin\model\order\StoreOrder::where('uid',$uid)->where('paid',1)->where('refund_status',0)->where('status',2)->count();
-}
/**
* 格式化属性
* @param $arr
@@ -98,6 +55,12 @@ function attrFormat($arr){
return [$data,$res];
}
+/**
+ * 格式化月份
+ * @param string $time
+ * @param int $ceil
+ * @return array
+ */
function getMonth($time='',$ceil=0){
if(empty($time)){
$firstday = date("Y-m-01",time());
@@ -118,3 +81,24 @@ function getMonth($time='',$ceil=0){
}
return array($firstday,$lastday);
}
+/**删除目录下所有文件
+ * @param $path 目录或者文件路径
+ * @param string $ext
+ * @return bool
+ */
+function clearfile($path,$ext = '*.log')
+{
+ $files = (array) glob($path.DS.'*');
+ foreach ($files as $path) {
+ if (is_dir($path)) {
+ $matches = glob($path . '/'.$ext);
+ if (is_array($matches)) {
+ array_map('unlink', $matches);
+ }
+ rmdir($path);
+ } else {
+ unlink($path);
+ }
+ }
+ return true;
+}
diff --git a/application/admin/controller/agent/AgentManage.php b/application/admin/controller/agent/AgentManage.php
index 39a6ba02..4b205292 100644
--- a/application/admin/controller/agent/AgentManage.php
+++ b/application/admin/controller/agent/AgentManage.php
@@ -3,6 +3,7 @@
namespace app\admin\controller\agent;
use app\admin\controller\AuthController;
+use app\admin\model\order\StoreOrder;
use app\admin\model\user\User;
use app\admin\model\wechat\WechatUser as UserModel;
use app\admin\library\FormBuilder;
@@ -74,6 +75,7 @@ class AgentManage extends AuthController
->order('u.add_time DESC')
->select()
->toArray();
+ foreach ($list as $key=>$value) $list[$key]['orderCount'] = StoreOrder::getOrderCount($value['uid']);
$this->assign('list',$list);
return $this->fetch();
}
diff --git a/application/admin/controller/article/Article.php b/application/admin/controller/article/Article.php
index c14c6898..49051bde 100644
--- a/application/admin/controller/article/Article.php
+++ b/application/admin/controller/article/Article.php
@@ -4,6 +4,7 @@ namespace app\admin\controller\article;
use app\admin\controller\AuthController;
use service\UtilService as Util;
+use service\PHPTreeService as Phptree;
use service\JsonService as Json;
use service\UploadService as Upload;
use think\Request;
@@ -22,18 +23,24 @@ class Article extends AuthController
* 显示后台管理员添加的图文
* @return mixed
*/
- public function index($cid = 0)
+ public function index($pid = 0)
{
$where = Util::getMore([
- ['title','']
+ ['title',''],
+ ['cid','']
],$this->request);
- if($cid)
- $where['cid'] = $cid;
- else
- $where['cid'] = '';
+ $pid = $this->request->param('pid');
$this->assign('where',$where);
$where['merchant'] = 0;//区分是管理员添加的图文显示 0 还是 商户添加的图文显示 1
- $this->assign('cid',$cid);
+ $catlist = ArticleCategoryModel::where('is_del',0)->select()->toArray();
+ //获取分类列表
+ $tree = Phptree::makeTreeForHtml($catlist);
+ $this->assign(compact('tree'));
+ if($pid){
+ $pids = Util::getChildrenPid($tree,$pid);
+ $where['cid'] = ltrim($pid.$pids);
+ }
+
$this->assign('cate',ArticleCategoryModel::getTierList());
$this->assign(ArticleModel::getAll($where));
return $this->fetch();
@@ -121,8 +128,6 @@ class Article extends AuthController
'synopsis',
'share_title',
'share_synopsis',
- 'is_banner',
- 'is_hot',
['visit',0],
['sort',0],
'url',
diff --git a/application/admin/controller/wechat/WechatUser.php b/application/admin/controller/wechat/WechatUser.php
index 59b3bd2a..bc1a1df3 100644
--- a/application/admin/controller/wechat/WechatUser.php
+++ b/application/admin/controller/wechat/WechatUser.php
@@ -1 +1 @@
-request);
$tagidList = explode(',',$where['tagid_list']);
foreach ($tagidList as $k=>$v){
if(!$v){
unset($tagidList[$k]);
}
}
$tagidList = array_unique($tagidList);
$where['tagid_list'] = implode(',',$tagidList);
$this->assign([
'where'=>$where,
'groupList'=>UserModel::getUserGroup(),
'tagList'=>UserModel::getUserTag()
]);
$limitTimeList = [
'today'=>implode(' - ',[date('Y/m/d'),date('Y/m/d',strtotime('+1 day'))]),
'week'=>implode(' - ',[
date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)),
date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600))
]),
'month'=>implode(' - ',[date('Y/m').'/01',date('Y/m').'/'.date('t')]),
'quarter'=>implode(' - ',[
date('Y').'/'.(ceil((date('n'))/3)*3-3+1).'/01',
date('Y').'/'.(ceil((date('n'))/3)*3).'/'.date('t',mktime(0,0,0,(ceil((date('n'))/3)*3),1,date('Y')))
]),
'year'=>implode(' - ',[
date('Y').'/01/01',date('Y/m/d',strtotime(date('Y').'/01/01 + 1year -1 day'))
])
];
$uidAll = UserModel::getAll($where);
$this->assign(compact('limitTimeList','uidAll'));
$this->assign(UserModel::systemPage($where,true));
return $this->fetch();
}
public function edit_user_tag($openid)
{
if(!$openid) return JsonService::fail('参数错误!');
$list = Collection::make(UserModel::getUserTag())->each(function($item){
return ['value'=>$item['id'],'label'=>$item['name']];
});
$tagList = UserModel::where('openid',$openid)->value('tagid_list');
$tagList = explode(',',$tagList)?:[];
$f = [Form::select('tag_id','用户标签',$tagList)->setOptions($list->toArray())->multiple(1)];
$form = Form::make_post_form('标签名称',$f,Url::build('update_user_tag',compact('openid')));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
public function update_user_tag(Request $request,$openid)
{
if(!$openid) return JsonService::fail('参数错误!');
$tagId = $request->post('tag_id/a',[]);
if(!$tagId) return JsonService::fail('请选择用户标签!');
$tagList = explode(',',UserModel::where('openid',$openid)->value('tagid_list'))?:[];
UserModel::beginTrans();
if(!$tagId[0])unset($tagId[0]);
UserModel::edit(['tagid_list'=>$tagId],$openid,'openid');
try{
foreach ($tagList as $tag){
if($tag) WechatService::userTagService()->batchUntagUsers([$openid],$tag);
}
foreach ($tagId as $tag){
WechatService::userTagService()->batchTagUsers([$openid],$tag);
}
}catch (\Exception $e){
UserModel::rollbackTrans();
return JsonService::fail($e->getMessage());
}
UserModel::commitTrans();
return JsonService::successful('修改成功!');
}
public function edit_user_group($openid)
{
if(!$openid) return JsonService::fail('参数错误!');
$list = Collection::make(UserModel::getUserGroup())->each(function($item){
return ['value'=>$item['id'],'label'=>$item['name']];
});
$groupId = UserModel::where('openid',$openid)->value('groupid');
$f = [Form::select('tag_id','用户标签',(string)$groupId)->setOptions($list->toArray())];
$form = Form::make_post_form('标签名称',$f,Url::build('update_user_group',compact('openid')));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
public function update_user_group(Request $request,$openid)
{
if(!$openid) return JsonService::fail('参数错误!');
$groupId = $request->post('group_id');
if(!$groupId) return JsonService::fail('请选择用户分组!');
UserModel::beginTrans();
UserModel::edit(['groupid'=>$groupId],$openid,'openid');
try{
WechatService::userGroupService()->moveUser($openid,$groupId);
}catch (\Exception $e){
UserModel::rollbackTrans();
return JsonService::fail($e->getMessage());
}
UserModel::commitTrans();
return JsonService::successful('修改成功!');
}
/**
* 用户标签列表
*/
public function tag($refresh = 0)
{
if($refresh == 1) {
UserModel::clearUserTag();
$this->redirect(Url::build('tag'));
}
$list = UserModel::getUserTag();
$this->assign(compact('list'));
return $this->fetch();
}
/**
* 添加标签
* @return mixed
*/
public function create_tag()
{
$f = [Form::input('name','标签名称')];
$form = Form::make_post_form('标签名称',$f,Url::build('save_tag'));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 添加
* @param Request $request
* @return \think\response\Json
*/
public function save_tag(Request $request)
{
$tagName = $request->post('name');
if(!$tagName) return JsonService::fail('请输入标签名称!');
try{
WechatService::userTagService()->create($tagName);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserTag();
return JsonService::successful('添加标签成功!');
}
/**
* 修改标签
* @param $id
* @return mixed
*/
public function edit_tag($id)
{
$f = [Form::input('name','标签名称')];
$form = Form::make_post_form('标签名称',$f,Url::build('update_tag',['id'=>$id]));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 修改标签
* @param Request $request
* @param $id
* @return \think\response\Json
*/
public function update_tag(Request $request, $id)
{
$tagName = $request->post('name');
if(!$tagName) return JsonService::fail('请输入标签名称!');
try{
WechatService::userTagService()->update($id,$tagName);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserTag();
return JsonService::successful('修改标签成功!');
}
/**
* 删除标签
* @param $id
* @return \think\response\Json
*/
public function delete_tag($id)
{
try{
WechatService::userTagService()->delete($id);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserTag();
return JsonService::successful('删除标签成功!');
}
/**
* 用户分组列表
*/
public function group($refresh = 0)
{
if($refresh == 1) {
UserModel::clearUserGroup();
$this->redirect(Url::build('group'));
}
$list = UserModel::getUserGroup();
$this->assign(compact('list'));
return $this->fetch();
}
/**
* 添加分组
* @return mixed
*/
public function create_group()
{
$f = [Form::input('name','分组名称')];
$form = Form::make_post_form('标签名称',$f,Url::build('save_group'));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 添加
* @param Request $request
* @return \think\response\Json
*/
public function save_group(Request $request)
{
$tagName = $request->post('name');
if(!$tagName) return JsonService::fail('请输入分组名称!');
try{
WechatService::userGroupService()->create($tagName);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserGroup();
return JsonService::successful('添加分组成功!');
}
/**
* 修改分组
* @param $id
* @return mixed
*/
public function edit_group($id)
{
$f = [Form::input('name','分组名称')];
$form = Form::make_post_form('标签名称',$f,Url::build('update_group',compact('id')));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 修改分组
* @param Request $request
* @param $id
* @return \think\response\Json
*/
public function update_group(Request $request, $id)
{
$tagName = $request->post('name');
if(!$tagName) return JsonService::fail('请输入分组名称!');
try{
WechatService::userGroupService()->update($id,$tagName);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserGroup();
return JsonService::successful('修改分组成功!');
}
/**
* 删除分组
* @param $id
* @return \think\response\Json
*/
public function delete_group($id)
{
try{
WechatService::userTagService()->delete($id);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserGroup();
return JsonService::successful('删除分组成功!');
}
public function synchro_tag($openid){
if(!$openid) return JsonService::fail('参数错误!');
$data = array();
if(UserModel::be($openid,'openid')){
try{
$tag = WechatService::userTagService()->userTags($openid)->toArray();
}catch (\Exception $e) {
return JsonService::fail($e->getMessage());
}
if($tag['tagid_list']) $data['tagid_list'] = implode(',',$tag['tagid_list']);
else $data['tagid_list'] = '';
$res = UserModel::edit($data,$openid,'openid');
if($res) return JsonService::successful('同步成功');
else return JsonService::fail('同步失败!');
}else return JsonService::fail('参数错误!');
}
/**
* 一级推荐人页面
* @return mixed
*/
public function stair($uid = ''){
if($uid == '') return $this->failed('参数错误');
$list = User::alias('u')
->where('u.spread_uid',$uid)
->field('u.avatar,u.nickname,u.now_money,u.add_time,u.uid')
->where('u.status',1)
->order('u.add_time DESC')
->select()
->toArray();
$this->assign('list',$list);
return $this->fetch();
}
/**
* 个人资金详情页面
* @return mixed
*/
public function now_money($uid = ''){
if($uid == '') return $this->failed('参数错误');
$list = UserBill::where('uid',$uid)->where('category','now_money')
->field('mark,pm,number,add_time')
->where('status',1)->order('add_time DESC')->select()->toArray();
foreach ($list as &$v){
$v['add_time'] = date('Y-m-d H:i:s',$v['add_time']);
}
$this->assign('list',$list);
return $this->fetch();
}
}
\ No newline at end of file
+request);
$tagidList = explode(',',$where['tagid_list']);
foreach ($tagidList as $k=>$v){
if(!$v){
unset($tagidList[$k]);
}
}
$tagidList = array_unique($tagidList);
$where['tagid_list'] = implode(',',$tagidList);
$this->assign([
'where'=>$where,
'groupList'=>UserModel::getUserGroup(),
'tagList'=>UserModel::getUserTag()
]);
$limitTimeList = [
'today'=>implode(' - ',[date('Y/m/d'),date('Y/m/d',strtotime('+1 day'))]),
'week'=>implode(' - ',[
date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)),
date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600))
]),
'month'=>implode(' - ',[date('Y/m').'/01',date('Y/m').'/'.date('t')]),
'quarter'=>implode(' - ',[
date('Y').'/'.(ceil((date('n'))/3)*3-3+1).'/01',
date('Y').'/'.(ceil((date('n'))/3)*3).'/'.date('t',mktime(0,0,0,(ceil((date('n'))/3)*3),1,date('Y')))
]),
'year'=>implode(' - ',[
date('Y').'/01/01',date('Y/m/d',strtotime(date('Y').'/01/01 + 1year -1 day'))
])
];
$uidAll = UserModel::getAll($where);
$this->assign(compact('limitTimeList','uidAll'));
$this->assign(UserModel::systemPage($where));
return $this->fetch();
}
public function edit_user_tag($openid)
{
if(!$openid) return JsonService::fail('参数错误!');
$list = Collection::make(UserModel::getUserTag())->each(function($item){
return ['value'=>$item['id'],'label'=>$item['name']];
});
$tagList = UserModel::where('openid',$openid)->value('tagid_list');
$tagList = explode(',',$tagList)?:[];
$f = [Form::select('tag_id','用户标签',$tagList)->setOptions($list->toArray())->multiple(1)];
$form = Form::make_post_form('标签名称',$f,Url::build('update_user_tag',compact('openid')));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
public function update_user_tag(Request $request,$openid)
{
if(!$openid) return JsonService::fail('参数错误!');
$tagId = $request->post('tag_id/a',[]);
if(!$tagId) return JsonService::fail('请选择用户标签!');
$tagList = explode(',',UserModel::where('openid',$openid)->value('tagid_list'))?:[];
UserModel::beginTrans();
if(!$tagId[0])unset($tagId[0]);
UserModel::edit(['tagid_list'=>$tagId],$openid,'openid');
try{
foreach ($tagList as $tag){
if($tag) WechatService::userTagService()->batchUntagUsers([$openid],$tag);
}
foreach ($tagId as $tag){
WechatService::userTagService()->batchTagUsers([$openid],$tag);
}
}catch (\Exception $e){
UserModel::rollbackTrans();
return JsonService::fail($e->getMessage());
}
UserModel::commitTrans();
return JsonService::successful('修改成功!');
}
public function edit_user_group($openid)
{
if(!$openid) return JsonService::fail('参数错误!');
$list = Collection::make(UserModel::getUserGroup())->each(function($item){
return ['value'=>$item['id'],'label'=>$item['name']];
});
$groupId = UserModel::where('openid',$openid)->value('groupid');
$f = [Form::select('tag_id','用户标签',(string)$groupId)->setOptions($list->toArray())];
$form = Form::make_post_form('标签名称',$f,Url::build('update_user_group',compact('openid')));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
public function update_user_group(Request $request,$openid)
{
if(!$openid) return JsonService::fail('参数错误!');
$groupId = $request->post('group_id');
if(!$groupId) return JsonService::fail('请选择用户分组!');
UserModel::beginTrans();
UserModel::edit(['groupid'=>$groupId],$openid,'openid');
try{
WechatService::userGroupService()->moveUser($openid,$groupId);
}catch (\Exception $e){
UserModel::rollbackTrans();
return JsonService::fail($e->getMessage());
}
UserModel::commitTrans();
return JsonService::successful('修改成功!');
}
/**
* 用户标签列表
*/
public function tag($refresh = 0)
{
if($refresh == 1) {
UserModel::clearUserTag();
$this->redirect(Url::build('tag'));
}
$list = UserModel::getUserTag();
$this->assign(compact('list'));
return $this->fetch();
}
/**
* 添加标签
* @return mixed
*/
public function create_tag()
{
$f = [Form::input('name','标签名称')];
$form = Form::make_post_form('标签名称',$f,Url::build('save_tag'));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 添加
* @param Request $request
* @return \think\response\Json
*/
public function save_tag(Request $request)
{
$tagName = $request->post('name');
if(!$tagName) return JsonService::fail('请输入标签名称!');
try{
WechatService::userTagService()->create($tagName);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserTag();
return JsonService::successful('添加标签成功!');
}
/**
* 修改标签
* @param $id
* @return mixed
*/
public function edit_tag($id)
{
$f = [Form::input('name','标签名称')];
$form = Form::make_post_form('标签名称',$f,Url::build('update_tag',['id'=>$id]));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 修改标签
* @param Request $request
* @param $id
* @return \think\response\Json
*/
public function update_tag(Request $request, $id)
{
$tagName = $request->post('name');
if(!$tagName) return JsonService::fail('请输入标签名称!');
try{
WechatService::userTagService()->update($id,$tagName);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserTag();
return JsonService::successful('修改标签成功!');
}
/**
* 删除标签
* @param $id
* @return \think\response\Json
*/
public function delete_tag($id)
{
try{
WechatService::userTagService()->delete($id);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserTag();
return JsonService::successful('删除标签成功!');
}
/**
* 用户分组列表
*/
public function group($refresh = 0)
{
if($refresh == 1) {
UserModel::clearUserGroup();
$this->redirect(Url::build('group'));
}
$list = UserModel::getUserGroup();
$this->assign(compact('list'));
return $this->fetch();
}
/**
* 添加分组
* @return mixed
*/
public function create_group()
{
$f = [Form::input('name','分组名称')];
$form = Form::make_post_form('标签名称',$f,Url::build('save_group'));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 添加
* @param Request $request
* @return \think\response\Json
*/
public function save_group(Request $request)
{
$tagName = $request->post('name');
if(!$tagName) return JsonService::fail('请输入分组名称!');
try{
WechatService::userGroupService()->create($tagName);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserGroup();
return JsonService::successful('添加分组成功!');
}
/**
* 修改分组
* @param $id
* @return mixed
*/
public function edit_group($id)
{
$f = [Form::input('name','分组名称')];
$form = Form::make_post_form('标签名称',$f,Url::build('update_group',compact('id')));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 修改分组
* @param Request $request
* @param $id
* @return \think\response\Json
*/
public function update_group(Request $request, $id)
{
$tagName = $request->post('name');
if(!$tagName) return JsonService::fail('请输入分组名称!');
try{
WechatService::userGroupService()->update($id,$tagName);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserGroup();
return JsonService::successful('修改分组成功!');
}
/**
* 删除分组
* @param $id
* @return \think\response\Json
*/
public function delete_group($id)
{
try{
WechatService::userTagService()->delete($id);
}catch (\Exception $e){
return JsonService::fail($e->getMessage());
}
UserModel::clearUserGroup();
return JsonService::successful('删除分组成功!');
}
public function synchro_tag($openid){
if(!$openid) return JsonService::fail('参数错误!');
$data = array();
if(UserModel::be($openid,'openid')){
try{
$tag = WechatService::userTagService()->userTags($openid)->toArray();
}catch (\Exception $e) {
return JsonService::fail($e->getMessage());
}
if($tag['tagid_list']) $data['tagid_list'] = implode(',',$tag['tagid_list']);
else $data['tagid_list'] = '';
$res = UserModel::edit($data,$openid,'openid');
if($res) return JsonService::successful('同步成功');
else return JsonService::fail('同步失败!');
}else return JsonService::fail('参数错误!');
}
/**
* 一级推荐人页面
* @return mixed
*/
public function stair($uid = ''){
if($uid == '') return $this->failed('参数错误');
$list = User::alias('u')
->where('u.spread_uid',$uid)
->field('u.avatar,u.nickname,u.now_money,u.add_time,u.uid')
->where('u.status',1)
->order('u.add_time DESC')
->select()
->toArray();
foreach ($list as $key=>$value) $list[$key]['orderCount'] = StoreOrder::getOrderCount($value['uid']);
$this->assign('list',$list);
return $this->fetch();
}
/**
* 个人资金详情页面
* @return mixed
*/
public function now_money($uid = ''){
if($uid == '') return $this->failed('参数错误');
$list = UserBill::where('uid',$uid)->where('category','now_money')
->field('mark,pm,number,add_time')
->where('status',1)->order('add_time DESC')->select()->toArray();
foreach ($list as &$v){
$v['add_time'] = date('Y-m-d H:i:s',$v['add_time']);
}
$this->assign('list',$list);
return $this->fetch();
}
}
\ No newline at end of file
diff --git a/application/admin/model/order/StoreOrder.php b/application/admin/model/order/StoreOrder.php
index d1d53c78..a341e19c 100644
--- a/application/admin/model/order/StoreOrder.php
+++ b/application/admin/model/order/StoreOrder.php
@@ -26,11 +26,168 @@ class StoreOrder extends ModelBasic
{
use ModelTrait;
+ public static function orderCount(){
+ $data['wz']=self::statusByWhere(0,new self())->count();
+ $data['wf']=self::statusByWhere(1,new self())->count();
+ $data['ds']=self::statusByWhere(2,new self())->count();
+ $data['dp']=self::statusByWhere(3,new self())->count();
+ $data['jy']=self::statusByWhere(4,new self())->count();
+ $data['tk']=self::statusByWhere(-1,new self())->count();
+ $data['yt']=self::statusByWhere(-2,new self())->count();
+ $data['general']=self::where(['pink_id'=>0,'combination_id'=>0,'seckill_id'=>0])->count();
+ $data['pink']=self::where('pink_id|combination_id','neq',0)->count();
+ $data['seckill']=self::where('seckill_id','neq',0)->count();
+ return $data;
+ }
+
+ public static function OrderList($where){
+ $model = self::getOrderWhere($where,self::alias('a')->join('user r','r.uid=a.uid','LEFT'),'a.','r')->field('a.*,r.nickname');
+ if($where['order']!=''){
+ $model = $model->order(self::setOrder($where['order']));
+ }else{
+ $model = $model->order('a.id desc');
+ }
+ $data=($data=$model->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
+ foreach ($data as &$item){
+ $_info = db('store_order_cart_info')->where('oid',$item['id'])->field('cart_info')->select();
+ foreach ($_info as $k=>$v){
+ $_info[$k]['cart_info'] = json_decode($v['cart_info'],true);
+ }
+ $item['_info'] = $_info;
+ if($item['pink_id'] && $item['combination_id']){
+ $pinkStatus = StorePink::where('order_id_key',$item['id'])->value('status');
+ switch ($pinkStatus){
+ case 1:
+ $item['pink_name'] = '[拼团订单]正在进行中';
+ $item['color'] = '#f00';
+ break;
+ case 2:
+ $item['pink_name'] = '[拼团订单]已完成';
+ $item['color'] = '#00f';
+ break;
+ case 3:
+ $item['pink_name'] = '[拼团订单]未完成';
+ $item['color'] = '#f0f';
+ break;
+ default:
+ $item['pink_name'] = '[拼团订单]历史订单';
+ $item['color'] = '#457856';
+ break;
+ }
+ }else{
+ if($item['seckill_id']){
+ $item['pink_name'] = '[秒杀订单]';
+ $item['color'] = '#32c5e9';
+ }else{
+ $item['pink_name'] = '[普通订单]';
+ $item['color'] = '#895612';
+ }
+ }
+ if($item['paid']==1){
+ switch ($item['pay_type']){
+ case 'weixin':
+ $item['pay_type_name']='微信支付';
+ break;
+ case 'yue':
+ $item['pay_type_name']='微信支付';
+ break;
+ case 'offline':
+ $item['pay_type_name']='线下支付';
+ break;
+ default:
+ $item['pay_type_name']='其他支付';
+ break;
+ }
+ }else{
+ switch ($item['pay_type']){
+ default:
+ $item['pay_type_name']='未支付';
+ break;
+ case 'offline':
+ $item['pay_type_name']='线下支付';
+ $item['pay_type_info']=1;
+ break;
+ }
+ }
+ if($item['paid']==0 && $item['status']==0){
+ $item['status_name']='未支付';
+ }else if($item['paid']==1 && $item['status']==0 && $item['refund_status']==0){
+ $item['status_name']='未发货';
+ }else if($item['paid']==1 && $item['status']==1 && $item['refund_status']==0){
+ $item['status_name']='待收货';
+ }else if($item['paid']==1 && $item['status']==2 && $item['refund_status']==0){
+ $item['status_name']='待评价';
+ }else if($item['paid']==1 && $item['status']==3 && $item['refund_status']==0){
+ $item['status_name']='待评价';
+ }else if($item['paid']==1 && $item['refund_status']==1){
+ $item['status_name']=<<申请退款
+退款原因:{$item['refund_reason_wap']}
+HTML;
+ }else if($item['paid']==1 && $item['refund_status']==2){
+ $item['status_name']='已退款';
+ }
+ if($item['paid']==0 && $item['status']==0 && $item['refund_status']==0){
+ $item['_status']=1;
+ }else if($item['paid']==1 && $item['status']==0 && $item['refund_status']==0){
+ $item['_status']=2;
+ }else if($item['paid']==1 && $item['refund_status']==1){
+ $item['_status']=3;
+ }else if($item['paid']==1 && $item['status']==1 && $item['refund_status']==0){
+ $item['_status']=4;
+ }else if($item['paid']==1 && $item['status']==2 && $item['refund_status']==0){
+ $item['_status']=5;
+ }else if($item['paid']==1 && $item['status']==3 && $item['refund_status']==0){
+ $item['_status']=6;
+ }else if($item['paid']==1 && $item['refund_status']==2){
+ $item['_status']=7;
+ }
+ }
+ if(isset($where['excel']) && $where['excel']==1){
+ self::SaveExcel($data);
+ }
+ $count=self::getOrderWhere($where,self::alias('a')->join('user r','r.uid=a.uid','LEFT'),'a.','r')->count();
+ return compact('count','data');
+ }
+ /*
+ * 保存并下载excel
+ * $list array
+ * return
+ */
+ public static function SaveExcel($list){
+ $export = [];
+ foreach ($list as $index=>$item){
+ $_info = db('store_order_cart_info')->where('oid',$item['id'])->column('cart_info');
+ $goodsName = [];
+ foreach ($_info as $k=>$v){
+ $v = json_decode($v,true);
+ $goodsName[] = implode(
+ [$v['productInfo']['store_name'],
+ isset($v['productInfo']['attrInfo']) ? '('.$v['productInfo']['attrInfo']['suk'].')' : '',
+ "[{$v['cart_num']} * {$v['truePrice']}]"
+ ],' ');
+ }
+ $item['cartInfo'] = $_info;
+ $export[] = [
+ $item['order_id'],$item['pay_type_name'],
+ $item['total_num'],$item['total_price'],$item['total_postage'],$item['pay_price'],$item['refund_price'],
+ $item['mark'],$item['remark'],
+ [$item['real_name'],$item['user_phone'],$item['user_address']],
+ $goodsName,
+ [$item['paid'] == 1? '已支付':'未支付','支付时间: '.($item['pay_time'] > 0 ? date('Y/md H:i',$item['pay_time']) : '暂无')]
+ ];
+ }
+ PHPExcelService::setExcelHeader(['订单号','支付方式','商品总数','商品总价','邮费','支付金额','退款金额','用户备注','管理员备注','收货人信息','商品信息','支付状态'])
+ ->setExcelTile('订单导出','订单信息'.time(),' 生成时间:'.date('Y-m-d H:i:s',time()))
+ ->setExcelContent($export)
+ ->ExcelSave();
+ }
+
/**
* @param $where
* @return array
*/
- public static function systemPage($where,$userid){
+ public static function systemPage($where,$userid=false){
$model = self::getOrderWhere($where,self::alias('a')->join('user r','r.uid=a.uid','LEFT'),'a.','r')->field('a.*,r.nickname');
if($where['order']){
$model = $model->order('a.'.$where['order']);
@@ -80,7 +237,6 @@ class StoreOrder extends ModelBasic
->ExcelSave();
}
return self::page($model,function ($item){
- $item['nickname'] = WechatUser::where('uid',$item['uid'])->value('nickname');
$_info = db('store_order_cart_info')->where('oid',$item['id'])->field('cart_info')->select();
foreach ($_info as $k=>$v){
$_info[$k]['cart_info'] = json_decode($v['cart_info'],true);
@@ -88,29 +244,32 @@ class StoreOrder extends ModelBasic
$item['_info'] = $_info;
if($item['pink_id'] && $item['combination_id']){
$pinkStatus = StorePink::where('order_id_key',$item['id'])->value('status');
- if($pinkStatus == 1){
- $item['pink_name'] = '[拼团订单]正在进行中';
- $item['color'] = '#f00';
- }else if($pinkStatus == 2){
- $item['pink_name'] = '[拼团订单]已完成';
- $item['color'] = '#00f';
- }else if($pinkStatus == 3){
- $item['pink_name'] = '[拼团订单]未完成';
- $item['color'] = '#f0f';
- }else{
- $item['pink_name'] = '[拼团订单]历史订单';
- $item['color'] = '#457856';
+ switch ($pinkStatus){
+ case 1:
+ $item['pink_name'] = '[拼团订单]正在进行中';
+ $item['color'] = '#f00';
+ break;
+ case 2:
+ $item['pink_name'] = '[拼团订单]已完成';
+ $item['color'] = '#00f';
+ break;
+ case 3:
+ $item['pink_name'] = '[拼团订单]未完成';
+ $item['color'] = '#f0f';
+ break;
+ default:
+ $item['pink_name'] = '[拼团订单]历史订单';
+ $item['color'] = '#457856';
+ break;
}
}else{
- if($item['seckill_id']){
- $item['pink_name'] = '[秒杀订单]';
- $item['color'] = '#32c5e9';
- }else{
- $item['pink_name'] = '[普通订单]';
- $item['color'] = '#895612';
- }
-
-
+ if($item['seckill_id']){
+ $item['pink_name'] = '[秒杀订单]';
+ $item['color'] = '#32c5e9';
+ }else{
+ $item['pink_name'] = '[普通订单]';
+ $item['color'] = '#895612';
+ }
}
},$where);
}
@@ -193,27 +352,107 @@ class StoreOrder extends ModelBasic
// $model = $model->where('combination_id',0);
if($where['status'] != '') $model = self::statusByWhere($where['status'],$model,$aler);
if($where['is_del'] != '' && $where['is_del'] != -1) $model = $model->where($aler.'is_del',$where['is_del']);
- if($where['combination_id'] =='普通订单'){
- $model = $model->where($aler.'combination_id',0)->where($aler.'seckill_id',0);
+ if(isset($where['combination_id'])){
+ if($where['combination_id'] =='普通订单'){
+ $model = $model->where($aler.'combination_id',0)->where($aler.'seckill_id',0);
+ }
+ if($where['combination_id'] =='拼团订单'){
+ $model = $model->where($aler.'combination_id',">",0)->where($aler.'pink_id',">",0);
+ }
+ if($where['combination_id'] =='秒杀订单'){
+ $model = $model->where($aler.'seckill_id',">",0);
+ }
}
- if($where['combination_id'] =='拼团订单'){
- $model = $model->where($aler.'combination_id',">",0)->where($aler.'pink_id',">",0);
- }
- if($where['combination_id'] =='秒杀订单'){
- $model = $model->where($aler.'seckill_id',">",0);
+ if(isset($where['type'])){
+ switch ($where['type']){
+ case 1:
+ $model = $model->where($aler.'combination_id',0)->where($aler.'seckill_id',0);
+ break;
+ case 2:
+ $model = $model->where($aler.'combination_id',">",0)->where($aler.'pink_id',">",0);
+ break;
+ case 3:
+ $model = $model->where($aler.'seckill_id',">",0);
+ break;
+ }
}
if($where['real_name'] != ''){
$model = $model->where($aler.'order_id|'.$aler.'real_name|'.$aler.'user_phone'.($join ? '|'.$join.'.nickname|'.$join.'.uid':''),'LIKE',"%$where[real_name]%");
}
if($where['data'] !== ''){
- list($startTime,$endTime) = explode(' - ',$where['data']);
- $model = $model->where($aler.'add_time','>',strtotime($startTime));
- $model = $model->where($aler.'add_time','<',strtotime($endTime));
+ $model = self::getModelTime($where,$model,$aler.'add_time');
}
return $model;
}
-
+ public static function getBadge($where){
+ $price=self::getOrderPrice($where);
+ return [
+ [
+ 'name'=>'订单数量',
+ 'field'=>'件',
+ 'count'=>$price['total_num'],
+ 'background_color'=>'layui-bg-blue',
+ 'col'=>2
+ ],
+ [
+ 'name'=>'售出商品',
+ 'field'=>'件',
+ 'count'=>$price['total_num'],
+ 'background_color'=>'layui-bg-blue',
+ 'col'=>2
+ ],
+ [
+ 'name'=>'订单金额',
+ 'field'=>'元',
+ 'count'=>$price['pay_price'],
+ 'background_color'=>'layui-bg-blue',
+ 'col'=>2
+ ],
+ [
+ 'name'=>'退款金额',
+ 'field'=>'元',
+ 'count'=>$price['refund_price'],
+ 'background_color'=>'layui-bg-blue',
+ 'col'=>2
+ ],
+ [
+ 'name'=>'微信支付金额',
+ 'field'=>'元',
+ 'count'=>$price['pay_price_wx'],
+ 'background_color'=>'layui-bg-blue',
+ 'col'=>2
+ ],
+ [
+ 'name'=>'余额支付金额',
+ 'field'=>'元',
+ 'count'=>$price['pay_price_yue'],
+ 'background_color'=>'layui-bg-blue',
+ 'col'=>2
+ ],
+ [
+ 'name'=>'线下支付金额',
+ 'field'=>'元',
+ 'count'=>$price['pay_price_offline'],
+ 'background_color'=>'layui-bg-blue',
+ 'col'=>2
+ ],
+ [
+ 'name'=>'积分抵扣',
+ 'field'=>'分',
+ 'count'=>$price['use_integral'].'(抵扣金额:¥'.$price['deduction_price'].')',
+ 'background_color'=>'layui-bg-blue',
+ 'col'=>2
+ ],
+ [
+ 'name'=>'退回积分',
+ 'field'=>'元',
+ 'count'=>$price['back_integral'],
+ 'background_color'=>'layui-bg-blue',
+ 'col'=>2
+ ]
+ ];
+ }
/**
* 处理订单金额
* @param $where
@@ -655,4 +894,14 @@ class StoreOrder extends ModelBasic
// }
// return $refundlist;
// }
+
+ /**
+ * 获取订单总数
+ * @param int $uid
+ * @return int|string
+ */
+ public static function getOrderCount($uid = 0){
+ if(!$uid) return 0;
+ return self::where('uid',$uid)->where('paid',1)->where('refund_status',0)->where('status',2)->count();
+ }
}
\ No newline at end of file
diff --git a/application/admin/model/store/StoreProduct.php b/application/admin/model/store/StoreProduct.php
index 36998f4d..b806c656 100644
--- a/application/admin/model/store/StoreProduct.php
+++ b/application/admin/model/store/StoreProduct.php
@@ -71,13 +71,7 @@ class StoreProduct extends ModelBasic
$model = $model->where('p.store_name|p.keyword|p.id','LIKE',"%$where[store_name]%");
}
if(isset($where['cate_id']) && trim($where['cate_id'])!=''){
- $cate=CategoryModel::where('id',$where['cate_id'])->find();
- if($cate['pid']==0){
- $arr=CategoryModel::where('pid',$cate['id'])->column('id');
- $model = $model->where('p.cate_id','in',$arr);
- }else{
- $model = $model->where('p.cate_id','LIKE',"%$where[cate_id]%");
- }
+ $model = $model->where('p.cate_id','LIKE',"%$where[cate_id]%");
}
if(isset($where['order']) && $where['order']!=''){
$model = $model->order(self::setOrder($where['order']));
@@ -386,7 +380,7 @@ class StoreProduct extends ModelBasic
->select();
$count=self::setWhere($where)->where('a.is_pay',1)->group('a.product_id')->count();
foreach ($data as &$item){
- $item['sum_price']=bcdiv($item['num_product'],$item['price'],2);
+ $item['sum_price']=bcmul($item['num_product'],$item['price'],2);
}
return compact('data','count');
}
diff --git a/application/admin/view/agent/agent_manage/stair.php b/application/admin/view/agent/agent_manage/stair.php
index 8214cf7c..f96da913 100644
--- a/application/admin/view/agent/agent_manage/stair.php
+++ b/application/admin/view/agent/agent_manage/stair.php
@@ -28,7 +28,7 @@
{$vo.add_time|date="Y-m-d H:i:s",###}