推广结算--更新

master
chenxiaojun 5 years ago
parent 311aeffbb7
commit 15174f8547

@ -775,14 +775,4 @@ function camelize($str, $separator = '_', $littleHump = false)
function unCamelize($str, $separator = '_') function unCamelize($str, $separator = '_')
{ {
return strtolower(preg_replace('/([a-z])([A-Z])/', "$1" . $separator . "$2", $str)); return strtolower(preg_replace('/([a-z])([A-Z])/', "$1" . $separator . "$2", $str));
}
//获取管理员账号
function getAdminNickname($adminId)
{
$adminId = intval($adminId);
if ($adminId) {
return M('member')->where(array('id' => $adminId))->getField('nickname');
}
return '未知';
} }

@ -2,6 +2,7 @@
namespace Admin\Controller; namespace Admin\Controller;
use Home\Controller\FileController;
use User\Api\UserApi as UserApi; use User\Api\UserApi as UserApi;
use Admin\Model\WithdrawModel; use Admin\Model\WithdrawModel;
@ -123,8 +124,11 @@ class QueryController extends ThinkController
$this->display(); $this->display();
} }
} elseif ($group == 2) { } elseif ($group == 2) {
$map = '1 = 1'; $map['_string'] = '1 = 1';
$createTime = strtotime(I('create_time', '')); $createTime = strtotime(I('create_time', ''));
$withdrawNumber = I('widthdraw_number', '');
$status = intval(I('status', ''));
$opType = intval(I('op_type', 0));
if ($createTime) { if ($createTime) {
$createTimeEnd = $createTime + 3600 * 24 - 1; $createTimeEnd = $createTime + 3600 * 24 - 1;
$map['create_time'] = ['between', [$createTime, $createTimeEnd]]; $map['create_time'] = ['between', [$createTime, $createTimeEnd]];
@ -132,11 +136,27 @@ class QueryController extends ThinkController
if ($promoteId) { if ($promoteId) {
$map['promote_id'] = $promoteId; $map['promote_id'] = $promoteId;
} }
if ($withdrawNumber) {
$map['widthdraw_number'] = ['like', "{$withdrawNumber}%"];
}
if (isset($_REQUEST['status'])) {
$map['status'] = $status;
}
if ($opType) {
$map['op_type'] = $opType;
}
$records = M('withdraw', 'tab_')->where($map)->select(); $records = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond')
->where($map)
->order('')
->page($page, $row)
->select();
$count = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond')
->where($map)
->count();
if (!empty($records)) { if (!empty($records)) {
foreach ($records as &$record) { foreach ($records as &$record) {
$record['settlement_begin_time'] = date('Y-m-d H:i:s', $record['settlement_begin_time']); $record['settlement_begin_time'] = $record['settlement_begin_time'] ? date('Y-m-d H:i:s', $record['settlement_begin_time']) : '--';
$record['settlement_end_time'] = date('Y-m-d H:i:s', $record['settlement_end_time']); $record['settlement_end_time'] = date('Y-m-d H:i:s', $record['settlement_end_time']);
$record['create_time'] = date('Y-m-d H:i:s', $record['create_time']); $record['create_time'] = date('Y-m-d H:i:s', $record['create_time']);
$record['status_text'] = promoteWithdrawStatus($record['status']); $record['status_text'] = promoteWithdrawStatus($record['status']);
@ -146,6 +166,10 @@ class QueryController extends ThinkController
} }
} }
$page = set_pagination($count, $row);
if($page) {
$this->assign('_page', $page);
}
$this->assign('records', $records); $this->assign('records', $records);
$this->display(); $this->display();
} }
@ -229,6 +253,8 @@ class QueryController extends ThinkController
$add['spend_ids'] = ''; $add['spend_ids'] = '';
$add['op_id'] = is_login(); $add['op_id'] = is_login();
$add['op_type'] = 2; $add['op_type'] = 2;
$add['last_op_id'] = $add['op_id'];
$add['last_op_type'] = 2;
M()->startTrans();//开启事物 M()->startTrans();//开启事物
$withdrawId = M('withdraw', 'tab_')->add($add); $withdrawId = M('withdraw', 'tab_')->add($add);
@ -259,6 +285,98 @@ class QueryController extends ThinkController
$this->ajaxReturn($data); $this->ajaxReturn($data);
} }
public function renewReview()
{
$id = intval(I('id', 0));
$data = M('withdraw', 'tab_')->find($id);
if (empty($data) || $data['status'] != -1) {
$data['status'] = 0;
$data['msg'] = '数据异常';
$this->ajaxReturn($data);
}
$save['id'] = $id;
$save['status'] = 0;
$save['last_up_update_time'] = time();
$save['last_op_id'] = is_login();
$save['last_op_type'] = 2;
$res = M('withdraw', 'tab_')->save($save);
if ($res === false) {
$data['status'] = 0;
$data['msg'] = '提交失败';
} else {
$data['status'] = 1;
$data['msg'] = '提交成功';
}
$this->ajaxReturn($data);
}
public function cancelWithdraw()
{
$id = intval(I('id', 0));
$data = M('withdraw', 'tab_')->find($id);
if (empty($data) || !in_array($data['status'], [-1, 0])) {
$data['status'] = 0;
$data['msg'] = '数据异常';
$this->ajaxReturn($data);
}
$spendMap['withdraw_id'] = $id;
$spendIds = M('Spend', 'tab_')->where($spendMap)->getField('id', true);
if (empty($spendIds)) {
$data['status'] = 0;
$data['msg'] = '数据异常';
$this->ajaxReturn($data);
}
$spendIds = implode(',', $spendIds);
$time = time();
$withdrawSave['id'] = $id;
$withdrawSave['status'] = -2;
$withdrawSave['spend_ids'] = $spendIds;
$withdrawSave['last_up_update_time'] = $time;
$withdrawSave['last_op_id'] = is_login();
$withdrawSave['last_op_type'] = 2;
M('withdraw', 'tab_')->startTrans();//开启事物
$withdrawRes = M('withdraw', 'tab_')->save($withdrawSave);
if ($withdrawRes === false) {
M('withdraw', 'tab_')->rollback();//事物回滚
$data['status'] = 0;
$data['msg'] = '撤销失败';
$this->ajaxReturn($data);
}
$spendSave['selle_status'] = 0;
$spendSave['withdraw_id'] = 0;
$spendRes = M('spend', 'tab_')->where($spendMap)->save($spendSave);
if ($spendRes === false) {
M('withdraw', 'tab_')->rollback();//事物回滚
$data['status'] = 0;
$data['msg'] = '撤销失败';
} else {
M('withdraw', 'tab_')->commit();//事物提交
$data['status'] = 1;
$data['msg'] = '撤销成功';
}
$this->ajaxReturn($data);
}
public function downloadProve()
{
$id = intval(I('id', 0));
if ($id) {
$withdraw = M('withdraw', 'tab_')->find($id);
if (empty($withdraw) || $withdraw['status'] != 2 || !$withdraw['transfer_proof']) {
$this->error('网络异常');
}
$file = new FileController();
$file->download($withdraw['transfer_proof']);
} else {
$this->error('参数异常');
}
}
public function cpsettlement($p = 0) public function cpsettlement($p = 0)
{ {
$page = intval($p); $page = intval($p);

@ -45,7 +45,9 @@
<div class="cf top_nav_list"> <div class="cf top_nav_list">
<div class="fl button_list"> <div class="fl button_list">
<div class="tools"> <div class="tools">
<a id="withdraw"><span class="button_icon button_icon10"></span>提 现</a> <if condition="I('group') eq 1 or $group eq 1">
<a id="withdraw"><span class="button_icon button_icon10"></span>提 现</a>
</if>
</div> </div>
</div> </div>
@ -85,7 +87,25 @@
</div> </div>
</if> </if>
<if condition="I('group') eq 2 or $group eq 2"> <if condition="I('group') eq 2 or $group eq 2">
<div class="input-list">
<input type="text" name="widthdraw_number" class="" value="{:I('widthdraw_number')}" placeholder="提现单号">
</div>
<div class="input-list">
<select name="status" class="select_gallery">
<option value="">提现状态</option>
<?php foreach (promoteWithdrawStatus() as $key => $value) :?>
<option value="<?=$key?>"><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<select name="op_type" class="select_gallery">
<option value="">操作人类型</option>
<?php foreach (getPromoteWithdrawOpType() as $key => $value) :?>
<option value="<?=$key?>"><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list"> <div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Query/settlement?group=2','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a> <a class="sch-btn" href="javascript:;" id="search" url="{:U('Query/settlement?group=2','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
</div> </div>
@ -149,6 +169,10 @@
<th>推广员账号</th> <th>推广员账号</th>
<th>结算单号</th> <th>结算单号</th>
<th>结算金额</th> <th>结算金额</th>
<th>操作人</th>
<th>操作人类型</th>
<th>最后操作人</th>
<th>最后操作人类型</th>
<th>结算开始时间</th> <th>结算开始时间</th>
<th>结算截止时间</th> <th>结算截止时间</th>
<th>提现时间</th> <th>提现时间</th>
@ -161,22 +185,42 @@
<tbody> <tbody>
<volist name="records" id="record"> <volist name="records" id="record">
<tr> <tr>
<td></td> <td>{$record.promote_account}</td>
<td>{$record.promote_account}</td> <td>{$record.widthdraw_number}</td>
<td>{$record.widthdraw_number}</td> <td>{$record.sum_money}</td>
<td>{$record.sum_money}</td> <td>
<td>{$record.settlement_begin_time}</td> <if condition="$record.op_type eq 1">
<td>{$record.settlement_end_time}</td> {:get_promote_name($record['op_id'])}
<td>{$record.create_time}</td> <else />
<td>{$record.status_text}</td> {:getAdminNickname($record['op_id'])}
<td>{$record.respond}</td> </if>
<td></td> </td>
<td>{:getPromoteWithdrawOpType($record['op_type'])}</td>
<td>
<if condition="$record.last_op_type eq 1">
{:get_promote_name($record['last_op_id'])}
<else />
{:getAdminNickname($record['last_op_id'])}
</if>
</td>
<td>{:getPromoteWithdrawOpType($record['last_op_type'])}</td>
<td>{$record.settlement_begin_time}</td>
<td>{$record.settlement_end_time}</td>
<td>{$record.create_time}</td>
<td>{$record.status_text}</td>
<td>{$record.respond}</td>
<td>
<if condition="$record['status'] eq 2">
<a href="{:U('downloadProve', ['id'=>$record['id']])}">汇款证明</a>
<elseif condition="$record['status'] eq -1"/>
<span class="renew-review" data-id="{$record['id']}" style="color: #0bb20c;cursor: pointer;">重新审核</span>
</if>
<if condition="$record['status'] eq -1 or $record['status'] eq 0">
<span class="cancel-withdraw" data-id="{$record['id']}" style="color: red;cursor: pointer;">撤销提现</span>
</if>
</td>
</tr> </tr>
</volist> </volist>
<tr class="data_summary">
<td>汇总</td>
<td colspan="10">当页结算:{$total}元 今日结算:{$ttotal}元 昨日结算:{$ytotal}元 累计结算:{$ztotal}元</td>
</tr>
</tbody> </tbody>
</table> </table>
</if> </if>
@ -239,7 +283,8 @@
var url = $(this).attr('url'); var url = $(this).attr('url');
var query = $('.top_nav_list').find('input').serialize(); var query = $('.top_nav_list').find('input').serialize();
var promoteId = $('#promote_id').val(); var promoteId = $('#promote_id').val();
if (promoteId == '') { var group = parseInt("{$group}");
if (promoteId == '' && group === 1) {
layer.msg('请选择推广员', {time: 1000}); layer.msg('请选择推广员', {time: 1000});
return false; return false;
} }
@ -378,5 +423,58 @@
}); });
}); });
}); });
$('.renew-review').click(function () {
var id = parseInt($(this).attr('data-id'));
$.ajax({
type: 'post',
url: '{:U("renewReview")}',
dataType: 'json',
data: {id:id},
success: function (data) {
if (data.status == 1) {
layer.msg(data.msg, {icon: 1});
setTimeout(function(){
window.location.reload();
},2000);
} else {
layer.msg(data.msg, {icon: 5});
}
},
error: function (result) {
layer.msg('网络异常', {icon: 5});
}
});
});
$('.cancel-withdraw').click(function () {
var id = parseInt($(this).attr('data-id'));
var msg = "确定要撤销提现吗?";
layer.confirm(msg, {
title: '提示',
btn: ['确定', '取消'],
}, function () {
$.ajax({
type: 'post',
url: '{:U("cancelWithdraw")}',
dataType: 'json',
data: {id:id},
success: function (data) {
if (data.status == 1) {
layer.msg(data.msg, {icon: 1});
setTimeout(function(){
window.location.reload();
},2000);
} else {
layer.msg(data.msg, {icon: 5});
}
},
error: function (result) {
layer.msg('网络异常', {icon: 5});
}
});
});
});
</script> </script>
</block> </block>

