From f473c0abc1897778558ffeeb61ce66b7c3e8e013 Mon Sep 17 00:00:00 2001
From: chenxiaojun <956334972@qq.com>
Date: Fri, 15 Nov 2019 14:26:28 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0->?=
=?UTF-8?q?=E6=B8=B8=E6=88=8F=E8=AE=A2=E5=8D=95->=E6=B8=B8=E6=88=8F?=
=?UTF-8?q?=E5=85=85=E5=80=BC--=E5=88=97=E8=A1=A8=E6=A0=B7=E5=BC=8F?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Admin/View/Spend/lists.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Application/Admin/View/Spend/lists.html b/Application/Admin/View/Spend/lists.html
index 154a3b6ad..35a762a32 100644
--- a/Application/Admin/View/Spend/lists.html
+++ b/Application/Admin/View/Spend/lists.html
@@ -229,7 +229,7 @@
汇总 |
-
+ |
当页充值:{:null_to_0(array_sum(array_column(array_status2value('pay_status','',$list_data),'pay_amount')))}
今日充值:{$ttotal}
昨日充值:{$ytotal}
From 9075730d83c0f2ea1d41b60969c823efd6b694ab Mon Sep 17 00:00:00 2001
From: chenxiaojun <956334972@qq.com>
Date: Fri, 15 Nov 2019 14:52:53 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0->?=
=?UTF-8?q?=E6=B8=B8=E6=88=8F=E8=AE=A2=E5=8D=95->=E6=B8=B8=E6=88=8F?=
=?UTF-8?q?=E5=85=85=E5=80=BC--=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Admin/Model/SpendModel.class.php | 911 ++++++++++---------
1 file changed, 494 insertions(+), 417 deletions(-)
diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php
index 1ba165eea..6f5e3ab07 100644
--- a/Application/Admin/Model/SpendModel.class.php
+++ b/Application/Admin/Model/SpendModel.class.php
@@ -8,6 +8,7 @@
// +----------------------------------------------------------------------
namespace Admin\Model;
+
use Common\Api\GameApi;
use Org\WeixinSDK\Weixin;
use Think\Model;
@@ -15,8 +16,8 @@ use Think\Model;
/**
* 文档基础模型
*/
-class SpendModel extends Model{
-
+class SpendModel extends Model
+{
/* 自动验证规则 */
@@ -24,16 +25,17 @@ class SpendModel extends Model{
/* 自动完成规则 */
protected $_auto = array(
- array('pay_time', 'getCreateTime', self::MODEL_INSERT,'callback'),
- array('pay_status', 0, self::MODEL_INSERT),
- array('order_number','',self::MODEL_INSERT),
+ array('pay_time', 'getCreateTime', self::MODEL_INSERT, 'callback'),
+ array('pay_status', 0, self::MODEL_INSERT),
+ array('order_number', '', self::MODEL_INSERT),
);
-protected function _after_select(&$result,$options){
- foreach($result as $key=>$value){
- // $result[$key]['pay_way'] = date('Y-m-d ', $value['time']);
- }
- }
+ protected function _after_select(&$result, $options)
+ {
+ foreach ($result as $key => $value) {
+ // $result[$key]['pay_way'] = date('Y-m-d ', $value['time']);
+ }
+ }
/**
* 构造函数
@@ -41,9 +43,10 @@ protected function _after_select(&$result,$options){
* @param string $tablePrefix 表前缀
* @param mixed $connection 数据库连接信息
*/
- public function __construct($name = '', $tablePrefix = '', $connection = '') {
+ public function __construct($name = '', $tablePrefix = '', $connection = '')
+ {
/* 设置默认的表前缀 */
- $this->tablePrefix ='tab_';
+ $this->tablePrefix = 'tab_';
/* 执行构造方法 */
parent::__construct($name, $tablePrefix, $connection);
}
@@ -54,16 +57,19 @@ protected function _after_select(&$result,$options){
* @return int 时间戳
* @author huajie
*/
- protected function getCreateTime(){
- $create_time = I('post.create_time');
- return $create_time?strtotime($create_time):NOW_TIME;
+ protected function getCreateTime()
+ {
+ $create_time = I('post.create_time');
+ return $create_time ? strtotime($create_time) : NOW_TIME;
}
public function amdin_account()
{
- return session('user_auth.username');
+ return session('user_auth.username');
}
- public function totalSpendTimes($map=""){
+
+ public function totalSpendTimes($map = "")
+ {
$map['s.pay_status'] = 1;
$data = $this->alias("s")->field("IFNULL(count(pay_amount),0) as count")
->join("left join tab_game g on g.id = s.game_id")
@@ -71,40 +77,44 @@ protected function _after_select(&$result,$options){
->find();
return $data['count'];
}
+
/**
* [dealPage 页码处理]
* @param [type] $p [description]
* @return [type] [description]
*/
- public function dealPage($p){
+ public function dealPage($p)
+ {
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
return $page;
}
+
/**
* 自动补单
*/
- public static function auto_repair(){
+ public static function auto_repair()
+ {
$game = new GameApi();
- $map['pay_status'] = 1;
+ $map['pay_status'] = 1;
$map['pay_game_status'] = 0;
- $order = M("spend",'tab_')->field('pay_order_number,1 as code')->where($map)->select();//普通消费
- $bind_spend = M("bind_spend",'tab_')->field('pay_order_number,2 as code')->where($map)->select();//绑币消费
- if(!empty($bind_spend)){
- array_push($order,$bind_spend);
+ $order = M("spend", 'tab_')->field('pay_order_number,1 as code')->where($map)->select();//普通消费
+ $bind_spend = M("bind_spend", 'tab_')->field('pay_order_number,2 as code')->where($map)->select();//绑币消费
+ if (!empty($bind_spend)) {
+ array_push($order, $bind_spend);
}
$success_num = $error_num = 0;
- foreach ($order as $key=>$val) {
+ foreach ($order as $key => $val) {
$param['out_trade_no'] = $val['pay_order_number'];
$result = $game->game_pay_notify($param, $val['code']);
- if($val['code'] == 1){
- M('spend','tab_')->where(['pay_order_number'=>$val['pay_order_number']])->setInc('auto_compensation');
- }else{
- M('bind_spend','tab_')->where(['pay_order_number'=>$val['pay_order_number']])->setInc('auto_compensation');
+ if ($val['code'] == 1) {
+ M('spend', 'tab_')->where(['pay_order_number' => $val['pay_order_number']])->setInc('auto_compensation');
+ } else {
+ M('bind_spend', 'tab_')->where(['pay_order_number' => $val['pay_order_number']])->setInc('auto_compensation');
}
- if($result == "success"){
+ if ($result == "success") {
$success_num++;
- }else{
+ } else {
$error_num++;
}
}
@@ -117,19 +127,19 @@ protected function _after_select(&$result,$options){
* 退款接口
* @param $map
*/
- public function Refund($map,$order,$sign)
+ public function Refund($map, $order, $sign)
{
- if(md5("mcaseqwezdsi".$order)!==$sign){
- return false;
+ if (md5("mcaseqwezdsi" . $order) !== $sign) {
+ return false;
}
$RefundRecord = M('RefundRecord', 'tab_')->where($map)->find();
if (null == $RefundRecord) {
$find = $this->where($map)->find();
$order_number = $find['pay_way'] == 1 ? date("YmdHis") : "TK_" . date('Ymd') . date('His') . sp_random_string(4);
- $BatchNo=date("YmdHis");
+ $BatchNo = date("YmdHis");
} else {
$order_number = $RefundRecord['order_number'];
- $BatchNo=$RefundRecord['batch_no'];
+ $BatchNo = $RefundRecord['batch_no'];
$find = $RefundRecord;
}
@@ -139,7 +149,7 @@ protected function _after_select(&$result,$options){
$vo = new \Think\Pay\PayVo();
$detail_data = $find['order_number'] . "^" . $find['pay_amount'] . "^调单";
- $find['batch_no']=$BatchNo;
+ $find['batch_no'] = $BatchNo;
$vo->setOrderNo($find['order_number'])
->setService("refund_fastpay_by_platform_pwd")
->setSignType("MD5")
@@ -165,7 +175,7 @@ protected function _after_select(&$result,$options){
$config = array("partner" => trim(C("weixin.partner")), "email" => "", "key" => trim(C("weixin.key")));
$pay = new \Think\Pay('swiftpass', $config);
$vo = new \Think\Pay\PayVo();
- $vo->setService('unified.trade.refund')
+ $vo->setService('unified.trade.refund')
->setSignType("MD5")
->setPayMethod("refund")
->setTable("RefundRecord")
@@ -173,8 +183,8 @@ protected function _after_select(&$result,$options){
->setBatchNo($order_number)
->setFee($find['pay_amount']);
$this->add_refund_record($find, $order_number);
- $this->where($map)->delete();
- $res=$pay->buildRequestForm($vo);
+ $this->where($map)->delete();
+ $res = $pay->buildRequestForm($vo);
if ($res['status'] == 0) {
return $res['status'];
} else {
@@ -183,8 +193,8 @@ protected function _after_select(&$result,$options){
} elseif ($find['pay_way'] == 0) {
$user_map['id'] = $find['user_id'];
M('user', 'tab_')->where($user_map)->setInc('balance', $find['pay_amount']);
- $this->add_refund_record($find, $order_number);
- $this->where($map)->delete();
+ $this->add_refund_record($find, $order_number);
+ $this->where($map)->delete();
return true;
}
@@ -202,24 +212,24 @@ protected function _after_select(&$result,$options){
$map['pay_order_number'] = $data['pay_order_number'];
$find = $RefundRecord->where($map)->find();
if (null !== $find) {
- if($data['pay_way']==4||$data['pay_way']==3){
+ if ($data['pay_way'] == 4 || $data['pay_way'] == 3) {
$RefundRecord->where($map)->delete();
$data['tui_status'] = 2;
$data['create_time'] = time();
$data['tui_amount'] = $data['pay_amount'];
$data['order_number'] = $order_number;
return $RefundRecord->add($data);
- }else{
+ } else {
return true;
}
} else {
if ($data['pay_way'] == 0) {
$data['tui_status'] = 1;
$data['tui_time'] = time();
- $savv['sub_status']=1;
- $savv['settle_check']=1;
+ $savv['sub_status'] = 1;
+ $savv['settle_check'] = 1;
$this->where($map)->save($savv);
- }elseif($data['pay_way'] == 4||$data['pay_way']==3){
+ } elseif ($data['pay_way'] == 4 || $data['pay_way'] == 3) {
$data['tui_status'] = 2;
}
@@ -232,34 +242,33 @@ protected function _after_select(&$result,$options){
}
-
-
/**
* 微信退款查询接口
* @param [type] $orderNo [description]
* @return [type] [description]
*/
- public function weixin_refundquery($orderNo){
- $weixn = new Weixin();
- $res = $weixn->weixin_refundquery($orderNo);
- if($res=="SUCCESS"){
- M('RefundRecord', 'tab_')->where(array('pay_order_number'=>$orderNo))->setField('tui_status', 1);
- return json_encode(array('status'=>1,'msg'=>'退款成功'));
- }elseif($res=="FAIL"){
- return json_encode(array('status'=>0,'msg'=>'退款失败'));
- }elseif($res=="PROCESSING"){
- return json_encode(array('status'=>0,'msg'=>'退款处理中'));
- }
+ public function weixin_refundquery($orderNo)
+ {
+ $weixn = new Weixin();
+ $res = $weixn->weixin_refundquery($orderNo);
+ if ($res == "SUCCESS") {
+ M('RefundRecord', 'tab_')->where(array('pay_order_number' => $orderNo))->setField('tui_status', 1);
+ return json_encode(array('status' => 1, 'msg' => '退款成功'));
+ } elseif ($res == "FAIL") {
+ return json_encode(array('status' => 0, 'msg' => '退款失败'));
+ } elseif ($res == "PROCESSING") {
+ return json_encode(array('status' => 0, 'msg' => '退款处理中'));
+ }
}
-
/**
* 威富通查询退款接口
* @param [type] $map [description]
* @return [type] [description]
*/
- public function swiftpass_refund($orderNo){
+ public function swiftpass_refund($orderNo)
+ {
$config = array("partner" => trim(C("weixin.partner")), "email" => "", "key" => trim(C("weixin.key")));
$pay = new \Think\Pay('swiftpass', $config);
$vo = new \Think\Pay\PayVo();
@@ -268,429 +277,495 @@ protected function _after_select(&$result,$options){
->setSignType("MD5")
->setPayMethod("find")
->setTable("RefundRecord");
- $res=$pay->buildRequestForm($vo);
- if($res['refund_status']=="SUCCESS"){
- M('RefundRecord', 'tab_')->where(array('pay_order_number'=>$orderNo))->setField('tui_status', 1);
- return json_encode(array('status'=>1,'msg'=>'退款成功'));
- }elseif($res['refund_status']=="FAIL"){
- return json_encode(array('status'=>0,'msg'=>'退款失败'));
- }elseif($res['refund_status']=="PROCESSING"){
- return json_encode(array('status'=>0,'msg'=>'退款处理中'));
+ $res = $pay->buildRequestForm($vo);
+ if ($res['refund_status'] == "SUCCESS") {
+ M('RefundRecord', 'tab_')->where(array('pay_order_number' => $orderNo))->setField('tui_status', 1);
+ return json_encode(array('status' => 1, 'msg' => '退款成功'));
+ } elseif ($res['refund_status'] == "FAIL") {
+ return json_encode(array('status' => 0, 'msg' => '退款失败'));
+ } elseif ($res['refund_status'] == "PROCESSING") {
+ return json_encode(array('status' => 0, 'msg' => '退款处理中'));
}
}
-
-
-
-
-
-
-
-
-
- /**
- * 开放平台 付费人数
- * @param string $map
- * @return mixed
- * author: xmy 280564871@qq.com
- */
- public function countSpendUserOfOpen($map=""){
- $sql = $this->alias("s")->field("s.user_id")
- ->join("left join tab_game g on g.id = s.game_id")
- ->where($map)
- ->group("s.game_id,s.user_id")
- ->select(false);
- $sql = "select count(DISTINCT user_id) as num from ({$sql}) as res";
- $data = M()->query($sql);
- return $data[0]['num'];
+ /**
+ * 开放平台 付费人数
+ * @param string $map
+ * @return mixed
+ * author: xmy 280564871@qq.com
+ */
+ public function countSpendUserOfOpen($map = "")
+ {
+ $sql = $this->alias("s")->field("s.user_id")
+ ->join("left join tab_game g on g.id = s.game_id")
+ ->where($map)
+ ->group("s.game_id,s.user_id")
+ ->select(false);
+ $sql = "select count(DISTINCT user_id) as num from ({$sql}) as res";
+ $data = M()->query($sql);
+ return $data[0]['num'];
}
- /**
- * 累计付费
- * @param string $map
- * @return mixed
- * author: xmy 280564871@qq.com
- */
- public function totalSpend($map=""){
- $map['s.pay_status'] = 1;
- $data = $this->alias("s")->field("IFNULL(sum(pay_amount),0) as num")
- ->join("right join tab_game g on g.id = s.game_id")
- ->where($map)
- ->find();
- return $data['num'];
+ /**
+ * 累计付费
+ * @param string $map
+ * @return mixed
+ * author: xmy 280564871@qq.com
+ */
+ public function totalSpend($map = "")
+ {
+ $map['s.pay_status'] = 1;
+ $data = $this->alias("s")->field("IFNULL(sum(pay_amount),0) as num")
+ ->join("right join tab_game g on g.id = s.game_id")
+ ->where($map)
+ ->find();
+ return $data['num'];
}
- /**
- * 获取开放平台流水
- * @param $map
- * @param $develop_id
- * author: xmy 280564871@qq.com
- */
- public function getOpenSpend($map,$develop_id,$game_id){
+ /**
+ * 获取开放平台流水
+ * @param $map
+ * @param $develop_id
+ * author: xmy 280564871@qq.com
+ */
+ public function getOpenSpend($map, $develop_id, $game_id)
+ {
// empty($game_id) || $map['s.game_id'] = $game_id;
- empty($game_id) || $join = "and g.id = {$game_id}";
- $data = $this->alias("s")->field("IFNULL(sum(pay_amount),0) as num,d.time")
- ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id {$join}")
- ->join("right join sys_date_list d on d.time = FROM_UNIXTIME(s.pay_time,'%Y-%m-%d') and s.pay_status = 1")
- ->where($map)
- ->group("d.time")
- ->select();
- return $data;
+ empty($game_id) || $join = "and g.id = {$game_id}";
+ $data = $this->alias("s")->field("IFNULL(sum(pay_amount),0) as num,d.time")
+ ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id {$join}")
+ ->join("right join sys_date_list d on d.time = FROM_UNIXTIME(s.pay_time,'%Y-%m-%d') and s.pay_status = 1")
+ ->where($map)
+ ->group("d.time")
+ ->select();
+ return $data;
}
- /**
- * 付费玩家数
- * @param $map
- * @param $develop_id
- * @return mixed
- * author: xmy 280564871@qq.com
- */
- public function getPayerNum($map,$develop_id,$game_id){
+ /**
+ * 付费玩家数
+ * @param $map
+ * @param $develop_id
+ * @return mixed
+ * author: xmy 280564871@qq.com
+ */
+ public function getPayerNum($map, $develop_id, $game_id)
+ {
// empty($game_id) || $map['s.game_id'] = $game_id;
- empty($game_id) || $join = "and g.id = {$game_id}";
- $data = $this->alias("s")->field("IFNULL(count(DISTINCT user_id),0) as num,d.time")
- ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id {$join}")
- ->join("right join sys_date_list d on d.time = FROM_UNIXTIME(s.pay_time,'%Y-%m-%d') and s.pay_status = 1")
- ->where($map)
- ->group("d.time")
- ->select();
- return $data;
+ empty($game_id) || $join = "and g.id = {$game_id}";
+ $data = $this->alias("s")->field("IFNULL(count(DISTINCT user_id),0) as num,d.time")
+ ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id {$join}")
+ ->join("right join sys_date_list d on d.time = FROM_UNIXTIME(s.pay_time,'%Y-%m-%d') and s.pay_status = 1")
+ ->where($map)
+ ->group("d.time")
+ ->select();
+ return $data;
}
- /**
- * 新增付费玩家
- * @param $start
- * @param $end
- * @param $develop_id
- * @return mixed
- * author: xmy 280564871@qq.com
- */
- public function getNewPayerNum($start,$end,$develop_id,$game_id){
- //第一次充值
- empty($game_id) || $map['s.game_id'] = $game_id;
-
- $map['s.pay_status'] = 1;
- $sql = $this->alias("s")->field("user_id,min(pay_time) as pay_time")
- ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id")
- ->where($map)
- ->group("s.user_id")
- ->select(false);
- $sql = "SELECT count(res.user_id) as num,d.time FROM ({$sql}) res right join sys_date_list d on d.time = FROM_UNIXTIME(res.pay_time,'%Y-%m-%d')
+ /**
+ * 新增付费玩家
+ * @param $start
+ * @param $end
+ * @param $develop_id
+ * @return mixed
+ * author: xmy 280564871@qq.com
+ */
+ public function getNewPayerNum($start, $end, $develop_id, $game_id)
+ {
+ //第一次充值
+ empty($game_id) || $map['s.game_id'] = $game_id;
+
+ $map['s.pay_status'] = 1;
+ $sql = $this->alias("s")->field("user_id,min(pay_time) as pay_time")
+ ->join("right join tab_game g on g.id = s.game_id and g.developers = $develop_id")
+ ->where($map)
+ ->group("s.user_id")
+ ->select(false);
+ $sql = "SELECT count(res.user_id) as num,d.time FROM ({$sql}) res right join sys_date_list d on d.time = FROM_UNIXTIME(res.pay_time,'%Y-%m-%d')
WHERE d.time BETWEEN '{$start}' and '{$end}' GROUP BY d.time";
- $data = $this->query($sql);
- return $data;
+ $data = $this->query($sql);
+ return $data;
}
- /**
- * 累计付费玩家数(按天分组)
- * @param $map
- * @param $develop_id
- * @return mixed
- * author: xmy 280564871@qq.com
- */
- public function getTotalPayerNum($start,$end,$develop_id){
- $start = strtotime($start);
- $end = strtotime($end);
- $map['g.developers'] = $develop_id;
- $map['s.pay_status'] = 1;
- for ($time = $start; $time <= $end; $time += 86400) {
- $map['s.pay_time'] = ['lt',$time+86399];
- $data[]['num'] = $this->countSpendUserOfOpen($map);
- }
- return $data;
+ /**
+ * 累计付费玩家数(按天分组)
+ * @param $map
+ * @param $develop_id
+ * @return mixed
+ * author: xmy 280564871@qq.com
+ */
+ public function getTotalPayerNum($start, $end, $develop_id)
+ {
+ $start = strtotime($start);
+ $end = strtotime($end);
+ $map['g.developers'] = $develop_id;
+ $map['s.pay_status'] = 1;
+ for ($time = $start; $time <= $end; $time += 86400) {
+ $map['s.pay_time'] = ['lt', $time + 86399];
+ $data[]['num'] = $this->countSpendUserOfOpen($map);
+ }
+ return $data;
}
- /**
- * 累计流水
- * @param $map
- * @return mixed
- * author: xmy 280564871@qq.com
- */
- public function getTotalSpend($map){
- $map['pay_status'] = 1;
- $data = $this->field("IFNULL(sum(pay_amount),0) as num")->where($map)->find();
- return $data;
- }
-
- /*
- * 游戏充值未到账列表
- * @return array 结果集
- * @author 鹿文学
- */
- public function checkSpend() {
-
- $list = $this->field('id,user_id,user_account,game_id,game_name,pay_amount,pay_order_number')->where(array('pay_status'=>0))->select();
- $type = 101;
- if ($list[0]) {
-
- $list = D('check')->dealWithCheckList($type,$list);
-
- if (empty($list[0])) {return '';}
-
- foreach ($list as $k => $v) {
- $data[$k]['info'] = '玩家:'.$v['user_account'].',游戏['.$v['game_name'].']充值金额:'.$v['pay_amount'].',订单状态:下单未支付';
- $data[$k]['type'] = $type;
- $data[$k]['url'] = U('Spend/lists',array('pay_order_number'=>$v['pay_order_number']));
- $data[$k]['create_time'] = time();
- $data[$k]['status']=0;
- $data[$k]['position'] = $v['id'];
- }
- return $data;
- }else {
- D('check')->dealWithCheckListOnNull($type);
- return '';
- }
-
- }
-
- /*
- * 游戏补单列表
- * @return array 结果集
- * @author 鹿文学
- */
- public function checkSupplement() {
-
- $list = $this->field('id,user_id,user_account,pay_order_number')->where(array('pay_status'=>1,'pay_game_status'=>0))->select();
- $type = 102;
- if ($list[0]) {
-
- $list = D('check')->dealWithCheckList($type,$list);
-
- if (empty($list[0])) {return '';}
-
- foreach ($list as $k => $v) {
- $data[$k]['info'] = '玩家:'.$v['user_account'].',订单:'.$v['pay_order_number'].',操作:补单失败';
- $data[$k]['type'] = $type;
- $data[$k]['url'] = U('Spend/lists',array('pay_order_number'=>$v['pay_order_number']));
- $data[$k]['create_time'] = time();
- $data[$k]['status']=0;
- $data[$k]['position'] = $v['id'];
- }
- return $data;
- }else {
- D('check')->dealWithCheckListOnNull($type);
- return '';
- }
-
- }
+ /**
+ * 累计流水
+ * @param $map
+ * @return mixed
+ * author: xmy 280564871@qq.com
+ */
+ public function getTotalSpend($map)
+ {
+ $map['pay_status'] = 1;
+ $data = $this->field("IFNULL(sum(pay_amount),0) as num")->where($map)->find();
+ return $data;
+ }
+ /*
+ * 游戏充值未到账列表
+ * @return array 结果集
+ * @author 鹿文学
+ */
+ public function checkSpend()
+ {
- /**
- * 统计总流水
- * @param array $where 条件数组
- * @return integer 数量
- * @author 鹿文学
- */
- public function totalAmount($map=array()) {
+ $list = $this->field('id,user_id,user_account,game_id,game_name,pay_amount,pay_order_number')->where(array('pay_status' => 0))->select();
+ $type = 101;
+ if ($list[0]) {
- $map['pay_status'] = 1;
+ $list = D('check')->dealWithCheckList($type, $list);
- $sum = $this->where($map)->sum('pay_amount');
-
- return $sum?$sum:0;
+ if (empty($list[0])) {
+ return '';
+ }
- }
+ foreach ($list as $k => $v) {
+ $data[$k]['info'] = '玩家:' . $v['user_account'] . ',游戏[' . $v['game_name'] . ']充值金额:' . $v['pay_amount'] . ',订单状态:下单未支付';
+ $data[$k]['type'] = $type;
+ $data[$k]['url'] = U('Spend/lists', array('pay_order_number' => $v['pay_order_number']));
+ $data[$k]['create_time'] = time();
+ $data[$k]['status'] = 0;
+ $data[$k]['position'] = $v['id'];
+ }
+ return $data;
+ } else {
+ D('check')->dealWithCheckListOnNull($type);
+ return '';
+ }
+ }
- /**
- * 分组统计流水
- * @param array $map 条件数组
- * @param string $fieldname 字段别名
- * @param string $group 分组字段名
- * @param integer $flag 时间类别(1:天,2:月,3:周)
- * @return array 详细数据
- * @author 鹿文学
- */
- public function totalAmountByGroup($map=array(),$fieldname='amount',$group='time',$flag=1,$order='time') {
+ /*
+ * 游戏补单列表
+ * @return array 结果集
+ * @author 鹿文学
+ */
+ public function checkSupplement()
+ {
- switch($flag) {
- case 2:{$dateform = '%Y-%m';};break;
- case 3:{$dateform = '%Y-%u';};break;
- case 4:{$dateform = '%Y';};break;
- case 5:{$dateform = '%Y-%m-%d %H';};break;
- default:$dateform = '%Y-%m-%d';
- }
+ $list = $this->field('id,user_id,user_account,pay_order_number')->where(array('pay_status' => 1, 'pay_game_status' => 0))->select();
+ $type = 102;
+ if ($list[0]) {
- $map['pay_status']=1;
+ $list = D('check')->dealWithCheckList($type, $list);
+ if (empty($list[0])) {
+ return '';
+ }
- $data = $this->field('FROM_UNIXTIME(pay_time,"'.$dateform.'") as '.$group.',sum(pay_amount) as '.$fieldname)
+ foreach ($list as $k => $v) {
+ $data[$k]['info'] = '玩家:' . $v['user_account'] . ',订单:' . $v['pay_order_number'] . ',操作:补单失败';
+ $data[$k]['type'] = $type;
+ $data[$k]['url'] = U('Spend/lists', array('pay_order_number' => $v['pay_order_number']));
+ $data[$k]['create_time'] = time();
+ $data[$k]['status'] = 0;
+ $data[$k]['position'] = $v['id'];
+ }
+ return $data;
+ } else {
+ D('check')->dealWithCheckListOnNull($type);
+ return '';
+ }
- ->where($map)->group($group)->order($order)->select();
+ }
- return $data;
- }
- /**
- * 分组统计所有流水
- * @param array $map 条件数组
- * @param string $fieldname 字段别名
- * @param string $group 分组字段名
- * @param integer $flag 时间类别(1:天,2:月,3:周)
- * @return array 详细数据
- * @author 鹿文学
- */
- public function allAmountByGroup($map=array(),$fieldname='amount',$group='time',$flag=1,$order='time') {
+ /**
+ * 统计总流水
+ * @param array $where 条件数组
+ * @return integer 数量
+ * @author 鹿文学
+ */
+ public function totalAmount($map = array())
+ {
- switch($flag) {
- case 2:{$dateform = '%Y-%m';};break;
- case 3:{$dateform = '%Y-%u';};break;
- case 4:{$dateform = '%Y';};break;
- case 5:{$dateform = '%Y-%m-%d %H';};break;
- default:$dateform = '%Y-%m-%d';
- }
+ $map['pay_status'] = 1;
- $map['pay_status']=1;
+ $sum = $this->where($map)->sum('pay_amount');
- $union = D('deposit')->field('pay_order_number,FROM_UNIXTIME(create_time,"'.$dateform.'") as '.$group.',sum(pay_amount) as '.$fieldname)
+ return $sum ? $sum : 0;
- ->where(['create_time'=>$map['pay_time'],'pay_status'=>1])
+ }
- ->group($group)->select(false);
+ /**
+ * 分组统计流水
+ * @param array $map 条件数组
+ * @param string $fieldname 字段别名
+ * @param string $group 分组字段名
+ * @param integer $flag 时间类别(1:天,2:月,3:周)
+ * @return array 详细数据
+ * @author 鹿文学
+ */
+ public function totalAmountByGroup($map = array(), $fieldname = 'amount', $group = 'time', $flag = 1, $order = 'time')
+ {
- $bind = M('Bind_recharge','tab_')->field('pay_order_number,FROM_UNIXTIME(create_time,"'.$dateform.'") as '.$group.',sum(real_amount) as '.$fieldname)
+ switch ($flag) {
+ case 2:
+ {
+ $dateform = '%Y-%m';
+ };
+ break;
+ case 3:
+ {
+ $dateform = '%Y-%u';
+ };
+ break;
+ case 4:
+ {
+ $dateform = '%Y';
+ };
+ break;
+ case 5:
+ {
+ $dateform = '%Y-%m-%d %H';
+ };
+ break;
+ default:
+ $dateform = '%Y-%m-%d';
+ }
- ->where(['create_time'=>$map['pay_time'],'pay_status'=>1])
+ $map['pay_status'] = 1;
- ->group($group)->select(false);
+ $data = $this->field('FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',sum(pay_amount) as ' . $fieldname)
+ ->where($map)->group($group)->order($order)->select();
- $sql = $this->field('pay_order_number,FROM_UNIXTIME(pay_time,"'.$dateform.'") as '.$group.',sum(pay_amount) as '.$fieldname)
+ return $data;
+ }
- ->union('('.$union.')')
+ /**
+ * 分组统计所有流水
+ * @param array $map 条件数组
+ * @param string $fieldname 字段别名
+ * @param string $group 分组字段名
+ * @param integer $flag 时间类别(1:天,2:月,3:周)
+ * @return array 详细数据
+ * @author 鹿文学
+ */
+ public function allAmountByGroup($map = array(), $fieldname = 'amount', $group = 'time', $flag = 1, $order = 'time')
+ {
- ->union('('.$bind.')')
+ switch ($flag) {
+ case 2:
+ {
+ $dateform = '%Y-%m';
+ };
+ break;
+ case 3:
+ {
+ $dateform = '%Y-%u';
+ };
+ break;
+ case 4:
+ {
+ $dateform = '%Y';
+ };
+ break;
+ case 5:
+ {
+ $dateform = '%Y-%m-%d %H';
+ };
+ break;
+ default:
+ $dateform = '%Y-%m-%d';
+ }
- ->where($map)->group($group)->select(false);
+ $map['pay_status'] = 1;
- $data = $this->table('('.$sql.') as a')->field('a.'.$group.',sum(a.'.$fieldname.') as '.$fieldname)->group('a.'.$group)->order($order)->select();
+ $union = D('deposit')->field('pay_order_number,FROM_UNIXTIME(create_time,"' . $dateform . '") as ' . $group . ',sum(pay_amount) as ' . $fieldname)
+ ->where(['create_time' => $map['pay_time'], 'pay_status' => 1])
+ ->group($group)->select(false);
- return $data;
- }
- /*
- * 付费用户
- * @param array $map 条件数组
- * @param string $fieldname 字段别名
- * @param string $group 分组字段名
- * @param integer $flag 时间类别(1:天,2:月,3:周)
- * @return array 详细数据
- * @author 鹿文学
- */
- public function totalPlayerByGroup($map=array(),$fieldname='count',$group='time',$flag=1,$order='time') {
+ $bind = M('Bind_recharge', 'tab_')->field('pay_order_number,FROM_UNIXTIME(create_time,"' . $dateform . '") as ' . $group . ',sum(real_amount) as ' . $fieldname)
+ ->where(['create_time' => $map['pay_time'], 'pay_status' => 1])
+ ->group($group)->select(false);
- switch($flag) {
- case 2:{$dateform = '%Y-%m';};break;
- case 3:{$dateform = '%Y-%u';};break;
- case 4:{$dateform = '%Y';};break;
- case 5:{$dateform = '%Y-%m-%d %H';};break;
- default:$dateform = '%Y-%m-%d';
- }
- $map['pay_status']=1;
+ $sql = $this->field('pay_order_number,FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',sum(pay_amount) as ' . $fieldname)
+ ->union('(' . $union . ')')
+ ->union('(' . $bind . ')')
+ ->where($map)->group($group)->select(false);
+ $data = $this->table('(' . $sql . ') as a')->field('a.' . $group . ',sum(a.' . $fieldname . ') as ' . $fieldname)->group('a.' . $group)->order($order)->select();
- $data = $this->field('FROM_UNIXTIME(pay_time,"'.$dateform.'") as '.$group.',count( DISTINCT user_id) as '.$fieldname)
+ return $data;
+ }
- ->where($map)->group($group)->order($order)->select();
+ /*
+ * 付费用户
+ * @param array $map 条件数组
+ * @param string $fieldname 字段别名
+ * @param string $group 分组字段名
+ * @param integer $flag 时间类别(1:天,2:月,3:周)
+ * @return array 详细数据
+ * @author 鹿文学
+ */
+ public function totalPlayerByGroup($map = array(), $fieldname = 'count', $group = 'time', $flag = 1, $order = 'time')
+ {
- return $data;
+ switch ($flag) {
+ case 2:
+ {
+ $dateform = '%Y-%m';
+ };
+ break;
+ case 3:
+ {
+ $dateform = '%Y-%u';
+ };
+ break;
+ case 4:
+ {
+ $dateform = '%Y';
+ };
+ break;
+ case 5:
+ {
+ $dateform = '%Y-%m-%d %H';
+ };
+ break;
+ default:
+ $dateform = '%Y-%m-%d';
+ }
- }
+ $map['pay_status'] = 1;
- /*
- * 付费用户
- * @param integer $start 开始时间戳
- * @param integer $end 结束时间戳
- * @param string $fieldname 字段别名
- * @param string $group 分组字段名
- * @param integer $flag 时间类别(1:天,2:月,3:周)
- * @return array 详细数据
- * @author 鹿文学
- */
- public function totalPlayerByTime($start,$end,$fieldname='count',$group='time',$flag=1,$order='time') {
- switch($flag) {
- case 2:{$dateform = '%Y-%m';};break;
- case 3:{$dateform = '%Y-%u';};break;
- case 4:{$dateform = '%Y';};break;
- case 5:{$dateform = '%Y-%m-%d %H';};break;
- default:$dateform = '%Y-%m-%d';
- }
+ $data = $this->field('FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',count( DISTINCT user_id) as ' . $fieldname)
+ ->where($map)->group($group)->order($order)->select();
- $map['pay_status']=1;
+ return $data;
- $map['create_time'] = ['between',[$start,$end]];
+ }
- $bindrecharge_data = M('bind_recharge','tab_')->field('FROM_UNIXTIME(create_time,"'.$dateform.'") as '.$group.',GROUP_CONCAT( DISTINCT user_id) as user_id')
- ->where($map)->group($group)->select(false);
+ /*
+ * 付费用户
+ * @param integer $start 开始时间戳
+ * @param integer $end 结束时间戳
+ * @param string $fieldname 字段别名
+ * @param string $group 分组字段名
+ * @param integer $flag 时间类别(1:天,2:月,3:周)
+ * @return array 详细数据
+ * @author 鹿文学
+ */
+ public function totalPlayerByTime($start, $end, $fieldname = 'count', $group = 'time', $flag = 1, $order = 'time')
+ {
- $deposit_data = M('deposit','tab_')->field('FROM_UNIXTIME(create_time,"'.$dateform.'") as '.$group.',GROUP_CONCAT( DISTINCT user_id) as user_id')
- ->where($map)->group($group)->select(false);
+ switch ($flag) {
+ case 2:
+ {
+ $dateform = '%Y-%m';
+ };
+ break;
+ case 3:
+ {
+ $dateform = '%Y-%u';
+ };
+ break;
+ case 4:
+ {
+ $dateform = '%Y';
+ };
+ break;
+ case 5:
+ {
+ $dateform = '%Y-%m-%d %H';
+ };
+ break;
+ default:
+ $dateform = '%Y-%m-%d';
+ }
- $map['pay_way'] = array('gt',0);
- unset($map['create_time']);
- $map['pay_time'] = ['between',[$start,$end]];
+ $map['pay_status'] = 1;
- $lists = $this->field('FROM_UNIXTIME(pay_time,"'.$dateform.'") as '.$group.',GROUP_CONCAT( DISTINCT user_id) as user_id')
+ $map['create_time'] = ['between', [$start, $end]];
- ->union(' ('.$bindrecharge_data.') ')->union(' ('.$deposit_data.') ')
+ $bindrecharge_data = M('bind_recharge', 'tab_')->field('FROM_UNIXTIME(create_time,"' . $dateform . '") as ' . $group . ',GROUP_CONCAT( DISTINCT user_id) as user_id')
+ ->where($map)->group($group)->select(false);
- ->where($map)->group($group)->select(false);
+ $deposit_data = M('deposit', 'tab_')->field('FROM_UNIXTIME(create_time,"' . $dateform . '") as ' . $group . ',GROUP_CONCAT( DISTINCT user_id) as user_id')
+ ->where($map)->group($group)->select(false);
- $lists = $this->field('a.'.$group.',GROUP_CONCAT(a.user_id) as user_id')->table(' ('.$lists.') as a')->group('a.'.$group)->order('a.'.$order)->select();
+ $map['pay_way'] = array('gt', 0);
+ unset($map['create_time']);
+ $map['pay_time'] = ['between', [$start, $end]];
- $data = [];
+ $lists = $this->field('FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',GROUP_CONCAT( DISTINCT user_id) as user_id')
+ ->union(' (' . $bindrecharge_data . ') ')->union(' (' . $deposit_data . ') ')
+ ->where($map)->group($group)->select(false);
- foreach($lists as $k=>$v) {
- $userid = array_unique(explode(',',$v['user_id']));
- $data[$k] = array(
- $group => $v[$group],
- $fieldname=>count($userid),
- );
- }
+ $lists = $this->field('a.' . $group . ',GROUP_CONCAT(a.user_id) as user_id')->table(' (' . $lists . ') as a')->group('a.' . $group)->order('a.' . $order)->select();
- return $data;
+ $data = [];
- }
+ foreach ($lists as $k => $v) {
+ $userid = array_unique(explode(',', $v['user_id']));
+ $data[$k] = array(
+ $group => $v[$group],
+ $fieldname => count($userid),
+ );
+ }
- /*
- * 付费用户总数
- * @param array $map 条件数组
- * @author 鹿文学
- */
- public function player($map=array()) {
+ return $data;
- $map['pay_status']=1;
+ }
- $data = $this->field('count( DISTINCT user_id) as count')
+ /*
+ * 付费用户总数
+ * @param array $map 条件数组
+ * @author 鹿文学
+ */
+ public function player($map = array())
+ {
- ->where($map)->select();
+ $map['pay_status'] = 1;
- return $data[0]?$data[0]['count']:0;
+ $data = $this->field('count( DISTINCT user_id) as count')
+ ->where($map)->select();
- }
+ return $data[0] ? $data[0]['count'] : 0;
- /*
- * 付费总数
- * @param array $map 条件数组
- * @author 鹿文学
- */
- public function amount($map=array()) {
+ }
- $map['pay_status'] = 1;
+ /*
+ * 付费总数
+ * @param array $map 条件数组
+ * @author 鹿文学
+ */
+ public function amount($map = array())
+ {
- $data = $this
+ $map['pay_status'] = 1;
- ->where($map)->sum('pay_amount');
+ $data = $this
+ ->where($map)->sum('pay_amount');
- return $data?$data:0;
- }
+ return $data ? $data : 0;
+ }
/**
* 列表
@@ -701,51 +776,53 @@ protected function _after_select(&$result,$options){
*
* @return mixed
*
- * @author: 鹿文学[lwx]
- * @since: 2019\4\11 0011 13:40
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
+ * @author: 鹿文学[lwx]
+ * @since: 2019\4\11 0011 13:40
*/
- public function lists($p=1, $map=array(), $order, $field=true)
+ public function lists($p = 1, $map = array(), $order, $field = true)
{
- $page = intval($p);
- $page = $page ? $page : 1; //默认显示第一页数据
- if(isset($_REQUEST['row'])) {
+ $page = intval($p);
+ $page = $page ? $page : 1; //默认显示第一页数据
+ if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
- $list = $this
- ->where($map)
- ->page($page, $row)
- ->order($order?$order:'pay_time desc')
- ->select();
+ $list = $this
+ ->where($map)
+ ->page($page, $row)
+ ->order($order ? $order : 'pay_time desc')
+ ->select();
$count = $this->where($map)->count();
$data['data'] = $list;
- $page = set_pagination($count,$row);
- if($page) {
- $data['page']=$page;
+ $page = set_pagination($count, $row);
+ if ($page) {
+ $data['page'] = $page;
}
return $data;
- }
+ }
/**
* 获取统计 $map,$page,$row
*/
- public function getSpendData($map=[],$field='',$group='',$order='',$page = 0,$row = 0) {
+ public function getSpendData($map = [], $field = '', $group = '', $order = '', $page = 0, $row = 0)
+ {
if ($row == 0) {
$data = $this->field($field)->where($map)->group($group)->order($order)->select();
} else {
- $data = $this->field($field)->where($map)->page($page,$row)->group($group)->order($order)->select();
+ $data = $this->field($field)->where($map)->page($page, $row)->group($group)->order($order)->select();
}
return $data;
}
- public function sumSpend($map=[],$field='') {
+ public function sumSpend($map = [], $field = '')
+ {
$sum = $this->where($map)->sum($field);
return $sum;
|