2020-10-11 19:23:42 +08:00
|
|
|
<?php
|
2020-10-13 09:38:55 +08:00
|
|
|
/*
|
|
|
|
|
* @Descripttion:
|
|
|
|
|
* @version:
|
|
|
|
|
* @Author: kangkang
|
|
|
|
|
* @Date: 2020-10-11 11:22:56
|
2020-12-07 17:35:27 +08:00
|
|
|
* @LastEditors: Please set LastEditors
|
|
|
|
|
* @LastEditTime: 2020-12-07 17:30:59
|
2020-10-13 09:38:55 +08:00
|
|
|
*/
|
2020-10-11 19:23:42 +08:00
|
|
|
|
|
|
|
|
namespace app\order\controller;
|
|
|
|
|
|
2021-05-28 17:06:09 +08:00
|
|
|
use app\manager\model\Manager;
|
2020-10-21 20:54:10 +08:00
|
|
|
use alipay\Alipay;
|
2020-10-11 19:23:42 +08:00
|
|
|
use app\order\model\CashOut as CashMoedl;
|
2020-10-21 20:24:13 +08:00
|
|
|
use app\order\model\User as UserModel;
|
|
|
|
|
use app\order\model\UserScore as ScoreModel;
|
2020-10-11 19:23:42 +08:00
|
|
|
use fastphp\base\Controller;
|
2021-02-26 11:01:06 +08:00
|
|
|
use app\agent\model\AgentScore as AgentScoreModel;
|
|
|
|
|
use app\agent\model\AgentUser;
|
2020-10-11 19:23:42 +08:00
|
|
|
|
2020-10-14 20:20:49 +08:00
|
|
|
class CashOutAdmin extends Controller
|
2020-10-11 19:23:42 +08:00
|
|
|
{
|
|
|
|
|
//获取记录
|
|
|
|
|
public function getData()
|
|
|
|
|
{
|
|
|
|
|
$cash = new CashMoedl;
|
2021-05-28 17:06:09 +08:00
|
|
|
$manager_model = new Manager;
|
|
|
|
|
|
|
|
|
|
$manager = $manager_model->getOne(['id'=>$this->userinfo['OperaterID']]);
|
|
|
|
|
$where = [];
|
|
|
|
|
if($manager['IsRoot'] != 1){
|
|
|
|
|
$where['status'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list = $cash->getListPage($where);
|
2020-10-11 19:23:42 +08:00
|
|
|
//提现状态
|
|
|
|
|
$status = ['待处理', '同意', '拒绝'];
|
|
|
|
|
foreach ($list as &$v) {
|
|
|
|
|
$v['status'] = $status[$v['status']];
|
|
|
|
|
$v['alipay_account'] = substr($v['alipay_account'], 0, 3) . '***' . substr($v['alipay_account'], -3);
|
2020-10-28 17:16:38 +08:00
|
|
|
|
2020-10-11 19:23:42 +08:00
|
|
|
}
|
2021-05-28 17:24:51 +08:00
|
|
|
$count = $cash->getCount($where);
|
2020-10-11 19:23:42 +08:00
|
|
|
$data = [
|
|
|
|
|
'Code' => 10000,
|
|
|
|
|
'count' => $count['count'],
|
|
|
|
|
'data' => $list,
|
|
|
|
|
];
|
|
|
|
|
echo json_encode($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取指定页码数据
|
|
|
|
|
public function pageList()
|
|
|
|
|
{
|
|
|
|
|
if (!$_GET) {
|
|
|
|
|
die;
|
|
|
|
|
}
|
2021-02-26 11:01:06 +08:00
|
|
|
|
|
|
|
|
$where = [];
|
2020-10-11 19:23:42 +08:00
|
|
|
$page = ($_GET['page'] - 1) * 50;
|
|
|
|
|
$cash = new CashMoedl;
|
2021-05-28 17:06:09 +08:00
|
|
|
$manager_model = new Manager;
|
|
|
|
|
|
|
|
|
|
$manager = $manager_model->getOne(['id'=>$this->userinfo['OperaterID']]);
|
|
|
|
|
$where = [];
|
|
|
|
|
if($manager['IsRoot'] != 1){
|
|
|
|
|
$where['status'] = 0;
|
|
|
|
|
}
|
2021-02-26 11:01:06 +08:00
|
|
|
$list = $cash->getListPage($where, '*', 'id desc', "$page,50");
|
2020-10-13 09:38:55 +08:00
|
|
|
//提现状态
|
|
|
|
|
$status = ['待处理', '同意', '拒绝'];
|
|
|
|
|
foreach ($list as &$v) {
|
|
|
|
|
$v['status'] = $status[$v['status']];
|
|
|
|
|
$v['alipay_account'] = substr($v['alipay_account'], 0, 3) . '***' . substr($v['alipay_account'], -3);
|
2021-01-14 12:21:44 +08:00
|
|
|
$v['username'] = substr($v['username'], 0, 3) . '***' . substr($v['username'], -3);
|
2020-10-28 17:16:38 +08:00
|
|
|
|
2020-10-13 09:38:55 +08:00
|
|
|
}
|
2020-10-11 19:23:42 +08:00
|
|
|
$data = [
|
|
|
|
|
'Code' => 10000,
|
|
|
|
|
'data' => $list,
|
|
|
|
|
];
|
|
|
|
|
echo json_encode($data);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-13 09:38:55 +08:00
|
|
|
/**
|
2020-10-14 20:20:49 +08:00
|
|
|
* @description: 处理订单
|
2020-10-21 20:54:10 +08:00
|
|
|
* @param {type}
|
|
|
|
|
* @return {type}
|
2020-10-13 09:38:55 +08:00
|
|
|
*/
|
2020-10-11 19:23:42 +08:00
|
|
|
public function handle()
|
|
|
|
|
{
|
2020-10-13 09:38:55 +08:00
|
|
|
$data = json_decode(file_get_contents("php://input"), true)['info'];
|
2020-10-11 19:23:42 +08:00
|
|
|
$id = $data['id'];
|
|
|
|
|
unset($data['update_time']);
|
|
|
|
|
unset($data['create_time']);
|
|
|
|
|
unset($data['id']);
|
2020-10-21 20:24:13 +08:00
|
|
|
unset($data['username']);
|
2020-10-13 09:38:55 +08:00
|
|
|
|
2020-10-11 19:23:42 +08:00
|
|
|
$user = $this->userinfo;
|
2020-10-21 20:24:13 +08:00
|
|
|
$cash = new CashMoedl;
|
|
|
|
|
$cash_data = $cash->getOne(['id' => $id]);
|
2020-10-21 20:54:10 +08:00
|
|
|
if ($data['status'] == '1') {
|
2020-10-21 20:24:13 +08:00
|
|
|
|
2025-02-14 15:16:25 +08:00
|
|
|
// $param = [
|
|
|
|
|
// 'out_biz_no' => '2020' . time() . rand(10000, 99999),
|
|
|
|
|
// 'trans_amount' => $cash_data['money'],
|
|
|
|
|
// 'product_code' => 'TRANS_ACCOUNT_NO_PWD',
|
|
|
|
|
// 'biz_scene' => 'DIRECT_TRANSFER',
|
|
|
|
|
// 'payee_info' => [
|
|
|
|
|
// 'identity' => $cash_data['alipay_account'],
|
|
|
|
|
// 'identity_type' => 'ALIPAY_LOGON_ID',
|
|
|
|
|
// 'name' => $cash_data['real_name'],
|
|
|
|
|
// ],
|
|
|
|
|
// 'remark' => '聚IP提现-会员' . $cash_data['username'] . '-' . $cash_data['money'] . '元',
|
|
|
|
|
// ];
|
|
|
|
|
// $result = Alipay::transfer($param);
|
|
|
|
|
// if ($result) {
|
|
|
|
|
// $data['cash_no'] = $result->alipay_fund_trans_uni_transfer_response->out_biz_no;
|
|
|
|
|
// $data['alipay_no'] = $result->alipay_fund_trans_uni_transfer_response->order_id;
|
|
|
|
|
// $data['status'] = 1;
|
|
|
|
|
// } else {
|
2020-10-21 20:24:13 +08:00
|
|
|
$data['status'] = 1;
|
2025-02-14 15:16:25 +08:00
|
|
|
// }
|
2020-10-21 20:54:10 +08:00
|
|
|
} else if ($data['status'] == '2') {
|
2021-02-26 11:01:06 +08:00
|
|
|
if ($cash_data['is_agent'] != 1){
|
|
|
|
|
$user_model = new UserModel;
|
|
|
|
|
$user_rest = $user_model->getOne(['id' => $data['userid']], 'RestAmount')['RestAmount'];
|
|
|
|
|
$rest = $user_rest + $cash_data['money'];
|
|
|
|
|
$user_model->where(['id' => $data['userid']])->update(['RestAmount' => $rest]);
|
|
|
|
|
$score = new ScoreModel;
|
|
|
|
|
$score_data = [
|
|
|
|
|
'UserId' => $data['userid'],
|
|
|
|
|
'ScoreType' => 9,
|
|
|
|
|
'ScoreTypeName' => '提现被拒退还',
|
|
|
|
|
'ScoreValue' => $cash_data['money'],
|
|
|
|
|
'UserName' => $cash_data['username'],
|
|
|
|
|
'OperateUserName' => $user['LoginName'],
|
|
|
|
|
'RestAmount1' => $user_rest,
|
|
|
|
|
'RestAmount2' => $rest,
|
|
|
|
|
'CreateTime' => date('Y-m-d H:i:s', time()),
|
|
|
|
|
'UpdateTime' => date('Y-m-d H:i:s', time()),
|
|
|
|
|
'TenantId' => 0,
|
|
|
|
|
'DeleteTag' => 0,
|
|
|
|
|
];
|
|
|
|
|
$score->add($score_data);
|
|
|
|
|
} else {
|
|
|
|
|
$agent_user_model = new AgentUser;
|
|
|
|
|
$agent_info = $agent_user_model->getOne(['id'=>$cash_data['userid']]);
|
|
|
|
|
$user_rest = $agent_info['account'];
|
|
|
|
|
$rest = $user_rest + $cash_data['money'];
|
|
|
|
|
$agent_user_model->where(['id'=>$cash_data['userid']])->update(['account' => $rest]);
|
|
|
|
|
$score_model = new AgentScoreModel;
|
|
|
|
|
$score['agent_id'] = $cash_data['userid'];
|
|
|
|
|
$score['order_id'] = 0;
|
|
|
|
|
$score['score_type'] = 3;
|
|
|
|
|
$score['score_value'] = $cash_data['money'];
|
|
|
|
|
$score['agent_name'] = $agent_info['realname'];
|
|
|
|
|
$score['op_user'] = $this->userinfo['LoginName'];
|
|
|
|
|
$score['rest_amount1'] = $agent_info['account'];
|
|
|
|
|
$score['rest_amount2'] = $rest;
|
|
|
|
|
$score['remark'] = '提现被拒退还';
|
|
|
|
|
$score_model->add($score);
|
|
|
|
|
}
|
2020-10-21 20:24:13 +08:00
|
|
|
}
|
2020-10-11 19:23:42 +08:00
|
|
|
$data['op_user'] = $user['LoginName'];
|
|
|
|
|
$status = ['0', '1', '2'];
|
2020-10-13 09:38:55 +08:00
|
|
|
if (!in_array($data['status'], $status)) {
|
2020-10-11 19:23:42 +08:00
|
|
|
unset($data['status']);
|
|
|
|
|
}
|
2020-10-21 20:54:10 +08:00
|
|
|
|
2020-10-13 09:38:55 +08:00
|
|
|
$up_status = $cash->where(['id' => $id])->update($data);
|
2020-10-11 19:23:42 +08:00
|
|
|
$return_info = [
|
|
|
|
|
'Code' => 10000,
|
|
|
|
|
];
|
|
|
|
|
echo json_encode($return_info);
|
|
|
|
|
}
|
2020-10-13 09:38:55 +08:00
|
|
|
|
|
|
|
|
//获取记录
|
|
|
|
|
public function search()
|
|
|
|
|
{
|
2020-12-07 17:35:27 +08:00
|
|
|
$data = json_decode(file_get_contents("php://input"), true)['data'];
|
|
|
|
|
$where = [];
|
|
|
|
|
$where_str = '';
|
|
|
|
|
if (!empty($data)) {
|
|
|
|
|
if (!empty($data['username'])) {
|
|
|
|
|
$where['username'] = ['like', '%' . $data['username'] . '%'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($data['op_user'])) {
|
|
|
|
|
$where['op_user'] = ['like', '%' . $data['op_user'] . '%'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($data['create_time']['st'])) {
|
|
|
|
|
$date1 = date('Y-m-d', strtotime($data['create_time']['st']));
|
|
|
|
|
$date2 = date('Y-m-d', strtotime($data['create_time']['et']));
|
|
|
|
|
$where_str = " create_time>='" . $date1 . "' and create_time<='" . $date2 . "' ";
|
|
|
|
|
}
|
|
|
|
|
if ($data['status'] != null) {
|
|
|
|
|
$where['status'] = $data['status'];
|
|
|
|
|
}
|
2021-02-26 11:01:06 +08:00
|
|
|
if ($data['is_agent'] != null){
|
|
|
|
|
$where ['is_agent'] = $data['is_agent'];
|
|
|
|
|
}
|
2020-10-13 09:38:55 +08:00
|
|
|
}
|
2020-12-07 17:35:27 +08:00
|
|
|
$cash = new CashMoedl;
|
|
|
|
|
$list = $cash->search($where, '*', 'id desc', '10000', $where_str);
|
2020-10-13 09:38:55 +08:00
|
|
|
//提现状态
|
|
|
|
|
$status = ['待处理', '同意', '拒绝'];
|
|
|
|
|
foreach ($list as &$v) {
|
|
|
|
|
$v['status'] = $status[$v['status']];
|
|
|
|
|
$v['alipay_account'] = substr($v['alipay_account'], 0, 3) . '***' . substr($v['alipay_account'], -3);
|
|
|
|
|
}
|
|
|
|
|
$data = [
|
|
|
|
|
'Code' => 10000,
|
|
|
|
|
'count' => $count['count'] ?? 0,
|
|
|
|
|
'data' => $list,
|
|
|
|
|
];
|
|
|
|
|
echo json_encode($data);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-22 11:18:33 +08:00
|
|
|
/**
|
|
|
|
|
* @description: 获取一条记录
|
|
|
|
|
* @param {*}
|
|
|
|
|
* @return {*}
|
|
|
|
|
*/
|
|
|
|
|
public function getOneInfo()
|
|
|
|
|
{
|
|
|
|
|
$data = json_decode(file_get_contents("php://input"), true);
|
|
|
|
|
$id = $data['id'];
|
|
|
|
|
$cash = new CashMoedl;
|
|
|
|
|
$info = $cash->getOne(['id' => $id]);
|
|
|
|
|
\result($info,'',30000);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-07 17:35:27 +08:00
|
|
|
/**
|
|
|
|
|
* @description: 导出数据
|
|
|
|
|
* @param {*}
|
|
|
|
|
* @return {*}
|
|
|
|
|
*/
|
|
|
|
|
public function export()
|
|
|
|
|
{
|
|
|
|
|
$data = json_decode(file_get_contents("php://input"), true)['data'];
|
|
|
|
|
$where = [];
|
|
|
|
|
$where_str = '';
|
|
|
|
|
if (!empty($data)) {
|
|
|
|
|
if (!empty($data['username'])) {
|
|
|
|
|
$where['username'] = ['like', '%' . $data['username'] . '%'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($data['op_user'])) {
|
|
|
|
|
$where['op_user'] = ['like', '%' . $data['op_user'] . '%'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($data['create_time']['st'])) {
|
|
|
|
|
$date1 = date('Y-m-d', strtotime($data['create_time']['st']));
|
|
|
|
|
$date2 = date('Y-m-d', strtotime($data['create_time']['et']));
|
|
|
|
|
$where_str = " create_time>='" . $date1 . "' and create_time<='" . $date2 . "' ";
|
|
|
|
|
}
|
|
|
|
|
if ($data['status'] != null) {
|
|
|
|
|
$where['status'] = $data['status'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$cash = new CashMoedl;
|
|
|
|
|
$list = $cash->search($where, '*', 'id desc', '10000', $where_str);
|
|
|
|
|
//提现状态
|
|
|
|
|
$status = ['待处理', '同意', '拒绝'];
|
|
|
|
|
foreach ($list as &$v) {
|
|
|
|
|
$v['status'] = $status[$v['status']];
|
|
|
|
|
$v['alipay_account'] = substr($v['alipay_account'], 0, 3) . '***' . substr($v['alipay_account'], -3);
|
|
|
|
|
}
|
|
|
|
|
\exportToCsv('test.csv',['id','用户id','用户名','真实姓名','账单号','支付宝订单号','状态','提现金额','申请理由','客户支付宝张号','处理人','处理备注','提现时间','处理时间'],$list);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-11 19:23:42 +08:00
|
|
|
}
|