|
|
@@ -4,17 +4,22 @@
|
|
|
*/
|
|
|
|
|
|
namespace app\admin\controller\withdraw;
|
|
|
+
|
|
|
use alipay\AopCertClient;
|
|
|
use alipay\request\AlipayFundTransUniTransferRequest;
|
|
|
+use app\admin\logic\WithdrawLogLogic;
|
|
|
+use app\admin\model\dao\WithdrawLog;
|
|
|
use app\admin\traits\Curd;
|
|
|
use app\api\services\AliPayServices;
|
|
|
use app\api\services\ThirdPayServices;
|
|
|
+use app\validate\admin\withdraw\withdraw\ReturnServiceMoney;
|
|
|
use EasyAdmin\annotation\ControllerAnnotation;
|
|
|
use EasyAdmin\annotation\NodeAnotation;
|
|
|
use app\common\controller\AdminController;
|
|
|
use app\common\model\WithDrawLogModel;
|
|
|
use think\App;
|
|
|
use think\Exception;
|
|
|
+use think\exception\ValidateException;
|
|
|
use think\facade\Db;
|
|
|
|
|
|
/**
|
|
|
@@ -24,17 +29,18 @@ use think\facade\Db;
|
|
|
*/
|
|
|
class Withdraw extends AdminController
|
|
|
{
|
|
|
- public function __construct (App $app, WithDrawLogModel $model)
|
|
|
+ public function __construct(App $app, WithDrawLogModel $model)
|
|
|
{
|
|
|
parent::__construct($app);
|
|
|
$this->model = $model;
|
|
|
}
|
|
|
|
|
|
use Curd;
|
|
|
+
|
|
|
/**
|
|
|
* @NodeAnotation(title="列表")
|
|
|
*/
|
|
|
- public function index ()
|
|
|
+ public function index()
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
if (input('selectFields')) {
|
|
|
@@ -42,8 +48,8 @@ class Withdraw extends AdminController
|
|
|
}
|
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
|
|
|
|
- foreach ($where as $key=>&$val){
|
|
|
- if ($val[0] == 'status'){
|
|
|
+ foreach ($where as $key => &$val) {
|
|
|
+ if ($val[0] == 'status') {
|
|
|
$where[$key][0] = 'w.status';
|
|
|
}
|
|
|
|
|
|
@@ -55,7 +61,7 @@ class Withdraw extends AdminController
|
|
|
->where($this->user_map)
|
|
|
->where($where)
|
|
|
->count();
|
|
|
- $list = $this->model
|
|
|
+ $list = $this->model
|
|
|
->alias('w')
|
|
|
->leftJoin('user u', 'u.id = w.uid')
|
|
|
// ->withJoin('user', 'INNER')
|
|
|
@@ -66,7 +72,9 @@ class Withdraw extends AdminController
|
|
|
->order($this->sort)
|
|
|
->select();
|
|
|
|
|
|
- foreach ($list as $key=>&$val){
|
|
|
+ $withdrawLog = new WithdrawLogLogic();
|
|
|
+
|
|
|
+ foreach ($list as $key => &$val) {
|
|
|
|
|
|
// 老刘下级 13824334135 uid 5344367
|
|
|
// 郑跃兵 17888779318 uid 5344369,13866400965 uid 5344368
|
|
|
@@ -93,32 +101,31 @@ class Withdraw extends AdminController
|
|
|
// }
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// if (strpos($val['path'], '7493433') !== false){
|
|
|
// $val['tips_text'] = '心态下级';
|
|
|
// }
|
|
|
//
|
|
|
- if (strpos($val['path'], '7493466') !== false){
|
|
|
+ if (strpos($val['path'], '7493466') !== false) {
|
|
|
$val['tips_text'] = '郑下级';
|
|
|
}
|
|
|
|
|
|
- if ($val['luzi_money'] > 0){
|
|
|
+ if ($val['luzi_money'] > 0) {
|
|
|
$val['tips_text'] = '撸子标记,不要提现';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$val['tips_text'] = '';
|
|
|
}
|
|
|
|
|
|
+ $val['is_show'] = $withdrawLog->isShowReturnServiceMoney($val['id']);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
// tips_text
|
|
|
$data = [
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => '',
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '',
|
|
|
'count' => $count,
|
|
|
- 'data' => $list,
|
|
|
+ 'data' => $list,
|
|
|
];
|
|
|
return json($data);
|
|
|
}
|
|
|
@@ -146,23 +153,23 @@ class Withdraw extends AdminController
|
|
|
/**
|
|
|
* @NodeAnotation(title="提现失败")
|
|
|
*/
|
|
|
- public function withdrawerror ($id)
|
|
|
+ public function withdrawerror($id)
|
|
|
{
|
|
|
- if ($this->request->isPost()){
|
|
|
+ if ($this->request->isPost()) {
|
|
|
$post = $this->request->post();
|
|
|
- $row = $this->model->where('id', $id)->where('status', 'in', '0')->find();
|
|
|
+ $row = $this->model->where('id', $id)->where('status', 'in', '0')->find();
|
|
|
empty($row) && $this->error('取消失败');
|
|
|
|
|
|
- $row->status = 3;
|
|
|
- $row->fail_log = $post['error_text'];
|
|
|
- $is_backsx = $post['is_backsx'];
|
|
|
+ $row->status = 3;
|
|
|
+ $row->fail_log = $post['error_text'];
|
|
|
+ $is_backsx = $post['is_backsx'];
|
|
|
$row->is_backsx = $is_backsx;
|
|
|
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- if ($is_backsx == 1){
|
|
|
+ if ($is_backsx == 1) {
|
|
|
edit_user_money(10, $row['uid'], $row['apply_money']);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
edit_user_money(10, $row['uid'], $row['practical_money']);
|
|
|
}
|
|
|
|
|
|
@@ -173,7 +180,7 @@ class Withdraw extends AdminController
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
|
- $this->error('取消失败'.$e->getMessage());
|
|
|
+ $this->error('取消失败' . $e->getMessage());
|
|
|
}
|
|
|
$this->success('取消成功');
|
|
|
}
|
|
|
@@ -212,7 +219,7 @@ class Withdraw extends AdminController
|
|
|
/**
|
|
|
* @NodeAnotation(title="执行提现")
|
|
|
*/
|
|
|
- public function tx ($id)
|
|
|
+ public function tx($id)
|
|
|
{
|
|
|
|
|
|
|
|
|
@@ -226,7 +233,7 @@ class Withdraw extends AdminController
|
|
|
if (empty($user) || $user['status'] != 1)
|
|
|
$this->error('用户不存在或已被禁用');
|
|
|
|
|
|
- if ($user['luzi_money'] > 0){
|
|
|
+ if ($user['luzi_money'] > 0) {
|
|
|
$this->error('撸子账号 联系技术处理');
|
|
|
}
|
|
|
|
|
|
@@ -235,54 +242,53 @@ class Withdraw extends AdminController
|
|
|
// $this->error('该用户还未实名认证');
|
|
|
|
|
|
|
|
|
-
|
|
|
Db::name('user')->whereIn('id', $user['path'])->inc('total_team_withdraw', $info['apply_money'])->update();
|
|
|
Db::name('user')->whereIn('id', $user['id'])->inc('total_team_withdraw', $info['apply_money'])->update();
|
|
|
|
|
|
// 支付宝提现
|
|
|
- if ($info['channel'] == 1){
|
|
|
+ if ($info['channel'] == 1) {
|
|
|
|
|
|
// 电科支付宝提现代付
|
|
|
- if(false){
|
|
|
+ if (false) {
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
|
|
|
$interface_url = 'http://1.14.197.47/proxy/pay/fetch'; //正式
|
|
|
- $out_trade_no = createdOrderWithdrawSn($info['uid']);
|
|
|
- $params = [
|
|
|
- 'appId'=>'diankef',
|
|
|
- 'version'=>'1.0',
|
|
|
- 'nonceStr'=>nonce_str(15),
|
|
|
- 'amount'=>intval($info['practical_money']*100),
|
|
|
- 'orderId'=>$out_trade_no,
|
|
|
- 'accountName'=>$info['zfb_name'],
|
|
|
- 'accountNo'=>$info['zfb_number'],
|
|
|
- 'bankName'=>'网商银行',
|
|
|
- 'asyncNotifyUrl'=>env('PAYSQZ.PAYBACK_DAIFU_ZFB_NEWURL'),
|
|
|
- 'quick'=>1,
|
|
|
- 'subject'=>'余额提现'
|
|
|
+ $out_trade_no = createdOrderWithdrawSn($info['uid']);
|
|
|
+ $params = [
|
|
|
+ 'appId' => 'diankef',
|
|
|
+ 'version' => '1.0',
|
|
|
+ 'nonceStr' => nonce_str(15),
|
|
|
+ 'amount' => intval($info['practical_money'] * 100),
|
|
|
+ 'orderId' => $out_trade_no,
|
|
|
+ 'accountName' => $info['zfb_name'],
|
|
|
+ 'accountNo' => $info['zfb_number'],
|
|
|
+ 'bankName' => '网商银行',
|
|
|
+ 'asyncNotifyUrl' => env('PAYSQZ.PAYBACK_DAIFU_ZFB_NEWURL'),
|
|
|
+ 'quick' => 1,
|
|
|
+ 'subject' => '余额提现'
|
|
|
];
|
|
|
|
|
|
ksort($params);
|
|
|
- $services = new ThirdPayServices();
|
|
|
+ $services = new ThirdPayServices();
|
|
|
$params['sign'] = $services->diankesigndf($params);
|
|
|
|
|
|
|
|
|
// 提交确定支付
|
|
|
- sr_log('确认提交提现'.json_encode($params));
|
|
|
+ sr_log('确认提交提现' . json_encode($params));
|
|
|
$result = curlPost($interface_url, $params);
|
|
|
- sr_log('result:'.$result);
|
|
|
+ sr_log('result:' . $result);
|
|
|
|
|
|
$res = json_decode($result);
|
|
|
- if (isset($res->status) && $res->status==9){
|
|
|
+ if (isset($res->status) && $res->status == 9) {
|
|
|
Db::name('withdraw_log')->where('id', $id)->update(['status' => 4, 'out_biz_no' => $out_trade_no, 'update_at' => date('Y-m-d H:i:s', time()), 'final_transfer_type' => 1]);
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sr_throw('支付错误,请联系客服');
|
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
@@ -294,7 +300,6 @@ class Withdraw extends AdminController
|
|
|
$this->success('提现成功');
|
|
|
|
|
|
|
|
|
-
|
|
|
// try {
|
|
|
////
|
|
|
// /** 初始化 **/
|
|
|
@@ -403,9 +408,9 @@ class Withdraw extends AdminController
|
|
|
// sr_log($e->getMessage());
|
|
|
// $this->error('提现失败');
|
|
|
// }
|
|
|
- }else{
|
|
|
- $info->status = 1;
|
|
|
- $info->update_at = date('Y-m-d H:i:s', time());
|
|
|
+ } else {
|
|
|
+ $info->status = 1;
|
|
|
+ $info->update_at = date('Y-m-d H:i:s', time());
|
|
|
$info->final_transfer_type = 3;
|
|
|
|
|
|
$info->save();
|
|
|
@@ -429,24 +434,25 @@ class Withdraw extends AdminController
|
|
|
// }
|
|
|
$this->success('提现成功');
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @NodeAnotation(title="导出")
|
|
|
*/
|
|
|
- public function export ()
|
|
|
+ public function export()
|
|
|
{
|
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
|
$tableName = $this->model->getName();
|
|
|
$tableName = CommonTool::humpToLine(lcfirst($tableName));
|
|
|
- $prefix = config('database.connections.mysql.prefix');
|
|
|
- $dbList = Db::query("show full columns from {$prefix}{$tableName}");
|
|
|
- $header = [];
|
|
|
+ $prefix = config('database.connections.mysql.prefix');
|
|
|
+ $dbList = Db::query("show full columns from {$prefix}{$tableName}");
|
|
|
+ $header = [];
|
|
|
foreach ($dbList as $vo) {
|
|
|
$comment = !empty($vo['Comment']) ? $vo['Comment'] : $vo['Field'];
|
|
|
if (!in_array($vo['Field'], $this->noExportFields)) {
|
|
|
$header[] = [$comment, $vo['Field']];
|
|
|
}
|
|
|
}
|
|
|
- $list = $this->model
|
|
|
+ $list = $this->model
|
|
|
->where($where)
|
|
|
->withJoin('user', 'INNER')
|
|
|
->where($where)
|
|
|
@@ -457,17 +463,50 @@ class Withdraw extends AdminController
|
|
|
$fileName = time();
|
|
|
return Excel::exportData($list, $header, $fileName, 'xlsx');
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @NodeAnotation(title="提现数据")
|
|
|
*/
|
|
|
- public function withdrawdata(){
|
|
|
+ public function withdrawdata()
|
|
|
+ {
|
|
|
|
|
|
- $tx_success = Db::name('withdraw_log')->where('status', 1)->sum('practical_money');
|
|
|
+ $tx_success = Db::name('withdraw_log')->where('status', 1)->sum('practical_money');
|
|
|
$this->assign('tx_success', $tx_success);
|
|
|
|
|
|
- $tx = Db::name('withdraw_log')->where('status', 0)->sum('practical_money');
|
|
|
+ $tx = Db::name('withdraw_log')->where('status', 0)->sum('practical_money');
|
|
|
$this->assign('tx', $tx);
|
|
|
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退还手续费
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function returnservicemoney()
|
|
|
+ {
|
|
|
+ $id = $this->request['id'];
|
|
|
+
|
|
|
+ $withdrawLog = new WithdrawLogLogic();
|
|
|
+ if ($this->request->isPost()) {
|
|
|
+ $post = $this->request->post();
|
|
|
+
|
|
|
+ try {
|
|
|
+ validate(ReturnServiceMoney::class)->check($post);
|
|
|
+ } catch (ValidateException $e) {
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = $withdrawLog->returnServiceMoney($post);
|
|
|
+ if ($result !== true) {
|
|
|
+ $this->error($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+ $withdrawLog->getWithdrawLog($id);
|
|
|
+ $this->assign('info', $withdrawLog);
|
|
|
+
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
}
|