Merge pull request !8 from 聆听/develop
This commit is contained in:
聆听 2018-11-22 18:25:45 +08:00
commit 4d4b77d93c
20 changed files with 663 additions and 36 deletions

View File

@ -19,5 +19,19 @@ return [
// 是否自动开启 SESSION
'auto_start' => true,
],
'system_wechat_tag' => '_system_wechat'
'app_debug' => false,
// 应用Trace
'app_trace' => false,
'exception_handle' =>\basic\AdminException::class,
'empty_controller' =>'Index',
// 视图输出字符串内容替换
'view_replace_str' => [
'{__ADMIN_PATH}' => PUBILC_PATH.'system/',//后台
'{__FRAME_PATH}' => PUBILC_PATH.'system/frame/',//H+框架
'{__PLUG_PATH}' => PUBILC_PATH.'static/plug/',//前后台通用
'{__MODULE_PATH}' => PUBILC_PATH.'system/module/',//后台功能模块
'{__STATIC_PATH}' => PUBILC_PATH.'static/',//全站通用
'{__PUBLIC_PATH}' => PUBILC_PATH,//静态资源路径
]
];

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,396 @@
<?php
namespace app\admin\controller\ump;
use app\admin\controller\AuthController;
use service\FormBuilder as Form;
use traits\CurdControllerTrait;
use service\UtilService as Util;
use service\JsonService as Json;
use service\UploadService as Upload;
use think\Request;
use app\admin\model\store\StoreProduct as ProductModel;
use app\admin\model\ump\StoreCombinationAttr;
use app\admin\model\ump\StoreCombinationAttrResult;
use app\admin\model\ump\StoreCombination as StoreCombinationModel;
use think\Url;
use app\admin\model\system\SystemAttachment;
use app\wap\model\store\StorePink;
/**
* 拼团管理
* Class StoreCombination
* @package app\admin\controller\store
*/
class StoreCombination extends AuthController
{
use CurdControllerTrait;
protected $bindModel = StoreCombinationModel::class;
/**
* @return mixed
*/
public function index()
{
$this->assign('countCombination',StoreCombinationModel::getCombinationCount());
$this->assign(StoreCombinationModel::getStatistics());
$this->assign('combinationId',StoreCombinationModel::getCombinationIdAll());
return $this->fetch();
}
public function save_excel(){
$where = Util::getMore([
['is_show',''],
['store_name',''],
]);
StoreCombinationModel::SaveExcel($where);
}
/**
* 异步获取拼团数据
*/
public function get_combination_list(Request $request){
$where=Util::getMore([
['page',1],
['limit',20],
['export',0],
['is_show',''],
['is_host',''],
['store_name','']
],$request);
$combinationList = StoreCombinationModel::systemPage($where);
if(is_object($combinationList['list'])) $combinationList['list'] = $combinationList['list']->toArray();
$data = $combinationList['list']['data'];
foreach ($data as $k=>$v){
$data[$k]['_stop_time'] = date('Y/m/d H:i:s',$v['stop_time']);
}
return Json::successlayui(['count'=>$combinationList['list']['total'],'data'=>$data]);
}
public function combination($id = 0){
if(!$id) return $this->failed('数据不存在');
$product = ProductModel::get($id);
if(!$product) return Json::fail('数据不存在!');
$f = array();
$f[] = Form::hidden('product_id',$id);
// $f[] = Form::select('product_id','产品名称')->setOptions(function(){
// $list = ProductModel::getTierList();
// foreach ($list as $menu){
// $menus[] = ['value'=>$menu['id'],'label'=>$menu['store_name'].'/'.$menu['id']];
// }
// return $menus;
// })->filterable(1);
$f[] = Form::input('title','拼团名称',$product->getData('store_name'));
$f[] = Form::input('info','拼团简介',$product->getData('store_info'))->type('textarea');
$f[] = Form::input('unit_name','单位',$product->getData('unit_name'))->placeholder('个、位');
$f[] = Form::dateTimeRange('section_time','拼团时间');
$f[] = Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')),$product->getData('image'))->icon('image');
$f[] = Form::frameImages('images','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'images')),json_decode($product->getData('slider_image')))->maxLength(5)->icon('images');
$f[] = Form::number('price','拼团价')->min(0)->col(12);
$f[] = Form::number('people','拼团人数')->min(3)->col(12);
$f[] = Form::number('stock','库存',$product->getData('stock'))->min(0)->precision(0)->col(12);
$f[] = Form::number('sales','销量',$product->getData('sales'))->min(0)->precision(0)->col(12);
$f[] = Form::number('sort','排序')->col(12);
$f[] = Form::number('postage','邮费',$product->getData('postage'))->min(0)->col(12);
$f[] = Form::radio('is_postage','是否包邮',$product->getData('is_postage'))->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(12);
$f[] = Form::radio('is_host','热门推荐',1)->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]])->col(12);
$f[] = Form::radio('is_show','活动状态',1)->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]])->col(12);
$form = Form::make_post_form('添加用户通知',$f,Url::build('save'));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
$f = array();
$f[] = Form::select('product_id','产品名称')->setOptions(function(){
$list = ProductModel::getTierList();
foreach ($list as $menu){
$menus[] = ['value'=>$menu['id'],'label'=>$menu['store_name'].'/'.$menu['id']];
}
return $menus;
})->filterable(1);
$f[] = Form::input('title','拼团名称');
$f[] = Form::input('info','拼团简介')->type('textarea');
$f[] = Form::input('unit_name','单位')->placeholder('个、位');
$f[] = Form::dateTimeRange('section_time','拼团时间');
$f[] = Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')))->icon('image');
$f[] = Form::frameImages('images','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'images')))->maxLength(5)->icon('images');
$f[] = Form::number('price','拼团价')->min(0)->col(12);
$f[] = Form::number('people','拼团人数')->min(3)->col(12);
$f[] = Form::number('stock','库存')->min(0)->precision(0)->col(12);
$f[] = Form::number('sales','销量')->min(0)->precision(0)->col(12);
$f[] = Form::number('sort','排序')->col(12);
$f[] = Form::number('postage','邮费')->min(0)->col(12);
$f[] = Form::radio('is_postage','是否包邮',1)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(12);
$f[] = Form::radio('is_host','热门推荐',1)->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]])->col(12);
$f[] = Form::radio('is_show','活动状态',1)->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]])->col(12);
$form = Form::make_post_form('添加用户通知',$f,Url::build('save'));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
}
/**
* 保存新建的资源
*
* @param \think\Request $request
* @return \think\Response
*/
public function save(Request $request,$id=0)
{
$data = Util::postMore([
'product_id',
'title',
'info',
['image',''],
['images',[]],
['section_time',[]],
'postage',
'price',
'people',
'sort',
'stock',
'sales',
['is_show',0],
['is_host',0],
['is_postage',0],
],$request);
if(!$data['title']) return Json::fail('请输入拼团名称');
if(!$data['info']) return Json::fail('请输入拼团简介');
if(!$data['image']) return Json::fail('请上传产品图片');
if(count($data['images'])<1) return Json::fail('请上传产品轮播图');
if($data['price'] == '' || $data['price'] < 0) return Json::fail('请输入产品售价');
if($data['people'] == '' || $data['people'] < 1) return Json::fail('请输入拼团人数');
if(count($data['section_time'])<1) return Json::fail('请选择活动时间');
if($data['stock'] == '' || $data['stock'] < 0) return Json::fail('请输入库存');
$data['images'] = json_encode($data['images']);
$data['add_time'] = time();
$data['start_time'] = strtotime($data['section_time'][0]);
$data['stop_time'] = strtotime($data['section_time'][1]);
$data['description'] = '';
unset($data['section_time']);
if($id){
$product = StoreCombinationModel::get($id);
if(!$product) return Json::fail('数据不存在!');
$data['product_id']=$product['product_id'];
StoreCombinationModel::edit($data,$id);
return Json::successful('编辑成功!');
}else{
StoreCombinationModel::set($data);
return Json::successful('添加拼团成功!');
}
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
if(!$id) return $this->failed('数据不存在');
$product = StoreCombinationModel::get($id);
if(!$product) return Json::fail('数据不存在!');
$f = array();
$f[] = Form::input('title','拼团名称',$product->getData('title'));
$f[] = Form::input('info','拼团简介',$product->getData('title'))->type('textarea');
$f[] = Form::input('unit_name','单位',$product->getData('title'))->placeholder('个、位');
$f[] = Form::dateTimeRange('section_time','拼团时间',$product->getData('start_time'),$product->getData('stop_time'));
$f[] = Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')),$product->getData('image'))->icon('image');
$f[] = Form::frameImages('images','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'images')),json_decode($product->getData('images')))->maxLength(5)->icon('images');
$f[] = Form::number('price','拼团价',$product->getData('price'))->min(0)->col(12);
$f[] = Form::number('people','拼团人数',$product->getData('people'))->min(2)->col(12);
$f[] = Form::number('stock','库存',$product->getData('stock'))->min(0)->precision(0)->col(12);
$f[] = Form::number('sales','销量',$product->getData('sales'))->min(0)->precision(0)->col(12);
$f[] = Form::number('sort','排序',$product->getData('sort'))->col(12);
$f[] = Form::number('postage','邮费',$product->getData('postage'))->min(0)->col(12);
$f[] = Form::radio('is_postage','是否包邮',$product->getData('is_postage'))->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(12);
$f[] = Form::radio('is_host','热门推荐',$product->getData('is_host'))->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]])->col(12);
$f[] = Form::radio('is_show','活动状态',$product->getData('is_show'))->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]])->col(12);
$form = Form::make_post_form('添加用户通知',$f,Url::build('save',compact('id')));
$this->assign(compact('form'));
return $this->fetch('public/form-builder');
// $this->assign([
// 'title'=>'编辑产品','rules'=>$this->read($id)->getContent(),
// 'action'=>Url::build('update',array('id'=>$id))
// ]);
// return $this->fetch('public/common_form');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if(!$id) return $this->failed('数据不存在');
$data['is_del'] = 1;
if(!StoreCombinationModel::edit($data,$id))
return Json::fail(StoreCombinationModel::getErrorInfo('删除失败,请稍候再试!'));
else
return Json::successful('删除成功!');
}
/**
* 属性页面
* @param $id
* @return mixed|void
*/
public function attr($id)
{
if(!$id) return $this->failed('数据不存在!');
$result = StoreCombinationAttrResult::getResult($id);
$image = StoreCombinationModel::where('id',$id)->value('image');
$this->assign(compact('id','result','product','image'));
return $this->fetch();
}
/**
* 生成属性
* @param int $id
*/
public function is_format_attr($id = 0){
if(!$id) return Json::fail('产品不存在');
list($attr,$detail) = Util::postMore([
['items',[]],
['attrs',[]]
],$this->request,true);
$product = StoreCombinationModel::get($id);
if(!$product) return Json::fail('产品不存在');
$attrFormat = attrFormat($attr)[1];
if(count($detail)){
foreach ($attrFormat as $k=>$v){
foreach ($detail as $kk=>$vv){
if($v['detail'] == $vv['detail']){
$attrFormat[$k]['price'] = $vv['price'];
$attrFormat[$k]['sales'] = $vv['sales'];
$attrFormat[$k]['pic'] = $vv['pic'];
$attrFormat[$k]['check'] = false;
break;
}else{
$attrFormat[$k]['price'] = '';
$attrFormat[$k]['sales'] = '';
$attrFormat[$k]['pic'] = $product['image'];
$attrFormat[$k]['check'] = true;
}
}
}
}else{
foreach ($attrFormat as $k=>$v){
$attrFormat[$k]['price'] = $product['price'];
$attrFormat[$k]['sales'] = $product['stock'];
$attrFormat[$k]['pic'] = $product['image'];
$attrFormat[$k]['check'] = false;
}
}
return Json::successful($attrFormat);
}
/**
* 添加 修改属性
* @param $id
*/
public function set_attr($id)
{
if(!$id) return $this->failed('产品不存在!');
list($attr,$detail) = Util::postMore([
['items',[]],
['attrs',[]]
],$this->request,true);
$res = StoreCombinationAttr::createProductAttr($attr,$detail,$id);
if($res)
return $this->successful('编辑属性成功!');
else
return $this->failed(StoreCombinationAttr::getErrorInfo());
}
/**
* 清除属性
* @param $id
*/
public function clear_attr($id)
{
if(!$id) return $this->failed('产品不存在!');
if(false !== StoreCombinationAttr::clearProductAttr($id) && false !== StoreCombinationAttrResult::clearResult($id))
return $this->successful('清空产品属性成功!');
else
return $this->failed(StoreCombinationAttr::getErrorInfo('清空产品属性失败!'));
}
public function edit_content($id){
if(!$id) return $this->failed('数据不存在');
$product = StoreCombinationModel::get($id);
if(!$product) return Json::fail('数据不存在!');
$this->assign([
'content'=>StoreCombinationModel::where('id',$id)->value('description'),
'field'=>'description',
'action'=>Url::build('change_field',['id'=>$id,'field'=>'description'])
]);
return $this->fetch('public/edit_content');
}
/**
* 上传图片
* @return \think\response\Json
*/
public function upload()
{
$res = Upload::image('file','store/product/'.date('Ymd'));
$thumbPath = Upload::thumb($res->dir);
//产品图片上传记录
$fileInfo = $res->fileInfo->getinfo();
SystemAttachment::attachmentAdd($res->fileInfo->getSaveName(),$fileInfo['size'],$fileInfo['type'],$res->dir,$thumbPath,2);
if($res->status == 200)
return Json::successful('图片上传成功!',['name'=>$res->fileInfo->getSaveName(),'url'=>Upload::pathToUrl($thumbPath)]);
else
return Json::fail($res->error);
}
/**拼团列表
* @return mixed
*/
public function combina_list()
{
$where = Util::getMore([
['status',''],
['data',''],
],$this->request);
$this->assign('where',$where);
$this->assign(StorePink::systemPage($where));
return $this->fetch();
}
/**拼团人列表
* @return mixed
*/
public function order_pink($id){
if(!$id) return $this->failed('数据不存在');
$StorePink = StorePink::getPinkUserOne($id);
if(!$StorePink) return $this->failed('数据不存在!');
$list = StorePink::getPinkMember($id);
$list[] = $StorePink;
$this->assign('list',$list);
return $this->fetch();
}/**
* 修改拼团状态
* @param $status
* @param int $idd
*/
public function set_combination_status($status,$id = 0){
if(!$id) return Json::fail('参数错误');
$res = StoreCombinationModel::edit(['is_show'=>$status],$id);
if($res) return Json::successful('修改成功');
else return Json::fail('修改失败');
}
}

