2020-10-11 19:23:42 +08:00
|
|
|
<?php
|
2020-10-13 09:38:55 +08:00
|
|
|
/*
|
|
|
|
|
* @Author: your name
|
|
|
|
|
* @Date: 2020-10-10 13:58:14
|
2020-10-21 20:54:10 +08:00
|
|
|
* @LastEditTime: 2020-10-21 20:47:18
|
2020-10-14 20:20:49 +08:00
|
|
|
* @LastEditors: kangkang
|
2020-10-13 09:38:55 +08:00
|
|
|
* @Description: In User Settings Edit
|
|
|
|
|
* @FilePath: /phptest/app/order/controller/Index.php
|
|
|
|
|
*/
|
2020-10-11 19:23:42 +08:00
|
|
|
|
|
|
|
|
namespace app\order\controller;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2020-10-14 20:20:49 +08:00
|
|
|
class CashOutIndex extends Controller
|
2020-10-11 19:23:42 +08:00
|
|
|
{
|
|
|
|
|
//接收提现请求
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
$post = json_decode(file_get_contents("php://input"), true);
|
|
|
|
|
$data = [];
|
|
|
|
|
$data['userid'] = $this->userinfo['UserId'];
|
|
|
|
|
$data['username'] = $this->userinfo['LoginName'];
|
|
|
|
|
$data['money'] = $post['cash_out_money'];
|
|
|
|
|
$data['apply_reason'] = $post['reason'];
|
|
|
|
|
$data['alipay_account'] = $post['alipay_account'];
|
2020-10-21 20:24:13 +08:00
|
|
|
$data['real_name'] = $post['real_name'];
|
2020-10-21 20:54:10 +08:00
|
|
|
$user = new UserModel;
|
|
|
|
|
$user_rest = $user->getOne(['id'=>$data['userid']],'RestAmount')['RestAmount'];
|
|
|
|
|
$rest = $user_rest - $post['cash_out_money'];
|
|
|
|
|
if ($rest < 0){
|
2020-10-11 19:23:42 +08:00
|
|
|
echo json_encode(['Code'=>-10000,]);
|
2020-10-21 20:54:10 +08:00
|
|
|
die;
|
|
|
|
|
} else {
|
|
|
|
|
$user->where(['id'=>$data['userid']])->update(['RestAmount'=>$rest]);
|
|
|
|
|
$cash = new CashMoedl;
|
|
|
|
|
$status = $cash->add($data);
|
|
|
|
|
$score = new ScoreModel;
|
|
|
|
|
$score_data = [
|
|
|
|
|
'UserId' => $data['userid'],
|
|
|
|
|
'ScoreType' => 8,
|
|
|
|
|
'ScoreTypeName' => '用户提现扣除',
|
|
|
|
|
'ScoreValue' => $post['cash_out_money'],
|
|
|
|
|
'UserName' => $data['username'],
|
|
|
|
|
'OperateUserName' => $data['username'],
|
|
|
|
|
'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);
|
2020-10-11 19:23:42 +08:00
|
|
|
}
|
2020-10-21 20:54:10 +08:00
|
|
|
echo json_encode(['Code'=>10000,]);
|
2020-10-11 19:23:42 +08:00
|
|
|
}
|
|
|
|
|
|
2020-10-13 09:38:55 +08:00
|
|
|
//获取记录
|
|
|
|
|
public function getData()
|
|
|
|
|
{
|
|
|
|
|
$cash = new CashMoedl;
|
2020-10-22 11:18:33 +08:00
|
|
|
$list = $cash->getListPage(['userid'=>$this->userinfo['UserId']],'username,money,apply_reason,alipay_account,status,create_time');
|
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'], -5);
|
|
|
|
|
}
|
|
|
|
|
$count = $cash->getCount();
|
|
|
|
|
$data = [
|
|
|
|
|
'Code' => 10000,
|
|
|
|
|
'count' => $count['count'],
|
|
|
|
|
'data' => $list,
|
|
|
|
|
];
|
|
|
|
|
echo json_encode($data);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-11 19:23:42 +08:00
|
|
|
}
|