|
|
|
@ -196,7 +196,6 @@ class PaymentMerchantController extends ThinkController
|
|
|
|
|
$data = [];
|
|
|
|
|
$data['name'] = $name;
|
|
|
|
|
$data['account'] = $account;
|
|
|
|
|
$data['identifier'] = $identifier;
|
|
|
|
|
$data['type'] = 1;
|
|
|
|
|
$data['status'] = $status;
|
|
|
|
|
$data['ways'] = $waysValue;
|
|
|
|
@ -207,8 +206,10 @@ class PaymentMerchantController extends ThinkController
|
|
|
|
|
if ($id == 0) {
|
|
|
|
|
$data['create_time'] = time();
|
|
|
|
|
$data['channel'] = $channel;
|
|
|
|
|
$data['identifier'] = $paymentMerchantService->getIdentifierByConfig($config, $channel);
|
|
|
|
|
M('payment_merchant', 'tab_')->add($data);
|
|
|
|
|
} else {
|
|
|
|
|
$data['identifier'] = $paymentMerchantService->getIdentifierByConfig($config, $merchant['channel']);
|
|
|
|
|
M('payment_merchant', 'tab_')->where(['id' => $id])->save($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -293,11 +294,24 @@ class PaymentMerchantController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getEffectiveTimeRange($startedAt, $endedAt)
|
|
|
|
|
{
|
|
|
|
|
$start = 0;
|
|
|
|
|
$end = PaymentRuleService::FOREVER_TIME;
|
|
|
|
|
if ($startedAt != '') {
|
|
|
|
|
$start = strtotime($startedAt . ' 00:00:00');
|
|
|
|
|
}
|
|
|
|
|
if ($endedAt != '') {
|
|
|
|
|
$end = strtotime($startedAt . ' 23:59:59');
|
|
|
|
|
}
|
|
|
|
|
return [$start, $end];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
|
|
|
|
$page = I('p', 1);
|
|
|
|
|
$row = I('row', 10);
|
|
|
|
|
$companyBelong = I('compnay_belong', -1);
|
|
|
|
|
$companyBelong = I('company_belong', -1);
|
|
|
|
|
$companyId = I('company_id', 0);
|
|
|
|
|
$gameTypeId = I('game_type_id', 0);
|
|
|
|
|
$gameId = I('game_id', 0);
|
|
|
|
@ -329,12 +343,17 @@ class PaymentMerchantController extends ThinkController
|
|
|
|
|
if ($expressId != 0) {
|
|
|
|
|
$conditions['express_merchant_id'] = $expressId;
|
|
|
|
|
}
|
|
|
|
|
if ($startedAt != '') {
|
|
|
|
|
$conditions['update_time'] = ['egt', strtotime($startedAt . ' 00:00:00')];
|
|
|
|
|
}
|
|
|
|
|
if ($endedAt != '') {
|
|
|
|
|
$conditions['update_time'] = ['elt', strtotime($endedAt . ' 23:59:59')];
|
|
|
|
|
|
|
|
|
|
[$start, $end] = $this->getEffectiveTimeRange($startedAt, $endedAt);
|
|
|
|
|
// var_dump($start, $end);die();
|
|
|
|
|
$timeCondition = ' ((start_time >= ' . $start . ' AND start_time <= ' . $end . ') OR (start_time <= ' . $start . ' AND end_time >= ' . $end
|
|
|
|
|
. ') OR (end_time >= ' . $start . ' AND end_time <= ' . $end . '))';
|
|
|
|
|
if (isset($conditions['_string'])) {
|
|
|
|
|
$conditions['_string'] .= $timeCondition;
|
|
|
|
|
} else {
|
|
|
|
|
$conditions['_string'] = $timeCondition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$paymentRuleService = new PaymentRuleService();
|
|
|
|
|
$gameService = new GameService();
|
|
|
|
@ -362,7 +381,7 @@ class PaymentMerchantController extends ThinkController
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
|
$records[] = [
|
|
|
|
|
'id' => $item['id'],
|
|
|
|
|
'company_type_name' => $companyTypes[$item['company_belong']] ?? '无',
|
|
|
|
|
'company_type_name' => $companyTypes[$item['company_belong']] ?? '--',
|
|
|
|
|
'company_name' => isset($companies[$item['company_id']]) ? $companies[$item['company_id']]['company_name'] : '--',
|
|
|
|
|
'game_name' => isset($games[$item['game_id']]) ? $games[$item['game_id']]['name'] : '--',
|
|
|
|
|
'game_type_name' => isset($gameTypes[$item['game_type_id']]) ? $gameTypes[$item['game_type_id']]['type_name'] : '--',
|
|
|
|
@ -375,7 +394,6 @@ class PaymentMerchantController extends ThinkController
|
|
|
|
|
'effective_time_display' => $paymentRuleService->getEffectiveTimeDisplay($item)
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
// var_dump($records);die();
|
|
|
|
|
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
|
|
if($page) {
|
|
|
|
@ -440,9 +458,16 @@ class PaymentMerchantController extends ThinkController
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$paymentRuleService = new PaymentRuleService();
|
|
|
|
|
foreach ($records as $record) {
|
|
|
|
|
$startTime = $record['start_time'] == '' ? 0 : strtotime($record['start_time'] . ' 00:00:00');
|
|
|
|
|
$endTime = $record['end_time'] == '' ? 0 : strtotime($record['end_time'] . ' 23:59:59');
|
|
|
|
|
$endTime = $record['end_time'] == '' ? PaymentRuleService::FOREVER_TIME : strtotime($record['end_time'] . ' 23:59:59');
|
|
|
|
|
|
|
|
|
|
$repeatRules = $paymentRuleService->getTimeRepeatRules($record);
|
|
|
|
|
if (count($repeatRules)) {
|
|
|
|
|
$paymentRuleService->resetTimeRules($repeatRules, $startTime, $endTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$item = [
|
|
|
|
|
'company_belong' => $record['company_id'] > 0 ? -1 : $record['company_belong'],
|
|
|
|
|
'company_id' => $record['company_id'],
|
|
|
|
@ -465,6 +490,105 @@ class PaymentMerchantController extends ThinkController
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function editRule()
|
|
|
|
|
{
|
|
|
|
|
$id = I('id', 0);
|
|
|
|
|
$rule = M('payment_rule', 'tab_')->where(['id' => $id])->find();
|
|
|
|
|
if ($rule === null) {
|
|
|
|
|
$this->error('记录不存在');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$gameService = new GameService();
|
|
|
|
|
$gameTypes = $gameService->getGameTypes(null, 'id,type_name');
|
|
|
|
|
$games = $gameService->getBaseGames(null, 'id,name');
|
|
|
|
|
$companyBelongs = PromoteCompanyService::$belongs;
|
|
|
|
|
$companyService = new PromoteCompanyService();
|
|
|
|
|
$paymentMerchantService = new PaymentMerchantService();
|
|
|
|
|
$aliMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_ALIPAY);
|
|
|
|
|
$weixinMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_WEIXIN);
|
|
|
|
|
$expressMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_EXPRESS);
|
|
|
|
|
$companies = $companyService->getCompanies(null, 'id,company_name');
|
|
|
|
|
|
|
|
|
|
$rule ['start_time'] = $rule ['start_time'] == 0 ? '' : date('Y-m-d', $rule ['start_time']);
|
|
|
|
|
$rule ['end_time'] = $rule ['end_time'] == PaymentRuleService::FOREVER_TIME ? '' : date('Y-m-d', $rule ['end_time']);
|
|
|
|
|
|
|
|
|
|
$this->assign('aliMerchants', $aliMerchants);
|
|
|
|
|
$this->assign('weixinMerchants', $weixinMerchants);
|
|
|
|
|
$this->assign('expressMerchants', $expressMerchants);
|
|
|
|
|
$this->assign('record', $rule);
|
|
|
|
|
$this->assign('games', $games);
|
|
|
|
|
$this->assign('gameTypes', $gameTypes);
|
|
|
|
|
$this->assign('companyBelongs', $companyBelongs);
|
|
|
|
|
$this->assign('companies', $companies);
|
|
|
|
|
$this->display('ruleEditForm');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function modifyRule()
|
|
|
|
|
{
|
|
|
|
|
$params = I('post.');
|
|
|
|
|
$id = $params['id'] ?? 0;
|
|
|
|
|
if ($id == 0) {
|
|
|
|
|
$this->ajaxReturn([
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'message' => '提交数据异常'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rule = M('payment_rule', 'tab_')->where(['id' => $id])->find();
|
|
|
|
|
if ($rule === null) {
|
|
|
|
|
$this->ajaxReturn([
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'message' => '记录不存在'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$startTime = $params['start_time'] == '' ? 0 : strtotime($params['start_time'] . ' 00:00:00');
|
|
|
|
|
$endTime = $params['end_time'] == '' ? PaymentRuleService::FOREVER_TIME : strtotime($params['end_time'] . ' 23:59:59');
|
|
|
|
|
|
|
|
|
|
if (date('Ymd', $rule['start_time']) <= date('Ymd') && $startTime != $rule['start_time']) {
|
|
|
|
|
$this->ajaxReturn([
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'message' => '原开始生效时间在今日之前,不可修改'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (date('Ymd', $startTime) <= date('Ymd') && $startTime != $rule['start_time']) {
|
|
|
|
|
$this->ajaxReturn([
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'message' => '开始生效时间在今日之前,不可修改'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
if (date('Ymd', $rule['end_time']) <= date('Ymd') && $endTime != $rule['end_time']) {
|
|
|
|
|
$this->ajaxReturn([
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'message' => '原最后生效时间在今日之前,不可修改'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (date('Ymd', $endTime) <= date('Ymd') && $endTime != $rule['end_time']) {
|
|
|
|
|
$this->ajaxReturn([
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'message' => '最后生效时间在今日之前,不可修改'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$item = [
|
|
|
|
|
'alipay_merchant_id' => $params['alipay_merchant_id'],
|
|
|
|
|
'weixin_merchant_id' => $params['weixin_merchant_id'],
|
|
|
|
|
'express_merchant_id' => $params['express_merchant_id'],
|
|
|
|
|
'start_time' => $startTime,
|
|
|
|
|
'end_time' => $endTime,
|
|
|
|
|
'update_time' => time()
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
M('payment_rule', 'tab_')->where(['id' => $id])->save($item);
|
|
|
|
|
|
|
|
|
|
$this->ajaxReturn([
|
|
|
|
|
'status' => 1,
|
|
|
|
|
'message' => '修改成功'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function deleteRule()
|
|
|
|
|
{
|
|
|
|
|
$id = I('id', 0);
|
|
|
|
@ -519,6 +643,29 @@ class PaymentMerchantController extends ThinkController
|
|
|
|
|
|
|
|
|
|
public function checkRules()
|
|
|
|
|
{
|
|
|
|
|
$records = I('records', []);
|
|
|
|
|
if (count($records) == 0) {
|
|
|
|
|
$this->ajaxReturn([
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'message' => '未提交换绑数据'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$isRepat = false;
|
|
|
|
|
$paymentRuleService = new PaymentRuleService();
|
|
|
|
|
foreach ($records as $record) {
|
|
|
|
|
$rules = $paymentRuleService->getTimeRepeatRules($record);
|
|
|
|
|
if (count($rules)) {
|
|
|
|
|
$isRepat = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->ajaxReturn([
|
|
|
|
|
'status' => 1,
|
|
|
|
|
'message' => '成功',
|
|
|
|
|
'data' => [
|
|
|
|
|
'is_repeat' => $isRepat
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|