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 @@

说明:此功能是查看所有的会长未提现订单,并可进行后台提现

-

说明:此功是查看并管理混服申请的功能

+

说明:此功是查看所有会长的结算记录

@@ -106,6 +106,14 @@
+
+ +
搜索
@@ -173,6 +181,7 @@ 操作人类型 最后操作人 最后操作人类型 + 提现模式 结算开始时间 结算截止时间 提现时间 @@ -208,6 +217,7 @@ {:getPromoteWithdrawOpType($record['last_op_type'])} + {:getPromoteWithdrawSettlementType($record['settlement_type'])} {$record.settlement_begin_time} {$record.settlement_end_time} {$record.create_time} @@ -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 += "
"; 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')); diff --git a/Application/Admin/View/Query/withdraw.html b/Application/Admin/View/Query/withdraw.html index c675cae0b..a7d71ba66 100644 --- a/Application/Admin/View/Query/withdraw.html +++ b/Application/Admin/View/Query/withdraw.html @@ -93,6 +93,14 @@ +
+ +
搜索 @@ -120,6 +128,7 @@ 操作人类型 最后操作人 最后操作人类型 + 提现模式 结算开始时间 结算截止时间 申请时间 @@ -176,6 +185,7 @@ {:getPromoteWithdrawOpType($data['last_op_type'])} + {:getPromoteWithdrawSettlementType($data['settlement_type'])} {$data.settlement_begin_time|date='Y-m-d H:i:s',###}--- {$data.settlement_end_time|date='Y-m-d H:i:s',###}--- {$data.create_time|date='Y-m-d H:i:s',###}--- diff --git a/Application/Common/Common/function.php b/Application/Common/Common/function.php index b45da22c6..9ba387a91 100644 --- a/Application/Common/Common/function.php +++ b/Application/Common/Common/function.php @@ -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; + } +} diff --git a/Data/update.sql b/Data/update.sql index 6e87b4a16..06f649355 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -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-其他';