diff --git a/Application/Admin/Controller/AutoController.class.php b/Application/Admin/Controller/AutoController.class.php
index e4ff6b0fd..7b268b3be 100644
--- a/Application/Admin/Controller/AutoController.class.php
+++ b/Application/Admin/Controller/AutoController.class.php
@@ -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);
diff --git a/Application/Admin/Controller/QueryController.class.php b/Application/Admin/Controller/QueryController.class.php
index fde9a8bc0..069a5c112 100644
--- a/Application/Admin/Controller/QueryController.class.php
+++ b/Application/Admin/Controller/QueryController.class.php
@@ -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 .= ' 说明:此功能是查看所有的会长未提现订单,并可进行后台提现 说明:此功是查看并管理混服申请的功能 说明:此功是查看所有会长的结算记录
';
+ }
+ }
+ $this->ajaxReturn(['msg' => $msg]);
}
public function set_withdraw_status()
diff --git a/Application/Admin/Model/WithdrawModel.class.php b/Application/Admin/Model/WithdrawModel.class.php
index 87d60eb32..3a9859c8e 100644
--- a/Application/Admin/Model/WithdrawModel.class.php
+++ b/Application/Admin/Model/WithdrawModel.class.php
@@ -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 => '其他',
+ ];
/*
* 开发者提现未处理列表
diff --git a/Application/Admin/View/Query/settlement.html b/Application/Admin/View/Query/settlement.html
index 13e7b913b..633ff12f7 100644
--- a/Application/Admin/View/Query/settlement.html
+++ b/Application/Admin/View/Query/settlement.html
@@ -39,7 +39,7 @@