生成个人结算单的功能完成

master
zhengyongxing 5 years ago
parent e497fb16ee
commit 955a1917b3

@ -2008,8 +2008,9 @@ function getWithdrawNumber() {
$data = M('withdraw',"tab_") $data = M('withdraw',"tab_")
->field("widthdraw_number") ->field("widthdraw_number")
->join('left join tab_promote_belong on tab_withdraw.promote_id=tab_promote_belong.promote_id')
->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field") ->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field")
->where("ext_field is null") ->where("ext_field is null and tab_promote_belong.company_type!=2")
->select(); ->select();
return $data; return $data;

@ -374,11 +374,38 @@ class StatementMangementController extends ThinkController
->where($withdrawMap) ->where($withdrawMap)
->select(); ->select();
$statement = M('statement','tab_')
->field('ext_field')
->where(['ext_field'=>['like','%,%']])
->select();
$withdrawData = [];
foreach($statement as $key => $value) {
$handleData = explode(',',$value['ext_field']);
foreach ($handleData as $hk => $hv) {
array_push($withdrawData,$hv);
}
}
foreach ($data as $key => $value) {
$data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']);
$data[$key]['settlement_end_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_end_time']);
if (in_array($value['widthdraw_number'],$withdrawData)) {
unset($data[$key]);
}
}
$this->assign('withdraw_data',$data); $this->assign('withdraw_data',$data);
} }
if ($_REQUEST['withdraw']) { if ($_REQUEST['withdraw']&&$data) {
$map = []; $map = [];
@ -497,8 +524,272 @@ class StatementMangementController extends ThinkController
public function savePersonOrder() { public function savePersonOrder() {
// dump($_POST);
$data['statement_info'] = $_POST['statement_info'];
$data['first_party_info'] = json_encode([]);
$data['second_party_info'] = $_POST['second_party_info'];
$data['statement_begin_time'] = strtotime($_POST['time_start']);
$data['statement_end_time'] = strtotime($_POST['time_end']);
$data['create_time'] = time();
$data['statement_money'] = 0;
$data['pay_amount'] = 0;
$data['ext_field'] = '';
$data['company_name'] = '个人结账单';
$data['statement_type'] = 2;
if($data['second_party_info'] == '[]' || $data['statement_info'] == '[]') {
$this->ajaxReturn(['status'=>1,'msg'=>'数据错误']);
}
$statement_info = json_decode($data['statement_info'],true);
foreach($statement_info as $key => $value) {
$data['statement_money'] += $value['sum_amount'];
$data['pay_amount'] += $value['real_amount'];
}
$second_party_info = json_decode($data['second_party_info'],true);
foreach($second_party_info as $key => $value) {
$data['ext_field'] = $data['ext_field'].$value['widthdraw_number'].',';
}
$is_exist = M('statement','tab_')->where(['ext_field'=>$data['ext_field'],'statement_type'=>2])->find();
if ($is_exist) {
$this->ajaxReturn(['status'=>0,'msg'=>'请勿重复添加']);
}
$is_save = M('statement','tab_')->add($data);
if ($is_save) {
$this->ajaxReturn(['status'=>1,'msg'=>'生成成功']);
} else {
$this->ajaxReturn(['status'=>0,'msg'=>'生成失败']);
}
}
public function PersonOrderEdit() {
if ($_REQUEST['time_start'] || $_REQUEST['time_end'] ) {
$withdrawMap = [];
if ($_REQUEST['time_start']&&!$_REQUEST['time_end']) {
$withdrawMap['settlement_begin_time'] = ['egt',strtotime($_REQUEST['time_start'])];
}
if (!$_REQUEST['time_start']&&$_REQUEST['time_end']) {
$withdrawMap['settlement_end_time'] = ['elt',strtotime($_REQUEST['time_end'])];
}
if ($_REQUEST['time_start']&&$_REQUEST['time_end']) {
$withdrawMap['settlement_begin_time'] = ['egt',strtotime($_REQUEST['time_start'])];
$withdrawMap['settlement_end_time'] = ['elt',strtotime($_REQUEST['time_end'])];
}
$data = M('withdraw',"tab_")
->field("widthdraw_number,settlement_begin_time,settlement_end_time,settlement_type,promote_account")
->join('left join tab_promote_belong on tab_withdraw.promote_id=tab_promote_belong.promote_id')
->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field")
->where("tab_promote_belong.company_type=2")
->where($withdrawMap)
->select();
// dump($data);die();
// $statement = M('statement','tab_')
// ->field('ext_field')
// ->where(['ext_field'=>['like','%,%']])
// ->select();
//
// $withdrawData = [];
//
// foreach($statement as $key => $value) {
//
// $handleData = explode(',',$value['ext_field']);
//
// foreach ($handleData as $hk => $hv) {
// array_push($withdrawData,$hv);
// }
//
// }
//
// foreach ($data as $key => $value) {
// $data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']);
// $data[$key]['settlement_end_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_end_time']);
//
// if (in_array($value['widthdraw_number'],$withdrawData)) {
// unset($data[$key]);
// }
//
// }
//
// foreach ($data as $key => $value) {
// $data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']);
// $data[$key]['settlement_end_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_end_time']);
//
// }
$this->assign('withdraw_data',$data);
}
if ($_REQUEST['withdraw']&&$data) {
$map = [];
$map['widthdraw_number'] = ['in',$_REQUEST['withdraw']];
$data = M('withdraw','tab_')
->field("tab_withdraw.id,pc.company_name,pc.id as cid,tab_withdraw.promote_id,tab_withdraw.promote_account,username,'个人' as type,game_ratio
,mobile_phone,real_name,tab_promote.bank_card,account_openin,tab_promote.address,bank_account")
->join('left join tab_promote_belong on tab_withdraw.promote_id=tab_promote_belong.promote_id')
->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field")
->join("left join tab_promote on tab_promote.id=tab_promote_belong.promote_id")
->join("left join tab_promote_company as pc on pc.id = tab_promote.company_id")
->join("left join sys_ucenter_member on sys_ucenter_member.id=tab_promote.admin_id")
->where("tab_promote_belong.company_type=2")
->where($map)
->select();
$game_ratio = [];
foreach($data as $dkey => &$dval) {
$gameStr = [];
$rowspan = 0;
$dval['rowspan'] = 0;
$dval['game_ratio'] = json_decode($dval['game_ratio'],true);
if (is_array($dval['game_ratio'])) {
foreach ($dval['game_ratio'] as $key => &$value) {
foreach ($value as $k => &$v) {
// $v['game_id'] = $key;
$v['game_name'] = substr(get_gamename($key),0,strpos(get_gamename($key), '('));
if (!in_array($v['game_name'],$gameStr)) {
array_push($gameStr,$v['game_name']);
} else {
// var_dump($key);
if (!$game_ratio[$v['game_name']]) {
$game_ratio[$v['game_name']] = $v;
}
else {
$game_ratio[$v['game_name']]['sum_amount'] += $v['sum_amount'];
}
unset($value[$k]);
}
//
}
if (!$value) {
unset($dval['game_ratio'][$key]);
}
}
foreach ($dval['game_ratio'] as $key => $val) {
$val[0]['reward'] = 0;
$val[0]['forfeit'] = 0;
$startTime = strtotime($val[0]['begin_time']);
$endTime = strtotime($val[0]['end_time']);
$rewardData = M('reward_record','tab_')
->field("sum(tab_reward_record.money) as money,reward_type,relation_game_name")
->join("left join (select * from tab_game group by relation_game_id)tab_game on tab_reward_record.relation_game_id=tab_game.relation_game_id")
->where(['company_type'=>2,'relation_game_name'=>['like',"%{$val[0]['game_name']}%"],'reward_time'=>['between',[$startTime,$endTime]]])
->group('reward_type')
->select();
foreach ($rewardData as $rk => $rv) {
if ($rv['reward_type'] == 1) {
$val[0]['reward'] = $rv['money'];
} else {
$val[0]['forfeit'] = $rv['money'];
}
}
foreach ($val as $k => &$v) {
if ($game_ratio[$v['game_name']]) {
$v['sum_amount'] = number_format($v['sum_amount'] + $game_ratio[$v['game_name']]['sum_amount'],2,'.','');
}
//计算结算金额
$val[0]['real_amount'] = number_format($val[0]['sum_amount'] * ($val[0]['selle_ratio']/100)+$val[0]['reward']-$val[0]['forfeit'],2,'.','');
}
$rowspan++;
unset($dval['game_ratio'][$key]);
array_push($dval['game_ratio'],$val[0]);
}
$dval['rowspan'] = $rowspan;
}
}
$this->assign('data',$data);
}
$this->display();
} }
public function savePersonOrderEdit() {
$data['statement_info'] = $_POST['statement_info'];
$data['first_party_info'] = json_encode([]);
$data['second_party_info'] = $_POST['second_party_info'];
$data['statement_begin_time'] = strtotime($_POST['time_start']);
$data['statement_end_time'] = strtotime($_POST['time_end']);
$data['create_time'] = time();
$data['statement_money'] = 0;
$data['pay_amount'] = 0;
$data['ext_field'] = '';
$data['company_name'] = '个人结账单';
$data['statement_type'] = 2;
if($data['second_party_info'] == '[]' || $data['statement_info'] == '[]') {
$this->ajaxReturn(['status'=>1,'msg'=>'数据错误']);
}
$statement_info = json_decode($data['statement_info'],true);
foreach($statement_info as $key => $value) {
$data['statement_money'] += $value['sum_amount'];
$data['pay_amount'] += $value['real_amount'];
}
$second_party_info = json_decode($data['second_party_info'],true);
foreach($second_party_info as $key => $value) {
$data['ext_field'] = $data['ext_field'].$value['widthdraw_number'].',';
}
$data['ext_field'] = rtrim($data['ext_field'], ",");
$is_save = M('statement','tab_')->where(['id'=>$_REQUEST['withdraw_id']])->save($data);
if ($is_save) {
$this->ajaxReturn(['status'=>1,'msg'=>'修改成功']);
} else {
$this->ajaxReturn(['status'=>0,'msg'=>'修改失败']);
}
}
} }

@ -112,7 +112,7 @@
</thead> </thead>
<!-- 列表 --> <!-- 列表 -->
<tbody> <tbody class="setData">
<if condition = "empty($withdraw_data)"> <if condition = "empty($withdraw_data)">
<tr> <tr>
<td colspan="16" class="text-center">aOh! 暂时还没有内容!</td> <td colspan="16" class="text-center">aOh! 暂时还没有内容!</td>
@ -121,17 +121,12 @@
<notemtpy name = "withdraw_data"> <notemtpy name = "withdraw_data">
<volist name="withdraw_data" id="withdraw_data"> <volist name="withdraw_data" id="withdraw_data">
<tr> <tr>
<td ><input class="ids" type="checkbox" value="{$withdraw_data.widthdraw_number}" name="ids[]" <td ><input class="ids" type="checkbox" value="{$withdraw_data.widthdraw_number}" name="ids[]" onclick="shenhe()"
<if condition = "check_str($_REQUEST['withdraw'],$withdraw_data['widthdraw_number']) gt 0">checked="checked" </if> > <if condition = "check_str($_REQUEST['withdraw'],$withdraw_data['widthdraw_number']) gt 0">checked="checked" </if> >
</td> </td>
<td >{$withdraw_data.widthdraw_number}</td> <td >{$withdraw_data.widthdraw_number}</td>
<td >{$withdraw_data.settlement_begin_time} - {$withdraw_data.settlement_end_time}</td> <td >{$withdraw_data.settlement_begin_time} - {$withdraw_data.settlement_end_time}</td>
<td > <td ><if condition = "$withdraw_data.settlement_type eq 1">周结<elseif condition = "$withdraw_data.settlement_type eq 2"/>月结<elseif condition = "$withdraw_data.settlement_type eq 3"/>补点</if></td>
<if condition = "$withdraw_data.settlement_type eq 1">周结
<elseif condition = "$withdraw_data.settlement_type eq 2"/>月结
<elseif condition = "$withdraw_data.settlement_type eq 3"/>补点
</if>
</td>
<td >{$withdraw_data.promote_account}</td> <td >{$withdraw_data.promote_account}</td>
</tr> </tr>
@ -143,15 +138,15 @@
</div> </div>
<div class="cf top_nav_list" style="margin-top: 20px"> <!-- <div class="cf top_nav_list" style="margin-top: 20px">-->
<!-- 高级搜索 --> <!-- &lt;!&ndash; 高级搜索 &ndash;&gt;-->
<div class="jssearch fl cf search_list"> <!-- <div class="jssearch fl cf search_list">-->
<div class="input-list"> <!-- <div class="input-list">-->
<a class="sch-btn" href="javascript:;" style="border: #0a0a0a solid 1px;width: 120px" onclick="shenhe()">预览</a> <!-- <a class="sch-btn" href="javascript:;" style="border: #0a0a0a solid 1px;width: 120px" onclick="shenhe()">预览</a>-->
</div> <!-- </div>-->
</div> <!-- </div>-->
</div> <!-- </div>-->
<if condition = "empty($data)"> <if condition = "empty($data)">
<else/> <else/>
@ -196,13 +191,13 @@
<td >{$data.username}</td> <td >{$data.username}</td>
<td >{$data.type}</td> <td >{$data.type}</td>
<td></td> <td></td>
<td></td> <td>-</td>
<td></td> <td>0</td>
<td></td> <td>0</td>
<td></td> <td>0</td>
<td></td> <td>0</td>
<td></td> <td>0</td>
<td >{$data.bank_account}</td> <td >{$data.bank_account}</td>
<td >{$data.bank_card}</td> <td >{$data.bank_card}</td>
@ -311,9 +306,9 @@
} }
$("#confirm").click(function() { $("#confirm").click(function() {
var set = []; var withdraw_datas = [];
$('.withdraw_datas tr').each(function() { $('.withdraw_datas tr').each(function() {
var row = []; var row = {};
$(this).find('td').each(function(index) { $(this).find('td').each(function(index) {
@ -351,13 +346,47 @@
}); });
set.push(row); withdraw_datas.push(row);
});
var setData = [];
$('.setData tr').each(function() {
var row = {};
var checked = $(this).find('input').is(":checked");
if (checked) {
$(this).find('td').each(function(index) {
// console.log($(this).text());return;
if (index == 1) {
row['widthdraw_number'] = $(this).text();
} else if (index == 2) {
row['time'] = $(this).text();
}else if (index == 3) {
row['settlement_type'] = $(this).text();
}else if (index == 4) {
row['promote_account'] = $(this).text();
}
});
setData.push(row);
}
}); });
setTimeout(function(){ $.ajax({
window.parent.reload(); url: "{:U('StatementMangement/savePersonOrder')}",
},1500); type: "post",
console.log(set); data: {"second_party_info": JSON.stringify(setData),"statement_info":JSON.stringify(withdraw_datas),"time_start":start,"time_end":end},
dataType: 'json',
success: function (data) {
layer.msg(data.msg);
setTimeout(function(){
window.parent.reload();
},1500);
}
});
console.log(JSON.stringify(withdraw_datas));
console.log(setData);
} }
); );
@ -368,6 +397,7 @@
//全选的实现 //全选的实现
$(".check-all").click(function(){ $(".check-all").click(function(){
$('.ids').prop("checked", this.checked); $('.ids').prop("checked", this.checked);
shenhe();
}); });
$(".ids").click(function(){ $(".ids").click(function(){
var option = $(".ids"); var option = $(".ids");

@ -125,7 +125,7 @@
<notemtpy name = "data"> <notemtpy name = "data">
<volist name="data" id="data"> <volist name="data" id="data">
<tr> <tr>
<td><if condition="$data['statement_type'] eq 0">上游对账单<elseif condition="$data['statement_type'] eq 1 and $data['order'] eq 0"/>下游对账单<elseif condition="$data['statement_type'] eq 1 and $data['order'] eq 1"/>下游补点对账单</if></td> <td><if condition="$data['statement_type'] eq 0">上游对账单<elseif condition="$data['statement_type'] eq 1 and $data['order'] eq 0"/>下游对账单<elseif condition="$data['statement_type'] eq 1 and $data['order'] eq 1"/>下游补点对账单<elseif condition="$data['statement_type'] eq 2"/>下游个人结算单</if></td>
<td>{$data.create_time}</td> <td>{$data.create_time}</td>
<td>{$data.company_name}</td> <td>{$data.company_name}</td>
<td>{$data.statement_begin_time}-{$data.statement_end_time}</td> <td>{$data.statement_begin_time}-{$data.statement_end_time}</td>
@ -134,13 +134,13 @@
<td> <td>
<a class="confirm statement_view" data-id="{$data.id}">查看</a> <a class="confirm statement_view" data-id="{$data.id}">查看</a>
<if condition="$data['is_confirm'] eq 0"> <if condition="$data['is_confirm'] eq 0">
<a class="confirm statement_edit" data-id="{$data.id}" data-type="{$data.statement_type}" ext_field="{$data.ext_field}">编辑</a> <a class="confirm statement_edit" data-id="{$data.id}" data-start="{$data.statement_begin_time}" data-end="{$data.statement_end_time}" data-type="{$data.statement_type}" ext_field="{$data.ext_field}">编辑</a>
</if> </if>
<a class="confirm statement_del" data-type="{$data.statement_type}" data-id="{$data.id}">撤销</a> <a class="confirm statement_del" data-type="{$data.statement_type}" data-id="{$data.id}">撤销</a>
</td> </td>
</tr> </tr>
</volist> </volist>
<tr><td>合计</td><td colspan="10">公司对账金额合计:{$sum[1]}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cp对账金额合计{$sum[0]}</td></tr> <tr><td>合计</td><td colspan="10">公司对账金额合计:{$sum[1]}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cp对账金额合计{$sum[0]+$sum[2]}</td></tr>
</notemtpy> </notemtpy>
</tbody> </tbody>
</table> </table>
@ -242,8 +242,10 @@
var ext_field = $(this).attr('ext_field'); var ext_field = $(this).attr('ext_field');
if(edit.type == 0){ if(edit.type == 0){
var url = "/admin.php?s=/Statement/editCpStatement/id/"+edit.id; var url = "/admin.php?s=/Statement/editCpStatement/id/"+edit.id;
}else{ }else if(edit.type == 1){
var url = "/admin.php?s=/StatementMangement/editDownstreamOrder/id/"+edit.id+"/ext_field/"+ext_field; var url = "/admin.php?s=/StatementMangement/editDownstreamOrder/id/"+edit.id+"/ext_field/"+ext_field;
}else if(edit.type == 2){
var url = "/admin.php?s=/StatementMangement/PersonOrderEdit/id/"+edit.id+"/withdraw/"+ext_field+"/time_start/"+edit.start+"/time_end/"+edit.end;
} }
layer.open({ layer.open({

@ -1157,3 +1157,7 @@ ADD COLUMN `company_type` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '工
-- 2020-02-10 cxj 推广提现--新增审核模式 -- 2020-02-10 cxj 推广提现--新增审核模式
ALTER TABLE `tab_withdraw` ALTER TABLE `tab_withdraw`
ADD COLUMN `review_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '审核模式1-人工审核 2-自动审核'; ADD COLUMN `review_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '审核模式1-人工审核 2-自动审核';
-- 2020-02-12 zyx 推广提现--新增审核模式
ALTER TABLE `tab_statement`
MODIFY COLUMN `ext_field` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '扩展字段,如果是下游为提现单号' AFTER `pay_type`;

Loading…
Cancel
Save