优化订单数据换绑

master
chenzhi 4 years ago
parent f670c7196a
commit 50363297e8

@ -193,6 +193,8 @@ class SubSpendController extends ThinkController
return $resarr;
}
public function addSubSpendSet(){
if(!isset($_REQUEST['time'])) $this->error("参数错误");
$time = $_REQUEST['time'];
@ -204,6 +206,13 @@ class SubSpendController extends ThinkController
$this->ajaxReturn(["status"=>0,"info"=>"固化数据任务登记错误"]);
}
}
public function changeSubSpend(){
if (IS_POST) {
$this->editSubSpend();
}else{
$this->showChooseSubSpendCount();
}
}
public function updateSubSpend(){
if(!isset($_REQUEST['begin']) || !isset($_REQUEST['end'])) $this->error("参数错误");
@ -240,6 +249,75 @@ class SubSpendController extends ThinkController
));
}
protected function editSubSpend(){
if(!isset($_REQUEST['ids']) || !isset($_REQUEST['company_id']) ) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$company_id = $_REQUEST['company_id'];
//获取会长及adminid
$promote = M("promote","tab_")->field("id,account,admin_id")->where("company_id = '{$company_id}' and level = '1' and status = '1'")->find();
$saveData = [
"promote_id"=>$promote['id'],
"promote_account"=>$promote['account'],
"market_admin_id"=>$promote['admin_id'],
];
$where = [
"id"=>['in',$ids]
];
M("spend","tab_",SUBSITE_DB)->where($where)->save($saveData);
$this->ajaxReturn([
'status' => 1,
"info"=>"换绑成功"
]);
}
protected function showChooseSubSpendCount(){
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$dbres = M("spend","tab_",SUBSITE_DB)->where("id in ({$ids})")->group("promote_id")->getField("promote_id,SUM(pay_amount) pay_amount");
//获取公司
$promoteIds = implode(",",array_keys($dbres));
$company = M("promote","tab_")
->alias('p')
->where("p.id in ({$promoteIds})")
->join("tab_promote_company c on p.company_id = c.id","left")
->group("p.company_id")
->getField("company_id,group_concat(p.id) promote_ids,c.company_name");
$sendData = [
"count" => 0,
"list"=>[]
];
foreach ($company as $k => $v) {
$v['promote_ids'] = explode(",",$v['promote_ids']);
$v['pay_amount'] = 0;
foreach($v['promote_ids'] as $promote_id){
$v['pay_amount'] += ($dbres[$promote_id]-0);
unset($dbres[$promote_id]);
}
unset($v['promote_ids'],$v['company_id']);
$sendData['count'] += $v['pay_amount'];
$sendData['list'][] = $v;
}
if(count($dbres) > 0){
$office_pay_amount = 0;
foreach ($dbres as $value) {
$office_pay_amount += ($value-0);
}
$sendData['list'][]= ["company_name"=>DEFAULT_COMPANY,"pay_amount"=>$office_pay_amount];
$sendData['count'] += $office_pay_amount;
}
//获取所有公司
$promoteCompany = M('promote_company','tab_')->field('id, company_name as name')->where(['status' => 1])->select();
$this->assign('promoteCompany', $promoteCompany);
$this->assign('data', $sendData);
$this->assign('ids', $ids);
$this->display("showChooseSubSpendCount");
}
protected function editOrderIscheck($ids,$oldval,$newval){
$dbres = M("spend","tab_",SUBSITE_DB)->where("id in ({$ids}) and is_check = '{$oldval}'")->select();
if(empty($dbres)) return false;

@ -518,6 +518,18 @@
success:callback
});
},
oepnIframe(text){
var url = "{:U('changeSubSpend')}"+"&ids="+text;
layer.open({
type: 2,
title: "海南万盟天下科技有限公司",
shadeClose: true,
shade: 0.8,
area: ['40%', '60%'],
content: url
});
// layer.closeAll("loading");
},
mainEven(){
$("#addSubSpendSet").on("click",function() {
SPENDOP.oepnHtml("新增固定订单","#addSubSpendTpl",SPENDOP.addSubSpendSetEvent);
@ -525,7 +537,22 @@
$("#updateSubSpend").on("click",function() {
SPENDOP.oepnHtml("重新固定订单","#updateSubSpendTpl",SPENDOP.updateSubSpendEvent);
});
$("#changeSubSpend").on("click",function() {
var ids= SPENDOP.getSelectIds();
if(ids){
SPENDOP.oepnIframe(ids);
}
});
},
getSelectIds(){
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
return $(elem).val();
}).get();
if(text.length < 1){
layer.msg("<font style='color:white'>请先选择需要换绑的数据</font>");
return;
}
return text.join(",");
},
addSubSpendSetEvent(){
$("#addSubSpendSubmit").off("click");
@ -622,6 +649,9 @@
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('lists')}");
function reload() {
window.location.reload();
}
$(function () {
SPENDOP.initFun();
//搜索功能

@ -0,0 +1,230 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="__CSS__/base.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/common.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/style.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/default_color.css" media="all">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<script type="text/javascript" src="__STATIC__/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<script type="text/javascript" src="__STATIC__/layer3/layer.js"></script>
<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 src="__STATIC__/juicer-min.js" type="text/javascript"></script>
</head>
<style>
html {
min-width:100%;
}
body {
max-width: 90%;
padding: 5% 0 0 5%;
}
.tabcon1711 table{
width: 480px;
}
table{
margin: auto;
}
.hidebox{
display: none;
}
.r{
width: 300px;
}
.l{
width: 180px;
}
.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;
}
.input-list, .i_list {
float: left;
margin: 0;
}
</style>
<block name="body">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" href="__CSS__/pro_promote.css" type="text/css" />
<script src="__STATIC__/jquery.form.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<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="__STATIC__/layer/extend/layer.ext.js"></script>
<link rel="stylesheet" href="__CSS__/promote.css" type="text/css"/>
<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;}
.butnbox {padding:10px 0 10px;}
.butnbox .butnlist {overflow:hidden;clear:both;}
.butnbox .butnlist .butn,.butnbox .butnlist .butn:hover {text-decoration:none;border:none;}
.butnbox .butnlist .butn {display:inline-block;width:120px;height:28px;line-height:28px;text-align:center;color:#FFF;background:#3C95C8;border-radius:3px;}
.butnbox .butnlist .butn.last {background:#009900;}
.butnbox .butnlist .butn~.butn {margin-left:20px;}
.butnbox a{
cursor:pointer
}
.data_list table tbody tr a.disabled,.data_list table tbody tr a.disabled:hover {color:#999;cursor:default;}
.data_list table td{
line-height: 2;
}
#tablebox tr{
border-bottom: 1px solid #e6e6e6;
}
</style>
<div style="font-size:14px;color:red;margin-bottom: 30px;">
说明:换绑后的数据将归属到选择的公司
</div>
<div class="cf top_nav_list">
<!-- <div class="fl button_list">
<div class="tools">
<a class=" " href="{:U('add')}"><span class="button_icon button_icon1"></span>新增推广游戏分成</a>
</div>
</div> -->
<!-- 高级搜索 -->
<div class="jssearch fl cf search_list" style="margin-bottom:12px">
<div class="input-list search-title-box">
<label>选择下游公司:</label>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="company_id" name="company_id" class="select_gallery" >
<option value="">请选择换绑公司</option>
<volist name="promoteCompany" id="vo">
<option value="{$vo.id}">{$vo.name}</option>
</volist>
</select>
</div>
<input id="ids" type="hidden" name="ids" value="{$ids}">
<div class="input-list" style="margin-left: 20px">
<a class="sch-btn" href="javascript:;" id="add_company" style="width: 100px;">确认换绑</a>
</div>
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div>所选订单统计:</div>
<div class="">
<table id="tablebox">
<!-- 表头 -->
<thead>
<tr>
<th>公司</th>
<th>金额</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<volist name="data['list']" id="vo">
<tr>
<td>{$vo.company_name}</td>
<td>{$vo.pay_amount}</td>
</tr>
</volist>
<tr>
<td>合计:</td>
<td>{$data['count']}</td>
</tr>
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
$(function(){
$("#company_id").select2();
//添加公司比例操作
$('#add_company').click(function () {
var company_id = $("#company_id").find("option:selected").val();
var ids = $("#ids").val();
if(company_id == ''){
layer.msg('请选择要换绑到的公司');
return false;
}
layer.load(2);
$.ajax({
type: 'post',
url: "{:U('changeSubSpend')}",
data:{"ids":ids,'company_id':company_id},
success: function(data) {
if(data.status == 1){
layer.msg(data.info);
setTimeout(function(){
parent.reload();
},1000)
}else{
layer.alert(data.info);
return false;
}
},
error:function(){
layer.alert("网络错误或超时");
return false;
}
});
});
});
</script>
</block>
</html>
Loading…
Cancel
Save