玄灵契约返利

master
ELF 3 years ago
parent 5f6c10bcc1
commit d188bb9072

@ -13,6 +13,8 @@ use GuzzleHttp\Client;
use think\Db;
use Base\Tool\GameResource;
use Base\Tool\GameResource\SbcqClient;
use Base\Tool\GameResource\XlqyClient;
use Base\Tool\GameResource\XyyClient;
class GameApiController extends Think {
@ -64,6 +66,24 @@ class GameApiController extends Think {
public function send()
{
$giftItem = [
'id' => 240,
'num' => 1,
];
$order = [
'id' => 1,
'user_id' => 77,
'user_account' => '13635240735',
'server_id' => '157',
'role_id' => '578157',
'role_name' => '小蜗牛',
];
$client = new XlqyClient();
$result = $client->sendEmail($giftItem, $order);
var_dump($result);
return;
$giftItem = [
'id' => 1782,
'num' => 1,
@ -137,14 +157,13 @@ class GameApiController extends Think {
public function rebateSend()
{
$service = new GameRebateService();
$service->sendAll('A');
$service->sendAll('B');
$service->sendAll('C');
}
$service->sendOnce('A');
$service->sendOnce('C');
$service->sendOnce('D');
$service->sendOnce('E');
public function rebateSendDaily()
{
$service = new GameRebateService();
$service->sendDaily(date('Y-m-d'));
$date = date('Y-m-d');
$service->sendDaily('B', $date);
$service->sendDaily('F', $date);
}
}

@ -27,139 +27,47 @@ class GameRebateController extends ThinkController
$this->records('B');
}
public function records($awardType)
public function firstPay()
{
$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;
}
$this->records('D');
}
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');
}
public function dayAccumulative()
{
$this->records('E');
}
if (I('create_time_start', '') != '') {
$where['_string'] .= ' and create_time>=' . strtotime(I('create_time_start') . ' 00:00:00');
}
if (I('create_time_end', '') != '') {
$where['_string'] .= ' and create_time<=' . strtotime(I('create_time_end') . ' 23:59:59');
}
public function weekly()
{
$this->records('F');
}
public function records($awardType)
{
$params = I('get.');
$params['is_export'] = ($params['export'] ?? 0);
$params['page'] = ($params['p'] ?? 1);
$params['limit'] = ($params['row'] ?? 10);
$query = M('rebate_orders', 'tab_')->where($where);
$baseGameId = $params['base_game_id'] ?? 0;
$isExport = $params['is_export'] == 1;
$records = [];
if (I('export', 0) == 1 || $row == 'all') {
$records = $query->order('create_time desc')->select();
} else {
$countQuery = clone $query;
$records = $query->order('create_time desc')->page($page, $row)->select();
$count = $countQuery->count();
}
$service = new GameRebateService();
[$records, $count] = $service->listQuery($params, $awardType);
$sendStatusList = [
0 => '待发放',
1 => '发放成功',
2 => '发放异常',
];
$reviewStatusList = [
0 => '待审核',
1 => '审核通过',
2 => '审核拒绝',
];
$pageTitles = [
'A' => '单笔充值福利',
'B' => '月卡福利发放',
'C' => '累充福利发放',
];
$pageNames = [
'A' => 'single',
'B' => 'daily',
'C' => 'accumulative',
];
$pageTitle = $pageTitles[$awardType];
$pageName = $pageNames[$awardType];
$newLine = I('export', 0) == 1 ? "\n" : '<br/>';
$pageTitle = $service->typeDisplayNames[$awardType];
$pageName = $service->typeNames[$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]['create_time'] = $record['create_time'] > 0 ? date('Y-m-d H:i:s', $record['create_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($newLine, explode('|', $record['gift_content']));
}
if (I('export', 0) == 1) {
$field = [
'base_game_name' => '游戏名称',
'server_name' => '区服',
'user_account' => '账号',
'role_id' => '角色ID',
'role_name' => '角色名称',
'gift_content' => '奖励内容',
'create_time' => '订单生成时间',
'review_status_text' => '审核状态',
'review_time' => '审核时间',
'send_status_text' => '发放状态',
'send_time' => '发放时间',
'reviewer_username' => '审核人',
];
if ($awardType == 'A') {
$field['pay_amount'] = '充值金额';
} elseif ($awardType == 'B') {
$field['pay_amount'] = '当日累计充值金额';
$field['award_date_range'] = '可领取福利日期';
} elseif ($awardType == 'C') {
$field['amount'] = '达到档位金额';
}
$records = $service->listRange($records);
if ($isExport) {
$field = $service->getExportHeadings($awardType);
addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出' . $pageTitle . '记录','url'=>U('GameRebate/' . $pageName),'menu'=>'推广员-发放福利管理-' . '导出' . $pageTitle . '记录']);
data2csv($records, $pageTitle, $field);
exit;
}
}
$page = set_pagination($count, $row == 'all' ? 99999999 : $row);
$page = set_pagination($count, $params['limit'] == 'all' ? 99999999 : $params['limit']);
if($page) {
$this->assign('_page', $page);
@ -175,8 +83,8 @@ class GameRebateController extends ThinkController
$this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId));
$this->assign('admins', $admins);
$this->assign('baseGames', $baseGames);
$this->assign('sendStatusList', $sendStatusList);
$this->assign('reviewStatusList', $reviewStatusList);
$this->assign('sendStatusList', $service->sendStatusList);
$this->assign('reviewStatusList', $service->reviewStatusList);
$this->assign('records', $records);
$this->display('records');
}

@ -445,6 +445,7 @@ class PromoteController extends ThinkController
$data['can_view_recharge'] = $_POST['can_view_recharge'];
$data['ts_over_apply'] = $_POST['ts_over_apply'] ?? 0;
$data['shift_over_apply'] = $_POST['shift_over_apply'] ?? 0;
$data['rebate_over_perm'] = $_POST['rebate_over_perm'] ?? 0;
if (empty($pwd)) {
unset($data['password']);
}

@ -192,6 +192,13 @@
<th>可领取福利日期</th>
<?php elseif($awardType == 'C'):?>
<th>达到档位金额</th>
<?php elseif($awardType == 'D'):?>
<th>首充金额</th>
<?php elseif($awardType == 'E'):?>
<th>当日累计充值金额</th>
<th>达成日期</th>
<?php elseif($awardType == 'F'):?>
<th>可领取福利日期</th>
<?php endif;?>
<th>奖励内容</th>
<th>订单生成时间</th>
@ -230,6 +237,13 @@
<td>{$data.award_date_range}</td>
<?php elseif($awardType == 'C'):?>
<td>{$data.amount}</td>
<?php elseif($awardType == 'D'):?>
<td>{$data.pay_amount}</td>
<?php elseif($awardType == 'E'):?>
<td>{$data.pay_amount}</td>
<td>{$data.award_date}</td>
<?php elseif($awardType == 'F'):?>
<td>{$data.award_date_range}</td>
<?php endif;?>
<td>{$data.gift_content}</td>

@ -364,6 +364,20 @@
</td>
</tr>
<?php endif;?>
<tr>
<td class="l">返利管理权限:</td>
<td class="r table_radio">
<span class="form_radio table_btn">
<label >
<input type="radio" value="1" name="rebate_over_perm" class="withdraw_done" <if condition="$data['rebate_over_perm'] eq 1">checked="checked"</if>> 开启
</label >
<label >
<input type="radio" value="0" name="rebate_over_perm" class="withdraw_done" <if condition="$data['rebate_over_perm'] eq 0">checked="checked"</if>> 锁定
</label>
</span>
<span class="notice-text">开启后该推广员有权限查看并操作整个公会用户返利功能</span>
</td>
</tr>
<tr>
<td class="l">备注:</td>
<td class="r table_textarea" >

@ -2,13 +2,54 @@
namespace Base\Service;
use Base\Tool\GameResource\SbcqClient;
use Base\Tool\GameResource\XlqyClient;
use Base\Tool\GameResource\XyyClient;
use Exception;
use GuzzleHttp\Client;
class GameRebateService
{
public function sendByOrder($order)
public $sendStatusList = [
0 => '待发放',
1 => '发放成功',
2 => '发放异常',
];
public $reviewStatusList = [
0 => '待审核',
1 => '审核通过',
2 => '审核拒绝',
];
public $typeDisplayNames = [
'A' => '单笔充值福利',
'B' => '月卡福利发放',
'C' => '累充福利发放',
'D' => '首充福利发放',
'E' => '单日累充福利发放',
'F' => '周卡福利发放',
];
public $typeNames = [
'A' => 'single',
'B' => 'daily',
'C' => 'accumulative',
'D' => 'firstPay',
'E' => 'dayAccumulative',
'F' => 'weekly',
];
public function isGiftItemSend($order, $item)
{
// 每日发放奖励暂时通过send_status来判断是否第一次发放
if ($order['send_status'] = 1 && isset($item['once']) && $item['once']) {
return false;
}
return true;
}
public function sendByOrder($order, $handleDate = null)
{
$gift = M('rebate_gifts', 'tab_')->where(['base_game_id' => $order['base_game_id'], 'type' => $order['type'], 'gift_key' => $order['gift_key']])->find();
$hasError = false;
@ -22,17 +63,26 @@ class GameRebateService
}
$giftItems = json_decode($gift['gifts'], true);
foreach ($giftItems as $giftItem) {
if (!$this->isGiftItemSend($order, $giftItem)) {
continue;
}
$result = $this->sendGift($order, $giftItem);
if (!$result['status']) {
$hasError = true;
}
$sendResult .= ($result['message'] ?? '') . ';';
}
M('rebate_orders', 'tab_')->where(['id' => $order['id']])->save([
$data = [
'send_status' => $hasError ? 2 : 1,
'send_time' => time(),
'send_result' => $sendResult,
]);
];
if ($handleDate) {
$data['current_award_date'] = $handleDate;
}
M('rebate_orders', 'tab_')->where(['id' => $order['id']])->save($data);
}
private function getClient($baseGameId)
@ -45,8 +95,11 @@ class GameRebateService
case 73:
$client = new SbcqClient();
break;
case 75:
$client = new XlqyClient();
break;
/* case 9:
$client = new SbcqClient();
$client = new XlqyClient();
break; */
default:
throw new \Exception('客户端未实现');
@ -89,31 +142,163 @@ class GameRebateService
]);
}
public function sendAll($type)
public function sendOnce($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)
public function sendDaily($type, $date)
{
$map = [
'type' => 'B',
'type' => $type,
'review_status' => 1,
'send_status' => 1,
'award_started_at' => ['elt', $date],
'award_ended_at' => ['egt', $date]
'award_ended_at' => ['egt', $date],
'_string' => '(current_award_date is null or current_award_date < "' . $date . '")'
];
$orders = M('rebate_orders', 'tab_')->where($map)->select();
foreach ($orders as $order) {
$this->sendByOrder($order);
$this->sendByOrder($order, $date);
}
}
public function listQuery($params, $awardType, $promote = null)
{
$isExport = $params['is_export'] ?? 0;
$page = $params['page'] ?? 0;
$limit = $params['limit'] ?? 0;
$baseGameId = $params['base_game_id'] ?? 0;
$serverId = $params['server_id'] ?? '';
$roleName = $params['role_name'] ?? '';
$userAccount = $params['user_account'] ?? '';
$reviewStatus = $params['review_status'] ?? -1;
$sendStatus = $params['send_status'] ?? -1;
$reviewerId = $params['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');
}
if (I('create_time_start', '') != '') {
$where['_string'] .= ' and create_time>=' . strtotime(I('create_time_start') . ' 00:00:00');
}
if (I('create_time_end', '') != '') {
$where['_string'] .= ' and create_time<=' . strtotime(I('create_time_end') . ' 23:59:59');
}
if ($promote) {
$promoteService = new PromoteService();
$subSql = M('user', 'tab_')->field(['id'])->where(['_string' => 'promote_id in(' . $promoteService->subInSql($promote) . ')'])->select(false);
$where['_string'] .= ' and user_id in(' . $subSql . ')';
}
$query = M('rebate_orders', 'tab_')->where($where);
$count = 0;
$records = [];
if ($isExport == 1 || $limit == 'all') {
$records = $query->order('create_time desc')->select();
$count = count($records);
} else {
$countQuery = clone $query;
$records = $query->order('create_time desc')->page($page, $limit)->select();
$count = $countQuery->count();
}
return [$records, $count];
}
public function listRange(array $records, $isExport = false)
{
$users = [];
if (count($records) > 0) {
$userIds = array_column($records, 'user_id');
$users = M('user', 'tab_')->field(['id', 'promote_account'])->where(['id' => ['in', $userIds]])->select();
$users = index_by_column('id', $users);
}
$newLine = $isExport == 1 ? "\n" : '<br/>';
foreach ($records as $key => $record) {
$user = $users[$record['user_id']];
$records[$key]['promote_account'] = $user['promote_account'];
$records[$key]['review_status_text'] = $this->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'] = $this->sendStatusList[$record['send_status']];
$records[$key]['send_time'] = $record['send_time'] > 0 ? date('Y-m-d H:i:s', $record['send_time']) : '--';
$records[$key]['create_time'] = $record['create_time'] > 0 ? date('Y-m-d H:i:s', $record['create_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($newLine, explode('|', $record['gift_content']));
}
return $records;
}
public function getExportHeadings($awardType)
{
$fields = [
'base_game_name' => '游戏名称',
'server_name' => '区服',
'user_account' => '账号',
'role_id' => '角色ID',
'role_name' => '角色名称',
];
if ($awardType == 'A') {
$fields['pay_amount'] = '充值金额';
} elseif ($awardType == 'B') {
$fields['pay_amount'] = '当日累计充值金额';
$fields['award_date_range'] = '可领取福利日期';
} elseif ($awardType == 'C') {
$fields['amount'] = '达到档位金额';
} elseif ($awardType == 'D') {
$fields['pay_amount'] = '首充金额';
} elseif($awardType == 'E') {
$fields['pay_amount'] = '当日累计充值金额';
$fields['award_date'] = '达成日期';
} elseif($awardType == 'F') {
$fields['award_date_range'] = '可领取福利日期';
}
$fields = array_merge($fields, [
'gift_content' => '奖励内容',
'create_time' => '订单生成时间',
'review_status_text' => '审核状态',
'review_time' => '审核时间',
'send_status_text' => '发放状态',
'send_time' => '发放时间',
'reviewer_username' => '审核人',
]);
return $fields;
}
}

@ -0,0 +1,176 @@
<?php
namespace Base\Tool\GameResource;
use Base\Tool\Log;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
/**
* 玄灵契约-测试资源接口
*/
class XlqyClient
{
const SIGN_NAME = 'sign';
const SUCCESS = '0000';
const APP_ID = 'FD32BDA67D6024D71';
const SIGN_KEY = 'FzYrrm23eN8sMkomGiHM0QG2Uvk8uAPw';
// const APP_ID = '77A38AE4C5CAD6756'; // IOS
// const SIGN_KEY = 'rKkoznJcEhWaVPSuBnH1QnC9goDd4TcB'; // IOS
protected $client;
private $apis = [
'send-email' => ['uri' => '', 'method' => 'post'],
];
public function __construct()
{
$this->client = new Client([
'base_uri' => 'http://xx2api.hnputihd.com/apip/payWM450S00/emRebate',
'timeout' => 10.0,
]);
}
public function api($name, array $params = [])
{
$api = $this->apis[$name] ?? null;
if (is_null($api)) {
throw new \Exception('接口不存在');
}
$params[self::SIGN_NAME] = $this->sign($name, $params);
try {
return $this->request($api, $params);
} catch (\Exception $e) {
$env = C('APP_ENV', null, 'prod');
Log::error('rebate:XLQY ' . $e->getMessage());
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();
Log::info('rebate:XLQY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
return json_decode($result, true);
}
protected function get($uri, array $params = [])
{
$response = $this->client->get($uri, [
'verify' => false,
'query' => $params,
]);
$result = (string)$response->getBody();
Log::info('rebate:XLQY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
return json_decode($result, true);
}
protected function sign($name, $params)
{
if ($name == 'send-email') {
return md5(
$params['appId'] .
$params['orderNum'] .
$params['userId'] .
$params['mailId'] .
$params['serviceId'] .
$params['roleId'] .
$params['time'] .
self::SIGN_KEY
);
} else {
return '';
}
}
public function sendEmail($giftItem, $order)
{
$data = [
'appId' => self::APP_ID,
'userId' => $order['user_id'],
'serviceId' => $order['server_id'],
'roleId' => $order['role_id'],
'mailId' => $giftItem['id'],
'orderNum' => $this->generateOrderNumber($order),
'time' => time(),
];
$result = $this->api('send-email', $data);
return $this->getCommonResult($result);
}
private function generateOrderNumber($order)
{
$length = 8 - strlen(strval($order['id']));
return date('Ymd') . str_repeat('0', $length) . $order['id'];
}
private function getCommonResult($result)
{
if ($result['code'] == 0) {
return [
'status' => true,
'message' => $result['msg'],
'result' => $result
];
} else {
return [
'status' => false,
'message' => $result['msg'],
'result' => $result
];
}
}
/**
* @todo 暂时没有测试资源
*/
public function apply($order, $role)
{
return $this->sendEmail($order['ref_amount'], $role);
}
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],
];
}
}

@ -32,13 +32,13 @@ class XyyClient
]);
}
public function api($api, array $params = [])
public function api($name, array $params = [])
{
$api = $this->apis[$api] ?? null;
$api = $this->apis[$name] ?? null;
if (is_null($api)) {
throw new \Exception('接口不存在');
}
$params[self::SIGN_NAME] = $this->sign($api, $params);
$params[self::SIGN_NAME] = $this->sign($name, $params);
try {
return $this->request($api, $params);
} catch (\Exception $e) {
@ -79,11 +79,11 @@ class XyyClient
return json_decode($result, true);
}
protected function sign($api, $params)
protected function sign($name, $params)
{
if ($api == 'send-email') {
if ($name == 'send-email') {
return md5($params['prop_id'].$params['serverid'].$params['role_id'].self::SIGN_KEY);
} elseif ($api == 'send-gold') {
} elseif ($name == 'send-gold') {
return md5($params['money'].$params['serverid'].$params['role_id'].self::SIGN_KEY);
} else {
return '';

@ -222,15 +222,20 @@ class BaseController extends HomeController
$count = $countQuery->count();
$records = $query->page($page, $pageSize)->select();
$pagination = $this->getPagination($count, $page, $pageSize);
return [$records, $pagination, $count];
}
public function getPagination($count, $page, $pageSize)
{
$params = [
'p' => $page,
'row' => $pageSize
];
$params = array_merge($params, $_POST);
$params = array_merge($params, $_GET);
$pagination = set_pagination($count, $pageSize, $params);
return [$records, $pagination, $count];
return set_pagination($count, $pageSize, $params);
}
public function getRecordsByIds($query, $ids, $params = [])

@ -0,0 +1,131 @@
<?php
namespace Home\Controller;
use Base\Model\PromoteModel;
use Base\Service\PromoteService;
use OSS\Core\OssException;
use Think\Model;
use Base\Service\TestingResourceService;
use Base\Repository\TestingResourceRepository;
use Base\Repository\GameRepository;
use Base\Service\GameRebateService;
use Base\Service\GameService;
class GameRebateController extends BaseController
{
protected function _initialize()
{
parent::_initialize();
$loginPromote = $this->getLoginPromote();
if ($loginPromote['rebate_over_perm'] == 0) {
return $this->error('无权限操作');
}
}
public function single()
{
$this->records('A');
}
public function accumulative()
{
$this->records('C');
}
public function daily()
{
$this->records('B');
}
public function firstPay()
{
$this->records('D');
}
public function dayAccumulative()
{
$this->records('E');
}
public function weekly()
{
$this->records('F');
}
public function records($awardType)
{
$promoteService = new PromoteService();
$loginPromote = $this->getLoginPromote();
$permPromote = $promoteService->getTopPromote($loginPromote);
$params = I('get.');
$params['is_export'] = ($params['export'] ?? 0);
$params['page'] = ($params['p'] ?? 1);
$params['limit'] = ($params['row'] ?? 10);
$baseGameId = $params['base_game_id'] ?? 0;
$isExport = $params['is_export'] == 1;
$service = new GameRebateService();
[$records, $count] = $service->listQuery($params, $awardType, $permPromote);
$pageTitle = $service->typeDisplayNames[$awardType];
$pageName = $service->typeNames[$awardType];
if (count($records) > 0) {
$records = $service->listRange($records);
if ($isExport) {
$field = $service->getExportHeadings($awardType);
data2csv($records, $pageTitle, $field);
exit;
}
}
$pagination = $this->getPagination($count, $params['page'], $params['limit']);
$admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->select();
$baseGames = M('base_game', 'tab_')->select();
$gameRepository = new GameRepository();
$this->assign('pageTitle', $pageTitle);
$this->assign('pageName', $pageName);
$this->assign('awardType', $awardType);
$this->assign('servers', $gameRepository->getServersByBaseGameId($baseGameId));
$this->assign('admins', $admins);
$this->assign('baseGames', $baseGames);
$this->assign('sendStatusList', $service->sendStatusList);
$this->assign('reviewStatusList', $service->reviewStatusList);
$this->assign('pagination', $pagination);
$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]]);
}
}

