|
|
@ -31,6 +31,8 @@ class QueryController extends ThinkController
|
|
|
|
|
|
|
|
|
|
|
|
public function settlement($p = 0)
|
|
|
|
public function settlement($p = 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
$settlementType = intval(I('settlement_type', 0));
|
|
|
|
|
|
|
|
$settlementTypeList = WithdrawModel::$settlementTypeList;
|
|
|
|
$page = intval(I('p', 1)); //默认显示第一页数据
|
|
|
|
$page = intval(I('p', 1)); //默认显示第一页数据
|
|
|
|
$row = intval(I('row', 10));
|
|
|
|
$row = intval(I('row', 10));
|
|
|
|
$group = I('group', 1);
|
|
|
|
$group = I('group', 1);
|
|
|
@ -39,13 +41,50 @@ class QueryController extends ThinkController
|
|
|
|
$promoteId = I('promote_id', 0);
|
|
|
|
$promoteId = I('promote_id', 0);
|
|
|
|
|
|
|
|
|
|
|
|
if ($group == 1) {
|
|
|
|
if ($group == 1) {
|
|
|
|
if (empty($promoteId)) {
|
|
|
|
unset($settlementTypeList[WithdrawModel::SETTLEMENT_TYPE_OTHER]);
|
|
|
|
|
|
|
|
$time = I('time', '');
|
|
|
|
|
|
|
|
if (empty($promoteId) || empty($settlementType) || empty($time)) {
|
|
|
|
|
|
|
|
$this->assign('settlementTypeList', $settlementTypeList);
|
|
|
|
$this->display();
|
|
|
|
$this->display();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$promoteIds = M('promote', 'tab_')->where(['chain' => ['like', "/{$promoteId}/%"]])->getField('id', true);
|
|
|
|
$promoteIds = M('promote', 'tab_')->where(['chain' => ['like', "/{$promoteId}/%"]])->getField('id', true);
|
|
|
|
$promoteIds[] = $promoteId;
|
|
|
|
$promoteIds[] = $promoteId;
|
|
|
|
$beginTime = I('timestart', get_lastweek_name(7));
|
|
|
|
|
|
|
|
$endTime = I('timeend', get_lastweek_name(1));
|
|
|
|
if ($settlementType == 1) {
|
|
|
|
|
|
|
|
$time = explode(' 至 ', $time);
|
|
|
|
|
|
|
|
if (count($time) != 2) {
|
|
|
|
|
|
|
|
$this->display();die;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$beginTime = strtotime($time[0]);
|
|
|
|
|
|
|
|
$endTime = strtotime($time[1]) + 3600 * 24 - 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$beginTime = strtotime($time);
|
|
|
|
|
|
|
|
$endTime = strtotime('+1 month', $beginTime) - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$promote = M('promote', 'tab_')->find($promoteId);
|
|
|
|
|
|
|
|
if (empty($promote) || $promote['level'] != 1 || empty($promote['settlement_type'])) {
|
|
|
|
|
|
|
|
$this->error('网络异常');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($promote['settlement_type'] == 1) {
|
|
|
|
|
|
|
|
unset($settlementTypeList[WithdrawModel::SETTLEMENT_TYPE_MONTH]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
unset($settlementTypeList[WithdrawModel::SETTLEMENT_TYPE_WEEK]);
|
|
|
|
|
|
|
|
unset($settlementTypeList[WithdrawModel::SETTLEMENT_TYPE_RECOUP]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($settlementType == 3) {
|
|
|
|
|
|
|
|
$withdrawMap['promote_id'] = $promoteId;
|
|
|
|
|
|
|
|
$withdrawMap['status'] = ['neq', -2];
|
|
|
|
|
|
|
|
$withdrawMap['settlement_begin_time'] = $beginTime;
|
|
|
|
|
|
|
|
$withdrawMap['settlement_end_time'] = $endTime;
|
|
|
|
|
|
|
|
$withdraw = D('withdraw')->where($withdrawMap)->find();
|
|
|
|
|
|
|
|
if (!empty($withdraw)) {
|
|
|
|
|
|
|
|
$this->assign('settlementTypeList', $settlementTypeList);
|
|
|
|
|
|
|
|
$this->display();die;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$sortBy = I('sort_by', '');
|
|
|
|
$sortBy = I('sort_by', '');
|
|
|
|
$sortColumn = I('sort_column', '');
|
|
|
|
$sortColumn = I('sort_column', '');
|
|
|
|
$order = 'day';
|
|
|
|
$order = 'day';
|
|
|
@ -59,8 +98,6 @@ class QueryController extends ThinkController
|
|
|
|
} elseif ($sortBy == 2) {
|
|
|
|
} elseif ($sortBy == 2) {
|
|
|
|
$orderType = 'asc';
|
|
|
|
$orderType = 'asc';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$beginTime = strtotime($beginTime);
|
|
|
|
|
|
|
|
$endTime = strtotime($endTime) + 3600 * 24 - 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$spendMap['tab_spend.pay_status'] = 1;
|
|
|
|
$spendMap['tab_spend.pay_status'] = 1;
|
|
|
|
$spendMap['tab_spend.selle_status'] = 0;
|
|
|
|
$spendMap['tab_spend.selle_status'] = 0;
|
|
|
@ -96,15 +133,19 @@ class QueryController extends ThinkController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($records)) {
|
|
|
|
if (!empty($records)) {
|
|
|
|
$promote = M('promote', 'tab_')->find($promoteId);
|
|
|
|
|
|
|
|
foreach ($records as &$record) {
|
|
|
|
foreach ($records as &$record) {
|
|
|
|
$record['promote_account'] = $promote['account'] ?? '未知';
|
|
|
|
$record['promote_account'] = $promote['account'] ?? '未知';
|
|
|
|
$record['settlement_amount'] = bcdiv($record['settlement_amount'], 100, 2);
|
|
|
|
$record['settlement_amount'] = bcdiv($record['settlement_amount'], 100, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($settlementType == 3) {
|
|
|
|
$totalField = 'sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount';
|
|
|
|
$totalField = 'sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount';
|
|
|
|
$zTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//累计
|
|
|
|
$zTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//累计
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$totalField = 'sum(tab_spend.pay_amount) as sum_amount';
|
|
|
|
|
|
|
|
$zTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['sum_amount']);//累计
|
|
|
|
|
|
|
|
}
|
|
|
|
$zTotal = bcdiv($zTotal, 100 ,2);
|
|
|
|
$zTotal = bcdiv($zTotal, 100 ,2);
|
|
|
|
|
|
|
|
|
|
|
|
if(I('export', 0) == 1) {
|
|
|
|
if(I('export', 0) == 1) {
|
|
|
@ -139,6 +180,7 @@ class QueryController extends ThinkController
|
|
|
|
if($page) {
|
|
|
|
if($page) {
|
|
|
|
$this->assign('_page', $page);
|
|
|
|
$this->assign('_page', $page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assign('settlementTypeList', $settlementTypeList);
|
|
|
|
$this->assign('records', $records);
|
|
|
|
$this->assign('records', $records);
|
|
|
|
$this->assign('zTotal', $zTotal);
|
|
|
|
$this->assign('zTotal', $zTotal);
|
|
|
|
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/settlement', 'status' => 1])->find());
|
|
|
|
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/settlement', 'status' => 1])->find());
|
|
|
@ -151,7 +193,6 @@ class QueryController extends ThinkController
|
|
|
|
$withdrawNumber = I('widthdraw_number', '');
|
|
|
|
$withdrawNumber = I('widthdraw_number', '');
|
|
|
|
$status = intval(I('status', ''));
|
|
|
|
$status = intval(I('status', ''));
|
|
|
|
$opType = intval(I('op_type', 0));
|
|
|
|
$opType = intval(I('op_type', 0));
|
|
|
|
$settlementType = intval(I('settlement_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]];
|
|
|
@ -244,6 +285,7 @@ class QueryController extends ThinkController
|
|
|
|
if($page) {
|
|
|
|
if($page) {
|
|
|
|
$this->assign('_page', $page);
|
|
|
|
$this->assign('_page', $page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assign('settlementTypeList', $settlementTypeList);
|
|
|
|
$this->assign('records', $records);
|
|
|
|
$this->assign('records', $records);
|
|
|
|
$this->display();
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -266,22 +308,22 @@ class QueryController extends ThinkController
|
|
|
|
|
|
|
|
|
|
|
|
public function settlementWithdraw()
|
|
|
|
public function settlementWithdraw()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$beginTime = strtotime(I('begin_time', ''));
|
|
|
|
|
|
|
|
$endTime = strtotime(I('end_time', ''));
|
|
|
|
|
|
|
|
$promoteId = intval(I('promote_id', 0));
|
|
|
|
$promoteId = intval(I('promote_id', 0));
|
|
|
|
if ($beginTime == 0 || $endTime == 0) {
|
|
|
|
$settlementType = intval(I('settlement_type', 0));
|
|
|
|
|
|
|
|
$time = I('time', '');
|
|
|
|
|
|
|
|
if (empty($promoteId)) {
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['msg'] = '时间参数错误';
|
|
|
|
$data['msg'] = '请选择会长账号';
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($beginTime > $endTime) {
|
|
|
|
if (empty($settlementType)) {
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['msg'] = '开始时间必须小于等于结束时间';
|
|
|
|
$data['msg'] = '请选择提现模式';
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($promoteId == 0) {
|
|
|
|
if (empty($time)) {
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['msg'] = '请选择会长账号';
|
|
|
|
$data['msg'] = '请选择充值时间';
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -301,78 +343,75 @@ class QueryController extends ThinkController
|
|
|
|
$data['msg'] = '该会长未通过资质认证审核,暂时无法提现';
|
|
|
|
$data['msg'] = '该会长未通过资质认证审核,暂时无法提现';
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($promote['settlement_type'] == 1) {
|
|
|
|
$endTime += 3600 * 24 - 1;
|
|
|
|
if (!in_array($settlementType, [1, 3])) {
|
|
|
|
$spendModel = M('spend', 'tab_');
|
|
|
|
|
|
|
|
$map['chain'] = ['like', $promote['chain'] . $promote['id'] . '/%'];
|
|
|
|
|
|
|
|
$promoteIds = M('promote', 'tab_')->where($map)->getField('id', true);
|
|
|
|
|
|
|
|
$promoteIds[] = $promote['id'];
|
|
|
|
|
|
|
|
$promoteIds = implode(',', $promoteIds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map = [];
|
|
|
|
|
|
|
|
$map['pay_status'] = 1;
|
|
|
|
|
|
|
|
$map['selle_status'] = 0;
|
|
|
|
|
|
|
|
$map['promote_id'] = ['in', $promoteIds];
|
|
|
|
|
|
|
|
$map['pay_time'] = ['between', [$beginTime, $endTime]];
|
|
|
|
|
|
|
|
$balance = $spendModel->field("sum(pay_amount * selle_ratio) as balance")
|
|
|
|
|
|
|
|
->where($map)
|
|
|
|
|
|
|
|
->find()['balance'];
|
|
|
|
|
|
|
|
$balance = bcdiv($balance, 100, 2);
|
|
|
|
|
|
|
|
if ($balance < 100) {
|
|
|
|
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['msg'] = '累计结算低于100元,无法提现!';
|
|
|
|
$data['msg'] = '参数异常';
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$spendIds = $spendModel->where($map)->getField('id', true);
|
|
|
|
} else {
|
|
|
|
if (empty($spendIds)) {
|
|
|
|
if ($settlementType != 2) {
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['msg'] = '数据异常';
|
|
|
|
$data['msg'] = '参数异常';
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$thisTime = time();
|
|
|
|
if ($settlementType == 1) {
|
|
|
|
$add['sum_money'] = $balance;
|
|
|
|
$time = explode(' 至 ', $time);
|
|
|
|
$add['promote_id'] = $promote['id'];
|
|
|
|
if (count($time) != 2) {
|
|
|
|
$add['promote_account'] = $promote['account'];
|
|
|
|
|
|
|
|
$add['create_time'] = $thisTime;
|
|
|
|
|
|
|
|
$add['status'] = 0;
|
|
|
|
|
|
|
|
$add['widthdraw_number'] = D('withdraw')->produceWithdrawNumber();
|
|
|
|
|
|
|
|
$add['settlement_begin_time'] = $beginTime;
|
|
|
|
|
|
|
|
$add['settlement_end_time'] = $endTime;
|
|
|
|
|
|
|
|
$add['spend_ids'] = '';
|
|
|
|
|
|
|
|
$add['op_id'] = is_login();
|
|
|
|
|
|
|
|
$add['op_type'] = 2;
|
|
|
|
|
|
|
|
$add['last_op_id'] = $add['op_id'];
|
|
|
|
|
|
|
|
$add['last_op_type'] = 2;
|
|
|
|
|
|
|
|
$add['settlement_type'] = 3;
|
|
|
|
|
|
|
|
$add['game_ratio'] = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
M()->startTrans();//开启事物
|
|
|
|
|
|
|
|
$withdrawId = M('withdraw', 'tab_')->add($add);
|
|
|
|
|
|
|
|
if (!$withdrawId) {
|
|
|
|
|
|
|
|
M()->rollback();//事物回滚
|
|
|
|
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['status'] = 0;
|
|
|
|
$data['msg'] = '提现失败';
|
|
|
|
$data['msg'] = '参数异常';
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$beginTime = strtotime($time[0]);
|
|
|
|
|
|
|
|
$endTime = strtotime($time[1]) + 3600 * 24 - 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$beginTime = strtotime($time);
|
|
|
|
|
|
|
|
$endTime = strtotime('+1 month', $beginTime) - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$map = [];
|
|
|
|
$withdrawModel = new WithdrawModel();
|
|
|
|
$map['id'] = ['in', $spendIds];
|
|
|
|
$data['begin_time'] = $beginTime;
|
|
|
|
$save['selle_status'] = 1;
|
|
|
|
$data['end_time'] = $endTime;
|
|
|
|
$save['selle_time'] = $thisTime;
|
|
|
|
$data['op_id'] = is_login();
|
|
|
|
$save['withdraw_id'] = $withdrawId;
|
|
|
|
$data['op_type'] = 2;
|
|
|
|
$res = $spendModel->where($map)->save($save);
|
|
|
|
switch ($settlementType) {
|
|
|
|
if ($res === false) {
|
|
|
|
case 1:
|
|
|
|
M('withdraw', 'tab_')->delete($withdrawId);
|
|
|
|
$result = $withdrawModel->promoteWithdrawWeeklyByPromote($promote, false, $data);
|
|
|
|
M()->rollback();//事物回滚
|
|
|
|
break;
|
|
|
|
$data['status'] = 0;
|
|
|
|
case 2:
|
|
|
|
$data['msg'] = '提现失败';
|
|
|
|
$result = $withdrawModel->promoteWithdrawPerMonthByPromote($promote, false, $data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
$result = $withdrawModel->promoteWithdrawRecoupByPromote($promote, $data);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
M()->commit();//事物提交
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
$data['status'] = 0;
|
|
|
|
|
|
|
|
switch ($result) {
|
|
|
|
|
|
|
|
case -4:
|
|
|
|
|
|
|
|
case -3:
|
|
|
|
|
|
|
|
$data['msg'] = '无可补点订单';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -2:
|
|
|
|
|
|
|
|
if ($settlementType == 3) {
|
|
|
|
|
|
|
|
$data['msg'] = '无可补点订单';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$data['msg'] = '累计结算低于100元,无法提现!';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1:
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
$data['msg'] = '操作失败';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
$data['status'] = 1;
|
|
|
|
$data['status'] = 1;
|
|
|
|
$data['msg'] = '提现成功';
|
|
|
|
$data['msg'] = '操作成功';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -412,6 +451,22 @@ class QueryController extends ThinkController
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$time = time();
|
|
|
|
|
|
|
|
$data['status'] = 1;
|
|
|
|
|
|
|
|
$data['msg'] = '撤销成功';
|
|
|
|
|
|
|
|
$withdrawSave['id'] = $id;
|
|
|
|
|
|
|
|
$withdrawSave['status'] = -2;
|
|
|
|
|
|
|
|
$withdrawSave['last_up_update_time'] = $time;
|
|
|
|
|
|
|
|
$withdrawSave['last_op_id'] = is_login();
|
|
|
|
|
|
|
|
$withdrawSave['last_op_type'] = 2;
|
|
|
|
|
|
|
|
if ($data['settlement_type'] == 3) {
|
|
|
|
|
|
|
|
$withdrawRes = M('withdraw', 'tab_')->save($withdrawSave);
|
|
|
|
|
|
|
|
if ($withdrawRes === false) {
|
|
|
|
|
|
|
|
$data['status'] = 0;
|
|
|
|
|
|
|
|
$data['msg'] = '撤销失败';
|
|
|
|
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$spendMap['withdraw_id'] = $id;
|
|
|
|
$spendMap['withdraw_id'] = $id;
|
|
|
|
$spendIds = M('Spend', 'tab_')->where($spendMap)->getField('id', true);
|
|
|
|
$spendIds = M('Spend', 'tab_')->where($spendMap)->getField('id', true);
|
|
|
|
if (empty($spendIds)) {
|
|
|
|
if (empty($spendIds)) {
|
|
|
@ -420,13 +475,7 @@ class QueryController extends ThinkController
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$spendIds = implode(',', $spendIds);
|
|
|
|
$spendIds = implode(',', $spendIds);
|
|
|
|
$time = time();
|
|
|
|
|
|
|
|
$withdrawSave['id'] = $id;
|
|
|
|
|
|
|
|
$withdrawSave['status'] = -2;
|
|
|
|
|
|
|
|
$withdrawSave['spend_ids'] = $spendIds;
|
|
|
|
$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();//开启事物
|
|
|
|
M('withdraw', 'tab_')->startTrans();//开启事物
|
|
|
|
$withdrawRes = M('withdraw', 'tab_')->save($withdrawSave);
|
|
|
|
$withdrawRes = M('withdraw', 'tab_')->save($withdrawSave);
|
|
|
@ -446,9 +495,9 @@ class QueryController extends ThinkController
|
|
|
|
$data['msg'] = '撤销失败';
|
|
|
|
$data['msg'] = '撤销失败';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
M('withdraw', 'tab_')->commit();//事物提交
|
|
|
|
M('withdraw', 'tab_')->commit();//事物提交
|
|
|
|
$data['status'] = 1;
|
|
|
|
|
|
|
|
$data['msg'] = '撤销成功';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
$this->ajaxReturn($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1393,7 +1442,6 @@ class QueryController extends ThinkController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function marketList($p=1) {
|
|
|
|
public function marketList($p=1) {
|
|
|
|
|
|
|
|
|
|
|
|
$page = intval($p);
|
|
|
|
$page = intval($p);
|
|
|
@ -1501,4 +1549,49 @@ class QueryController extends ThinkController
|
|
|
|
$this->display();
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getPromoteSettlementType()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$promoteId = intval(I('post.promote_id', 0));
|
|
|
|
|
|
|
|
$settlementType = [];
|
|
|
|
|
|
|
|
if ($promoteId > 0) {
|
|
|
|
|
|
|
|
$promote = D('promote')->field('level, settlement_type')->where(array('id' => $promoteId))->find();
|
|
|
|
|
|
|
|
if (empty($promote) || $promote['level'] != 1 || empty($promote['settlement_type'])) {
|
|
|
|
|
|
|
|
$settlementType = [];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$settlementType = WithdrawModel::$settlementTypeList;
|
|
|
|
|
|
|
|
unset($settlementType[WithdrawModel::SETTLEMENT_TYPE_OTHER]);
|
|
|
|
|
|
|
|
if ($promote['settlement_type'] == 1) {
|
|
|
|
|
|
|
|
unset($settlementType[WithdrawModel::SETTLEMENT_TYPE_MONTH]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
unset($settlementType[WithdrawModel::SETTLEMENT_TYPE_WEEK]);
|
|
|
|
|
|
|
|
unset($settlementType[WithdrawModel::SETTLEMENT_TYPE_RECOUP]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->ajaxReturn(['settlement_type' => $settlementType]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getRecoupAmount()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$withdrawModel = new WithdrawModel();
|
|
|
|
|
|
|
|
$promoteId = intval(I('promote_id', 0));
|
|
|
|
|
|
|
|
$settlementType = intval(I('settlement_type', 0));
|
|
|
|
|
|
|
|
$time = I('time', '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($promoteId) || $settlementType != 3) {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['balance' => 0]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$promote = M('promote', 'tab_')->find($promoteId);
|
|
|
|
|
|
|
|
if (empty($promote) || $promote['level'] != 1 || $promote['ver_status'] != 1 || $promote['settlement_type'] != 1 || empty($time)) {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['balance' => 0]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['begin_time'] = strtotime($time);
|
|
|
|
|
|
|
|
$data['end_time'] = strtotime('+1 month', $data['begin_time']) - 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$balance = $withdrawModel->getRecoupAmount($promote, $data);
|
|
|
|
|
|
|
|
$this->ajaxReturn(['balance' => $balance]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|