Merge branch 'release' of 47.111.118.107:wmtx/platform into release

master
yulingwei 5 years ago
commit dc96411757

@ -149,10 +149,10 @@ class FinancePromoteController extends AdminController
$insideBelong = 0;
foreach ($data as $key => $value) {
if ($value['company_belong']=='外团') {
$outBelong+=$value['allcount'];
} else {
if ($value['company_belong']=='内团') {
$insideBelong+=$value['allcount'];
} else {
$outBelong+=$value['allcount'];
}
}

@ -316,7 +316,11 @@ class StatementMangementController extends ThinkController
}
if ($id) {
$upt = M('reward_record', 'tab_')->where(['id'=>$id])->save($data);
return $upt ? $this->success('更新成功', U('StatementMangement/rewardManageList')) : $this->error('更新失败');
if ($upt === false) {
$this->error('保存失败');
} else {
$this->success('保存成功', U('StatementMangement/rewardManageList'));
}
} else {
$data['create_time'] = time();
$data['creater_id'] = is_login();
@ -609,7 +613,7 @@ class StatementMangementController extends ThinkController
$statement = M('statement','tab_')
->field('ext_field')
->where(['ext_field'=>['like','%,%']])
->where(['statement_type'=>2])
->select();
$withdrawData = [];
@ -624,7 +628,10 @@ class StatementMangementController extends ThinkController
}
$thisWithdraw = explode(',',$_REQUEST['withdraw']);
// $thisWithdraw = explode(',',$_REQUEST['withdraw']);
$thisWithdraw = explode(',',M('statement','tab_')->where(['id'=>$_REQUEST['id']])->find()['ext_field']);
// dump($thisWithdraw);die();
foreach ($data as $key => $value) {
// $data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']);
@ -795,6 +802,8 @@ class StatementMangementController extends ThinkController
$is_save = M('statement','tab_')->where(['id'=>$_REQUEST['withdraw_id']])->save($data);
// echo M('statement','tab_')->_sql();die();
if ($is_save) {
$this->ajaxReturn(['status'=>1,'msg'=>'修改成功']);
} else {

@ -498,7 +498,7 @@ class WithdrawModel extends Model{
{
$promoteGameRatioMap['status'] = 1;
$promoteGameRatioMap['promote_id'] = $promote['id'];
$promoteGameRatios = D('promote_game_ratio')->field('game_id, ratio, turnover_ratio, begin_time, end_time')
$promoteGameRatios = M('promote_game_ratio', 'tab_')->field('game_id, ratio, turnover_ratio, begin_time, end_time')
->where($promoteGameRatioMap)
->order('update_time desc')
->select();
@ -566,7 +566,7 @@ class WithdrawModel extends Model{
$promoteGameRatioMap['status'] = 1;
$promoteGameRatioMap['promote_id'] = $promote['id'];
$promoteGameRatios = D('promote_game_ratio')->field('game_id, ratio, turnover_ratio, begin_time, end_time')
$promoteGameRatios = M('promote_game_ratio', 'tab_')->field('game_id, ratio, turnover_ratio, begin_time, end_time')
->where($promoteGameRatioMap)
->order('update_time desc')
->select();

@ -258,7 +258,7 @@
</tr>
<tr class="data_summary">
<td style="text-align: center;">内外团占比:</td>
<td colspan="20" style="text-align: center;">内团充值金额占比:{$insideBelong}%&nbsp&nbsp&nbsp&nbsp外团充值金额占比:{$outBelong}%</td>
<td colspan="20" style="text-align: center;">内团充值金额占比:{$insideBelong}%&nbsp&nbsp&nbsp&nbsp其他团体充值金额占比:{$outBelong}%</td>
</tr>
</tbody>
</table>

@ -299,6 +299,9 @@
<if condition="session('user_auth.uid') eq 1">
<a class='delete' data-id="{$data.id}">删除</a>
</if>
<if condition="$data.level = 1">
<a href="{:U('certification', array('id' => $data['id']))}">资质认证</a>
</if>
</td>
</tr>
</volist>

@ -80,6 +80,7 @@
<div class="jssearch fl cf search_list">
<div class="input-list">
<input type="text" id="withdraw_id" style="display: none" value="{:I('id')}"/>
<input type="text" id="withdraw" name="withdraw" style="display: none" value="{:I('withdraw')}"/>
<input type="text" readonly id="time_start" name="time_start" class="" value="{:I('time_start')}" placeholder="结算开始时间" />
&nbsp;-&nbsp;
<div class="input-append date" id="datetimepicker" style="display:inline-block">
@ -277,6 +278,7 @@
return $(elem).val();
}).get().join(",");
var id =$("#withdraw_id").val();
var withdraw =$("#withdraw").val();
var url = "/admin.php?s=/statementMangement/PersonOrderEdit/withdraw/" + text + "/time_start/" + $("#time_start").val() + "/time_end/" + $("#time_end").val() + "/id/" + id;
console.log(url)

@ -34,13 +34,23 @@ class FinanceController extends BaseController
return true;
}
private function getDayList($beginTime, $endTime)
private function getDayList($beginTime, $endTime, $timeType = 1)
{
$dayList = [];
do {
$dayList[] = date('Y-m-d', $beginTime);
$beginTime += 24 * 60 * 60;
} while ($beginTime < $endTime);
switch ($timeType) {
case 1:
do {
$dayList[] = date('Y-m-d', $beginTime);
$beginTime += 24 * 60 * 60;
} while ($beginTime < $endTime);
break;
case 2:
do {
$dayList[] = date('Y-m', $beginTime);
$beginTime = strtotime('+1 month', $beginTime);
} while ($beginTime < $endTime);
break;
}
return $dayList;
}
@ -120,20 +130,24 @@ class FinanceController extends BaseController
$income = $model->field("sum(if(pay_time < $thisDay, if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as history_income,
sum(if(pay_time >= $thisMonth, if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as this_month_income,
sum(if((pay_time >= $yesterday and pay_time < $thisDay), if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as yesterday_income,
sum(if(pay_time < $thisDay, if(selle_status = 0, pay_amount * selle_ratio, 0), 0)) as balance,
sum(if(selle_status = 0, pay_amount, 0)) as not_withdrawn_amount")
sum(if(pay_time < $thisDay, if(selle_status = 0, pay_amount * selle_ratio, 0), 0)) as balance")
->where($map)
->find();
foreach ($income as &$value) {
$value = bcdiv($value, 100, 2);
}
$withdrawMap['promote_id'] = $this->loginPromote['id'];
$withdrawMap['status'] = ['neq', 2];
$withdrawMap['status'] = 2;
//已提现总额
$income['withdrawn_amount'] = M('withdraw', 'tab_')->field('sum(sum_money) as withdrawn_amount')->where($withdrawMap)->find()['withdrawn_amount'];
foreach ($income as &$value) {
$value = bcdiv($value, 100, 2);
}
$withdrawMap['status'] = ['in', [-1, 0, 1]];
$notWithdrawnAmount = M('withdraw', 'tab_')->field('sum(sum_money) as withdrawn_amount')->where($withdrawMap)->find()['withdrawn_amount'];
$income['withdrawn_amount'] = $income['withdrawn_amount'] ?? '0.00';
$notWithdrawnAmount = $notWithdrawnAmount ?? 0;
$income['not_withdrawn_amount'] = bcadd($this->getSumAmountBySettlementType(), $notWithdrawnAmount, 2);
$withdrawMap['status'] = ['not in', [-2, -1]];
$withdrawns = M('withdraw', 'tab_')->field('settlement_begin_time, settlement_end_time')
@ -191,6 +205,122 @@ class FinanceController extends BaseController
$this->display();
}
public function getSumAmountBySettlementType()
{
$withdrawModel = new WithdrawModel();
$balance = 0;
if ($this->loginPromote['settlement_type'] == 2) {
$settlementType = 2;
} else {
$map['pay_status'] = 1;
$map['selle_status'] = 0;
$balance = M('spend', 'tab_')->field('sum(pay_amount * selle_ratio) as balance')->where($map)->find()['balance'];
$balance = $balance ? bcdiv($balance , 100, 2) : 0;
$settlementType = 3;
}
$months = $this->getDayList(strtotime('2019-09'), strtotime(date('Y-m')), 2);
$promote = $this->loginPromote;
if ($settlementType == 2) {
$fun = 'getMonthAmount';
} else {
$fun = 'getRecoupAmount';
}
if ($months) {
foreach ($months as $month) {
$data['begin_time'] = strtotime($month);
$data['end_time'] = strtotime('+1 month', $data['begin_time']) - 1;
$balance = bcadd($balance, $withdrawModel->$fun($promote, $data), 2);
}
}
return $balance;
}
public function getNotWithdrawnAmount()
{
$thisMonth = strtotime(date('Y-m'));
$map['promote_id'] = $this->loginPromote['id'];
$map['status'] = 1;
$map['begin_time'] = ['elt', $thisMonth];
$promoteGameRatios = M('promote_game_ratio', 'tab_')->field('game_id, begin_time, end_time, ratio, turnover_ratio')
->where($map)
->select();
if (empty($promoteGameRatios)) {
return 0;
} else {
$income = 0;
$map['status'] = ['neq', -2];
$map['settlement_type'] = ['in', [2, 3]];
unset($map['begin_time']);
$withdrawDays = M('withdraw', 'tab_')->where($map)->getField('settlement_begin_time', true);
if ($withdrawDays) {
foreach ($withdrawDays as &$withdrawDay) {
$withdrawDay = date('Y-m', $withdrawDay);
}
} else {
$withdrawDays = [];
}
foreach ($promoteGameRatios as $promoteGameRatio) {
$map = [];
$map['game_id'] = $promoteGameRatio['game_id'];
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
$days = $this->getDayList($promoteGameRatio['begin_time'], $thisMonth, 2);
if ($days) {
foreach ($days as $day) {
if (!in_array($day, $withdrawDays)) {
$day = strtotime($day);
$map['pay_time'] = ['between', [$day, strtotime('+1 month', $day) - 1]];
$sumAmount = $this->getSumMoney($map);
$diffRatio = $this->getDiffRatio($sumAmount, $promoteGameRatio['ratio'], $promoteGameRatio['turnover_ratio']);
$income += bcmul($sumAmount, bcdiv($diffRatio, 100, 2), 2);
}
}
}
}
}
return $income;
}
private function getSumMoney($map = [])
{
$map['pay_status'] = 1;
$sumAmount = M('spend', 'tab_')->field('sum(pay_amount) as sum_amount')->where($map)->find()['sum_amount'];
$sumAmount = $sumAmount ?? 0;
return $sumAmount;
}
private function getDiffRatio($sumAmount, $defaultRatio, $turnoverRatios)
{
if ($turnoverRatios) {
$ratio = $defaultRatio;
foreach ($turnoverRatios as $turnoverRatio) {
if (empty($turnoverRatio['instanceof']) || $turnoverRatio['instanceof'] == 1) {
if ($sumAmount >= $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
} else {
if ($sumAmount > $turnoverRatio['turnover']) {
$ratio = $turnoverRatio['ratio'];
break;
}
}
}
$ratio = bcsub($ratio - $defaultRatio, 2);
return $ratio;
}
return 0;
}
//结算明细
public function settlementDtl()
{

@ -34,8 +34,8 @@
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div> <div class="text text5"><p>账户余额</p><span>¥{$income.balance}</span></div> </li>
</ul>
<ul style="margin-top: 10px;">
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div> <div class="text text2"><p>已提现总金额</p><span>¥{$income.withdrawn_amount}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div> <div class="text text1"><p>未提现金额</p><span>¥{$income.not_withdrawn_amount}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div> <div class="text text2"><p>实际提现总金额</p><span>¥{$income.withdrawn_amount}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div> <div class="text text1"><p>实际提现金额</p><span>¥{$income.not_withdrawn_amount}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div> <div class="text text3"><p>结算周期</p><span>{$settlementCycle}</span></div> </li>
</ul>
</div>

Loading…
Cancel
Save