@ -118,6 +118,8 @@
<th>推广员账号</th> <th>推广员账号</th>
<th>操作人</th> <th>操作人</th>
<th>操作人类型</th> <th>操作人类型</th>
<th>最后操作人</th>
<th>最后操作人类型</th>
<th>结算开始时间</th> <th>结算开始时间</th>
<th>结算截止时间</th> <th>结算截止时间</th>
<th><a class="paixu" data-order='create_time'>申请时间</a></th> <th><a class="paixu" data-order='create_time'>申请时间</a></th>
@ -162,6 +164,14 @@
</if> </if>
</td> </td>
<td>{:getPromoteWithdrawOpType($data['op_type'])}</td> <td>{:getPromoteWithdrawOpType($data['op_type'])}</td>
<td>
<if condition="$data.last_op_type eq 1">
{:get_promote_name($data['last_op_id'])}
<else />
{:getAdminNickname($data['last_op_id'])}
</if>
</td>
<td>{:getPromoteWithdrawOpType($data['last_op_type'])}</td>
<td><notempty name="data.settlement_begin_time">{$data.settlement_begin_time|date='Y-m-d H:i:s',###}<else />---</notempty></td> <td><notempty name="data.settlement_begin_time">{$data.settlement_begin_time|date='Y-m-d H:i:s',###}<else />---</notempty></td>
<td><notempty name="data.settlement_end_time">{$data.settlement_end_time|date='Y-m-d H:i:s',###}<else />---</notempty></td> <td><notempty name="data.settlement_end_time">{$data.settlement_end_time|date='Y-m-d H:i:s',###}<else />---</notempty></td>
<td><notempty name="data.create_time">{$data.create_time|date='Y-m-d H:i:s',###}<else />---</notempty></td> <td><notempty name="data.create_time">{$data.create_time|date='Y-m-d H:i:s',###}<else />---</notempty></td>

@ -1454,3 +1454,12 @@ function getPromoteWithdrawOpType($opType = null)
} }
} }
//获取管理员账号
function getAdminNickname($adminId)
{
$adminId = intval($adminId);
if ($adminId) {
return M('member')->where(array('id' => $adminId))->getField('nickname');
}
return '未知';
}

