diff --git a/.htaccess b/.htaccess deleted file mode 100644 index dd7fb8245..000000000 --- a/.htaccess +++ /dev/null @@ -1,8 +0,0 @@ - -Options +FollowSymlinks -Multiviews -RewriteEngine on - -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] - \ No newline at end of file diff --git a/application/admin/common.php b/application/admin/common.php index 90f292c12..3c137dcfb 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/config.php b/application/admin/config.php index 90bc37840..7486457d6 100644 --- a/application/admin/config.php +++ b/application/admin/config.php @@ -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,//静态资源路径 + ] ]; diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index 3a78c6b6c..6a6835c54 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -160,7 +160,7 @@ class Index extends AuthController ->group("FROM_UNIXTIME(add_time, '%Y%m%e')") ->order('add_time asc') ->select()->toArray(); - if(empty($order_list)) return false; + if(empty($order_list)) return Json::fail('无数据'); foreach ($order_list as $k=>&$v){ $order_list[$v['day']] = $v; } diff --git a/application/admin/controller/Login.php b/application/admin/controller/Login.php index d98ea6f4d..c466fa74f 100644 --- a/application/admin/controller/Login.php +++ b/application/admin/controller/Login.php @@ -36,7 +36,7 @@ class Login extends SystemBasic //检验验证码 if(!captcha_check($verify)) return $this->failed('验证码错误,请重新输入'); $error = Session::get('login_error')?:['num'=>0,'time'=>time()]; - if($error['num'] >=5 && $error['time'] < strtotime('+ 5 minutes')) + if($error['num'] >=5 && $error['time'] > strtotime('- 5 minutes')) return $this->failed('错误次数过多,请稍候再试!'); //检验帐号密码 $res = SystemAdmin::login($account,$pwd); diff --git a/application/admin/controller/agent/AgentManage.php b/application/admin/controller/agent/AgentManage.php index 39a6ba02c..4b2052927 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 c14c68983..f1b9436ed 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,30 @@ 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(); + //获取分类列表 + if($catlist){ + $tree = Phptree::makeTreeForHtml($catlist); + $this->assign(compact('tree')); + if($pid){ + $pids = Util::getChildrenPid($tree,$pid); + $where['cid'] = ltrim($pid.$pids); + } + }else{ + $tree = []; + $this->assign(compact('tree')); + } + + $this->assign('cate',ArticleCategoryModel::getTierList()); $this->assign(ArticleModel::getAll($where)); return $this->fetch(); @@ -121,11 +134,11 @@ class Article extends AuthController 'synopsis', 'share_title', 'share_synopsis', - 'is_banner', - 'is_hot', ['visit',0], ['sort',0], 'url', + ['is_banner',0], + ['is_hot',0], ['status',1],],$request); $data['cid'] = implode(',',$data['cid']); $content = $data['content']; diff --git a/application/admin/controller/finance/UserExtract.php b/application/admin/controller/finance/UserExtract.php index 91fce337f..0fb1b66fb 100644 --- a/application/admin/controller/finance/UserExtract.php +++ b/application/admin/controller/finance/UserExtract.php @@ -83,6 +83,10 @@ class UserExtract extends AuthController { if(!UserExtractModel::be(['id'=>$id,'status'=>0])) return JsonService::fail('操作记录不存在或状态错误!'); $fail_msg =$request->post(); + $extract=UserExtractModel::get($id); + if(!$extract) return JsonService::fail('操作记录不存在!'); + if($extract->status==1) return JsonService::fail('已经提现,错误操作'); + if($extract->status==-1) return JsonService::fail('您的提现申请已被拒绝,请勿重复操作!'); $res = UserExtractModel::changeFail($id,$fail_msg['message']); if($res){ return JsonService::successful('操作成功!'); @@ -95,6 +99,10 @@ class UserExtract extends AuthController if(!UserExtractModel::be(['id'=>$id,'status'=>0])) return JsonService::fail('操作记录不存在或状态错误!'); UserExtractModel::beginTrans(); + $extract=UserExtractModel::get($id); + if(!$extract) return JsonService::fail('操作记录不存!'); + if($extract->status==1) return JsonService::fail('您已提现,请勿重复提现!'); + if($extract->status==-1) return JsonService::fail('您的提现申请已被拒绝!'); $res = UserExtractModel::changeSuccess($id); if($res){ return JsonService::successful('操作成功!'); diff --git a/application/admin/controller/order/StoreOrder.php b/application/admin/controller/order/StoreOrder.php index a25616e5e..415e678b3 100644 --- a/application/admin/controller/order/StoreOrder.php +++ b/application/admin/controller/order/StoreOrder.php @@ -1 +1 @@ -request); $limitTimeList = [ 'yesterday'=>implode(' - ',[date('Y/m/d',strtotime('-1 day')),date('Y/m/d')]), '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')) ]) ]; $seven_day = strtotime(date('Y-m-d',strtotime('-7 day')));//前7天时间戳 $orderTopData = []; //最近7天下单数量 $orderTopData['sevenDayOrderNum'] = StoreOrderModel::where('add_time','>=',$seven_day)->count(); //代付款数量 $orderTopData['noPayNum'] = StoreOrderModel::where('paid',0)->count(); //代发货数量 $orderTopData['noDeliveryNum'] = StoreOrderModel::where('status',0)->where('refund_status',0)->where('paid',1)->count(); //退换货数量 $orderTopData['yesRefundNum'] = StoreOrderModel::where('refund_status','IN','1,2')->count(); //7天收入 $orderTopData['sevenDayPrice'] = StoreOrderModel::where('pay_time','>=',$seven_day)->where('paid',1)->count(); $this->assign(StoreOrderModel::systemPage($where,$this->adminId)); $this->assign('price',StoreOrderModel::getOrderPrice($where)); $this->assign(compact('where','limitTimeList','orderTopData')); return $this->fetch(); } public function orderchart(){ $where = Util::getMore([ ['status',''], ['real_name',''], ['is_del',0], ['data',''], ['combination_id',''], ['export',0], ['order','id desc'] ],$this->request); $limitTimeList = [ 'today'=>implode(' - ',[date('Y/m/d'),date('Y/m/d',strtotime('+1 day'))]), 'week'=>implode(' - ',[ date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)), date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)) ]), 'month'=>implode(' - ',[date('Y/m').'/01',date('Y/m').'/'.date('t')]), 'quarter'=>implode(' - ',[ date('Y').'/'.(ceil((date('n'))/3)*3-3+1).'/01', date('Y').'/'.(ceil((date('n'))/3)*3).'/'.date('t',mktime(0,0,0,(ceil((date('n'))/3)*3),1,date('Y'))) ]), 'year'=>implode(' - ',[ date('Y').'/01/01',date('Y/m/d',strtotime(date('Y').'/01/01 + 1year -1 day')) ]) ]; if($where['data'] == '') $where['data'] = $limitTimeList['today']; $orderCount = [ urlencode('未支付')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(0))->count(), urlencode('未发货')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(1))->count(), urlencode('待收货')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(2))->count(), urlencode('待评价')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(3))->count(), urlencode('交易完成')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(4))->count(), urlencode('退款中')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(-1))->count(), urlencode('已退款')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(-2))->count() ]; $model = StoreOrderModel::getOrderWhere($where,new StoreOrderModel())->field('sum(total_num) total_num,count(*) count,sum(total_price) total_price,sum(refund_price) refund_price,from_unixtime(add_time,\'%Y-%m-%d\') add_time') ->group('from_unixtime(add_time,\'%Y-%m-%d\')'); $orderPrice = $model->select()->toArray(); $orderDays = []; $orderCategory = [ ['name'=>'商品数','type'=>'line','data'=>[]], ['name'=>'订单数','type'=>'line','data'=>[]], ['name'=>'订单金额','type'=>'line','data'=>[]], ['name'=>'退款金额','type'=>'line','data'=>[]] ]; foreach ($orderPrice as $price){ $orderDays[] = $price['add_time']; $orderCategory[0]['data'][] = $price['total_num']; $orderCategory[1]['data'][] = $price['count']; $orderCategory[2]['data'][] = $price['total_price']; $orderCategory[3]['data'][] = $price['refund_price']; } $this->assign(StoreOrderModel::systemPage($where,$this->adminId)); $this->assign('price',StoreOrderModel::getOrderPrice($where)); $this->assign(compact('limitTimeList','where','orderCount','orderPrice','orderDays','orderCategory')); return $this->fetch(); } /** * 修改支付金额等 * @param $id * @return mixed|\think\response\Json|void */ public function edit($id) { if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $f = array(); $f[] = Form::input('order_id','订单编号',$product->getData('order_id'))->disabled(1); $f[] = Form::number('total_price','商品总价',$product->getData('total_price'))->min(0); $f[] = Form::number('total_postage','原始邮费',$product->getData('total_postage'))->min(0); $f[] = Form::number('pay_price','实际支付金额',$product->getData('pay_price'))->min(0); $f[] = Form::number('pay_postage','实际支付邮费',$product->getData('pay_postage')); $f[] = Form::number('gain_integral','赠送积分',$product->getData('gain_integral')); // $f[] = Form::radio('status','状态',$product->getData('status'))->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]]); $form = Form::make_post_form('修改订单',$f,Url::build('update',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** 修改订单提交更新 * @param Request $request * @param $id */ public function update(Request $request, $id) { $data = Util::postMore([ 'order_id', 'total_price', 'total_postage', 'pay_price', 'pay_postage', 'gain_integral', ],$request); if($data['total_price'] <= 0) return Json::fail('请输入商品总价'); if($data['pay_price'] <= 0) return Json::fail('请输入实际支付金额'); $data['order_id'] = StoreOrderModel::changeOrderId($data['order_id']); StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_edit',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'order_edit','修改商品总价为:'.$data['total_price'].' 实际支付金额'.$data['pay_price']); return Json::successful('修改成功!'); } /** * 送货 * @param $id * send */ public function delivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1 && $product['status'] == 0) { $f = array(); $f[] = Form::input('delivery_name','送货人姓名')->required('送货人姓名不能为空','required:true;'); $f[] = Form::input('delivery_id','送货人电话')->required('请输入正确电话号码','telephone'); $form = Form::make_post_form('修改订单',$f,Url::build('updateDelivery',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } else return Json::fail('数据不存在!'); } public function updateDelivery(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); $data['delivery_type'] = 'send'; if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); $data['status'] = 1; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_delivery',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'delivery','已配送 发货人:'.$data['delivery_name'].' 发货人电话:'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 发货 * @param $id * express */ public function deliver_goods($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1 && $product['status'] == 0){ $f = array(); $f[] = Form::select('delivery_name','快递公司')->setOptions(function(){ $list = db('express')->where('is_show',1)->order('sort DESC')->column('id,name'); $menus = []; foreach ($list as $k=>$v){ $menus[] = ['value'=>$v,'label'=>$v]; } return $menus; })->filterable(1); $f[] = Form::input('delivery_id','快递单号')->number(1); $form = Form::make_post_form('修改订单',$f,Url::build('updateDeliveryGoods',array('id'=>$id)),2); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } else return Json::fail('数据不存在!'); } /**发货保存 * @param Request $request * @param $id */ public function updateDeliveryGoods(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); $data['delivery_type'] = 'express'; if(!$data['delivery_name']) return Json::fail('请选择快递公司'); if(!$data['delivery_id']) return Json::fail('请输入快递单号'); $data['status'] = 1; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_delivery_goods',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'delivery_goods','已发货 快递公司:'.$data['delivery_name'].' 快递单号:'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 修改状态为已收货 * @param $id * @return \think\response\Json|void */ public function take_delivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['status'] == 2) return Json::fail('不能重复收货!'); if($product['paid'] == 1 && $product['status'] == 1) $data['status'] = 2; else if($product['pay_type'] == 'offline') $data['status'] = 2; else return Json::fail('请先发货或者送货!'); if(!StoreOrderModel::edit($data,$id)) return Json::fail(StoreOrderModel::getErrorInfo('收货失败,请稍候再试!')); else{ try{ HookService::listen('store_product_order_take_delivery',$data,$id,false,StoreProductBehavior::class); }catch (Exception $e){ return Json::fail($e->getMessage()); } StoreOrderStatus::setStatus($id,'take_delivery','已收货'); return Json::successful('收货成功!'); } } /** * 修改退款状态 * @param $id * @return \think\response\Json|void */ public function refund_y($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1){ $f = array(); $f[] = Form::input('order_id','退款单号',$product->getData('order_id'))->disabled(1); $f[] = Form::number('refund_price','退款金额',$product->getData('pay_price'))->precision(2)->min(0.01); $f[] = Form::radio('type','状态',1)->options([['label'=>'直接退款','value'=>1],['label'=>'退款后,返回原状态','value'=>2]]); $form = Form::make_post_form('退款处理',$f,Url::build('updateRefundY',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } else return Json::fail('数据不存在!'); } /**退款处理 * @param Request $request * @param $id */ public function updateRefundY(Request $request, $id){ $data = Util::postMore([ 'refund_price', ['type',1], ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['pay_price'] == $product['refund_price']) return Json::fail('已退完支付金额!不能再退款了'); if(!$data['refund_price']) return Json::fail('请输入退款金额'); $refund_price = $data['refund_price']; $data['refund_price'] = bcadd($data['refund_price'],$product['refund_price'],2); $bj = bccomp((float)$product['pay_price'],(float)$data['refund_price'],2); if($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额'); if($data['type'] == 1){ $data['refund_status'] = 2; }else if($data['type'] == 2){ $data['refund_status'] = 0; } $type = $data['type']; unset($data['type']); $refund_data['pay_price'] = $product['pay_price']; $refund_data['refund_price'] = $refund_price; if($product['pay_type'] == 'weixin'){ if($product['is_channel']){ try{ HookService::listen('routine_pay_order_refund',$product['order_id'],$refund_data,true,PaymentBehavior::class); }catch(\Exception $e){ return Json::fail($e->getMessage()); } }else{ try{ HookService::listen('wechat_pay_order_refund',$product['order_id'],$refund_data,true,PaymentBehavior::class); }catch(\Exception $e){ return Json::fail($e->getMessage()); } } }else if($product['pay_type'] == 'yue'){ ModelBasic::beginTrans(); $res1 = User::bcInc($product['uid'],'now_money',$refund_price,'uid'); $res2 = $res2 = UserBill::income('商品退款',$product['uid'],'now_money','pay_product_refund',$refund_price,$product['id'],$product['pay_price'],'订单退款到余额'.floatval($refund_price).'元'); try{ HookService::listen('store_order_yue_refund',$product,$refund_data,false,StoreProductBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } $res = $res1 && $res2; ModelBasic::checkTrans($res); if(!$res) return Json::fail('余额退款失败!'); } $resEdit = StoreOrderModel::edit($data,$id); if($resEdit){ $data['type'] = $type; if($data['type'] == 1) StorePink::setRefundPink($id); HookService::afterListen('store_product_order_refund_y',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'refund_price','退款给用户'.$refund_price.'元'); return Json::successful('修改成功!'); }else{ StoreOrderStatus::setStatus($id,'refund_price','退款给用户'.$refund_price.'元失败'); return Json::successful('修改失败!'); } } public function order_info($oid = '') { if(!$oid || !($orderInfo = StoreOrderModel::get($oid))) return $this->failed('订单不存在!'); $userInfo = User::getUserInfo($orderInfo['uid']); if($userInfo['spread_uid']){ $spread = User::where('uid',$userInfo['spread_uid'])->value('nickname'); }else{ $spread =''; } $this->assign(compact('orderInfo','userInfo','spread')); return $this->fetch(); } public function express($oid = '') { if(!$oid || !($order = StoreOrderModel::get($oid))) return $this->failed('订单不存在!'); if($order['delivery_type'] != 'express' || !$order['delivery_id']) return $this->failed('该订单不存在快递单号!'); $cacheName = $order['order_id'].$order['delivery_id']; $result = CacheService::get($cacheName,null); if($result === null){ $result = Express::query($order['delivery_id']); if(is_array($result) && isset($result['result']) && isset($result['result']['deliverystatus']) && $result['result']['deliverystatus'] >= 3) $cacheTime = 0; else $cacheTime = 1800; CacheService::set($cacheName,$result,$cacheTime); } $this->assign([ 'order'=>$order, 'express'=>$result ]); return $this->fetch(); } /** * 修改配送信息 * @param $id * @return mixed|\think\response\Json|void */ public function distribution($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $f = array(); $f[] = Form::input('order_id','退款单号',$product->getData('order_id'))->disabled(1); if($product['delivery_type'] == 'send'){ $f[] = Form::input('delivery_name','送货人姓名',$product->getData('delivery_name')); $f[] = Form::input('delivery_id','送货人电话',$product->getData('delivery_id')); }else if($product['delivery_type'] == 'express'){ $f[] = Form::select('delivery_name','快递公司',$product->getData('delivery_name'))->setOptions(function (){ $list = db('express')->where('is_show',1)->column('id,name'); $menus = []; foreach ($list as $k=>$v){ $menus[] = ['value'=>$v,'label'=>$v]; } return $menus; }); $f[] = Form::input('delivery_id','快递单号',$product->getData('delivery_id')); } $form = Form::make_post_form('配送信息',$f,Url::build('updateDistribution',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /**修改配送信息 * @param Request $request * @param $id */ public function updateDistribution(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['delivery_type'] == 'send'){ if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); }else if($product['delivery_type'] == 'express'){ if(!$data['delivery_name']) return Json::fail('请选择快递公司'); if(!$data['delivery_id']) return Json::fail('请输入快递单号'); } StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_distribution',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'distribution','修改发货信息为'.$data['delivery_name'].'号'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 修改退款状态 * @param $id * @return mixed|\think\response\Json|void */ public function refund_n($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $f[] = Form::input('order_id','退款单号',$product->getData('order_id'))->disabled(1); $f[] = Form::input('refund_reason','退款原因')->type('textarea'); $form = Form::make_post_form('退款',$f,Url::build('updateRefundN',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /**不退款原因 * @param Request $request * @param $id */ public function updateRefundN(Request $request, $id){ $data = Util::postMore([ 'refund_reason', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if(!$data['refund_reason']) return Json::fail('请输入退款原因'); $data['refund_status'] = 0; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_refund_n',$data['refund_reason'],$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'refund_n','不退款原因:'.$data['refund_reason']); return Json::successful('修改成功!'); } /** * 立即支付 * @param $id */ public function offline($id){ $res = StoreOrderModel::updateOffline($id); if($res){ try{ HookService::listen('store_product_order_offline',$id,false,StoreProductBehavior::class); }catch (Exception $e){ return Json::fail($e->getMessage()); } StoreOrderStatus::setStatus($id,'offline','线下付款'); return Json::successful('修改成功!'); }else{ return Json::fail('修改失败!'); } } /** * 修改积分和金额 * @param $id * @return mixed|\think\response\Json|void */ public function integral_back($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1){ $f[] = Form::input('order_id','退款单号',$product->getData('order_id'))->disabled(1); $f[] = Form::number('back_integral','退积分')->min(0); $form = Form::make_post_form('退积分',$f,Url::build('updateIntegralBack',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); }else{ return Json::fail('参数错误!'); } return $this->fetch('public/form-builder'); } /** 退积分保存 * @param Request $request * @param $id */ public function updateIntegralBack(Request $request, $id){ $data = Util::postMore([ 'back_integral', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($data['back_integral'] <= 0) return Json::fail('请输入积分'); if($product['use_integral'] == $product['back_integral']) return Json::fail('已退完积分!不能再积分了'); $back_integral = $data['back_integral']; $data['back_integral'] = bcadd($data['back_integral'],$product['back_integral'],2); $bj = bccomp((float)$product['use_integral'],(float)$data['back_integral'],2); if($bj < 0) return Json::fail('退积分大于支付积分,请修改退积分'); ModelBasic::beginTrans(); $res1 = User::bcInc($product['uid'],'integral',$back_integral,'uid'); $res2 = UserBill::income('商品退积分',$product['uid'],'integral','pay_product_integral_back',$back_integral,$product['id'],$product['pay_price'],'订单退积分'.floatval($back_integral).'积分到用户积分'); try{ HookService::listen('store_order_integral_back',$product,$back_integral,false,StoreProductBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } $res = $res1 && $res2; ModelBasic::checkTrans($res); if(!$res) return Json::fail('退积分失败!'); StoreOrderModel::edit($data,$id); StoreOrderStatus::setStatus($id,'integral_back','商品退积分:'.$data['back_integral']); return Json::successful('退积分成功!'); } public function remark(Request $request){ $data = Util::postMore(['id','remark'],$request); if(!$data['id']) return Json::fail('参数错误!'); if($data['remark'] == '') return Json::fail('请输入要备注的内容!'); $id = $data['id']; unset($data['id']); StoreOrderModel::edit($data,$id); return Json::successful('备注成功!'); } public function order_status($oid){ if(!$oid) return $this->failed('数据不存在'); $this->assign(StoreOrderStatus::systemPage($oid)); return $this->fetch(); } } \ No newline at end of file + * @day: 2017/11/11 */ namespace app\admin\controller\order; use basic\ModelBasic; use Api\Express; use app\admin\controller\AuthController; use service\FormBuilder as Form; use app\admin\model\order\StoreOrderStatus; use app\admin\model\ump\StorePink; use app\admin\model\user\User; use app\admin\model\user\UserBill; use behavior\system\OrderBehavior; use behavior\wechat\PaymentBehavior; use EasyWeChat\Core\Exception; use service\CacheService; use service\HookService; use service\JsonService; use service\SystemConfigService; use service\UtilService as Util; use service\JsonService as Json; use think\Db; use think\Request; use think\Url; use app\admin\model\order\StoreOrder as StoreOrderModel; /** * 订单管理控制器 同一个订单表放在一个控制器 * Class StoreOrder * @package app\admin\controller\store */ class StoreOrder extends AuthController { /** * @return mixed */ public function index() { $config = SystemConfigService::more(['pay_routine_appid','pay_routine_appsecret','pay_routine_mchid','pay_routine_key','pay_routine_client_cert','pay_routine_client_key']); $this->assign([ 'year'=>getMonth('y'), 'real_name'=>$this->request->get('real_name',''), 'orderCount'=>StoreOrderModel::orderCount(), ]); return $this->fetch(); } /** * 获取头部订单金额等信息 * return json * */ public function getBadge(){ $where = Util::postMore([ ['status',''], ['real_name',''], ['is_del',0], ['data',''], ['type',''], ['order',''] ]); return JsonService::successful(StoreOrderModel::getBadge($where)); } /** * 获取订单列表 * return json */ public function order_list(){ $where = Util::getMore([ ['status',''], ['real_name',$this->request->param('real_name','')], ['is_del',0], ['data',''], ['type',''], ['order',''], ['page',1], ['limit',20], ['excel',0] ]); return JsonService::successlayui(StoreOrderModel::OrderList($where)); } public function orderchart(){ $where = Util::getMore([ ['status',''], ['real_name',''], ['is_del',0], ['data',''], ['combination_id',''], ['export',0], ['order','id desc'] ],$this->request); $limitTimeList = [ 'today'=>implode(' - ',[date('Y/m/d'),date('Y/m/d',strtotime('+1 day'))]), 'week'=>implode(' - ',[ date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)), date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)) ]), 'month'=>implode(' - ',[date('Y/m').'/01',date('Y/m').'/'.date('t')]), 'quarter'=>implode(' - ',[ date('Y').'/'.(ceil((date('n'))/3)*3-3+1).'/01', date('Y').'/'.(ceil((date('n'))/3)*3).'/'.date('t',mktime(0,0,0,(ceil((date('n'))/3)*3),1,date('Y'))) ]), 'year'=>implode(' - ',[ date('Y').'/01/01',date('Y/m/d',strtotime(date('Y').'/01/01 + 1year -1 day')) ]) ]; if($where['data'] == '') $where['data'] = $limitTimeList['today']; $orderCount = [ urlencode('未支付')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(0))->count(), urlencode('未发货')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(1))->count(), urlencode('待收货')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(2))->count(), urlencode('待评价')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(3))->count(), urlencode('交易完成')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(4))->count(), urlencode('退款中')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(-1))->count(), urlencode('已退款')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(-2))->count() ]; $model = StoreOrderModel::getOrderWhere($where,new StoreOrderModel())->field('sum(total_num) total_num,count(*) count,sum(total_price) total_price,sum(refund_price) refund_price,from_unixtime(add_time,\'%Y-%m-%d\') add_time') ->group('from_unixtime(add_time,\'%Y-%m-%d\')'); $orderPrice = $model->select()->toArray(); $orderDays = []; $orderCategory = [ ['name'=>'商品数','type'=>'line','data'=>[]], ['name'=>'订单数','type'=>'line','data'=>[]], ['name'=>'订单金额','type'=>'line','data'=>[]], ['name'=>'退款金额','type'=>'line','data'=>[]] ]; foreach ($orderPrice as $price){ $orderDays[] = $price['add_time']; $orderCategory[0]['data'][] = $price['total_num']; $orderCategory[1]['data'][] = $price['count']; $orderCategory[2]['data'][] = $price['total_price']; $orderCategory[3]['data'][] = $price['refund_price']; } $this->assign(StoreOrderModel::systemPage($where,$this->adminId)); $this->assign('price',StoreOrderModel::getOrderPrice($where)); $this->assign(compact('limitTimeList','where','orderCount','orderPrice','orderDays','orderCategory')); return $this->fetch(); } /** * 修改支付金额等 * @param $id * @return mixed|\think\response\Json|void */ public function edit($id) { if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $f = array(); $f[] = Form::input('order_id','订单编号',$product->getData('order_id'))->disabled(1); $f[] = Form::number('total_price','商品总价',$product->getData('total_price'))->min(0); $f[] = Form::number('total_postage','原始邮费',$product->getData('total_postage'))->min(0); $f[] = Form::number('pay_price','实际支付金额',$product->getData('pay_price'))->min(0); $f[] = Form::number('pay_postage','实际支付邮费',$product->getData('pay_postage')); $f[] = Form::number('gain_integral','赠送积分',$product->getData('gain_integral')); // $f[] = Form::radio('status','状态',$product->getData('status'))->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]]); $form = Form::make_post_form('修改订单',$f,Url::build('update',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** 修改订单提交更新 * @param Request $request * @param $id */ public function update(Request $request, $id) { $data = Util::postMore([ 'order_id', 'total_price', 'total_postage', 'pay_price', 'pay_postage', 'gain_integral', ],$request); if($data['total_price'] <= 0) return Json::fail('请输入商品总价'); if($data['pay_price'] <= 0) return Json::fail('请输入实际支付金额'); $data['order_id'] = StoreOrderModel::changeOrderId($data['order_id']); StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_edit',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'order_edit','修改商品总价为:'.$data['total_price'].' 实际支付金额'.$data['pay_price']); return Json::successful('修改成功!'); } /** * 送货 * @param $id * send */ public function delivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1 && $product['status'] == 0) { $f = array(); $f[] = Form::input('delivery_name','送货人姓名')->required('送货人姓名不能为空','required:true;'); $f[] = Form::input('delivery_id','送货人电话')->required('请输入正确电话号码','telephone'); $form = Form::make_post_form('修改订单',$f,Url::build('updateDelivery',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } else return Json::fail('数据不存在!'); } /**送货 * @param Request $request * @param $id */ public function updateDelivery(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); $data['delivery_type'] = 'send'; if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); $data['status'] = 1; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_delivery',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'delivery','已配送 发货人:'.$data['delivery_name'].' 发货人电话:'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 发货 * @param $id * express */ public function deliver_goods($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1 && $product['status'] == 0){ $f = array(); $f[] = Form::select('delivery_name','快递公司')->setOptions(function(){ $list = Db::name('express')->where('is_show',1)->order('sort DESC')->column('id,name'); $menus = []; foreach ($list as $k=>$v){ $menus[] = ['value'=>$v,'label'=>$v]; } return $menus; })->filterable(1); $f[] = Form::input('delivery_id','快递单号')->number(1); $form = Form::make_post_form('修改订单',$f,Url::build('updateDeliveryGoods',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } else return Json::fail('数据不存在!'); } /**发货保存 * @param Request $request * @param $id */ public function updateDeliveryGoods(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); $data['delivery_type'] = 'express'; if(!$data['delivery_name']) return Json::fail('请选择快递公司'); if(!$data['delivery_id']) return Json::fail('请输入快递单号'); $data['status'] = 1; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_delivery_goods',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'delivery_goods','已发货 快递公司:'.$data['delivery_name'].' 快递单号:'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 修改状态为已收货 * @param $id * @return \think\response\Json|void */ public function take_delivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['status'] == 2) return Json::fail('不能重复收货!'); if($product['paid'] == 1 && $product['status'] == 1) $data['status'] = 2; else if($product['pay_type'] == 'offline') $data['status'] = 2; else return Json::fail('请先发货或者送货!'); if(!StoreOrderModel::edit($data,$id)) return Json::fail(StoreOrderModel::getErrorInfo('收货失败,请稍候再试!')); else{ try{ HookService::listen('store_product_order_take_delivery',$data,$id,false,OrderBehavior::class); }catch (Exception $e){ return Json::fail($e->getMessage()); } StoreOrderStatus::setStatus($id,'take_delivery','已收货'); return Json::successful('收货成功!'); } } /** * 修改退款状态 * @param $id * @return \think\response\Json|void */ public function refund_y($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1){ $f = array(); $f[] = Form::input('order_id','退款单号',$product->getData('order_id'))->disabled(1); $f[] = Form::number('refund_price','退款金额',$product->getData('pay_price'))->precision(2)->min(0.01); $f[] = Form::radio('type','状态',1)->options([['label'=>'直接退款','value'=>1],['label'=>'退款后,返回原状态','value'=>2]]); $form = Form::make_post_form('退款处理',$f,Url::build('updateRefundY',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } else return Json::fail('数据不存在!'); } /**退款处理 * @param Request $request * @param $id */ public function updateRefundY(Request $request, $id){ $data = Util::postMore([ 'refund_price', ['type',1], ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['pay_price'] == $product['refund_price']) return Json::fail('已退完支付金额!不能再退款了'); if(!$data['refund_price']) return Json::fail('请输入退款金额'); $refund_price = $data['refund_price']; $data['refund_price'] = bcadd($data['refund_price'],$product['refund_price'],2); $bj = bccomp((float)$product['pay_price'],(float)$data['refund_price'],2); if($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额'); if($data['type'] == 1){ $data['refund_status'] = 2; }else if($data['type'] == 2){ $data['refund_status'] = 0; } $type = $data['type']; unset($data['type']); $refund_data['pay_price'] = $product['pay_price']; $refund_data['refund_price'] = $refund_price; if($product['pay_type'] == 'weixin'){ if($product['is_channel']){ try{ HookService::listen('routine_pay_order_refund',$product['order_id'],$refund_data,true,PaymentBehavior::class); }catch(\Exception $e){ return Json::fail($e->getMessage()); } }else{ try{ HookService::listen('wechat_pay_order_refund',$product['order_id'],$refund_data,true,PaymentBehavior::class); }catch(\Exception $e){ return Json::fail($e->getMessage()); } } }else if($product['pay_type'] == 'yue'){ ModelBasic::beginTrans(); $res1 = User::bcInc($product['uid'],'now_money',$refund_price,'uid'); $res2 = $res2 = UserBill::income('商品退款',$product['uid'],'now_money','pay_product_refund',$refund_price,$product['id'],$product['pay_price'],'订单退款到余额'.floatval($refund_price).'元'); try{ HookService::listen('store_order_yue_refund',$product,$refund_data,false,OrderBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } $res = $res1 && $res2; ModelBasic::checkTrans($res); if(!$res) return Json::fail('余额退款失败!'); } $resEdit = StoreOrderModel::edit($data,$id); if($resEdit){ $data['type'] = $type; if($data['type'] == 1) StorePink::setRefundPink($id); HookService::afterListen('store_product_order_refund_y',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'refund_price','退款给用户'.$refund_price.'元'); return Json::successful('修改成功!'); }else{ StoreOrderStatus::setStatus($id,'refund_price','退款给用户'.$refund_price.'元失败'); return Json::successful('修改失败!'); } } public function order_info($oid = '') { if(!$oid || !($orderInfo = StoreOrderModel::get($oid))) return $this->failed('订单不存在!'); $userInfo = User::getUserInfos($orderInfo['uid']); if($userInfo['spread_uid']){ $spread = User::where('uid',$userInfo['spread_uid'])->value('nickname'); }else{ $spread =''; } $this->assign(compact('orderInfo','userInfo','spread')); return $this->fetch(); } public function express($oid = '') { if(!$oid || !($order = StoreOrderModel::get($oid))) return $this->failed('订单不存在!'); if($order['delivery_type'] != 'express' || !$order['delivery_id']) return $this->failed('该订单不存在快递单号!'); $cacheName = $order['order_id'].$order['delivery_id']; $result = CacheService::get($cacheName,null); if($result === null || 1==1){ $result = Express::query($order['delivery_id']); if(is_array($result) && isset($result['result']) && isset($result['result']['deliverystatus']) && $result['result']['deliverystatus'] >= 3) $cacheTime = 0; else $cacheTime = 1800; CacheService::set($cacheName,$result,$cacheTime); } $this->assign([ 'order'=>$order, 'express'=>$result ]); return $this->fetch(); } /** * 修改配送信息 * @param $id * @return mixed|\think\response\Json|void */ public function distribution($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $f = array(); $f[] = Form::input('order_id','退款单号',$product->getData('order_id'))->disabled(1); if($product['delivery_type'] == 'send'){ $f[] = Form::input('delivery_name','送货人姓名',$product->getData('delivery_name')); $f[] = Form::input('delivery_id','送货人电话',$product->getData('delivery_id')); }else if($product['delivery_type'] == 'express'){ $f[] = Form::select('delivery_name','快递公司',$product->getData('delivery_name'))->setOptions(function (){ $list = Db::name('express')->where('is_show',1)->column('id,name'); $menus = []; foreach ($list as $k=>$v){ $menus[] = ['value'=>$v,'label'=>$v]; } return $menus; }); $f[] = Form::input('delivery_id','快递单号',$product->getData('delivery_id')); } $form = Form::make_post_form('配送信息',$f,Url::build('updateDistribution',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /**修改配送信息 * @param Request $request * @param $id */ public function updateDistribution(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['delivery_type'] == 'send'){ if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); }else if($product['delivery_type'] == 'express'){ if(!$data['delivery_name']) return Json::fail('请选择快递公司'); if(!$data['delivery_id']) return Json::fail('请输入快递单号'); } StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_distribution',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'distribution','修改发货信息为'.$data['delivery_name'].'号'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 修改退款状态 * @param $id * @return mixed|\think\response\Json|void */ public function refund_n($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $f[] = Form::input('order_id','退款单号',$product->getData('order_id'))->disabled(1); $f[] = Form::input('refund_reason','退款原因')->type('textarea'); $form = Form::make_post_form('退款',$f,Url::build('updateRefundN',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /**不退款原因 * @param Request $request * @param $id */ public function updateRefundN(Request $request, $id){ $data = Util::postMore([ 'refund_reason', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if(!$data['refund_reason']) return Json::fail('请输入退款原因'); $data['refund_status'] = 0; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_refund_n',$data['refund_reason'],$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'refund_n','不退款原因:'.$data['refund_reason']); return Json::successful('修改成功!'); } /** * 立即支付 * @param $id */ public function offline($id){ $res = StoreOrderModel::updateOffline($id); if($res){ try{ HookService::listen('store_product_order_offline',$id,false,OrderBehavior::class); }catch (Exception $e){ return Json::fail($e->getMessage()); } StoreOrderStatus::setStatus($id,'offline','线下付款'); return Json::successful('修改成功!'); }else{ return Json::fail('修改失败!'); } } /** * 修改积分和金额 * @param $id * @return mixed|\think\response\Json|void */ public function integral_back($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1){ $f[] = Form::input('order_id','退款单号',$product->getData('order_id'))->disabled(1); $f[] = Form::number('back_integral','退积分')->min(0); $form = Form::make_post_form('退积分',$f,Url::build('updateIntegralBack',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); }else{ return Json::fail('参数错误!'); } return $this->fetch('public/form-builder'); } /** 退积分保存 * @param Request $request * @param $id */ public function updateIntegralBack(Request $request, $id){ $data = Util::postMore([ 'back_integral', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($data['back_integral'] <= 0) return Json::fail('请输入积分'); if($product['use_integral'] == $product['back_integral']) return Json::fail('已退完积分!不能再积分了'); $back_integral = $data['back_integral']; $data['back_integral'] = bcadd($data['back_integral'],$product['back_integral'],2); $bj = bccomp((float)$product['use_integral'],(float)$data['back_integral'],2); if($bj < 0) return Json::fail('退积分大于支付积分,请修改退积分'); ModelBasic::beginTrans(); $res1 = User::bcInc($product['uid'],'integral',$back_integral,'uid'); $res2 = UserBill::income('商品退积分',$product['uid'],'integral','pay_product_integral_back',$back_integral,$product['id'],$product['pay_price'],'订单退积分'.floatval($back_integral).'积分到用户积分'); try{ HookService::listen('store_order_integral_back',$product,$back_integral,false,OrderBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } $res = $res1 && $res2; ModelBasic::checkTrans($res); if(!$res) return Json::fail('退积分失败!'); StoreOrderModel::edit($data,$id); StoreOrderStatus::setStatus($id,'integral_back','商品退积分:'.$data['back_integral']); return Json::successful('退积分成功!'); } public function remark(Request $request){ $data = Util::postMore(['id','remark'],$request); if(!$data['id']) return Json::fail('参数错误!'); if($data['remark'] == '') return Json::fail('请输入要备注的内容!'); $id = $data['id']; unset($data['id']); StoreOrderModel::edit($data,$id); return Json::successful('备注成功!'); } public function order_status($oid){ if(!$oid) return $this->failed('数据不存在'); $this->assign(StoreOrderStatus::systemPage($oid)); return $this->fetch(); } } \ No newline at end of file diff --git a/application/admin/controller/order/StoreOrderPink.php b/application/admin/controller/order/StoreOrderPink.php deleted file mode 100644 index a10a36f60..000000000 --- a/application/admin/controller/order/StoreOrderPink.php +++ /dev/null @@ -1 +0,0 @@ -request); $this->assign('where',$where); $this->assign(StorePink::systemPage($where)); return $this->fetch(); } 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 $id * @return mixed|\think\response\Json|void */ public function edit($id) { if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $this->assign([ 'title'=>'修改订单','rules'=>$this->read($id)->getContent(), 'action'=>Url::build('update',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } public function read($id) { if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); FormBuilder::text('order_id','订单编号',$product->getData('order_id'))->readonly(); FormBuilder::number('total_price','商品总价',$product->getData('total_price'))->min(0); FormBuilder::number('total_postage','原始邮费',$product->getData('total_postage'))->min(0); FormBuilder::number('pay_price','实际支付金额',$product->getData('pay_price'))->min(0); FormBuilder::number('pay_postage','实际支付邮费',$product->getData('pay_postage'))->min(0); FormBuilder::number('gain_integral','赠送积分',$product->getData('gain_integral'))->min(0); return FormBuilder::builder(); } public function update(Request $request, $id) { $data = Util::postMore([ 'order_id', 'total_price', 'total_postage', 'pay_price', 'pay_postage', 'gain_integral', ],$request); if($data['total_price'] <= 0) return Json::fail('请输入商品总价'); if($data['pay_price'] <= 0) return Json::fail('请输入实际支付金额'); $data['order_id'] = StoreOrderModel::changeOrderId($data['order_id']); StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_edit',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'order_edit','修改商品总价为:'.$data['total_price'].' 实际支付金额'.$data['pay_price']); return Json::successful('修改成功!'); } /** * 送货 * @param $id * send */ public function delivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1 && $product['status'] == 0) { $this->assign([ 'title' => '送货信息', 'rules' => $this->readDelivery($id)->getContent(), 'action' => Url::build('updateDelivery', array('id' => $id)) ]); return $this->fetch('public/common_form'); } else return Json::fail('数据不存在!'); } public function readDelivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); FormBuilder::text('delivery_name','送货人姓名'); FormBuilder::text('delivery_id','送货人电话')->number(); return FormBuilder::builder(); } public function updateDelivery(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); $data['delivery_type'] = 'send'; if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); $data['status'] = 1; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_delivery',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'delivery','已配送 发货人:'.$data['delivery_name'].' 发货人电话:'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 发货 * @param $id * express */ public function deliver_goods($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1 && $product['status'] == 0){ $this->assign([ 'title'=>'发货信息','rules'=>$this->readDeliveryGoods($id)->getContent(), 'action'=>Url::build('updateDeliveryGoods',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } else return Json::fail('数据不存在!'); } public function readDeliveryGoods($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); FormBuilder::select('delivery_name','快递公司',function(){ $list = db('express')->where('is_show',1)->column('id,name'); $menus = []; foreach ($list as $k=>$v){ $menus[] = ['value'=>$v,'label'=>$v]; } return $menus; })->filterable(); FormBuilder::text('delivery_id','快递单号'); return FormBuilder::builder(); } public function updateDeliveryGoods(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); $data['delivery_type'] = 'express'; if(!$data['delivery_name']) return Json::fail('请选择快递公司'); if(!$data['delivery_id']) return Json::fail('请输入快递单号'); $data['status'] = 1; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_delivery_goods',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'delivery_goods','已发货 快递公司:'.$data['delivery_name'].' 快递单号:'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 修改状态为已收货 * @param $id * @return \think\response\Json|void */ public function take_delivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['status'] == 2) return Json::fail('不能重复收货!'); if($product['paid'] == 1 && $product['status'] == 1) $data['status'] = 2; else if($product['pay_type'] == 'offline') $data['status'] = 2; else return Json::fail('请先发货或者送货!'); if(!StoreOrderModel::edit($data,$id)) return Json::fail(StoreOrderModel::getErrorInfo('收货失败,请稍候再试!')); else{ try{ HookService::listen('store_product_order_take_delivery',$data,$id,false,StoreProductBehavior::class); }catch (Exception $e){ return Json::fail($e->getMessage()); } StoreOrderStatus::setStatus($id,'take_delivery','已收货'); return Json::successful('收货成功!'); } } /** * 修改退款状态 * @param $id * @return \think\response\Json|void */ public function refund_y($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1){ $this->assign([ 'title'=>'退款','rules'=>$this->readRefundY($id)->getContent(), 'action'=>Url::build('updateRefundY',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } else return Json::fail('数据不存在!'); } public function readRefundY($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); FormBuilder::text('order_id','退款单号',$product->getData('order_id'))->readonly(); FormBuilder::number('refund_price','退款金额',$product->getData('pay_price'))->min(0); FormBuilder::radio('type','状态',[['label'=>'直接退款','value'=>1],['label'=>'退款后,返回原状态','value'=>2]],1); return FormBuilder::builder(); } public function updateRefundY(Request $request, $id){ $data = Util::postMore([ 'refund_price', ['type',1], ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['pay_price'] == $product['refund_price']) return Json::fail('已退完支付金额!不能再退款了'); if(!$data['refund_price']) return Json::fail('请输入退款金额'); $refund_price = $data['refund_price']; $data['refund_price'] = bcadd($data['refund_price'],$product['refund_price'],2); $bj = bccomp((float)$product['pay_price'],(float)$data['refund_price'],2); if($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额'); if($data['type'] == 1){ $data['refund_status'] = 2; }else if($data['type'] == 2){ $data['refund_status'] = 0; } $type = $data['type']; unset($data['type']); $refund_data['pay_price'] = $product['pay_price']; $refund_data['refund_price'] = $refund_price; if($product['pay_type'] == 'weixin'){ try{ HookService::listen('wechat_pay_order_refund',$product['order_id'],$refund_data,true,PaymentBehavior::class); }catch(\Exception $e){ return Json::fail($e->getMessage()); } }else if($product['pay_type'] == 'yue'){ ModelBasic::beginTrans(); $res1 = User::bcInc($product['uid'],'now_money',$refund_price,'uid'); $res2 = $res2 = UserBill::income('商品退款',$product['uid'],'now_money','pay_product_refund',$refund_price,$product['id'],$product['pay_price'],'订单退款到余额'.floatval($refund_price).'元'); try{ HookService::listen('store_order_yue_refund',$product,$refund_data,false,StoreProductBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } $res = $res1 && $res2; ModelBasic::checkTrans($res); if(!$res) return Json::fail('余额退款失败!'); } StoreOrderModel::edit($data,$id); $data['type'] = $type; HookService::afterListen('store_product_order_refund_y',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'refund_price','退款给用户'.$refund_price.'元'); return Json::successful('修改成功!'); } /** * 修改配送信息 * @param $id * @return mixed|\think\response\Json|void */ public function distribution($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $this->assign([ 'title'=>'配送信息','rules'=>$this->readDistribution($id)->getContent(), 'action'=>Url::build('updateDistribution',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } public function readDistribution($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['delivery_type'] == 'send'){ FormBuilder::text('delivery_name','送货人姓名',$product->getData('delivery_name')); FormBuilder::text('delivery_id','送货人电话',$product->getData('delivery_id'))->number(); }else if($product['delivery_type'] == 'express'){ FormBuilder::select('delivery_name','快递公司',function(){ $list = db('express')->where('is_show',1)->column('id,name'); $menus = []; foreach ($list as $k=>$v){ $menus[] = ['value'=>$v,'label'=>$v]; } return $menus; },$product->getData('delivery_name'))->filterable(); FormBuilder::text('delivery_id','快递单号',$product->getData('delivery_id')); } return FormBuilder::builder(); } public function updateDistribution(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['delivery_type'] == 'send'){ if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); }else if($product['delivery_type'] == 'express'){ if(!$data['delivery_name']) return Json::fail('请选择快递公司'); if(!$data['delivery_id']) return Json::fail('请输入快递单号'); } StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_distribution',$data,$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'distribution','修改发货信息为'.$data['delivery_name'].'号'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 修改退款状态 * @param $id * @return mixed|\think\response\Json|void */ public function refund_n($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $this->assign([ 'title'=>'退款','rules'=>$this->readRefundN($id)->getContent(), 'action'=>Url::build('updateRefundN',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } public function readRefundN($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); FormBuilder::text('order_id','退款单号',$product->getData('order_id'))->readonly(); FormBuilder::textarea('refund_reason','退款原因'); return FormBuilder::builder(); } public function updateRefundN(Request $request, $id){ $data = Util::postMore([ 'refund_reason', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if(!$data['refund_reason']) return Json::fail('请输入退款原因'); $data['refund_status'] = 0; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_refund_n',$data['refund_reason'],$id,false,StoreProductBehavior::class); StoreOrderStatus::setStatus($id,'refund_n','不退款原因:'.$data['refund_reason']); return Json::successful('修改成功!'); } /** * 立即支付 * @param $id */ public function offline($id){ $res = StoreOrderModel::updateOffline($id); if($res){ try{ HookService::listen('store_product_order_offline',$id,false,StoreProductBehavior::class); }catch (Exception $e){ return Json::fail($e->getMessage()); } StoreOrderStatus::setStatus($id,'offline','线下付款'); return Json::successful('修改成功!'); }else{ return Json::fail('修改失败!'); } } /** * 修改积分和金额 * @param $id * @return mixed|\think\response\Json|void */ public function integral_back($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1){ $this->assign([ 'title'=>'退积分','rules'=>$this->readIntegralBack($id)->getContent(), 'action'=>Url::build('updateIntegralBack',array('id'=>$id)) ]); }else{ return Json::fail('参数错误!'); } return $this->fetch('public/common_form'); } public function readIntegralBack($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); FormBuilder::text('order_id','退积分单号',$product->getData('order_id'))->readonly(); FormBuilder::number('back_integral','退积分')->min(0); return FormBuilder::builder(); } public function updateIntegralBack(Request $request, $id){ $data = Util::postMore([ 'back_integral', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($data['back_integral'] <= 0) return Json::fail('请输入积分'); if($product['use_integral'] == $product['back_integral']) return Json::fail('已退完积分!不能再积分了'); $back_integral = $data['back_integral']; $data['back_integral'] = bcadd($data['back_integral'],$product['back_integral'],2); $bj = bccomp((float)$product['use_integral'],(float)$data['back_integral'],2); if($bj < 0) return Json::fail('退积分大于支付积分,请修改退积分'); ModelBasic::beginTrans(); $res1 = User::bcInc($product['uid'],'integral',$back_integral,'uid'); $res2 = UserBill::income('商品退积分',$product['uid'],'integral','pay_product_integral_back',$back_integral,$product['id'],$product['pay_price'],'订单退积分'.floatval($back_integral).'积分到用户积分'); try{ HookService::listen('store_order_integral_back',$product,$back_integral,false,StoreProductBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } $res = $res1 && $res2; ModelBasic::checkTrans($res); if(!$res) return Json::fail('退积分失败!'); StoreOrderModel::edit($data,$id); StoreOrderStatus::setStatus($id,'integral_back','商品退积分:'.$data['back_integral']); return Json::successful('退积分成功!'); } public function remark(Request $request){ $data = Util::postMore(['id','remark'],$request); if(!$data['id']) return Json::fail('参数错误!'); if($data['remark'] == '') return Json::fail('请输入要备注的内容!'); $id = $data['id']; unset($data['id']); StoreOrderModel::edit($data,$id); return Json::successful('备注成功!'); } public function order_status($oid){ if(!$oid) return $this->failed('数据不存在'); $this->assign(StoreOrderStatus::systemPage($oid)); return $this->fetch(); } } \ No newline at end of file diff --git a/application/admin/controller/setting/SystemConfig.php b/application/admin/controller/setting/SystemConfig.php index 1cd15aff6..8ba46bda1 100644 --- a/application/admin/controller/setting/SystemConfig.php +++ b/application/admin/controller/setting/SystemConfig.php @@ -1 +1 @@ -assign('tab_id',$tab_id); $list = ConfigModel::getAll($tab_id); if($type==3){//其它分类 $config_tab = null; }else{ $config_tab = ConfigModel::getConfigTabAll($type); foreach ($config_tab as $kk=>$vv){ $arr = ConfigModel::getAll($vv['value'])->toArray(); if(empty($arr)){ unset($config_tab[$kk]); } } } $this->assign('config_tab',$config_tab); $this->assign('list',$list); return $this->fetch(); } /** * 添加字段 * */ public function create(Request $request){ $data = Util::getMore(['type',],$request);//接收参数 $tab_id = !empty($request->param('tab_id'))?$request->param('tab_id'):1; $formbuider = array(); switch ($data['type']){ case 0://文本框 $formbuider = ConfigModel::createInputRule($tab_id); break; case 1://多行文本框 $formbuider = ConfigModel::createTextAreaRule($tab_id); break; case 2://单选框 $formbuider = ConfigModel::createRadioRule($tab_id); break; case 3://文件上传 $formbuider = ConfigModel::createUploadRule($tab_id); break; case 4://多选框 $formbuider = ConfigModel::createCheckboxRule($tab_id); break; } $form = Form::make_post_form('添加字段',$formbuider,Url::build('save')); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * 保存字段 * */ public function save(Request $request){ $data = Util::postMore([ 'menu_name', 'type', 'config_tab_id', 'parameter', 'upload_type', 'required', 'width', 'high', 'value', 'info', 'desc', 'sort', 'status',],$request); if(!$data['info']) return Json::fail('请输入配置名称'); if(!$data['menu_name']) return Json::fail('请输入字段名称'); if($data['menu_name']){ $oneConfig = ConfigModel::getOneConfig('menu_name',$data['menu_name']); if(!empty($oneConfig)) return Json::fail('请重新输入字段名称,之前的已经使用过了'); } if(!$data['desc']) return Json::fail('请输入配置简介'); if($data['sort'] < 0){ $data['sort'] = 0; } if($data['type'] == 'text'){ if(!ConfigModel::valiDateTextRole($data)) return Json::fail(ConfigModel::getErrorInfo()); } if($data['type'] == 'textarea'){ if(!ConfigModel::valiDateTextareaRole($data)) return Json::fail(ConfigModel::getErrorInfo()); } if($data['type'] == 'radio' || $data['type'] == 'checkbox'){ if(!$data['parameter']) return Json::fail('请输入配置参数'); if(!ConfigModel::valiDateRadioAndCheckbox($data)) return Json::fail(ConfigModel::getErrorInfo()); $data['value'] = json_encode($data['value']); } ConfigModel::set($data); return Json::successful('添加菜单成功!'); } /** * @param Request $request * @param $id * @return \think\response\Json */ public function update_config(Request $request, $id) { $data = Util::postMore(['status','info','desc','sort','config_tab_id','required','parameter','value','upload_type'],$request); if(!ConfigModel::get($id)) return Json::fail('编辑的记录不存在!'); ConfigModel::edit($data,$id); return Json::successful('修改成功!'); } /** * 修改是否显示子子段 * @param $id * @return mixed */ public function edit_cinfig($id){ $menu = ConfigModel::get($id)->getData(); if(!$menu) return Json::fail('数据不存在!'); $formbuider = array(); $formbuider[] = Form::input('menu_name','字段变量',$menu['menu_name'])->disabled(1); $formbuider[] = Form::select('config_tab_id','分类',(string)$menu['config_tab_id'])->setOptions(ConfigModel::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称',$menu['info'])->autofocus(1); $formbuider[] = Form::input('desc','配置简介',$menu['desc']); //输入框验证规则 if(!empty($menu['required'])){ $formbuider[] = Form::input('value','默认值',$menu['value']); $formbuider[] = Form::number('width','文本框宽(%)',$menu['width']); $formbuider[] = Form::input('required','验证规则',$menu['required'])->placeholder('多个请用,隔开例如:required:true,url:true'); } //多行文本 if(!empty($menu['high'])){ $formbuider[] = Form::textarea('value','默认值',$menu['value'])->rows(5); $formbuider[] = Form::number('width','文本框宽(%)',$menu['width']); $formbuider[] = Form::number('high','多行文本框高(%)',$menu['high']); }else{ $formbuider[] = Form::input('value','默认值',$menu['value']); } //单选和多选参数配置 if(!empty($menu['parameter'])){ $formbuider[] = Form::textarea('parameter','配置参数',$menu['parameter'])->placeholder("参数方式例如:\n1=白色\n2=红色\n3=黑色"); } //上传类型选择 if(!empty($menu['upload_type'])){ $formbuider[] = Form::radio('upload_type','上传类型',$menu['upload_type'])->options([['value'=>1,'label'=>'单图'],['value'=>2,'label'=>'多图'],['value'=>3,'label'=>'文件']]); } $formbuider[] = Form::number('sort','排序',$menu['sort']); $formbuider[] = Form::radio('status','状态',$menu['status'])->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); $form = Form::make_post_form('编辑字段',$formbuider,Url::build('update_config',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); // $this->assign(['title'=>'编辑菜单','read'=>Url::build('read_config',array('id'=>$id)),'update'=>Url::build('update_config',array('id'=>$id))]); // return $this->fetch(); } /** * 删除子字段 * @return \think\response\Json */ public function delete_cinfig(){ $id = input('id'); if(!ConfigModel::del($id)) return Json::fail(ConfigModel::getErrorInfo('删除失败,请稍候再试!')); else return Json::successful('删除成功!'); } /** * 保存数据 true * */ public function save_basics(){ $request = Request::instance(); if($request->isPost()){ $post = $request->post(); $tab_id = $post['tab_id']; unset($post['tab_id']); foreach ($post as $k=>$v){ if(is_array($v)){ $res = ConfigModel::where('menu_name',$k)->column('type,upload_type'); foreach ($res as $kk=>$vv){ if($kk == 'upload'){ if($vv == 1 || $vv == 3){ $post[$k] = $v[0]; } } } } } foreach ($post as $k=>$v){ ConfigModel::edit(['value' => json_encode($v)],$k,'menu_name'); } return $this->successfulNotice('修改成功'); } } /** * 模板表单提交 * */ public function view_upload(){ if($_POST['type'] == 3){ $res = Upload::file($_POST['file'],'config/file'); }else{ $res = Upload::Image($_POST['file'],'config/image'); } if(!$res->status) return Json::fail($res->error); if(strpos(PUBILC_PATH,'public') == false){ $res->dir = str_replace('public/','',$res->dir); } return Json::successful('上传成功!',['url'=>$res->dir]); } /** * 基础配置 单个 * @return mixed|void */ public function index_alone(){ $tab_id = input('tab_id'); if(!$tab_id) return $this->failed('参数错误,请重新打开'); $this->assign('tab_id',$tab_id); $list = ConfigModel::getAll($tab_id); $config_tab = ConfigModel::getConfigTabAll(); foreach ($config_tab as $kk=>$vv){ $arr = ConfigModel::getAll($vv['value'])->toArray(); if(empty($arr)){ unset($config_tab[$kk]); } } $this->assign('config_tab',$config_tab); $this->assign('list',$list); return $this->fetch(); } /** * 保存数据 单个 * @return mixed */ public function save_basics_alone(){ $request = Request::instance(); if($request->isPost()){ $post = $request->post(); $tab_id = $post['tab_id']; unset($post['tab_id']); foreach ($post as $k=>$v){ ConfigModel::edit(['value' => json_encode($v)],$k,'menu_name'); } return $this->successfulNotice('修改成功'); } } /** * 获取文件名 * */ public function getImageName(){ $request = Request::instance(); $post = $request->post(); $src = $post['src']; $data['name'] = basename($src); exit(json_encode($data)); } } \ No newline at end of file +assign('tab_id',$tab_id); $list = ConfigModel::getAll($tab_id); if($type==3){//其它分类 $config_tab = null; }else{ $config_tab = ConfigModel::getConfigTabAll($type); foreach ($config_tab as $kk=>$vv){ $arr = ConfigModel::getAll($vv['value'])->toArray(); if(empty($arr)){ unset($config_tab[$kk]); } } } foreach ($list as $k=>$v){ if(!is_null(json_decode($v['value']))) $list[$k]['value'] = json_decode($v['value'],true); if($v['type'] == 'upload' && !empty($v['value'])){ if($v['upload_type'] == 1 || $v['upload_type'] == 3) $list[$k]['value'] = explode(',',$v['value']); } } $this->assign('config_tab',$config_tab); $this->assign('list',$list); return $this->fetch(); } /** * 基础配置 单个 * @return mixed|void */ public function index_alone(){ $tab_id = input('tab_id'); if(!$tab_id) return $this->failed('参数错误,请重新打开'); $this->assign('tab_id',$tab_id); $list = ConfigModel::getAll($tab_id); foreach ($list as $k=>$v){ if(!is_null(json_decode($v['value']))) $list[$k]['value'] = json_decode($v['value'],true); if($v['type'] == 'upload' && !empty($v['value'])){ if($v['upload_type'] == 1 || $v['upload_type'] == 3) $list[$k]['value'] = explode(',',$v['value']); } } $this->assign('list',$list); return $this->fetch(); } /** * 添加字段 * */ public function create(Request $request){ $data = Util::getMore(['type',],$request);//接收参数 $tab_id = !empty($request->param('tab_id'))?$request->param('tab_id'):1; $formbuider = array(); switch ($data['type']){ case 0://文本框 $formbuider = ConfigModel::createInputRule($tab_id); break; case 1://多行文本框 $formbuider = ConfigModel::createTextAreaRule($tab_id); break; case 2://单选框 $formbuider = ConfigModel::createRadioRule($tab_id); break; case 3://文件上传 $formbuider = ConfigModel::createUploadRule($tab_id); break; case 4://多选框 $formbuider = ConfigModel::createCheckboxRule($tab_id); break; } $form = Form::make_post_form('添加字段',$formbuider,Url::build('save')); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * 保存字段 * */ public function save(Request $request){ $data = Util::postMore([ 'menu_name', 'type', 'config_tab_id', 'parameter', 'upload_type', 'required', 'width', 'high', 'value', 'info', 'desc', 'sort', 'status',],$request); if(!$data['info']) return Json::fail('请输入配置名称'); if(!$data['menu_name']) return Json::fail('请输入字段名称'); if($data['menu_name']){ $oneConfig = ConfigModel::getOneConfig('menu_name',$data['menu_name']); if(!empty($oneConfig)) return Json::fail('请重新输入字段名称,之前的已经使用过了'); } if(!$data['desc']) return Json::fail('请输入配置简介'); if($data['sort'] < 0){ $data['sort'] = 0; } if($data['type'] == 'text'){ if(!ConfigModel::valiDateTextRole($data)) return Json::fail(ConfigModel::getErrorInfo()); } if($data['type'] == 'textarea'){ if(!ConfigModel::valiDateTextareaRole($data)) return Json::fail(ConfigModel::getErrorInfo()); } if($data['type'] == 'radio' || $data['type'] == 'checkbox' ){ if(!$data['parameter']) return Json::fail('请输入配置参数'); if(!ConfigModel::valiDateRadioAndCheckbox($data)) return Json::fail(ConfigModel::getErrorInfo()); $data['value'] = json_encode($data['value']); } ConfigModel::set($data); return Json::successful('添加菜单成功!'); } /** * @param Request $request * @param $id * @return \think\response\Json */ public function update_config(Request $request, $id) { $type = $request->post('type'); if($type =='text' || $type =='textarea'|| $type == 'radio' || ($type == 'upload' && ($request->post('upload_type') == 1 || $request->post('upload_type') == 3))){ $value = $request->post('value'); }else{ $value = $request->post('value/a'); } $data = Util::postMore(['status','info','desc','sort','config_tab_id','required','parameter',['value',$value],'upload_type'],$request); $data['value'] = json_encode($data['value']); if(!ConfigModel::get($id)) return Json::fail('编辑的记录不存在!'); ConfigModel::edit($data,$id); return Json::successful('修改成功!'); } /** * 修改是否显示子子段 * @param $id * @return mixed */ public function edit_cinfig($id){ $menu = ConfigModel::get($id)->getData(); if(!$menu) return Json::fail('数据不存在!'); $formbuider = array(); $formbuider[] = Form::input('menu_name','字段变量',$menu['menu_name'])->disabled(1); // $formbuider[] = Form::input('type','字段类型',$menu['type'])->disabled(1); $formbuider[] = Form::hidden('type',$menu['type']); $formbuider[] = Form::select('config_tab_id','分类',(string)$menu['config_tab_id'])->setOptions(ConfigModel::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称',$menu['info'])->autofocus(1); $formbuider[] = Form::input('desc','配置简介',$menu['desc']); switch ($menu['type']){ case 'text': $menu['value'] = json_decode($menu['value'],true); //输入框验证规则 $formbuider[] = Form::input('value','默认值',$menu['value']); if(!empty($menu['required'])){ $formbuider[] = Form::number('width','文本框宽(%)',$menu['width']); $formbuider[] = Form::input('required','验证规则',$menu['required'])->placeholder('多个请用,隔开例如:required:true,url:true'); } break; case 'textarea': $menu['value'] = json_decode($menu['value'],true); //多行文本 if(!empty($menu['high'])){ $formbuider[] = Form::textarea('value','默认值',$menu['value'])->rows(5); $formbuider[] = Form::number('width','文本框宽(%)',$menu['width']); $formbuider[] = Form::number('high','多行文本框高(%)',$menu['high']); }else{ $formbuider[] = Form::input('value','默认值',$menu['value']); } break; case 'radio': $menu['value'] = json_decode($menu['value'],true); $parameter = explode("\n",$menu['parameter']); $options = []; if($parameter){ foreach ($parameter as $v){ $data = explode("=>",$v); $options[] = ['label'=>$data[1],'value'=>$data[0]]; } $formbuider[] = Form::radio('value','默认值',$menu['value'])->options($options); } //单选和多选参数配置 if(!empty($menu['parameter'])){ $formbuider[] = Form::textarea('parameter','配置参数',$menu['parameter'])->placeholder("参数方式例如:\n1=白色\n2=红色\n3=黑色"); } break; case 'checkbox': $menu['value'] = json_decode($menu['value'],true)?:[]; $parameter = explode("\n",$menu['parameter']); $options = []; if($parameter) { foreach ($parameter as $v) { $data = explode("=>", $v); $options[] = ['label' => $data[1], 'value' => $data[0]]; } $formbuider[] = Form::checkbox('value', '默认值', $menu['value'])->options($options); } //单选和多选参数配置 if(!empty($menu['parameter'])){ $formbuider[] = Form::textarea('parameter','配置参数',$menu['parameter'])->placeholder("参数方式例如:\n1=白色\n2=红色\n3=黑色"); } break; case 'upload': if($menu['upload_type'] == 1 ){ $menu['value'] = json_decode($menu['value'],true); $formbuider[] = Form::frameImageOne('value','图片',Url::build('admin/widget.images/index',array('fodder'=>'value')),(string)$menu['value'])->icon('image')->width('100%')->height('550px'); }elseif ($menu['upload_type'] == 2 ){ $menu['value'] = json_decode($menu['value'],true)?:[]; $formbuider[] = Form::frameImages('value','多图片',Url::build('admin/widget.images/index',array('fodder'=>'value')),$menu['value'])->maxLength(5)->icon('images')->width('100%')->height('550px')->spin(0); }else{ $menu['value'] = json_decode($menu['value'],true); $formbuider[] = Form::uploadFileOne('value','文件',Url::build('file_upload'))->name('file'); } //上传类型选择 if(!empty($menu['upload_type'])){ $formbuider[] = Form::radio('upload_type','上传类型',$menu['upload_type'])->options([['value'=>1,'label'=>'单图'],['value'=>2,'label'=>'多图'],['value'=>3,'label'=>'文件']]); } break; } $formbuider[] = Form::number('sort','排序',$menu['sort']); $formbuider[] = Form::radio('status','状态',$menu['status'])->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); $form = Form::make_post_form('编辑字段',$formbuider,Url::build('update_config',array('id'=>$id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * 删除子字段 * @return \think\response\Json */ public function delete_cinfig(){ $id = input('id'); if(!ConfigModel::del($id)) return Json::fail(ConfigModel::getErrorInfo('删除失败,请稍候再试!')); else return Json::successful('删除成功!'); } /** * 保存数据 true * */ public function save_basics(){ $request = Request::instance(); if($request->isPost()){ $post = $request->post(); $tab_id = $post['tab_id']; unset($post['tab_id']); foreach ($post as $k=>$v){ if(is_array($v)){ $res = ConfigModel::where('menu_name',$k)->column('type,upload_type'); foreach ($res as $kk=>$vv){ if($kk == 'upload'){ if($vv == 1 || $vv == 3){ $post[$k] = $v[0]; } } } } } foreach ($post as $k=>$v){ ConfigModel::edit(['value' => json_encode($v)],$k,'menu_name'); } return $this->successfulNotice('修改成功'); } } /** * 模板表单提交 * */ public function view_upload(){ if($_POST['type'] == 3){ $res = Upload::file($_POST['file'],'config/file'); }else{ $res = Upload::Image($_POST['file'],'config/image'); } if(!$res->status) return Json::fail($res->error); return Json::successful('上传成功!',['url'=>$res->filePath]); } /** * 文件上传 * */ public function file_upload(){ $res = Upload::file($_POST['file'],'config/file'); if(!$res->status) return Json::fail($res->error); return Json::successful('上传成功!',['url'=>$res->filePath]); } /** * 获取文件名 * */ public function getImageName(){ $request = Request::instance(); $post = $request->post(); $src = $post['src']; $data['name'] = basename($src); exit(json_encode($data)); } } \ No newline at end of file diff --git a/application/admin/controller/setting/SystemConfigTab.php b/application/admin/controller/setting/SystemConfigTab.php index c3b82cf97..fa8f4c684 100644 --- a/application/admin/controller/setting/SystemConfigTab.php +++ b/application/admin/controller/setting/SystemConfigTab.php @@ -1 +1 @@ -assign('tab_id',$tab_id); $list = ConfigModel::getAll($tab_id); foreach ($list as $k=>$v){ $list[$k]['value'] = json_decode($v['value'],true); if($v['type'] == 'radio' || $v['type'] == 'checkbox'){ $list[$k]['value'] = ConfigTabModel::getRadioOrCheckboxValueInfo($v['menu_name'],$v['value']); } if($v['type'] == 'upload' && !empty($v['value'])){ if($v['upload_type'] == 1 || $v['upload_type'] == 3) $list[$k]['value'] = explode(',',$v['value']); } } $this->assign('list',$list); return $this->fetch(); } /** * 基础配置 * @return mixed */ public function index(){ $where = Util::getMore([ ['status',''], ['title',''], ],$this->request); $this->assign('where',$where); $this->assign(ConfigTabModel::getSystemConfigTabPage($where)); return $this->fetch(); } /** * 添加配置分类 * @return mixed */ public function create(){ $form = Form::create(Url::build('save'),[ Form::input('title','分类昵称'), Form::input('eng_title','分类字段'), Form::frameInputOne('icon','图标',Url::build('admin/widget.widgets/icon',array('fodder'=>'icon')))->icon('ionic'), Form::radio('type','类型',0)->options([['value'=>0,'label'=>'系统'],['value'=>1,'label'=>'公众号'],['value'=>2,'label'=>'小程序'],['value'=>3,'label'=>'其它']]), Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]) ]); $form->setMethod('post')->setTitle('添加分类配置'); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * 保存分类名称 * @param Request $request * @return \think\response\Json */ public function save(Request $request){ $data = Util::postMore([ 'eng_title', 'status', 'title', 'icon', 'type'],$request); if(!$data['title']) return Json::fail('请输入按钮名称'); ConfigTabModel::set($data); return Json::successful('添加菜单成功!'); } /** * 修改分类 * @param $id * @return mixed */ public function edit($id){ $menu = ConfigTabModel::get($id)->getData(); if(!$menu) return Json::fail('数据不存在!'); $form = Form::create(Url::build('update',array('id'=>$id)),[ Form::input('title','分类昵称',$menu['title']), Form::input('eng_title','分类字段',$menu['eng_title']), Form::frameInputOne('icon','图标',Url::build('admin/widget.widgets/icon',array('fodder'=>'icon')),$menu['icon'])->icon('ionic'), Form::radio('type','类型',$menu['type'])->options([['value'=>0,'label'=>'系统'],['value'=>1,'label'=>'公众号'],['value'=>2,'label'=>'小程序'],['value'=>3,'label'=>'其它']]), Form::radio('status','状态',$menu['status'])->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]) ]); $form->setMethod('post')->setTitle('添加分类配置'); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * @param Request $request * @param $id * @return \think\response\Json */ public function update(Request $request, $id) { $data = Util::postMore(['title','status','eng_title','icon','type'],$request); if(!$data['title']) return Json::fail('请输入分类昵称'); if(!$data['eng_title']) return Json::fail('请输入分类字段'); if(!ConfigTabModel::get($id)) return Json::fail('编辑的记录不存在!'); ConfigTabModel::edit($data,$id); return Json::successful('修改成功!'); } /** * @param $id * @return \think\response\Json */ public function delete($id){ if(!ConfigTabModel::del($id)) return Json::fail(ConfigTabModel::getErrorInfo('删除失败,请稍候再试!')); else return Json::successful('删除成功!'); } } \ No newline at end of file +assign('tab_id',$tab_id); $list = ConfigModel::getAll($tab_id); foreach ($list as $k=>$v){ $list[$k]['value'] = json_decode($v['value'],true)?:''; if($v['type'] == 'radio' || $v['type'] == 'checkbox'){ $list[$k]['value'] = ConfigTabModel::getRadioOrCheckboxValueInfo($v['menu_name'],$v['value']); } if($v['type'] == 'upload' && !empty($v['value'])){ // if($v['upload_type'] == 1 || $v['upload_type'] == 3) $list[$k]['value'] = explode(',',$v['value']); } } $this->assign('list',$list); return $this->fetch(); } /** * 基础配置 * @return mixed */ public function index(){ $where = Util::getMore([ ['status',''], ['title',''], ],$this->request); $this->assign('where',$where); $this->assign(ConfigTabModel::getSystemConfigTabPage($where)); return $this->fetch(); } /** * 添加配置分类 * @return mixed */ public function create(){ $form = Form::create(Url::build('save'),[ Form::input('title','分类昵称'), Form::input('eng_title','分类字段'), Form::frameInputOne('icon','图标',Url::build('admin/widget.widgets/icon',array('fodder'=>'icon')))->icon('ionic'), Form::radio('type','类型',0)->options([['value'=>0,'label'=>'系统'],['value'=>1,'label'=>'公众号'],['value'=>2,'label'=>'小程序'],['value'=>3,'label'=>'其它']]), Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]) ]); $form->setMethod('post')->setTitle('添加分类配置'); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * 保存分类名称 * @param Request $request * @return \think\response\Json */ public function save(Request $request){ $data = Util::postMore([ 'eng_title', 'status', 'title', 'icon', 'type'],$request); if(!$data['title']) return Json::fail('请输入按钮名称'); ConfigTabModel::set($data); return Json::successful('添加菜单成功!'); } /** * 修改分类 * @param $id * @return mixed */ public function edit($id){ $menu = ConfigTabModel::get($id)->getData(); if(!$menu) return Json::fail('数据不存在!'); $form = Form::create(Url::build('update',array('id'=>$id)),[ Form::input('title','分类昵称',$menu['title']), Form::input('eng_title','分类字段',$menu['eng_title']), Form::frameInputOne('icon','图标',Url::build('admin/widget.widgets/icon',array('fodder'=>'icon')),$menu['icon'])->icon('ionic'), Form::radio('type','类型',$menu['type'])->options([['value'=>0,'label'=>'系统'],['value'=>1,'label'=>'公众号'],['value'=>2,'label'=>'小程序'],['value'=>3,'label'=>'其它']]), Form::radio('status','状态',$menu['status'])->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]) ]); $form->setMethod('post')->setTitle('添加分类配置'); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * @param Request $request * @param $id * @return \think\response\Json */ public function update(Request $request, $id) { $data = Util::postMore(['title','status','eng_title','icon','type'],$request); if(!$data['title']) return Json::fail('请输入分类昵称'); if(!$data['eng_title']) return Json::fail('请输入分类字段'); if(!ConfigTabModel::get($id)) return Json::fail('编辑的记录不存在!'); ConfigTabModel::edit($data,$id); return Json::successful('修改成功!'); } /** * @param $id * @return \think\response\Json */ public function delete($id){ if(!ConfigTabModel::del($id)) return Json::fail(ConfigTabModel::getErrorInfo('删除失败,请稍候再试!')); else return Json::successful('删除成功!'); } } \ No newline at end of file diff --git a/application/admin/controller/setting/SystemGroupData.php b/application/admin/controller/setting/SystemGroupData.php index 227ebffd7..f8f936289 100644 --- a/application/admin/controller/setting/SystemGroupData.php +++ b/application/admin/controller/setting/SystemGroupData.php @@ -52,7 +52,7 @@ class SystemGroupData extends AuthController $params = explode("\n",$value["param"]); if(is_array($params) && !empty($params)){ foreach ($params as $index => $v) { - $vl = explode('=',$v); + $vl = explode('=>',$v); if(!empty($vl[0]) && !empty($vl[1])){ $info[$index]["value"] = $vl[0]; $info[$index]["label"] = $vl[1]; @@ -109,7 +109,8 @@ class SystemGroupData extends AuthController foreach ($params as $key => $param) { foreach ($Fields['fields'] as $index => $field) { if($key == $field["title"]){ - if($param == "" || count($param) == 0) +// if($param == "" || count($param) == 0) + if($param == "") return Json::fail($field["name"]."不能为空!"); else{ $value[$key]["type"] = $field["type"]; @@ -154,7 +155,7 @@ class SystemGroupData extends AuthController $params = explode("\n",$value["param"]); if(is_array($params) && !empty($params)){ foreach ($params as $index => $v) { - $vl = explode('=',$v); + $vl = explode('=>',$v); if(!empty($vl[0]) && !empty($vl[1])){ $info[$index]["value"] = $vl[0]; $info[$index]["label"] = $vl[1]; @@ -162,37 +163,38 @@ class SystemGroupData extends AuthController } } } + $fvalue = isset($GroupDataValue[$value['title']]['value'])?$GroupDataValue[$value['title']]['value']:''; switch ($value['type']){ case 'input': - $f[] = Form::input($value['title'],$value['name'],$GroupDataValue[$value['title']]['value']); + $f[] = Form::input($value['title'],$value['name'],$fvalue); break; case 'textarea': - $f[] = Form::input($value['title'],$value['name'],$GroupDataValue[$value['title']]['value'])->type('textarea'); + $f[] = Form::input($value['title'],$value['name'],$fvalue)->type('textarea'); break; case 'radio': - $f[] = Form::radio($value['title'],$value['name'],$GroupDataValue[$value['title']]['value'])->options($info); + $f[] = Form::radio($value['title'],$value['name'],$fvalue)->options($info); break; case 'checkbox': - $f[] = Form::checkbox($value['title'],$value['name'],$GroupDataValue[$value['title']]['value'])->options($info); + $f[] = Form::checkbox($value['title'],$value['name'],$fvalue)->options($info); break; case 'upload': - if(!empty($GroupDataValue[$value['title']]['value'])){ - $image = is_string($GroupDataValue[$value['title']]['value']) ? $GroupDataValue[$value['title']]['value'] : $GroupDataValue[$value['title']]['value'][0]; + if(!empty($fvalue)){ + $image = is_string($fvalue) ? $fvalue : $fvalue[0]; }else{ $image = ''; } $f[] = Form::frameImageOne($value['title'],$value['name'],Url::build('admin/widget.images/index',array('fodder'=>$value['title'],'big'=>1)),$image)->icon('image'); break; case 'uploads': - $images = !empty($GroupDataValue[$value['title']]['value']) ? $GroupDataValue[$value['title']]['value']:[]; + $images = !empty($fvalue) ? $fvalue:[]; $f[] = Form::frameImages($value['title'],$value['name'],Url::build('admin/widget.images/index', array('fodder' => $value['title'],'big'=>1)),$images)->maxLength(5)->icon('images')->width('100%')->height('550px')->spin(0); break; case 'select': - $f[] = Form::select($value['title'],$value['name'],$GroupDataValue[$value['title']]['value'])->setOptions($info); + $f[] = Form::select($value['title'],$value['name'],$fvalue)->setOptions($info); break; default: - $f[] = Form::input($value['title'],$value['name'],$GroupDataValue[$value['title']]['value']); + $f[] = Form::input($value['title'],$value['name'],$fvalue); break; } diff --git a/application/admin/controller/store/StoreCategory.php b/application/admin/controller/store/StoreCategory.php index d594f20fa..782f7eb71 100644 --- a/application/admin/controller/store/StoreCategory.php +++ b/application/admin/controller/store/StoreCategory.php @@ -1,9 +1,9 @@ request->param('pid')?$this->request->param('pid'):0; - $where = Util::getMore([ - ['is_show',''], - ['pid',$pid], - ['cate_name',''], - ],$this->request); - $this->assign('where',$where); + $this->assign('pid',$this->request->get('pid',0)); $this->assign('cate',CategoryModel::getTierList()); - $this->assign(CategoryModel::systemPage($where)); return $this->fetch(); } - + /* + * 异步获取分类列表 + * @return json + */ + public function category_list(){ + $where = Util::getMore([ + ['is_show',''], + ['pid',$this->request->param('pid','')], + ['cate_name',''], + ['page',1], + ['limit',20], + ['order',''] + ]); + return JsonService::successlayui(CategoryModel::CategoryList($where)); + } + /** + * 设置单个产品上架|下架 + * + * @return json + */ + public function set_show($is_show='',$id=''){ + ($is_show=='' || $id=='') && JsonService::fail('缺少参数'); + $res=CategoryModel::where(['id'=>$id])->update(['is_show'=>(int)$is_show]); + if($res){ + return JsonService::successful($is_show==1 ? '显示成功':'隐藏成功'); + }else{ + return JsonService::fail($is_show==1 ? '显示失败':'隐藏失败'); + } + } + /** + * 快速编辑 + * + * @return json + */ + public function set_category($field='',$id='',$value=''){ + $field=='' || $id=='' || $value=='' && JsonService::fail('缺少参数'); + if(CategoryModel::where(['id'=>$id])->update([$field=>$value])) + return JsonService::successful('保存成功'); + else + return JsonService::fail('保存失败'); + } /** * 显示创建资源表单页. * @@ -60,7 +93,7 @@ class StoreCategory extends AuthController Form::number('sort','排序'), Form::radio('is_show','状态',1)->options([['label'=>'显示','value'=>1],['label'=>'隐藏','value'=>0]]) ]; - $form = Form::make_post_form('添加产品',$field,Url::build('save')); + $form = Form::make_post_form('添加分类',$field,Url::build('save'),2); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } @@ -119,7 +152,7 @@ class StoreCategory extends AuthController { $c = CategoryModel::get($id); if(!$c) return Json::fail('数据不存在!'); - $form = Form::create(Url::build('update',array('id'=>$id)),[ + $field = [ Form::select('pid','父级',(string)$c->getData('pid'))->setOptions(function() use($id){ $list = CategoryModel::getTierList(CategoryModel::where('id','<>',$id)); // $list = (Util::sortListTier(CategoryModel::where('id','<>',$id)->select()->toArray(),'顶级','pid','cate_name')); @@ -133,8 +166,9 @@ class StoreCategory extends AuthController Form::frameImageOne('pic','分类图标',Url::build('admin/widget.images/index',array('fodder'=>'pic')),$c->getData('pic'))->icon('image'), Form::number('sort','排序',$c->getData('sort')), Form::radio('is_show','状态',$c->getData('is_show'))->options([['label'=>'显示','value'=>1],['label'=>'隐藏','value'=>0]]) - ]); - $form->setMethod('post')->setTitle('添加分类'); + ]; + $form = Form::make_post_form('编辑分类',$field,Url::build('update',array('id'=>$id)),2); + $this->assign(compact('form')); return $this->fetch('public/form-builder'); } diff --git a/application/admin/controller/store/StoreProduct.php b/application/admin/controller/store/StoreProduct.php index 96fcd7d24..f2a976bde 100644 --- a/application/admin/controller/store/StoreProduct.php +++ b/application/admin/controller/store/StoreProduct.php @@ -17,9 +17,7 @@ use think\Request; use app\admin\model\store\StoreCategory as CategoryModel; use app\admin\model\store\StoreProduct as ProductModel; use think\Url; -use app\admin\model\ump\StoreSeckill as StoreSeckillModel; -use app\admin\model\order\StoreOrder as StoreOrderModel; -use app\admin\model\ump\StoreBargain as StoreBargainModel; + use app\admin\model\system\SystemAttachment; @@ -140,22 +138,27 @@ class StoreProduct extends AuthController $menus[] = ['value'=>$menu['id'],'label'=>$menu['html'].$menu['cate_name'],'disabled'=>$menu['pid']== 0];//,'disabled'=>$menu['pid']== 0]; } return $menus; - })->filterable(1)->multiple(1), - Form::input('store_name','产品名称')->col(Form::col(24)), + })->filterable(1)->multiple(1)->required(), + Form::input('store_name','产品名称')->col(Form::col(24))->validateFn(function($validate){ + $validate->min(5)->max(32); + })->required(), Form::input('store_info','产品简介')->type('textarea'), Form::input('keyword','产品关键字')->placeholder('多个用英文状态下的逗号隔开'), - Form::input('unit_name','产品单位','件'), - Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')))->icon('image')->width('100%')->height('550px'), - Form::frameImages('slider_image','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'slider_image','big'=>1)))->maxLength(5)->icon('images')->width('100%')->height('550px')->spin(0), - Form::number('price','产品售价')->min(0)->col(8), + Form::input('unit_name','产品单位','件')->required(), + Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')))->icon('image')->width('100%')->height('500px')->required(), + Form::frameImages('slider_image','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'slider_image')))->maxLength(5)->icon('images')->width('100%')->height('500px')->spin(0) + ->required()->validateFn(function($validate){ + $validate->min(1)->max(5); + }), + Form::number('price','产品售价')->min(0)->col(8)->required(), Form::number('ot_price','产品市场价')->min(0)->col(8), Form::number('give_integral','赠送积分')->min(0)->precision(0)->col(8), - Form::number('postage','邮费')->min(0)->col(Form::col(8)), - Form::number('sales','销量')->min(0)->precision(0)->col(8), + Form::number('postage','邮费')->min(0)->col(Form::col(8))->required(), + Form::number('sales','销量',0)->min(0)->precision(0)->col(8)->readonly(1), Form::number('ficti','虚拟销量')->min(0)->precision(0)->col(8), - Form::number('stock','库存')->min(0)->precision(0)->col(8), + Form::number('stock','库存')->min(0)->precision(0)->col(8)->required(), Form::number('cost','产品成本价')->min(0)->col(8), - Form::number('sort','排序')->col(8), + Form::number('sort','排序',0)->col(8)->required(), Form::radio('is_show','产品状态',0)->options([['label'=>'上架','value'=>1],['label'=>'下架','value'=>0]])->col(8), Form::radio('is_hot','热卖单品',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8), Form::radio('is_benefit','促销单品',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8), @@ -163,8 +166,7 @@ class StoreProduct extends AuthController Form::radio('is_new','首发新品',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8), Form::radio('is_postage','是否包邮',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8) ]; - $form = Form::create(Url::build('save')); - $form->setMethod('post')->setTitle('添加产品')->components($field)->setSuccessScript('parent.$(".J_iframe:visible")[0].contentWindow.location.reload();'); + $form = Form::make_post_form('添加产品',$field,Url::build('save'),2); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } @@ -265,7 +267,7 @@ class StoreProduct extends AuthController if(!$id) return $this->failed('数据不存在'); $product = ProductModel::get($id); if(!$product) return Json::fail('数据不存在!'); - $form = Form::create(Url::build('update',array('id'=>$id)),[ + $field = [ Form::select('cate_id','产品分类',explode(',',$product->getData('cate_id')))->setOptions(function(){ $list = CategoryModel::getTierList(); $menus=[]; @@ -278,13 +280,13 @@ class StoreProduct extends AuthController Form::input('store_info','产品简介',$product->getData('store_info'))->type('textarea'), Form::input('keyword','产品关键字',$product->getData('keyword'))->placeholder('多个用英文状态下的逗号隔开'), Form::input('unit_name','产品单位',$product->getData('unit_name')), - Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')),$product->getData('image'))->icon('image')->width('100%')->height('550px'), - Form::frameImages('slider_image','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'slider_image')),json_decode($product->getData('slider_image'),1))->maxLength(5)->icon('images'), + Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')),$product->getData('image'))->icon('image')->width('100%')->height('500px'), + Form::frameImages('slider_image','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'slider_image')),json_decode($product->getData('slider_image'),1))->maxLength(5)->icon('images')->width('100%')->height('500px'), Form::number('price','产品售价',$product->getData('price'))->min(0)->precision(2)->col(8), Form::number('ot_price','产品市场价',$product->getData('ot_price'))->min(0)->col(8), Form::number('give_integral','赠送积分',$product->getData('give_integral'))->min(0)->precision(0)->col(8), Form::number('postage','邮费',$product->getData('postage'))->min(0)->col(8), - Form::number('sales','销量',$product->getData('sales'))->min(0)->precision(0)->col(8), + Form::number('sales','销量',$product->getData('sales'))->min(0)->precision(0)->col(8)->readonly(1), Form::number('ficti','虚拟销量',$product->getData('ficti'))->min(0)->precision(0)->col(8), Form::number('stock','库存',ProductModel::getStock($id)>0?ProductModel::getStock($id):$product->getData('stock'))->min(0)->precision(0)->col(8), Form::number('cost','产品成本价',$product->getData('cost'))->min(0)->col(8), @@ -295,8 +297,8 @@ class StoreProduct extends AuthController Form::radio('is_best','精品推荐',$product->getData('is_best'))->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8), Form::radio('is_new','首发新品',$product->getData('is_new'))->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8), Form::radio('is_postage','是否包邮',$product->getData('is_postage'))->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8) - ]); - $form->setMethod('post')->setTitle('编辑产品')->setSuccessScript('parent.$(".J_iframe:visible")[0].contentWindow.location.reload();'); + ]; + $form = Form::make_post_form('编辑产品',$field,Url::build('update',array('id'=>$id)),2); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } @@ -325,7 +327,7 @@ class StoreProduct extends AuthController 'price', 'sort', 'stock', - 'sales', +// 'sales', 'ficti', ['give_integral',0], ['is_show',0], @@ -350,7 +352,7 @@ class StoreProduct extends AuthController if($data['postage'] == '' || $data['postage'] < 0) return Json::fail('请输入邮费'); if($data['cost'] == '' || $data['cost'] < 0) return Json::fail('请输入产品成本价'); if($data['stock'] == '' || $data['stock'] < 0) return Json::fail('请输入库存'); - if($data['sales'] == '' || $data['sales'] < 0) return Json::fail('请输入销量'); +// if($data['sales'] == '' || $data['sales'] < 0) return Json::fail('请输入销量'); if($data['give_integral'] < 0) return Json::fail('请输入赠送积分'); $data['image'] = $data['image'][0]; $data['slider_image'] = json_encode($data['slider_image']); @@ -442,11 +444,17 @@ class StoreProduct extends AuthController public function delete($id) { if(!$id) return $this->failed('数据不存在'); - $data['is_del'] = 1; - if(!ProductModel::edit($data,$id)) - return Json::fail(ProductModel::getErrorInfo('删除失败,请稍候再试!')); - else - return Json::successful('删除成功!'); + if(!ProductModel::be(['id'=>$id])) return $this->failed('产品数据不存在'); + if(ProductModel::be(['id'=>$id,'is_del'=>1])){ + return Json::fail(ProductModel::getErrorInfo('暂不支持回收站删除产品!')); + }else{ + $data['is_del'] = 1; + if(!ProductModel::edit($data,$id)) + return Json::fail(ProductModel::getErrorInfo('删除失败,请稍候再试!')); + else + return Json::successful('成功移到回收站!'); + } + } diff --git a/application/admin/controller/system/SystemCleardata.php b/application/admin/controller/system/SystemCleardata.php index 6da840f16..03bb4d790 100644 --- a/application/admin/controller/system/SystemCleardata.php +++ b/application/admin/controller/system/SystemCleardata.php @@ -85,28 +85,11 @@ class SystemCleardata extends AuthController SystemCleardata::ClearData('store_service_log',1); return Json::successful('清除数据成功!'); } - //修改用户默认密码 - public function userdate(){ - SystemCleardata::ClearData('user',1); - $headimgurl= WechatUser::Where('uid',1)->value('headimgurl'); - $data['account']='crmeb'; - $data['pwd']=md5(123456); - $data['avatar']=$headimgurl; - $data['add_time']=time(); - $data['status']=1; - $data['level']=0; - $data['user_type']="wechat"; - $data['is_promoter']=1; - User::create($data); - return Json::successful('清除数据成功!'); - } + //清除微信管理数据 public function wechatdata(){ SystemCleardata::ClearData('wechat_media',1); SystemCleardata::ClearData('wechat_reply',1); - SystemCleardata::ClearData('wechat_news_content',1); - SystemCleardata::ClearData('wechat_news',1); - SystemCleardata::ClearData('wechat_news_category',1); $this->delDirAndFile('./public/uploads/wechat'); return Json::successful('清除数据成功!'); } @@ -117,15 +100,15 @@ class SystemCleardata extends AuthController } //清除微信用户 public function wechatuserdata(){ - $data= WechatUser::get(1)->toArray(); SystemCleardata::ClearData('wechat_user',1); - unset($data['uid']); - WechatUser::set($data); + SystemCleardata::ClearData('user',1); return Json::successful('清除数据成功!'); } //清除内容分类 public function articledata(){ SystemCleardata::ClearData('article_category',1); + SystemCleardata::ClearData('article',1); + SystemCleardata::ClearData('article_content',1); $this->delDirAndFile('./public/uploads/article/'); return Json::successful('清除数据成功!'); } @@ -133,15 +116,15 @@ class SystemCleardata extends AuthController public function ClearData($table_name,$status){ $table_name = Config::get('database')['prefix'].$table_name; if($status){ - db::query('TRUNCATE TABLE '.$table_name); + @db::query('TRUNCATE TABLE '.$table_name); }else{ - db::query('DELETE FROM'.$table_name); + @db::query('DELETE FROM'.$table_name); } } //递归删除文件 function delDirAndFile($dirName,$subdir=true){ - if ($handle = opendir("$dirName")){ + if ($handle = @opendir("$dirName")){ while(false !== ($item = readdir($handle))){ if($item != "." && $item != ".."){ if(is_dir("$dirName/$item")) diff --git a/application/admin/controller/system/SystemFile.php b/application/admin/controller/system/SystemFile.php index 87eb84177..09234cdc9 100644 --- a/application/admin/controller/system/SystemFile.php +++ b/application/admin/controller/system/SystemFile.php @@ -20,11 +20,11 @@ class SystemFile extends AuthController public function opendir($filedir=''){ $fileAll = array('dir'=>[],'file'=>[]); if(Request::instance()->param('superior') && !empty(Request::instance()->param('dir'))){ - $path = '.'.DS.Request::instance()->param('dir'); + $path = './'.Request::instance()->param('dir'); $path = dirname($path); }else{ $path = !empty(Request::instance()->param('dir'))?Request::instance()->param('dir'):'.'; - $path = $path.DS.Request::instance()->param('filedir'); + $path = $path.'/'.Request::instance()->param('filedir'); } $list = scandir($path); foreach($list as $key=>$v) { @@ -38,6 +38,9 @@ class SystemFile extends AuthController } } // var_dump($fileAll['file']); + //兼容windows + $uname=php_uname('s'); + if(strstr($uname,'Windows')!==false) $path = ltrim($path,'\\'); $dir = ltrim($path,'./'); $this->assign(compact('fileAll','dir')); return $this->fetch(); @@ -65,6 +68,10 @@ class SystemFile extends AuthController $comment = $this->request->post('comment'); $filepath = $this->request->post('filepath'); if(!empty($comment) && !empty($filepath)){ + //兼容windows + $uname=php_uname('s'); + if(strstr($uname,'Windows')!==false) + $filepath = ltrim(str_replace('/', DS, $filepath),'.'); $res = FileClass::write_file($filepath,$comment); if($res){ return Json::successful('保存成功!'); diff --git a/application/admin/controller/ump/StoreCoupon.php b/application/admin/controller/ump/StoreCoupon.php index dc6a847e8..a0c4aa9be 100644 --- a/application/admin/controller/ump/StoreCoupon.php +++ b/application/admin/controller/ump/StoreCoupon.php @@ -42,7 +42,7 @@ class StoreCoupon extends AuthController public function create() { $f = array(); - $f[] = Form::input('title','优惠券名称'); + $f[] = Form::input('title','优惠券名称')->required(); $f[] = Form::number('coupon_price','优惠券面值',0)->min(0); $f[] = Form::number('use_min_price','优惠券最低消费')->min(0); $f[] = Form::number('coupon_time','优惠券有效期限')->min(0); diff --git a/application/admin/controller/ump/StoreSeckill.php b/application/admin/controller/ump/StoreSeckill.php index b1abcb17f..46158f99d 100644 --- a/application/admin/controller/ump/StoreSeckill.php +++ b/application/admin/controller/ump/StoreSeckill.php @@ -60,11 +60,14 @@ class StoreSeckill extends AuthController if(is_object($seckillList['list'])) $seckillList['list'] = $seckillList['list']->toArray(); $data = $seckillList['list']['data']; foreach ($data as $k=>$v){ - $data[$k]['_stop_time'] = date('Y/m/d H:i:s',$v['stop_time']); + $data[$k]['_stop_time'] =$v['stop_time'] ? date('Y/m/d H:i:s',$v['stop_time']) : ''; } return Json::successlayui(['count'=>$seckillList['list']['total'],'data'=>$data]); } + public function get_seckill_id(){ + return Json::successlayui(StoreSeckillModel::getSeckillIdAll()); + } /** * 添加秒杀产品 * @return form-builder @@ -103,6 +106,7 @@ class StoreSeckill extends AuthController { $data = Util::postMore([ 'title', + 'product_id', 'info', 'unit_name', ['image',''], @@ -124,6 +128,7 @@ class StoreSeckill extends AuthController ],$request); if(!$data['title']) return Json::fail('请输入产品标题'); if(!$data['unit_name']) return Json::fail('请输入产品单位'); + if(!$data['product_id']) return Json::fail('产品ID不能为空'); // var_dump($this->request->post()); if(count($data['section_time'])<1) return Json::fail('请选择活动时间'); $data['start_time'] = strtotime($data['section_time'][0]); @@ -159,6 +164,7 @@ class StoreSeckill extends AuthController if(!$product) return Json::fail('数据不存在!'); $f = array(); $f[] = Form::input('title','产品标题',$product->getData('store_name')); + $f[] = Form::hidden('product_id',$id); $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','活动时间'); @@ -170,7 +176,7 @@ class StoreSeckill extends AuthController $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('num','单次购买产品个数')->precision(0)->col(12); + $f[] = Form::number('num','单次购买产品个数',1)->precision(0)->col(12); $f[] = Form::number('give_integral','赠送积分',$product->getData('give_integral'))->min(0)->precision(0)->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); @@ -212,6 +218,7 @@ class StoreSeckill extends AuthController $product = StoreSeckillModel::get($id); if(!$product) return Json::fail('数据不存在!'); $f = array(); + $f[] = Form::hidden('product_id',$product->getData('product_id')); $f[] = Form::input('title','产品标题',$product->getData('title')); $f[] = Form::input('info','秒杀活动简介',$product->getData('info'))->type('textarea'); $f[] = Form::input('unit_name','单位',$product->getData('unit_name'))->placeholder('个、位'); @@ -219,7 +226,7 @@ class StoreSeckill extends AuthController $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('ot_price','原价',$product->getData('price'))->min(0)->col(12); + $f[] = Form::number('ot_price','原价',$product->getData('ot_price'))->min(0)->col(12); $f[] = Form::number('cost','成本价',$product->getData('cost'))->min(0)->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); diff --git a/application/admin/controller/user/User.php b/application/admin/controller/user/User.php index b08f1c58a..231949000 100644 --- a/application/admin/controller/user/User.php +++ b/application/admin/controller/user/User.php @@ -1 +1 @@ -assign('count_user',UserModel::getcount()); return $this->fetch(); } /** * 修改user表状态 * * @return json */ public function set_status($status='',$uid=0,$is_echo=0){ if($is_echo==0) { if ($status == '' || $uid == 0) return Json::fail('参数错误'); UserModel::where(['uid' => $uid])->update(['status' => $status]); }else{ $uids=Util::postMore([ ['uids',[]] ]); UserModel::destrSyatus($uids['uids'],$status); } return Json::successful($status==0 ? '禁用成功':'解禁成功'); } /** * 获取user表 * * @return json */ public function get_user_list(){ $where=Util::getMore([ ['page',1], ['limit',20], ['nickname',''], ['status',''], ['pay_count',''], ['is_promoter',''], ['order',''], ['data',''], ['user_type',''], ['country',''], ['province',''], ['city',''], ['user_time_type',''], ['user_time',''], ['sex',''], ]); return Json::successlayui(UserModel::getUserList($where)); } /** * 编辑模板消息 * @param $id * @return mixed|\think\response\Json|void */ public function edit($uid) { if(!$uid) return $this->failed('数据不存在'); $user = UserModel::get($uid); if(!$user) return Json::fail('数据不存在!'); $f = array(); $f[] = Form::input('uid','用户编号',$user->getData('uid'))->disabled(1); $f[] = Form::input('nickname','用户姓名',$user->getData('nickname')); $f[] = Form::radio('money_status','修改余额',1)->options([['value'=>1,'label'=>'增加'],['value'=>2,'label'=>'减少']])->col(12); $f[] = Form::number('money','余额')->min(0)->col(12); $f[] = Form::radio('integration_status','修改积分',1)->options([['value'=>1,'label'=>'增加'],['value'=>2,'label'=>'减少']])->col(12); $f[] = Form::number('integration','积分')->min(0)->col(12); $f[] = Form::radio('status','状态',$user->getData('status'))->options([['value'=>1,'label'=>'开启'],['value'=>0,'label'=>'锁定']]); $f[] = Form::radio('is_promoter','推广员',$user->getData('is_promoter'))->options([['value'=>1,'label'=>'开启'],['value'=>0,'label'=>'关闭']]); $form = Form::make_post_form('添加用户通知',$f,Url::build('update',array('id'=>$uid))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } public function update(Request $request, $uid) { $data = Util::postMore([ ['money_status',0], ['is_promoter',1], ['money',0], ['integration_status',0], ['integration',0], ['status',0], ],$request); if(!$uid) return $this->failed('数据不存在'); $user = UserModel::get($uid); if(!$user) return Json::fail('数据不存在!'); ModelBasic::beginTrans(); $res1 = false; $res2 = false; $edit = array(); if($data['money_status'] && $data['money']){//余额增加或者减少 if($data['money_status'] == 1){//增加 $edit['now_money'] = bcadd($user['now_money'],$data['money'],2); $res1 = UserBill::income('系统增加余额',$user['uid'],'now_money','system_add',$data['money'],$this->adminId,$user['now_money'],'系统增加了'.floatval($data['money']).'余额'); try{ HookService::listen('admin_add_money',$user,$data['money'],false,UserBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } }else if($data['money_status'] == 2){//减少 $edit['now_money'] = bcsub($user['now_money'],$data['money'],2); $res1 = UserBill::expend('系统减少余额',$user['uid'],'now_money','system_sub',$data['money'],$this->adminId,$user['now_money'],'系统扣除了'.floatval($data['money']).'余额'); try{ HookService::listen('admin_sub_money',$user,$data['money'],false,UserBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } } }else{ $res1 = true; } if($data['integration_status'] && $data['integration']){//积分增加或者减少 if($data['integration_status'] == 1){//增加 $edit['integral'] = bcadd($user['integral'],$data['integration'],2); $res2 = UserBill::income('系统增加积分',$user['uid'],'integral','system_add',$data['integration'],$this->adminId,$user['integral'],'系统增加了'.floatval($data['integration']).'积分'); try{ HookService::listen('admin_add_integral',$user,$data['integration'],false,UserBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } }else if($data['integration_status'] == 2){//减少 $edit['integral'] = bcsub($user['integral'],$data['integration'],2); $res2 = UserBill::expend('系统减少积分',$user['uid'],'integral','system_sub',$data['integration'],$this->adminId,$user['integral'],'系统扣除了'.floatval($data['integration']).'积分'); try{ HookService::listen('admin_sub_integral',$user,$data['integration'],false,UserBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } } }else{ $res2 = true; } $edit['status'] = $data['status']; $edit['is_promoter'] = $data['is_promoter']; if($edit) $res3 = UserModel::edit($edit,$uid); else $res3 = true; if($res1 && $res2 && $res3) $res =true; else $res = false; ModelBasic::checkTrans($res); if($res) return Json::successful('修改成功!'); else return Json::fail('修改失败'); } /** * 用户图表 * @return mixed */ public function user_analysis(){ $where = Util::getMore([ ['nickname',''], ['status',''], ['is_promoter',''], ['date',''], ['user_type',''], ['export',0] ],$this->request); $user_count=UserModel::consume($where,'',true); //头部信息 $header=[ [ 'name'=>'新增用户', 'class'=>'fa-line-chart', 'value'=>$user_count, 'color'=>'red' ], [ 'name'=>'用户留存', 'class'=>'fa-area-chart', 'value'=>$this->gethreaderValue(UserModel::consume($where,'',true),$where).'%', 'color'=>'lazur' ], [ 'name'=>'新增用户总消费', 'class'=>'fa-bar-chart', 'value'=>'¥'.UserModel::consume($where), 'color'=>'navy' ], [ 'name'=>'用户活跃度', 'class'=>'fa-pie-chart', 'value'=>$this->gethreaderValue(UserModel::consume($where,'',true)).'%', 'color'=>'yellow' ], ]; $name=['新增用户','用户消费']; $dates=$this->get_user_index($where,$name); $user_index=['name'=>json_encode($name), 'date'=>json_encode($dates['time']), 'series'=>json_encode($dates['series'])]; //用户浏览分析 $view=StoreVisit::getVisit($where['date'],['','warning','info','danger']); $view_v1=WechatMessage::getViweList($where['date'],['','warning','info','danger']); $view=array_merge($view,$view_v1); $view_v2=[]; foreach ($view as $val){ $view_v2['color'][]='#'.rand(100000,339899); $view_v2['name'][]=$val['name']; $view_v2['value'][]=$val['value']; } $view=$view_v2; //消费会员排行用户分析 $user_null=UserModel::getUserSpend($where['date']); //消费数据 $now_number=UserModel::getUserSpend($where['date'],true); list($paren_number,$title)=UserModel::getPostNumber($where['date']); if($paren_number==0) { $rightTitle=[ 'number'=>$now_number>0?$now_number:0, 'icon'=>'fa-level-up', 'title'=>$title ]; }else{ $number=(float)bcsub($now_number,$paren_number,4); if($now_number==0){ $icon='fa-level-down'; }else{ $icon=$now_number>$paren_number?'fa-level-up':'fa-level-down'; } $rightTitle=['number'=>$number, 'icon'=>$icon, 'title'=>$title]; } unset($title,$paren_number,$now_number); list($paren_user_count,$title)=UserModel::getPostNumber($where['date'],true,'add_time',''); if($paren_user_count==0){ $count=$user_count==0?0:$user_count; $icon=$user_count==0?'fa-level-down':'fa-level-up'; }else{ $count=(float)bcsub($user_count,$paren_user_count,4); $icon=$user_count<$paren_user_count?'fa-level-down':'fa-level-up'; } $leftTitle=[ 'count'=>$count, 'icon'=>$icon, 'title'=>$title ]; unset($count,$icon,$title); $consume=[ 'title'=>'消费金额为¥'.UserModel::consume($where), 'series'=>UserModel::consume($where,'xiaofei'), 'rightTitle'=>$rightTitle, 'leftTitle'=>$leftTitle, ]; $form=UserModel::consume($where,'form'); $grouping=UserModel::consume($where,'grouping'); $this->assign(compact('header','user_index','view','user_null','consume','form','grouping','where')); return $this->fetch(); } public function gethreaderValue($chart,$where=[]){ if($where){ switch($where['date']){ case null:case 'today':case 'week':case 'year': if($where['date']==null){ $where['date']='month'; } $sum_user=UserModel::whereTime('add_time',$where['date'])->count(); if($sum_user==0) return 0; $counts=bcdiv($chart,$sum_user,4)*100; return $counts; break; case 'quarter': $quarter=UserModel::getMonth('n'); $quarter[0]=strtotime($quarter[0]); $quarter[1]=strtotime($quarter[1]); $sum_user=UserModel::where('add_time','between',$quarter)->count(); if($sum_user==0) return 0; $counts=bcdiv($chart,$sum_user,4)*100; return $counts; default: //自定义时间 $quarter=explode('-',$where['date']); $quarter[0]=strtotime($quarter[0]); $quarter[1]=strtotime($quarter[1]); $sum_user=UserModel::where('add_time','between',$quarter)->count(); if($sum_user==0) return 0; $counts=bcdiv($chart,$sum_user,4)*100; return $counts; break; } }else{ $num=UserModel::count(); $chart=$num!=0?bcdiv($chart,$num,5)*100:0; return $chart; } } public function get_user_index($where,$name){ switch ($where['date']){ case null: $days = date("t",strtotime(date('Y-m',time()))); $dates=[]; $series=[]; $times_list=[]; foreach ($name as $key=>$val){ for($i=1;$i<=$days;$i++){ if(!in_array($i.'号',$times_list)){ array_push($times_list,$i.'号'); } $time=$this->gettime(date("Y-m",time()).'-'.$i); if($key==0){ $dates['data'][]=UserModel::where('add_time','between',$time)->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,$time); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; case 'today': $dates=[]; $series=[]; $times_list=[]; foreach ($name as $key=>$val){ for($i=0;$i<=24;$i++){ $strtitle=$i.'点'; if(!in_array($strtitle,$times_list)){ array_push($times_list,$strtitle); } $time=$this->gettime(date("Y-m-d ",time()).$i); if($key==0){ $dates['data'][]=UserModel::where('add_time','between',$time)->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,$time); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; case "week": $dates=[]; $series=[]; $times_list=[]; foreach ($name as $key=>$val){ for($i=0;$i<=6;$i++){ if(!in_array('星期'.($i+1),$times_list)){ array_push($times_list,'星期'.($i+1)); } $time=UserModel::getMonth('h',$i); if($key==0){ $dates['data'][]=UserModel::where('add_time','between',[strtotime($time[0]),strtotime($time[1])])->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,[strtotime($time[0]),strtotime($time[1])]); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; case 'year': $dates=[]; $series=[]; $times_list=[]; $year=date('Y'); foreach ($name as $key=>$val){ for($i=1;$i<=12;$i++){ if(!in_array($i.'月',$times_list)){ array_push($times_list,$i.'月'); } $t = strtotime($year.'-'.$i.'-01'); $arr= explode('/',date('Y-m-01',$t).'/'.date('Y-m-',$t).date('t',$t)); if($key==0){ $dates['data'][]=UserModel::where('add_time','between',[strtotime($arr[0]),strtotime($arr[1])])->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,[strtotime($arr[0]),strtotime($arr[1])]); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; case 'quarter': $dates=[]; $series=[]; $times_list=[]; foreach ($name as $key=>$val){ for($i=1;$i<=4;$i++){ $arr=$this->gettime('quarter',$i); if(!in_array(implode('--',$arr).'季度',$times_list)){ array_push($times_list,implode('--',$arr).'季度'); } if($key==0){ $dates['data'][]=UserModel::where('add_time','between',[strtotime($arr[0]),strtotime($arr[1])])->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,[strtotime($arr[0]),strtotime($arr[1])]); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; default: $list=UserModel::consume($where,'default'); $dates=[]; $series=[]; $times_list=[]; foreach ($name as $k=>$v){ foreach ($list as $val){ $date=$val['add_time']; if(!in_array($date,$times_list)){ array_push($times_list,$date); } if($k==0){ $dates['data'][]=$val['num']; }else if($k==1){ $dates['data'][]=UserBill::where(['uid'=>$val['uid'],'type'=>'pay_product'])->sum('number'); } } $dates['name']=$v; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; } } public function gettime($time='',$season=''){ if(!empty($time) && empty($season)){ $timestamp0 = strtotime($time); $timestamp24 =strtotime($time)+86400; return [$timestamp0,$timestamp24]; }else if(!empty($time) && !empty($season)){ $firstday=date('Y-m-01',mktime(0,0,0,($season - 1) *3 +1,1,date('Y'))); $lastday=date('Y-m-t',mktime(0,0,0,$season * 3,1,date('Y'))); return [$firstday,$lastday]; } } /** * 会员等级首页 */ public function group(){ return $this->fetch(); } /** * 会员详情 */ public function see($uid=''){ $this->assign([ 'uid'=>$uid, 'userinfo'=>UserModel::getUserDetailed($uid), 'is_layui'=>true, 'headerList'=>UserModel::getHeaderList($uid), 'count'=>UserModel::getCountInfo($uid), ]); return $this->fetch(); } /** * 获取某用户的订单列表 */ public function getOneorderList($uid,$page=1,$limit=20){ return Json::successful(StoreOrder::getOneorderList(compact('uid','page','limit'))); } /** * 获取某用户的积分列表 */ public function getOneIntegralList($uid,$page=1,$limit=20){ return Json::successful(UserBillAdmin::getOneIntegralList(compact('uid','page','limit'))); } /** * 获取某用户的积分列表 */ public function getOneSignList($uid,$page=1,$limit=20){ return Json::successful(UserBillAdmin::getOneSignList(compact('uid','page','limit'))); } /** * 获取某用户的持有优惠劵 */ public function getOneCouponsList($uid,$page=1,$limit=20){ return Json::successful(StoreCouponUser::getOneCouponsList(compact('uid','page','limit'))); } /** * 获取某用户的余额变动记录 */ public function getOneBalanceChangList($uid,$page=1,$limit=20){ return Json::successful(UserBillAdmin::getOneBalanceChangList(compact('uid','page','limit'))); } } \ No newline at end of file +assign('count_user',UserModel::getcount()); return $this->fetch(); } /** * 修改user表状态 * * @return json */ public function set_status($status='',$uid=0,$is_echo=0){ if($is_echo==0) { if ($status == '' || $uid == 0) return Json::fail('参数错误'); UserModel::where(['uid' => $uid])->update(['status' => $status]); }else{ $uids=Util::postMore([ ['uids',[]] ]); UserModel::destrSyatus($uids['uids'],$status); } return Json::successful($status==0 ? '禁用成功':'解禁成功'); } /** * 获取user表 * * @return json */ public function get_user_list(){ $where=Util::getMore([ ['page',1], ['limit',20], ['nickname',''], ['status',''], ['pay_count',''], ['is_promoter',''], ['order',''], ['data',''], ['user_type',''], ['country',''], ['province',''], ['city',''], ['user_time_type',''], ['user_time',''], ['sex',''], ]); return Json::successlayui(UserModel::getUserList($where)); } /** * 编辑模板消息 * @param $id * @return mixed|\think\response\Json|void */ public function edit($uid) { if(!$uid) return $this->failed('数据不存在'); $user = UserModel::get($uid); if(!$user) return Json::fail('数据不存在!'); $f = array(); $f[] = Form::input('uid','用户编号',$user->getData('uid'))->disabled(1); $f[] = Form::input('nickname','用户姓名',$user->getData('nickname')); $f[] = Form::radio('money_status','修改余额',1)->options([['value'=>1,'label'=>'增加'],['value'=>2,'label'=>'减少']])->col(12); $f[] = Form::number('money','余额')->min(0)->col(12); $f[] = Form::radio('integration_status','修改积分',1)->options([['value'=>1,'label'=>'增加'],['value'=>2,'label'=>'减少']])->col(12); $f[] = Form::number('integration','积分')->min(0)->col(12); $f[] = Form::radio('status','状态',$user->getData('status'))->options([['value'=>1,'label'=>'开启'],['value'=>0,'label'=>'锁定']]); $f[] = Form::radio('is_promoter','推广员',$user->getData('is_promoter'))->options([['value'=>1,'label'=>'开启'],['value'=>0,'label'=>'关闭']]); $form = Form::make_post_form('添加用户通知',$f,Url::build('update',array('id'=>$uid))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } public function update(Request $request, $uid) { $data = Util::postMore([ ['money_status',0], ['is_promoter',1], ['money',0], ['integration_status',0], ['integration',0], ['status',0], ],$request); if(!$uid) return $this->failed('数据不存在'); $user = UserModel::get($uid); if(!$user) return Json::fail('数据不存在!'); ModelBasic::beginTrans(); $res1 = false; $res2 = false; $edit = array(); if($data['money_status'] && $data['money']){//余额增加或者减少 if($data['money_status'] == 1){//增加 $edit['now_money'] = bcadd($user['now_money'],$data['money'],2); $res1 = UserBill::income('系统增加余额',$user['uid'],'now_money','system_add',$data['money'],$this->adminId,$user['now_money'],'系统增加了'.floatval($data['money']).'余额'); try{ HookService::listen('admin_add_money',$user,$data['money'],false,UserBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } }else if($data['money_status'] == 2){//减少 $edit['now_money'] = bcsub($user['now_money'],$data['money'],2); $res1 = UserBill::expend('系统减少余额',$user['uid'],'now_money','system_sub',$data['money'],$this->adminId,$user['now_money'],'系统扣除了'.floatval($data['money']).'余额'); try{ HookService::listen('admin_sub_money',$user,$data['money'],false,UserBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } } }else{ $res1 = true; } if($data['integration_status'] && $data['integration']){//积分增加或者减少 if($data['integration_status'] == 1){//增加 $edit['integral'] = bcadd($user['integral'],$data['integration'],2); $res2 = UserBill::income('系统增加积分',$user['uid'],'integral','system_add',$data['integration'],$this->adminId,$user['integral'],'系统增加了'.floatval($data['integration']).'积分'); try{ HookService::listen('admin_add_integral',$user,$data['integration'],false,UserBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } }else if($data['integration_status'] == 2){//减少 $edit['integral'] = bcsub($user['integral'],$data['integration'],2); $res2 = UserBill::expend('系统减少积分',$user['uid'],'integral','system_sub',$data['integration'],$this->adminId,$user['integral'],'系统扣除了'.floatval($data['integration']).'积分'); try{ HookService::listen('admin_sub_integral',$user,$data['integration'],false,UserBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } } }else{ $res2 = true; } $edit['status'] = $data['status']; $edit['is_promoter'] = $data['is_promoter']; if($edit) $res3 = UserModel::edit($edit,$uid); else $res3 = true; if($res1 && $res2 && $res3) $res =true; else $res = false; ModelBasic::checkTrans($res); if($res) return Json::successful('修改成功!'); else return Json::fail('修改失败'); } /** * 用户图表 * @return mixed */ public function user_analysis(){ $where = Util::getMore([ ['nickname',''], ['status',''], ['is_promoter',''], ['date',''], ['user_type',''], ['export',0] ],$this->request); $user_count=UserModel::consume($where,'',true); //头部信息 $header=[ [ 'name'=>'新增用户', 'class'=>'fa-line-chart', 'value'=>$user_count, 'color'=>'red' ], [ 'name'=>'用户留存', 'class'=>'fa-area-chart', 'value'=>$this->gethreaderValue(UserModel::consume($where,'',true),$where).'%', 'color'=>'lazur' ], [ 'name'=>'新增用户总消费', 'class'=>'fa-bar-chart', 'value'=>'¥'.UserModel::consume($where), 'color'=>'navy' ], [ 'name'=>'用户活跃度', 'class'=>'fa-pie-chart', 'value'=>$this->gethreaderValue(UserModel::consume($where,'',true)).'%', 'color'=>'yellow' ], ]; $name=['新增用户','用户消费']; $dates=$this->get_user_index($where,$name); $user_index=['name'=>json_encode($name), 'date'=>json_encode($dates['time']), 'series'=>json_encode($dates['series'])]; //用户浏览分析 $view=StoreVisit::getVisit($where['date'],['','warning','info','danger']); $view_v1=WechatMessage::getViweList($where['date'],['','warning','info','danger']); $view=array_merge($view,$view_v1); $view_v2=[]; foreach ($view as $val){ $view_v2['color'][]='#'.rand(100000,339899); $view_v2['name'][]=$val['name']; $view_v2['value'][]=$val['value']; } $view=$view_v2; //消费会员排行用户分析 $user_null=UserModel::getUserSpend($where['date']); //消费数据 $now_number=UserModel::getUserSpend($where['date'],true); list($paren_number,$title)=UserModel::getPostNumber($where['date']); if($paren_number==0) { $rightTitle=[ 'number'=>$now_number>0?$now_number:0, 'icon'=>'fa-level-up', 'title'=>$title ]; }else{ $number=(float)bcsub($now_number,$paren_number,4); if($now_number==0){ $icon='fa-level-down'; }else{ $icon=$now_number>$paren_number?'fa-level-up':'fa-level-down'; } $rightTitle=['number'=>$number, 'icon'=>$icon, 'title'=>$title]; } unset($title,$paren_number,$now_number); list($paren_user_count,$title)=UserModel::getPostNumber($where['date'],true,'add_time',''); if($paren_user_count==0){ $count=$user_count==0?0:$user_count; $icon=$user_count==0?'fa-level-down':'fa-level-up'; }else{ $count=(float)bcsub($user_count,$paren_user_count,4); $icon=$user_count<$paren_user_count?'fa-level-down':'fa-level-up'; } $leftTitle=[ 'count'=>$count, 'icon'=>$icon, 'title'=>$title ]; unset($count,$icon,$title); $consume=[ 'title'=>'消费金额为¥'.UserModel::consume($where), 'series'=>UserModel::consume($where,'xiaofei'), 'rightTitle'=>$rightTitle, 'leftTitle'=>$leftTitle, ]; $form=UserModel::consume($where,'form'); $grouping=UserModel::consume($where,'grouping'); $this->assign(compact('header','user_index','view','user_null','consume','form','grouping','where')); return $this->fetch(); } public function gethreaderValue($chart,$where=[]){ if($where){ switch($where['date']){ case null:case 'today':case 'week':case 'year': if($where['date']==null){ $where['date']='month'; } $sum_user=UserModel::whereTime('add_time',$where['date'])->count(); if($sum_user==0) return 0; $counts=bcdiv($chart,$sum_user,4)*100; return $counts; break; case 'quarter': $quarter=UserModel::getMonth('n'); $quarter[0]=strtotime($quarter[0]); $quarter[1]=strtotime($quarter[1]); $sum_user=UserModel::where('add_time','between',$quarter)->count(); if($sum_user==0) return 0; $counts=bcdiv($chart,$sum_user,4)*100; return $counts; default: //自定义时间 $quarter=explode('-',$where['date']); $quarter[0]=strtotime($quarter[0]); $quarter[1]=strtotime($quarter[1]); $sum_user=UserModel::where('add_time','between',$quarter)->count(); if($sum_user==0) return 0; $counts=bcdiv($chart,$sum_user,4)*100; return $counts; break; } }else{ $num=UserModel::count(); $chart=$num!=0?bcdiv($chart,$num,5)*100:0; return $chart; } } public function get_user_index($where,$name){ switch ($where['date']){ case null: $days = date("t",strtotime(date('Y-m',time()))); $dates=[]; $series=[]; $times_list=[]; foreach ($name as $key=>$val){ for($i=1;$i<=$days;$i++){ if(!in_array($i.'号',$times_list)){ array_push($times_list,$i.'号'); } $time=$this->gettime(date("Y-m",time()).'-'.$i); if($key==0){ $dates['data'][]=UserModel::where('add_time','between',$time)->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,$time); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; case 'today': $dates=[]; $series=[]; $times_list=[]; foreach ($name as $key=>$val){ for($i=0;$i<=24;$i++){ $strtitle=$i.'点'; if(!in_array($strtitle,$times_list)){ array_push($times_list,$strtitle); } $time=$this->gettime(date("Y-m-d ",time()).$i); if($key==0){ $dates['data'][]=UserModel::where('add_time','between',$time)->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,$time); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; case "week": $dates=[]; $series=[]; $times_list=[]; foreach ($name as $key=>$val){ for($i=0;$i<=6;$i++){ if(!in_array('星期'.($i+1),$times_list)){ array_push($times_list,'星期'.($i+1)); } $time=UserModel::getMonth('h',$i); if($key==0){ $dates['data'][]=UserModel::where('add_time','between',[strtotime($time[0]),strtotime($time[1])])->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,[strtotime($time[0]),strtotime($time[1])]); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; case 'year': $dates=[]; $series=[]; $times_list=[]; $year=date('Y'); foreach ($name as $key=>$val){ for($i=1;$i<=12;$i++){ if(!in_array($i.'月',$times_list)){ array_push($times_list,$i.'月'); } $t = strtotime($year.'-'.$i.'-01'); $arr= explode('/',date('Y-m-01',$t).'/'.date('Y-m-',$t).date('t',$t)); if($key==0){ $dates['data'][]=UserModel::where('add_time','between',[strtotime($arr[0]),strtotime($arr[1])])->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,[strtotime($arr[0]),strtotime($arr[1])]); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; case 'quarter': $dates=[]; $series=[]; $times_list=[]; foreach ($name as $key=>$val){ for($i=1;$i<=4;$i++){ $arr=$this->gettime('quarter',$i); if(!in_array(implode('--',$arr).'季度',$times_list)){ array_push($times_list,implode('--',$arr).'季度'); } if($key==0){ $dates['data'][]=UserModel::where('add_time','between',[strtotime($arr[0]),strtotime($arr[1])])->count(); }else if($key==1){ $dates['data'][]=UserModel::consume(true,[strtotime($arr[0]),strtotime($arr[1])]); } } $dates['name']=$val; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; default: $list=UserModel::consume($where,'default'); $dates=[]; $series=[]; $times_list=[]; foreach ($name as $k=>$v){ foreach ($list as $val){ $date=$val['add_time']; if(!in_array($date,$times_list)){ array_push($times_list,$date); } if($k==0){ $dates['data'][]=$val['num']; }else if($k==1){ $dates['data'][]=UserBill::where(['uid'=>$val['uid'],'type'=>'pay_product'])->sum('number'); } } $dates['name']=$v; $dates['type']='line'; $series[]=$dates; unset($dates); } return ['time'=>$times_list,'series'=>$series]; } } public function gettime($time='',$season=''){ if(!empty($time) && empty($season)){ $timestamp0 = strtotime($time); $timestamp24 =strtotime($time)+86400; return [$timestamp0,$timestamp24]; }else if(!empty($time) && !empty($season)){ $firstday=date('Y-m-01',mktime(0,0,0,($season - 1) *3 +1,1,date('Y'))); $lastday=date('Y-m-t',mktime(0,0,0,$season * 3,1,date('Y'))); return [$firstday,$lastday]; } } /** * 会员等级首页 */ public function group(){ return $this->fetch(); } /** * 会员详情 */ public function see($uid=''){ $this->assign([ 'uid'=>$uid, 'userinfo'=>UserModel::getUserDetailed($uid), 'is_layui'=>true, 'headerList'=>UserModel::getHeaderList($uid), 'count'=>UserModel::getCountInfo($uid), ]); return $this->fetch(); } /* * 获取某个用户的推广下线 * */ public function getSpreadList($uid,$page=1,$limit=20){ return Json::successful(UserModel::getSpreadList($uid,(int)$page,(int)$limit)); } /** * 获取某用户的订单列表 */ public function getOneorderList($uid,$page=1,$limit=20){ return Json::successful(StoreOrder::getOneorderList(compact('uid','page','limit'))); } /** * 获取某用户的积分列表 */ public function getOneIntegralList($uid,$page=1,$limit=20){ return Json::successful(UserBillAdmin::getOneIntegralList(compact('uid','page','limit'))); } /** * 获取某用户的积分列表 */ public function getOneSignList($uid,$page=1,$limit=20){ return Json::successful(UserBillAdmin::getOneSignList(compact('uid','page','limit'))); } /** * 获取某用户的持有优惠劵 */ public function getOneCouponsList($uid,$page=1,$limit=20){ return Json::successful(StoreCouponUser::getOneCouponsList(compact('uid','page','limit'))); } /** * 获取某用户的余额变动记录 */ public function getOneBalanceChangList($uid,$page=1,$limit=20){ return Json::successful(UserBillAdmin::getOneBalanceChangList(compact('uid','page','limit'))); } } \ No newline at end of file diff --git a/application/admin/controller/user/UserNotice.php b/application/admin/controller/user/UserNotice.php index 13aa31563..6e0db1a57 100644 --- a/application/admin/controller/user/UserNotice.php +++ b/application/admin/controller/user/UserNotice.php @@ -25,8 +25,15 @@ class UserNotice extends AuthController */ public function index() { - $this->assign(UserNoticeModel::getList()); - return $this->fetch(); + if($this->request->isAjax()){ + $where=Util::getMore([ + ['page',1], + ['limit',20] + ]); + return Json::successlayui(UserNoticeModel::getList($where)); + }else{ + return $this->fetch(); + } } /** @@ -289,8 +296,9 @@ class UserNotice extends AuthController public function send_user($id = 0,$uid = '') { if(!$id || $uid == '') return JsonService::fail('参数错误'); - $uid = ",".$uid.","; - UserNoticeModel::edit(array("is_send"=>1,"send_time"=>time(),'uid'=>$uid),$id); + $uids = UserNoticeModel::where(['id'=>$id])->value('uid'); + $uid = rtrim($uids,',').",".$uid.","; + UserNoticeModel::edit(array("send_time"=>time(),'uid'=>$uid),$id); return Json::successful('发送成功!'); } } \ No newline at end of file diff --git a/application/admin/controller/wechat/Reply.php b/application/admin/controller/wechat/Reply.php index e5151fdc5..ff7b9a01a 100644 --- a/application/admin/controller/wechat/Reply.php +++ b/application/admin/controller/wechat/Reply.php @@ -16,16 +16,17 @@ use think\Request; */ class Reply extends AuthController { + /**关注回复 + * @return mixed|void + */ public function index() { if(empty(input('key'))) return $this->failed('请输入参数key'); if(empty(input('title'))) return $this->failed('请输入参数title'); - $replay = WechatReply::where('key',input('key'))->find(); - $replay_arr =!empty($replay) ? $replay->toArray() : []; - $replay_arr['data'] = json_decode(isset($replay_arr['data']) ? $replay_arr['data'] : '',true); - $this->assign('replay_arr',json_encode($replay_arr)); + $replay = WechatReply::getDataByKey(input('key')); + $this->assign('replay_arr',json_encode($replay)); $this->assign('key',input('key')); - $this->assign('title',input('title')); + $this->assign('title',urldecode(input('title'))); return $this->fetch(); } @@ -36,10 +37,8 @@ class Reply extends AuthController ],$this->request); // dump($where); // exit(); - if(!empty($where['key'])) $replay = WechatReply::where('key',$where['key'])->find(); - $replay_arr = $replay->toArray(); + if(!empty($where['key'])) $replay_arr = WechatReply::getDataByKey($where['key']); $replay_arr['code'] = 200; - $replay_arr['data'] = json_decode($replay_arr['data'],true); if(empty($replay_arr)) { $replay_arr['code'] = 0; } @@ -117,10 +116,8 @@ class Reply extends AuthController public function info_keyword(){ $key = input('key'); if(empty($key)) return $this->failed('参数错误,请重新修改'); - $replay = WechatReply::where('key',$key)->find(); - $replay_arr = $replay->toArray(); - $replay_arr['data'] = json_decode($replay_arr['data'],true); - $this->assign('replay_arr',json_encode($replay_arr)); + $replay = WechatReply::getDataByKey($key); + $this->assign('replay_arr',json_encode($replay)); $this->assign('key',$key); $this->assign('dis',2); return $this->fetch('add_keyword'); diff --git a/application/admin/controller/wechat/WechatUser.php b/application/admin/controller/wechat/WechatUser.php index 59b3bd2ae..bc1a1df3c 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/controller/widget/Images.php b/application/admin/controller/widget/Images.php index 8d8a348af..6151a151c 100644 --- a/application/admin/controller/widget/Images.php +++ b/application/admin/controller/widget/Images.php @@ -1,7 +1,6 @@ ['tid'=>0,'name'=>'编辑器','path'=>'editor'] - ,1=>['tid'=>1,'name'=>'产品图片','path'=>'store/product'] - ,2=>['tid'=>2,'name'=>'拼团图片','path'=>'store/combination'] - ,3=>['tid'=>3,'name'=>'砍价图片','path'=>'store/bargain'] - ,4=>['tid'=>4,'name'=>'秒杀图片','path'=>'store/seckill'] - ,5=>['tid'=>5,'name'=>'文章图片','path'=>'wechat/image'] - ,6=>['tid'=>6,'name'=>'组合数据图','path'=>'common'] - ]; /** * 附件列表 * @return \think\response\Json */ public function index() { - $pid = input('pid')!=''?input('pid'):0; + $pid = input('pid') != NULL ?input('pid'):session('pid'); + if($pid != NULL)session('pid',$pid); + if(!empty(session('pid')))$pid = session('pid'); $this->assign('pid',$pid); //分类标题 $typearray = Category::getAll(); @@ -46,17 +38,20 @@ class Images extends AuthController return $this->fetch('widget/images'); } /** - * 编辑器上传图片 + * 图片管理上传图片 * @return \think\response\Json */ public function upload() { - $pid = input('pid')!=''?input('pid'):0; - - $res = Upload::image('file',$pid.'/'.date('Ymd')); + $pid = input('pid')!= NULL ?input('pid'):session('pid'); + $res = Upload::image('file','attach'.DS.date('Y').DS.date('m').DS.date('d')); $thumbPath = Upload::thumb($res->dir); //产品图片上传记录 $fileInfo = $res->fileInfo->getinfo(); + //入口是public需要替换图片路径 + if(strpos(PUBILC_PATH,'public') == false){ + $res->dir = str_replace('public/','',$res->dir); + } SystemAttachmentModel::attachmentAdd($res->fileInfo->getSaveName(),$fileInfo['size'],$fileInfo['type'],$res->dir,$thumbPath,$pid); $info = array( // "originalName" => $fileInfo['name'], @@ -66,7 +61,7 @@ class Images extends AuthController // "type" => $fileInfo['type'], // "state" => "SUCCESS" 'code' =>200, - 'msg' =>'SUCCESS', + 'msg' =>'上传成功', 'src' =>$res->dir ); echo json_encode($info); @@ -92,19 +87,13 @@ class Images extends AuthController public function deleteimganddata($att_id){ $attinfo = SystemAttachmentModel::get($att_id)->toArray(); if($attinfo){ - if(strpos($attinfo['att_dir'],'public') !== false){ - @unlink(ROOT_PATH.ltrim($attinfo['att_dir'],'/')); - @unlink(ROOT_PATH.ltrim($attinfo['satt_dir'],'/')); - }else{ - @unlink(ROOT_PATH.ltrim('public'.$attinfo['att_dir'],'/')); - @unlink(ROOT_PATH.ltrim('public'.$attinfo['satt_dir'],'/')); - } - + @unlink(ROOT_PATH.ltrim($attinfo['att_dir'],'.')); + @unlink(ROOT_PATH.ltrim($attinfo['satt_dir'],'.')); SystemAttachmentModel::where(['att_id'=>$att_id])->delete(); } } /** - * 移动图片分类 + * 移动图片分类显示 */ public function moveimg($imgaes){ @@ -123,7 +112,7 @@ class Images extends AuthController return $this->fetch('public/form-builder'); } - /**移动图片 + /**移动图片分类操作 * @param Request $request * @param $id */ diff --git a/application/admin/model/finance/FinanceModel.php b/application/admin/model/finance/FinanceModel.php index a22ee6620..0242ce247 100644 --- a/application/admin/model/finance/FinanceModel.php +++ b/application/admin/model/finance/FinanceModel.php @@ -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') diff --git a/application/admin/model/order/StoreOrder.php b/application/admin/model/order/StoreOrder.php index d1d53c783..99da5ee6c 100644 --- a/application/admin/model/order/StoreOrder.php +++ b/application/admin/model/order/StoreOrder.php @@ -10,11 +10,15 @@ namespace app\admin\model\order; use app\admin\model\wechat\WechatUser; use app\admin\model\ump\StorePink; +use app\admin\model\order\StoreOrderCartInfo; use app\admin\model\store\StoreProduct; +use app\admin\model\routine\RoutineFormId; +use app\admin\model\routine\RoutineTemplate; use service\PHPExcelService; use traits\ModelTrait; use basic\ModelBasic; use service\WechatTemplateService; +use service\RoutineTemplateService; use think\Url; use think\Db; /** @@ -26,11 +30,174 @@ 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'); + } + if(isset($where['excel']) && $where['excel']==1){ + $data=($data=$model->select()) && count($data) ? $data->toArray() : []; + }else{ + $data=($data=$model->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() : []; + } +// $data=($data=$model->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() : []; + foreach ($data as &$item){ + $_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); + } + $item['_info'] = $_info; + $item['add_time'] = date('Y-m-d H:i:s',$item['add_time']); + 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::name('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']); @@ -52,7 +219,7 @@ class StoreOrder extends ModelBasic $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); @@ -80,37 +247,39 @@ 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(); + $_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); } $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,33 +362,114 @@ 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 * @return array */ public static function getOrderPrice($where){ + $where['is_del'] = 0;//删除订单不统计 $model = new self; $price = array(); $price['pay_price'] = 0;//支付金额 @@ -233,7 +483,7 @@ class StoreOrder extends ModelBasic $price['deduction_price'] = 0;//抵扣金额 $price['total_num'] = 0; //商品总数 $model = self::getOrderWhere($where,$model); - $list = $model->select()->toArray(); + $list = $model->where('is_del',0)->select()->toArray(); foreach ($list as $v){ $price['total_num'] = bcadd($price['total_num'],$v['total_num'],0); $price['pay_price'] = bcadd($price['pay_price'],$v['pay_price'],2); @@ -274,7 +524,7 @@ class StoreOrder extends ModelBasic $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); @@ -301,7 +551,7 @@ class StoreOrder extends ModelBasic 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); } @@ -631,28 +881,109 @@ class StoreOrder extends ModelBasic ] ]; } - /* - * 退款列表 - * $where array - * return array + + /**微信 订单发货 + * @param $oid + * @param array $postageData */ -// public static function getRefundList($where){ -// $refundlist=self::setEchatWhere($where)->field([ -// 'order_id','total_price','coupon_price','deduction_price', -// 'use_integral','FROM_UNIXTIME(add_time,"%Y-%m-%d") as add_time','FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time','combination_id', -// 'seckill_id','bargain_id','cost','status','cart_id','pay_price','refund_status' -// ])->page((int)$where['page'],(int)$where['limit'])->select(); -// count($refundlist) && $refundlist=$refundlist->toArray(); -// foreach($refundlist as &$item){ -// $item['product']=StoreProduct::where('id','in',function ($quers) use($item){ -// $quers->name('store_cart')->where('id','in',json_decode($item['cart_id'],true))->field('product_id'); -// })->field(['store_name','cost','price','image'])->select()->toArray(); -// if($item['refund_status']==1) { -// $item['_refund'] = '申请退款中'; -// }elseif ($item['refund_status']==2){ -// $item['_refund'] = '退款成功'; -// } -// } -// return $refundlist; -// } + public static function orderPostageAfter($oid,$postageData = []) + { + $order = self::where('id',$oid)->find(); + $openid = WechatUser::uidToOpenid($order['uid']); + $url = Url::build('wap/My/order',['uni'=>$order['order_id']],true,true); + $group = [ + 'first'=>'亲,您的订单已发货,请注意查收', + 'remark'=>'点击查看订单详情' + ]; + if($postageData['delivery_type'] == 'send'){//送货 + $goodsName = StoreOrderCartInfo::getProductNameList($order['id']); + $group = array_merge($group,[ + 'keyword1'=>$goodsName, + 'keyword2'=>$order['pay_type'] == 'offline' ? '线下支付' : date('Y/m/d H:i',$order['pay_time']), + 'keyword3'=>$order['user_address'], + 'keyword4'=>$postageData['delivery_name'], + 'keyword5'=>$postageData['delivery_id'] + ]); + WechatTemplateService::sendTemplate($openid,WechatTemplateService::ORDER_DELIVER_SUCCESS,$group,$url); + + }else if($postageData['delivery_type'] == 'express'){//发货 + $group = array_merge($group,[ + 'keyword1'=>$order['order_id'], + 'keyword2'=>$postageData['delivery_name'], + 'keyword3'=>$postageData['delivery_id'] + ]); + WechatTemplateService::sendTemplate($openid,WechatTemplateService::ORDER_POSTAGE_SUCCESS,$group,$url); + } + } + /** + * 小程序 订单发货提醒 + * @param int $oid + * @param array $postageData + * @return bool + */ + public static function sendOrderGoods($oid = 0,$postageData=array()){ + if(!$oid || !$postageData) return true; + $order = self::where('id',$oid)->find(); + $routine_openid = WechatUser::uidToRoutineOpenid($order['uid']); + if(!$routine_openid) return true; + if($postageData['delivery_type'] == 'send'){//送货 + $data['keyword1']['value'] = $order['order_id']; + $data['keyword2']['value'] = $order['delivery_name']; + $data['keyword3']['value'] = $order['delivery_id']; + $data['keyword4']['value'] = date('Y-m-d H:i:s',time()); + $data['keyword5']['value'] = '您的商品已经发货请注意查收'; + $formId = RoutineFormId::getFormIdOne($order['uid']); + if($formId){ + RoutineFormId::delFormIdOne($formId); + RoutineTemplateService::sendTemplate($routine_openid, + RoutineTemplateService::setTemplateId(RoutineTemplateService::ORDER_DELIVER_SUCCESS), + '', + $data, + $formId); + } + }else if($postageData['delivery_type'] == 'express'){//发货 + $data['keyword1']['value'] = $order['order_id']; + $data['keyword2']['value'] = $order['delivery_name']; + $data['keyword3']['value'] = $order['delivery_id']; + $data['keyword4']['value'] = date('Y-m-d H:i:s',time()); + $data['keyword5']['value'] = '您的商品已经发货请注意查收'; + $formId = RoutineFormId::getFormIdOne($order['uid']); + if($formId){ + RoutineFormId::delFormIdOne($formId); + RoutineTemplateService::sendTemplate($routine_openid, + RoutineTemplateService::setTemplateId(RoutineTemplateService::ORDER_POSTAGE_SUCCESS), + '', + $data, + $formId); + } + } + } + + + /** + * 获取订单总数 + * @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(); + } + /** + * 获取已支付的订单 + * @param int $is_promoter + * @return int|string + */ + public static function getOrderPayCount($is_promoter = 0){ + return self::where('o.paid',1)->alias('o')->join('User u','u.uid=o.uid')->where('u.is_promoter',$is_promoter)->count(); + } + + /** + * 获取最后一个月已支付的订单 + * @param int $is_promoter + * @return int|string + */ + public static function getOrderPayMonthCount($is_promoter = 0){ + return self::where('o.paid',1)->alias('o')->whereTime('o.pay_time','last month')->join('User u','u.uid=o.uid')->where('u.is_promoter',$is_promoter)->count(); + } } \ No newline at end of file diff --git a/application/admin/model/order/StoreOrderCartInfo.php b/application/admin/model/order/StoreOrderCartInfo.php new file mode 100644 index 000000000..ef5e86a8a --- /dev/null +++ b/application/admin/model/order/StoreOrderCartInfo.php @@ -0,0 +1,33 @@ + + * @day: 2017/12/26 + */ + +namespace app\admin\model\order; + + +use basic\ModelBasic; +use traits\ModelTrait; + +class StoreOrderCartInfo extends ModelBasic +{ + use ModelTrait; + + /** 获取订单产品列表 + * @param $oid + * @return array + */ + public static function getProductNameList($oid) + { + $cartInfo = self::where('oid',$oid)->select(); + $goodsName = []; + foreach ($cartInfo as $cart){ + $suk = isset($cart['cart_info']['productInfo']['attrInfo']) ? '('.$cart['cart_info']['productInfo']['attrInfo']['suk'].')' : ''; + $goodsName[] = $cart['cart_info']['productInfo']['store_name'].$suk; + } + return $goodsName; + } + +} \ No newline at end of file diff --git a/application/admin/model/record/StoreStatistics.php b/application/admin/model/record/StoreStatistics.php index 10c04cda6..04fe9cd38 100644 --- a/application/admin/model/record/StoreStatistics.php +++ b/application/admin/model/record/StoreStatistics.php @@ -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(); } } diff --git a/application/admin/model/routine/RoutineFormId.php b/application/admin/model/routine/RoutineFormId.php new file mode 100644 index 000000000..9a72b78c3 --- /dev/null +++ b/application/admin/model/routine/RoutineFormId.php @@ -0,0 +1,43 @@ +where('stop_time','LT',time())->delete(); + } + + /** + * 获取一个可以使用的formId + * @return bool|mixed + */ + public static function getFormIdOne($uid = 0){ + $formId = self::where('status',1)->where('stop_time','GT',time())->where('uid',$uid)->order('id asc')->find(); + if($formId) return $formId['form_id']; + else return false; + } + + /** + * 修改一个FormID为已使用 + * @param string $formId + * @return $this|bool + */ + public static function delFormIdOne($formId = ''){ + if($formId == '') return true; + return self::where('form_id',$formId)->update(['status'=>2]); + } +} \ No newline at end of file diff --git a/application/admin/model/store/StoreCategory.php b/application/admin/model/store/StoreCategory.php index 4b16e1cf5..7a4e13e24 100644 --- a/application/admin/model/store/StoreCategory.php +++ b/application/admin/model/store/StoreCategory.php @@ -7,7 +7,6 @@ namespace app\admin\model\store; - use traits\ModelTrait; use basic\ModelBasic; use service\UtilService; @@ -20,16 +19,39 @@ class StoreCategory extends ModelBasic { use ModelTrait; + /* + * 异步获取分类列表 + * @param $where + * @return array + */ + public static function CategoryList($where){ + $data=($data=self::systemPage($where,true)->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() :[]; + foreach ($data as &$item){ + if($item['pid']){ + $item['pid_name'] = self::where('id',$item['pid'])->value('cate_name'); + }else{ + $item['pid_name'] = '顶级'; + } + } + $count=self::systemPage($where,true)->count(); + return compact('count','data'); + } /** * @param $where * @return array */ - public static function systemPage($where){ + public static function systemPage($where,$isAjax=false){ $model = new self; if($where['pid'] != '') $model = $model->where('pid',$where['pid']); else if($where['pid']=='' && $where['cate_name']=='') $model = $model->where('pid',0); if($where['is_show'] != '') $model = $model->where('is_show',$where['is_show']); if($where['cate_name'] != '') $model = $model->where('cate_name','LIKE',"%$where[cate_name]%"); + if($isAjax===true){ + if(isset($where['order']) && $where['order']!=''){ + $model=$model->order(self::setOrder($where['order'])); + } + return $model; + } return self::page($model,function ($item){ if($item['pid']){ $item['pid_name'] = self::where('id',$item['pid'])->value('cate_name'); diff --git a/application/admin/model/store/StoreCouponUser.php b/application/admin/model/store/StoreCouponUser.php index 4300f71ce..3e3a2a014 100644 --- a/application/admin/model/store/StoreCouponUser.php +++ b/application/admin/model/store/StoreCouponUser.php @@ -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=[]; diff --git a/application/admin/model/store/StoreProduct.php b/application/admin/model/store/StoreProduct.php index 36998f4d9..3723f30e2 100644 --- a/application/admin/model/store/StoreProduct.php +++ b/application/admin/model/store/StoreProduct.php @@ -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 @@ -71,13 +95,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'])); @@ -249,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(); @@ -274,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(); @@ -366,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]%"); } @@ -386,7 +404,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'); } @@ -477,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', ], [ diff --git a/application/admin/model/store/StoreProductAttr.php b/application/admin/model/store/StoreProductAttr.php index d685496ba..910cb9451 100644 --- a/application/admin/model/store/StoreProductAttr.php +++ b/application/admin/model/store/StoreProductAttr.php @@ -77,7 +77,7 @@ class StoreProductAttr extends ModelBasic ]; } foreach ($valueList as $k=>$value){ - ksort($value['detail'],SORT_STRING); + sort($value['detail'],SORT_STRING); $suk = implode(',',$value['detail']); $valueGroup[$suk] = [ 'product_id'=>$productId, diff --git a/application/admin/model/system/SystemAttachment.php b/application/admin/model/system/SystemAttachment.php index aae35c070..fc16fd2ef 100644 --- a/application/admin/model/system/SystemAttachment.php +++ b/application/admin/model/system/SystemAttachment.php @@ -38,7 +38,7 @@ class SystemAttachment extends ModelBasic $model = new self; $where['pid'] = $id; $model->where($where)->order('att_id desc'); - return $model->page($model,$where,'',30); + return $model->page($model,$where,'',24); } /** * 获取单条信息 diff --git a/application/admin/model/system/SystemConfig.php b/application/admin/model/system/SystemConfig.php index 93702e472..b1219d55d 100644 --- a/application/admin/model/system/SystemConfig.php +++ b/application/admin/model/system/SystemConfig.php @@ -1 +1 @@ - * @day: 2017/11/02 */ namespace app\admin\model\system; use basic\ModelBasic; use service\FormBuilder as Form; use traits\ModelTrait; class SystemConfig extends ModelBasic { use ModelTrait; /** * 修改单个配置 * */ public static function setValue($menu,$value){ if(empty($menu) || !($config_one = self::get(['menu_name'=>$menu]))) return self::setErrorInfo('字段名称错误'); if($config_one['type'] == 'radio' || $config_one['type'] == 'checkbox'){ $parameter = array(); $option = array(); $parameter = explode(',',$config_one['parameter']); foreach ($parameter as $k=>$v){ if(isset($v) && !empty($v)){ $option[$k] = explode('-',$v); } } $value_arr = array();//选项的值 foreach ($option as $k=>$v){ foreach ($v as $kk=>$vv) if(!$kk){ $value_arr[$k] = $vv; } } $i = 0;// if(is_array($value)){ foreach ($value as $value_v){ if(in_array($value_v,$value_arr)){ $i++; } } if(count($value) != $i) return self::setErrorInfo('输入的值不属于选项中的参数'); }else{ if(in_array($value,$value_arr)){ $i++; } if(!$i) return self::setErrorInfo('输入的值不属于选项中的参数'); } if($config_one['type'] == 'radio' && is_array($value)) return self::setErrorInfo('单选按钮的值是字符串不是数组'); } $bool = self::edit(['value' => json_encode($value)],$menu,'menu_name'); return $bool; } /** * 获取单个参数配置 * */ public static function getValue($menu){ if(empty($menu) || !($config_one = self::get(['menu_name'=>$menu]))) return false; return json_decode($config_one['value'],true); } /** * 获得多个参数 * @param $menus * @return array */ public static function getMore($menus) { $menus = is_array($menus) ? implode(',',$menus) : $menus; $list = self::where('menu_name','IN',$menus)->column('value','menu_name')?:[]; foreach ($list as $menu => $value){ $list[$menu] = json_decode($value,true); } return $list; } public static function getAllConfig() { $list = self::column('value','menu_name')?:[]; foreach ($list as $menu => $value){ $list[$menu] = json_decode($value,true); } return $list; } /** * text 判断 * */ public static function valiDateTextRole($data){ if (!$data['width']) return self::setErrorInfo('请输入文本框的宽度'); if ($data['width'] <= 0) return self::setErrorInfo('请输入正确的文本框的宽度'); return true; } /** * radio 和 checkbox规则的判断 * */ public static function valiDateRadioAndCheckbox($data){ $parameter = array(); $option = array(); $option_new = array(); $data['parameter'] = str_replace("\r\n","\n",$data['parameter']);//防止不兼容 $parameter = explode("\n",$data['parameter']); if(count($parameter) < 2)return self::setErrorInfo('请输入正确格式的配置参数'); foreach ($parameter as $k=>$v){ if(isset($v) && !empty($v)){ $option[$k] = explode('=',$v); } } if(count($option) < 2)return self::setErrorInfo('请输入正确格式的配置参数'); $bool = 1; foreach ($option as $k=>$v){ $option_new[$k] = $option[$k][0]; foreach ($v as $kk=>$vv){ $vv_num = strlen($vv); if(!$vv_num){ $bool = 0; } } } // dump($option); if(!$bool)return self::setErrorInfo('请输入正确格式的配置参数'); $num1 = count($option_new);//提取该数组的数目 $arr2 = array_unique($option_new);//合并相同的元素 $num2 = count($arr2);//提取合并后数组个数 if($num1>$num2)return self::setErrorInfo('请输入正确格式的配置参数'); return true; } /** * textarea 判断 * */ public static function valiDateTextareaRole($data){ if (!$data['width']) return self::setErrorInfo('请输入多行文本框的宽度'); if (!$data['high']) return self::setErrorInfo('请输入多行文本框的高度'); if ($data['width'] < 0) return self::setErrorInfo('请输入正确的多行文本框的宽度'); if ($data['high'] < 0) return self::setErrorInfo('请输入正确的多行文本框的宽度'); return true; } /** * 获取一数据 * */ public static function getOneConfig($filed,$value){ $where[$filed] = $value; return self::where($where)->find(); } /** * 获取配置分类 * */ public static function getAll($id){ $where['config_tab_id'] = $id; $where['status'] = 1; return self::where($where)->order('sort desc,id asc')->select(); } /** * 获取所有配置分类 * */ public static function getConfigTabAll($type=0){ $configAll = \app\admin\model\system\SystemConfigTab::getAll($type); $config_tab = array(); foreach ($configAll as $k=>$v){ if(!$v['info']){ $config_tab[$k]['value'] = $v['id']; $config_tab[$k]['label'] = $v['title']; $config_tab[$k]['icon'] = $v['icon']; $config_tab[$k]['type'] = $v['type']; } } return $config_tab; } /** * 选择类型 * */ public static function radiotype($type='text'){ return [ ['value'=>'text','label'=>'文本框','disabled'=>1] ,['value'=>'textarea','label'=>'多行文本框','disabled'=>1] ,['value'=>'radio','label'=>'单选按钮','disabled'=>1] ,['value'=>'upload','label'=>'文件上传','disabled'=>1] ,['value'=>'checkbox','label'=>'多选按钮','disabled'=>1] ]; } /** * 文本框 * */ public static function createInputRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','text')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::input('value','默认值'); $formbuider[] = Form::number('width','文本框宽(%)',100); $formbuider[] = Form::input('required','验证规则')->placeholder('多个请用,隔开例如:required:true,url:true'); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 多行文本框 * */ public static function createTextAreaRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','textarea')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::textarea('value','默认值'); $formbuider[] = Form::number('width','文本框宽(%)',100); $formbuider[] = Form::number('high','多行文本框高(%)',5); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 单选按钮 * */ public static function createRadioRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','radio')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::textarea('parameter','配置参数')->placeholder("参数方式例如:\n1=男\n2=女\n3=保密"); $formbuider[] = Form::input('value','默认值'); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 文件上传 * */ public static function createUploadRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','upload')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::radio('upload_type','上传类型',1)->options([['value'=>1,'label'=>'单图'],['value'=>2,'label'=>'多图'],['value'=>3,'label'=>'文件']]); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 多选框 * */ public static function createCheckboxRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','checkbox')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::textarea('parameter','配置参数')->placeholder("参数方式例如:\n1=白色\n2=红色\n3=黑色"); $formbuider[] = Form::input('value','默认值'); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 插入数据到数据库 * */ public static function set($data) { return self::create($data); } } \ No newline at end of file + * @day: 2017/11/02 */ namespace app\admin\model\system; use basic\ModelBasic; use service\FormBuilder as Form; use traits\ModelTrait; use \app\admin\model\system\SystemConfigTab; class SystemConfig extends ModelBasic { use ModelTrait; /** * 修改单个配置 * */ public static function setValue($menu,$value){ if(empty($menu) || !($config_one = self::get(['menu_name'=>$menu]))) return self::setErrorInfo('字段名称错误'); if($config_one['type'] == 'radio' || $config_one['type'] == 'checkbox'){ $parameter = array(); $option = array(); $parameter = explode(',',$config_one['parameter']); foreach ($parameter as $k=>$v){ if(isset($v) && !empty($v)){ $option[$k] = explode('-',$v); } } $value_arr = array();//选项的值 foreach ($option as $k=>$v){ foreach ($v as $kk=>$vv) if(!$kk){ $value_arr[$k] = $vv; } } $i = 0;// if(is_array($value)){ foreach ($value as $value_v){ if(in_array($value_v,$value_arr)){ $i++; } } if(count($value) != $i) return self::setErrorInfo('输入的值不属于选项中的参数'); }else{ if(in_array($value,$value_arr)){ $i++; } if(!$i) return self::setErrorInfo('输入的值不属于选项中的参数'); } if($config_one['type'] == 'radio' && is_array($value)) return self::setErrorInfo('单选按钮的值是字符串不是数组'); } $bool = self::edit(['value' => json_encode($value)],$menu,'menu_name'); return $bool; } /** * 获取单个参数配置 * */ public static function getValue($menu){ if(empty($menu) || !($config_one = self::get(['menu_name'=>$menu]))) return false; return json_decode($config_one['value'],true); } /** * 获得多个参数 * @param $menus * @return array */ public static function getMore($menus) { $menus = is_array($menus) ? implode(',',$menus) : $menus; $list = self::where('menu_name','IN',$menus)->column('value','menu_name')?:[]; foreach ($list as $menu => $value){ $list[$menu] = json_decode($value,true); } return $list; } public static function getAllConfig() { $list = self::column('value','menu_name')?:[]; foreach ($list as $menu => $value){ $list[$menu] = json_decode($value,true); } return $list; } /** * text 判断 * */ public static function valiDateTextRole($data){ if (!$data['width']) return self::setErrorInfo('请输入文本框的宽度'); if ($data['width'] <= 0) return self::setErrorInfo('请输入正确的文本框的宽度'); return true; } /** * radio 和 checkbox规则的判断 * */ public static function valiDateRadioAndCheckbox($data){ $parameter = array(); $option = array(); $option_new = array(); $data['parameter'] = str_replace("\r\n","\n",$data['parameter']);//防止不兼容 $parameter = explode("\n",$data['parameter']); if(count($parameter) < 2)return self::setErrorInfo('请输入正确格式的配置参数'); foreach ($parameter as $k=>$v){ if(isset($v) && !empty($v)){ $option[$k] = explode('=>',$v); } } if(count($option) < 2)return self::setErrorInfo('请输入正确格式的配置参数'); $bool = 1; foreach ($option as $k=>$v){ $option_new[$k] = $option[$k][0]; foreach ($v as $kk=>$vv){ $vv_num = strlen($vv); if(!$vv_num){ $bool = 0; } } } // dump($option); if(!$bool)return self::setErrorInfo('请输入正确格式的配置参数'); $num1 = count($option_new);//提取该数组的数目 $arr2 = array_unique($option_new);//合并相同的元素 $num2 = count($arr2);//提取合并后数组个数 if($num1>$num2)return self::setErrorInfo('请输入正确格式的配置参数'); return true; } /** * textarea 判断 * */ public static function valiDateTextareaRole($data){ if (!$data['width']) return self::setErrorInfo('请输入多行文本框的宽度'); if (!$data['high']) return self::setErrorInfo('请输入多行文本框的高度'); if ($data['width'] < 0) return self::setErrorInfo('请输入正确的多行文本框的宽度'); if ($data['high'] < 0) return self::setErrorInfo('请输入正确的多行文本框的宽度'); return true; } /** * 获取一数据 * */ public static function getOneConfig($filed,$value){ $where[$filed] = $value; return self::where($where)->find(); } /** * 获取配置分类 * */ public static function getAll($id){ $where['config_tab_id'] = $id; $where['status'] = 1; return self::where($where)->order('sort desc,id asc')->select(); } /** * 获取所有配置分类 * */ public static function getConfigTabAll($type=0){ $configAll = SystemConfigTab::getAll($type); $config_tab = array(); foreach ($configAll as $k=>$v){ if(!$v['info']){ $config_tab[$k]['value'] = $v['id']; $config_tab[$k]['label'] = $v['title']; $config_tab[$k]['icon'] = $v['icon']; $config_tab[$k]['type'] = $v['type']; } } return $config_tab; } /** * 选择类型 * */ public static function radiotype($type='text'){ return [ ['value'=>'text','label'=>'文本框','disabled'=>1] ,['value'=>'textarea','label'=>'多行文本框','disabled'=>1] ,['value'=>'radio','label'=>'单选按钮','disabled'=>1] ,['value'=>'upload','label'=>'文件上传','disabled'=>1] ,['value'=>'checkbox','label'=>'多选按钮','disabled'=>1] ]; } /** * 文本框 * */ public static function createInputRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','text')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::input('value','默认值'); $formbuider[] = Form::number('width','文本框宽(%)',100); $formbuider[] = Form::input('required','验证规则')->placeholder('多个请用,隔开例如:required:true,url:true'); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 多行文本框 * */ public static function createTextAreaRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','textarea')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::textarea('value','默认值'); $formbuider[] = Form::number('width','文本框宽(%)',100); $formbuider[] = Form::number('high','多行文本框高(%)',5); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 单选按钮 * */ public static function createRadioRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','radio')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::textarea('parameter','配置参数')->placeholder("参数方式例如:\n1=>男\n2=>女\n3=>保密"); $formbuider[] = Form::input('value','默认值'); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 文件上传 * */ public static function createUploadRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','upload')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::radio('upload_type','上传类型',1)->options([['value'=>1,'label'=>'单图'],['value'=>2,'label'=>'多图'],['value'=>3,'label'=>'文件']]); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 多选框 * */ public static function createCheckboxRule($tab_id){ $formbuider = array(); $formbuider[] = Form::radio('type','类型','checkbox')->options(self::radiotype()); $formbuider[] = Form::select('config_tab_id','分类',$tab_id)->setOptions(SystemConfig::getConfigTabAll(-1)); $formbuider[] = Form::input('info','配置名称')->autofocus(1); $formbuider[] = Form::input('menu_name','字段变量')->placeholder('例如:site_url'); $formbuider[] = Form::input('desc','配置简介'); $formbuider[] = Form::textarea('parameter','配置参数')->placeholder("参数方式例如:\n1=>白色\n2=>红色\n3=>黑色"); // $formbuider[] = Form::input('value','默认值'); $formbuider[] = Form::number('sort','排序'); $formbuider[] = Form::radio('status','状态',1)->options([['value'=>1,'label'=>'显示'],['value'=>2,'label'=>'隐藏']]); return $formbuider; } /** * 插入数据到数据库 * */ public static function set($data) { return self::create($data); } } \ No newline at end of file diff --git a/application/admin/model/system/SystemConfigTab.php b/application/admin/model/system/SystemConfigTab.php index 04e61db3d..5c47e7609 100644 --- a/application/admin/model/system/SystemConfigTab.php +++ b/application/admin/model/system/SystemConfigTab.php @@ -1 +1 @@ - * @day: 2017/11/02 */ namespace app\admin\model\system; use traits\ModelTrait; use basic\ModelBasic; use think\Db; /** * 配置分类model * * Class SystemConfigTab * @package app\admin\model\system */ class SystemConfigTab extends ModelBasic { use ModelTrait; /** * 获取单选按钮或者多选按钮的显示值 * */ public static function getRadioOrCheckboxValueInfo($menu_name,$value){ $parameter = array(); $option = array(); $config_one = \app\admin\model\system\SystemConfig::getOneConfig('menu_name',$menu_name); // dump($config_one); // exit(); // if(empty($menu) || !($config_one = self::get(['menu_name'=>$menu]))) return false; $parameter = explode("\n",$config_one['parameter']); foreach ($parameter as $k=>$v){ if(isset($v) && !empty($v)){ $option[$k] = explode('=',$v); } } // $value = json_decode($value,true); if(!is_array($value)){ $value = explode("\n",$value); } // dump($value); // dump($option); $value_arr = array();//选项的值 foreach ($option as $k=>$v){ foreach ($v as $kk=>$vv){ if(is_array($value)) { if (in_array($v[0], $value)) { $value_arr[$k] = $v[1]; } } break; } } if(empty($value_arr)){ return '空'; } return $value_arr; // exit(); // if(is_array($value)){ // foreach ($value as $k=>$value_v){ // if(in_array($value_v,$value_arr)){ // $i[$k] = 1; // } // } // if(count($value) != $i) return self::setErrorInfo('输入的值不属于选项中的参数'); // }else{ // if(in_array($value,$value_arr)){ // $i++; // } // if(!$i) return self::setErrorInfo('输入的值不属于选项中的参数'); // } // if($config_one['type'] == 'radio' && is_array($value)) return self::setErrorInfo('单选按钮的值是字符串不是数组'); } /** * 插入数据到数据库 * */ public static function set($data) { return self::create($data); } /** * 获取全部 * */ public static function getAll($type = 0){ $where['status'] = 1; if($type>-1)$where['type'] = $type; return Db::name('SystemConfigTab')->where($where)->select(); } /** * 获取配置分类 * */ public static function getSystemConfigTabPage($where = array()) { $model = new self; if($where['title'] != '') $model = $model->where('title','LIKE',"%$where[title]%"); if($where['status'] != '') $model = $model->where('status',$where['status']); return self::page($model,$where); } public static function edit($data,$id,$field='id') { return self::update($data,[$field=>$id]); } /** * 更新数据 * @access public * @param array $data 数据数组 * @param array $where 更新条件 * @param array|true $field 允许字段 * @return $this */ public static function update($data = [], $where = [], $field = null) { $model = new static(); if (!empty($field)) { $model->allowField($field); } $result = $model->isUpdate(true)->save($data, $where); return $model; } } \ No newline at end of file + * @day: 2017/11/02 */ namespace app\admin\model\system; use traits\ModelTrait; use basic\ModelBasic; use think\Db; /** * 配置分类model * * Class SystemConfigTab * @package app\admin\model\system */ class SystemConfigTab extends ModelBasic { use ModelTrait; /** * 获取单选按钮或者多选按钮的显示值 * */ public static function getRadioOrCheckboxValueInfo($menu_name,$value){ $parameter = array(); $option = array(); $config_one = SystemConfig::getOneConfig('menu_name',$menu_name); $parameter = explode("\n",$config_one['parameter']); foreach ($parameter as $k=>$v){ if(isset($v) && strlen($v)>0){ $data = explode('=>',$v); $option[$data[0]] = $data[1]; } } $str = ''; if(is_array($value)){ foreach ($value as $v){ $str .= $option[$v].','; } }else{ $str .= !empty($value)?$option[$value]:$option[0]; } return $str; } /** * 插入数据到数据库 * */ public static function set($data) { return self::create($data); } /** * 获取全部 * */ public static function getAll($type = 0){ $where['status'] = 1; if($type>-1)$where['type'] = $type; return Db::name('SystemConfigTab')->where($where)->select(); } /** * 获取配置分类 * */ public static function getSystemConfigTabPage($where = array()) { $model = new self; if($where['title'] != '') $model = $model->where('title','LIKE',"%$where[title]%"); if($where['status'] != '') $model = $model->where('status',$where['status']); return self::page($model,$where); } public static function edit($data,$id,$field='id') { return self::update($data,[$field=>$id]); } /** * 更新数据 * @access public * @param array $data 数据数组 * @param array $where 更新条件 * @param array|true $field 允许字段 * @return $this */ public static function update($data = [], $where = [], $field = null) { $model = new static(); if (!empty($field)) { $model->allowField($field); } $result = $model->isUpdate(true)->save($data, $where); return $model; } } \ No newline at end of file diff --git a/application/admin/model/system/SystemGroupData.php b/application/admin/model/system/SystemGroupData.php index d9c8b9e7b..285541cde 100644 --- a/application/admin/model/system/SystemGroupData.php +++ b/application/admin/model/system/SystemGroupData.php @@ -28,6 +28,7 @@ class SystemGroupData extends ModelBasic $model = new self; if($params['gid'] !== '') $model = $model->where('gid',$params['gid']); if($params['status'] !== '') $model = $model->where('status',$params['status']); + $model = $model->order('sort desc,id ASC'); return self::page($model,function($item,$key){ $info = json_decode($item->value,true); foreach ($info as $index => $value) { diff --git a/application/admin/model/ump/StoreSeckill.php b/application/admin/model/ump/StoreSeckill.php index f3c69d0d7..56c8a5f39 100644 --- a/application/admin/model/ump/StoreSeckill.php +++ b/application/admin/model/ump/StoreSeckill.php @@ -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(); diff --git a/application/admin/model/user/User.php b/application/admin/model/user/User.php index 24df12162..a752537c3 100644 --- a/application/admin/model/user/User.php +++ b/application/admin/model/user/User.php @@ -1 +1 @@ - * @day: 2017/11/11 */ namespace app\admin\model\user; use app\admin\model\order\StoreOrder; use traits\ModelTrait; use app\wap\model\user\UserBill; use basic\ModelBasic; use app\admin\model\wechat\WechatUser; use app\admin\model\store\StoreCouponUser; use app\admin\model\user\UserExtract; /** * 用户管理 model * Class User * @package app\admin\model\user */ class User extends ModelBasic { use ModelTrait; /** * @param $where * @return array */ public static function systemPage($where){ $model = new self; if($where['status'] != '') $model = $model->where('status',$where['status']); if($where['is_promoter'] != '') $model = $model->where('is_promoter',$where['is_promoter']); if(isset($where['user_type']) && $where['user_type'] != '') $model = $model->where('user_type',$where['user_type']); if($where['nickname'] != '') $model = $model->where('nickname|uid','like',"%$where[nickname]%"); $model = $model->order('uid desc'); return self::page($model,function ($item){ if($item['spread_uid']){ $item['spread_uid_nickname'] = self::where('uid',$item['spread_uid'])->value('nickname'); }else{ $item['spread_uid_nickname'] = '无'; } },$where); } /** * 异步获取当前用户 信息 * @param $where * @return array */ public static function getUserList($where){ if($where['order']!=''){ $model=self::order(self::setOrder($where['order'])); }else{ $model=self::order('u.uid desc'); } if($where['user_time_type'] == 'visitno'){ list($startTime, $endTime) = explode(' - ', $where['user_time']); $model = $model->where('u.last_time', ['>', strtotime($endTime)], ['<', strtotime($startTime)],'or'); } if($where['user_time_type'] == 'visit'){ list($startTime, $endTime) = explode(' - ', $where['user_time']); $model = $model->where('u.last_time', '>', strtotime($startTime)); $model = $model->where('u.last_time', '<', strtotime($endTime)); } if($where['user_time_type'] == 'add_time'){ list($startTime, $endTime) = explode(' - ', $where['user_time']); $model = $model->where('u.add_time', '>', strtotime($startTime)); $model = $model->where('u.add_time', '<', strtotime($endTime)); } if($where['pay_count'] !== '') { if($where['pay_count'] == '-1') $model = $model->where('pay_count',0); else $model = $model->where('pay_count','>',$where['pay_count']); } if($where['country'] == 'domestic') $model = $model->where('w.country','EQ','中国'); else if($where['country'] == 'abroad') $model = $model->where('w.country','NEQ','中国'); // dump(self::setWherePage($model,$where,['w.province','w.city','u.status','u.is_promoter','u.user_type'],['u.nickname','u.uid'])); // dump($model); // dump($where); // exit(); $list = self::setWherePage($model,$where,['w.sex','w.province','w.city','u.status','u.is_promoter','u.user_type'],['u.nickname','u.uid']) ->alias('u') ->join('WechatUser w','u.uid=w.uid') ->field('u.*,w.country,w.province,w.city,w.sex,w.unionid,w.openid,w.routine_openid,w.groupid,w.tagid_list,w.subscribe,w.subscribe_time') ->page((int)$where['page'],(int)$where['limit']) ->select() ->each(function ($item){ $item['add_time']=date('Y-m-d H:i:s',$item['add_time']); if($item['last_time']) $item['last_time'] = date('Y-m-d H:i:s',$item['last_time']);//最近一次访问日期 else $item['last_time'] = '无访问';//最近一次访问日期 // self::edit(['pay_count'=>StoreOrder::getUserCountPay($item['uid'])],$item['uid']); $item['extract_count_price'] = UserExtract::getUserCountPrice($item['uid']);//累计提现 if($item['spread_uid']){ $item['spread_uid_nickname'] = self::where('uid',$item['spread_uid'])->value('nickname').'/'.$item['spread_uid']; }else{ $item['spread_uid_nickname'] = '无'; } if($item['user_type']=='wechat'){ $item['user_type']='微信类型'; }else if($item['user_type']=='routine'){ $item['user_type']='小程序类型'; }else $item['user_type']='其他类型'; if($item['sex'] == 1){ $item['sex']='男'; }else if($item['sex'] == 2){ $item['sex']='女'; }else $item['sex']='保密'; })->toArray(); // $model=self::getModelTime($where,$model,$where['time_visit'],'data',' - '); if($where['user_time_type'] == 'visitno'){ list($startTime, $endTime) = explode(' - ', $where['user_time']); $model = $model->where('u.last_time', ['>', strtotime($endTime)], ['<', strtotime($startTime)],'or'); } if($where['user_time_type'] == 'visit'){ list($startTime, $endTime) = explode(' - ', $where['user_time']); $model = $model->where('u.last_time', '>', strtotime($startTime)); $model = $model->where('u.last_time', '<', strtotime($endTime)); } if($where['user_time_type'] == 'add_time'){ list($startTime, $endTime) = explode(' - ', $where['user_time']); $model = $model->where('u.add_time', '>', strtotime($startTime)); $model = $model->where('u.add_time', '<', strtotime($endTime)); } if($where['pay_count'] !== '') $model = $model->where('pay_count','>',$where['pay_count']); if($where['country'] == 'domestic') $model = $model->where('w.country','EQ','中国'); else if($where['country'] == 'abroad') $model = $model->where('w.country','NEQ','中国'); $count=self::setWherePage($model,$where,['w.sex','w.province','w.city','u.status','u.is_promoter','u.user_type'],['u.nickname','u.uid'])->alias('u')->join('WechatUser w','u.uid=w.uid')->count(); return ['count'=>$count,'data'=>$list]; } /** * 修改用户状态 * @param $uids 用户uid * @param $status 修改状态 * @return array */ public static function destrSyatus($uids,$status){ if(empty($uids) && !is_array($uids)) return false; if($status=='') return false; self::beginTrans(); try{ $res=self::where('uid','in',$uids)->update(['status'=>$status]); self::checkTrans($res); return true; }catch (\Exception $e){ self::rollbackTrans(); return Json::fail($e->getMessage()); } } /* * 获取某季度,某年某年后的时间戳 * * self::getMonth('n',1) 获取当前季度的上个季度的时间戳 * self::getMonth('n') 获取当前季度的时间戳 */ public static function getMonth($time='',$ceil=0){ if(empty($time)){ $firstday = date("Y-m-01",time()); $lastday = date("Y-m-d",strtotime("$firstday +1 month -1 day")); }else if($time=='n'){ if($ceil!=0) $season = ceil(date('n') /3)-$ceil; else $season = ceil(date('n') /3); $firstday=date('Y-m-01',mktime(0,0,0,($season - 1) *3 +1,1,date('Y'))); $lastday=date('Y-m-t',mktime(0,0,0,$season * 3,1,date('Y'))); }else if($time=='y'){ $firstday=date('Y-01-01'); $lastday=date('Y-12-31'); }else if($time=='h'){ $firstday = date('Y-m-d', strtotime('this week +'.$ceil.' day')) . ' 00:00:00'; $lastday = date('Y-m-d', strtotime('this week +'.($ceil+1).' day')) . ' 23:59:59'; } return array($firstday,$lastday); } public static function getcount(){ return self::count(); } /* *获取用户某个时间段的消费信息 * * reutrn Array || number */ public static function consume($where,$status='',$keep=''){ $model = new self; $user_id=[]; if(is_array($where)){ if($where['is_promoter']!='') $model=$model->where('is_promoter',$where['is_promoter']); if($where['status']!='') $model=$model->where('status',$where['status']); switch ($where['date']){ case null:case 'today':case 'week':case 'year': if($where['date']==null){ $where['date']='month'; } if($keep){ $model=$model->whereTime('add_time',$where['date'])->whereTime('last_time',$where['date']); }else{ $model=$model->whereTime('add_time',$where['date']); } break; case 'quarter': $quarter=self::getMonth('n'); $startTime=strtotime($quarter[0]); $endTime=strtotime($quarter[1]); if($keep){ $model = $model->where('add_time','>',$startTime)->where('add_time','<',$endTime)->where('last_time','>',$startTime)->where('last_time','<',$endTime); }else{ $model = $model->where('add_time','>',$startTime)->where('add_time','<',$endTime); } break; default: //自定义时间 if(strstr($where['date'],'-')!==FALSE){ list($startTime,$endTime)=explode('-',$where['date']); $model = $model->where('add_time','>',strtotime($startTime))->where('add_time','<',strtotime($endTime)); }else{ $model=$model->whereTime('add_time','month'); } break; } }else{ if(is_array($status)){ $model=$model->where('add_time','>',$status[0])->where('add_time','<',$status[1]); } } if($keep===true){ return $model->count(); } if($status==='default'){ return $model->group('from_unixtime(add_time,\'%Y-%m-%d\')')->field('count(uid) num,from_unixtime(add_time,\'%Y-%m-%d\') add_time,uid')->select()->toArray(); } if($status==='grouping'){ return $model->group('user_type')->field('user_type')->select()->toArray(); } $uid=$model->field('uid')->select()->toArray(); foreach ($uid as $val){ $user_id[]=$val['uid']; } if(empty($user_id)){ $user_id=[0]; } if($status==='xiaofei'){ $list=UserBill::where('uid','in',$user_id) ->group('type') ->field('sum(number) as top_number,title') ->select() ->toArray(); $series=[ 'name'=>isset($list[0]['title'])?$list[0]['title']:'', 'type'=>'pie', 'radius'=> ['40%', '50%'], 'data'=>[] ]; foreach($list as $key=>$val){ $series['data'][$key]['value']=$val['top_number']; $series['data'][$key]['name']=$val['title']; } return $series; }else if($status==='form'){ $list=WechatUser::where('uid','in',$user_id)->group('city')->field('count(city) as top_city,city')->limit(0,10)->select()->toArray(); $count=self::getcount(); $option=[ 'legend_date'=>[], 'series_date'=>[] ]; foreach($list as $key=>$val){ $num=$count!=0?(bcdiv($val['top_city'],$count,2))*100:0; $t=['name'=>$num.'% '.(empty($val['city'])?'未知':$val['city']),'icon'=>'circle']; $option['legend_date'][$key]=$t; $option['series_date'][$key]=['value'=>$num,'name'=>$t['name']]; } return $option; }else{ $number=UserBill::where('uid','in',$user_id)->where('type','pay_product')->sum('number'); return $number; } } /* * 获取 用户某个时间段的钱数或者TOP20排行 * * return Array || number */ public static function getUserSpend($date,$status=''){ $model=new self(); $model=$model->alias('A'); switch ($date){ case null:case 'today':case 'week':case 'year': if($date==null) $date='month'; $model=$model->whereTime('A.add_time',$date); break; case 'quarter': list($startTime,$endTime)=User::getMonth('n'); $model = $model->where('A.add_time','>',strtotime($startTime)); $model = $model->where('A.add_time','<',strtotime($endTime)); break; default: list($startTime,$endTime)=explode('-',$date); $model = $model->where('A.add_time','>',strtotime($startTime)); $model = $model->where('A.add_time','<',strtotime($endTime)); break; } if($status===true){ return $model->join('user_bill B','B.uid=A.uid')->where('B.type','pay_product')->where('B.pm',0)->sum('B.number'); } $list=$model->join('user_bill B','B.uid=A.uid') ->where('B.type','pay_product') ->where('B.pm',0) ->field('sum(B.number) as totel_number,A.nickname,A.avatar,A.now_money,A.uid,A.add_time') ->order('totel_number desc') ->limit(0,20) ->select() ->toArray(); if(!isset($list[0]['totel_number'])){ $list=[]; } return $list; } /* * 获取 相对于上月或者其他的数据 * * return Array */ public static function getPostNumber($date,$status=false,$field='A.add_time',$t='消费'){ $model=new self(); if(!$status) $model=$model->alias('A'); switch ($date){ case null:case 'today':case 'week':case 'year': if($date==null) { $date='last month'; $title='相比上月用户'.$t.'增长'; } if($date=='today') { $date='yesterday'; $title='相比昨天用户'.$t.'增长'; } if($date=='week') { $date='last week'; $title='相比上周用户'.$t.'增长'; } if($date=='year') { $date='last year'; $title='相比去年用户'.$t.'增长'; } $model=$model->whereTime($field,$date); break; case 'quarter': $title='相比上季度用户'.$t.'增长'; list($startTime,$endTime)=User::getMonth('n',1); $model = $model->where($field,'>',$startTime); $model = $model->where($field,'<',$endTime); break; default: list($startTime,$endTime)=explode('-',$date); $title='相比'.$startTime.'-'.$endTime.'时间段用户'.$t.'增长'; $Time=strtotime($endTime)-strtotime($startTime); $model = $model->where($field,'>',strtotime($startTime)+$Time); $model = $model->where($field,'<',strtotime($endTime)+$Time); break; } if($status){ return [$model->count(),$title]; } $number=$model->join('user_bill B','B.uid=A.uid')->where('B.type','pay_product')->where('B.pm',0)->sum('B.number'); return [$number,$title]; } //获取用户新增,头部信息 public static function getBadgeList($where){ $user_count=self::setWherePage(self::getModelTime($where,new self),$where,['is_promoter','status'])->count(); $user_count_old=self::getOldDate($where)->count(); $fenxiao=self::setWherePage(self::getModelTime($where,new self),$where,['is_promoter','status'])->where('spread_uid','<>',0)->count(); $fenxiao_count=self::getOldDate($where)->where('spread_uid','neq',0)->count(); $newFemxiao_count=bcsub($fenxiao,$fenxiao_count,0); $order_count=bcsub($user_count,$user_count_old,0); return [ [ 'name'=>'会员人数', 'field'=>'个', 'count'=>$user_count, 'content'=>'会员总人数', 'background_color'=>'layui-bg-blue', 'sum'=>self::count(), 'class'=>'fa fa-bar-chart', ], [ 'name'=>'会员增长', 'field'=>'个', 'count'=>$order_count, 'content'=>'会员增长率', 'background_color'=>'layui-bg-cyan', 'sum'=>$user_count_old ? bcdiv($order_count,$user_count_old,2)*100:0, 'class'=>'fa fa-line-chart', ], [ 'name'=>'分销人数', 'field'=>'个', 'count'=>$fenxiao, 'content'=>'分销总人数', 'background_color'=>'layui-bg-green', 'sum'=>self::where('spread_uid','neq',0)->count(), 'class'=>'fa fa-bar-chart', ], [ 'name'=>'分销增长', 'field'=>'个', 'count'=>$newFemxiao_count, 'content'=>'分销总人数', 'background_color'=>'layui-bg-orange', 'sum'=>$fenxiao_count ? bcdiv($newFemxiao_count,$fenxiao_count,2)*100:0, 'class'=>'fa fa-cube', ], ]; } /* * 获取会员增长曲线图和分布图 * $where 查询条件 * $limit 显示条数,是否有滚动条 */ public static function getUserChartList($where,$limit=20){ $list=self::setWherePage(self::getModelTime($where,new self),$where,['is_promoter','status']) ->where('add_time','neq',0) ->field(['FROM_UNIXTIME(add_time,"%Y-%m-%d") as _add_time','count(uid) as num']) ->order('_add_time asc') ->group('_add_time') ->select(); count($list) && $list=$list->toArray(); $seriesdata=[]; $xdata=[]; $Zoom=''; foreach ($list as $item){ $seriesdata[]=$item['num']; $xdata[]=$item['_add_time']; } (count($xdata) > $limit) && $Zoom=$xdata[$limit-5]; //多次购物会员数量饼状图 $count=self::setWherePage(self::getModelTime($where,new self),$where,['is_promoter'])->count(); $user_count=self::setWherePage(self::getModelTime($where,self::alias('a')->join('store_order r','r.uid=a.uid'),'a.add_time'),$where,['is_promoter']) ->where('r.paid',1)->count('a.uid'); $shop_xdata=['多次购买数量占比','无购买数量占比']; $shop_data=[]; $count >0 && $shop_data=[ [ 'value'=>bcdiv($user_count,$count,2)*100, 'name'=>$shop_xdata[0], 'itemStyle'=>[ 'color'=>'#D789FF', ] ], [ 'value'=>bcdiv($count-$user_count,$count,2)*100, 'name'=>$shop_xdata[1], 'itemStyle'=>[ 'color'=>'#7EF0FB', ] ] ]; return compact('shop_data','shop_xdata','fenbu_data','fenbu_xdata','seriesdata','xdata','Zoom'); } //获取$date的前一天或者其他的时间段 public static function getOldDate($where,$moedls=null){ $model=$moedls ===null ? self::setWherePage(new self(),$where,['is_promoter','status']) :$moedls; switch ($where['data']){ case 'today': $model=$model->whereTime('add_time','yesterday'); break; case 'week': $model=$model->whereTime('add_time','last week'); break; case 'month': $model=$model->whereTime('add_time','last month'); break; case 'year': $model=$model->whereTime('add_time','last year'); break; case 'quarter': $time=self::getMonth('n',1); $model=$model->where('add_time','between',$time); break; } return $model; } //获取用户属性和性别分布图 public static function getEchartsData($where){ $model=self::alias('a'); $data=self::getModelTime($where,$model,'a.add_time') ->join('wechat_user r','r.uid=a.uid') ->group('r.province') ->field('count(r.province) as count,province') ->order('count desc') ->limit(15) ->select(); if(count($data)) $data=$data->toArray(); $legdata=[]; $dataList=[]; foreach ($data as $value){ $value['province']=='' && $value['province']='未知省份'; $legdata[]=$value['province']; $dataList[]=$value['count']; } $model=self::alias('a'); $sex=self::getModelTime($where,$model,'a.add_time') ->join('wechat_user r','r.uid=a.uid') ->group('r.sex') ->field('count(r.uid) as count,sex') ->order('count desc') ->select(); if(count($sex)) $sex=$sex->toArray(); $sexlegdata=['男','女','未知']; $sexcount=self::getModelTime($where,new self())->count(); $sexList=[]; $color=['#FB7773','#81BCFE','#91F3FE']; foreach ($sex as $key=>$item){ if($item['sex']==1){ $item_date['name']='男'; }else if($item['sex']==2){ $item_date['name']='女'; }else{ $item_date['name']='未知性别'; } $item_date['value']=bcdiv($item['count'],$sexcount,2)*100; $item_date['itemStyle']['color']=$color[$key]; $sexList[]=$item_date; } return compact('sexList','sexlegdata','legdata','dataList'); } //获取佣金记录列表 public static function getCommissionList($where){ $list=self::setCommissionWhere($where) ->page((int)$where['page'],(int)$where['limit']) ->select(); count($list) && $list=$list->toArray(); foreach ($list as &$value){ $value['ex_price']=db('user_extract')->where(['uid'=>$value['uid']])->sum('extract_price'); $value['extract_price']=db('user_extract')->where(['uid'=>$value['uid'],'status'=>1])->sum('extract_price'); } $count=self::setCommissionWhere($where)->count(); return ['data'=>$list,'count'=>$count]; } //获取佣金记录列表的查询条件 public static function setCommissionWhere($where){ $models=self::setWherePage(self::alias('A'),$where,[],['A.nickname','A.uid']) ->join('user_bill B','B.uid=A.uid') ->group('A.uid') ->where(['B.category'=>'now_money','B.type'=>'brokerage']) ->field(['sum(B.number) as sum_number','A.nickname','A.uid','A.now_money']); if($where['order']==''){ $models=$models->order('sum_number desc'); }else{ $models=$models->order($where['order']==1 ? 'sum_number desc':'sum_number asc'); } if($where['price_max']!='' && $where['price_min']!=''){ $models=$models->where('now_money','between',[$where['price_max'],$where['price_min']]); } return $models; } //获取某人用户推广信息 public static function getUserinfo($uid){ $userinfo=self::where(['uid'=>$uid])->field(['nickname','spread_uid','now_money','add_time'])->find()->toArray(); $userinfo['number']=UserBill::where(['category'=>'now_money','type'=>'brokerage'])->sum('number'); $userinfo['spread_name']=$userinfo['spread_uid'] ? self::where(['uid'=>$userinfo['spread_uid']])->value('nickname') :''; return $userinfo; } //获取某用户的详细信息 public static function getUserDetailed($uid){ $key_field=['real_name','phone','province','city','district','detail','post_code']; $Address=($thisAddress=db('user_address')->where(['uid'=>$uid,'is_default'=>1])->field($key_field)->find()) ? $thisAddress : db('user_address')->where(['uid'=>$uid])->field($key_field)->find(); $UserInfo=self::get($uid); return [ ['col'=>12,'name'=>'默认收货地址','value'=>'邮编:'.$thisAddress['post_code'].' 收货人电话:'.$thisAddress['phone'].' 地址:'.$thisAddress['province'].' '.$thisAddress['city'].' '.$thisAddress['district'].' '.$thisAddress['detail']], // ['name'=>'微信OpenID','value'=>WechatUser::where(['uid'=>$uid])->value('openid'),'col'=>8], ['name'=>'手机号码','value'=>$UserInfo['phone']], // ['name'=>'ID','value'=>$uid], ['name'=>'姓名','value'=>''], ['name'=>'微信昵称','value'=>$UserInfo['nickname']], ['name'=>'邮箱','value'=>''], ['name'=>'生日','value'=>''], ['name'=>'积分','value'=>UserBill::where(['category'=>'integral','uid'=>$uid])->where('type','in',['sign','system_add'])->sum('number')], ['name'=>'上级推广人','value'=>$UserInfo['spread_uid'] ? self::where(['uid'=>$UserInfo['spread_uid']])->value('nickname'):''], ['name'=>'账户余额','value'=>$UserInfo['now_money']], ['name'=>'佣金总收入','value'=>UserBill::where(['category'=>'now_money','type'=>'brokerage','uid'=>$uid])->sum('number')], ['name'=>'提现总金额','value'=>db('user_extract')->where(['uid'=>$uid,'status'=>1])->sum('extract_price')], ]; } //获取某用户的订单个数,消费明细 public static function getHeaderList($uid){ return [ [ 'title'=>'总计订单', 'value'=>StoreOrder::where(['uid'=>$uid])->count(), 'key'=>'笔', 'class'=>'', ], [ 'title'=>'总消费金额', 'value'=>StoreOrder::where(['uid'=>$uid,'paid'=>1])->sum('total_price'), 'key'=>'元', 'class'=>'', ], [ 'title'=>'本月订单', 'value'=>StoreOrder::where(['uid'=>$uid])->whereTime('add_time','month')->count(), 'key'=>'笔', 'class'=>'', ], [ 'title'=>'本月消费金额', 'value'=>StoreOrder::where(['uid'=>$uid])->whereTime('add_time','month')->sum('total_price'), 'key'=>'元', 'class'=>'', ] ]; } /* * 获取 会员 订单个数,积分明细,优惠劵明细 * * $uid 用户id; * * return array */ public static function getCountInfo($uid){ $order_count=StoreOrder::where(['uid'=>$uid])->count(); $integral_count=UserBill::where(['uid'=>$uid,'category'=>'integral'])->where('type','in',['deduction','system_add'])->count(); $sign_count=UserBill::where(['uid'=>$uid,'category'=>'integral','type'=>'sign'])->count(); $balanceChang_count=UserBill::where(['uid'=>$uid,'category'=>'now_money']) ->where('type','in',['system_add','pay_product','extract','pay_product_refund','system_sub']) ->count(); $coupon_count=StoreCouponUser::where(['uid'=>$uid])->count(); return compact('order_count','integral_count','sign_count','balanceChang_count','coupon_count'); } /* * 获取 会员业务的 * 购物会员统计 * 会员访问量 * * 曲线图 * * $where 查询条件 * * return array */ public static function getUserBusinessChart($where,$limit=20){ //获取购物会员人数趋势图 $list=self::getModelTime($where,self::where('a.status',1)->alias('a')->join('store_order r','r.uid=a.uid'),'a.add_time') ->where(['r.paid'=>1,'a.is_promoter'=>0]) ->where('a.add_time','neq',0) ->field(['FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as _add_time','count(r.uid) as count_user']) ->group('_add_time') ->order('_add_time asc') ->select(); count($list) && $list=$list->toArray(); $seriesdata=[]; $xdata=[]; $zoom=''; foreach ($list as $item){ $seriesdata[]=$item['count_user']; $xdata[]=$item['_add_time']; } count($xdata) > $limit && $zoom=$xdata[$limit-5]; //会员访问量 $visit=self::getModelTime($where,self::alias('a')->join('store_visit t','t.uid=a.uid'),'t.add_time') ->where('a.is_promoter',0) ->field(['FROM_UNIXTIME(t.add_time,"%Y-%m-%d") as _add_time','count(t.uid) as count_user']) ->group('_add_time') ->order('_add_time asc') ->select(); count($visit) && $visit=$visit->toArray(); $visit_data=[]; $visit_xdata=[]; $visit_zoom=''; foreach ($visit as $item){ $visit_data[]=$item['count_user']; $visit_xdata[]=$item['_add_time']; } count($visit_xdata) > $limit && $visit_zoom=$visit_xdata[$limit-5]; //多次购物会员数量饼状图 $count=self::getModelTime($where,self::where('is_promoter',0))->count(); $user_count=self::getModelTime($where,self::alias('a')->join('store_order r','r.uid=a.uid'),'a.add_time') ->where('a.is_promoter',0) ->where('r.paid',1) ->group('a.uid') ->count(); $shop_xdata=['多次购买数量占比','无购买数量占比']; $shop_data=[]; $count >0 && $shop_data=[ [ 'value'=>bcdiv($user_count,$count,2)*100, 'name'=>$shop_xdata[0], 'itemStyle'=>[ 'color'=>'#D789FF', ] ], [ 'value'=>bcdiv($count-$user_count,$count,2)*100, 'name'=>$shop_xdata[1], 'itemStyle'=>[ 'color'=>'#7EF0FB', ] ] ]; return compact('seriesdata','xdata','zoom','visit_data','visit_xdata','visit_zoom','shop_data','shop_xdata'); } /* * 获取用户 * 积分排行 * 会员余额排行榜 * 分销商佣金总额排行榜 * 购物笔数排行榜 * 购物金额排行榜 * 分销商佣金提现排行榜 * 上月消费排行榜 * $limit 查询多少条 * return array */ public static function getUserTop10List($limit=10,$is_promoter=0){ //积分排行 $integral=self::where('status',1) ->where('is_promoter',$is_promoter) ->order('integral desc') ->field(['nickname','phone','integral','FROM_UNIXTIME(add_time,"%Y-%m-%d") as add_time']) ->limit($limit) ->select(); count($integral) && $integral=$integral->toArray(); //会员余额排行榜 $now_money=self::where('status',1) ->where('is_promoter',$is_promoter) ->order('now_money desc') ->field(['nickname','phone','now_money','FROM_UNIXTIME(add_time,"%Y-%m-%d") as add_time']) ->limit($limit) ->select(); count($now_money) && $now_money=$now_money->toArray(); //购物笔数排行榜 $shopcount=self::alias('a') ->join('store_order r','r.uid=a.uid') ->where(['r.paid'=>1,'a.is_promoter'=>$is_promoter]) ->group('r.uid') ->field(['a.nickname','a.phone','count(r.uid) as sum_count','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time']) ->order('sum_count desc') ->limit($limit) ->select(); count($shopcount) && $shopcount=$shopcount->toArray(); //购物金额排行榜 $order=self::alias('a') ->join('store_order r','r.uid=a.uid') ->where(['r.paid'=>1,'a.is_promoter'=>$is_promoter]) ->group('r.uid') ->field(['a.nickname','a.phone','sum(r.pay_price) as sum_price','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time','r.uid']) ->order('sum_price desc') ->limit($limit) ->select(); count($order) && $order=$order->toArray(); //上月消费排行 $lastorder=self::alias('a') ->join('store_order r','r.uid=a.uid') ->where(['r.paid'=>1,'a.is_promoter'=>$is_promoter]) ->whereTime('r.pay_time','last month') ->group('r.uid') ->field(['a.nickname','a.phone','sum(r.pay_price) as sum_price','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time','r.uid']) ->order('sum_price desc') ->limit($limit) ->select(); return compact('integral','now_money','shopcount','order','lastorder'); } /* * 获取 会员业务 * 会员总余额 会员总积分 * $where 查询条件 * * return array */ public static function getUserBusinesHeade($where){ return [ [ 'name'=>'会员总余额', 'field'=>'元', 'count'=>self::getModelTime($where,self::where('status',1))->sum('now_money'), 'background_color'=>'layui-bg-cyan', 'col'=>6, ], [ 'name'=>'会员总积分', 'field'=>'分', 'count'=>self::getModelTime($where,self::where('status',1))->sum('integral'), 'background_color'=>'layui-bg-cyan', 'col'=>6 ] ]; } /* * 分销会员头部信息查询获取 * * 分销商总佣金余额 * 分销商总提现佣金 * 本月分销商业务佣金 * 本月分销商佣金提现金额 * 上月分销商业务佣金 * 上月分销商佣金提现金额 * $where array 时间条件 * * return array */ public static function getDistributionBadgeList($where){ return [ [ 'name'=>'分销商总佣金', 'field'=>'元', 'count'=>self::getModelTime($where,UserBill::where('category','now_money')->where('type','brokerage'))->where('uid','in',function($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->whereOr('spread_uid','neq',0)->field('uid'); })->sum('number'), 'background_color'=>'layui-bg-cyan', 'col'=>3, ], [ 'name'=>'分销商总佣金余额', 'field'=>'元', 'count'=>self::getModelTime($where,self::where('status',1)->where('is_promoter',1))->sum('now_money'), 'background_color'=>'layui-bg-cyan', 'col'=>3, ], [ 'name'=>'分销商总提现佣金', 'field'=>'元', 'count'=>self::getModelTime($where,UserExtract::where('status',1))->sum('extract_price'), 'background_color'=>'layui-bg-cyan', 'col'=>3, ], [ 'name'=>'本月分销商业务佣金', 'field'=>'元', 'count'=>self::getModelTime(['data'=>'month'],UserBill::where('category','now_money')->where('type','brokerage')) ->where('uid','in',function ($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->whereOr('spread_uid','neq',0)->field('uid'); })->sum('number'), 'background_color'=>'layui-bg-cyan', 'col'=>3, ], [ 'name'=>'本月分销商佣金提现金额', 'field'=>'元', 'count'=>self::getModelTime(['data'=>'month'],UserExtract::where('status',1)) ->where('uid','in',function ($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->field('uid'); })->sum('extract_price'), 'background_color'=>'layui-bg-cyan', 'col'=>4, ], [ 'name'=>'上月分销商业务佣金', 'field'=>'元', 'count'=>self::getOldDate(['data'=>'year'],UserBill::where('category','now_money')->where('uid','in',function ($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->whereOr('spread_uid','neq',0)->field('uid'); })->where('type','brokerage'))->sum('number'), 'background_color'=>'layui-bg-cyan', 'col'=>4, ], [ 'name'=>'上月分销商佣金提现金额', 'field'=>'元', 'count'=>self::getOldDate(['data'=>'year'],UserBill::where('category','now_money')->where('uid','in',function ($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->whereOr('spread_uid','neq',0)->field('uid'); })->where('type','brokerage'))->sum('number'), 'background_color'=>'layui-bg-cyan', 'col'=>4, ], ]; } /* * 分销会员 * 分销数量 饼状图 * 分销商会员访问量 曲线 * 获取购物会员人数趋势图 曲线 * 多次购物分销会员数量 饼状图 * $where array 条件 * $limit int n条数据后出拖动条 * return array */ public static function getUserDistributionChart($where,$limit=20){ //分销数量 $fenbu_user=self::getModelTime($where,new self)->field(['count(uid) as num'])->group('is_promoter')->select(); count($fenbu_user) && $fenbu_user=$fenbu_user->toArray(); $sum_user=0; $fenbu_data=[]; $fenbu_xdata=['分销商','非分销商']; $color=['#81BCFE','#91F3FE']; foreach($fenbu_user as $item){ $sum_user+=$item['num']; } foreach ($fenbu_user as $key=>$item){ $value['value']=bcdiv($item['num'],$sum_user,2)*100; $value['name']=isset($fenbu_xdata[$key]) ?$fenbu_xdata[$key].' %'.$value['value'] :''; $value['itemStyle']['color']=$color[$key]; $fenbu_data[]=$value; } //分销商会员访问量 $visit=self::getModelTime($where,self::alias('a')->join('store_visit t','t.uid=a.uid'),'t.add_time') ->where('a.is_promoter',1) ->field(['FROM_UNIXTIME(t.add_time,"%Y-%m-%d") as _add_time','count(t.uid) as count_user']) ->group('_add_time') ->order('_add_time asc') ->select(); count($visit) && $visit=$visit->toArray(); $visit_data=[]; $visit_xdata=[]; $visit_zoom=''; foreach ($visit as $item){ $visit_data[]=$item['count_user']; $visit_xdata[]=$item['_add_time']; } count($visit_xdata) > $limit && $visit_zoom=$visit_xdata[$limit-5]; //获取购物会员人数趋势图 $list=self::getModelTime($where,self::where('a.status',1)->alias('a')->join('store_order r','r.uid=a.uid'),'a.add_time') ->where(['r.paid'=>1,'a.is_promoter'=>1]) ->where('a.add_time','neq',0) ->field(['FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as _add_time','count(r.uid) as count_user']) ->group('_add_time') ->order('_add_time asc') ->select(); count($list) && $list=$list->toArray(); $seriesdata=[]; $xdata=[]; $zoom=''; foreach ($list as $item){ $seriesdata[]=$item['count_user']; $xdata[]=$item['_add_time']; } count($xdata) > $limit && $zoom=$xdata[$limit-5]; //多次购物分销会员数量饼状图 $count=self::getModelTime($where,self::where('is_promoter',1))->count(); $user_count=self::getModelTime($where,self::alias('a') ->join('store_order r','r.uid=a.uid'),'a.add_time') ->where('a.is_promoter',1) ->where('r.paid',1) ->group('a.uid') ->count(); $shop_xdata=['多次购买数量占比','无购买数量占比']; $shop_data=[]; $count >0 && $shop_data=[ [ 'value'=>bcdiv($user_count,$count,2)*100, 'name'=>$shop_xdata[0].$user_count.'人', 'itemStyle'=>[ 'color'=>'#D789FF', ] ], [ 'value'=>bcdiv($count-$user_count,$count,2)*100, 'name'=>$shop_xdata[1].($count-$user_count).'人', 'itemStyle'=>[ 'color'=>'#7EF0FB', ] ] ]; return compact('fenbu_data','fenbu_xdata','visit_data','visit_xdata','visit_zoom','seriesdata','xdata','zoom','shop_xdata','shop_data'); } /* * 分销商佣金提现排行榜 * 分销商佣金总额排行榜 * $limit 截取条数 * return array */ public static function getUserDistributionTop10List($limit){ //分销商佣金提现排行榜 $extract=self::alias('a') ->join('user_extract t','a.uid=t.uid') ->where(['t.status'=>1,'a.is_promoter'=>1]) ->group('t.uid') ->field(['a.nickname','a.phone','sum(t.extract_price) as sum_price','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time','t.uid']) ->order('sum_price desc') ->limit($limit) ->select(); count($extract) && $extract=$extract->toArray(); //分销商佣金总额排行榜 $commission=UserBill::alias('l') ->join('user a','l.uid=a.uid') ->where(['l.status'=>'1','l.category'=>'now_money','l.type'=>'brokerage','a.is_promoter'=>1]) ->group('l.uid') ->field(['a.nickname','a.phone','sum(number) as sum_number','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time']) ->order('sum_number desc') ->limit($limit) ->select(); count($commission) && $commission=$commission->toArray(); return compact('extract','commission'); } } \ No newline at end of file + * @day: 2017/11/11 */ namespace app\admin\model\user; use app\admin\model\order\StoreOrder; use traits\ModelTrait; use app\wap\model\user\UserBill; use basic\ModelBasic; use app\admin\model\wechat\WechatUser; use app\admin\model\store\StoreCouponUser; use app\admin\model\user\UserExtract; use think\Db; /** * 用户管理 model * Class User * @package app\admin\model\user */ class User extends ModelBasic { use ModelTrait; /** * @param $where * @return array */ public static function systemPage($where){ $model = new self; if($where['status'] != '') $model = $model->where('status',$where['status']); if($where['is_promoter'] != '') $model = $model->where('is_promoter',$where['is_promoter']); if(isset($where['user_type']) && $where['user_type'] != '') $model = $model->where('user_type',$where['user_type']); if($where['nickname'] != '') $model = $model->where('nickname|uid','like',"%$where[nickname]%"); $model = $model->order('uid desc'); return self::page($model,function ($item){ if($item['spread_uid']){ $item['spread_uid_nickname'] = self::where('uid',$item['spread_uid'])->value('nickname'); }else{ $item['spread_uid_nickname'] = '无'; } },$where); } /* * 设置搜索条件 * */ public static function setWhere($where) { if($where['order']!=''){ $model=self::order(self::setOrder($where['order'])); }else{ $model=self::order('u.uid desc'); } if($where['user_time_type'] == 'visitno' && $where['user_time'] != ''){ list($startTime, $endTime) = explode(' - ', $where['user_time']); $model = $model->where('u.last_time', ['>', strtotime($endTime)+24*3600], ['<', strtotime($startTime)],'or'); } if($where['user_time_type'] == 'visit' && $where['user_time'] != ''){ list($startTime, $endTime) = explode(' - ', $where['user_time']); $model = $model->where('u.last_time', '>', strtotime($startTime)); $model = $model->where('u.last_time', '<', strtotime($endTime)+24*3600); } if($where['user_time_type'] == 'add_time' && $where['user_time'] != ''){ list($startTime, $endTime) = explode(' - ', $where['user_time']); $model = $model->where('u.add_time', '>', strtotime($startTime)); $model = $model->where('u.add_time', '<', strtotime($endTime)+24*3600); } if($where['pay_count'] !== '') { if($where['pay_count'] == '-1') $model = $model->where('pay_count',0); else $model = $model->where('pay_count','>',$where['pay_count']); } if($where['user_type'] != ''){ if($where['user_type'] == 'routine') $model = $model->where('w.routine_openid','not null'); else if($where['user_type'] == 'wechat') $model = $model->where('w.openid','not null'); } if($where['country'] != ''){ if($where['country'] == 'domestic') $model = $model->where('w.country','EQ','中国'); else if($where['country'] == 'abroad') $model = $model->where('w.country','NEQ','中国'); } return $model; } /** * 异步获取当前用户 信息 * @param $where * @return array */ public static function getUserList($where){ $model = self::setWherePage(self::setWhere($where),$where,['w.sex','w.province','w.city','u.status','u.is_promoter'],['u.nickname','u.uid']); $list = $model->alias('u') ->join('WechatUser w','u.uid=w.uid') ->field('u.*,w.country,w.province,w.city,w.sex,w.unionid,w.openid,w.routine_openid,w.groupid,w.tagid_list,w.subscribe,w.subscribe_time') ->page((int)$where['page'],(int)$where['limit']) ->select() ->each(function ($item){ $item['add_time']=date('Y-m-d H:i:s',$item['add_time']); if($item['last_time']) $item['last_time'] = date('Y-m-d H:i:s',$item['last_time']);//最近一次访问日期 else $item['last_time'] = '无访问';//最近一次访问日期 self::edit(['pay_count'=>StoreOrder::getUserCountPay($item['uid'])],$item['uid']); $item['extract_count_price'] = UserExtract::getUserCountPrice($item['uid']);//累计提现 if($item['spread_uid']){ $item['spread_uid_nickname'] = self::where('uid',$item['spread_uid'])->value('nickname').'/'.$item['spread_uid']; }else{ $item['spread_uid_nickname'] = '无'; } if($item['openid'] != '' && $item['routine_openid'] != ''){ $item['user_type']='通用'; }else if($item['openid'] == '' && $item['routine_openid'] != ''){ $item['user_type']='小程序'; }else if($item['openid'] != '' && $item['routine_openid'] == ''){ $item['user_type']='公众号'; }else $item['user_type']='其他'; if($item['sex'] == 1){ $item['sex']='男'; }else if($item['sex'] == 2){ $item['sex']='女'; }else $item['sex']='保密'; })->toArray(); $count=self::setWherePage(self::setWhere($where),$where,['w.sex','w.province','w.city','u.status','u.is_promoter'],['u.nickname','u.uid'])->alias('u')->join('WechatUser w','u.uid=w.uid')->count(); return ['count'=>$count,'data'=>$list]; } /** * 修改用户状态 * @param $uids 用户uid * @param $status 修改状态 * @return array */ public static function destrSyatus($uids,$status){ if(empty($uids) && !is_array($uids)) return false; if($status=='') return false; self::beginTrans(); try{ $res=self::where('uid','in',$uids)->update(['status'=>$status]); self::checkTrans($res); return true; }catch (\Exception $e){ self::rollbackTrans(); return Json::fail($e->getMessage()); } } /* * 获取某季度,某年某年后的时间戳 * * self::getMonth('n',1) 获取当前季度的上个季度的时间戳 * self::getMonth('n') 获取当前季度的时间戳 */ public static function getMonth($time='',$ceil=0){ if(empty($time)){ $firstday = date("Y-m-01",time()); $lastday = date("Y-m-d",strtotime("$firstday +1 month -1 day")); }else if($time=='n'){ if($ceil!=0) $season = ceil(date('n') /3)-$ceil; else $season = ceil(date('n') /3); $firstday=date('Y-m-01',mktime(0,0,0,($season - 1) *3 +1,1,date('Y'))); $lastday=date('Y-m-t',mktime(0,0,0,$season * 3,1,date('Y'))); }else if($time=='y'){ $firstday=date('Y-01-01'); $lastday=date('Y-12-31'); }else if($time=='h'){ $firstday = date('Y-m-d', strtotime('this week +'.$ceil.' day')) . ' 00:00:00'; $lastday = date('Y-m-d', strtotime('this week +'.($ceil+1).' day')) . ' 23:59:59'; } return array($firstday,$lastday); } public static function getcount(){ return self::count(); } /* *获取用户某个时间段的消费信息 * * reutrn Array || number */ public static function consume($where,$status='',$keep=''){ $model = new self; $user_id=[]; if(is_array($where)){ if($where['is_promoter']!='') $model=$model->where('is_promoter',$where['is_promoter']); if($where['status']!='') $model=$model->where('status',$where['status']); switch ($where['date']){ case null:case 'today':case 'week':case 'year': if($where['date']==null){ $where['date']='month'; } if($keep){ $model=$model->whereTime('add_time',$where['date'])->whereTime('last_time',$where['date']); }else{ $model=$model->whereTime('add_time',$where['date']); } break; case 'quarter': $quarter=self::getMonth('n'); $startTime=strtotime($quarter[0]); $endTime=strtotime($quarter[1]); if($keep){ $model = $model->where('add_time','>',$startTime)->where('add_time','<',$endTime)->where('last_time','>',$startTime)->where('last_time','<',$endTime); }else{ $model = $model->where('add_time','>',$startTime)->where('add_time','<',$endTime); } break; default: //自定义时间 if(strstr($where['date'],'-')!==FALSE){ list($startTime,$endTime)=explode('-',$where['date']); $model = $model->where('add_time','>',strtotime($startTime))->where('add_time','<',strtotime($endTime)); }else{ $model=$model->whereTime('add_time','month'); } break; } }else{ if(is_array($status)){ $model=$model->where('add_time','>',$status[0])->where('add_time','<',$status[1]); } } if($keep===true){ return $model->count(); } if($status==='default'){ return $model->group('from_unixtime(add_time,\'%Y-%m-%d\')')->field('count(uid) num,from_unixtime(add_time,\'%Y-%m-%d\') add_time,uid')->select()->toArray(); } if($status==='grouping'){ return $model->group('user_type')->field('user_type')->select()->toArray(); } $uid=$model->field('uid')->select()->toArray(); foreach ($uid as $val){ $user_id[]=$val['uid']; } if(empty($user_id)){ $user_id=[0]; } if($status==='xiaofei'){ $list=UserBill::where('uid','in',$user_id) ->group('type') ->field('sum(number) as top_number,title') ->select() ->toArray(); $series=[ 'name'=>isset($list[0]['title'])?$list[0]['title']:'', 'type'=>'pie', 'radius'=> ['40%', '50%'], 'data'=>[] ]; foreach($list as $key=>$val){ $series['data'][$key]['value']=$val['top_number']; $series['data'][$key]['name']=$val['title']; } return $series; }else if($status==='form'){ $list=WechatUser::where('uid','in',$user_id)->group('city')->field('count(city) as top_city,city')->limit(0,10)->select()->toArray(); $count=self::getcount(); $option=[ 'legend_date'=>[], 'series_date'=>[] ]; foreach($list as $key=>$val){ $num=$count!=0?(bcdiv($val['top_city'],$count,2))*100:0; $t=['name'=>$num.'% '.(empty($val['city'])?'未知':$val['city']),'icon'=>'circle']; $option['legend_date'][$key]=$t; $option['series_date'][$key]=['value'=>$num,'name'=>$t['name']]; } return $option; }else{ $number=UserBill::where('uid','in',$user_id)->where('type','pay_product')->sum('number'); return $number; } } /* * 获取 用户某个时间段的钱数或者TOP20排行 * * return Array || number */ public static function getUserSpend($date,$status=''){ $model=new self(); $model=$model->alias('A'); switch ($date){ case null:case 'today':case 'week':case 'year': if($date==null) $date='month'; $model=$model->whereTime('A.add_time',$date); break; case 'quarter': list($startTime,$endTime)=User::getMonth('n'); $model = $model->where('A.add_time','>',strtotime($startTime)); $model = $model->where('A.add_time','<',strtotime($endTime)); break; default: list($startTime,$endTime)=explode('-',$date); $model = $model->where('A.add_time','>',strtotime($startTime)); $model = $model->where('A.add_time','<',strtotime($endTime)); break; } if($status===true){ return $model->join('user_bill B','B.uid=A.uid')->where('B.type','pay_product')->where('B.pm',0)->sum('B.number'); } $list=$model->join('user_bill B','B.uid=A.uid') ->where('B.type','pay_product') ->where('B.pm',0) ->field('sum(B.number) as totel_number,A.nickname,A.avatar,A.now_money,A.uid,A.add_time') ->order('totel_number desc') ->limit(0,20) ->select() ->toArray(); if(!isset($list[0]['totel_number'])){ $list=[]; } return $list; } /* * 获取 相对于上月或者其他的数据 * * return Array */ public static function getPostNumber($date,$status=false,$field='A.add_time',$t='消费'){ $model=new self(); if(!$status) $model=$model->alias('A'); switch ($date){ case null:case 'today':case 'week':case 'year': if($date==null) { $date='last month'; $title='相比上月用户'.$t.'增长'; } if($date=='today') { $date='yesterday'; $title='相比昨天用户'.$t.'增长'; } if($date=='week') { $date='last week'; $title='相比上周用户'.$t.'增长'; } if($date=='year') { $date='last year'; $title='相比去年用户'.$t.'增长'; } $model=$model->whereTime($field,$date); break; case 'quarter': $title='相比上季度用户'.$t.'增长'; list($startTime,$endTime)=User::getMonth('n',1); $model = $model->where($field,'>',$startTime); $model = $model->where($field,'<',$endTime); break; default: list($startTime,$endTime)=explode('-',$date); $title='相比'.$startTime.'-'.$endTime.'时间段用户'.$t.'增长'; $Time=strtotime($endTime)-strtotime($startTime); $model = $model->where($field,'>',strtotime($startTime)+$Time); $model = $model->where($field,'<',strtotime($endTime)+$Time); break; } if($status){ return [$model->count(),$title]; } $number=$model->join('user_bill B','B.uid=A.uid')->where('B.type','pay_product')->where('B.pm',0)->sum('B.number'); return [$number,$title]; } //获取用户新增,头部信息 public static function getBadgeList($where){ $user_count=self::setWherePage(self::getModelTime($where,new self),$where,['is_promoter','status'])->count(); $user_count_old=self::getOldDate($where)->count(); $fenxiao=self::setWherePage(self::getModelTime($where,new self),$where,['is_promoter','status'])->where('spread_uid','<>',0)->count(); $fenxiao_count=self::getOldDate($where)->where('spread_uid','neq',0)->count(); $newFemxiao_count=bcsub($fenxiao,$fenxiao_count,0); $order_count=bcsub($user_count,$user_count_old,0); return [ [ 'name'=>'会员人数', 'field'=>'个', 'count'=>$user_count, 'content'=>'会员总人数', 'background_color'=>'layui-bg-blue', 'sum'=>self::count(), 'class'=>'fa fa-bar-chart', ], [ 'name'=>'会员增长', 'field'=>'个', 'count'=>$order_count, 'content'=>'会员增长率', 'background_color'=>'layui-bg-cyan', 'sum'=>$user_count_old ? bcdiv($order_count,$user_count_old,2)*100:0, 'class'=>'fa fa-line-chart', ], [ 'name'=>'分销人数', 'field'=>'个', 'count'=>$fenxiao, 'content'=>'分销总人数', 'background_color'=>'layui-bg-green', 'sum'=>self::where('spread_uid','neq',0)->count(), 'class'=>'fa fa-bar-chart', ], [ 'name'=>'分销增长', 'field'=>'个', 'count'=>$newFemxiao_count, 'content'=>'分销总人数', 'background_color'=>'layui-bg-orange', 'sum'=>$fenxiao_count ? bcdiv($newFemxiao_count,$fenxiao_count,2)*100:0, 'class'=>'fa fa-cube', ], ]; } /* * 获取会员增长曲线图和分布图 * $where 查询条件 * $limit 显示条数,是否有滚动条 */ public static function getUserChartList($where,$limit=20){ $list=self::setWherePage(self::getModelTime($where,new self),$where,['is_promoter','status']) ->where('add_time','neq',0) ->field(['FROM_UNIXTIME(add_time,"%Y-%m-%d") as _add_time','count(uid) as num']) ->order('_add_time asc') ->group('_add_time') ->select(); count($list) && $list=$list->toArray(); $seriesdata=[]; $xdata=[]; $Zoom=''; foreach ($list as $item){ $seriesdata[]=$item['num']; $xdata[]=$item['_add_time']; } (count($xdata) > $limit) && $Zoom=$xdata[$limit-5]; //多次购物会员数量饼状图 $count=self::setWherePage(self::getModelTime($where,new self),$where,['is_promoter'])->count(); $user_count=self::setWherePage(self::getModelTime($where,self::alias('a')->join('__STORE_ORDER__ r','r.uid=a.uid'),'a.add_time'),$where,['is_promoter']) ->where('r.paid',1)->count('a.uid'); $shop_xdata=['多次购买数量占比','无购买数量占比']; $shop_data=[]; $count >0 && $shop_data=[ [ 'value'=>bcdiv($user_count,$count,2)*100, 'name'=>$shop_xdata[0], 'itemStyle'=>[ 'color'=>'#D789FF', ] ], [ 'value'=>bcdiv($count-$user_count,$count,2)*100, 'name'=>$shop_xdata[1], 'itemStyle'=>[ 'color'=>'#7EF0FB', ] ] ]; return compact('shop_data','shop_xdata','fenbu_data','fenbu_xdata','seriesdata','xdata','Zoom'); } //获取$date的前一天或者其他的时间段 public static function getOldDate($where,$moedls=null){ $model=$moedls ===null ? self::setWherePage(new self(),$where,['is_promoter','status']) :$moedls; switch ($where['data']){ case 'today': $model=$model->whereTime('add_time','yesterday'); break; case 'week': $model=$model->whereTime('add_time','last week'); break; case 'month': $model=$model->whereTime('add_time','last month'); break; case 'year': $model=$model->whereTime('add_time','last year'); break; case 'quarter': $time=self::getMonth('n',1); $model=$model->where('add_time','between',$time); break; } return $model; } //获取用户属性和性别分布图 public static function getEchartsData($where){ $model=self::alias('a'); $data=self::getModelTime($where,$model,'a.add_time') ->join('wechat_user r','r.uid=a.uid') ->group('r.province') ->field('count(r.province) as count,province') ->order('count desc') ->limit(15) ->select(); if(count($data)) $data=$data->toArray(); $legdata=[]; $dataList=[]; foreach ($data as $value){ $value['province']=='' && $value['province']='未知省份'; $legdata[]=$value['province']; $dataList[]=$value['count']; } $model=self::alias('a'); $sex=self::getModelTime($where,$model,'a.add_time') ->join('wechat_user r','r.uid=a.uid') ->group('r.sex') ->field('count(r.uid) as count,sex') ->order('count desc') ->select(); if(count($sex)) $sex=$sex->toArray(); $sexlegdata=['男','女','未知']; $sexcount=self::getModelTime($where,new self())->count(); $sexList=[]; $color=['#FB7773','#81BCFE','#91F3FE']; foreach ($sex as $key=>$item){ if($item['sex']==1){ $item_date['name']='男'; }else if($item['sex']==2){ $item_date['name']='女'; }else{ $item_date['name']='未知性别'; } $item_date['value']=bcdiv($item['count'],$sexcount,2)*100; $item_date['itemStyle']['color']=$color[$key]; $sexList[]=$item_date; } return compact('sexList','sexlegdata','legdata','dataList'); } //获取佣金记录列表 public static function getCommissionList($where){ $list=self::setCommissionWhere($where) ->page((int)$where['page'],(int)$where['limit']) ->select(); count($list) && $list=$list->toArray(); foreach ($list as &$value){ $value['ex_price']= Db::name('user_extract')->where(['uid'=>$value['uid']])->sum('extract_price'); $value['extract_price']= Db::name('user_extract')->where(['uid'=>$value['uid'],'status'=>1])->sum('extract_price'); } $count=self::setCommissionWhere($where)->count(); return ['data'=>$list,'count'=>$count]; } //获取佣金记录列表的查询条件 public static function setCommissionWhere($where){ $models=self::setWherePage(self::alias('A'),$where,[],['A.nickname','A.uid']) ->join('user_bill B','B.uid=A.uid') ->group('A.uid') ->where(['B.category'=>'now_money','B.type'=>'brokerage']) ->field(['sum(B.number) as sum_number','A.nickname','A.uid','A.now_money']); if($where['order']==''){ $models=$models->order('sum_number desc'); }else{ $models=$models->order($where['order']==1 ? 'sum_number desc':'sum_number asc'); } if($where['price_max']!='' && $where['price_min']!=''){ $models=$models->where('now_money','between',[$where['price_max'],$where['price_min']]); } return $models; } /**获取用户详细信息 * @param $uid * @return array */ public static function getUserInfos($uid) { $userInfo = self::where('uid',$uid)->find(); if(!$userInfo) exception('读取用户信息失败!'); return $userInfo->toArray(); } //获取某人用户推广信息 public static function getUserinfo($uid){ $userinfo=self::where(['uid'=>$uid])->field(['nickname','spread_uid','now_money','add_time'])->find()->toArray(); $userinfo['number']=UserBill::where(['category'=>'now_money','type'=>'brokerage'])->sum('number'); $userinfo['spread_name']=$userinfo['spread_uid'] ? self::where(['uid'=>$userinfo['spread_uid']])->value('nickname') :''; return $userinfo; } //获取某用户的详细信息 public static function getUserDetailed($uid){ $key_field=['real_name','phone','province','city','district','detail','post_code']; $Address=($thisAddress= Db::name('user_address')->where(['uid'=>$uid,'is_default'=>1])->field($key_field)->find()) ? $thisAddress : Db::name('user_address')->where(['uid'=>$uid])->field($key_field)->find(); $UserInfo=self::get($uid); return [ ['col'=>12,'name'=>'默认收货地址','value'=>$thisAddress ? '收货人:'.$thisAddress['real_name'].'邮编:'.$thisAddress['post_code'].' 收货人电话:'.$thisAddress['phone'].' 地址:'.$thisAddress['province'].' '.$thisAddress['city'].' '.$thisAddress['district'].' '.$thisAddress['detail'] : ''], // ['name'=>'微信OpenID','value'=>WechatUser::where(['uid'=>$uid])->value('openid'),'col'=>8], ['name'=>'手机号码','value'=>$UserInfo['phone']], // ['name'=>'ID','value'=>$uid], ['name'=>'姓名','value'=>''], ['name'=>'微信昵称','value'=>$UserInfo['nickname']], ['name'=>'邮箱','value'=>''], ['name'=>'生日','value'=>''], ['name'=>'积分','value'=>UserBill::where(['category'=>'integral','uid'=>$uid])->where('type','in',['sign','system_add'])->sum('number')], ['name'=>'上级推广人','value'=>$UserInfo['spread_uid'] ? self::where(['uid'=>$UserInfo['spread_uid']])->value('nickname'):''], ['name'=>'账户余额','value'=>$UserInfo['now_money']], ['name'=>'佣金总收入','value'=>UserBill::where(['category'=>'now_money','type'=>'brokerage','uid'=>$uid])->sum('number')], ['name'=>'提现总金额','value'=> Db::name('user_extract')->where(['uid'=>$uid,'status'=>1])->sum('extract_price')], ]; } //获取某用户的订单个数,消费明细 public static function getHeaderList($uid){ return [ [ 'title'=>'总计订单', 'value'=>StoreOrder::where(['uid'=>$uid])->count(), 'key'=>'笔', 'class'=>'', ], [ 'title'=>'总消费金额', 'value'=>StoreOrder::where(['uid'=>$uid,'paid'=>1])->sum('total_price'), 'key'=>'元', 'class'=>'', ], [ 'title'=>'本月订单', 'value'=>StoreOrder::where(['uid'=>$uid])->whereTime('add_time','month')->count(), 'key'=>'笔', 'class'=>'', ], [ 'title'=>'本月消费金额', 'value'=>StoreOrder::where(['uid'=>$uid])->whereTime('add_time','month')->sum('total_price'), 'key'=>'元', 'class'=>'', ] ]; } /* * 获取 会员 订单个数,积分明细,优惠劵明细 * * $uid 用户id; * * return array */ public static function getCountInfo($uid){ $order_count=StoreOrder::where(['uid'=>$uid])->count(); $integral_count=UserBill::where(['uid'=>$uid,'category'=>'integral'])->where('type','in',['deduction','system_add'])->count(); $sign_count=UserBill::where(['uid'=>$uid,'category'=>'integral','type'=>'sign'])->count(); $balanceChang_count=UserBill::where(['uid'=>$uid,'category'=>'now_money']) ->where('type','in',['system_add','pay_product','extract','pay_product_refund','system_sub']) ->count(); $coupon_count=StoreCouponUser::where(['uid'=>$uid])->count(); $spread_count=self::where(['spread_uid'=>$uid])->count(); return compact('order_count','integral_count','sign_count','balanceChang_count','coupon_count','spread_count'); } /* * 获取 会员业务的 * 购物会员统计 * 会员访问量 * * 曲线图 * * $where 查询条件 * * return array */ public static function getUserBusinessChart($where,$limit=20){ //获取购物会员人数趋势图 $list=self::getModelTime($where,self::where('a.status',1)->alias('a')->join('__STORE_ORDER__ r','r.uid=a.uid'),'a.add_time') ->where(['r.paid'=>1,'a.is_promoter'=>0]) ->where('a.add_time','neq',0) ->field(['FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as _add_time','count(r.uid) as count_user']) ->group('_add_time') ->order('_add_time asc') ->select(); count($list) && $list=$list->toArray(); $seriesdata=[]; $xdata=[]; $zoom=''; foreach ($list as $item){ $seriesdata[]=$item['count_user']; $xdata[]=$item['_add_time']; } count($xdata) > $limit && $zoom=$xdata[$limit-5]; //会员访问量 $visit=self::getModelTime($where,self::alias('a')->join('__STORE_VISIT__ t','t.uid=a.uid'),'t.add_time') ->where('a.is_promoter',0) ->field(['FROM_UNIXTIME(t.add_time,"%Y-%m-%d") as _add_time','count(t.uid) as count_user']) ->group('_add_time') ->order('_add_time asc') ->select(); count($visit) && $visit=$visit->toArray(); $visit_data=[]; $visit_xdata=[]; $visit_zoom=''; foreach ($visit as $item){ $visit_data[]=$item['count_user']; $visit_xdata[]=$item['_add_time']; } count($visit_xdata) > $limit && $visit_zoom=$visit_xdata[$limit-5]; //多次购物会员数量饼状图 $count=self::getModelTime($where,self::where('is_promoter',0))->count(); $user_count=self::getModelTime($where,self::alias('a')->join('__STORE_ORDER__ r','r.uid=a.uid'),'a.add_time') ->where('a.is_promoter',0) ->where('r.paid',1) ->group('a.uid') ->count(); $shop_xdata=['多次购买数量占比','无购买数量占比']; $shop_data=[]; $count >0 && $shop_data=[ [ 'value'=>bcdiv($user_count,$count,2)*100, 'name'=>$shop_xdata[0], 'itemStyle'=>[ 'color'=>'#D789FF', ] ], [ 'value'=>bcdiv($count-$user_count,$count,2)*100, 'name'=>$shop_xdata[1], 'itemStyle'=>[ 'color'=>'#7EF0FB', ] ] ]; return compact('seriesdata','xdata','zoom','visit_data','visit_xdata','visit_zoom','shop_data','shop_xdata'); } /* * 获取用户 * 积分排行 * 会员余额排行榜 * 分销商佣金总额排行榜 * 购物笔数排行榜 * 购物金额排行榜 * 分销商佣金提现排行榜 * 上月消费排行榜 * $limit 查询多少条 * return array */ public static function getUserTop10List($limit=10,$is_promoter=0){ //积分排行 $integral=self::where('status',1) ->where('is_promoter',$is_promoter) ->order('integral desc') ->field(['nickname','phone','integral','FROM_UNIXTIME(add_time,"%Y-%m-%d") as add_time']) ->limit($limit) ->select(); count($integral) && $integral=$integral->toArray(); //会员余额排行榜 $now_money=self::where('status',1) ->where('is_promoter',$is_promoter) ->order('now_money desc') ->field(['nickname','phone','now_money','FROM_UNIXTIME(add_time,"%Y-%m-%d") as add_time']) ->limit($limit) ->select(); count($now_money) && $now_money=$now_money->toArray(); //购物笔数排行榜 $orderPayCount = StoreOrder::getOrderPayCount($is_promoter); if($orderPayCount){ $shopcount=self::alias('a') ->join('__STORE_ORDER__ r','r.uid=a.uid') ->where(['r.paid'=>1,'a.is_promoter'=>$is_promoter]) ->group('r.uid') ->field(['a.nickname','a.phone','count(r.uid) as sum_count','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time']) ->order('sum_count desc') ->limit($limit) ->select(); }else $shopcount = []; count($shopcount) && $shopcount=$shopcount->toArray(); //购物金额排行榜 if($orderPayCount){ $order=self::alias('a') ->join('__STORE_ORDER__ r','r.uid=a.uid') ->where(['r.paid'=>1,'a.is_promoter'=>$is_promoter]) ->group('r.uid') ->field(['a.nickname','a.phone','sum(r.pay_price) as sum_price','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time','r.uid']) ->order('sum_price desc') ->limit($limit) ->select(); }else $order = []; count($order) && $order=$order->toArray(); //上月消费排行 $orderPayCount = StoreOrder::getOrderPayMonthCount($is_promoter); if($orderPayCount){ $lastorder=self::alias('a') ->join('__STORE_ORDER__ r','r.uid=a.uid') ->where(['r.paid'=>1,'a.is_promoter'=>$is_promoter]) // ->whereTime('r.pay_time','last month') ->where('r.pay_time','between',[strtotime(date('Y-m',strtotime('-1 month'))),strtotime(date('Y-m'))]) ->group('r.uid') ->field(['a.nickname','a.phone','sum(r.pay_price) as sum_price','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time','r.uid']) ->order('sum_price desc') ->limit($limit) ->select(); }else $lastorder = []; count($lastorder) && $lastorder=$lastorder->toArray(); return compact('integral','now_money','shopcount','order','lastorder'); } /* * 获取 会员业务 * 会员总余额 会员总积分 * $where 查询条件 * * return array */ public static function getUserBusinesHeade($where){ return [ [ 'name'=>'会员总余额', 'field'=>'元', 'count'=>self::getModelTime($where,self::where('status',1))->sum('now_money'), 'background_color'=>'layui-bg-cyan', 'col'=>6, ], [ 'name'=>'会员总积分', 'field'=>'分', 'count'=>self::getModelTime($where,self::where('status',1))->sum('integral'), 'background_color'=>'layui-bg-cyan', 'col'=>6 ] ]; } /* * 分销会员头部信息查询获取 * * 分销商总佣金余额 * 分销商总提现佣金 * 本月分销商业务佣金 * 本月分销商佣金提现金额 * 上月分销商业务佣金 * 上月分销商佣金提现金额 * $where array 时间条件 * * return array */ public static function getDistributionBadgeList($where){ return [ [ 'name'=>'分销商总佣金', 'field'=>'元', 'count'=>self::getModelTime($where,UserBill::where('category','now_money')->where('type','brokerage'))->where('uid','in',function($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->whereOr('spread_uid','neq',0)->field('uid'); })->sum('number'), 'background_color'=>'layui-bg-cyan', 'col'=>3, ], [ 'name'=>'分销商总佣金余额', 'field'=>'元', 'count'=>self::getModelTime($where,self::where('status',1)->where('is_promoter',1))->sum('now_money'), 'background_color'=>'layui-bg-cyan', 'col'=>3, ], [ 'name'=>'分销商总提现佣金', 'field'=>'元', 'count'=>self::getModelTime($where,UserExtract::where('status',1))->sum('extract_price'), 'background_color'=>'layui-bg-cyan', 'col'=>3, ], [ 'name'=>'本月分销商业务佣金', 'field'=>'元', 'count'=>self::getModelTime(['data'=>'month'],UserBill::where('category','now_money')->where('type','brokerage')) ->where('uid','in',function ($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->whereOr('spread_uid','neq',0)->field('uid'); })->sum('number'), 'background_color'=>'layui-bg-cyan', 'col'=>3, ], [ 'name'=>'本月分销商佣金提现金额', 'field'=>'元', 'count'=>self::getModelTime(['data'=>'month'],UserExtract::where('status',1)) ->where('uid','in',function ($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->field('uid'); })->sum('extract_price'), 'background_color'=>'layui-bg-cyan', 'col'=>4, ], [ 'name'=>'上月分销商业务佣金', 'field'=>'元', 'count'=>self::getOldDate(['data'=>'year'],UserBill::where('category','now_money')->where('uid','in',function ($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->whereOr('spread_uid','neq',0)->field('uid'); })->where('type','brokerage'))->sum('number'), 'background_color'=>'layui-bg-cyan', 'col'=>4, ], [ 'name'=>'上月分销商佣金提现金额', 'field'=>'元', 'count'=>self::getOldDate(['data'=>'year'],UserBill::where('category','now_money')->where('uid','in',function ($query){ $query->name('user')->where('status',1)->where('is_promoter',1)->whereOr('spread_uid','neq',0)->field('uid'); })->where('type','brokerage'))->sum('number'), 'background_color'=>'layui-bg-cyan', 'col'=>4, ], ]; } /* * 分销会员 * 分销数量 饼状图 * 分销商会员访问量 曲线 * 获取购物会员人数趋势图 曲线 * 多次购物分销会员数量 饼状图 * $where array 条件 * $limit int n条数据后出拖动条 * return array */ public static function getUserDistributionChart($where,$limit=20){ //分销数量 $fenbu_user=self::getModelTime($where,new self)->field(['count(uid) as num'])->group('is_promoter')->select(); count($fenbu_user) && $fenbu_user=$fenbu_user->toArray(); $sum_user=0; $fenbu_data=[]; $fenbu_xdata=['分销商','非分销商']; $color=['#81BCFE','#91F3FE']; foreach($fenbu_user as $item){ $sum_user+=$item['num']; } foreach ($fenbu_user as $key=>$item){ $value['value']=bcdiv($item['num'],$sum_user,2)*100; $value['name']=isset($fenbu_xdata[$key]) ?$fenbu_xdata[$key].' %'.$value['value'] :''; $value['itemStyle']['color']=$color[$key]; $fenbu_data[]=$value; } //分销商会员访问量 $visit=self::getModelTime($where,self::alias('a')->join('__STORE_VISIT__ t','t.uid=a.uid'),'t.add_time') ->where('a.is_promoter',1) ->field(['FROM_UNIXTIME(t.add_time,"%Y-%m-%d") as _add_time','count(t.uid) as count_user']) ->group('_add_time') ->order('_add_time asc') ->select(); count($visit) && $visit=$visit->toArray(); $visit_data=[]; $visit_xdata=[]; $visit_zoom=''; foreach ($visit as $item){ $visit_data[]=$item['count_user']; $visit_xdata[]=$item['_add_time']; } count($visit_xdata) > $limit && $visit_zoom=$visit_xdata[$limit-5]; //获取购物会员人数趋势图 $list=self::getModelTime($where,self::where('a.status',1)->alias('a')->join('__STORE_ORDER__ r','r.uid=a.uid'),'a.add_time') ->where(['r.paid'=>1,'a.is_promoter'=>1]) ->where('a.add_time','neq',0) ->field(['FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as _add_time','count(r.uid) as count_user']) ->group('_add_time') ->order('_add_time asc') ->select(); count($list) && $list=$list->toArray(); $seriesdata=[]; $xdata=[]; $zoom=''; foreach ($list as $item){ $seriesdata[]=$item['count_user']; $xdata[]=$item['_add_time']; } count($xdata) > $limit && $zoom=$xdata[$limit-5]; //多次购物分销会员数量饼状图 $count=self::getModelTime($where,self::where('is_promoter',1))->count(); $user_count=self::getModelTime($where,self::alias('a') ->join('__STORE_ORDER__ r','r.uid=a.uid'),'a.add_time') ->where('a.is_promoter',1) ->where('r.paid',1) ->group('a.uid') ->count(); $shop_xdata=['多次购买数量占比','无购买数量占比']; $shop_data=[]; $count >0 && $shop_data=[ [ 'value'=>bcdiv($user_count,$count,2)*100, 'name'=>$shop_xdata[0].$user_count.'人', 'itemStyle'=>[ 'color'=>'#D789FF', ] ], [ 'value'=>bcdiv($count-$user_count,$count,2)*100, 'name'=>$shop_xdata[1].($count-$user_count).'人', 'itemStyle'=>[ 'color'=>'#7EF0FB', ] ] ]; return compact('fenbu_data','fenbu_xdata','visit_data','visit_xdata','visit_zoom','seriesdata','xdata','zoom','shop_xdata','shop_data'); } /* * 分销商佣金提现排行榜 * 分销商佣金总额排行榜 * $limit 截取条数 * return array */ public static function getUserDistributionTop10List($limit){ //分销商佣金提现排行榜 $extract=self::alias('a') ->join('user_extract t','a.uid=t.uid') ->where(['t.status'=>1,'a.is_promoter'=>1]) ->group('t.uid') ->field(['a.nickname','a.phone','sum(t.extract_price) as sum_price','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time','t.uid']) ->order('sum_price desc') ->limit($limit) ->select(); count($extract) && $extract=$extract->toArray(); //分销商佣金总额排行榜 $commission=UserBill::alias('l') ->join('user a','l.uid=a.uid') ->where(['l.status'=>'1','l.category'=>'now_money','l.type'=>'brokerage','a.is_promoter'=>1]) ->group('l.uid') ->field(['a.nickname','a.phone','sum(number) as sum_number','FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as add_time']) ->order('sum_number desc') ->limit($limit) ->select(); count($commission) && $commission=$commission->toArray(); return compact('extract','commission'); } public static function getSpreadList($uid,$page,$limit){ $list=self::where(['spread_uid'=>$uid])->field(['uid','nickname','now_money','integral','add_time']) ->order('uid desc')->page((int)$page,(int)$limit)->select(); count($list) && $list=$list->toArray(); foreach ($list as &$item){ $item['add_time']=date('Y-m-d H',$item['add_time']); } return $list; } } \ No newline at end of file diff --git a/application/admin/model/user/UserAddress.php b/application/admin/model/user/UserAddress.php new file mode 100644 index 000000000..056ba2360 --- /dev/null +++ b/application/admin/model/user/UserAddress.php @@ -0,0 +1,51 @@ + + * @day: 2017/12/25 + */ + +namespace app\admin\model\user; + + +use basic\ModelBasic; +use traits\ModelTrait; + +class UserAddress extends ModelBasic +{ + use ModelTrait; + + protected $insert = ['add_time']; + + protected function setAddTimeAttr() + { + return time(); + } + + public static function setDefaultAddress($id,$uid) + { + self::beginTrans(); + $res1 = self::where('uid',$uid)->update(['is_default'=>0]); + $res2 = self::where('id',$id)->where('uid',$uid)->update(['is_default'=>1]); + $res =$res1 !== false && $res2 !== false; + self::checkTrans($res); + return $res; + } + + public static function userValidAddressWhere($model=null,$prefix = '') + { + if($prefix) $prefix .='.'; + $model = self::getSelfModel($model); + return $model->where("{$prefix}is_del",0); + } + + public static function getUserValidAddressList($uid,$field = '*') + { + return self::userValidAddressWhere()->where('uid',$uid)->order('add_time DESC')->field($field)->select()->toArray()?:[]; + } + + public static function getUserDefaultAddress($uid,$field = '*') + { + return self::userValidAddressWhere()->where('uid',$uid)->where('is_default',1)->field($field)->find(); + } +} \ No newline at end of file diff --git a/application/admin/model/user/UserBill.php b/application/admin/model/user/UserBill.php index 50ba732da..c21435a55 100644 --- a/application/admin/model/user/UserBill.php +++ b/application/admin/model/user/UserBill.php @@ -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 @@ -16,11 +16,17 @@ class UserBill extends ModelBasic { use ModelTrait; + protected $insert = ['add_time']; + + protected function setAddTimeAttr() + { + return time(); + } + public static function income($title,$uid,$category,$type,$number,$link_id = 0,$balance = 0,$mark = '',$status = 1){ $pm = 1; return self::set(compact('title','uid','link_id','category','type','number','balance','mark','status','pm')); } - //获取柱状图和饼状图数据 public static function getUserBillChart($where,$category='now_money',$type='brokerage',$pm=1,$zoom=15){ $model=self::getModelTime($where,new self()); @@ -95,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(); @@ -105,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){ @@ -139,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]; } diff --git a/application/admin/model/user/UserNotice.php b/application/admin/model/user/UserNotice.php index 4f3d61e5e..ac18c7f02 100644 --- a/application/admin/model/user/UserNotice.php +++ b/application/admin/model/user/UserNotice.php @@ -24,9 +24,23 @@ class UserNotice extends ModelBasic /** * @return array */ - public static function getList(){ + public static function getList($where=[]){ $model = new self; $model->order('id desc'); + if(!empty($where)){ + $data=($data=$model->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() : []; + foreach ($data as &$item){ + if($item["uid"] != ''){ + $uids = explode(",",$item["uid"]); + array_splice($uids,0,1); + array_splice($uids,count($uids)-1,1); + $item["uid"] = $uids; + } + $item['send_time']=date('Y-m-d H:i:s',$item['send_time']); + } + $count=self::count(); + return compact('data','count'); + } return self::page($model,function($item,$key){ if($item["uid"] != ''){ $uids = explode(",",$item["uid"]); @@ -46,7 +60,7 @@ class UserNotice extends ModelBasic $model = new self; if(isset($where['title']) && $where['title'] != '') $model = $model->where('title','LIKE',"%".$where['title']."%"); $model = $model->where('type',2); - $model = $model->where('is_send',0); +// $model = $model->where('is_send',0); $model = $model->order('id desc'); return self::page($model,$where); } diff --git a/application/admin/model/wechat/WechatMessage.php b/application/admin/model/wechat/WechatMessage.php index e30277313..7e1d152ee 100644 --- a/application/admin/model/wechat/WechatMessage.php +++ b/application/admin/model/wechat/WechatMessage.php @@ -33,9 +33,11 @@ class WechatMessage extends ModelBasic 'event_subscribe'=>'关注微信号', 'event_unsubscribe'=>'取消关注微信号', 'event_scan'=>'扫码', + 'event_templatesendjobfinish'=>'进入小程序', 'event_location'=>'获取位置', 'event_click'=>'点击微信菜单关键字', 'event_view'=>'点击微信菜单链接', + 'event_view_miniprogram'=>'点击微信菜单进入小程序', 'text'=>'收到文本消息', 'image'=>'收到图片消息', 'video'=>'收到视频消息', diff --git a/application/admin/model/wechat/WechatReply.php b/application/admin/model/wechat/WechatReply.php index 66ce3cf96..4a82d2c76 100644 --- a/application/admin/model/wechat/WechatReply.php +++ b/application/admin/model/wechat/WechatReply.php @@ -26,6 +26,15 @@ class WechatReply extends ModelBasic public static $reply_type = ['text','image','news','voice']; + /**根据关键字查询一条 + * @param $key + */ + public static function getDataByKey($key){ + $resdata = []; + $resdata = self::where('key',$key)->find(); + $resdata['data'] = json_decode($resdata['data'],true); + return $resdata; + } public function getUrlAttr($value,$data) { return $value == '' ? \think\Url::build('index/index/news',['id'=>$data['id']]) : $value; @@ -194,4 +203,5 @@ class WechatReply extends ModelBasic } + } \ No newline at end of file diff --git a/application/admin/model/wechat/WechatUser.php b/application/admin/model/wechat/WechatUser.php index 998212501..fe16aff46 100644 --- a/application/admin/model/wechat/WechatUser.php +++ b/application/admin/model/wechat/WechatUser.php @@ -33,7 +33,7 @@ use service\SystemConfigService; protected $insert = ['add_time']; /** - * 用uid获得openid + * 用uid获得 微信openid * @param $uid * @return mixed */ @@ -47,6 +47,21 @@ use service\SystemConfigService; Cache::set($cacheName,$openid,0); return $openid; } + /** + * 用uid获得 小程序 openid + * @param $uid + * @return mixed + */ + public static function uidToRoutineOpenid($uid,$update = false) + { + $cacheName = 'routine_openid'.$uid; + $openid = Cache::get($cacheName); + if($openid && !$update) return $openid; + $openid = self::where('uid',$uid)->value('routine_openid'); + if(!$openid) exception('对应的routine_openid不存在!'); + Cache::set($cacheName,$openid,0); + return $openid; + } public static function setAddTimeAttr($value) { @@ -145,7 +160,7 @@ use service\SystemConfigService; * @return array */ public static function agentSystemPage($where = array(),$isall=false){ - self::setWechatUserOrder();//设置 一级推荐人 二级推荐人 一级推荐人订单 二级推荐人订单 佣金 +// self::setWechatUserOrder();//设置 一级推荐人 二级推荐人 一级推荐人订单 二级推荐人订单 佣金 $model = new self; if($isall==false) { $status = (int)SystemConfigService::get('store_brokerage_statu'); @@ -155,7 +170,7 @@ use service\SystemConfigService; } } } - $model = $model->where('openid','NOT NULL'); +// $model = $model->where('openid','NOT NULL'); if($where['nickname'] !== '') $model = $model->where('nickname','LIKE',"%$where[nickname]%"); if($where['data'] !== ''){ list($startTime,$endTime) = explode(' - ',$where['data']); @@ -203,7 +218,6 @@ use service\SystemConfigService; $item['qr_code'] = QrcodeService::getForeverQrcode('spread',$item['uid']); $item['extract_count_price'] = UserExtract::getUserCountPrice($item['uid']);//累计提现 $item['extract_count_num'] = UserExtract::getUserCountNum($item['uid']);//提现次数 -// $item['qr_code'] = ''; },$where); } diff --git a/application/admin/view/agent/agent_manage/stair.php b/application/admin/view/agent/agent_manage/stair.php index 8214cf7c1..f96da913d 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",###} - {$vo.uid|getOrderCount} + {$vo.orderCount} {$vo.now_money} diff --git a/application/admin/view/article/article/create.php b/application/admin/view/article/article/create.php index 2ffa57883..aeb06bc2d 100644 --- a/application/admin/view/article/article/create.php +++ b/application/admin/view/article/article/create.php @@ -1 +1 @@ -{extend name="public/container"} {block name="head_top"} {/block} {block name="content"}
文章列表
{if condition="$news['image_input']"}
{else/}
{/if}
文章内容编辑
标题
作者
文章分类 {volist name="all" id="vo" key="k"} {if condition="$key eq $cid"} {elseif condition="in_array($key,$news['cid'])"} {else/} {/if} {/volist}
{if condition="$news['image_input']"}
{else/}
{/if}