View File

@ -227,8 +227,8 @@ class FinanceModel extends ModelBasic
{
$trans = self::alias('a')
->join('user b', 'a.uid=b.uid')
->join('store_order_cart_info c', 'a.id=c.oid')
->join('store_product d', 'c.product_id=d.id')
->join('__STORE_ORDER_CART_INFO__ c', 'a.id=c.oid')
->join('__STORE_PRODUCT__ d', 'c.product_id=d.id')
->field('b.nickname,a.pay_price,d.store_name')
->order('a.add_time DESC')
->limit('6')

View File

@ -49,7 +49,7 @@ class StoreOrder extends ModelBasic
}
$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();
$_info = Db::name('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);
}
@ -157,7 +157,7 @@ HTML;
public static function SaveExcel($list){
$export = [];
foreach ($list as $index=>$item){
$_info = db('store_order_cart_info')->where('oid',$item['id'])->column('cart_info');
$_info = Db::name('store_order_cart_info')->where('oid',$item['id'])->column('cart_info');
$goodsName = [];
foreach ($_info as $k=>$v){
$v = json_decode($v,true);
@ -209,7 +209,7 @@ HTML;
$payType = '其他支付';
}
$_info = db('store_order_cart_info')->where('oid',$item['id'])->column('cart_info');
$_info = Db::name('store_order_cart_info')->where('oid',$item['id'])->column('cart_info');
$goodsName = [];
foreach ($_info as $k=>$v){
$v = json_decode($v,true);
@ -237,7 +237,7 @@ HTML;
->ExcelSave();
}
return self::page($model,function ($item){
$_info = db('store_order_cart_info')->where('oid',$item['id'])->field('cart_info')->select();
$_info = Db::name('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);
}
@ -513,7 +513,7 @@ HTML;
$payType = '其他支付';
}
$_info = db('store_order_cart_info')->where('oid',$item['id'])->column('cart_info');
$_info = Db::name('store_order_cart_info')->where('oid',$item['id'])->column('cart_info');
$goodsName = [];
foreach ($_info as $k=>$v){
$v = json_decode($v,true);
@ -540,7 +540,7 @@ HTML;
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();
$_info = Db::name('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);
}

View File

@ -173,8 +173,8 @@ class StoreStatistics extends ModelBasic
{
$trans = self::alias('a')
->join('user b', 'a.uid=b.uid')
->join('store_order_cart_info c', 'a.id=c.oid')
->join('store_product d', 'c.product_id=d.id')
->join('__STORE_ORDER_CART_INFO__ c', 'a.id=c.oid')
->join('__STORE_PRODUCT__ d', 'c.product_id=d.id')
->field('b.nickname,a.pay_price,d.store_name')
->order('a.add_time DESC')
->limit('6')
@ -200,6 +200,8 @@ class StoreStatistics extends ModelBasic
$cost=$info['cost'];//成本
$export[] = [$time,$price,$zhichu,$cost,$coupon,$deduction,$profit];
}
// ExportService::exportCsv($export,'统计'.time(),['时间','营业额(元)','支出(元)','成本','优惠','积分抵扣','盈利(元)']);
dump($export);
PHPExcelService::setExcelHeader(['时间','营业额(元)','支出(元)','成本','优惠','积分抵扣','盈利(元)'])->setExcelTile('财务统计', '财务统计',date('Y-m-d H:i:s',time()))->setExcelContent($export)->ExcelSave();
}
}

View File

@ -4,6 +4,7 @@ namespace app\admin\model\store;
use basic\ModelBasic;
use traits\ModelTrait;
use think\Db;
class StoreCouponUser extends ModelBasic
{
@ -38,7 +39,7 @@ class StoreCouponUser extends ModelBasic
$coupon['_msg'] = '可使用';
}
}
$coupon['integral']=db('store_coupon')->where(['id'=>$coupon['cid']])->value('integral');
$coupon['integral']= Db::name('store_coupon')->where(['id'=>$coupon['cid']])->value('integral');
}
return $couponList;
}
@ -53,7 +54,7 @@ class StoreCouponUser extends ModelBasic
[
'name'=>'总发放优惠券',
'field'=>'张',
'count'=>self::getModelTime($where,db('store_coupon_issue'))->where('status',1)->sum('total_count'),
'count'=>self::getModelTime($where, Db::name('store_coupon_issue'))->where('status',1)->sum('total_count'),
'background_color'=>'layui-bg-blue',
'col'=>6,
],
@ -69,7 +70,7 @@ class StoreCouponUser extends ModelBasic
//获取优惠劵图表
public static function getConponCurve($where,$limit=20){
//优惠劵发放记录
$list=self::getModelTime($where,db('store_coupon_issue')
$list=self::getModelTime($where, Db::name('store_coupon_issue')
->where('status',1)
->field(['FROM_UNIXTIME(add_time,"%Y-%m-%d") as _add_time','sum(total_count) as total_count'])->group('_add_time')->order('_add_time asc'))->select();
$date=[];

View File

@ -15,6 +15,9 @@ use traits\ModelTrait;
use basic\ModelBasic;
use app\admin\model\store\StoreCategory as CategoryModel;
use app\admin\model\order\StoreOrder;
use app\admin\model\ump\StoreSeckill as StoreSeckillModel;
use app\admin\model\ump\StoreCombination as StoreCombinationModel;
use app\admin\model\ump\StoreBargain as StoreBargainModel;
use app\admin\model\system\SystemConfig;
/**
@ -26,6 +29,27 @@ class StoreProduct extends ModelBasic
{
use ModelTrait;
/**删除产品
* @param $id
*/
public static function proDelete($id){
//删除产品
//删除属性
//删除秒杀
//删除拼团
//删除砍价
//删除拼团
$model=new self();
self::beginTrans();
$res0 = $model::del($id);
$res1 = StoreSeckillModel::where(['product_id'=>$id])->delete();
$res2 = StoreCombinationModel::where(['product_id'=>$id])->delete();
$res3 = StoreBargainModel::where(['product_id'=>$id])->delete();
//。。。。
$res = $res0 && $res1 && $res2 && $res3;
self::checkTrans($res);
return $res;
}
/**
* 获取连表查询条件
* @param $type
@ -243,7 +267,7 @@ class StoreProduct extends ModelBasic
*/
public static function getMaxList($where){
$classs=['layui-bg-red','layui-bg-orange','layui-bg-green','layui-bg-blue','layui-bg-cyan'];
$model=StoreOrder::alias('a')->join('StoreOrderCartInfo c','a.id=c.oid')->join('store_product b','b.id=c.product_id');
$model=StoreOrder::alias('a')->join('StoreOrderCartInfo c','a.id=c.oid')->join('__STORE_PRODUCT__ b','b.id=c.product_id');
$list=self::getModelTime($where,$model,'a.add_time')->group('c.product_id')->order('p_count desc')->limit(10)
->field(['count(c.product_id) as p_count','b.store_name','sum(b.price) as sum_price'])->select();
if(count($list)) $list=$list->toArray();
@ -268,7 +292,7 @@ class StoreProduct extends ModelBasic
//获取利润
public static function ProfityTop10($where){
$classs=['layui-bg-red','layui-bg-orange','layui-bg-green','layui-bg-blue','layui-bg-cyan'];
$model=StoreOrder::alias('a')->join('StoreOrderCartInfo c','a.id=c.oid')->join('store_product b','b.id=c.product_id');
$model=StoreOrder::alias('a')->join('StoreOrderCartInfo c','a.id=c.oid')->join('__STORE_PRODUCT__ b','b.id=c.product_id');
$list=self::getModelTime($where,$model,'a.add_time')->group('c.product_id')->order('profity desc')->limit(10)
->field(['count(c.product_id) as p_count','b.store_name','sum(b.price) as sum_price','(b.price-b.cost) as profity'])
->select();
@ -360,7 +384,7 @@ class StoreProduct extends ModelBasic
}else{
$time['data']=isset($where['data'])? $where['data']:'';
}
$model=self::getModelTime($time,db('store_cart')->alias('a')->join('store_product b','a.product_id=b.id'),'a.add_time');
$model=self::getModelTime($time, Db::name('store_cart')->alias('a')->join('__STORE_PRODUCT__ b','a.product_id=b.id'),'a.add_time');
if(isset($where['title']) && $where['title']!=''){
$model=$model->where('b.store_name|b.id','like',"%$where[title]%");
}
@ -471,7 +495,7 @@ class StoreProduct extends ModelBasic
[
'name'=>'点赞次数',
'field'=>'个',
'count'=>db('store_product_relation')->where('product_id',$id)->where('type','like')->count(),
'count'=>Db::name('store_product_relation')->where('product_id',$id)->where('type','like')->count(),
'background_color'=>'layui-bg-blue',
],
[

View File

@ -161,7 +161,7 @@ class StoreSeckill extends ModelBasic
*/
public static function getMaxList($where){
$classs=['layui-bg-red','layui-bg-orange','layui-bg-green','layui-bg-blue','layui-bg-cyan'];
$model=StoreOrder::alias('a')->join('store_seckill b','b.id=a.seckill_id')->where('a.paid',1);
$model=StoreOrder::alias('a')->join('__STORE_SECKILL__ b','b.id=a.seckill_id')->where('a.paid',1);
$list=self::getModelTime($where,$model,'a.add_time')->group('a.seckill_id')->order('p_count desc')->limit(10)
->field(['count(a.seckill_id) as p_count','b.title as store_name','sum(b.price) as sum_price'])->select();
if(count($list)) $list=$list->toArray();
@ -191,7 +191,7 @@ class StoreSeckill extends ModelBasic
*/
public static function ProfityTop10($where){
$classs=['layui-bg-red','layui-bg-orange','layui-bg-green','layui-bg-blue','layui-bg-cyan'];
$model = StoreOrder::alias('a')->join('store_seckill b','b.id = a.seckill_id')->where('a.paid',1);
$model = StoreOrder::alias('a')->join('__STORE_SECKILL__ b','b.id = a.seckill_id')->where('a.paid',1);
$list=self::getModelTime($where,$model,'a.add_time')->group('a.seckill_id')->order('profity desc')->limit(10)
->field(['count(a.seckill_id) as p_count','b.title as store_name','sum(b.price) as sum_price','(b.price-b.cost) as profity'])
->select();
@ -244,7 +244,7 @@ class StoreSeckill extends ModelBasic
* @return mixed
*/
public static function getBargainRefundList($where = array()){
$model = StoreOrder::alias('a')->join('store_seckill b','b.id=a.seckill_id');
$model = StoreOrder::alias('a')->join('__STORE_SECKILL__ b','b.id=a.seckill_id');
$list = self::getModelTime($where,$model,'a.add_time')->where('a.refund_status','NEQ',0)->group('a.seckill_id')->order('count desc')->page((int)$where['page'],(int)$where['limit'])
->field(['count(a.seckill_id) as count','b.title as store_name','sum(b.price) as sum_price'])->select();
if(count($list)) $list=$list->toArray();

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@ namespace app\admin\model\user;
use traits\ModelTrait;
use basic\ModelBasic;
use app\admin\model\wechat\WechatUser;
use think\Db;
/**
* 用户消费新增金额明细 model
* Class User
@ -101,7 +101,7 @@ class UserBill extends ModelBasic
$list=self::alias('a')->join('user r','a.uid=r.uid')
->where($datawhere)
->order('a.number desc')
->join('store_order o','o.id=a.link_id')
->join('__STORE_ORDER__ o','o.id=a.link_id')
->field(['o.order_id','FROM_UNIXTIME(a.add_time,"%Y-%c-%d") as add_time','a.uid','o.uid as down_uid','r.nickname','r.avatar','r.spread_uid','r.level','a.number'])
->page((int)$where['page'],(int)$where['limit'])
->select();
@ -111,7 +111,7 @@ class UserBill extends ModelBasic
//获取返佣用户总人数
public static function getFanCount(){
$datawhere=['a.category'=>'now_money','a.type'=>'brokerage','a.pm'=>1];
return self::alias('a')->join('user r','a.uid=r.uid')->join('store_order o','o.id=a.link_id')->where($datawhere)->count();
return self::alias('a')->join('user r','a.uid=r.uid')->join('__STORE_ORDER__ o','o.id=a.link_id')->where($datawhere)->count();
}
//获取用户充值数据
public static function getEchartsRecharge($where,$limit=15){
@ -145,7 +145,7 @@ class UserBill extends ModelBasic
count($list) && $list=$list->toArray();
$count=self::setOneWhere($where,$uid)->count();
foreach ($list as &$value){
$value['order_id']=db('store_order')->where(['order_id'=>$value['link_id']])->value('order_id');
$value['order_id']=Db::name('store_order')->where(['order_id'=>$value['link_id']])->value('order_id');
}
return ['data'=>$list,'count'=>$count];
}

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> 404 页面</title>
<meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
<meta name="description" content="H+是一个完全响应式基于Bootstrap3最新版本开发的扁平化主题她采用了主流的左右两栏式布局使用了Html5+CSS3等现代技术">
<link rel="shortcut icon" href="favicon.ico">
<link href="{__FRAME_PATH}css/bootstrap.min.css" rel="stylesheet">
<link href="{__FRAME_PATH}css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="{__FRAME_PATH}css/style.min.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="middle-box text-center animated fadeInDown">
<h1>404</h1>
<h3 class="font-bold">页面未找到!</h3>
<div class="error-desc">
抱歉,页面好像去火星了~
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> {$title}</title>
<meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
<meta name="description" content="H+是一个完全响应式基于Bootstrap3最新版本开发的扁平化主题她采用了主流的左右两栏式布局使用了Html5+CSS3等现代技术">
<link rel="shortcut icon" href="favicon.ico">
<link href="{__FRAME_PATH}css/bootstrap.min.css" rel="stylesheet">
<link href="{__FRAME_PATH}css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="{__FRAME_PATH}css/style.min.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="middle-box text-center animated fadeInDown">
<h1>500</h1>
<h3 class="font-bold">服务器内部错误</h3>
<div class="error-desc">
服务器好像出错了...
<p>{$msg}</p>
</div>
</div>
</body>
</html>

View File

@ -33,4 +33,28 @@ function sensitive_words_filter($str)
}
}
return '';
}
/**
* 上传路径转化,默认路径 UPLOAD_PATH
* $type 类型
*/
function makePathToUrl($path,$type = 2)
{
$path = DS.ltrim(rtrim($path));
switch ($type){
case 1:
$path .= DS.date('Y');
break;
case 2:
$path .= DS.date('Y').DS.date('m');
break;
case 3:
$path .= DS.date('Y').DS.date('m').DS.date('d');
break;
}
if (is_dir(ROOT_PATH.UPLOAD_PATH.$path) == true || mkdir(ROOT_PATH.UPLOAD_PATH.$path, 0777, true) == true) {
return trim(str_replace(DS, '/',UPLOAD_PATH.$path),'.');
}else return '';
}

View File

@ -17,7 +17,7 @@ return [
// 应用命名空间
'app_namespace' => 'app',
// 应用调试模式
'app_debug' => true,
'app_debug' => false,
// 应用Trace
'app_trace' => false,
// 应用模式状态

View File

@ -2,7 +2,7 @@
namespace app\routine\model\routine;
use app\admin\model\system\SystemConfig;
use think\Db;
class RoutineServer{
/**
* curl get方式
@ -73,14 +73,14 @@ class RoutineServer{
* @return mixed
*/
public static function get_access_token(){
$accessToken = db('routine_access_token')->where('id',1)->find();
$accessToken = Db::name('routine_access_token')->where('id',1)->find();
if($accessToken['stop_time'] > time()) return $accessToken['access_token'];
else{
$accessToken = self::getAccessToken();
if(isset($accessToken['access_token'])){
$data['access_token'] = $accessToken['access_token'];
$data['stop_time'] = bcadd($accessToken['expires_in'],time(),0);
db('routine_access_token')->where('id',1)->update($data);
Db::name('routine_access_token')->where('id',1)->update($data);
}
return $accessToken['access_token'];
}

View File

@ -58,8 +58,8 @@ class StoreOrder extends ModelBasic
public static function getOrderPriceGroup($cartInfo)
{
$storePostage = floatval(SystemConfigService::get('store_postage'))?:0;
$storeFreePostage = floatval(SystemConfigService::get('store_free_postage'))?:0;
$storePostage = floatval(SystemConfigService::get('store_postage'))?:0;//基础邮费
$storeFreePostage = floatval(SystemConfigService::get('store_free_postage'))?:0;//满*包邮
$totalPrice = self::getOrderTotalPrice($cartInfo);
$costPrice = self::getOrderCostPrice($cartInfo);
if(!$storeFreePostage) {
@ -196,7 +196,6 @@ class StoreOrder extends ModelBasic
$couponPrice = 0;
}
if(!$res1) return self::setErrorInfo('使用优惠劵失败!');
//是否包邮
if((isset($other['offlinePostage']) && $other['offlinePostage'] && $payType == 'offline')) $payPostage = 0;
$payPrice = bcadd($payPrice,$payPostage,2);
@ -572,7 +571,7 @@ class StoreOrder extends ModelBasic
$status['_msg'] = '已为您退款,感谢您的支持';
$status['_class'] = 'state-sqtk';
}else if(!$order['status']){
if($order['pink_id']){
if(isset($order['pink_id'])){
if(StorePink::where('id',$order['pink_id'])->where('status',1)->count()){
$status['_type'] = 1;
$status['_title'] = '拼团中';

View File

@ -0,0 +1,53 @@
<?php
/**
*
* @author: xaboy<365615158@qq.com>
* @day: 2018/01/10
*/
namespace basic;
use Exception;
use service\JsonService;
use think\exception\Handle;
use think\exception\HttpException;
use think\exception\ValidateException;
use think\Log;
use think\Request;
use think\Url;
class AdminException extends Handle
{
public function render(Exception $e){
// 参数验证错误
if ($e instanceof ValidateException) {
return json($e->getError(), 422);
}
// 请求异常
if ($e instanceof HttpException && request()->isAjax()) {
return JsonService::fail('系统错误');
}else{
if(config("app_debug")==true){ //如是开启调试,就走原来的方法
return parent::render($e);
}else {
$title = '系统错误';
$msg = addslashes($e->getMessage());
$this->recordErrorLog($e);
exit(view('public/500', compact('title', 'msg'))->getContent());
}
}
}
/*
* 将异常写入日志
*/
private function recordErrorLog(Exception $e) {
Log::init([
'type' => 'File',
'path' => LOG_PATH,
'level' => ['error'],
]);
Log::record($e->getMessage(), 'error');
}
}

View File

@ -94,10 +94,21 @@ class SystemBasic extends \think\Controller
exit($this->fetch('public/success'));
}
}
/**异常抛出
* @param $name
*/
protected function exception($msg = '无法打开页面')
{
$this->assign(compact('msg'));
exit($this->fetch('public/exception'));
}
/**找不到页面
* @param $name
*/
public function _empty($name)
{
exit($this->fetch('public/404'));
}
}

View File

@ -177,6 +177,49 @@ class UtilService
}
return $list;
}
/**
* 分级返回多维数组
* @param $data
* @param int $pid
* @param string $field
* @param string $pk
* @param int $level
* @return array
*/
public static function getChindNode($data, $pid = 0, $field = 'pid', $pk = 'id', $level = 1)
{
static $list = [];
foreach ($data as $k => $res) {
if ($res['pid'] == $pid) {
$list[] = $res;
unset($data[$k]);
self::getChindNode($data, $res['id'], $field, $pk, $level + 1);
}
}
return $list;
}
/**分级返回下级所有分类ID
* @param $data
* @param string $children
* @param string $field
* @param string $pk
* @return string
*/
public static function getChildrenPid($data,$pid, $field = 'pid', $pk = 'id')
{
static $pids = '';
foreach ($data as $k => $res) {
if ($res[$field] == $pid) {
$pids .= ','.$res[$pk];
self::getChildrenPid($data, $res[$pk], $field, $pk);
}
}
return $pids;
}
/**