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
|
2023-07-29 18:06:18 +08:00
|
|
|
* @LastEditTime: 2023-07-29 18:05:41
|
2023-07-28 18:54:34 +08:00
|
|
|
* @LastEditors: “wanyongkang” “937888580@qq.com”
|
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;
|
2023-07-28 18:54:34 +08:00
|
|
|
use extend\alisms\Sms;
|
|
|
|
|
use app\manager\model\Manager;
|
2020-10-11 19:23:42 +08:00
|
|
|
|
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;
|
2023-07-28 18:54:34 +08:00
|
|
|
$user_one_info = $user->getOne(['id'=>$data['userid']],'RestAmount,ManagerId');
|
|
|
|
|
$user_rest = $user_one_info['RestAmount'];
|
2021-04-23 18:37:43 +08:00
|
|
|
$rest = $user_rest - abs($post['cash_out_money']);
|
2021-04-23 18:33:09 +08:00
|
|
|
|
|
|
|
|
if($data['money']<=0){
|
|
|
|
|
die;
|
|
|
|
|
}
|
2020-10-21 20:54:10 +08:00
|
|
|
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,]);
|
2023-07-29 17:15:12 +08:00
|
|
|
$h = date('H');
|
|
|
|
|
if ($h>8 && $h<23) {
|
|
|
|
|
$alisms = new Sms;
|
2023-07-29 18:06:18 +08:00
|
|
|
$manager_model = new Manager;
|
2023-07-29 17:15:12 +08:00
|
|
|
$manager_info = $manager_model->getOne(['id' => $user_one_info['ManagerId']]);
|
|
|
|
|
if ($manager_info['RoleId'] == 100 && $manager_info['TenantId'] == 1) {
|
|
|
|
|
$alisms::sendToCashout($manager_info['Phone'], ['name'=>$manager_info['RealName'],'phone'=>$data['username']]);
|
|
|
|
|
}
|
2023-07-28 18:54:34 +08:00
|
|
|
}
|
2020-10-11 19:23:42 +08:00
|
|
|
}
|
|
|
|
|
|
2020-10-13 09:38:55 +08:00
|
|
|
//获取记录
|
|
|
|
|
public function getData()
|
|
|
|
|
{
|
|
|
|
|
$cash = new CashMoedl;
|
2021-01-03 15:34:44 +08:00
|
|
|
$list = $cash->getListPage(['userid'=>$this->userinfo['UserId']],'username,money,remark,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
|
|
|
}
|