封面大图片建议尺寸:900像素 * 500像素



{/block} {block name="script"} {/block} \ No newline at end of file +{extend name="public/container"} {block name="head_top"} {/block} {block name="content"}
文章列表
{if condition="$news['image_input']"}
{else/}
{/if}
文章内容编辑
标题
作者
文章分类 {volist name="all" id="vo" key="k"} {if condition="$key eq $cid"} {elseif condition="in_array($key,$news['cid'])"} {else/} {/if} {/volist}
{if condition="$news['image_input']"}
{else/}
{/if}

封面大图片建议尺寸:900像素 * 500像素



{/block} {block name="script"} {/block} \ No newline at end of file diff --git a/application/admin/view/article/article/index.php b/application/admin/view/article/article/index.php index 072584a3e..ffd82f5e1 100644 --- a/application/admin/view/article/article/index.php +++ b/application/admin/view/article/article/index.php @@ -1,26 +1,33 @@ {extend name="public/container"} {block name="head_top"} - + {/block} {block name="content"}
-
+
+
+
分类
+
+ +
+
+
+
- +
- +
@@ -33,28 +40,26 @@ id - 分类 图片 - 标题 - 简介 - 操作 + [分类]标题 + 浏览量 + 添加时间 + 操作 {volist name="list" id="vo"} - {$vo.id} - {$vo.catename} - + {$vo.id} + - {$vo.title} - - {$vo.synopsis} - + [{$vo.catename}]{$vo.title} + {$vo.visit} + {$vo.add_time|date="Y-m-d H:i:s",###} - +
+
+ {include file="public/inner_page"} +
+
-
- {include file="public/inner_page"} -
+ {/block} {block name="script"} {/block} diff --git a/application/admin/view/order/store_order/index.php b/application/admin/view/order/store_order/index.php index d29f34fe2..1ef3f7768 100644 --- a/application/admin/view/order/store_order/index.php +++ b/application/admin/view/order/store_order/index.php @@ -1,667 +1,518 @@ {extend name="public/container"} -{block name="head_top"} - - - - - - - - -{/block} {block name="content"} -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- 订单状态: - - - - - - - - - -
-
- 订单类型: - - - - - -
-
- 创建时间: - - - - - - -
- +
+
+ +
+
+
搜索条件
+
+ -
-
- toArray(); ?> -
- 售出商品:{$price.total_num} - 订单数量:{$list_num.total} - 订单金额:¥{$price.pay_price} - 退款金额:¥{$price.refund_price} - {if condition="$price['pay_price_wx'] GT 0"} - 微信支付金额:¥{$price.pay_price_wx} - {/if} - {if condition="$price['pay_price_yue'] GT 0"} - 余额支付金额:¥{$price.pay_price_yue} - {/if} - {if condition="$price['pay_price_offline'] GT 0"} - 线下支付金额:¥{$price.pay_price_offline} - {/if} - {if condition="$price['pay_price_other'] GT 0"} - 线下支付金额:¥{$price.pay_price_other} - {/if} - {if condition="$price['use_integral'] GT 0"} - 积分抵扣:{$price.use_integral} (抵扣金额:¥{$price.deduction_price}) - {/if} - {if condition="$price['back_integral'] GT 0"} - 退回积分:{$price.back_integral} - {/if} -
- -
- - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - diff --git a/application/admin/view/ump/store_coupon/grant_group.php b/application/admin/view/ump/store_coupon/grant_group.php index b94aead67..cbf60f72d 100644 --- a/application/admin/view/ump/store_coupon/grant_group.php +++ b/application/admin/view/ump/store_coupon/grant_group.php @@ -46,7 +46,7 @@ {$vo.coupon_time}天 diff --git a/application/admin/view/ump/store_coupon/grant_subscribe.php b/application/admin/view/ump/store_coupon/grant_subscribe.php index 2744b733d..394e0b7ef 100644 --- a/application/admin/view/ump/store_coupon/grant_subscribe.php +++ b/application/admin/view/ump/store_coupon/grant_subscribe.php @@ -46,7 +46,7 @@ {$vo.coupon_time}天 diff --git a/application/admin/view/ump/store_coupon/grant_tag.php b/application/admin/view/ump/store_coupon/grant_tag.php index ad8d475b0..17905d3b3 100644 --- a/application/admin/view/ump/store_coupon/grant_tag.php +++ b/application/admin/view/ump/store_coupon/grant_tag.php @@ -46,7 +46,7 @@ {$vo.coupon_time}天 diff --git a/application/admin/view/ump/store_seckill/index.php b/application/admin/view/ump/store_seckill/index.php index c8f1bea9e..5888cef4b 100644 --- a/application/admin/view/ump/store_seckill/index.php +++ b/application/admin/view/ump/store_seckill/index.php @@ -89,35 +89,43 @@ {block name="script"} + + + + - {include file="public/inner_page"} + {/block} {block name="script"} +
+
+
+ {/block} \ No newline at end of file + }()); +{/block} \ No newline at end of file diff --git a/application/wap/view/first/my/index.html b/application/wap/view/first/my/index.html index 85fdf3bdd..6ba104973 100644 --- a/application/wap/view/first/my/index.html +++ b/application/wap/view/first/my/index.html @@ -78,13 +78,7 @@ {/volist} - {eq name="userInfo.is_promoter" value="1"} - - - -