@ -414,7 +414,7 @@ class FinanceController extends BaseController
} }
} }
$data = $model->field('id,widthdraw_number,create_time,settlement_end_time,sum_money,status,respond,transfer_proof') $data = $model->field('id, widthdraw_number, create_time, settlement_begin_time, settlement_end_time, sum_money, status, respond, transfer_proof, op_id, op_type, last_op_id, last_op_type')
->where($map) ->where($map)
->order('id desc') ->order('id desc')
->page($page, $row) ->page($page, $row)
@ -426,8 +426,13 @@ class FinanceController extends BaseController
if (!empty($data)) { if (!empty($data)) {
foreach ($data as &$list) { foreach ($data as &$list) {
$list['create_time'] = date('Y-m-d H:i:s', $list['create_time']); $list['create_time'] = date('Y-m-d H:i:s', $list['create_time']);
$list['settlement_begin_time'] = $list['settlement_begin_time'] ? date('Y-m-d H:i:s', $list['settlement_begin_time']) : '--';
$list['settlement_end_time'] = date('Y-m-d H:i:s', $list['settlement_end_time']); $list['settlement_end_time'] = date('Y-m-d H:i:s', $list['settlement_end_time']);
$list['status_name'] = FinanceController::$withdrawStatus[$list['status']]; $list['status_name'] = FinanceController::$withdrawStatus[$list['status']];
$list['op_id'] = ($list['op_type'] == 1) ? get_promote_name($list['op_id']) : getAdminNickname($list['op_id']);
$list['last_op_id'] = ($list['last_op_type'] == 1) ? get_promote_name($list['last_op_id']) : getAdminNickname($list['last_op_id']);
$list['op_type'] = getPromoteWithdrawOpType($list['op_type']);
$list['last_op_type'] = getPromoteWithdrawOpType($list['last_op_type']);
switch ($list['status']) { switch ($list['status']) {
case -2: case -2:
$list['status_name'] = '<span style="color: #bbbaba;">' . $list['status_name'] . '</span>'; $list['status_name'] = '<span style="color: #bbbaba;">' . $list['status_name'] . '</span>';

@ -149,7 +149,12 @@
<tr class="odd"> <tr class="odd">
<th>提现订单</th> <th>提现订单</th>
<th>提现日期</th> <th>提现日期</th>
<th>结算开始日期</th>
<th>结算截止日期</th> <th>结算截止日期</th>
<th>操作人</th>
<th>操作人类型</th>
<th>最后操作人</th>
<th>最后操作人类型</th>
<th>收益金额</th> <th>收益金额</th>
<th>实际提现金额</th> <th>实际提现金额</th>
<th>提现状态</th> <th>提现状态</th>
@ -168,7 +173,12 @@
<tr class="num2"> <tr class="num2">
<td>{$vo.widthdraw_number}</td> <td>{$vo.widthdraw_number}</td>
<td>{$vo.create_time}</td> <td>{$vo.create_time}</td>
<td>{$vo.settlement_begin_time}</td>
<td>{$vo.settlement_end_time}</td> <td>{$vo.settlement_end_time}</td>
<td>{$vo.op_id}</td>
<td>{$vo.op_type}</td>
<td>{$vo.last_op_id}</td>
<td>{$vo.last_op_type}</td>
<td>{$vo.sum_money}</td> <td>{$vo.sum_money}</td>
<td>{$vo.sum_money}</td> <td>{$vo.sum_money}</td>
<td>{$vo.status_name}</td> <td>{$vo.status_name}</td>

@ -924,4 +924,7 @@ ADD COLUMN `settlement_begin_time` int(10) NOT NULL DEFAULT 0 COMMENT '结算开
ALTER TABLE `tab_withdraw` ALTER TABLE `tab_withdraw`
ADD COLUMN `op_id` int(11) NOT NULL DEFAULT 0 COMMENT '操作id'; ADD COLUMN `op_id` int(11) NOT NULL DEFAULT 0 COMMENT '操作id';
ALTER TABLE `tab_withdraw` ALTER TABLE `tab_withdraw`
ADD COLUMN `op_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '操作人1-推广员 2-管理员'; ADD COLUMN `op_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '操作人1-推广员 2-管理员';
ALTER TABLE `tab_withdraw`
ADD COLUMN `last_op_id` int(11) NOT NULL DEFAULT 0 COMMENT '最后操作人id',
ADD COLUMN `last_op_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '最后操作人1-推广员 2-管理员';
Loading…
Cancel
Save