You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

869 lines
28 KiB
PHTML

5 years ago
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: huajie <banhuajie@163.com>
// +----------------------------------------------------------------------
namespace Admin\Model;
5 years ago
use Common\Api\GameApi;
use Org\WeixinSDK\Weixin;
use Think\Model;
/**
* 文档基础模型
*/
class SpendModel extends Model
{
5 years ago
/* 自动验证规则 */
protected $_validate = array();
/* 自动完成规则 */
protected $_auto = array(
array('pay_time', 'getCreateTime', self::MODEL_INSERT, 'callback'),
array('pay_status', 0, self::MODEL_INSERT),
array('order_number', '', self::MODEL_INSERT),
5 years ago
);
protected function _after_select(&$result, $options)
{
foreach ($result as $key => $value) {
// $result[$key]['pay_way'] = date('Y-m-d ', $value['time']);
}
}
5 years ago
/**
* 构造函数
* @param string $name 模型名称
* @param string $tablePrefix 表前缀
* @param mixed $connection 数据库连接信息
*/
public function __construct($name = '', $tablePrefix = '', $connection = '')
{
5 years ago
/* 设置默认的表前缀 */
$this->tablePrefix = 'tab_';
5 years ago
/* 执行构造方法 */
parent::__construct($name, $tablePrefix, $connection);
}
/**
* 创建时间不写则取当前时间
* @return int 时间戳
* @author huajie <banhuajie@163.com>
*/
protected function getCreateTime()
{
$create_time = I('post.create_time');
return $create_time ? strtotime($create_time) : NOW_TIME;
5 years ago
}
public function amdin_account()
{
return session('user_auth.username');
5 years ago
}
public function totalSpendTimes($map = "")
{
5 years ago
$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")
->where($map)
->find();
return $data['count'];
}
5 years ago
/**
* [dealPage 页码处理]
* @param [type] $p [description]
* @return [type] [description]
*/
public function dealPage($p)
{
5 years ago
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
return $page;
}
5 years ago
/**
* 自动补单
*/
public static function auto_repair()
{
5 years ago
$game = new GameApi();
$map['pay_status'] = 1;
5 years ago
$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);
5 years ago
}
$success_num = $error_num = 0;
foreach ($order as $key => $val) {
5 years ago
$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');
5 years ago
}
if ($result == "success") {
5 years ago
$success_num++;
} else {
5 years ago
$error_num++;
}
}
$time = time_format0();
\Think\Log::record("自动补单({$time}:成功 {$success_num} 个,失败:{$error_num}个");
}
/**
* 退款接口
* @param $map
*/
public function Refund($map, $order, $sign)
5 years ago
{
if (md5("mcaseqwezdsi" . $order) !== $sign) {
return false;
5 years ago
}
$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");
5 years ago
} else {
$order_number = $RefundRecord['order_number'];
$BatchNo = $RefundRecord['batch_no'];
5 years ago
$find = $RefundRecord;
}
if ($find['pay_way'] == 1) {
//页面上通过表单选择在线支付类型支付宝为alipay 财付通为tenpay
$pay = new \Think\Pay('alipay', C('alipay'));
$vo = new \Think\Pay\PayVo();
$detail_data = $find['order_number'] . "^" . $find['pay_amount'] . "^调单";
$find['batch_no'] = $BatchNo;
5 years ago
$vo->setOrderNo($find['order_number'])
->setService("refund_fastpay_by_platform_pwd")
->setSignType("MD5")
->setPayMethod("refund")
->setTable("RefundRecord")
->setBatchNo($BatchNo)
->setDetailData($detail_data);
$this->add_refund_record($find, $find['order_number']);
$this->where($map)->delete();
return $pay->buildRequestForm($vo);
} elseif ($find['pay_way'] == 3) {
$weixn = new Weixin();
$res = json_decode($weixn->weixin_Refund_pub($find['pay_order_number'], $order_number, $find['pay_amount'], $find['pay_amount'], C('wei_xin_app.partner')), true);
$this->add_refund_record($find, $order_number);
$this->where($map)->delete();
if ($res['status'] == 1) {
return $res['status'];
} else {
return $res;
}
} elseif ($find['pay_way'] == 4) {
$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')
5 years ago
->setSignType("MD5")
->setPayMethod("refund")
->setTable("RefundRecord")
->setOrderNo($find['pay_order_number'])
->setBatchNo($order_number)
->setFee($find['pay_amount']);
$this->add_refund_record($find, $order_number);
$this->where($map)->delete();
$res = $pay->buildRequestForm($vo);
5 years ago
if ($res['status'] == 0) {
return $res['status'];
} else {
return false;
}
} 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();
5 years ago
return true;
}
}
/**
* 添加退款记录
* @param $data
* @return mixed
*/
public function add_refund_record($data, $order_number)
{
$RefundRecord = M('RefundRecord', 'tab_');
unset($data['id']);
$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) {
5 years ago
$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 {
5 years ago
return true;
}
} else {
if ($data['pay_way'] == 0) {
$data['tui_status'] = 1;
$data['tui_time'] = time();
$savv['sub_status'] = 1;
$savv['settle_check'] = 1;
5 years ago
$this->where($map)->save($savv);
} elseif ($data['pay_way'] == 4 || $data['pay_way'] == 3) {
5 years ago
$data['tui_status'] = 2;
}
$data['create_time'] = time();
$data['tui_amount'] = $data['pay_amount'];
$data['order_number'] = $order_number;
return $RefundRecord->add($data);
}
}
/**
* 微信退款查询接口
* @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' => '退款处理中'));
}
5 years ago
}
/**
* 威富通查询退款接口
* @param [type] $map [description]
* @return [type] [description]
*/
public function swiftpass_refund($orderNo)
{
5 years ago
$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->setOrderNo($orderNo)
->setService('unified.trade.refundquery')
->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' => '退款处理中'));
5 years ago
}
}
/**
* 开放平台 付费人数
* @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'];
5 years ago
}
/**
* 累计付费
* @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'];
5 years ago
}
/**
* 获取开放平台流水
* @param $map
* @param $develop_id
* author: xmy 280564871@qq.com
*/
public function getOpenSpend($map, $develop_id, $game_id)
{
5 years ago
// 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;
5 years ago
}
/**
* 付费玩家数
* @param $map
* @param $develop_id
* @return mixed
* author: xmy 280564871@qq.com
*/
public function getPayerNum($map, $develop_id, $game_id)
{
5 years ago
// 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;
5 years ago
}
/**
* 新增付费玩家
* @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')
5 years ago
WHERE d.time BETWEEN '{$start}' and '{$end}' GROUP BY d.time";
$data = $this->query($sql);
return $data;
5 years ago
}
/**
* 累计付费玩家数(按天分组)
* @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;
5 years ago
}
/**
* 累计流水
* @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;
}
5 years ago
/*
* 游戏充值未到账列表
* @return array 结果集
* @author 鹿文学
*/
public function checkSpend()
{
5 years ago
$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]) {
5 years ago
$list = D('check')->dealWithCheckList($type, $list);
5 years ago
if (empty($list[0])) {
return '';
}
5 years ago
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 '';
}
5 years ago
}
5 years ago
/*
* 游戏补单列表
* @return array 结果集
* @author 鹿文学
*/
public function checkSupplement()
{
5 years ago
$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]) {
5 years ago
$list = D('check')->dealWithCheckList($type, $list);
5 years ago
if (empty($list[0])) {
return '';
}
5 years ago
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 '';
}
5 years ago
}
5 years ago
/**
* 统计总流水
* @param array $where 条件数组
* @return integer 数量
* @author 鹿文学
*/
public function totalAmount($map = array())
{
5 years ago
$map['pay_status'] = 1;
5 years ago
$sum = $this->where($map)->sum('pay_amount');
5 years ago
return $sum ? $sum : 0;
5 years ago
}
5 years ago
/**
* 分组统计流水
* @param array $map 条件数组
* @param string $fieldname 字段别名
* @param string $group 分组字段名
* @param integer $flag 时间类别123
* @return array 详细数据
* @author 鹿文学
*/
public function totalAmountByGroup($map = array(), $fieldname = 'amount', $group = 'time', $flag = 1, $order = 'time')
{
5 years ago
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';
}
5 years ago
$map['pay_status'] = 1;
5 years ago
$data = $this->field('FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',sum(pay_amount) as ' . $fieldname)
->where($map)->group($group)->order($order)->select();
5 years ago
return $data;
}
5 years ago
/**
* 分组统计所有流水
* @param array $map 条件数组
* @param string $fieldname 字段别名
* @param string $group 分组字段名
* @param integer $flag 时间类别123
* @return array 详细数据
* @author 鹿文学
*/
public function allAmountByGroup($map = array(), $fieldname = 'amount', $group = 'time', $flag = 1, $order = 'time')
{
5 years ago
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';
}
5 years ago
$map['pay_status'] = 1;
5 years ago
$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);
5 years ago
$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);
5 years ago
$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);
5 years ago
$data = $this->table('(' . $sql . ') as a')->field('a.' . $group . ',sum(a.' . $fieldname . ') as ' . $fieldname)->group('a.' . $group)->order($order)->select();
5 years ago
return $data;
}
5 years ago
/*
* 付费用户
* @param array $map 条件数组
* @param string $fieldname 字段别名
* @param string $group 分组字段名
* @param integer $flag 时间类别123
* @return array 详细数据
* @author 鹿文学
*/
public function totalPlayerByGroup($map = array(), $fieldname = 'count', $group = 'time', $flag = 1, $order = 'time')
{
5 years ago
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';
}
5 years ago
$map['pay_status'] = 1;
5 years ago
$data = $this->field('FROM_UNIXTIME(pay_time,"' . $dateform . '") as ' . $group . ',count( DISTINCT user_id) as ' . $fieldname)
->where($map)->group($group)->order($order)->select();
5 years ago
return $data;
5 years ago
}
5 years ago
/*
* 付费用户
* @param integer $start 开始时间戳
* @param integer $end 结束时间戳
* @param string $fieldname 字段别名
* @param string $group 分组字段名
* @param integer $flag 时间类别123
* @return array 详细数据
* @author 鹿文学
*/
public function totalPlayerByTime($start, $end, $fieldname = 'count', $group = 'time', $flag = 1, $order = 'time')
{
5 years ago
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';
}
5 years ago
$map['pay_status'] = 1;
5 years ago
$map['create_time'] = ['between', [$start, $end]];
5 years ago
$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);
5 years ago
$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);
5 years ago
$map['pay_way'] = array('gt', 0);
unset($map['create_time']);
$map['pay_time'] = ['between', [$start, $end]];
5 years ago
$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);
5 years ago
$lists = $this->field('a.' . $group . ',GROUP_CONCAT(a.user_id) as user_id')->table(' (' . $lists . ') as a')->group('a.' . $group)->order('a.' . $order)->select();
5 years ago
$data = [];
5 years ago
foreach ($lists as $k => $v) {
$userid = array_unique(explode(',', $v['user_id']));
$data[$k] = array(
$group => $v[$group],
$fieldname => count($userid),
);
}
5 years ago
return $data;
5 years ago
}
5 years ago
/*
* 付费用户总数
* @param array $map 条件数组
* @author 鹿文学
*/
public function player($map = array())
{
5 years ago
$map['pay_status'] = 1;
5 years ago
$data = $this->field('count( DISTINCT user_id) as count')
->where($map)->select();
5 years ago
return $data[0] ? $data[0]['count'] : 0;
5 years ago
}
5 years ago
/*
* 付费总数
* @param array $map 条件数组
* @author 鹿文学
*/
public function amount($map = array())
{
5 years ago
$map['pay_status'] = 1;
5 years ago
$data = $this
->where($map)->sum('pay_amount');
5 years ago
return $data ? $data : 0;
}
5 years ago
/**
* 列表
*
* @param int $p
* @param array $map
* @param bool $field
*
* @return mixed
*
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author: 鹿文学[lwx]<fyj301415926@126.com>
* @since: 2019\4\11 0011 13:40
5 years ago
*/
public function lists($p = 1, $map = array(), $order, $field = true)
5 years ago
{
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
if (isset($_REQUEST['row'])) {
5 years ago
$row = $_REQUEST['row'];
} else {
$row = 10;
}
$list = $this
->where($map)
->page($page, $row)
->order($order ? $order : 'pay_time desc')
->select();
$count = $this->where($map)->count();
5 years ago
$data['data'] = $list;
$page = set_pagination($count, $row);
if ($page) {
$data['page'] = $page;
5 years ago
}
return $data;
}
5 years ago
/**
* 获取统计 $map,$page,$row
*/
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();
}
return $data;
}
public function sumSpend($map = [], $field = '')
{
$sum = $this->where($map)->sum($field);
5 years ago
return $sum;
}
5 years ago
5 years ago
/**
*获取游戏统计列表数据
*/
public function gameStatistics($map)
{
$data = $this->alias("s")
->field("s.game_id,s.game_name,p.partner as partner_name,SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count")
->join('LEFT JOIN tab_game as g ON s.game_id=g.id')
->join('LEFT JOIN tab_partner as p ON g.partner_id=p.id')
->where(['s.pay_status' => 1])
->where($map)
->group('s.game_id')
->select();
return $data;
}
5 years ago
/**
*获取游戏统计列表数据
*/
public function totalGameStatistics($map)
{
$data = $this->alias("s")
->field("SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count")
->join('LEFT JOIN tab_game as g ON s.game_id=g.id')
->join('LEFT JOIN tab_partner as p ON g.partner_id=p.id')
->where(['s.pay_status' => 1])
->where($map)
->find();
return $data;
}
5 years ago
5 years ago
}