我的余额

-
- */ ?> + {if condition="$statu == 2 || $userInfo['is_promoter'] == 1"} - {/eq} + {/if} {include file="public/store_menu"} diff --git a/application/wap/view/first/my/order.html b/application/wap/view/first/my/order.html index 15db3d8d3..4d2063601 100644 --- a/application/wap/view/first/my/order.html +++ b/application/wap/view/first/my/order.html @@ -171,7 +171,7 @@ var that = this; layer.confirm('确定申请退款?',{icon:3},function(index){ layer.close(index); - require(['wap/crmeb/module/refund-reason'],function($r){ + require(['wap/first/crmeb/module/refund-reason'],function($r){ Vue.use($r); that.$orderRefundReason(function(msg){ $h.load(); diff --git a/application/wap/view/first/my/order_pink_after.html b/application/wap/view/first/my/order_pink_after.html index a7b9ba98f..e777f25e6 100644 --- a/application/wap/view/first/my/order_pink_after.html +++ b/application/wap/view/first/my/order_pink_after.html @@ -116,7 +116,7 @@ that = this; storeApi.goBuy({ cartNum: that.cartNum, - uniqueId: '', + uniqueId: 0, productId: this.product.product_id, combinationId: this.product.id }, function (cartId) { diff --git a/application/wap/view/first/store/confirm_order.html b/application/wap/view/first/store/confirm_order.html index 63174de74..4e492c211 100644 --- a/application/wap/view/first/store/confirm_order.html +++ b/application/wap/view/first/store/confirm_order.html @@ -106,9 +106,9 @@ var $key = ''; var $seckill_id = ''; var $bargain_id = ''; - var wap_path = '{__WAP_PATH}'; - requirejs(['vue','store','helper','{__WAP_PATH}crmeb/module/store/use-coupon.js','{__WAP_PATH}crmeb/module/store/use-address.js','layer'],function(Vue,storeApi,$h,useCoupon,useAddress,layer){ + requirejs(['vue','store','helper','{__WAP_PATH}crmeb/module/store/use-coupon.js' + ,'{__WAP_PATH}crmeb/module/store/use-address.js','layer'],function(Vue,storeApi,$h,useCoupon,useAddress,layer){ Vue.use(useCoupon); Vue.use(useAddress); diff --git a/application/wap/view/first/store/detail.html b/application/wap/view/first/store/detail.html index e5179486b..4ce744047 100644 --- a/application/wap/view/first/store/detail.html +++ b/application/wap/view/first/store/detail.html @@ -13,20 +13,20 @@
{$storeInfo.store_name}
+
¥{$storeInfo.price|floatval}
原价:¥{$storeInfo.ot_price|floatval}
商品编号:{$storeInfo.id} 库存:{$storeInfo.stock}{$storeInfo.unit_name} - 销量:{$storeInfo.sales}{$storeInfo.unit_name}
+ 销量:{$storeInfo.ficti+$storeInfo.sales}{$storeInfo.unit_name}
{gt name="storeInfo['give_integral']" value="0"}
积分:{$storeInfo.give_integral|floatval} 赠送
{/gt} -
选择 {{productAttrCate}}
+ {notempty name="reply"}
评价
{$reply.comment}
{$reply.add_time} {$reply.suk}
- {gt name="replyCount" value="1"} 查看全部评价 + {gt name="replyCount" value="1"} + 查看全部评价 {/gt}
{/notempty}
-
详情
+
详情
- - - +
订单号用户信息商品信息 -
- - - -
-
支付状态订单状态详情操作
- {$vo.order_id} 
  - {$vo.pink_name}   -
-

{$vo.nickname} / {$vo.uid}

-
- - {volist name="info_order" id="info"} - {if condition="isset($info['cart_info']['productInfo']['attrInfo']) && !empty($info['cart_info']['productInfo']['attrInfo'])"} -

- {$info.cart_info.productInfo.store_name} - {$info.cart_info.productInfo.store_name} {$info.cart_info.productInfo.attrInfo.suk} | ¥{$info.cart_info.truePrice}×{$info.cart_info.cart_num} -

- {else/} -

- {$info.cart_info.productInfo.store_name} - {$info.cart_info.productInfo.store_name} | ¥{$info.cart_info.truePrice}×{$info.cart_info.cart_num} -

- {/if} - {/volist} -
- ¥{$vo.pay_price} - - {if condition="$vo['paid'] eq 1"} -

- {if condition="$vo['pay_type'] eq 'weixin'"} - 微信支付 - {elseif condition="$vo['pay_type'] eq 'yue'"} - 余额支付 - {elseif condition="$vo['pay_type'] eq 'offline'"} - 线下支付 - {else/} - 其他支付 - {/if} -

- {else/} - {if condition="$vo['pay_type'] eq 'offline'"} + + + + +
+
+
+ {{item.name}} + {{item.field}} +
+
+

{{item.count}}

+

+ {{item.content}} + {{item.sum}} +

+
+
+
+ + + +
+
+
+
订单列表
+
+
+ + + + + + + + + + - {else/} -

未支付

- {/if} - {/if} -
- {if condition="$vo['paid'] eq 0 && $vo['status'] eq 0"} - 未支付 - {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 0 && $vo['refund_status'] eq 0"/} - 未发货 - {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 1 && $vo['refund_status'] eq 0"/} - 待收货 - - {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 2 && $vo['refund_status'] eq 0"/} - 待评价 - {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 3 && $vo['refund_status'] eq 0"/} - 交易完成 - {elseif condition="$vo['paid'] eq 1 && $vo['refund_status'] eq 1"/} - 申请退款
- 退款原因:{$vo.refund_reason_wap} - {elseif condition="$vo['paid'] eq 1 && $vo['refund_status'] eq 2"/} - 已退款 - {/if} -
- + - {include file="public/inner_page"} + - + {/block} {block name="script"} {/block} diff --git a/application/admin/view/public/404.php b/application/admin/view/public/404.php new file mode 100644 index 000000000..68a82d757 --- /dev/null +++ b/application/admin/view/public/404.php @@ -0,0 +1,30 @@ + + + + + + 404 页面 + + + + + + + + + + + +
+

404

+

页面未找到!

+ +
+ 抱歉,页面好像去火星了~ + +
+
+ + + + diff --git a/application/admin/view/public/500.php b/application/admin/view/public/500.php new file mode 100644 index 000000000..94d2a98c1 --- /dev/null +++ b/application/admin/view/public/500.php @@ -0,0 +1,30 @@ + + + + + + {$title} + + + + + + + + + + + +
+

500

+

服务器内部错误

+ +
+ 服务器好像出错了... +

{$msg}

+
+
+ + + + diff --git a/application/admin/view/public/error.php b/application/admin/view/public/error.php index d2ff2952e..604d2064e 100644 --- a/application/admin/view/public/error.php +++ b/application/admin/view/public/error.php @@ -26,7 +26,7 @@
刷新试试 返回上一页

-

crmeb提示您:您可能输入了错误的网址,或者该网页已删除或移动,3秒钟后自动跳转

+

CRMEB提示您:您可能输入了错误的网址,或者该网页已删除或移动,3秒钟后自动跳转

diff --git a/application/admin/view/public/form-builder.php b/application/admin/view/public/form-builder.php index 16f3c077c..cc18660dc 100644 --- a/application/admin/view/public/form-builder.php +++ b/application/admin/view/public/form-builder.php @@ -3,11 +3,17 @@ <?=$form->getTitle()?> - getScript())?> + + + + + + @@ -19,10 +25,89 @@ //关闭当前窗口 // var index = parent.layer.getFrameIndex(window.name); // parent.layer.close(index); + //提交成功后按钮恢复 + $r.btn.finish(); }; - (function () { - var create = formScript()?> - create(); + + (function () { + var create = (function () { + var getRule = function () { + var rule = getRules())?>; + rule.forEach(function (c) { + if ((c.type == 'cascader' || c.type == 'tree') && Object.prototype.toString.call(c.props.data) == '[object String]') { + if (c.props.data.indexOf('js.') === 0) { + c.props.data = window[c.props.data.replace('js.', '')]; + } + } + }); + return rule; + }, vm = new Vue,name = 'formBuilderExecgetId() ? '' : '_'.$form->getId() ?>'; + var _b = false; + window[name] = function create(el, callback) { + if(_b) return ; + _b = true; + if (!el) el = document.body; + var $f = formCreate.create(getRule(), { + el: el, + form:getConfig('form'))?>, + row:getConfig('row'))?>, + submitBtn:isSubmitBtn() ? '{}' : 'false'?>, + resetBtn:isResetBtn() ? 'true' : '{}'?>, + iframeHelper:true, + upload: { + onExceededSize: function (file) { + vm.$Message.error(file.name + '超出指定大小限制'); + }, + onFormatError: function () { + vm.$Message.error(file.name + '格式验证失败'); + }, + onError: function (error) { + vm.$Message.error(file.name + '上传失败,(' + error + ')'); + }, + onSuccess: function (res) { + if (res.code == 200) { + return res.data.filePath; + } else { + vm.$Message.error(res.msg); + } + } + }, + //表单提交事件 + onSubmit: function (formData) { + $f.submitStatus({loading: true}); + $.ajax({ + url: 'getAction()?>', + type: 'getMethod()?>', + dataType: 'json', + data: formData, + success: function (res) { + if (res.code == 200) { + vm.$Message.success(res.msg); + $f.submitStatus({loading: false}); + formCreate.formSuccess && formCreate.formSuccess(res, $f, formData); + callback && callback(0, res, $f, formData); + //TODO 表单提交成功! + } else { + vm.$Message.error(res.msg || '表单提交失败'); + $f.btn.finish(); + callback && callback(1, res, $f, formData); + //TODO 表单提交失败 + } + }, + error: function () { + vm.$Message.error('表单提交失败'); + $f.btn.finish(); + } + }); + } + }); + return $f; + }; + return window[name]; + }()); + + window.$f = create(); +// create(); })(); diff --git a/application/admin/view/public/success.php b/application/admin/view/public/success.php index df1b3c242..be047010b 100644 --- a/application/admin/view/public/success.php +++ b/application/admin/view/public/success.php @@ -26,7 +26,7 @@

{$msg}!

3秒钟后自动跳转,点此手动跳转

-

crmeb提示您:您访问的页面正在跳转中,请耐心等待…

+

CRMEB提示您:您访问的页面正在跳转中,请耐心等待…

diff --git a/application/admin/view/setting/system_config/index.php b/application/admin/view/setting/system_config/index.php index e32a23237..240630a5a 100644 --- a/application/admin/view/setting/system_config/index.php +++ b/application/admin/view/setting/system_config/index.php @@ -1 +1 @@ -{extend name="public/container"} {block name="head"} {/block} {block name="content"}
$v){ if(!is_null(json_decode($v['value']))) $list[$k]['value'] = json_decode($v['value'],true); if($v['type'] == 'upload' && !empty($v['value'])){ if($v['upload_type'] == 1 || $v['upload_type'] == 3) $list[$k]['value'] = explode(',',$v['value']); } } $bool_upload_num = 0; ?>
{volist name="list" id="vo"} {eq name="$vo['config_tab_id']" value="$tab_id"}
{switch name="$vo['type']" } {case value="text" break="1"} {/case} {case value="textarea" break="1"} {/case} {case value="checkbox" break="1"} $v){ $option[$k] = explode('=',$v); } // dump($parameter); // exit(); } $checkbox_value = $vo['value']; if(!is_array($checkbox_value)) $checkbox_value = explode("\n",$checkbox_value); // dump($checkbox_value); // exit(); ?> {volist name="option" id="son" key="k"} {if condition="in_array($son[0],$checkbox_value)"} {else/} {/if} {/volist} {/case} {case value="radio" break="1"} $v){ $option[$k] = explode('=',$v); } } ?> {volist name="option" id="son"} {if condition="$son[0] eq $vo['value']"}
{else /}
{/if} {/volist} {/case} {case value="upload" break="1"} {if condition="$vo['upload_type'] EQ 3"}
{if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
×
{/volist} {/if}
{elseif condition="$vo['upload_type'] EQ 2"/}
{volist name="$vo['value']" id="img"}
image
×
{/volist}
{else/}
{if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
image
×
{/volist}
{/if}
{/if} {/case} {/switch}
{$vo.desc}
{/eq} {/volist}
{/block} {block name="script"} {/block} \ No newline at end of file +{extend name="public/container"} {block name="head"} {/block} {block name="content"}
{volist name="list" id="vo"} {eq name="$vo['config_tab_id']" value="$tab_id"}
{switch name="$vo['type']" } {case value="text" break="1"} {/case} {case value="textarea" break="1"} {/case} {case value="checkbox" break="1"} $v){ $option[$k] = explode('=>',$v); } // dump($parameter); // exit(); } $checkbox_value = $vo['value']; if(!is_array($checkbox_value)) $checkbox_value = explode("\n",$checkbox_value); // dump($checkbox_value); // exit(); ?> {volist name="option" id="son" key="k"} {if condition="in_array($son[0],$checkbox_value)"} {else/} {/if} {/volist} {/case} {case value="radio" break="1"} $v){ $option[$k] = explode('=>',$v); } } ?> {volist name="option" id="son"} {if condition="$son[0] eq $vo['value']"}
{else /}
{/if} {/volist} {/case} {case value="upload" break="1"} {if condition="$vo['upload_type'] EQ 3"}
{if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
×
{/volist} {/if}
{elseif condition="$vo['upload_type'] EQ 2"/}
{volist name="$vo['value']" id="img"}
image
×
{/volist}
{else/}
{if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
image
×
{/volist}
{/if}
{/if} {/case} {/switch}
{$vo.desc}
{/eq} {/volist}
{/block} {block name="script"} {/block} \ No newline at end of file diff --git a/application/admin/view/setting/system_config/index_alone.php b/application/admin/view/setting/system_config/index_alone.php index 7e3e2c493..b098d2a17 100644 --- a/application/admin/view/setting/system_config/index_alone.php +++ b/application/admin/view/setting/system_config/index_alone.php @@ -1 +1 @@ -{extend name="public/container"} {block name="head"} {/block} {block name="content"}
配置
$v){ $list[$k]['value'] = json_decode($v['value'],true); } $bool_upload_num = 0; ?>
{volist name="list" id="vo"} {eq name="$vo['config_tab_id']" value="$tab_id"}
{switch name="$vo['type']" } {case value="text" break="1"} {/case} {case value="textarea" break="1"} {/case} {case value="checkbox" break="1"} $v){ $option[$k] = explode('-',$v); } // dump($option); // exit(); } $checkbox_value = $vo['value']; if(!is_array($checkbox_value)) $checkbox_value = explode(',',$checkbox_value); // dump($checkbox_value); // exit(); ?> {volist name="option" id="son" key="k"} {if condition="in_array($son[0],$checkbox_value)"} {else/} {/if} {/volist} {/case} {case value="radio" break="1"} $v){ $option[$k] = explode('-',$v); } } ?> {volist name="option" id="son"} {if condition="$son[0] eq $vo['value']"}
{else /}
{/if} {/volist} {/case} {case value="upload" break="1"} {if condition="$vo['upload_type'] EQ 3"}
点击上传 {if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
删除
{/volist} {/if}
{elseif condition="$vo['upload_type'] EQ 2"/}
点击上传
{volist name="$vo['value']" id="img"}
image
删除
{/volist}
{else/}
{if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
image
删除
{/volist}
{/if}
{/if} {/case} {/switch}
{$vo.desc}
{/eq} {/volist}
{/block} {block name="script"} {/block} \ No newline at end of file +{extend name="public/container"} {block name="head"} {/block} {block name="content"}
配置
{volist name="list" id="vo"} {eq name="$vo['config_tab_id']" value="$tab_id"}
{switch name="$vo['type']" } {case value="text" break="1"} {/case} {case value="textarea" break="1"} {/case} {case value="checkbox" break="1"} $v){ $option[$k] = explode('=>',$v); } // dump($option); // exit(); } $checkbox_value = $vo['value']; if(!is_array($checkbox_value)) $checkbox_value = explode("\n",$checkbox_value); // dump($checkbox_value); // exit(); ?> {volist name="option" id="son" key="k"} {if condition="in_array($son[0],$checkbox_value)"} {else/} {/if} {/volist} {/case} {case value="radio" break="1"} $v){ $option[$k] = explode('=>',$v); } } ?> {volist name="option" id="son"} {if condition="$son[0] eq $vo['value']"}
{else /}
{/if} {/volist} {/case} {case value="upload" break="1"} {if condition="$vo['upload_type'] EQ 3"}
点击上传 {if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
删除
{/volist} {/if}
{elseif condition="$vo['upload_type'] EQ 2"/}
点击上传
{volist name="$vo['value']" id="img"}
image
删除
{/volist}
{else/}
{if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
image
删除
{/volist}
{/if}
{/if} {/case} {/switch}
{$vo.desc}
{/eq} {/volist}
{/block} {block name="script"} {/block} \ No newline at end of file diff --git a/application/admin/view/setting/system_config_tab/sonconfigtab.php b/application/admin/view/setting/system_config_tab/sonconfigtab.php index e2be3a1da..35187b21a 100644 --- a/application/admin/view/setting/system_config_tab/sonconfigtab.php +++ b/application/admin/view/setting/system_config_tab/sonconfigtab.php @@ -1 +1 @@ -{extend name="public/container"} {block name="content"}
{volist name="list" id="vo"} {/volist}
编号 配置名称 字段变量 字段类型 是否显示 操作
{$vo.id} {$vo.info} {$vo.menu_name} {$vo.type} 2){ if($vo['value']){ foreach ($vo['value'] as $v){ ?>
image
{if condition="$vo.status eq 1"} {elseif condition="$vo.status eq 2"/} {/if}
{/block} {block name="script"} {/block} \ No newline at end of file +{extend name="public/container"} {block name="content"}
{volist name="list" id="vo"} {/volist}
编号 配置名称 字段变量 字段类型 是否显示 操作
{$vo.id} {$vo.info} {$vo.menu_name} {$vo.type}
image
image
{if condition="$vo.status eq 1"} {elseif condition="$vo.status eq 2"/} {/if}
{/block} {block name="script"} {/block} \ No newline at end of file diff --git a/application/admin/view/store/store_bargain/index.php b/application/admin/view/store/store_bargain/index.php deleted file mode 100644 index 69cbc273c..000000000 --- a/application/admin/view/store/store_bargain/index.php +++ /dev/null @@ -1,236 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - - - - - - -{/block} -{block name="content"} -
-
- -
-
-
-
-
-
- 创建时间: - - - - - -
- -
- -
-
- 砍价状态: - - - - -
- -
- - - - - - -
-
-
- -
- -
- - - - - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - - - - - {/volist} - -
编号砍价活动名称砍价产品名称砍价图片砍价价格砍价状态活动状态库存排序内容操作
- {$vo.id} - - {$vo.title} - - {$vo.store_name} - - {$vo.store_name} - - {$vo.price} - - - - {$vo.start_name} - - {$vo.stock} - - {$vo.sort} - - - -
-
- - -
-
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_category/index.php b/application/admin/view/store/store_category/index.php index eb58749b9..f6d948f98 100644 --- a/application/admin/view/store/store_category/index.php +++ b/application/admin/view/store/store_category/index.php @@ -1,133 +1,172 @@ {extend name="public/container"} {block name="content"} -
-
-
-
- 分类首页 - -
+
+
+
+
+
搜索条件
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
-
-
-
-
- - -
- - -
-
+
+ +
+
+
分类列表
+
+ - +
+ 分类首页 + +
+
+ + + +
-
- - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - {/volist} - -
编号父级分类名称分类图标排序是否显示操作
- {$vo.id} - - {$vo.pid_name} - - {$vo.cate_name} - - {$vo.cate_name} - - {$vo.sort} - - - -
-
- - -
-
-
-
- {include file="public/inner_page"}
+ {/block} {block name="script"} {/block} diff --git a/application/admin/view/store/store_combination/attr.php b/application/admin/view/store/store_combination/attr.php deleted file mode 100644 index ce9f54d66..000000000 --- a/application/admin/view/store/store_combination/attr.php +++ /dev/null @@ -1,371 +0,0 @@ - - - - {include file="public/head"} - {$title|default=''} - - - -
- - - - - 添加新规则 - - - - - - - - - - - - - - 添加新规则 - - - - - - - {{ attr }} - - - - - - 添加 - - - - - - - 生成 - - - - - - - 保存中... -
- - diff --git a/application/admin/view/store/store_combination/index.php b/application/admin/view/store/store_combination/index.php deleted file mode 100644 index 504d6d374..000000000 --- a/application/admin/view/store/store_combination/index.php +++ /dev/null @@ -1,159 +0,0 @@ -{extend name="public/container"} -{block name="content"} -
-
-
-
- -
-
-
-
-
- - -
- - -
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - - - - - - - {/volist} - -
编号拼团名称产品名称拼团图片开始时间结束时间拼团人数价格产品状态推荐状态库存排序内容操作
- {$vo.id} - - {$vo.title} - - {$vo.store_name}/{$vo.product_id} - - {$vo.store_name} - - {$vo.start_time|date="Y-m-d H:i:s",###} - - {$vo.stop_time|date="Y-m-d H:i:s",###} - - {$vo.people} - - {$vo.price} - - - - - - {$vo.stock} - - {$vo.sort} - - - -
-
- - -
-
-
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_coupon/grant.php b/application/admin/view/store/store_coupon/grant.php deleted file mode 100644 index 339e6ab14..000000000 --- a/application/admin/view/store/store_coupon/grant.php +++ /dev/null @@ -1,90 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - -{/block} -{block name="content"} -
-
-
-
-
-
-
- -
- - -
-
-
-
-
- - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - {/volist} - -
优惠券名称优惠券面值优惠券最低消费优惠券有效期限操作
- {$vo.title} - - {$vo.coupon_price} - - {$vo.use_min_price} - - {$vo.coupon_time}天 - - -
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_coupon/grant_all.php b/application/admin/view/store/store_coupon/grant_all.php deleted file mode 100644 index 6667c72f5..000000000 --- a/application/admin/view/store/store_coupon/grant_all.php +++ /dev/null @@ -1,90 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - -{/block} -{block name="content"} -
-
-
-
-
-
-
- -
- - -
-
-
-
-
- - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - {/volist} - -
优惠券名称优惠券面值优惠券最低消费优惠券有效期限操作
- {$vo.title} - - {$vo.coupon_price} - - {$vo.use_min_price} - - {$vo.coupon_time}天 - - -
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_coupon/grant_group.php b/application/admin/view/store/store_coupon/grant_group.php deleted file mode 100644 index b94aead67..000000000 --- a/application/admin/view/store/store_coupon/grant_group.php +++ /dev/null @@ -1,115 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - -{/block} -{block name="content"} -
-
-
-
-
-
-
- -
- - -
-
-
-
-
- - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - {/volist} - -
优惠券名称优惠券面值优惠券最低消费优惠券有效期限操作
- {$vo.title} - - {$vo.coupon_price} - - {$vo.use_min_price} - - {$vo.coupon_time}天 - - -
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_coupon/grant_subscribe.php b/application/admin/view/store/store_coupon/grant_subscribe.php deleted file mode 100644 index 2744b733d..000000000 --- a/application/admin/view/store/store_coupon/grant_subscribe.php +++ /dev/null @@ -1,90 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - -{/block} -{block name="content"} -
-
-
-
-
-
-
- -
- - -
-
-
-
-
- - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - {/volist} - -
优惠券名称优惠券面值优惠券最低消费优惠券有效期限操作
- {$vo.title} - - {$vo.coupon_price} - - {$vo.use_min_price} - - {$vo.coupon_time}天 - - -
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_coupon/grant_tag.php b/application/admin/view/store/store_coupon/grant_tag.php deleted file mode 100644 index ad8d475b0..000000000 --- a/application/admin/view/store/store_coupon/grant_tag.php +++ /dev/null @@ -1,115 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - -{/block} -{block name="content"} -
-
-
-
-
-
-
- -
- - -
-
-
-
-
- - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - {/volist} - -
优惠券名称优惠券面值优惠券最低消费优惠券有效期限操作
- {$vo.title} - - {$vo.coupon_price} - - {$vo.use_min_price} - - {$vo.coupon_time}天 - - -
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_coupon/index.php b/application/admin/view/store/store_coupon/index.php deleted file mode 100644 index d7a721b26..000000000 --- a/application/admin/view/store/store_coupon/index.php +++ /dev/null @@ -1,157 +0,0 @@ -{extend name="public/container"} -{block name="content"} -
-
-
-
- -
- -
-
-
-
-
-
- - -
- - -
-
-
- -
-
- - - - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - - - {/volist} - -
编号优惠券名称优惠券面值优惠券最低消费优惠券有效期限排序是否有效添加时间操作
- {$vo.id} - - {$vo.title} - - {$vo.coupon_price} - - {$vo.use_min_price} - - {$vo.coupon_time}天 - - {$vo.sort} - - - - {$vo.add_time|date='Y-m-d H:i:s',###} - -
-
- - -
-
-
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_coupon_issue/index.php b/application/admin/view/store/store_coupon_issue/index.php deleted file mode 100644 index 24255aadc..000000000 --- a/application/admin/view/store/store_coupon_issue/index.php +++ /dev/null @@ -1,107 +0,0 @@ -{extend name="public/container"} -{block name="content"} -
-
-
-
-
-
- -
- -
- - -
-
-
- -
-
- - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - {/volist} - -
编号优惠券名称领取日期发布数量状态操作
- {$vo.id} - - {$vo.title} - - {empty name="$vo.start_time"} - 不限时 - {else/} - {$vo.start_time|date="Y/m/d H:i",###} - {$vo.end_time|date="Y/m/d H:i",###} - {/empty} - - {empty name="$vo.total_count"} - 不限量 - {else/} - 发布:{$vo.total_count} -
- 剩余:{$vo.remain_count} - {/empty} -
- - 未开启 - - 已失效 - - 正常 - - - - {neq name="vo.status" value="-1"} - - {/neq} - -
-
- {include file="public/inner_page"} -
-
-
-
- -{/block} diff --git a/application/admin/view/store/store_coupon_issue/issue_log.php b/application/admin/view/store/store_coupon_issue/issue_log.php deleted file mode 100644 index 9c09f3fe7..000000000 --- a/application/admin/view/store/store_coupon_issue/issue_log.php +++ /dev/null @@ -1,40 +0,0 @@ -{include file="public/frame_head"} - -
-
-
-
-
- - - - - - - - - - {volist name="list" id="vo"} - - - - - - {/volist} - -
用户名用户头像领取时间
{$vo.nickname}{$vo.add_time}
-
- {include file="public/inner_page"} -
-
-
- -
-{include file="public/inner_footer"} diff --git a/application/admin/view/store/store_coupon_user/index.php b/application/admin/view/store/store_coupon_user/index.php deleted file mode 100644 index 219dec2c4..000000000 --- a/application/admin/view/store/store_coupon_user/index.php +++ /dev/null @@ -1,104 +0,0 @@ -{extend name="public/container"} -{block name="content"} -
-
-
-
-
-
- -
- - - -
- -
-
- - -
-
-
- -
-
- - - - - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - - - {/volist} - -
编号优惠券名称发放人优惠券面值优惠券最低消费优惠券开始使用时间优惠券结束使用时间获取放方式是否可用状态
- {$vo.id} - - {$vo.coupon_title} - - {$vo.nickname} - - {$vo.coupon_price} - - {$vo.use_min_price} - - {$vo.add_time|date='Y-m-d H:i:s',###} - - {$vo.end_time|date='Y-m-d H:i:s',###} - - {$vo.type == 'send' ? '后台发放' : '手动领取'} - - {if condition="$vo['status'] eq 0" && $vo['is_fail'] eq 0} - - {else/} - - {/if} - - {if condition="$vo['status'] eq 2"} - 已过期 - {elseif condition="$vo['status'] eq 1"/} - 已使用 - {else/} - 未使用 - {/if} -
-
- {include file="public/inner_page"} -
-
-
-
-{/block} diff --git a/application/admin/view/store/store_order/express.php b/application/admin/view/store/store_order/express.php deleted file mode 100644 index 69e42a1c3..000000000 --- a/application/admin/view/store/store_order/express.php +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - 物流信息 - - - - - - - - - -
-
-
-
-
-
物流公司:{$order.delivery_name}
-
物流单号:{$order.delivery_id}
-
-
-
- -
- -

暂无查询记录

-
- -
    - {volist name="express.result.list" id="vo"} -
  • -
    -

    {$vo.status}

    - {$vo.time} -
    -
  • - {/volist} -
- -
-
-
- - diff --git a/application/admin/view/store/store_order/index.php b/application/admin/view/store/store_order/index.php deleted file mode 100644 index 1e6d7b27c..000000000 --- a/application/admin/view/store/store_order/index.php +++ /dev/null @@ -1,609 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - - - - - - -{/block} -{block name="content"} -
-
-
-
-
-
-
-
- 订单状态: - - - - - - - - - -
-
- 订单类型: - - - - - -
-
- 创建时间: - - - - - - -
- -
- -
-
-
- - - - - - - - -
-
-
-
-
-
-
- toArray(); ?> -
- 售出商品:{$price.total_num} - 订单数量:{$list_num.total} - 订单金额:¥{$price.pay_price} - 退款金额:¥{$price.refund_price} - {if condition="$price['pay_price_wx'] GT 0"} - 微信支付金额:¥{$price.pay_price_wx} - {/if} - {if condition="$price['pay_price_yue'] GT 0"} - 余额支付金额:¥{$price.pay_price_yue} - {/if} - {if condition="$price['pay_price_offline'] GT 0"} - 线下支付金额:¥{$price.pay_price_offline} - {/if} - {if condition="$price['pay_price_other'] GT 0"} - 线下支付金额:¥{$price.pay_price_other} - {/if} - {if condition="$price['use_integral'] GT 0"} - 积分抵扣:{$price.use_integral} (抵扣金额:¥{$price.deduction_price}) - {/if} - {if condition="$price['back_integral'] GT 0"} - 退回积分:{$price.back_integral} - {/if} -
- -
- - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - {/volist} - -
订单号用户信息商品信息 -
- - - -
-
支付状态订单状态详情操作
- {$vo.order_id} 
  - {$vo.pink_name}   -
-

{$vo.nickname} / {$vo.uid}

-
- - {volist name="info_order" id="info"} - {if condition="isset($info['cart_info']['productInfo']['attrInfo']) && !empty($info['cart_info']['productInfo']['attrInfo'])"} -

- {$info.cart_info.productInfo.store_name} - {$info.cart_info.productInfo.store_name} {$info.cart_info.productInfo.attrInfo.suk} | ¥{$info.cart_info.truePrice}×{$info.cart_info.cart_num} -

- {else/} -

- {$info.cart_info.productInfo.store_name} - {$info.cart_info.productInfo.store_name} | ¥{$info.cart_info.truePrice}×{$info.cart_info.cart_num} -

- {/if} - {/volist} -
- ¥{$vo.pay_price} - - {if condition="$vo['paid'] eq 1"} -

- {if condition="$vo['pay_type'] eq 'weixin'"} - 微信支付 - {elseif condition="$vo['pay_type'] eq 'yue'"} - 余额支付 - {elseif condition="$vo['pay_type'] eq 'offline'"} - 线下支付 - {else/} - 其他支付 - {/if} -

- {else/} - {if condition="$vo['pay_type'] eq 'offline'"} -

线下支付

-

- - {else/} -

未支付

- {/if} - {/if} -
- {if condition="$vo['paid'] eq 0 && $vo['status'] eq 0"} - 未支付 - {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 0 && $vo['refund_status'] eq 0"/} - 未发货 - {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 1 && $vo['refund_status'] eq 0"/} - 待收货 - - {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 2 && $vo['refund_status'] eq 0"/} - 待评价 - {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 3 && $vo['refund_status'] eq 0"/} - 交易完成 - {elseif condition="$vo['paid'] eq 1 && $vo['refund_status'] eq 1"/} - 申请退款
- 退款原因:{$vo.refund_reason_wap} - {elseif condition="$vo['paid'] eq 1 && $vo['refund_status'] eq 2"/} - 已退款 - {/if} -
- - 订单详情 - - - - {if condition="$vo['paid'] eq 0 && $vo['status'] eq 0 && $vo['refund_status'] eq 0"} - - {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 0 && $vo['refund_status'] eq 0"/} - - -
- - -
- {elseif condition="$vo['paid'] eq 1 && $vo['refund_status'] eq 1"/} -
- - -
- {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 1 && $vo['refund_status'] eq 0"/} - -
- - -
- {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 2 && $vo['refund_status'] eq 0"/} -
- - -
- {elseif condition="$vo['paid'] eq 1 && $vo['status'] eq 3 && $vo['refund_status'] eq 0"/} -
- - -
-{elseif condition="$vo['paid'] eq 1 && $vo['refund_status'] eq 2"/} - -
- - -
- {/if} -
-
-
- {include file="public/inner_page"} -
-
-
-
- -{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_order/order_info.php b/application/admin/view/store/store_order/order_info.php deleted file mode 100644 index cd27f3e0c..000000000 --- a/application/admin/view/store/store_order/order_info.php +++ /dev/null @@ -1,138 +0,0 @@ -{extend name="public/container"} -{block name="content"} -
- -
-
-
-
- 收货信息 -
-
-
-
用户昵称: {$userInfo.nickname}
-
收货人: {$orderInfo.real_name}
-
联系电话: {$orderInfo.user_phone}
-
收货地址: {$orderInfo.user_address}
-
-
-
-
-
-
-
- 订单信息 -
-
-
-
订单编号: {$orderInfo.order_id}
-
订单状态: - {if condition="$orderInfo['paid'] eq 0 && $orderInfo['status'] eq 0"} - 未支付 - {elseif condition="$orderInfo['paid'] eq 1 && $orderInfo['status'] eq 0 && $orderInfo['refund_status'] eq 0"/} - 未发货 - {elseif condition="$orderInfo['paid'] eq 1 && $orderInfo['status'] eq 1 && $orderInfo['refund_status'] eq 0"/} - 待收货 - {elseif condition="$orderInfo['paid'] eq 1 && $orderInfo['status'] eq 2 && $orderInfo['refund_status'] eq 0"/} - 待评价 - {elseif condition="$orderInfo['paid'] eq 1 && $orderInfo['status'] eq 3 && $orderInfo['refund_status'] eq 0"/} - 交易完成 - {elseif condition="$orderInfo['paid'] eq 1 && $orderInfo['refund_status'] eq 1"/} - 申请退款{$orderInfo.refund_reason_wap} - {elseif condition="$orderInfo['paid'] eq 1 && $orderInfo['refund_status'] eq 2"/} - 已退款 - {/if} -
-
商品总数: {$orderInfo.total_num}
-
商品总价: ¥{$orderInfo.total_price}
-
支付邮费: ¥{$orderInfo.total_postage}
-
实际支付: ¥{$orderInfo.pay_price}
- {if condition="$orderInfo['refund_price'] GT 0"} -
退款金额: ¥{$orderInfo.refund_price}
- {/if} - {if condition="$orderInfo['deduction_price'] GT 0"} -
使用积分: {$orderInfo.use_integral}积分(抵扣了¥{$orderInfo.deduction_price})
- {/if} - {if condition="$orderInfo['back_integral'] GT 0"} -
退回积分: ¥{$orderInfo.back_integral}
- {/if} -
创建时间: {$orderInfo.add_time|date="Y/m/d H:i",###}
-
支付方式: - {if condition="$orderInfo['paid'] eq 1"} - {if condition="$orderInfo['pay_type'] eq 'weixin'"} - 微信支付 - {elseif condition="$orderInfo['pay_type'] eq 'yue'"} - 余额支付 - {elseif condition="$orderInfo['pay_type'] eq 'offline'"} - 线下支付 - {else/} - 其他支付 - {/if} - {else/} - {if condition="$orderInfo['pay_type'] eq 'offline'"} - 线下支付 - {else/} - 未支付 - {/if} - {/if} -
- {notempty name="orderInfo.pay_time"} -
支付时间: {$orderInfo.pay_time|date="Y/m/d H:i",###}
- {/notempty} -
用户备注: {$orderInfo.mark?:'无'}
-
商家备注: {$orderInfo.remark?:'无'}
-
推广人: {if $spread}{$spread}{else}无{/if}
-
-
-
-
- {if condition="$orderInfo['delivery_type'] eq 'express'"} -
-
-
- 物流信息 -
-
-
-
快递公司: {$orderInfo.delivery_name}
-
快递单号: {$orderInfo.delivery_id} |
-
-
-
-
- {elseif condition="$orderInfo['delivery_type'] eq 'send'"} -
-
-
- 配送信息 -
-
-
-
送货人姓名: {$orderInfo.delivery_name}
-
送货人电话: {$orderInfo.delivery_id}
-
-
-
-
- {/if} -
-
-
- 备注信息 -
-
-
-
{if $orderInfo.mark}{$orderInfo.mark}{else}暂无备注信息{/if}
-
-
-
-
-
-
- - - -{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_order/order_status.php b/application/admin/view/store/store_order/order_status.php deleted file mode 100644 index dd59f8ec6..000000000 --- a/application/admin/view/store/store_order/order_status.php +++ /dev/null @@ -1,79 +0,0 @@ -{extend name="public/container"} -{block name="content"} -
-
-
-
-
- - - - - - - - - - - {volist name="list" id="vo"} - - - - - - {/volist} - -
订单编号操作记录操作时间
- {$vo.oid} - - {$vo.change_message} - - {$vo.change_time|date='Y-m-d H:i:s',###} -
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_order/orderchart.php b/application/admin/view/store/store_order/orderchart.php deleted file mode 100644 index 904f049a4..000000000 --- a/application/admin/view/store/store_order/orderchart.php +++ /dev/null @@ -1,278 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - - - - - - -{/block} -{block name="content"} -
-
-
-
-
-
-
-
- 订单状态: - - - - - - - - - -
-
- 订单类型: - - - - - -
-
- 创建时间: - - - - - - -
- -
- -
-
- toArray(); ?> -
-
- 售出商品:{$price.total_num} -
-
- 订单数量:{$list_num.total} -
-
- 订单金额:¥{$price.pay_price} -
-
- 退款金额:¥{$price.refund_price} -
-
-
-
-
-
-
主要数据统计
- -
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_order_pink/index.php b/application/admin/view/store/store_order_pink/index.php deleted file mode 100644 index 260f34488..000000000 --- a/application/admin/view/store/store_order_pink/index.php +++ /dev/null @@ -1,212 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - - - -{/block} -{block name="content"} -
-
-
-
-
-
-
-
- -
- -
- - - -
- -
-
- -
-
- - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - {/volist} - -
开团团长开团时间拼团产品几人团几人参加结束时间状态操作
- {$vo.uid|getUserNickname}/{$vo.uid} - - {$vo.add_time|date='Y-m-d H:i:s',###} - - {$vo.title}/{$vo.cid} - - {$vo.people}人 - - {$vo.count_people}人 - - {$vo.stop_time|date='Y-m-d H:i:s',###} - - {if condition="$vo['status'] eq 1"} - 进行中 - {elseif condition="$vo['status'] eq 2"} - 已完成 - {elseif condition="$vo['status'] eq 3"} - 未完成 - {/if} - -

-
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_order_pink/order_pink.php b/application/admin/view/store/store_order_pink/order_pink.php deleted file mode 100644 index 5ec20a81b..000000000 --- a/application/admin/view/store/store_order_pink/order_pink.php +++ /dev/null @@ -1,173 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - - - -{/block} -{block name="content"} -
-
-
-
-
-
-
- - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - {/volist} - -
编号用户名称用户头像订单编号金额订单状态
- {$vo.id} - - {$vo.nickname}/{$vo.uid} - - {$vo.nickname} - - {$vo.order_id} - - ¥{$vo.price} - - {if condition="$vo['is_refund']"} - 已退款 - {else/} - 未退款 - {/if} -
-
-
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_order_pink/order_status.php b/application/admin/view/store/store_order_pink/order_status.php deleted file mode 100644 index dd59f8ec6..000000000 --- a/application/admin/view/store/store_order_pink/order_status.php +++ /dev/null @@ -1,79 +0,0 @@ -{extend name="public/container"} -{block name="content"} -
-
-
-
-
- - - - - - - - - - - {volist name="list" id="vo"} - - - - - - {/volist} - -
订单编号操作记录操作时间
- {$vo.oid} - - {$vo.change_message} - - {$vo.change_time|date='Y-m-d H:i:s',###} -
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_product/index.php b/application/admin/view/store/store_product/index.php index 52c4a79f9..c5877ccdc 100644 --- a/application/admin/view/store/store_product/index.php +++ b/application/admin/view/store/store_product/index.php @@ -71,7 +71,7 @@
{switch name='type'} {case value="1"} - + {/case} {case value="2"} @@ -98,7 +98,7 @@ - diff --git a/application/admin/view/store/store_seckill/index.php b/application/admin/view/store/store_seckill/index.php deleted file mode 100644 index a74d2abd2..000000000 --- a/application/admin/view/store/store_seckill/index.php +++ /dev/null @@ -1,148 +0,0 @@ -{extend name="public/container"} -{block name="content"} -
-
-
-
-
-
-
- - -
- - -
-
-
- -
-
- - - - - - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - - - - - {/volist} - -
编号产品图片活动标题活动简介价格库存开始时间结束时间添加时间产品状态内容操作
- {$vo.id} - - {$vo.store_name} - - {$vo.title} - - {$vo.info} - - {$vo.price} - - {$vo.stock} - - {$vo.start_time|date='Y-m-d H:i:s',###} - - {$vo.stop_time|date='Y-m-d H:i:s',###} - - {$vo.add_time|date='Y-m-d H:i:s',###} - - {if condition="$vo['status']"} - {$vo.start_name} - {else/} - - {/if} - - - -
-
- - -
-
-
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/store/store_service/chat_list.php b/application/admin/view/store/store_service/chat_list.php deleted file mode 100644 index c8b988558..000000000 --- a/application/admin/view/store/store_service/chat_list.php +++ /dev/null @@ -1,46 +0,0 @@ -{include file="public/frame_head"} - -
-
-
-
-
- - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - {/volist} - -
用户名称用户头像发送消息发送时间
- - {$vo.nickname} - - {$vo.msn}{$vo.add_time|date='Y-m-d H:i:s',###}
-
- {include file="public/inner_page"} -
-
-
- -
-{include file="public/inner_footer"} diff --git a/application/admin/view/store/store_service/chat_user.php b/application/admin/view/store/store_service/chat_user.php deleted file mode 100644 index e042a73c9..000000000 --- a/application/admin/view/store/store_service/chat_user.php +++ /dev/null @@ -1,32 +0,0 @@ -{include file="public/frame_head"} -
-
-
-
-
- - - - - - - - - - {volist name="list" id="vo"} - - - - - - {/volist} - -
用户名称用户头像操作
{$vo.nickname} - -
-
-
-
-
-
-{include file="public/inner_footer"} diff --git a/application/admin/view/store/store_service/create.php b/application/admin/view/store/store_service/create.php deleted file mode 100644 index 389cf813b..000000000 --- a/application/admin/view/store/store_service/create.php +++ /dev/null @@ -1,157 +0,0 @@ -{include file="public/frame_head"} - - - - - - -
-
-
-
-
-
- -
-
-
- - - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - {/volist} - - -
编号微信用户名称头像性别地区是否关注公众号首次关注时间
- - - {$vo.uid} - - {$vo.nickname} - - {$vo.nickname} - - {if condition="$vo['sex'] eq 1"} - 男 - {elseif condition="$vo['sex'] eq 2"/} - 女 - {else/} - 保密 - {/if} - - {$vo.country}{$vo.province}{$vo.city} - - {if condition="$vo['subscribe']"} - 关注 - {else/} - 取消 - {/if} - - {$vo.add_time|date="Y-m-d H:i:s",###} -
-
- {include file="public/inner_page"} -
-
-
-
-
- -
- -{include file="public/inner_footer"} diff --git a/application/admin/view/store/store_service/edit.php b/application/admin/view/store/store_service/edit.php deleted file mode 100644 index 58932262d..000000000 --- a/application/admin/view/store/store_service/edit.php +++ /dev/null @@ -1,28 +0,0 @@ - - - - {include file="public/head"} - {$title} - - -
- -
- - diff --git a/application/admin/view/store/store_service/index.html b/application/admin/view/store/store_service/index.html deleted file mode 100644 index 3ee5d8987..000000000 --- a/application/admin/view/store/store_service/index.html +++ /dev/null @@ -1,161 +0,0 @@ -{include file="public/frame_head"} -
-
-
-
- -
-
-
-
-
- - - - - -
- - -
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - - - - - - - - - - {/volist} - -
编号产品图片产品名称产品分类价格产品状态热卖单品促销单品精品推荐首发新品库存点赞收藏内容秒杀操作评论
- {$vo.id} - - {$vo.store_name} - - {$vo.store_name} - - {$vo.cate_name} - - {$vo.price} - - - - - - - - - - - - {$vo.stock} - - -   {$vo.collect} - - - -   {$vo.like} - - - - - - - - - - 查看 -
-
- {include file="public/inner_page"} -
-
-
- -
- -{include file="public/inner_footer"} diff --git a/application/admin/view/store/store_service/index.php b/application/admin/view/store/store_service/index.php deleted file mode 100644 index f1a666131..000000000 --- a/application/admin/view/store/store_service/index.php +++ /dev/null @@ -1,74 +0,0 @@ -{extend name="public/container"} -{block name="head_top"}{/block} -{block name="content"} -
-
-
-
- -
-
-
- - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - {/volist} - -
编号微信用户名称客服头像客服名称是否显示添加时间操作
{$vo.id}{$vo.wx_name}{$vo.nickname} - - {$vo.add_time|date='Y-m-d H:i:s',###} - - - -
-
- {include file="public/inner_page"} -
-
-
- {/block} - {block name="script"} - -
-{/block} diff --git a/application/admin/view/store/store_statistics/index.php b/application/admin/view/store/store_statistics/index.php deleted file mode 100644 index 3005dd0cd..000000000 --- a/application/admin/view/store/store_statistics/index.php +++ /dev/null @@ -1,443 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - - - - - -{/block} -{block name="content"} - -
-
-
-
-
-
-
- 创建时间: - 全部 - 今天 - 本周 - 本月 - 本季度 - 本年 -
- 自定义 -
-
- -
-
-
-
-
-
-
-
- {volist name='header' id='val'} -
-
-
-
- -
-
- {$val.name} -

{$val.value}

-
-
-
- -
- {/volist} -
-
-
-
-
-
- -
-
- - -
-
-
-
-
-
主要数据统计
-
- - - - - - -
-
-
-
-
-
-
-
-
-
-
支付方式
-
- - - - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
支出详情
-
- - - - - - -
-
-
-
-
-
-
-
-
-
-
营收详情
-
- - - - - - -
-
-
-
-
-
-
-
-
-
-
最近交易记录
-
- - - - - - -
-
-
-
- {volist name="trans" id="vo"} -

{$vo.nickname}

-

购买{$vo.store_name}

-

¥{$vo.pay_price}

- {/volist} -
-
-
-
-
-
-
-
-
- -
- {if condition="$price['pay_price_wx'] GT 0"} -
- 微信支付金额:¥{$price.pay_price_wx} -
- {/if} - {if condition="$price['pay_price_yue'] GT 0"} -
- 余额支付金额:¥{$price.pay_price_yue} -
- {/if} - {if condition="$price['pay_price_offline'] GT 0"} -
- 线下支付金额:¥{$price.pay_price_offline} -
- {/if} -
-
-
- - Excel导出 - -
-
-
-
-
- - - -{/block} diff --git a/application/admin/view/system/system_cleardata/index.php b/application/admin/view/system/system_cleardata/index.php index b3ee510b5..3fafeccd1 100644 --- a/application/admin/view/system/system_cleardata/index.php +++ b/application/admin/view/system/system_cleardata/index.php @@ -21,7 +21,7 @@


- +
-{/block} -{block name="content"} -
-
-
-
-
砍价产品搜索
-
- - - -
-
-
-
- - 目前拥有{$countBargain}个砍价产品 -
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- - - -
- - - - -
-
-
-
-
-{/block} -{block name="script"} - - - -{/block} diff --git a/application/admin/view/ump/store_combination/attr.php b/application/admin/view/ump/store_combination/attr.php deleted file mode 100644 index ce9f54d66..000000000 --- a/application/admin/view/ump/store_combination/attr.php +++ /dev/null @@ -1,371 +0,0 @@ - - - - {include file="public/head"} - {$title|default=''} - - - -
- - - - - 添加新规则 - - - - - - - - - - - - - - 添加新规则 - - - - - - - {{ attr }} - - - - - - 添加 - - - - - - - 生成 - - - - - - - 保存中... -
- - diff --git a/application/admin/view/ump/store_combination/combina_list.php b/application/admin/view/ump/store_combination/combina_list.php deleted file mode 100644 index 260f34488..000000000 --- a/application/admin/view/ump/store_combination/combina_list.php +++ /dev/null @@ -1,212 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - - - -{/block} -{block name="content"} -
-
-
-
-
-
-
-
- -
- -
- - - -
- -
-
- -
-
- - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - {/volist} - -
开团团长开团时间拼团产品几人团几人参加结束时间状态操作
- {$vo.uid|getUserNickname}/{$vo.uid} - - {$vo.add_time|date='Y-m-d H:i:s',###} - - {$vo.title}/{$vo.cid} - - {$vo.people}人 - - {$vo.count_people}人 - - {$vo.stop_time|date='Y-m-d H:i:s',###} - - {if condition="$vo['status'] eq 1"} - 进行中 - {elseif condition="$vo['status'] eq 2"} - 已完成 - {elseif condition="$vo['status'] eq 3"} - 未完成 - {/if} - -

-
-
- {include file="public/inner_page"} -
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/ump/store_combination/index.php b/application/admin/view/ump/store_combination/index.php deleted file mode 100644 index ba6bba8c9..000000000 --- a/application/admin/view/ump/store_combination/index.php +++ /dev/null @@ -1,269 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - -{/block} -{block name="content"} -
-
-
-
-
拼团产品搜索
-
-
- - 目前拥有{$countCombination}个拼团产品 -
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
-
-
-
-
-
- 总展现量 - -
-
-

{$statistics.browseCount}

-
-
-
-
-
-
- 访客人数 - -
-
-

{$statistics.visitCount}

-
-
-
-
-
-
- 参与人数 - -
-
-

{$statistics.partakeCount}

-
-
-
-
-
-
- 成团数量 - -
-
-

{$statistics.pinkCount}

-
-
-
- -
-
-
拼团产品列表
-
-
- - - -
-
-
-
-
-{/block} -{block name="script"} - - -{/block} \ No newline at end of file diff --git a/application/admin/view/ump/store_combination/order_pink.php b/application/admin/view/ump/store_combination/order_pink.php deleted file mode 100644 index 6c373503f..000000000 --- a/application/admin/view/ump/store_combination/order_pink.php +++ /dev/null @@ -1,173 +0,0 @@ -{extend name="public/container"} -{block name="head_top"} - - - - -{/block} -{block name="content"} -
-
-
-
-
-
-
- - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - {/volist} - -
编号用户名称用户头像订单编号金额订单状态
- {$vo.id} - - {$vo.nickname}/{$vo.uid} - - {$vo.nickname} - - {$vo.order_id} - - ¥{$vo.price} - - {if condition="$vo['is_refund']"} - 已退款 - {else/} - 未退款 - {/if} -
-
-
-
-
-
-{/block} -{block name="script"} - -{/block} diff --git a/application/admin/view/ump/store_coupon/grant_all.php b/application/admin/view/ump/store_coupon/grant_all.php index 6667c72f5..13c5dbf62 100644 --- a/application/admin/view/ump/store_coupon/grant_all.php +++ b/application/admin/view/ump/store_coupon/grant_all.php @@ -46,7 +46,7 @@ {$vo.coupon_time}天
-
-
-
-