From cccb34a21db4ddaf096cee705525675e1cebc9b1 Mon Sep 17 00:00:00 2001 From: yangsai Date: Tue, 15 Oct 2024 14:54:51 +0800 Subject: [PATCH] 20241015 --- application/admin/controller/Order.php | 50 +++++++++++ application/admin/model/Order.php | 23 ++++- application/admin/view/order/index.html | 20 ++++- application/admin/view/order/yungudong.html | 47 ++++++++++ application/admin/view/order/zanshang.html | 47 ++++++++++ application/admin/view/user/vipset/edit.html | 12 --- application/admin/view/user/vipset/index.html | 7 +- application/admin/view/user/zanshang/add.html | 8 +- .../admin/view/user/zanshang/edit.html | 8 +- application/api/controller/Content.php | 52 +++++++++-- application/api/controller/Order.php | 6 ++ application/api/controller/Systembasic.php | 4 +- public/assets/js/backend/content.js | 2 +- public/assets/js/backend/content/pinglun.js | 10 +-- public/assets/js/backend/order.js | 86 +++++++++++++++++-- public/assets/js/backend/user/vipset.js | 15 ++-- public/assets/js/backend/user/zanshang.js | 5 +- 17 files changed, 337 insertions(+), 65 deletions(-) create mode 100644 application/admin/view/order/yungudong.html create mode 100644 application/admin/view/order/zanshang.html diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index 7eee9c1..9449152 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -26,7 +26,57 @@ class Order extends Backend } + public function index(){ + $data = $this->request->param(); + if($this->request->isAjax()){ + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $paysum = $this->model->where($where)->where('status',1)->sum('money'); + $systemsum = $this->model->where($where)->where('status',1)->sum('system_money'); + $usersum = $this->model->where($where)->where('status',1)->sum('user_money'); + $list = $this->model->getlist($where, $order, $offset, $limit,$sort); + //计算金额 + $list['paysum'] = "¥".$paysum; + $list['systemsum'] = "¥".$systemsum; + $list['usersum'] = "¥".$usersum; + return json($list); + } + return $this->view->fetch(); + } + public function yungudong($type) + { + $data = $this->request->param(); + if($this->request->isAjax()){ + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $paysum = $this->model->where($where)->where('status',1)->where('type',$type)->sum('money'); + $systemsum = $this->model->where($where)->where('status',1)->where('type',$type)->sum('system_money'); + $usersum = $this->model->where($where)->where('status',1)->where('type',$type)->sum('user_money'); + $list = $this->model->yungudong($where, $order, $offset, $limit,$sort,$type); + //计算金额 + $list['paysum'] = "¥".$paysum; + $list['systemsum'] = "¥".$systemsum; + $list['usersum'] = "¥".$usersum; + return json($list); + } + return $this->view->fetch(); + } + public function zanshang($type) + { + $data = $this->request->param(); + if($this->request->isAjax()){ + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $paysum = $this->model->where($where)->where('status',1)->where('type',$type)->sum('money'); + $systemsum = $this->model->where($where)->where('status',1)->where('type',$type)->sum('system_money'); + $usersum = $this->model->where($where)->where('status',1)->where('type',$type)->sum('user_money'); + $list = $this->model->yungudong($where, $order, $offset, $limit,$sort,$type); + //计算金额 + $list['paysum'] = "¥".$paysum; + $list['systemsum'] = "¥".$systemsum; + $list['usersum'] = "¥".$usersum; + return json($list); + } + return $this->view->fetch(); + } /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 diff --git a/application/admin/model/Order.php b/application/admin/model/Order.php index b05fd3d..dca0064 100644 --- a/application/admin/model/Order.php +++ b/application/admin/model/Order.php @@ -29,11 +29,26 @@ class Order extends Model ]; // 查询当前用户是否已经付过费 - public function getlist($where, $order, $offset, $limit){ - $order = empty($order)?['createtime'=>"desc"]:$order; - $list = $this->field("order_no,title,o.money,paytime,content_id,type")->alias('o')->join('fa_content f','f.id = o.content_id','LEFT')->order($order) + public function getlist($where, $order, $offset, $limit,$sort){ + $order = empty($order)?['o.createtime'=>"desc"]:$order; + $list = $this->field("o.id,o.user_id,o.createtime,order_no,title,o.money,paytime,content_id,ispay,user_money,system_money,o.status,type,f.user_id as fabu_user_id,f.title")->alias('o')->join('fa_content f','f.id = o.content_id','LEFT') ->where($where) - ->paginate(['page'=> $offset?? 1,'list_rows' => $limit]); + ->where('ispay',1) + ->paginate($limit); + // ->paginate(['page'=> $offset?? 1,'list_rows' => $limit]); + $result = array("total" => $list->total(), "rows" => $list->items(),"sql"=>$this->fetchSql()); + return $result; + } + // 查询当前用户是否已经付过费 + public function yungudong($where, $order, $offset, $limit,$sort,$type){ + $order = empty($order)?['o.createtime'=>"desc"]:$order; + $page = $offset/ $limit+1; + $list = $this->field("o.id,o.user_id,o.createtime,order_no,title,o.money,paytime,content_id,u.nickname,ispay,user_money,system_money,o.status,type,f.user_id as fabu_user_id,f.title")->alias('o')->join('fa_content f','f.id = o.content_id','LEFT')->join('fa_user u','u.id = o.user_id','LEFT') + ->where($where) + ->where('ispay',1) + ->where('type',$type) + ->paginate($limit); + // ->paginate(['page'=> $page?? 1,'list_rows' => $limit]); $result = array("total" => $list->total(), "rows" => $list->items(),"sql"=>$this->fetchSql()); return $result; } diff --git a/application/admin/view/order/index.html b/application/admin/view/order/index.html index 594f1af..b2118a9 100644 --- a/application/admin/view/order/index.html +++ b/application/admin/view/order/index.html @@ -1,10 +1,26 @@ +
+
+ +
+
+

支付总金额(元):¥0.00平台总收入(元):¥0.00发布人总收入(元):¥0.00

+
统计结果为平台计算得出仅用于展示
+
+
+
{:build_heading()} -
+ + + text + { + font-size:20px;font-weight: bold; margin-right: 10%; + color:#1688f1; + } + +
+
+ +
+
+

支付总金额(元):¥0.00平台总收入(元):¥0.00发布人总收入(元):¥0.00

+
统计结果为平台计算得出仅用于展示
+
+
+
+ {:build_heading()} +
+
+
+
+ +
+
+
diff --git a/application/admin/view/order/zanshang.html b/application/admin/view/order/zanshang.html new file mode 100644 index 0000000..b2118a9 --- /dev/null +++ b/application/admin/view/order/zanshang.html @@ -0,0 +1,47 @@ + +
+
+ +
+
+

支付总金额(元):¥0.00平台总收入(元):¥0.00发布人总收入(元):¥0.00

+
统计结果为平台计算得出仅用于展示
+
+
+
+ {:build_heading()} +
+
+ + +
+
+
diff --git a/application/admin/view/user/vipset/edit.html b/application/admin/view/user/vipset/edit.html index cdaeb3b..bb1be59 100644 --- a/application/admin/view/user/vipset/edit.html +++ b/application/admin/view/user/vipset/edit.html @@ -24,18 +24,6 @@ -
- -
- -
- {foreach name="statusList" item="vo"} - - {/foreach} -
- -
-
- -
- -
-
-
- +
diff --git a/application/api/controller/Content.php b/application/api/controller/Content.php index 74b358a..409a3dd 100644 --- a/application/api/controller/Content.php +++ b/application/api/controller/Content.php @@ -15,6 +15,7 @@ use app\admin\model\Order; use app\admin\model\user\Friend; use think\Model; use think\Db; +use fast\Random; use think\Exception; /** * 事件接口 @@ -155,13 +156,32 @@ class Content extends Api $logModel = new LogModel; $id = $this->request->post('id'); $post = $this->request->post(); + $data = $this->model->get($id); if(isset($post['token']) && !empty($post['token']) && $this->auth->id){ + $userin = User::get($this->auth->id); $playinfo = $logModel->where('type',3)->where('content_id',$id)->where('user_id',$this->auth->id)->find(); if(empty($playinfo)){ $this->operaContentneibu(['content_id'=>$id,'type'=>3,'user_id'=>$this->auth->id]); } + $order = Order::where(['content_id'=>$data['id'],'user_id'=>$this->auth->id,'status'=>1])->find(); + //判断是否是云股东 + if($userin['is_vip']&&$userin['vipout_time']>time()&&$userin['read_num']>0&&empty($order)){ + $order['content_id'] = $data['id']; + $order['user_id'] = $this->auth->id; + $order['order_no'] = "YGD".Random::numeric(15); + $order['money'] = 0; + $order['createtime'] = date('Y-m-d H:i:s',time()); + $order['paytime'] = date('Y-m-d H:i:s',time()); + $order['ispay'] = 1; + $order['status'] = 1; + $order['paytype'] = "云股东权益"; + $order['user_money'] = 0; + $order['system_money'] = 0; + Order::insertGetId($order); + $userin->read_num = $userin['read_num']-1; + $userin->save(); + } } - $data = $this->model->get($id); //查询发布人信息 $userinfo = User::get($data['user_id']); $data['avatar'] = empty($userinfo)?'':$userinfo['avatar']; @@ -338,11 +358,14 @@ class Content extends Api } $insert['title'] = implode(',',array_values($data['where'])); $insert['createtime'] = date("Y-m-d H:i:s",time()); - if(Search::insert($insert)){ - return true; - }else{ - return false; + if(!empty($insert['title'])){ + if(Search::insert($insert)){ + return true; + }else{ + return false; + } } + return false; } public function getsearchlist(){ //获取搜索记录 @@ -353,7 +376,24 @@ class Content extends Api foreach($list as $key => &$val){ $val['content'] = json_decode($val['content'],true); } - $rerurn = ['list'=>$list,'lianxiang'=>$list]; + //查询联想内容 + //查询次数多的内容 + $lianxiang = Search::where('user_id',$uid)->order('createtime desc')->select(); + + //获取信息 + $keyword = array_column($lianxiang,'title'); + $keyword = array_count_values($keyword); + + arsort($keyword); + $top_strings = array_keys($keyword); + $top_strings = array_slice($top_strings, 0, 1); + $returnlx = Search::where("title","like",$top_strings[0])->order('createtime desc')->limit(0,10)->select(); + + foreach($returnlx as $ke => &$va){ + $va['content'] = json_decode($va['content'],true); + } + + $rerurn = ['list'=>$list,'lianxiang'=>$returnlx]; return $this->success('获取成功', $rerurn); } public function delsearch(){ diff --git a/application/api/controller/Order.php b/application/api/controller/Order.php index d872548..ee90a20 100644 --- a/application/api/controller/Order.php +++ b/application/api/controller/Order.php @@ -80,11 +80,13 @@ class Order extends Api if($this->request->isPost()){ $min_user = new \app\admin\model\miniprogram\User; $amount = $this->request->post('pay_price'); + //订单号 $out_trade_no = $this->request->post('orderno'); $type = 'wechat'; $method = 'miniapp'; $min_user_info = $min_user->getbyUser_id($this->auth->id); + //判断是否是云股东 $openid = $min_user_info['openid']; if (!$amount || $amount < 0) { $this->error("支付金额必须大于0"); @@ -152,6 +154,7 @@ class Order extends Api $order->paytime = date('Y-m-d H:i:s',time()); $order->money = $payamount; $order->paytype = $paytype; + $order->system_money = $payamount; if($order->type==1){ // 更改用户余额 // 查询事件用户ID @@ -159,6 +162,8 @@ class Order extends Api $contentinfo = Content::get($order->content_id); $dashang = number_format($order->money*0.5, 2, '.', ''); User::money($dashang, $contentinfo['user_id'], $contentinfo->title,1); + $order->user_money = $dashang; + $order->system_money = $payamount-$dashang; } }else if($order->type==2){ $user = User::get($order->user_id); @@ -166,6 +171,7 @@ class Order extends Api $user->vipout_time = (int)$user->vipout_time>time()?(time() + 2592000):(int)$user->vipout_time+2592000; $user->read_num = (int)$user->vipout_time>time()?10:(int)$user->read_num+10; $user->save(); + $order->outtime = date("Y-m-d H:i:s",(int)$user->vipout_time>time()?(time() + 2592000):(int)$user->vipout_time+2592000); } $order->save(); } diff --git a/application/api/controller/Systembasic.php b/application/api/controller/Systembasic.php index b7992b8..d57049e 100644 --- a/application/api/controller/Systembasic.php +++ b/application/api/controller/Systembasic.php @@ -47,8 +47,8 @@ class Systembasic extends Api return $this->success('获取成功',$return); } public function infoopen(){ - $info['qq'] = false; - $info['wechat'] = false; + $info['qq'] = true; + $info['wechat'] = true; return $this->success('获取成功',$info); } } \ No newline at end of file diff --git a/public/assets/js/backend/content.js b/public/assets/js/backend/content.js index 997f4f1..4496712 100644 --- a/public/assets/js/backend/content.js +++ b/public/assets/js/backend/content.js @@ -42,7 +42,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'status', title: '审核状态', searchList: {"0":'待审核',"1":'审核通过',"-1":'驳回'}, formatter: Table.api.formatter.status}, {field: 'updatetime', title: '审核时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'content', title: __('Content')}, + {field: 'content', title: __('Content'), formatter: Table.api.formatter.content}, // {field: 'video', title: __('Video')}, {field: 'main_company', title: __('Main_company'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'user_id', title: __('User_id')}, diff --git a/public/assets/js/backend/content/pinglun.js b/public/assets/js/backend/content/pinglun.js index e008be8..d828b14 100644 --- a/public/assets/js/backend/content/pinglun.js +++ b/public/assets/js/backend/content/pinglun.js @@ -26,11 +26,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'content_id', title: __('Content_id')}, - {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'status', title: __('Status'), searchList: {"11":__('Status 11')}, formatter: Table.api.formatter.status}, - {field: 'user_id', title: __('User_id')}, + {field: 'Content_id', title: "标题"}, + {field: 'type', title: "内容类型"}, + {field: 'user_id', title: "评论人"}, + {field: 'content', title: __('Content')}, + {field: 'createtime', title: "评论时间", operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/order.js b/public/assets/js/backend/order.js index 4944330..9dc58f1 100644 --- a/public/assets/js/backend/order.js +++ b/public/assets/js/backend/order.js @@ -26,16 +26,90 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'content_id', title: __('Content_id')}, - {field: 'user_id', title: __('User_id')}, {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, - {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'type', title: __('Type')}, + {field: 'money', title: '订单金额(元)'}, + {field: 'title', title: '内容标题'}, + {field: 'fabu_user_id', title: '发布者ID'}, + {field: 'user_id', title: '支付者ID'}, + {field: 'user_money', title: '平台收入(元)'}, + {field: 'system_money', title: '用户收入(元)'}, + {field: 'paytime', title: '支付时间'}, + {field: 'status', title: "订单状态"}, + // {field: 'content_id', title: __('Content_id')}, + // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + // {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + // {field: 'type', title: "订单类型"}, + // {field: 'ispay', title: "支付状态"}, + // {field: 'status', title: "订单状态"}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] - ] + ], + onLoadSuccess: function(data,$element) { + console.log(data) + $("#paysum").html(data.paysum) + $("#systemsum").html(data.systemsum) + $("#usersum").html(data.usersum) + + } + }); + + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + + zanshang: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'order/index' + location.search, + add_url: 'order/add', + edit_url: 'order/edit', + del_url: 'order/del', + multi_url: 'order/multi', + import_url: 'order/import', + table: 'order', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: 'order/zanshang?type=3', + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, + {field: 'money', title: '订单金额(元)'}, + {field: 'title', title: '内容标题'}, + {field: 'fabu_user_id', title: '发布者ID'}, + {field: 'user_id', title: '支付者ID'}, + {field: 'user_money', title: '平台收入(元)'}, + {field: 'system_money', title: '用户收入(元)'}, + {field: 'paytime', title: '支付时间'}, + {field: 'status', title: "订单状态"}, + // {field: 'content_id', title: __('Content_id')}, + // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + // {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + // {field: 'type', title: "订单类型"}, + // {field: 'ispay', title: "支付状态"}, + // {field: 'status', title: "订单状态"}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ], + onLoadSuccess: function(data,$element) { + console.log(data) + $("#paysum").html(data.paysum) + $("#systemsum").html(data.systemsum) + $("#usersum").html(data.usersum) + + } }); + // 为表格绑定事件 Table.api.bindevent(table); diff --git a/public/assets/js/backend/user/vipset.js b/public/assets/js/backend/user/vipset.js index 157a940..b3b672e 100644 --- a/public/assets/js/backend/user/vipset.js +++ b/public/assets/js/backend/user/vipset.js @@ -6,7 +6,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin Table.api.init({ extend: { index_url: 'user/vipset/index' + location.search, - add_url: 'user/vipset/add', + add_url: 'user/vipset/edit/ids/1', edit_url: 'user/vipset/edit', del_url: 'user/vipset/del', multi_url: 'user/vipset/multi', @@ -19,18 +19,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // 初始化表格 table.bootstrapTable({ - url: $.fn.bootstrapTable.defaults.extend.index_url, + url: 'order/yungudong?type=2', pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'money', title: __('Money'), operate:'BETWEEN'}, - {field: 'pay_money', title: __('Pay_money'), operate:'BETWEEN'}, - {field: 'status', title: __('Status'), searchList: {"1":__('Status 1')}, formatter: Table.api.formatter.status}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + {field: 'user_id', title: '用户ID'}, + {field: 'nickname', title: '用户昵称'}, + {field: 'money', title: __('Pay_money'), operate:'BETWEEN'}, + {field: 'createtime', title: '加入时间'}, + {field: 'outtime', title: '到期时间'}, + // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); diff --git a/public/assets/js/backend/user/zanshang.js b/public/assets/js/backend/user/zanshang.js index 0b6a94a..d81e5af 100644 --- a/public/assets/js/backend/user/zanshang.js +++ b/public/assets/js/backend/user/zanshang.js @@ -27,9 +27,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'money', title: __('Money'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'order', title: __('Order')}, + {field: 'money', title: "赞赏金额", operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'order', title: "排序"}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ]