结算管理--更新

master
chenxiaojun 5 years ago
commit 461e80bd30

@ -1035,6 +1035,18 @@ public function auto_rrdae(){
return $ret;
}
//会长周结--初始化
public function promoteWithdrawWeeklyInitial()
{
$this->promoteWithdraw(1, true);
}
//会长月结--初始化
public function promoteWithdrawPerMonthInitial()
{
$this->promoteWithdraw(2, true);
}
//会长周结
public function promoteWithdrawWeekly()
{
@ -1048,7 +1060,7 @@ public function auto_rrdae(){
}
//会长提现 $settlement 1-周结算 2-月结算
private function promoteWithdraw($settlement = 1)
private function promoteWithdraw($settlement = 1, $initial = false)
{
$map['level'] = 1;
$map['ver_status'] = 1;
@ -1061,7 +1073,7 @@ public function auto_rrdae(){
if (!empty($promotes)) {
foreach ($promotes as $promote) {
$result = $this->promoteWithdrawByPromote($promote);
$result = $this->promoteWithdrawByPromote($promote, $initial);
switch ($result) {
case -2:
$error_balance++;
@ -1082,17 +1094,30 @@ public function auto_rrdae(){
echo "success{$success} error_withdraw{$error_withdraw} error_spend{$error_spend} error_balance{$error_balance}";
}
private function promoteWithdrawByPromote($promote)
private function promoteWithdrawByPromote($promote, $initial = false)
{
$promoteMap['chain'] = ['like', "{$promote['chain']}{$promote['id']}/%"];
$promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true);
$promoteIds[] = $promote['id'];
$settlementEndTime = strtotime(date('Y-m-d')) - 1;
if ($initial) {
$settlementBeginTime = 0;
} else {
switch ($promote['settlement_type']) {
case 2:
$settlementBeginTime = strtotime(date('Y-m', strtotime('-1 month', time())));
break;
case 1:
default:
$settlementBeginTime = strtotime(date('Y-m-d', strtotime('-7 day', time())));
break;
}
}
$spendMap['pay_status'] = 1;
$spendMap['selle_status'] = 0;
$spendMap['promote_id'] = ['in', $promoteIds];
$spendMap['pay_time'] = ['elt', $settlementEndTime];
$spendMap['pay_time'] = ['between', [$settlementBeginTime, $settlementEndTime]];
$spendModel = M('spend', 'tab_');
$balance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance")
->where($spendMap)
@ -1109,13 +1134,14 @@ public function auto_rrdae(){
$add['create_time'] = $thisTime;
$add['status'] = 0;
$add['widthdraw_number'] = D('withdraw')->produceWithdrawNumber();
$add['settlement_begin_time'] = 0;
$add['settlement_begin_time'] = $settlementBeginTime;
$add['settlement_end_time'] = $settlementEndTime;
$add['spend_ids'] = '';
$add['op_id'] = 0;
$add['op_type'] = 3;
$add['last_op_id'] = $add['op_id'];
$add['last_op_type'] = 3;
$add['settlement_type'] = $promote['settlement_type'];
M()->startTrans();//开启事物
$withdrawId = D('withdraw')->add($add);

@ -129,6 +129,7 @@ class QueryController extends ThinkController
$withdrawNumber = I('widthdraw_number', '');
$status = intval(I('status', ''));
$opType = intval(I('op_type', 0));
$settlementType = intval(I('settlement_type', 0));
if ($createTime) {
$createTimeEnd = $createTime + 3600 * 24 - 1;
$map['create_time'] = ['between', [$createTime, $createTimeEnd]];
@ -145,8 +146,11 @@ class QueryController extends ThinkController
if ($opType) {
$map['op_type'] = $opType;
}
if ($settlementType) {
$map['settlement_type'] = $settlementType;
}
$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')
$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, settlement_type')
->where($map)
->order('create_time desc')
->page($page, $row)
@ -862,6 +866,7 @@ class QueryController extends ThinkController
public function withdraw()
{
$page = I('p', 1);
$adminid = C('USER_ADMINISTRATOR');//获取超管id
$adminmobile = M('UcenterMember')->field('mobile')->find($adminid);
$this->assign('adminmobile', $adminmobile['mobile']);
@ -874,6 +879,9 @@ class QueryController extends ThinkController
if (isset($_REQUEST['op_type'])) {
$map['op_type'] = $_REQUEST['op_type'];
}
if (isset($_REQUEST['settlement_type'])) {
$map['settlement_type'] = $_REQUEST['settlement_type'];
}
if (isset($_REQUEST['promote_account'])) {
if ($_REQUEST['promote_account'] == '全部') {
unset($_REQUEST['promote_account']);
@ -920,8 +928,43 @@ class QueryController extends ThinkController
//为数据权限添加
setPowerPromoteIds($map);
$this->assign('is_admin', is_administrator());
$user->money_list($model, $p, $map);
$user->money_list($model, $page, $map);
}
public function getWithdraw()
{
$promoteId = intval(I('post.promote_id', 0));
$beginTime = I('post.begin_time', '');
$endTime = I('post.end_time', '');
$msg = '';
if (empty($promoteId) || empty($beginTime) || empty($endTime)) {
$this->ajaxReturn(['msg' => $msg]);
}
$beginTime = strtotime($beginTime);
$endTime = strtotime($endTime) + 3600 * 24 - 1;
$map['promote_id'] = $promoteId;
$map['settlement_end_time'] = ['between', [$beginTime, $endTime]];
$map['status'] = ['neq', -2];
$withdraws = D('withdraw')->field('id, settlement_begin_time, settlement_end_time')
->where($map)
->select();
if (!empty($withdraws)) {
foreach ($withdraws as $withdraw) {
$settlementEndTime = date('Y-m-d', $withdraw['settlement_end_time'] + 1);
if ($withdraw['settlement_begin_time'] > 0) {
$settlementBeginTime = date('Y-m-d', $withdraw['settlement_begin_time']);
$msg .= "{$settlementBeginTime}至{$settlementEndTime}之间的订单已经提现;";
} else {
$msg .= "{$settlementEndTime}之前的订单已经提现;";
}
$msg .= '<br>';
}
}
$this->ajaxReturn(['msg' => $msg]);
}
public function set_withdraw_status()

@ -15,10 +15,16 @@ use Think\Model;
*/
class WithdrawModel extends Model{
//操作人类型
const OP_TYPE_PROMOTE = 1;
const OP_TYPE_ADMIN = 2;
const OP_TYPE_AUTO = 3;
//结算类型
const SETTLEMENT_TYPE_WEEK = 1;
const SETTLEMENT_TYPE_MONTH = 2;
const SETTLEMENT_TYPE_OTHER = 3;
/**
* 构造函数
* @param string $name 模型名称
@ -37,6 +43,12 @@ class WithdrawModel extends Model{
self::OP_TYPE_ADMIN => '管理员',
self::OP_TYPE_AUTO => '自动',
];
public static $settlementTypeList = [
self::SETTLEMENT_TYPE_WEEK => '周结',
self::SETTLEMENT_TYPE_MONTH => '月结',
self::SETTLEMENT_TYPE_OTHER => '其他',
];
/*
* 开发者提现未处理列表

@ -39,7 +39,7 @@
<if condition="$group eq 1">
<p class="description_text">说明:此功能是查看所有的会长未提现订单,并可进行后台提现</p>
<else/>
<p class="description_text">说明:此功是查看并管理混服申请的功能</p>
<p class="description_text">说明:此功是查看所有会长的结算记录</p>
</if>
</div>
<div class="cf top_nav_list">
@ -106,6 +106,14 @@
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<select name="settlement_type" class="select_gallery">
<option value="">提现模式</option>
<?php foreach (getPromoteWithdrawSettlementType() as $key => $value) :?>
<option value="<?=$key?>"><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<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>
</div>
@ -173,6 +181,7 @@
<th>操作人类型</th>
<th>最后操作人</th>
<th>最后操作人类型</th>
<th>提现模式</th>
<th>结算开始时间</th>
<th>结算截止时间</th>
<th>提现时间</th>
@ -208,6 +217,7 @@
</if>
</td>
<td>{:getPromoteWithdrawOpType($record['last_op_type'])}</td>
<td>{:getPromoteWithdrawSettlementType($record['settlement_type'])}</td>
<td>{$record.settlement_begin_time}</td>
<td>{$record.settlement_end_time}</td>
<td>{$record.create_time}</td>
@ -383,7 +393,8 @@
var endTime = $('#time-end').val();
var promoteId = parseInt($('#promote_id').val());
var balance = parseFloat("{$zTotal}");
var msg = "收益结算时间:" + $('#time-start').val() + " 至 " + $('#time-end').val();
var msg = getWithdraw(promoteId, beginTime, endTime);
msg += "收益结算时间:" + $('#time-start').val() + " 至 " + $('#time-end').val();
msg += "<br>";
msg += "提现金额:{$zTotal}元";
@ -429,6 +440,25 @@
});
});
function getWithdraw(promoteId, beginTime, endTime)
{
var msg = '';
$.ajax({
type: 'post',
url: '{:U("getWithdraw")}',
dataType: 'json',
async: false,
data: {promote_id:promoteId, begin_time:beginTime, end_time:endTime},
success: function (data) {
msg = data.msg;
},
error: function (result) {
layer.msg('网络异常', {icon: 5});
}
});
return msg;
}
$('.renew-review').click(function () {
var id = parseInt($(this).attr('data-id'));

@ -93,6 +93,14 @@
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<select name="settlement_type" class="select_gallery">
<option value="">提现模式</option>
<?php foreach (getPromoteWithdrawSettlementType() as $key => $value) :?>
<option value="<?=$key?>"><?=$value?></option>
<?php endforeach;?>
</select>
</div>
<input type="hidden" name="" value="" class="sortBy">
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Query/withdraw','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
@ -120,6 +128,7 @@
<th>操作人类型</th>
<th>最后操作人</th>
<th>最后操作人类型</th>
<th>提现模式</th>
<th>结算开始时间</th>
<th>结算截止时间</th>
<th><a class="paixu" data-order='create_time'>申请时间</a></th>
@ -176,6 +185,7 @@
</if>
</td>
<td>{:getPromoteWithdrawOpType($data['last_op_type'])}</td>
<td>{:getPromoteWithdrawSettlementType($data['settlement_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_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>

@ -1463,3 +1463,13 @@ function getAdminNickname($adminId)
}
return '未知';
}
//获取提现操作人类型
function getPromoteWithdrawSettlementType($type = null)
{
if ($type) {
return Admin\Model\WithdrawModel::$settlementTypeList[$type] ?? '未知';
} else {
return Admin\Model\WithdrawModel::$settlementTypeList;
}
}

@ -937,3 +937,7 @@ ADD COLUMN `settlement_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '结算类型
ALTER TABLE tab_promote add `company_belong` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会归属0-内团1-外团';
ALTER TABLE tab_promote add `company_relation` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会关系0-自主开发及维护1-只维护';
-- 2020-01-02
-- 提现结算类型 cxj
ALTER TABLE `tab_withdraw`
ADD COLUMN `settlement_type` tinyint(3) NOT NULL DEFAULT 3 COMMENT '结算类型1-周结 2-月结 3-其他';

Loading…
Cancel
Save