Merge pull request '游戏返利' (#408) from feature/game_rebate into release

Reviewed-on: http://8.136.139.249:3000/wmtx/platform/pulls/408
master
廖金灵 4 years ago
commit 083c7710e4

@ -1264,6 +1264,13 @@ class CompanyStatementPoolController extends ThinkController
$v['company_info'] = json_decode($v['company_info'],true);
$v['statement_begin_time'] = date('Y.m.d',$v['statement_begin_time']);
$v['statement_end_time'] = date('Y.m.d',$v['statement_end_time']);
if($is_export){
$v['remark'] = str_replace(";","\n",$v['remark']);
}else{
$v['remark'] = str_replace(";","<br>",$v['remark']);
}
if( isset($v['verify_status'])){
if( $v['verify_status'] ==2 ){
$v['is_payment'] = 2; //不打款

@ -307,7 +307,7 @@ class CompanyStatementSetController extends Controller {
$game['pay_amount'] =$va['pay_money'];
$game['game_name'] =$ke;
//获取游戏id及比例
$game_id = $GameDb->where("relation_game_name='{$ke}' OR original_package_name='{$ke}'")->field("id,relation_game_id")->find();
$game_id = $GameDb->where("(relation_game_name='{$ke}' OR original_package_name='{$ke}') and partner_id = '{$add_data['company_id']}'")->field("id,relation_game_id")->find();
if (empty($game_id) && isset($va['unique_code']) && !empty($va['unique_code'])) {
$unique_code = $va['unique_code'];
$game_id = $GameDb->where("unique_code='{$unique_code }'")->field("id,relation_game_id")->find();

@ -4,6 +4,7 @@
*/
namespace Admin\Controller;
use Admin\Model\SpendModel;
use Base\Service\GameRebateService;
use Think\Think;
use Base\Tool\Printer;
use Base\Tool\TaskClient;
@ -114,4 +115,18 @@ class GameApiController extends Think {
$result = $gameResource->apply($order, $role);
var_dump($result);
}
public function rebateSend()
{
$service = new GameRebateService();
$service->sendAll('A');
$service->sendAll('B');
$service->sendAll('C');
}
public function rebateSendDaily()
{
$service = new GameRebateService();
$service->sendDaily(date('Y-m-d'));
}
}

@ -373,12 +373,14 @@ class GameMarginSetController extends Controller {
}else{
$ratio = $val['second_ratio'];
}
$statement_money = round( $this->adddata[$game]['pay_amount'] / $val['pay_amount'] * $val['sum_money'],2);
if( array_key_exists("cp_statement_amount",$this->adddata[$game]) ){
$this->adddata[$game]['cp_statement_amount'] += $statement_money;
}else{
$this->adddata[$game]['cp_statement_amount'] = $statement_money;
}
$this->adddata[$game]['cp_promote_ratio'] = $val['promote_ratio'];
$this->adddata[$game]['cp_ratio'] = $ratio;
}
@ -391,7 +393,7 @@ class GameMarginSetController extends Controller {
{
$where = [
"partner_id"=>$company_id,
"_string"=>"original_package_name = '{$OPName}' OR relation_game_name = '{$OPName}'"
"_string"=>"( original_package_name = '{$OPName}' AND select_package_name = 0 ) OR ( relation_game_name = '{$OPName}' AND select_package_name = 1 )"
];
$game = M("Game","tab_")->field("relation_game_name")->where($where)->group("relation_game_name")->select();
if($game){

@ -0,0 +1,183 @@
<?php
namespace Admin\Controller;
use Base\Repository\GameRepository;
use Base\Service\GameRebateService;
use User\Api\UserApi as UserApi;
use Base\Service\PresidentDepositService;
/**
* 游戏返利
*/
class GameRebateController extends ThinkController
{
public function single()
{
$this->records('A');
}
public function accumulative()
{
$this->records('C');
}
public function daily()
{
$this->records('B');
}
public function records($awardType)
{
$page = I('p', 1);
$row = I('row', 10);
$baseGameId = I('base_game_id', 0);
$serverId = I('server_id', '');
$roleName = I('role_name', '');
$userAccount = I('user_account', '');
$reviewStatus = I('review_status', -1);
$sendStatus = I('send_status', -1);
$reviewerId = I('reviewer_id', 0);
$where = [
'_string' => '1=1',
];
$where['type'] = $awardType;
if ($baseGameId != 0) {
$where['base_game_id'] = $baseGameId;
}
if ($userAccount != '') {
$where['user_account'] = ['like', $userAccount . '%'];
}
if ($roleName != '') {
$where['role_name'] = ['like', $roleName . '%'];
}
if ($serverId != '') {
$where['server_id'] = $serverId;
}
if ($reviewStatus != -1) {
$where['review_status'] = $reviewStatus;
}
if ($sendStatus != -1) {
$where['send_status'] = $sendStatus;
}
if ($reviewerId != 0) {
$where['reviewer_id'] = $reviewerId;
}
if (I('send_time_start', '') != '') {
$where['_string'] .= ' and send_time>=' . strtotime(I('send_time_start') . ' 00:00:00');
}
if (I('send_time_end', '') != '') {
$where['_string'] .= ' and send_time<=' . strtotime(I('send_time_end') . ' 23:59:59');
}
$query = M('rebate_orders', 'tab_')->where($where);
$records = [];
if (I('export', 0) == 1 || $row == 'all') {
$records = $query->select();
} else {
$countQuery = clone $query;
$records = $query->page($page, $row)->select();
$count = $countQuery->count();
}
$sendStatusList = [
0 => '待发放',
1 => '发放成功',
2 => '发放异常',
];
$reviewStatusList = [
0 => '待审核',
1 => '审核通过',
2 => '审核拒绝',
];
$pageTitles = [
'A' => '单笔充值福利',
'B' => '月卡福利发放',
'C' => '累充福利发放',
];
$pageTitle = $pageTitles[$awardType];
if (count($records) > 0) {
foreach ($records as $key => $record) {
$records[$key]['review_status_text'] = $reviewStatusList[$record['review_status']];
$records[$key]['review_time'] = $record['review_time'] > 0 ? date('Y-m-d H:i:s', $record['review_time']) : '--';
$records[$key]['send_status_text'] = $sendStatusList[$record['send_status']];
$records[$key]['send_time'] = $record['send_time'] > 0 ? date('Y-m-d H:i:s', $record['send_time']) : '--';
$records[$key]['award_date_range'] = is_null($record['award_started_at']) || is_null($record['award_ended_at'])
? '' : $record['award_started_at'] . ' ~ ' . $record['award_ended_at'];
$records[$key]['gift_content'] = implode('<br/>', explode('|', $record['gift_content']));
}
if (I('export', 0) == 1) {
$field = [
'base_game_name' => '游戏名称',
'server_name' => '区服',
'user_account' => '账号',
'role_id' => '角色ID',
'role_name' => '角色名称',
'pay_amount' => '充值金额',
'gift_content' => '奖励内容',
'review_status_text' => '审核状态',
'review_time' => '审核时间',
'send_status_text' => '发放状态',
'send_time' => '发放时间',
'reviewer_username' => '审核人',
];
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出' . $pageTitle . '记录','url'=>U('GameRebate/records'),'menu'=>'推广员-发放福利管理-' . '导出' . $pageTitle . '记录']);
data2csv($records, $pageTitle, $field);
exit;
}
}
$page = set_pagination($count, $row == 'all' ? 99999999 : $row);
if($page) {
$this->assign('_page', $page);
}
$admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->select();
$baseGames = M('base_game', 'tab_')->select();
$gameRepository = new GameRepository();
$this->assign('pageTitle', $pageTitle);
$this->assign('awardType', $awardType);
$this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId));
$this->assign('admins', $admins);
$this->assign('baseGames', $baseGames);
$this->assign('sendStatusList', $sendStatusList);
$this->assign('reviewStatusList', $reviewStatusList);
$this->assign('records', $records);
$this->display('records');
}
public function review()
{
$ids = I('ids', []);
$status = I('status', 0);
try {
$service = new GameRebateService();
$service->review($ids, $status);
$this->ajaxReturn([
'status' => 1,
'message' => '操作成功'
]);
} catch (\Exception $e) {
$this->ajaxReturn([
'status' => 0,
'message' => $e->getMessage()
]);
}
}
public function getServers()
{
$gameId = I('game_id', 0);
$gameRepository = new GameRepository();
$servers = $gameRepository->getServersByBaseGameId($gameId);
return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]);
}
}

@ -122,9 +122,10 @@ class MarketPercentageController extends ThinkController
// var_dump($map);die();
$data = SM("settleup_marketorder", "tab_")
->field("pay_time,promote_account,company_name,company_belong,real_name,develop_type,game_name,
->field("id,pay_time,promote_account,company_name,company_belong,real_name,develop_type,game_name,
sum(pay_amount) pay_amount,sum(cp_amount) cp_amount,sum(promote_amount) promote_amount,
sum(channel_amount) channel_amount, sum(company_tax) company_tax,sum(company_profit) company_profit");
sum(channel_amount) channel_amount, sum(company_tax) company_tax,sum(company_profit) company_profit,
other_amount,refund_amount");
if ($_REQUEST['export']) {
$data = $data->where($map)
@ -142,7 +143,8 @@ class MarketPercentageController extends ThinkController
$sum = SM("settleup_marketorder", "tab_")
->field("pay_time,promote_account,company_belong,real_name,develop_type,game_name,
sum(pay_amount) pay_amount,sum(cp_amount) cp_amount,sum(promote_amount) promote_amount,
sum(channel_amount) channel_amount, sum(company_tax) company_tax,sum(company_profit) company_profit")
sum(channel_amount) channel_amount, sum(company_tax) company_tax,sum(company_profit) company_profit,
sum(other_amount) other_amount,sum(refund_amount) refund_amount")
->where($map)
->find();
@ -181,9 +183,11 @@ class MarketPercentageController extends ThinkController
'develop_type' => '类型',
'game_name' => '游戏名称',
'pay_amount' => '总流水',
'cp_amount' => '上游结算流水',
'promote_amount' => '下游结算流水',
'cp_amount' => '上游结算',
'promote_amount' => '下游结算',
'channel_amount' => '支付渠道费用',
'refund_amount'=>'退款金额',
'other_amount'=>'返点及其他',
'company_tax' => '公司税费',
'company_profit' => '税后毛利额'];
@ -221,6 +225,22 @@ class MarketPercentageController extends ThinkController
$this->display();
}
public function otherAmountEdit()
{
if(!array_key_exists('id',$_REQUEST) || !array_key_exists('other_amount',$_REQUEST)){
$this->ajaxReturn(['status'=>0,'msg'=>'参数错误']);
}
$id = I("id");
$other_amount = I("other_amount");
$dbres = M("settleup_marketorder","tab_")->where("id = {$id}")->find();
$save = [
'id'=>$id,
'company_profit'=>$dbres['company_profit']-($other_amount-$dbres['other_amount']),
'other_amount'=>$other_amount
];
M("settleup_marketorder","tab_")->save($save);
$this->ajaxReturn(['status'=>1,'msg'=>'其他扣款添加成功']);
}
public function indexuncaculate($row = 10, $p = 1)
{
@ -1275,19 +1295,23 @@ class MarketPercentageController extends ThinkController
public function reCaculateBonus()
{
$pay_time = $_REQUEST['pay_time'];
if (!$pay_time) {
$pay_time = "all";
// $pay_time = date("Y-m",strtotime('-1 month'));
$type = $_REQUEST['type'];
if(empty($type)){
die('参数错误');
}
if($type == 1){
$action = "caculateMarketStream/time";
}else{
$action = "createMarketBonus/pay_time";
}
$pay_time = date( 'Y-m', strtotime( 'last day of -1 months' ) );
$params = "php ".SUBSITE_INDEX." Timing/{$action}/{$pay_time}";
$r = D("CmdTasks")->addTask("MarketPerformanceSet",$params);
if($r){
$this->ajaxReturn(["status"=>"1",'msg'=>"任务添加成功大约需等待5分钟后生成"]);
}else{
$this->ajaxReturn(["status"=>"0","msg"=>'任务添加失败']);
}
// var_dump("cd ".ROOTTT.";php admin.php timing/caculateMarketStream/time/{$pay_time} > /dev/null &");die();
exec("source /etc/profile;cd " . ROOTTT . ";php " . SUBSITE_INDEX . " timing/caculateMarketStream/time/{$pay_time} > /dev/null &");
$this->ajaxReturn(['status' => 1]);
}
public function showBonusList($row = 10, $p = 1)

@ -0,0 +1,475 @@
<?php
namespace Admin\Controller;
use Think\Controller;
/**
* 市场专员业绩
* @author cz
*
*/
class MarketPerformanceSetController extends Controller {
private $beginThismonth;
private $endThismonth;
private $date;
private $nowdata;
private $month;//月份
private $year;//年份
private $adddata;//要添加的数据
private $inSideCompanyIds;
private $downFlowData;
private $channelRatio;
private $gameInfo;
private $companyInfo;
private $settleupMarketorderModel;
private $taxRatio;
private $oldMarketPerformance;
/**
* 更新某月数据
*/
public function setFreeMonth($count_date)
{
//设置转换精度
ini_set('serialize_precision',14);
$month = $count_date;
if(empty($month)) die("参数错误");
$this->adddata = [];//置空否者会脚本进来会重复计算
$this->date = $month;
$tarry = explode('-',$month);
$this->year= $tarry[0];
if(strlen($tarry[1]) < 2) $tarry[1]="0".$tarry[1];
$this->month= $tarry[1];
$this->beginThismonth=mktime(0,0,0,$tarry[1],1,$tarry[0]);
$this->endThismonth=mktime(0,0,0,$tarry[1]-0+1,1,$tarry[0])-1;
$this->settleupMarketorderModel=SM("settleup_marketorder","tab_");
$this->reCount();
$this->setSettleupMarketorder();
}
/**
* 强制重新聚合
*/
private function reCount()
{
// $this->settleupMarketorderModel->where(['pay_time'=>$this->date])->delete();
echo "旧数据清理成功".PHP_EOL;
}
/**
* 计算公司毛利
*/
private function setSettleupMarketorder()
{
$this->setIsTipData();
$this->getInsideCompanyid();
$this->getChannelRatio();
$this->getTaxRatio();
$this->getAllDownFlowSpend();
$this->getAllGameInfo();
$this->getCompanyOtherInfo();
$this->getPuStatement();
$this->getPuSpecialStatement();
$this->performanceSet();
$this->settleupMarketorderDbSave();
echo "{$this->year}-{$this->month}生成成功".PHP_EOL;
}
/**
* 获取是否标红提示数据,旧数据比对
*/
private function setIsTipData()
{
$dbres = $this->settleupMarketorderModel->where(['pay_time'=>$this->date])->select();
if($dbres){
foreach ($dbres as $key => $v) {
$this->oldMarketPerformance[$v['company_id']][$v['game_name']]['company_profit'] = $v['company_profit'];
}
}else{
$this->oldMarketPerformance = false;
}
//取消所有提示
$this->settleupMarketorderModel->where("1=1")->save(["is_tip"=>0]);
}
/**
* 获取公司内部公司id
*/
private function getInsideCompanyid()
{
$res = M("PromoteCompany","tab_")->where("is_inside = 1")->field("id")->select();
if($res){
$res = array_column($res,"id");
$res[] = 0;
}else{
$res = [0];
}
$this->inSideCompanyIds = implode(",",$res);
}
/**
* 支付服务商渠道费
* TODO:当前默认除了绑定币其他渠道都1%
*/
private function getChannelRatio()
{
$res = M("payment_merchant","tab_")->getField("id,config",true);
foreach ($res as $k => $v) {
$res[$k] = 1;
//------begin------注释的部分表示按实际配置收取
// $config = json_decode($v,true);
// if(array_key_exists("channel_rate",$config) && $config['channel_rate'] > 0){
// $res[$k] = $config['channel_rate'];
// }else{
// $res[$k] = 0;
// }
//----------end------
}
$res[0] = 1;//平台币
$res[-1] = 0;//绑定币
$this->channelRatio = $res;
unset($res);
}
/**
* 获取公司税率
*/
private function getTaxRatio()
{
$where = [
"time"=>['ELT',$this->beginThismonth]
];
$tax_data = M("tax_radio","tab_")
->field("tax_radio")
->order("time desc")
->where($where)
->find();
if($tax_data){
$this->taxRatio = $tax_data['tax_radio'];
}else{
$this->taxRatio = 0;
}
}
/**
* 获取所有下游公司支付信息
*/
private function getAllDownFlowSpend()
{
$where = [
"pay_status"=>1,
"s.is_check"=>1,
"payed_time"=>["between",[$this->beginThismonth,$this->endThismonth]],
"p.company_id"=>["NOT IN",$this->inSideCompanyIds],
"p.company_belong"=>['GT',0]
];
$dbres = M("Spend","tab_")
->alias("s")
->field("substring_index(game_name, '(', 1) relation_game_name,
SUM(pay_amount) pay_amount,
IFNULL(SUM(CASE WHEN is_refund = 1 THEN pay_amount ELSE 0 END),0) as refund_amount,
p.company_id,p.company_belong,merchant_id")
->join("tab_promote as p on s.promote_id = p.id")
->where($where)
->group("relation_game_name,company_id,merchant_id")
->order("pay_amount desc")->select();
foreach ($dbres as $v) {
if(!array_key_exists($v['relation_game_name'],$this->downFlowData[$v['company_id']])){
$this->downFlowData[$v['company_id']][$v['relation_game_name']] = [
"cp_pay_amount"=>0,
"promote_pay_amount"=>0,
"pay_amount"=>0,
"channel_amount"=>0,
"refund_amount"=>0,
"special_amount"=>0,
"ratio"=>0
];
}
$channel_amount = round($v['pay_amount']*$this->channelRatio[$v['merchant_id']]/100,2);
$cp_amount = $v['pay_amount']-$v['refund_amount'];
$promote_amount = $v['pay_amount']-$v['refund_amount'];
$this->downFlowData[$v['company_id']][$v['relation_game_name']]['channel_amount'] += $channel_amount;
$this->downFlowData[$v['company_id']][$v['relation_game_name']]['cp_pay_amount'] += $cp_amount;
$this->downFlowData[$v['company_id']][$v['relation_game_name']]['promote_pay_amount'] += $promote_amount;
$this->downFlowData[$v['company_id']][$v['relation_game_name']]['pay_amount'] += $v['pay_amount'];
$this->downFlowData[$v['company_id']][$v['relation_game_name']]['refund_amount'] += $v['refund_amount'];
}
unset($dbres);
}
/**
* 获取游戏信息及cp结算比例
*/
private function getAllGameInfo()
{
$games=[];
foreach ( $this->downFlowData as $key => $value) {
$games = array_merge(array_keys($value),$games);
}
$games = array_unique($games);
//获取游戏信息
$gameRes = M("Game","tab_")->where(['relation_game_name'=>['in',$games]])->getField("relation_game_name,relation_game_id",TRUE);
foreach ($gameRes as $k => $v) {
$this->gameInfo[$k]['relation_game_id'] = $v;
$this->gameInfo[$k]['cp_ratio'] = 0;
}
$this->getCpStatement();
}
/**
* 获取公司信息及推广员账号,市场员信息
*/
private function getCompanyOtherInfo()
{
$companyIds = array_unique(array_keys($this->downFlowData));
$companyRes = M("promote_company","tab_")->alias("pc")
->join("tab_promote as p on p.company_id = pc.id")
->join("sys_member as m on p.admin_id = m.uid")
->where(['pc.id'=>['in',$companyIds],'p.level'=>1])
->group("pc.id")
->getField("pc.id company_id,pc.company_name,pc.company_belong,pc.develop_type,p.id promote_id,p.account promote_account,p.admin_id,m.real_name",TRUE);
$this->companyInfo = $companyRes;
}
/**
* 获取下游结算比例,以最后一周的结算比例为最终比例
*/
private function getPuStatement()
{
//1.获取下游周结结算单
$where = [
"_string"=>"statement_begin_time between {$this->beginThismonth} and {$this->endThismonth} OR statement_end_time between {$this->beginThismonth} and {$this->endThismonth}",
"company_type"=>2,
"withdraw_type"=>0
];
$statement_pool = M("company_statement_pool","tab_")->where($where)->order("statement_begin_time desc")->select();
//获取结算分段
$date_arr = [];
foreach ($statement_pool as $k => $v) {
$tem = [
"statement_begin_time"=>$v['statement_begin_time'],
"statement_end_time"=>$v['statement_end_time'],
"begin_time"=>date("Y.m.d",$v['statement_begin_time']),
"end_time"=>date("Y.m.d",$v['statement_end_time']),
"withdraw_type"=>0
];
if($v['statement_begin_time'] < $this->beginThismonth){
$tem['statement_begin_time'] = $this->beginThismonth;
$tem['begin_time'] = date("Y.m.d",$this->beginThismonth);
}
if($v['statement_end_time'] > $this->endThismonth){
$tem['statement_end_time'] = $this->endThismonth;
$tem['end_time'] = date("Y.m.d",$this->endThismonth);
}
$this->getPuAllStatement($tem,$v);
$this->getPuCompanyStatement($tem);//对公周结
$date_arr[] = $tem;
}
//2.获取对公的下游
$tem = [
"statement_begin_time"=>$this->beginThismonth,
"statement_end_time"=>$this->endThismonth,
"begin_time"=>date("Y.m.d",$this->beginThismonth),
"end_time"=>date("Y.m.d",$this->endThismonth),
"withdraw_type"=>1
];
$this->getPuCompanyStatement($tem);
}
/**
* 获取所有个人周结
*/
private function getPuAllStatement($time,$pool){
$id = $pool['id'];
//获取基本信息
$infolist = M("company_statement_info","tab_")->where("pool_id = '{$id}'")->select();
//获取母单
if(!empty($pool['create_lack_ids'])){
$l_ids = $pool['create_lack_ids'];
$lack_info = M("company_lack_statement_info","tab_")->where("id in ({$l_ids})")->select();
$infolist =array_merge($infolist,$lack_info);
}
foreach ($infolist as $v) {
$sinfo = json_decode($v['statement_info'],true);
foreach ($sinfo as $va) {
foreach ($va["game_list"] as $val) {
//奖罚不算
if( !array_key_exists($val['game_name'],$this->gameInfo) ){
continue;
}
//其他计算日期不算
if( ($val['statement_begin_time'] != $time['begin_time']) && ($val['statement_end_time'] != $time['end_time']) ){
continue;
}
if(!array_key_exists($val['game_name'],$this->downFlowData[$v['company_id']])){
continue;
}
if($this->downFlowData[$v['company_id']][$val['game_name']]["ratio"] == 0){
$this->downFlowData[$v['company_id']][$val['game_name']]["ratio"] = $val['ratio'];
}
}
}
}
}
/**
* 对公的下游结算
*/
private function getPuCompanyStatement($time)
{
$where = [
"company_belong"=>["NOT IN",[0,9]],
"withdraw_type"=>$time['withdraw_type']
];
if($time['recount']){
$where['_string'] = "statement_begin_time = {$time['statement_begin_time']} OR statement_end_time = {$time['statement_end_time']}";
}else{
$where['statement_begin_time'] = $time['statement_begin_time'];
$where['statement_end_time'] = $time['statement_end_time'];
}
$res = M("company_statement","tab_")->where($where)->select();
if($res){
foreach ($res as $v) {
$sinfo = json_decode($v['statement_info'],true);
foreach ($sinfo as $val) {
//奖罚不算
if( !array_key_exists($val['game_name'],$this->gameInfo) ){
continue;
}
//其他计算日期不算
if( ($val['statement_begin_time'] != $time['begin_time']) && ($val['statement_end_time'] != $time['end_time']) ){
continue;
}
if(!array_key_exists($val['game_name'],$this->downFlowData[$v['company_id']])){
continue;
}
if($this->downFlowData[$v['company_id']][$val['game_name']]["ratio"] == 0){
$this->downFlowData[$v['company_id']][$val['game_name']]["ratio"] = $val['ratio'];
}
}
}
}
}
/**
* 特殊补点
*/
private function getPuSpecialStatement()
{
$where = [
"company_belong"=>["NOT IN",[0,9]],
"withdraw_type"=>3,
"_string"=>"statement_begin_time >= {$this->beginThismonth} and statement_end_time <= {$this->endThismonth}"
];
$res = M("company_statement","tab_")->where($where)->select();
if($res){
foreach ($res as $v) {
$sinfo = json_decode($v['statement_info'],true);
foreach ($sinfo as $va) {
foreach ($va["game_list"] as $val) {
//奖罚不算
if( !array_key_exists($val['game_name'],$this->gameInfo) ){
continue;
}
$this->downFlowData[$v['company_id']][$val['game_name']]["special_amount"] += $val['sum_money'];
}
}
}
}
}
//获取cp结算单
private function getCpStatement()
{
$where = [
"company_belong"=>9,
"withdraw_type"=>1,
"statement_begin_time"=>$this->beginThismonth,
"statement_end_time"=>$this->endThismonth
];
$res = M("company_statement","tab_")->where($where)->select();
if($res){
foreach ($res as $v) {
$sinfo = json_decode($v['statement_info'],true);
foreach ($sinfo as $val) {
//获取真实游戏名
$games = $this->cpOPName2GName($val['game_name'],$v['company_id']);
foreach ($games as $game) {
if( !array_key_exists($game,$this->gameInfo) ){
continue;
}
if($v['pay_type'] == 1){
$ratio = $val['first_ratio'];
}else{
$ratio = $val['second_ratio'];
}
$this->gameInfo[$game]['cp_ratio'] = $ratio;
}
}
}
}
}
//结算包名还原游戏名
private function cpOPName2GName($OPName,$company_id)
{
$where = [
"partner_id"=>$company_id,
"_string"=>"original_package_name = '{$OPName}' OR relation_game_name = '{$OPName}'"
];
$game = M("Game","tab_")->field("relation_game_name")->where($where)->group("relation_game_name")->select();
if($game){
return array_column($game,"relation_game_name");
}else{
return [$OPName];
}
}
/**
* 计算相应数据
*/
private function performanceSet()
{
foreach ($this->downFlowData as $company_id => $games) {
$baseArr = $this->companyInfo[$company_id];
$baseArr['pay_time'] = $this->date;
$baseArr['is_settlement'] = 1;
foreach ($games as $k => $v) {
// if($company_id == 452){
// dd($v);
// }
$game = $this->gameInfo[$k];
$cp_ratio = $game['cp_ratio'];
$tempArr = $baseArr;
$tempArr['game_id'] = $game['relation_game_id'];
$tempArr['relation_game_id'] = $game['relation_game_id'];
$tempArr['game_name'] = $k;
$tempArr['pay_amount'] = $v['pay_amount'];
$tempArr['cp_amount'] = round($v['cp_pay_amount']*$cp_ratio/100,2);
$tempArr['promote_amount'] = round($v['promote_pay_amount']*$v['ratio']/100+$v['special_amount'],2);
$tempArr['channel_amount'] = $v['channel_amount'];
$tempArr['refund_amount'] = $v['refund_amount'];
$tempArr['company_tax'] = round( ($v['pay_amount']-$tempArr['cp_amount']-$tempArr['promote_amount']) * ($this->taxRatio / 100),2 );
$tempArr['company_profit'] = $tempArr['pay_amount']-$tempArr['cp_amount']-$tempArr['promote_amount']-$tempArr['channel_amount']-$tempArr['company_tax'];
$tempArr['is_tip'] = 0;
if($this->oldMarketPerformance){
if(!array_key_exists($company_id,$this->oldMarketPerformance) || !array_key_exists($k,$this->oldMarketPerformance[$company_id])){
$tempArr['is_tip'] = 1;
}else{
if($this->oldMarketPerformance[$company_id][$k]['company_profit'] != $tempArr['company_profit'].''){
$tempArr['is_tip'] = 1;
}
}
}
if($tempArr['promote_amount'] != 0){
$this->adddata[]= $tempArr;
}
}
}
}
/**
* 毛利数据库操作
*/
private function settleupMarketorderDbSave()
{
//删除旧数据
$this->settleupMarketorderModel->where(['pay_time'=>$this->date])->delete();
$this->settleupMarketorderModel->addAll($this->adddata);
}
}

@ -836,9 +836,17 @@ class TimingController extends AdminController {
return $spend;
}
//计算市场专员业绩公式 参数 time 2020-10
public function caculateMarketStream () {
if ($_REQUEST['time']) {
$count_date = $_REQUEST['time'];
}else{
$count_date = date('Y-m',strtotime(date('Y',time()).'-'.(date('m',time())-1).'-01'));
}
A("MarketPerformanceSet")->setFreeMonth($count_date);
$this->createMarketBonus($_REQUEST['time']);
die();
echo date("Y-m-d H:i:s")."----------------------市场结算管理计算----------------------\n";
$map['pay_time'] = date('Y-m',strtotime(date('Y',time()).'-'.(date('m',time())-1).'-01'));
@ -846,6 +854,7 @@ class TimingController extends AdminController {
if ($_REQUEST['time']) {
$map['pay_time'] = $_REQUEST['time'];
}
$spend_map = [];
$time_start = 0;
$time_end = 0;
@ -1349,6 +1358,7 @@ class TimingController extends AdminController {
->field("id,admin_id,pay_time,promote_account,company_belong,tab_settleup_marketorder.real_name,develop_type,game_name,
sum(pay_amount) pay_amount,sum(company_profit) company_profit,
sum(if((develop_type = 1 or develop_type = 2), pay_amount, 0)) performance_revenue,sum(if(develop_type = 3, pay_amount, 0)) appraisal_bonuses,
sum(if((develop_type = 1 or develop_type = 2), refund_amount, 0)) performance_refund_amount,sum(if(develop_type = 3, refund_amount, 0)) appraisal_refund_amount,
sum(company_tax) company_tax, sum(cp_amount) cp_amount,sum(promote_amount) promote_amount")
->where($map)
->where(["admin_id"=>['in',array_keys($accessData)]])
@ -1360,6 +1370,8 @@ class TimingController extends AdminController {
if(isset($accessData[$admin_id])){
$value = array_merge($value,$accessData[$admin_id]);
}
$value['performance_revenue'] -= $value['performance_refund_amount'];
$value['appraisal_bonuses'] -= $value['appraisal_refund_amount'];
$sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses'];

@ -0,0 +1,404 @@
<extend name="Public/base"/>
<block name="css">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" href="__CSS__/promote.css" type="text/css"/>
<script src="__STATIC__/laydate/laydate.js"></script>
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader/webuploader.css" media="all">
<style>
.select2-container--default .select2-selection--single {
color: #000;
resize: none;
border-width: 1px;
border-style: solid;
border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
box-shadow: 0px 3px 3px #F7F8F9 inset;height:35px;
height:28px;border-radius:3px;font-size:12px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height:35px;
line-height:28px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height:26px;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
height:26px;line-height:26px;font-size:12px;
}
.select2-results__option[aria-selected] {font-size:12px;}
.textarea-style {
width: 200px;
height: 80px;
border-radius: 5px;
padding: 5px;
}
.mustmark {
color: #FF0000;
font-style: normal;
margin: 0 3px;
}
.butnbox {
padding: 10px 0 10px;
}
.butnbox .butnlist .butn {
display: inline-block;
width: 120px;
height: 28px;
line-height: 28px;
text-align: center;
color: #FFF;
background: #3C95C8;
border-radius: 3px;
cursor: pointer;
}
.data_list table td .status-0 {
color: #e6a23c;
}
.data_list table td .status-1 {
color: #67c23a;
}
.data_list table td .status-2 {
color: #f56c6c;
}
</style>
</block>
<block name="body">
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<script type="text/javascript" src="__JS__/jquery.form.js"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script src="__STATIC__/md5.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="__STATIC__/webuploader/webuploader.js"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<div class="cf main-place top_nav_list navtab_list">
<?php if($awardType == 'A'):?>
<h3 class="page_title">单笔充值福利</h3>
<?php elseif($awardType == 'B'):?>
<h3 class="page_title">月卡福利发放</h3>
<?php elseif($awardType == 'C'):?>
<h3 class="page_title">累充福利发放</h3>
<?php endif;?>
</div>
<div class="cf top_nav_list" style="height: 38px;">
<!-- 高级搜索 -->
<div class="jssearch cf search_list">
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="game_id" name="base_game_id" class="select_gallery" style="width:120px;">
<option value="0">请选择游戏</option>
<?php foreach($baseGames as $baseGame):?>
<option value="<?=$baseGame['id']?>"><?=$baseGame['name']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="server_id" name="server_id" class="select_gallery" style="width:120px;">
<option value="">请选择区服</option>
<?php foreach($servers as $server):?>
<option server-id="<?=$server['server_id']?>" value="<?=$server['server_id']?>">
<?=$server['server_name']?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<input type="text" name="user_account" class="" placeholder="玩家账号" value="{:I('user_account')}"/>&nbsp;
</div>
<div class="input-list">
<input type="text" name="role_name" class="" placeholder="角色名" value="{:I('role_name')}"/>&nbsp;
</div>
<div class="input-list input-list-promote search_label_rehab">
<input type="text" readonly name="send_time_start" class="time-select" value="{:I('send_time_start')}"
placeholder="发放开始时间"/>
-
<div class="input-append date" id="datetimepicker" style="display:inline-block">
<input type="text" readonly name="send_time_end" class="time-select" value="{:I('send_time_end')}"
placeholder="发放结束时间"/>
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select name="review_status" class="select_gallery" style="width:120px;">
<option value="-1">请选择审核状态</option>
<?php foreach($reviewStatusList as $key => $name):?>
<option value="<?=$key?>">
<?=$name?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select name="send_status" class="select_gallery" style="width:120px;">
<option value="-1">请选择发放状态</option>
<?php foreach($sendStatusList as $key => $name):?>
<option value="<?=$key?>">
<?=$name?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select name="reviewer_id" class="select_gallery" style="width:120px;">
<option value="0">请选择审核人</option>
<?php foreach($admins as $admin):?>
<option value="<?=$admin['id']?>">
<?=$admin['username']?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('GameRebate/single')}">搜索</a>
</div>
<!-- <div class="input-list">
<a class="sch-btn" href="{:U('Export/expUser',array_merge(array('id'=>12,),I('get.')))}">导出</a>
</div> -->
</div>
</div>
<div class="butnbox">
<div class="butnlist jscheckbutn" style="margin-left: 2px">
<a class="butn" id="review-agree-btn">审批通过</a>
<a class="butn" id="review-refuse-btn" style="background-color: red;">审核拒绝</a>
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th>
<input class="check-all" type="checkbox">
</th>
<th>游戏名称</th>
<th>区服</th>
<th>账号</th>
<th>角色ID</th>
<th>角色名</th>
<?php if($awardType == 'A'):?>
<th>充值金额</th>
<?php elseif($awardType == 'B'):?>
<th>当日累计充值金额</th>
<th>可领取福利日期</th>
<?php elseif($awardType == 'C'):?>
<th>达到档位金额</th>
<?php endif;?>
<th>奖励内容</th>
<th>发放状态</th>
<th>发放时间</th>
<th>审核状态</th>
<th>审核时间</th>
<th>审核人</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<empty name ="records">
<td colspan="99" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="records" id="data">
<tr data-id="<?=$data['id']?>">
<td>
<?php if($data['review_status'] == 0):?>
<input class="ids" type="checkbox" value="{$data['id']}" name="ids[]">
<?php else:?>
<input class="ids disabled" disabled="disabled" type="checkbox" value="{$data['id']}" name="ids[]">
<?php endif;?>
</td>
<td>{$data.base_game_name}</td>
<td>{$data.server_name}</td>
<td>{$data.user_account}</td>
<td>{$data.role_id}</td>
<td>{$data.role_name}</td>
<?php if($awardType == 'A'):?>
<td>{$data.pay_amount}</td>
<?php elseif($awardType == 'B'):?>
<td>{$data.pay_amount}</td>
<td>{$data.award_date_range}</td>
<?php elseif($awardType == 'C'):?>
<td>{$data.amount}</td>
<?php endif;?>
<td>{$data.gift_content}</td>
<td>
<span class="status-{$data.send_status}">{$data.send_status_text}</span>
</td>
<td>{$data.send_time}</td>
<td>
<span class="status-{$data.review_status}">{$data.review_status_text}</span>
</td>
<td>{$data.review_time}</td>
<td>{$data.reviewer_username}</td>
</tr>
</volist>
</empty>
</tbody>
</table>
</div>
</div>
<div class="page">
<if condition="$role_export_check eq true ">
<a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
</if>
{$_page|default=''}
</div>
<div class="common_settings">
<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
<form class="addShortcutIcon">
<input type="hidden" name="title" value="{$m_title}">
<input type="hidden" name="url" value="Query/withdraw">
</form>
<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
</div>
</block>
<block name="script">
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js" ></script>
<script src="__STATIC__/jquery.cookie.js" charset="utf-8"></script>
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('GameRebate/single')}");
$(function(){
// 添加全部选项
if ('all' == "{:I('row', 0)}") {
$("#pagechange").prepend("<option value='all' selected>全部</option>");
} else {
$("#pagechange").prepend("<option value='all'>全部</option>");
}
$('.time-select').each(function(){
laydate.render({
elem: this,
type: 'date'
});
});
//搜索功能
$("#search").click(function(){
var sdate = Date.parse($("input[name='send_time_start']").val()) / 1000;
var edate = Date.parse($("input[name='send_time_end']").val()) / 1000;
if (sdate > edate) {
layer.msg('开始时间必须小于等于结束时间');
return false;
}
if ((edate - sdate) > 2592000) {
layer.msg('时间间隔不能超过31天请重新选择日期');
return false;
}
var url = $(this).attr('url');
var query = $('.jssearch').find('input').serialize();
query += "&"+$('.jssearch').find('select').serialize();
//query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
if( url.indexOf('?')>0 ){
url += '&' + query;
}else{
url += '?' + query;
}
window.location.href = url;
});
//回车自动提交
$('.jssearch').find('input').keyup(function(event){
if(event.keyCode===13){
$("#search").click();
}
});
$("#game_id").change(function () {
$.ajax({
url: "{:U('getServers')}",
type: "post",
data: { game_id: $("#game_id").val() },
dataType: 'json',
success: function (result ) {
if (result.status == 1) {
var servers = result.data.servers
var str = "<option value=''>请选择区服</option>"
for (var i in servers){
str += "<option value='"+servers[i].server_id+"'>"+servers[i].server_name+"</option>"
}
$("#server_id").empty()
$("#server_id").append(str)
$("#server_id").select2()
}
}
})
})
$('#review-agree-btn').on({
click:function () {
var ids = getIds()
if (ids.length == 0) {
return layer.msg('请选择要操作的记录')
}
layer.confirm('确定要审核通过这些记录吗?', {
title: '审核通过',
btn: ['确定']
}, function(){
verify(ids, 1)
})
}
})
$('#review-refuse-btn').on({
click:function () {
var ids = getIds()
if (ids.length == 0) {
return layer.msg('请选择要操作的记录')
}
layer.confirm('确定要审核拒绝这些记录吗?', {
title: '审核拒绝',
btn: ['确定']
}, function(){
verify(ids, 2)
})
}
})
function verify(ids, status) {
$.ajax({
url: "{:U('review')}",
type: "post",
data: { ids: ids, status: status },
dataType: 'json',
success: function (result ) {
if (result.status == 1) {
layer.msg(result.message, function(){
window.location.href = window.location.href
})
} else {
layer.msg(result.message)
}
}
})
}
function getIds() {
var ids = [];
$('.ids:checked').each(function() {
ids.push($(this).val());
})
return ids;
}
});
$(".export-btn").on("click",function(e){
e.preventDefault();
window.location.href=$(this).attr("href")
})
</script>
</block>

@ -43,7 +43,7 @@
<div class="tools">
<if condition="$caculate_check eq true">
<empty name="show_status">
<a class="recaculate" url="{:U('reCaculateBonus?pay_time='.$_GET['pay_time'])}" style="width: 60px;text-align: center;padding-right: 0;margin-right: 0;">重算</a>
<a class="recaculate" url="{:U('reCaculateBonus')}" style="width: 60px;text-align: center;padding-right: 0;margin-right: 0;">重算</a>
</empty>
</if>
</div>
@ -125,11 +125,14 @@
<th>类型</th>
<th >游戏名称</th>
<th >总流水</th>
<th>上游结算流水</th>
<th>下游结算流水</th>
<th>上游结算</th>
<th>下游结算</th>
<th>支付渠道费用</th>
<th>退款金额</th>
<th>返点及其他</th>
<th><a href="{:U('editTaxRatio')}" style="text-decoration:none;">公司税费</a></th>
<th>税后毛利额</th>
<th>操作</th>
</tr>
</thead>
@ -154,8 +157,11 @@
<td>{$data['cp_amount']}</td>
<td>{$data['promote_amount']}</td>
<td>{$data['channel_amount']}</td>
<td>{$data['refund_amount']}</td>
<td>{$data['other_amount']}</td>
<td>{$data['company_tax']}</td>
<td>{$data['company_profit']}</td>
<td><a class="edit_oter_amout" data-id="{$data.id}" data-amount="{$data['other_amount']}">编辑</a></td>
</tr>
</volist>
<tr>
@ -170,8 +176,11 @@
<td>{$sum['cp_amount']}</td>
<td>{$sum['promote_amount']}</td>
<td>{$sum['channel_amount']}</td>
<td>{$sum['refund_amount']}</td>
<td>{$sum['other_amount']}</td>
<td>{$sum['company_tax']}</td>
<td>{$sum['company_profit']}</td>
<td></td>
</tr>
</notemtpy>
</tbody>
@ -187,6 +196,24 @@
</if>
{$_page|default=''}
</div>
<script type="text/html" id="changeTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
</spend>
<table border="0" cellspacing="0" cellpadding="0" style="margin:0px;">
<tr style="line-height: 4;">
<td class="l noticeinfo" style="width:80px;">返点及其他:</td>
<td class="r table_radio">
<input type="text" id="other_amount" placeholder="其他扣款" />
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="changeMargin" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
</block>
@ -206,6 +233,63 @@
//导航高亮
highlight_subnav('{:U('MarketPercentage/index')}');
$(function(){
$(".edit_oter_amout").on("click",function(){
var data = $(this).data();
layer.open({
type: 1,
title: '编辑',
maxWidth:720,
closeBtn: 1,
shadeClose: false,
content: $("#changeTpl").html(),
success:function(){
env(data);
}
});
});
function env(data) {
$("#other_amount").val(data.amount);
$("#changeMargin").off("click");
$("#changeMargin").on("click",function(){
let other_amount = $("#other_amount").val();
var reg = /^(\-|\+)?\d+(\.\d*)?$/;
if( !reg.test(other_amount)){
layer.msg("返点扣款金额格式错误");
return ;
}
if(other_amount == data.amount){
layer.msg("无修改请直接关闭窗口");
return ;
}
//成功
let send = {
id:data.id,
other_amount:other_amount,
}
$.ajax({
type: "POST",
url: "{:U('otherAmountEdit')}",
dataType: 'json',
data: send,
success: function (data) {
if (data.status == 1) {
layer.msg(data.msg);
setTimeout(function () {
window.location.reload();
}, 1500);
} else {
layer.msg(data.msg);
return false;
}
}
});
});
}
//搜索功能
$("#search").click(function(){
var url = $(this).attr('url');
@ -230,54 +314,12 @@
window.location.href = url;
});
$(".paixu").click(function(){
var that=$(this);
$data_order=that.attr('data-order');
$order_type='{$userarpu_order}';
if($order_type==''||$order_type=='4'){
$(".sortBy").attr('name','data_order');
val='3,'+$data_order;
$(".sortBy").attr('value',val);
$("#search").click();
}else if($order_type=='3'){
$(".sortBy").attr('name','data_order');
val='4,'+$data_order;
$(".sortBy").attr('value',val);
$("#search").click();
}
});
//回车自动提交
$('.jssearch').find('input').keyup(function(event){
if(event.keyCode===13){
$("#search").click();
}
});
$("#admin").on('click',function(event) {
var navlist = $(this).find('.i_list_li');
if (navlist.hasClass('hidden')) {
navlist.removeClass('hidden');
$(this).find('#i_list_id').focus().val('');
} else {
navlist.addClass('hidden');
}
$(document).one("click", function(){
navlist.addClass('hidden');
});
event.stopPropagation();
});
$('#admin #i_list_id').on('keyup',function(event) {
var val = $.trim($(this).val()).toLowerCase();
$(this).closest('.drop-down').find('#i_list_idh').val(val);
});
$("#admin #i_list_li").find("a").each(function(){
$(this).click(function(){
var text = $.trim($(this).text()).toLowerCase();
$(this).closest('.drop-down').find("#i_list_id").val(text);
$(this).closest('.drop-down').find('#i_list_idh').val(text);
})
});
$('#time_start').datetimepicker({
format: 'yyyy-mm',
@ -321,35 +363,6 @@
});
event.stopPropagation();
});
/* 状态搜索子菜单 */
/*渠道删除*/
$('.delete').click(function(){
var id = $(this).attr('data-id');
layer.confirm('渠道删除后,下级渠道同时被删除,所属数据归属于自然渠道!', {
title:'确定要删除该渠道?',
icon:0,
btn: ['删除','取消'] //按钮
}, function(){
$.ajax({
type: "POST",
url: "{:U('del_promote')}",
dataType: 'json',
async: false,
data: {id:id},
success:function(data){
if(data.status==1){
layer.msg(data.msg);
setTimeout(function(){
window.location.reload();
},1500);
}
}
});
}, function(){
layer.close();
});
})
$('.recaculate').click(function(){
var url = $(this).attr('url');
@ -361,16 +374,17 @@
$.ajax({
type: "POST",
url: url,
data:{type:1},
dataType: 'json',
async: false,
success:function(data){
if(data.status == 1) {
layer.msg("重新计算需要时间,请等待10分钟后再查看");
layer.msg(data.msg);
setTimeout(function(){
window.location.reload();
},1500);
} else {
layer.msg(data.info);
layer.msg(data.msg);
}
},
});
@ -384,124 +398,4 @@
</script>
<script type="text/javascript">
//点击字母按照条件按钮筛选
$(".pro_promot_select_list_con").click(function(){
//选中高亮样式
$(this).addClass('active');
$(this).siblings().removeClass('active');
var that = $(this);
var index = $(this).attr("data-index");
$("#game_list li").each(function(index,ele){
var short = $(this).attr('data-short');
$(this).show();
if(that.attr('data-index')){
if(that.attr('data-index')!=short.charAt(0)){
$(this).hide();
}
}
})
});
//打开弹窗
$(".ajax-view").click(function(){
//获取游戏列表
var url = "{:U('Promote/getPromoteGame')}";
var id = $(this).attr('data-id');
var checked = 'checked';
$.post(url,{id:id},function(res){
if(res.code==1){
$(".pro_promot_select_list a").eq(0).addClass('active');
$(".pro_promot_select_list a").eq(0).siblings().removeClass('active');
var game_list = res.data.game_list;
var promote_info = res.data.promote_info;
var lis = [];
$.each(game_list,function(index,ele){
if(ele.game_name.length>6){
ele.game_name = ele.game_name .substring(0,6)+"..."
}
lis.push('<li class="fl pro_promot_game_con" data-short="'+ele.short+'">');
if(promote_info['game_ids']==''){
lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" checked="checked" id="gameCheck'+index+'" />');
}else{
if(promote_info['game_ids'].indexOf(ele.id)>-1){
lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" checked="checked" id="gameCheck'+index+'" />');
}else{
$(".jsgamecheckall").attr('checked',false);
lis.push('<input type="checkbox" value="'+ele.id+'" name="game_ids[]" class="fl pro_promot_game_check jsgameid" id="gameCheck'+index+'" />');
checked = '';
}
}
lis.push('<label for="gameCheck'+index+'" class="fl"></label>');
lis.push('<span class="fl pro_promot_game_name">'+ele.game_name+'</span>');
lis.push('</li>');
});
$(".jsgamecheckall").attr('checked',checked);
$("#game_list").html(lis.join(''));
$(".pro_promot_number").text(res.data.promote_info.account);
$("#se_promote_id").val(res.data.promote_info.id);
$(".pro_promot").css("display","block");
jsgameid();
}else{
var tip_msg = res.info ? res.info : '操作失败';
layer.msg(tip_msg);
}
});
});
//保存修改
$(".pro_promot_btn_confirm").click(function(){
$("#ajaxForm").ajaxSubmit(function(res){
layer.msg(res.msg);
$(".pro_promot").hide();
});
return false;
});
//关闭弹窗
$(".pro_promot_close").click(function(){
$(".pro_promot").css("display","none");
});
//取消修改
$(".pro_promot_btn_cancel").click(function(){
$(".pro_promot").css("display","none");
layer.msg('修改已取消');
});
$(".jsgamecheckall").click(function(){
$(this).closest('.jsgamecheckallbox').siblings("#game_list").find(".jsgameid").prop("checked", this.checked);
});
//可申请游戏 全选及全选反选 功能 @author zwm date 20180604
function jsgameid(){
$(".jsgameid").click(function(){
var option = $(this).closest('ul').find(".jsgameid"),
checkall = $(this).closest('ul').siblings('.jsgamecheckallbox').find('.jsgamecheckall');
option.each(function(i){
if(!this.checked){
checkall.prop("checked", false);
return false;
}else{
checkall.prop("checked", true);
}
});
});
}
</script>
</block>

@ -113,7 +113,7 @@
<div class="tools">
<if condition="$caculate_check eq true">
<empty name="show_status">
<a class="recaculate" url="{:U('reCaculateBonus?pay_time='.$_GET['pay_time'])}" style="width: 60px;text-align: center;padding-right: 0;margin-right: 0;">重算</a>
<a class="recaculate" url="{:U('reCaculateBonus')}" style="width: 60px;text-align: center;padding-right: 0;margin-right: 0;">重算</a>
</empty>
</if>
</div>
@ -199,8 +199,8 @@
<th>市场专员</th>
<th>离职时间</th>
<th>级别</th>
<th><div class="tooltip">开发总流水<span class="tooltiptext"><span style="margin-left: -10px">当月自主开发下渠道游戏内充值总和</span></span></div></th>
<th><div class="tooltip">维护总流水<span class="tooltiptext"><span style="margin-left: -10px">当月只维护下渠道游戏内充值总和</span></span></div></th>
<th><div class="tooltip">开发总流水<span class="tooltiptext"><span style="margin-left: -10px">当月自主开发下渠道游戏内充值总和(已减去退款)</span></span></div></th>
<th><div class="tooltip">维护总流水<span class="tooltiptext"><span style="margin-left: -10px">当月只维护下渠道游戏内充值总和(已减去退款)</span></span></div></th>
<th >业绩提成</th>
<th ><div class="tooltip">绩效考核奖金<span class="tooltiptext"><span style="margin-left: -10px">当月开发税后毛利奖金与维护税后毛利奖金之和</span></span></div></th>
<th >绩效系数</th>
@ -282,6 +282,7 @@
<td></td>
<td></td>
<td></td>
<td></td>
</notemtpy>
</tbody>
</table>
@ -635,16 +636,17 @@
$.ajax({
type: "POST",
url: url,
data:{type:2},
dataType: 'json',
async: false,
success:function(data){
if(data.status == 1) {
layer.msg("重新计算需要时间,请等待10分钟后再查看");
layer.msg(data.msg);
setTimeout(function(){
window.location.reload();
},1500);
} else {
layer.msg(data.info);
layer.msg(data.msg);
}
},

@ -55,6 +55,19 @@ class GameRepository
->select();
}
public function getServersByBaseGameId($baseGameId, $fields = ['id', 'server_name', 'server_id'])
{
$baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find();
$map = [];
$map['game_id'] = ['in', $this->getGameIdsByBaseGame($baseGame)];
return M('server', 'tab_')
->field($fields)
->where($map)
->group('server_id')
->order('server_id asc')
->select();
}
public function getGameIdsByBaseGame($baseGame, $deviceType = 0)
{
$gameIds = [];

@ -0,0 +1,137 @@
<?php
namespace Base\Service;
use GuzzleHttp\Client;
class GameRebateService
{
const SIGN_KEY = 'Eza65532qaOIAAWasdq962aqweasd';
private function getClient()
{
return new Client([
'base_uri' => 'http://rebate.99you.cn/xyy_apply.php/23400/',
'timeout' => 10.0,
]);
}
public function sendByOrder($order)
{
$gift = M('rebate_gifts', 'tab_')->where(['type' => $order['type'], 'gift_key' => $order['gift_key']])->find();
$hasError = false;
$sendResult = '';
if ($gift['game_currency'] > 0) {
$result = $this->sendCurrency($order['server_id'], $order['role_id'], $gift['game_currency']);
if ($result['code'] != 1) {
$hasError = true;
}
$sendResult .= ($result['msg'] ?? '');
$sendResult .= ';';
}
if ($gift['gift_id'] > 0) {
$result = $this->sendGift($order['server_id'], $order['role_id'], $gift['gift_id']);
if ($result['code'] != 1) {
$hasError = true;
}
$sendResult .= ($result['msg'] ?? '');
}
M('rebate_orders', 'tab_')->where(['id' => $order['id']])->save([
'send_status' => $hasError ? 2 : 1,
'send_time' => time(),
'send_result' => $sendResult,
]);
}
public function sendCurrency($serverId, $roleId, $currency)
{
$sign = md5($currency.$serverId.$roleId.self::SIGN_KEY);
$params = [
'act' => 'sendgold',
'serverid' => $serverId,
'role_id' => $roleId,
'money' => $currency,
'sign' => $sign
];
return $this->get('', $params);
}
public function sendGift($serverId, $roleId, $giftId)
{
$sign = md5($giftId.$serverId.$roleId.self::SIGN_KEY);
$params = [
'act' => 'send_email',
'serverid' => $serverId,
'role_id' => $roleId,
'prop_id' => $giftId,
'sign' => $sign
];
return $this->get('', $params);
}
protected function get($uri, array $params = [])
{
try {
$response = $this->getClient()->get($uri, [
'verify' => false,
'query' => $params,
]);
$result = (string)$response->getBody();
return json_decode($result, true);
} catch (\Exception $e) {
return [
'code' => 3,
'msg' => '网络异常:' . $e->getMessage(),
];
}
}
public function review(array $ids, $status)
{
if (!in_array($status, [1, 2])) {
throw new \Exception('状态异常');
}
if (count($ids) == 0) {
throw new \Exception('请选择要操作的记录');
}
$orders = M('rebate_orders', 'tab_')->field(['id'])->where(['review_status' => 0, 'id' => ['in', $ids]])->select();
if (count($orders) != count($ids)) {
throw new \Exception('含有不存在的记录或者已审核的记录');
}
$adminInfo = $_SESSION['onethink_admin']['user_auth'];
M('rebate_orders', 'tab_')->where(['review_status' => 0, 'id' => ['in', $ids]])->save([
'review_status' => $status,
'review_time' => time(),
'reviewer_id' => $adminInfo['uid'],
'reviewer_username' => $adminInfo['username'],
]);
}
public function sendAll($type)
{
$orders = M('rebate_orders', 'tab_')->where(['type' => $type, 'review_status' => 1, 'send_status' => 0])->select();
foreach ($orders as $order) {
if ($type == 'B') {
if (time() < strtotime($order['award_started_at'] . ' 00:00:00') || time() > strtotime($order['award_ended_at'] . ' 23:59:59')) {
continue;
}
}
$this->sendByOrder($order);
}
}
public function sendDaily($date)
{
$map = [
'type' => 'B',
'review_status' => 1,
'send_status' => 1,
'award_started_at' => ['elt', $date],
'award_ended_at' => ['egt', $date]
];
$orders = M('rebate_orders', 'tab_')->where($map)->select();
foreach ($orders as $order) {
$this->sendByOrder($order);
}
}
}

@ -0,0 +1,134 @@
<?php
namespace Base\Tool\GameResource;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
/**
* 逍遥游之仙魔降世-测试资源接口
*/
class XyyClient
{
const SIGN_NAME = 'sign';
const SUCCESS = '0000';
const KEY = 'Eza65532qaOIAAWasdq962aqweasd';
protected $client;
private $apis = [
'provide' => ['uri' => '/', 'method' => 'get'],
];
public function __construct()
{
$this->client = new Client([
'base_uri' => 'http://rebate.99you.cn/wdzx_apply.php/23399',
'timeout' => 10.0,
]);
}
public function api($api, array $params = [])
{
$api = $this->apis[$api] ?? null;
if (is_null($api)) {
throw new \Exception('接口不存在');
}
$params[self::SIGN_NAME] = $this->sign($params);
try {
return $this->request($api, $params);
} catch (\Exception $e) {
$env = C('APP_ENV', null, 'prod');
return ['code' => 3, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []];
}
}
public function request($api, $params)
{
if ($api['method'] == 'get') {
return $this->get($api['uri'], $params);
} else {
return $this->post($api['uri'], $params);
}
}
protected function post($uri, array $params = [])
{
$response = $this->client->post($uri, [
'verify' => false,
'form_params' => $params,
]);
$result = (string)$response->getBody();
return json_decode($result, true);
}
protected function get($uri, array $params = [])
{
$response = $this->client->get($uri, [
'verify' => false,
'query' => $params,
]);
$result = (string)$response->getBody();
return json_decode($result, true);
}
protected function sign($params)
{
return md5($params['orderid'] . $params['serverid'] . $params['role_id'] . self::KEY);
}
public function apply($order, $role)
{
$data = [
'role_id' => $role['role_id'],
'serverid' => $role['server_id'],
'amount' => $order['ref_amount'],
// 'money' => intval($order['ref_amount']) * 10,
'orderid' => $order['order_no'],
];
$result = $this->api('provide', $data);
if ($result['code'] == 1) {
return [
'status' => true,
'message' => $result['msg'],
'result' => $result
];
} else {
return [
'status' => false,
'message' => $result['msg'],
'result' => $result
];
}
}
public function getResourceTypes($deviceType)
{
if ($deviceType == 'andriod') {
return [['id' => 1, 'name' => '通用', 'device_type' => 'andriod']];
} elseif ($deviceType == 'ios') {
return [['id' => 2, 'name' => '通用', 'device_type' => 'ios']];
}
}
public function getResources($typeId, $deviceType)
{
return [
1 => ['ref_id' => 1, 'name' => '60元宝', 'amount' => 6],
2 => ['ref_id' => 2, 'name' => '300元宝', 'amount' => 30],
3 => ['ref_id' => 3, 'name' => '980元宝', 'amount' => 98],
4 => ['ref_id' => 4, 'name' => '1280元宝', 'amount' => 128],
5 => ['ref_id' => 5, 'name' => '1980元宝', 'amount' => 198],
6 => ['ref_id' => 6, 'name' => '3280元宝', 'amount' => 328],
7 => ['ref_id' => 7, 'name' => '6480元宝', 'amount' => 648],
8 => ['ref_id' => 8, 'name' => '10000元宝', 'amount' => 1000],
9 => ['ref_id' => 9, 'name' => '20000元宝', 'amount' => 2000],
10 => ['ref_id' => 10, 'name' => '30000元宝', 'amount' => 3000],
11 => ['ref_id' => 11, 'name' => '50000元宝', 'amount' => 5000],
12 => ['ref_id' => 12, 'name' => '100000元宝', 'amount' => 10000],
13 => ['ref_id' => 13, 'name' => '200000元宝', 'amount' => 20000],
];
}
}
Loading…
Cancel
Save