master
chenzhi 5 years ago
parent 6c45b4dd3f
commit 81192f36c8

@ -23,10 +23,10 @@ class SpendCountSetController extends \Think\Controller
$this->model =M("spend_count",'tab_');
$this->usermodel =M("spend_user_count",'tab_');
$this->monthmodel =M("spend_month_count",'tab_');
$this->gamemodel =M("spend_count",'tab_');
}
/**
* TODO:仅供测试,测试结束后删除
* 更新某月数据
*/
public function setMonthSpendCount()
@ -242,6 +242,69 @@ class SpendCountSetController extends \Think\Controller
}
}
}
public function createGameCount($type)
{
$map = array(
"pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"spend.pay_status"=>1,
"pay_way"=> array("LT",0)
);
if($type == "cash_count"){
//现金统计
$map['pay_way'] = array("GT",0);
}
$field = "IFNULL(game.partner_id,0) partner_id,partner.partner partner_name,
spend.promote_id,spend.promote_account,spend.game_id,spend.game_name,sum(pay_amount) {$type},
IFNULL(promote.level,0) level,promote.chain,
'{$this->date}' as count_date,'{$this->nowdata}' as create_time";
$spendRes = M()
->table("tab_spend spend")
->field($field)
->where($map)
->join("tab_promote promote ON spend.promote_id = promote.id","left")
->join("tab_game game ON spend.game_id = game.id","left")
->join("tab_partner partner ON partner.id = game.partner_id","left")
->group('spend.promote_id,spend.game_id')
->select();
if(empty($spendRes)){
return ;
}
//集中两个表
if($type == "cash_count"){
$dbres = $this->gamemodel->addAll($spendRes);
if(!$dbres){
$this->model->rollback();
die("error");
}
}else{
for ($i=0; $i < count($spendRes); $i++) {
# code...
$tempmap = array(
"game_id"=>$spendRes[$i]['game_id'],
"promote_id"=>$spendRes[$i]['promote_id'],
"count_date"=>$this->date
);
$dbres = $this->gamemodel->where($tempmap)->find();
if(!$dbres){
//不存在
$tempdbres = $this->gamemodel->add($spendRes[$i]);
if(!$tempdbres){
$this->model->rollback();
die("error");
}
}else{
$dbres["inside_cash_count"] = $balanceRes[$i]['inside_cash_count'];
$tempdbres = $this->model->save($dbres);
if(!$tempdbres){
$this->model->rollback();
die("error");
}
}
}
}
# code...
}
protected function getRoot()
{

@ -254,3 +254,48 @@ MODIFY COLUMN `name` char(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT N
ALTER TABLE `tab_spend_month_count`
MODIFY COLUMN `balance_coin_count` decimal(10,2) NULL DEFAULT 0.00 COMMENT '平台币游戏支付流水' AFTER `cash_count`,
ADD COLUMN `balance_coin_deposit` decimal(10,2) NULL DEFAULT 0.00 COMMENT '平台币充值流水' AFTER `balance_coin_count`;
DROP TABLE IF EXISTS `tab_spend_count`;
CREATE TABLE `tab_spend_count` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
`promote_account` varchar(30) DEFAULT '' COMMENT '推广员账号',
`chain` varchar(255) NOT NULL DEFAULT '' COMMENT '推广员链路',
`level` tinyint(1) NOT NULL DEFAULT '0' COMMENT '推广员级别',
`game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id',
`game_name` varchar(30) DEFAULT '' COMMENT '游戏名称',
`partner_id` int(11) DEFAULT '0' COMMENT '合作方id',
`partner_name` varchar(50) DEFAULT NULL COMMENT '合作方名称',
`cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '现金流水',
`balance_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '平台币流水',
`inside_cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '内充流水/绑定币流水',
`count_date` varchar(30) DEFAULT '' COMMENT '统计月份',
`create_time` int(11) DEFAULT NULL COMMENT '添加时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `game_id` (`game_id`) USING BTREE,
KEY `promote_id` (`promote_id`) USING BTREE,
KEY `partner_id` (`partner_id`) USING BTREE,
KEY `chain` (`chain`) USING BTREE,
KEY `level` (`level`) USING BTREE,
KEY `count_date` (`count_date`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='游戏流水聚合表';
DROP TABLE IF EXISTS `tab_spend_user_count`;
CREATE TABLE `tab_spend_user_count` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
`promote_account` varchar(30) DEFAULT '' COMMENT '推广员账号',
`chain` varchar(255) NOT NULL DEFAULT '' COMMENT '推广员链路',
`level` tinyint(1) NOT NULL DEFAULT '0' COMMENT '推广员级别',
`cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '现金流水',
`balance_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '平台币流水',
`inside_cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '内充流水',
`all_count` decimal(10,2) DEFAULT '0.00' COMMENT '流水和',
`count_date` varchar(30) DEFAULT '' COMMENT '统计月份',
`create_time` int(11) DEFAULT NULL COMMENT '添加时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `promote_id` (`promote_id`) USING BTREE,
KEY `chain` (`chain`) USING BTREE,
KEY `level` (`level`) USING BTREE,
KEY `count_date` (`count_date`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='流水角色聚合表';
Loading…
Cancel
Save