master
parent
55c1b393e1
commit
8440c5d384
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
namespace Base\Service;
|
||||
|
||||
class MendService
|
||||
{
|
||||
public static $statusList = [
|
||||
0 => '处理中',
|
||||
1 => '处理成功',
|
||||
2 => '处理失败',
|
||||
];
|
||||
|
||||
public function getStatusText($status)
|
||||
{
|
||||
return self::$statusList[$status] ?? '未知';
|
||||
}
|
||||
|
||||
public function addMendTask($params, $handlePromote = null)
|
||||
{
|
||||
$userId = $params['user_id'] ?? 0;
|
||||
$remark = $params['remark'] ?? '';
|
||||
$orderTime = $params['order_time'] ?? '';
|
||||
$toPromoteId = $params['promote_id_to'] ?? '';
|
||||
|
||||
$promoteService = new PromoteService();
|
||||
if ($toPromoteId == -1) {
|
||||
$toPromoteId = 0;
|
||||
}
|
||||
if ($toPromoteId === '') {
|
||||
throw new \Exception('请选择需要变更的渠道');
|
||||
}
|
||||
|
||||
$user = M('user', 'tab_')->where(['id' => $userId])->find();
|
||||
if (!$user) {
|
||||
throw new \Exception('用户不存在');
|
||||
}
|
||||
if ($user['promote_id'] == $toPromoteId) {
|
||||
throw new \Exception('没有变更数据');
|
||||
}
|
||||
if ($orderTime == '') {
|
||||
throw new \Exception('没有订单日期');
|
||||
}
|
||||
|
||||
if ($this->checkOrderTime(strtotime($orderTime))) {
|
||||
throw new \Exception('仅能补链本周数据,请重新选择补链时间');
|
||||
}
|
||||
|
||||
if ($this->checkPromote(strtotime($orderTime), $user['account'])) {
|
||||
throw new \Exception('在订单日期内含有多个推广员,无法补链');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'from_promote_id' => $user['promote_id'],
|
||||
'to_promote_id' => $toPromoteId,
|
||||
'order_time' => $orderTime,
|
||||
'type' => 2,
|
||||
'shift_ids' => [$userId],
|
||||
'creator_type' => $handlePromote ? 1 : 0,
|
||||
'creator_id' => $handlePromote ? $handlePromote['id'] : $_SESSION["onethink_admin"]["user_auth"]["uid"]
|
||||
];
|
||||
|
||||
if(!empty($params['remark'])){
|
||||
$data['remark'] = $params['remark'];
|
||||
}
|
||||
|
||||
$result = $promoteService->addShiftTask($data);
|
||||
if (!$result['status']) {
|
||||
throw new \Exception($result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
private function checkOrderTime($orderTime)
|
||||
{
|
||||
$sdefaultDate = date('Y-m-d');
|
||||
$first = 1; //周一开始
|
||||
$w = date('w',strtotime($sdefaultDate));
|
||||
$checktime = strtotime("$sdefaultDate -" . ($w ? $w - $first : 6) .' days'); //本周开始时间
|
||||
if($orderTime >= $checktime){
|
||||
//在本周允许换绑
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkPromote($orderTime, $account)
|
||||
{
|
||||
$res = M('Spend','tab_')->field('promote_id')->where(['pay_time' => array('EGT', $orderTime), 'user_account' => $account])->group('promote_id')->select();
|
||||
if(count($res)>1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Home\Controller;
|
||||
|
||||
use Base\Service\MendService;
|
||||
use Base\Service\PromoteService;
|
||||
|
||||
/**
|
||||
* 补链控制器
|
||||
*/
|
||||
class MendController extends BaseController
|
||||
{
|
||||
|
||||
protected function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$page = intval(I('p', 1));
|
||||
$row = intval(I('row', 10));
|
||||
$params = I('get.');
|
||||
$loginer = $this->getLoginPromote();
|
||||
|
||||
$map = ['op_type' => 1, '_string' => '1=1'];
|
||||
if(isset($params['account'])) {
|
||||
$map['user_account']= ['like', '%' . $params['account'] . '%'];
|
||||
}
|
||||
if(!empty($params['promote_id'])) {
|
||||
$map['promote_id']= $params['promote_id'];
|
||||
}
|
||||
if(!empty($params['promote_id_to'])) {
|
||||
$map['promote_id_to'] = $params['promote_id_to'];
|
||||
}
|
||||
if(!empty($params['op_id'])) {
|
||||
$map['op_id'] = $params['op_id'];
|
||||
}
|
||||
if (!empty($params['time_start'])) {
|
||||
$map['order_time'] = ['egt', strtotime($params['time_start'])];
|
||||
}
|
||||
if (!empty($params['time_end'])) {
|
||||
$map['order_time'] = ['elt', strtotime($params['time_end']) + 86399];
|
||||
}
|
||||
|
||||
$promoteService = new PromoteService();
|
||||
$subInSql = $promoteService->subInSql($loginer);
|
||||
$map['_string'] .= ' and (promote_id in (' . $subInSql . ') or promote_id_to in (' . $subInSql . '))';
|
||||
|
||||
$records = M('mend', 'tab_')->where($map)->order('create_time desc')->page($page, $row)->select();
|
||||
$count = M('mend', 'tab_')->where($map)->count();
|
||||
|
||||
$mendService = new MendService();
|
||||
foreach ($records as $key => $record) {
|
||||
$record['status_text'] = $mendService->getStatusText($record['status']);
|
||||
$records[$key] = $record;
|
||||
}
|
||||
|
||||
|
||||
$page = set_pagination($count, $row, $params);
|
||||
if ($page) {
|
||||
$this->assign('_page', $page);
|
||||
}
|
||||
|
||||
$levelColumn = 'level'. $loginer['level'] . '_id';
|
||||
$promotes = M('promote', 'tab_')->field(['id', 'account'])->where([$levelColumn => $loginer['id']])->select();
|
||||
|
||||
$this->assign('promotes', $promotes);
|
||||
$this->assign('count', $count);
|
||||
$this->assign('records', $records);
|
||||
$this->meta_title = '补链记录';
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$userId = I('user_id', 0);
|
||||
$user = M('user', 'tab_')->where(['id' => $userId])->find();
|
||||
if (!$user) {
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
|
||||
$loginer = $this->getLoginPromote();
|
||||
$levelColumn = 'level'. $loginer['level'] . '_id';
|
||||
$promote = M('promote', 'tab_')->where(['id' => $user['promote_id']])->where([$levelColumn => $loginer['id']])->find();
|
||||
if (!$promote) {
|
||||
return $this->error('所属推广员异常');
|
||||
}
|
||||
|
||||
$promotes = M('promote', 'tab_')->field(['id', 'account'])->where([$levelColumn => $loginer['id']])->select();
|
||||
|
||||
$this->meta_title = '玩家补链';
|
||||
$this->assign('user', $user);
|
||||
$this->assign('promotes', $promotes);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$params = I('post.');
|
||||
$loginer = $this->getLoginPromote();
|
||||
$service = new MendService();
|
||||
try {
|
||||
$service->addMendTask($params, $loginer);
|
||||
$this->ajaxReturn(['status' => 1, 'msg' => '补链申请成功']);
|
||||
} catch (\Exception $e) {
|
||||
$this->ajaxReturn(['status' => 0, 'msg' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
<extend name="Public/promote_base"/>
|
||||
<block name="css">
|
||||
<link href="__CSS__/20180207/platform.css" rel="stylesheet">
|
||||
<style>
|
||||
.trunk-list .table3 {width: 100%;}
|
||||
.table3 tr td{border: 1px solid #E0E7EF;}
|
||||
.pagenation{line-height: 6.5vh;}
|
||||
.pagenation>div {text-align: right;}
|
||||
.trunk-list .table3 tr {height: 4.2vh;}
|
||||
|
||||
.table_scroll {width:100%;table-layout:fixed;}
|
||||
.table_scroll tr td {border:none;border-right:1px solid #E0E7EF;}
|
||||
.table_scroll tr td:last-child{border-right:none;}
|
||||
.table_scroll tr+tr td {border-top:1px solid #E0E7EF;}
|
||||
.btn {cursor: pointer;}
|
||||
</style>
|
||||
</block>
|
||||
|
||||
<block name="body">
|
||||
<div class="page-search normal_list promoteCoin-shift-search">
|
||||
<div class="trunk-title">
|
||||
<div class="location">
|
||||
<div class="location-container">当前位置:<span>数据管理></span><span>玩家补链</span></div>
|
||||
</div>
|
||||
<img src="__IMG__/20180207/icon_normal_yve.png"><span class="title_main">玩家补链</span>
|
||||
</div>
|
||||
<div class="trunk-content article">
|
||||
<div class="trunk-list" style="padding-top:33px;">
|
||||
<form id="form" action="{:U('save')}" method="post">
|
||||
<input type="hidden" name="user_id" value="<?=$user['id']?>">
|
||||
<table class="table2">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="l"><span class="req">*</span>用户账号:</td>
|
||||
<td class="r">
|
||||
<input type="text" class="name txt" disabled value="<?=getHideAccount($user['account'])?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"><span class="req">*</span>修改前推广员:</td>
|
||||
<td class="r">
|
||||
<input type="text" class="name txt" disabled value="<?=$user['promote_account']?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"><span class="req">*</span>补链后推广员:</td>
|
||||
<td class="r">
|
||||
<select name="promote_id_to" class="reselect select_gallery" style="width: 220px;" >
|
||||
<option value="">请选择推广账号</option>
|
||||
<?php foreach($promotes as $promote):?>
|
||||
<option value="<?=$promote['id']?>"><?=$promote['account']?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"><span class="req">*</span>订单日期:</td>
|
||||
<td class="r">
|
||||
<input id="shift-order-time" type="text" autocomplete="off" class="name txt" name="order_time" placeholder="订单日期"" value="" style="width: 199px;">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l">备注:</td>
|
||||
<td class="r">
|
||||
<textarea name="remark" id="" cols="30" rows="10" class="name txt" style="padding: 10px"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"></td>
|
||||
<td class="r">
|
||||
<button type="button" class="tjbnt btn" onclick="check()" >确认</button>
|
||||
<button type="button" style="background: #E5E5E5; color: #8B8CA0;" class="tjbnt btn" onclick="window.history.back();" >返回</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</block>
|
||||
<block name="script">
|
||||
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js" ></script>
|
||||
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
|
||||
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
|
||||
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
|
||||
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
|
||||
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#promote_id").change();
|
||||
$("#promote_child").change();
|
||||
$(".select_gallery").select2();
|
||||
|
||||
$('#shift-order-time').datetimepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
language:"zh-CN",
|
||||
minView:2,
|
||||
autoclose:true,
|
||||
scrollMonth:false,
|
||||
scrollTime:false,
|
||||
scrollInput:false
|
||||
})
|
||||
});
|
||||
|
||||
function addParamsToUrl(url, params)
|
||||
{
|
||||
var pos = url.indexOf('.html')
|
||||
url = url.substring(0, pos)
|
||||
for (var i in params) {
|
||||
url += '/' + i + '/' + params[i]
|
||||
}
|
||||
url += '.html'
|
||||
return url
|
||||
}
|
||||
|
||||
function submit() {
|
||||
var userId = $('[name=user_id]').val()
|
||||
var toPromoteId = $('[name=promote_id_to]').val()
|
||||
var remark = $('[name=remark]').val()
|
||||
var orderTime = $('[name=order_time]').val()
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url:"{:U('save')}",
|
||||
data: {
|
||||
user_id: userId,
|
||||
remark: remark,
|
||||
promote_id_to: toPromoteId,
|
||||
order_time: orderTime,
|
||||
},
|
||||
success:function(res){
|
||||
if(res.status==1){
|
||||
layer.msg(res.msg);
|
||||
setTimeout(function(){
|
||||
window.location.href = "{:U('Query/userRoles')}";
|
||||
}, 1500);
|
||||
} else {
|
||||
layer.msg(res.msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function check() {
|
||||
data = validation();
|
||||
if (data.status != 1) {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
return false;
|
||||
} else {
|
||||
submit();
|
||||
}
|
||||
}
|
||||
|
||||
function validation() {
|
||||
var json_data = "";
|
||||
var limits = parseInt("{$loginer['balance_coin']|default=0}");
|
||||
if ($('[name=promote_id_to]').val() == '') {
|
||||
return json_data = {'status': 0, 'msg': '请选择补链后推广员'}
|
||||
}
|
||||
if ($('#shift-order-time').val() == '') {
|
||||
return json_data = {'status': 0, 'msg': '请选择订单日期'}
|
||||
}
|
||||
return json_data = {'status': 1, 'msg': '成功'};
|
||||
}
|
||||
</script>
|
||||
</block>
|
@ -0,0 +1,179 @@
|
||||
<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">
|
||||
<link href="__STATIC__/icons_alibaba/iconfont.css?v=1.2" rel="stylesheet">
|
||||
</block>
|
||||
|
||||
<block name="body">
|
||||
<div class="page-search normal_list query-register-search jssearch" style="font-size: small;">
|
||||
<div class="trunk-title">
|
||||
<div class="location">
|
||||
<div class="location-container">当前位置:<span>数据管理></span><span>补链记录</span></div>
|
||||
</div>
|
||||
<img src="__IMG__/20180207/icon_zhuce.png">
|
||||
<span class="title_main">补链记录</span>
|
||||
</div>
|
||||
<div class="trunk-content article">
|
||||
<div class="trunk-search clearfix">
|
||||
<!-- <form action="{:U('Query/viewRole',array('row'=>I('get.row'),'id'=>I('get.id')))}" method="post" enctype="multipart/form-data">-->
|
||||
<div class="form-group normal_space fl">
|
||||
<input type="text" name="account" class="txt normal_txt" placeholder="请输入玩家账号"
|
||||
value="{:I('account')}">
|
||||
</div>
|
||||
<div class="form-group normal_space fl">
|
||||
<select id="promote_id" name="promote_id" class="reselect select_gallery">
|
||||
<option value="">补链前推广员</option>
|
||||
<volist name="promotes" id="vo">
|
||||
<option value="{$vo.id}" title="{$vo.account}">{$vo.account}</option>
|
||||
</volist>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group normal_space fl">
|
||||
<select id="promote_id_to" name="promote_id_to" class="reselect select_gallery">
|
||||
<option value="">补链后推广员</option>
|
||||
<volist name="promotes" id="vo">
|
||||
<option value="{$vo.id}" title="{$vo.account}">{$vo.account}</option>
|
||||
</volist>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group normal_space fl">
|
||||
<select id="op_id" name="op_id" class="reselect select_gallery">
|
||||
<option value="">操作人员</option>
|
||||
<volist name="promotes" id="vo">
|
||||
<option value="{$vo.id}" title="{$vo.account}">{$vo.account}</option>
|
||||
</volist>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group normal_space fl">
|
||||
<label class="form-title select-title" style="position: relative;">起止时间:</label>
|
||||
<div class="select-time">
|
||||
<input type="text" id="sdate" class="txt" name="time_start" placeholder="开始时间" value="{:I('time_start')}">
|
||||
</div>
|
||||
<label class="form-title select-title zhi_color"> — </label>
|
||||
<div class="select-time">
|
||||
<input type="text" id="edate" class="txt" name="time_end" placeholder="结束时间" value="{:I('time_end')}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group normal_space fl">
|
||||
<input type="submit" class="submit" id='submit' url="{:U('Mend/index',array('model'=>$model['name']),false)}"
|
||||
value="查询">
|
||||
</div>
|
||||
<!-- </form>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-list query-register-list">
|
||||
<div class="trunk-content article">
|
||||
<div class="trunk-list list_normal" style="">
|
||||
<table class="table normal_table">
|
||||
<tr class="odd">
|
||||
<th>玩家账号</th>
|
||||
<th>补链前推广账号</th>
|
||||
<th>补链前归属金额</th>
|
||||
<th>补链后推广账号</th>
|
||||
<th>备注</th>
|
||||
<th>切分时间</th>
|
||||
<th>补链时间</th>
|
||||
<th>状态</th>
|
||||
<th>操作人员</th>
|
||||
</tr>
|
||||
<empty name="records">
|
||||
<tr class="num2">
|
||||
<td colspan="7" 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="vo">
|
||||
<tr class="num2">
|
||||
<td><?=getHideAccount($vo['user_account'])?></td>
|
||||
<td>{$vo.promote_account}</td>
|
||||
<td>{$vo.pay_amount}</td>
|
||||
<td>{$vo.promote_account_to}</td>
|
||||
<td>{$vo.remark}</td>
|
||||
<td>{$vo.order_time|date='Y-m-d H:i:s',###}</td>
|
||||
<td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
|
||||
<td>{$vo.status_text}</td>
|
||||
<td>{$vo.op_account}</td>
|
||||
</tr>
|
||||
</volist>
|
||||
</empty>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagenation clearfix">
|
||||
{$_page}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</block>
|
||||
<block name="script">
|
||||
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
|
||||
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
|
||||
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
|
||||
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
|
||||
charset="UTF-8"></script>
|
||||
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$().ready(function () {
|
||||
setValue('promote_id', {$Think.request.promote_id |default = '""'});
|
||||
setValue('promote_id_to', {$Think.request.promote_id_to |default = '""'});
|
||||
setValue('op_id', {$Think.request.op_id |default = '""'});
|
||||
setValue('row', '{:I("get.row",10)}');
|
||||
|
||||
var date = "{$setdate}";
|
||||
$('#sdate').datetimepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
language: "zh-CN",
|
||||
minView: 2,
|
||||
autoclose: true,
|
||||
scrollMonth: false,
|
||||
scrollTime: false,
|
||||
scrollInput: false,
|
||||
endDate: date
|
||||
});
|
||||
|
||||
$('#edate').datetimepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
language: "zh-CN",
|
||||
minView: 2,
|
||||
autoclose: true,
|
||||
pickerPosition: 'bottom-left',
|
||||
scrollMonth: false,
|
||||
scrollTime: false,
|
||||
scrollInput: false,
|
||||
endDate: date
|
||||
});
|
||||
|
||||
$(".select_gallery").select2();
|
||||
|
||||
$('#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');
|
||||
console.log(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;
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</block>
|
Loading…
Reference in New Issue