@ -0,0 +1,404 @@
<extend name="Public/promote_base"/>
<block name="css">
<link href="__CSS__/20180207/data.css" rel="stylesheet">
<link href="__CSS__/20180207/manager.css" rel="stylesheet" >
<link href="__CSS__/20180207/finance.css" rel="stylesheet">
<style>
.page-list .trunk-search{
padding-top: 20px;
}
.view-detail {
width: 70px;
height: 35px;
display: block;
background: #409eff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
.normal_table td .status-0 {
color: #e6a23c;
}
.normal_table td .status-1 {
color: #67c23a;
}
.normal_table td .status-2 {
color: #f56c6c;
}
.normal_table tr td {
padding: 10px 5px;
}
</style>
</block>
<block name="body">
<div class="page-list normal_list apply-app_apply-list">
<div class="trunk-title">
<div class="location">
<div class="location-container">当前位置:<span>返利管理></span><span>{$pageTitle}</span></div>
</div>
<img src="__IMG__/20180207/icon_normal_shenqing.png">
<span class="title_main">{$pageTitle}</span>
<span class="details">说明:{$pageTitle}</span>
</div>
<div class="trunk-content article">
<div class="trunk-search clearfix">
<div id="form1">
<div class="clearfix">
<div class="form-group normal_space fr">
<select name="send_status" class="reselect select_gallery">
<option status-id="-1" value="-1">请选择发放状态</option>
<?php foreach($sendStatusList as $key => $name):?>
<option status-id="<?=key?>" value="<?=$key?>" <?php if(strval($key) === I('send_status')):?>selected="selected"<?php endif;?>>
<?=$name?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="form-group normal_space fr">
<select name="review_status" class="reselect select_gallery">
<option status-id="-1" value="-1">请选择审核状态</option>
<?php foreach($reviewStatusList as $key => $name):?>
<option status-id="<?=key?>" value="<?=$key?>" <?php if(strval($key) === I('review_status')):?>selected="selected"<?php endif;?>>
<?=$name?>
</option>
<?php endforeach;?>
</select>
</div>
<div class="form-group normal_space fr">
<input type="text" name="role_name" class="txt normal_txt" id="uid" style="width:110px;" placeholder="请输入角色名" value="{:I('role_name')}" onKeyDown="webchat_chkkeysend(event);">
</div>
<div class="form-group normal_space fr">
<input type="text" name="account" class="txt normal_txt" id="uid" style="width:110px;" placeholder="请输入玩家账号" value="{:I('account')}" onKeyDown="webchat_chkkeysend(event);">
</div>
<div class="form-group normal_space fr">
<span id="server_js">
<select id="server_id" name="server_id" class="reselect select_gallery" style="width:101px">
<option server-id="0" value="">请选择区服</option>
<?php foreach($servers as $server):?>
<option server-id="<?=$server['server_id']?>" value="<?=$server['id']?>" <?php if($server['id'] == I('server_id')):?>selected="selected"<?php endif;?>>
<?=$server['server_name']?>
</option>
<?php endforeach;?>
</select>
</span>
</div>
<div class="form-group normal_space fr">
<select id="game_id" name="base_game_id" class="reselect select_gallery" >
<option game-id="0" value="">请选择游戏</option>
<?php foreach($baseGames as $baseGame):?>
<option game-id="<?=$baseGame['id']?>" value="<?=$baseGame['id']?>" <?php if($baseGame['id'] == I('base_game_id')):?>selected="selected"<?php endif;?>>
<?=$baseGame['name']?>
</option>
<?php endforeach;?>
</select>
</div>
</div>
<div class="clearfix" style="margin-top: 10px;">
<div class="form-group normal_space fr">
<input type="submit" class="submit" id='submit' value="查询" url="{:U($pageName)}" style="cursor:pointer;">
</div>
<div class="form-group normal_space fr" style="margin-left: 9px;">
<label class="form-title select-title" style="margin-right: 9px;"></label>
<div class="select-time">
<input type="text" id="edate" class="txt" name="create_time_end" placeholder="结束时间" value="{:I('create_time_end')}" autocomplete="off">
</div>
</div>
<div class="form-group normal_space fr">
<label class="form-title select-title">订单生成时间:</label>
<div class="select-time">
<input type="text" id="sdate" class="txt" name="create_time_start" placeholder="开始时间" value="{:I('create_time_start')}" autocomplete="off">
</div>
</div>
<div class="form-group normal_space fr" style="margin-left: 9px;">
<label class="form-title select-title" style="margin-right: 9px;"></label>
<div class="select-time">
<input type="text" id="edate" class="txt" name="send_time_end" placeholder="结束时间" value="{:I('send_time_end')}" autocomplete="off">
</div>
</div>
<div class="form-group normal_space fr">
<label class="form-title select-title">发放时间:</label>
<div class="select-time">
<input type="text" id="sdate" class="txt" name="send_time_start" placeholder="开始时间" value="{:I('send_time_start')}" autocomplete="off">
</div>
</div>
</div>
<br>
<div class="form-group normal_space fr">
<input type="button" class="submit" id='review-agree-btn'
style="width: 100px;text-align: center;background:#67c23a;cursor:pointer;"
value="审批通过">
</div>
<div class="form-group normal_space fr">
<input type="button" class="submit" id='review-refuse-btn'
style="width: 100px;text-align: center;background:rgb(249,104,104);cursor:pointer;"
value="审核拒绝" url="{:U('add')}">
</div>
</div>
</div>
</div>
<div class="page-list apply-app_apply-list query-recharge-list">
<div class="trunk-content article">
<div class="tabcon trunk-list">
<table class="table normal_table zwm_tab" >
<tr class="odd zwm_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 elseif($awardType == 'D'):?>
<th>首充金额</th>
<?php elseif($awardType == 'E'):?>
<th>当日累计充值金额</th>
<th>达成日期</th>
<?php elseif($awardType == 'F'):?>
<th>可领取福利日期</th>
<?php endif;?>
<th>奖励内容</th>
<th>订单生成时间</th>
<th>发放状态</th>
<th>发放时间</th>
<th>审核状态</th>
<th>审核时间</th>
<th>审核人</th>
</tr>
<empty name="records">
<tr><td colspan="16" style="text-align: center;height: 45vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
<else />
<volist name="records" id="data" mod="2">
<tr data-id="<?=$data['id']?>" class="<eq name='mod' value='1'>odd</eq>">
<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 elseif($awardType == 'D'):?>
<td>{$data.pay_amount}</td>
<?php elseif($awardType == 'E'):?>
<td>{$data.pay_amount}</td>
<td>{$data.award_date}</td>
<?php elseif($awardType == 'F'):?>
<td>{$data.award_date_range}</td>
<?php endif;?>
<td>{$data.gift_content}</td>
<td>{$data.create_time}</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>
</table>
<div class="pagenation clearfix">
{$pagination}
</div>
</div>
</div>
</div>
</div>
</block>
<block name="script">
<link rel="stylesheet" type="text/css" href="__CSS__/p_jquery.datetimepicker.css">
<script type="text/javascript" src="__JS__/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript">
$().ready(function(){
setValue('row','{:I("get.row",10)}');
$("#pagehtml a").on("click",function(event){
event.preventDefault();//使a自带的方法失效即无法调整到href中的URL(http://www.baidu.com)
var geturl = $(this).attr('href');
$('#data_form').attr('action',geturl);
$('#data_form').submit();
});
$('#sdate').datetimepicker({
lang:'ch',
format:'Y-m-d',
formatDate:'Y-m-d',
timepicker:false
});
$(".select_gallery").select2();
$('#edate').datetimepicker({
lang:'ch',
format:'Y-m-d',
formatDate:'Y-m-d',
timepicker:false
});
});
</script>
<script type="text/javascript">
$("#submit").click(function(){
var sdate =$('#sdate').val();
var edate =$('#edate').val();
if(Date.parse(sdate) > Date.parse(edate)){
layer.msg('开始时间必须小于等于结束时间');
return false;
}
var url = $(this).attr('url');
var query = $('#form1').find('input').serialize();
query += "&"+$('#form1').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;
});
$("#game_id").change(function(){
$.ajax({
url: "{:U('getServers')}",
type: "post",
data: {game_id:$("#game_id option:selected").attr('game-id')},
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].id+"'>"+servers[i].server_name+"</option>"
}
$("#server_id").empty()
$("#server_id").append(str)
$("#server_id").select2()
}
}
})
})
function getIds() {
var ids = [];
$('.ids:checked').each(function() {
ids.push($(this).val());
})
return ids;
}
$('#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 webchat_chkkeysend(event)
{
if (event.keyCode==13) {
$('#submit').click();
}
}
</script>
</block>

@ -136,6 +136,17 @@
<a href="{:U('TestingResource/batches')}" class="<?=is_active_class(['TestingResource'], ['batches'])?>">测试资源申请记录</a>
</div>
<?php endif;?>
<?php if($loginer['rebate_over_perm'] == 1):?>
<div class="subNav jssubNav"><i class="prev_icon icon_fenbao"></i><span>返利管理</span><i class="arrow_icon"></i></div>
<div class="navContent jsnavContent">
<a href="{:U('GameRebate/single')}" class="<?=is_active_class(['GameRebate'], ['single'])?>">单笔充值福利</a>
<a href="{:U('GameRebate/daily')}" class="<?=is_active_class(['GameRebate'], ['daily'])?>">月卡福利发放</a>
<a href="{:U('GameRebate/accumulative')}" class="<?=is_active_class(['GameRebate'], ['accumulative'])?>">累充福利发放</a>
<a href="{:U('GameRebate/firstPay')}" class="<?=is_active_class(['GameRebate'], ['firstPay'])?>">首充福利发放</a>
<a href="{:U('GameRebate/dayAccumulative')}" class="<?=is_active_class(['GameRebate'], ['dayAccumulative'])?>">单日累充福利发放</a>
<a href="{:U('GameRebate/weekly')}" class="<?=is_active_class(['GameRebate'], ['weekly'])?>">周卡福利发放</a>
</div>
<?php endif;?>
<?php if(C('APP_ENV') == 'dev' || $company['type'] == 1):?>
<div class="subNav jssubNav"><i class="prev_icon icon_fenbao"></i><span>评级管理</span><i class="arrow_icon"></i></div>
<div class="navContent jsnavContent">

@ -166,7 +166,7 @@
<?=substr($record['provide_time'], 10)?>
</td>
<!-- <td>{$record.content}</td> -->
<td><button class="view-detail">操作</button></td>
<td><button class="view-detail">详情</button></td>
</tr>
</volist>
</empty>

@ -2910,4 +2910,12 @@ CREATE TABLE `tab_rebate_orders` (
ALTER TABLE `sys_shift_task`
ADD COLUMN `is_replenished` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已处理玩家补充迁移' AFTER `status`;
update sys_shift_task set is_replenished = 1;
update sys_shift_task set is_replenished = 1;
ALTER TABLE tab_rebate_orders add column `user_id` int(11) NOT NULL DEFAULT 0 COMMENT '用户ID' after base_game_name;
update tab_rebate_orders a left join tab_user b on a.user_account=b.account set a.user_id=b.id where b.id is not null;
ALTER TABLE tab_rebate_orders add column `current_award_date` date DEFAULT NULL COMMENT '当前返利日期' after award_ended_at;
update tab_rebate_orders set current_award_date = FROM_UNIXTIME(UNIX_TIMESTAMP(now()), '%Y-%m-%d') where type='B' and send_status=1;
ALTER TABLE tab_promote add column `rebate_over_perm` tinyint(1) not null DEFAULT 0 COMMENT '是否开启推广后台返利管理权限' after shift_over_apply;
Loading…
Cancel
Save