master
parent
dbfad2d69c
commit
a153fb9a0e
@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
namespace Admin\Controller;
|
||||
|
||||
use User\Api\UserApi as UserApi;
|
||||
use Base\Service\PresidentDepositService;
|
||||
use Base\Task\Task;
|
||||
/**
|
||||
* 市场
|
||||
*/
|
||||
class MarketController extends ThinkController
|
||||
{
|
||||
public function rebindRecords()
|
||||
{
|
||||
$page = I('p', 1);
|
||||
$row = I('row', 10);
|
||||
$companyId = I('company_id', 0);
|
||||
$promoteId = I('promote_id', 0);
|
||||
|
||||
$conditions = [];
|
||||
$promoteIds = [];
|
||||
if ($promoteId !== 0) {
|
||||
$promoteIds = [$promoteId];
|
||||
}
|
||||
if ($companyId !== 0) {
|
||||
$companyPromoteIds = M('promote', 'tab_')->field(['id'])->where(['company_id' => $companyId, 'level' => 1])->getField('id', true);
|
||||
if (count($companyPromoteIds) > 0) {
|
||||
$promoteIds = count($promoteIds) ? array_intersect($companyPromoteIds, $promoteIds) : $companyPromoteIds;
|
||||
$promoteIds[] = 0;
|
||||
} else {
|
||||
$promoteIds = [0];
|
||||
}
|
||||
}
|
||||
if (count($promoteIds)) {
|
||||
$conditions['promote_id'] = ['in', $promoteIds];
|
||||
}
|
||||
$query = M('market_shift', 'tab_')->where($conditions);
|
||||
|
||||
$countQuery = clone $query;
|
||||
$items = $query->order('id desc')->page($page, $row)->select();
|
||||
$count = $countQuery->count();
|
||||
|
||||
$recordPromotes = [];
|
||||
$recordCompanys = [];
|
||||
if (count($items) > 0) {
|
||||
$recordPromotes = M('promote', 'tab_')->field(['id', 'account', 'company_id'])->where(['id' => ['in', array_column($items, 'promote_id')]])->select();
|
||||
$recordCompanyIds = array_column($recordPromotes, 'company_id');
|
||||
if (count($recordCompanyIds) > 0) {
|
||||
$recordCompanys = M('promote_company', 'tab_')->field(['id', 'company_name', 'company_belong'])->where(['id' => ['in', $recordCompanyIds]])->select();
|
||||
}
|
||||
$adminIds = array_merge(array_column($items, 'from_id'), array_column($items, 'to_id'));
|
||||
$recordAdmins = M('ucenter_member', 'sys_')->field(['id', 'username'])->where(['id' => ['in', $adminIds]])->select();
|
||||
$recordPromotes = index_by_column('id', $recordPromotes);
|
||||
$recordCompanys = index_by_column('id', $recordCompanys);
|
||||
$recordAdmins = index_by_column('id', $recordAdmins);
|
||||
}
|
||||
|
||||
$companyTypes = [
|
||||
0 => '内团',
|
||||
1 => '外团',
|
||||
2 => '外团-分发联盟',
|
||||
3 => '无'
|
||||
];
|
||||
|
||||
$statusList = [
|
||||
0 => '待处理',
|
||||
1 => '处理成功',
|
||||
2 => '处理失败',
|
||||
];
|
||||
|
||||
$records = [];
|
||||
foreach ($items as $item) {
|
||||
$records[] = [
|
||||
'id' => $item['id'],
|
||||
'promote_account' => $recordPromotes[$item['promote_id']]['account'],
|
||||
'company_name' => $recordCompanys[$recordPromotes[$item['promote_id']]['company_id']]['company_name'],
|
||||
'company_belong' => $companyTypes[$recordCompanys[$recordPromotes[$item['promote_id']]['company_id']]['company_belong']],
|
||||
'remark' => $item['remark'],
|
||||
'from_username' => $recordAdmins[$item['from_id']]['username'],
|
||||
'to_username' => $recordAdmins[$item['to_id']]['username'],
|
||||
'split_time' => date('Y-m-d H:i:s', $item['split_time']),
|
||||
'created_time' => date('Y-m-d H:i:s', $item['created_time']),
|
||||
'status_text' => $statusList[$item['status']],
|
||||
'status' => $item['status']
|
||||
];
|
||||
}
|
||||
$companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->where(['company_belong' => ['in', [1, 2]]])->select();
|
||||
|
||||
$page = set_pagination($count, $row);
|
||||
if($page) {
|
||||
$this->assign('_page', $page);
|
||||
}
|
||||
$this->assign('records', $records);
|
||||
$this->assign('companys', $companys);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function rebind()
|
||||
{
|
||||
$this->meta_title = '新增换绑';
|
||||
$id = I('id', 0);
|
||||
$companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->where(['company_belong' => ['in', [1, 2]]])->select();
|
||||
$marketAdmins = getMarketAdmins();
|
||||
$this->assign('companys', $companys);
|
||||
$this->assign('marketAdmins', $marketAdmins);
|
||||
$this->display('rebind');
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$records = I('records', []);
|
||||
if (count($records) == 0) {
|
||||
$this->ajaxReturn([
|
||||
'status' => 0,
|
||||
'message' => '未提交换绑数据'
|
||||
]);
|
||||
}
|
||||
|
||||
$userAuth = session('user_auth');
|
||||
foreach ($records as $record) {
|
||||
$item = [
|
||||
'promote_id' => $record['promote_id'],
|
||||
'from_id' => $record['from_id'],
|
||||
'to_id' => $record['to_id'],
|
||||
'split_time' => $record['split_time'],
|
||||
'remark' => $record['remark'],
|
||||
'creator_id' => $userAuth['uid'],
|
||||
'created_time' => time()
|
||||
];
|
||||
$id = M('market_shift', 'tab_')->add($item);
|
||||
if ($id) {
|
||||
Task::add('market-shift', ['market_shift_id' => $id]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->ajaxReturn([
|
||||
'status' => 1,
|
||||
'message' => '提交成功,等待后台处理'
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$id = I('id', 0);
|
||||
M('market_shift', 'tab_')->where(['id' => $id])->delete();
|
||||
|
||||
addOperationLog([
|
||||
'op_type' => 2,
|
||||
'key' => $id,
|
||||
'op_name' => '删除市场换绑记录',
|
||||
'url' => U('Market/delete', ['id' => $id]),
|
||||
'menu' => '推广员-推广员管理-市场换绑-删除市场换绑记录'
|
||||
]);
|
||||
|
||||
$this->ajaxReturn([
|
||||
'status' => 1,
|
||||
'message' => '删除成功'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getPromotesByCompany()
|
||||
{
|
||||
$companyId = I('company_id', 0);
|
||||
$promotes = M('promote', 'tab_')->field(['id', 'account', 'admin_id'])
|
||||
->where(['level' => 1, 'company_id' => $companyId, 'admin_id' => ['gt', 0]])
|
||||
->select();
|
||||
|
||||
$marketAdmins = index_by_column('id', getMarketAdmins());
|
||||
|
||||
$records = [];
|
||||
foreach ($promotes as $promote) {
|
||||
$admin = isset($marketAdmins[$promote['admin_id']]) ? $marketAdmins[$promote['admin_id']] : null;
|
||||
$records[] = [
|
||||
'id' => $promote['id'],
|
||||
'account' => $promote['account'],
|
||||
'admin_id' => $promote['admin_id'],
|
||||
'admin_username' => $admin ? $admin['username'] : '',
|
||||
];
|
||||
}
|
||||
|
||||
$this->ajaxReturn([
|
||||
'status' => 1,
|
||||
'message' => '获取成功',
|
||||
'data' => [
|
||||
'promotes' => $records
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
@ -0,0 +1,365 @@
|
||||
<extend name="Public/base" />
|
||||
|
||||
<block name="body">
|
||||
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
|
||||
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
|
||||
<link href="__STATIC__/icons_alibaba/iconfont.css" rel="stylesheet">
|
||||
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
|
||||
<script type="text/javascript" src="__STATIC__/provincecityarea/AreaData_min.js"></script>
|
||||
<script src="__STATIC__/layer/layer.js"></script>
|
||||
<script type="text/javascript" src="__JS__/select2.min.js"></script>
|
||||
|
||||
<style>
|
||||
.tabcon1711 input.time {
|
||||
width: 150px;
|
||||
}
|
||||
#form .txt_area {
|
||||
width: 300px;
|
||||
height: 150px;
|
||||
}
|
||||
.tabcon1711 .form_unit {
|
||||
margin-left: 2px;
|
||||
}
|
||||
.tabcon1711 .mustmark {
|
||||
margin-left:-7px;
|
||||
}
|
||||
.list-ratio {
|
||||
display: table;
|
||||
}
|
||||
.list-ratio .li-ratio {
|
||||
display: flex;
|
||||
margin-bottom: 20px;
|
||||
align-items: center;
|
||||
}
|
||||
.list-ratio .li-ratio .turnover, .list-ratio .li-ratio .turnover-ratio {
|
||||
position: relative;
|
||||
}
|
||||
.list-ratio .li-ratio .turnover span, .list-ratio .li-ratio .turnover-ratio .error-message {
|
||||
color: red;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 30px;
|
||||
white-space: nowrap;
|
||||
display: none;
|
||||
}
|
||||
.iconfont-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
.iconfont-style {
|
||||
font-size: 18px;
|
||||
color: #fff;
|
||||
border-radius: 4px;
|
||||
border: 0;
|
||||
padding: 5px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.iconfont-selected {
|
||||
background-color: #0A9AF2;
|
||||
}
|
||||
.iconfont-selected:hover {
|
||||
background-color: #03a9f4;
|
||||
}
|
||||
.iconfont-unselected {
|
||||
background-color: #999;
|
||||
}
|
||||
.iconfont-unselected:hover {
|
||||
background-color: #ababab;
|
||||
}
|
||||
.tabcon1711 .submit_btn.small-btn {
|
||||
float: none;
|
||||
line-height: 25px;
|
||||
width: 50px;
|
||||
height: 25px;
|
||||
font-size: 12px;
|
||||
padding: 0px 8px 0px 0px;
|
||||
}
|
||||
</style>
|
||||
<div class="cf main-place top_nav_list navtab_list">
|
||||
<h3 class="page_title">{$meta_title}</h3>
|
||||
<!-- <p class="description_text">说明:此功是创建推广员时所需填写信息</p>-->
|
||||
</div>
|
||||
|
||||
<!-- 标签页导航 -->
|
||||
<div class="tab-wrap">
|
||||
<div class="tab-content tabcon1711">
|
||||
<!-- 表单 -->
|
||||
<form id="form" method="post" class="form-horizontal" style="margin-bottom: 40px;">
|
||||
<!-- 基础文档模型 -->
|
||||
<div id="tab1" class="tab-pane in tab1">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="l"><i class="mustmark">*</i>推广公司:</td>
|
||||
<td class="r">
|
||||
<select name="company_id" id="company-select" class="select_gallery">
|
||||
<option value="">请选择推广公司</option>
|
||||
<?php foreach($companys as $company):?>
|
||||
<option value="<?=$company['id']?>" <?php if($company['id'] == $promote['company_id']):?>selected<?php endif;?>><?=$company['company_name']?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"><i class="mustmark">*</i>会长:</td>
|
||||
<td class="r">
|
||||
<select name="promote_id" id="promote-select" class="select_gallery">
|
||||
<option value="">请选择会长</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"><i class="mustmark">*</i>原市场专员:</td>
|
||||
<td class="r">
|
||||
<span id="from-market-name" class="form_radio table_btn" style="color: red;">--</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"><i class="mustmark">*</i>新市场专员:</td>
|
||||
<td class="r">
|
||||
<select name="to_id" id="market-select" class="select_gallery">
|
||||
<option value="">请选择新市场专员</option>
|
||||
<?php foreach($marketAdmins as $admin):?>
|
||||
<option value="<?=$admin['id']?>"><?=$admin['username']?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l">订单切分时间:</td>
|
||||
<td class="r">
|
||||
<input type="text" id="split_time" name="split_time" class="time" value="" autocomplete="off" placeholder="请选择订单切分时间" style="width: 200px"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l">备注:</td>
|
||||
<td class="r">
|
||||
<textarea name="" id="remark" cols="30" rows="10"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<input type="hidden" name="id" id="id" value="{$record.id}" />
|
||||
<div class="form-item cf">
|
||||
<button class="submit_btn mlspacing" id="add-item" type="button" target-form="form-horizontal" style="margin-top: 10px;">
|
||||
新增
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="data_list">
|
||||
<div class="">
|
||||
<table id="record-table">
|
||||
<!-- 表头 -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>推广公司</th>
|
||||
<th>会长账号</th>
|
||||
<th>内外团</th>
|
||||
<th>原市场专员</th>
|
||||
<th>新市场专员</th>
|
||||
<th>订单切分时间</th>
|
||||
<th>备注</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<!-- 列表 -->
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 30px; height: 35px; width: 100%;">
|
||||
<a class="submit_btn" href="javascript:;" id="submit" style="margin: 0px auto; margin-left: 208px; ">全部提交</a>
|
||||
</div>
|
||||
</div>
|
||||
</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="Promote/lists/type/1">
|
||||
</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">
|
||||
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
|
||||
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
|
||||
<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">
|
||||
//导航高亮
|
||||
highlight_subnav("{:U('PromoteLimitRule/records')}");
|
||||
$(".select_gallery").select2();
|
||||
|
||||
$(function(){
|
||||
$('.time').datetimepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
language: "zh-CN",
|
||||
autoclose: true,
|
||||
scrollMonth: false,
|
||||
scrollTime: false,
|
||||
scrollInput: false,
|
||||
startView: 'month',
|
||||
minView:'month',
|
||||
maxView:'month',
|
||||
});
|
||||
showTab();
|
||||
var promoteIds = []
|
||||
$('#company-select').on({
|
||||
change: function() {
|
||||
var companyId = $(this).val()
|
||||
getPromotesByCompany(companyId, function(promotes) {
|
||||
var html = '<option value="">请选择会长</option>'
|
||||
for (var key in promotes) {
|
||||
html += '<option value="' +
|
||||
promotes[key].id +
|
||||
'" data-admin-id="' +
|
||||
promotes[key].admin_id +
|
||||
'" data-admin-username="' +
|
||||
promotes[key].admin_username +
|
||||
'">' + promotes[key].account + '</option>'
|
||||
}
|
||||
$('#promote-select').html(html)
|
||||
$('#promote-select').select2()
|
||||
})
|
||||
}
|
||||
})
|
||||
$('#promote-select').on({
|
||||
change: function() {
|
||||
var promoteOption = $("#promote-select option:selected");
|
||||
var fromMarketUsername = promoteOption.attr('data-admin-username')
|
||||
var fromMarketId = promoteOption.attr('data-admin-id')
|
||||
$('#from-market-name').text(fromMarketUsername)
|
||||
$('#from-market-name').attr('data-id', fromMarketId)
|
||||
}
|
||||
})
|
||||
function getPromotesByCompany(companyId, callback) {
|
||||
$.ajax({
|
||||
url: '{:U("getPromotesByCompany")}',
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
data: {company_id: companyId},
|
||||
success: function(result) {
|
||||
if (result.status == 1) {
|
||||
callback(result.data.promotes)
|
||||
} else {
|
||||
layer.msg(result.message)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
$('#add-item').on({
|
||||
click: function () {
|
||||
var companyOption = $("#company-select option:selected");
|
||||
var companyId = companyOption.val()
|
||||
var companyName = companyOption.text()
|
||||
var promoteOption = $("#promote-select option:selected");
|
||||
var promoteId = promoteOption.val()
|
||||
var promoteName = promoteOption.text()
|
||||
var marketOption = $("#market-select option:selected");
|
||||
var marketId = marketOption.val()
|
||||
var marketName = marketOption.text()
|
||||
var splitTime = $('#split_time').val()
|
||||
var remark = $('#remark').val()
|
||||
var fromId = $('#from-market-name').attr('data-id')
|
||||
if (companyId == '') {
|
||||
return layer.msg('请选择推广公司')
|
||||
}
|
||||
if (promoteId == '') {
|
||||
return layer.msg('请选择会长')
|
||||
}
|
||||
if (marketId == '') {
|
||||
return layer.msg('请新市场专员')
|
||||
}
|
||||
if (promoteIds.includes(promoteId)) {
|
||||
return layer.msg('该会长已添加')
|
||||
}
|
||||
|
||||
var data = {
|
||||
company_id: companyId,
|
||||
promote_id: promoteId,
|
||||
from_id: fromId,
|
||||
to_id: marketId,
|
||||
split_time: splitTime,
|
||||
remark: remark,
|
||||
}
|
||||
|
||||
disabledPromote(promoteId)
|
||||
promoteIds.push(promoteId)
|
||||
console.log(promoteIds)
|
||||
var html = '<tr data-post=' + JSON.stringify(data) + '><td>' + companyName + '</td>' +
|
||||
'<td class="promote-item" data-id="' + promoteId + '">' + promoteName + '</td>' +
|
||||
'<td>' + 'ssb' + '</td>' +
|
||||
'<td>' + $('#from-market-name').text() + '</td>' +
|
||||
'<td>' + marketName + '</td>' +
|
||||
'<td>' + splitTime + '</td>' +
|
||||
'<td>' + remark + '</td>' +
|
||||
'<td><a class="delete-btn">删除</a></td>' +
|
||||
'</tr>';
|
||||
$('#record-table').find('tbody').append(html);
|
||||
}
|
||||
})
|
||||
$('#record-table').on('click', '.delete-btn', function() {
|
||||
var tr = $(this).parents('tr').eq(0)
|
||||
tr.remove()
|
||||
var promoteId = tr.find('.promote-item').attr('data-id')
|
||||
var index = promoteIds.indexOf(promoteId)
|
||||
console.log(promoteId)
|
||||
console.log(index)
|
||||
if (index !== -1) {
|
||||
promoteIds.splice(index, 1)
|
||||
}
|
||||
console.log(promoteIds)
|
||||
undisabledPromote(promoteId)
|
||||
})
|
||||
|
||||
function disabledPromote(promoteId) {
|
||||
var promoteOption = $("#promote-select").children('option').each(function() {
|
||||
if ($(this).val() == promoteId) {
|
||||
$(this).attr('disabled', true)
|
||||
$('#promote-select').select2()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function undisabledPromote(promoteId) {
|
||||
var promoteOption = $("#promote-select").children('option').each(function() {
|
||||
if ($(this).val() == promoteId) {
|
||||
$(this).attr('disabled', false)
|
||||
$('#promote-select').select2()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$('#submit').click(function (e) {
|
||||
var records = []
|
||||
$('#record-table').find('tbody').children('tr').each(function() {
|
||||
records.push(JSON.parse($(this).attr('data-post')))
|
||||
})
|
||||
$.ajax({
|
||||
url: '{:U("save")}',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {records: records},
|
||||
success: function(result) {
|
||||
if (result.status == 1) {
|
||||
layer.msg(result.message)
|
||||
setTimeout(function() {
|
||||
window.location.href = '{:U("rebindRecords")}'
|
||||
}, 200)
|
||||
} else {
|
||||
layer.msg(result.message)
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</block>
|
@ -0,0 +1,241 @@
|
||||
<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"/>
|
||||
<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;
|
||||
}
|
||||
</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">
|
||||
<h3 class="page_title">市场换绑</h3>
|
||||
</div>
|
||||
<div class="cf top_nav_list">
|
||||
<!-- 高级搜索 -->
|
||||
<div class="jssearch fl 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="company_select" name="company_id" class="select_gallery" style="width:200px;">
|
||||
<option value="">请选择公司</option>
|
||||
<?php foreach($companys as $company):?>
|
||||
<option value="<?=$company['id']?>"><?=$company['company_name']?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-list input-list-promote search_label_rehab">
|
||||
<select id="promote-select" name="promote_id" class="select_gallery" style="width:120px;">
|
||||
<option value="">请选择会长</option>
|
||||
<volist name=":get_promote_list_by_id()" id="vo">
|
||||
<option value="{$vo.id}">{$vo.account}</option>
|
||||
</volist>
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-list">
|
||||
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Market/rebind')}">搜索</a>
|
||||
<a class="sch-btn" href="{:U('Market/rebind')}">添加</a>
|
||||
<!-- <a class="sch-btn" href="javascript:;" id="batch-delete-btn">删除</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="data_list">
|
||||
<div class="">
|
||||
<table>
|
||||
<!-- 表头 -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>推广公司</th>
|
||||
<th>会长账号</th>
|
||||
<th>内外团</th>
|
||||
<th>原市场专员</th>
|
||||
<th>新市场专员</th>
|
||||
<th>备注</th>
|
||||
<th>订单切分时间</th>
|
||||
<th>状态</th>
|
||||
<th>换绑操作时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<!-- 列表 -->
|
||||
<tbody>
|
||||
<empty name ="records">
|
||||
<td colspan="14" class="text-center">aOh! 暂时还没有内容!</td>
|
||||
<else />
|
||||
<volist name="records" id="data">
|
||||
<tr data-id="<?=$data['id']?>">
|
||||
<td>{$data.company_name}</td>
|
||||
<td>{$data.promote_account}</td>
|
||||
<td>{$data.company_belong}</td>
|
||||
<td>{$data.from_username}</td>
|
||||
<td>{$data.to_username}</td>
|
||||
<td>{$data.remark}</td>
|
||||
<td>{$data.split_time}</td>
|
||||
<td>{$data.status_text}</td>
|
||||
<td>{$data.created_time}</td>
|
||||
<td>
|
||||
<div class="partakebtn">
|
||||
<a class="delete-btn">删除</a>
|
||||
</div>
|
||||
</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('PromoteLimitRule/records')}");
|
||||
$(function(){
|
||||
//搜索功能
|
||||
$("#search").click(function(){
|
||||
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();
|
||||
}
|
||||
})
|
||||
$('#batch-delete-btn').on({
|
||||
click: function() {
|
||||
var ids = getIds();
|
||||
$.ajax({
|
||||
url: '{:U("batchDelete")}',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {ids: ids},
|
||||
success: function(result) {
|
||||
if (result.status == 1) {
|
||||
layer.msg(result.message)
|
||||
setTimeout(function() {
|
||||
window.location.href = window.location.href
|
||||
}, 200)
|
||||
} else {
|
||||
layer.msg(result.message)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
function getIds() {
|
||||
var ids = [];
|
||||
$('.ids:checked').each(function() {
|
||||
ids.push($(this).val());
|
||||
})
|
||||
return ids;
|
||||
}
|
||||
$('.delete-btn').on({
|
||||
click: function() {
|
||||
var id = $(this).parents('tr').eq(0).attr('data-id');
|
||||
$.ajax({
|
||||
url: '{:U("delete")}',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {id: id},
|
||||
success: function(result) {
|
||||
if (result.status == 1) {
|
||||
layer.msg(result.message)
|
||||
setTimeout(function() {
|
||||
window.location.href = window.location.href
|
||||
}, 200)
|
||||
} else {
|
||||
layer.msg(result.message)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
/* $(".export-btn").on("click",function(e){
|
||||
e.preventDefault();
|
||||
window.location.href=$(this).attr("href")
|
||||
}) */
|
||||
</script>
|
||||
</block>
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
namespace Base\Service;
|
||||
|
||||
use Base\Facade\Request;
|
||||
|
||||
class MarketService
|
||||
{
|
||||
public function shift($marketShift)
|
||||
{
|
||||
$formId = $marketShift['form_id'];
|
||||
$promoteId = $marketShift['promote_id'];
|
||||
$toId = $marketShift['to_id'];
|
||||
$time = $marketShift['split_time'] == 0 ? null : $marketShift['split_time'];
|
||||
|
||||
$promote = M('promote', 'tab_')->field(['chain', 'id', 'level', 'admin_id'])->where(['id' => $promoteId, 'admin_id' => $formId])->find();
|
||||
|
||||
if (!$promote) {
|
||||
throw new \Exception('会长不存在');
|
||||
}
|
||||
if ($promote['level'] != 1) {
|
||||
throw new \Exception('该账号非会长');
|
||||
}
|
||||
$promotes = (new PromoteService)->getAllChildren($promote, 0, ['id']);
|
||||
$promoteIds = [$promote['id']];
|
||||
$promoteIds = array_merge(array_column($promotes, 'id'), $promoteIds);
|
||||
|
||||
$this->shiftPromote($formId, $toId);
|
||||
$this->shiftSpend($promoteIds, $formId, $toId, $time);
|
||||
$this->shiftDeposit($promoteIds, $formId, $toId, $time);
|
||||
}
|
||||
|
||||
private function shiftPromote($promoteId, $formId, $toId, $time = null)
|
||||
{
|
||||
$map = [];
|
||||
$map['id'] = $promoteId;
|
||||
M('promote', 'tab_')->where($map)->save(['admin_id' => $toId]);
|
||||
}
|
||||
|
||||
private function shiftSpend($promoteIds, $formId, $toId, $time = null)
|
||||
{
|
||||
$map = [];
|
||||
$map['promote_id'] = ['in', $promoteIds];
|
||||
$map['market_admin_id'] = $formId;
|
||||
if ($time) {
|
||||
$map['pay_time'] = ['egt', $time];
|
||||
}
|
||||
|
||||
$count = M('spend', 'tab_')->where($map)->count();
|
||||
$limit = 50;
|
||||
$pageCount = ceil($count/$limit);
|
||||
for ($page = 0; $page <= $pageCount; $page ++) {
|
||||
M('spend', 'tab_')->where($map)->limit($limit)->save(['market_admin_id' => $toId]);
|
||||
}
|
||||
M('spend', 'tab_')->where($map)->save(['market_admin_id' => $toId]);
|
||||
}
|
||||
|
||||
private function shiftDeposit($promoteIds, $formId, $toId, $time = null)
|
||||
{
|
||||
$map = [];
|
||||
$map['promote_id'] = ['in', $promoteIds];
|
||||
$map['market_admin_id'] = $formId;
|
||||
if ($time) {
|
||||
$map['create_time'] = ['egt', $time];
|
||||
}
|
||||
|
||||
$count = M('deposit', 'tab_')->where($map)->count();
|
||||
$limit = 50;
|
||||
$pageCount = ceil($count/$limit);
|
||||
for ($page = 0; $page <= $pageCount; $page ++) {
|
||||
M('deposit', 'tab_')->where($map)->limit($limit)->save(['market_admin_id' => $toId]);
|
||||
}
|
||||
M('deposit', 'tab_')->where($map)->save(['market_admin_id' => $toId]);
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Base\Service;
|
||||
|
||||
use Base\Facade\Request;
|
||||
|
||||
class PaymentService
|
||||
{
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Base\Task;
|
||||
|
||||
/**
|
||||
* 任务基类
|
||||
* @author elf<360197197@qq.com>
|
||||
*/
|
||||
class BaseTask
|
||||
{
|
||||
public $params;
|
||||
|
||||
public function __construct($params = [])
|
||||
{
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Base\Task;
|
||||
|
||||
use Base\Service\MarketService;
|
||||
|
||||
/**
|
||||
* 任务处理
|
||||
* @author elf<360197197@qq.com>
|
||||
*/
|
||||
class MarketShiftTask extends BaseTask
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$id = $this->params['market_shift_id'];
|
||||
$record = M('market_shift', 'tab_')->where(['id' => $id])->find();
|
||||
if (!$record) {
|
||||
throw new \Exception('换绑记录不存在');
|
||||
}
|
||||
if ($record['status'] != 0) {
|
||||
throw new \Exception('换绑记录状态错误');
|
||||
}
|
||||
try {
|
||||
$marketService = new MarketService();
|
||||
$marketService->shift($record);
|
||||
M('market_shift', 'tab_')->where(['id' => $id])->save(['status' => 1]);
|
||||
} catch (\Exception $e) {
|
||||
M('market_shift', 'tab_')->where(['id' => $id])->save(['status' => 2]);
|
||||
throw new \Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace Base\Task;
|
||||
|
||||
/**
|
||||
* 任务处理
|
||||
* @author elf<360197197@qq.com>
|
||||
*/
|
||||
class Task
|
||||
{
|
||||
public static $types = [
|
||||
'market-shift' => '\Base\Task\MarketShiftTask',
|
||||
];
|
||||
|
||||
public $type;
|
||||
public $tasks;
|
||||
|
||||
public function __construct($type = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function run($count = 1)
|
||||
{
|
||||
$map = ['status' => 0];
|
||||
if ($this->type !== null) {
|
||||
$map['type'] = $this->type;
|
||||
}
|
||||
$this->tasks = M('tasks', 'tab_')->where($map)->limit($count)->select();
|
||||
if (count($this->tasks) == 0) {
|
||||
throw new \Exception('暂无任务');
|
||||
}
|
||||
|
||||
$this->updateTasks(['status' => 1, 'start_time' => time()]);
|
||||
|
||||
foreach ($this->tasks as $task) {
|
||||
$class = $this->getTypeClass($task);
|
||||
if (is_null($class) || !class_exists($class)) {
|
||||
$this->updateTask($task, ['status' => 3, 'end_time' => time(), 'result' => '任务处理类不存在']);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$params = json_decode($task['params'], true);
|
||||
$obj = new $class($params);
|
||||
$obj->run();
|
||||
$this->updateTask($task, ['status' => 2, 'end_time' => time(), 'result' => '处理成功']);
|
||||
} catch (\Exception $e) {
|
||||
$this->updateTask($task, ['status' => 3, 'end_time' => time(), 'result' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTypeClass($task)
|
||||
{
|
||||
if (!isset(self::$types[$task['type']])) {
|
||||
return null;
|
||||
}
|
||||
return self::$types[$task['type']];
|
||||
}
|
||||
|
||||
private function updateTask($task, $data)
|
||||
{
|
||||
M('tasks', 'tab_')->where(['id' => $task['id']])->save($data);
|
||||
}
|
||||
|
||||
private function updateTasks($data)
|
||||
{
|
||||
$ids = array_column($this->tasks, 'id');
|
||||
M('tasks', 'tab_')->where(['id' => ['in', $ids]])->save($data);
|
||||
}
|
||||
|
||||
public static function add($type, $params = [])
|
||||
{
|
||||
if (!isset(self::$types[$type])) {
|
||||
return false;
|
||||
}
|
||||
$record = [
|
||||
'type' => $type,
|
||||
'params' => json_encode($params),
|
||||
'created_time' => time()
|
||||
];
|
||||
return M('tasks', 'tab_')->add($record);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Base\Tool;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class ServiceClient
|
||||
{
|
||||
const SUCCESS = '0000';
|
||||
|
||||
protected $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = new Client([
|
||||
'base_uri' => C('SERVICE_URL'),
|
||||
'timeout' => 10.0,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function post($uri, $data)
|
||||
{
|
||||
$response = $this->client->post($uri, [
|
||||
'verify' => false,
|
||||
'form_params' => $data
|
||||
]);
|
||||
$result = (string)$response->getBody();
|
||||
return json_decode($result, true);
|
||||
}
|
||||
|
||||
public function sendSmsCode(string $mobile, string $clientIp)
|
||||
{
|
||||
$options = ['type' => 'code', 'client_ip' => $clientIp];
|
||||
return $this->sendSms($mobile, $options);
|
||||
}
|
||||
|
||||
public function sendSmsContent(string $mobile, string $content)
|
||||
{
|
||||
$options = ['type' => 'content', 'content' => $content];
|
||||
return $this->sendSms($mobile, $options);
|
||||
}
|
||||
|
||||
public function sendSmsBatch(array $mobiles, string $content)
|
||||
{
|
||||
$options = ['type' => 'batch', 'content' => $content];
|
||||
return $this->sendSms($mobiles, $options);
|
||||
}
|
||||
|
||||
private function sendSms($mobile, array $options)
|
||||
{
|
||||
return $this->post('/message/sms-send', ['mobile' => $mobile, 'options' => $options]);
|
||||
}
|
||||
|
||||
public function checkSms($mobile, $code)
|
||||
{
|
||||
return $this->post('/message/sms-check', ['mobile' => $mobile, 'code' => $code]);
|
||||
}
|
||||
|
||||
public function registerEvent($userId, $source)
|
||||
{
|
||||
return $this->post('/game-event/register', ['user_id' => $userId, 'source' => $source]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue