提现修复
This commit is contained in:
@@ -5,16 +5,16 @@
|
|||||||
* @Author: kangkang
|
* @Author: kangkang
|
||||||
* @Date: 2020-10-11 11:22:56
|
* @Date: 2020-10-11 11:22:56
|
||||||
* @LastEditors: kangkang
|
* @LastEditors: kangkang
|
||||||
* @LastEditTime: 2020-10-21 20:01:22
|
* @LastEditTime: 2020-10-21 20:26:56
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace app\order\controller;
|
namespace app\order\controller;
|
||||||
|
|
||||||
|
use alipay\Alipay;
|
||||||
use app\order\model\CashOut as CashMoedl;
|
use app\order\model\CashOut as CashMoedl;
|
||||||
use app\order\model\User as UserModel;
|
use app\order\model\User as UserModel;
|
||||||
use app\order\model\UserScore as ScoreModel;
|
use app\order\model\UserScore as ScoreModel;
|
||||||
use fastphp\base\Controller;
|
use fastphp\base\Controller;
|
||||||
use alipay\Alipay;
|
|
||||||
|
|
||||||
class CashOutAdmin extends Controller
|
class CashOutAdmin extends Controller
|
||||||
{
|
{
|
||||||
@@ -64,8 +64,8 @@ class CashOutAdmin extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 处理订单
|
* @description: 处理订单
|
||||||
* @param {type}
|
* @param {type}
|
||||||
* @return {type}
|
* @return {type}
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
@@ -79,35 +79,33 @@ class CashOutAdmin extends Controller
|
|||||||
$user = $this->userinfo;
|
$user = $this->userinfo;
|
||||||
$cash = new CashMoedl;
|
$cash = new CashMoedl;
|
||||||
$cash_data = $cash->getOne(['id' => $id]);
|
$cash_data = $cash->getOne(['id' => $id]);
|
||||||
if($data['status'] == '1'){
|
if ($data['status'] == '1') {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$param = [
|
$param = [
|
||||||
'out_biz_no'=>'2020'.time().rand(10000,99999),
|
'out_biz_no' => '2020' . time() . rand(10000, 99999),
|
||||||
'trans_amount' => $cash_data['money'],
|
'trans_amount' => $cash_data['money'],
|
||||||
'product_code' => 'TRANS_ACCOUNT_NO_PWD',
|
'product_code' => 'TRANS_ACCOUNT_NO_PWD',
|
||||||
'biz_scene' => 'DIRECT_TRANSFER',
|
'biz_scene' => 'DIRECT_TRANSFER',
|
||||||
'payee_info' => [
|
'payee_info' => [
|
||||||
'identity' => $cash_data['alipay_account'],
|
'identity' => $cash_data['alipay_account'],
|
||||||
'identity_type' => 'ALIPAY_LOGON_ID',
|
'identity_type' => 'ALIPAY_LOGON_ID',
|
||||||
'name' => $cash_data['real_name']
|
'name' => $cash_data['real_name'],
|
||||||
],
|
],
|
||||||
'remark' => '聚IP提现-会员'.$cash_data['username'].'-'.$cash_data['money'].'元'
|
'remark' => '聚IP提现-会员' . $cash_data['username'] . '-' . $cash_data['money'] . '元',
|
||||||
];
|
];
|
||||||
$result = Alipay::transfer($param);
|
$result = Alipay::transfer($param);
|
||||||
if ($result){
|
if ($result) {
|
||||||
$data['cash_no'] = $result->alipay_fund_trans_uni_transfer_response->out_biz_no;
|
$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['alipay_no'] = $result->alipay_fund_trans_uni_transfer_response->order_id;
|
||||||
$data['status'] = 1;
|
$data['status'] = 1;
|
||||||
} else {
|
} else {
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
} else if($data['status'] == '2'){
|
} else if ($data['status'] == '2') {
|
||||||
$user_model = new UserModel;
|
$user_model = new UserModel;
|
||||||
$user_rest = $user_model->getOne(['id'=>$data['userid']],'RestAmount')['RestAmount'];
|
$user_rest = $user_model->getOne(['id' => $data['userid']], 'RestAmount')['RestAmount'];
|
||||||
$rest = $user_rest + $cash_data['money'];
|
$rest = $user_rest + $cash_data['money'];
|
||||||
$user_model->where(['id'=>$data['userid']])->update(['RestAmount'=>$rest]);
|
$user_model->where(['id' => $data['userid']])->update(['RestAmount' => $rest]);
|
||||||
$score = new ScoreModel;
|
$score = new ScoreModel;
|
||||||
$score_data = [
|
$score_data = [
|
||||||
'UserId' => $data['userid'],
|
'UserId' => $data['userid'],
|
||||||
@@ -118,8 +116,8 @@ class CashOutAdmin extends Controller
|
|||||||
'OperateUserName' => $user['LoginName'],
|
'OperateUserName' => $user['LoginName'],
|
||||||
'RestAmount1' => $user_rest,
|
'RestAmount1' => $user_rest,
|
||||||
'RestAmount2' => $rest,
|
'RestAmount2' => $rest,
|
||||||
'CreateTime' => date('Y-m-d H:i:s',time()),
|
'CreateTime' => date('Y-m-d H:i:s', time()),
|
||||||
'UpdateTime' => date('Y-m-d H:i:s',time()),
|
'UpdateTime' => date('Y-m-d H:i:s', time()),
|
||||||
'TenantId' => 0,
|
'TenantId' => 0,
|
||||||
'DeleteTag' => 0,
|
'DeleteTag' => 0,
|
||||||
];
|
];
|
||||||
@@ -130,7 +128,7 @@ class CashOutAdmin extends Controller
|
|||||||
if (!in_array($data['status'], $status)) {
|
if (!in_array($data['status'], $status)) {
|
||||||
unset($data['status']);
|
unset($data['status']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$up_status = $cash->where(['id' => $id])->update($data);
|
$up_status = $cash->where(['id' => $id])->update($data);
|
||||||
$return_info = [
|
$return_info = [
|
||||||
'Code' => 10000,
|
'Code' => 10000,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: your name
|
* @Author: your name
|
||||||
* @Date: 2020-10-10 13:58:14
|
* @Date: 2020-10-10 13:58:14
|
||||||
* @LastEditTime: 2020-10-21 19:57:25
|
* @LastEditTime: 2020-10-21 20:47:18
|
||||||
* @LastEditors: kangkang
|
* @LastEditors: kangkang
|
||||||
* @Description: In User Settings Edit
|
* @Description: In User Settings Edit
|
||||||
* @FilePath: /phptest/app/order/controller/Index.php
|
* @FilePath: /phptest/app/order/controller/Index.php
|
||||||
@@ -28,38 +28,34 @@ class CashOutIndex extends Controller
|
|||||||
$data['apply_reason'] = $post['reason'];
|
$data['apply_reason'] = $post['reason'];
|
||||||
$data['alipay_account'] = $post['alipay_account'];
|
$data['alipay_account'] = $post['alipay_account'];
|
||||||
$data['real_name'] = $post['real_name'];
|
$data['real_name'] = $post['real_name'];
|
||||||
$cash = new CashMoedl;
|
$user = new UserModel;
|
||||||
$status = $cash->add($data);
|
$user_rest = $user->getOne(['id'=>$data['userid']],'RestAmount')['RestAmount'];
|
||||||
if ($status) {
|
$rest = $user_rest - $post['cash_out_money'];
|
||||||
$user = new UserModel;
|
if ($rest < 0){
|
||||||
$user_rest = $user->getOne(['id'=>$data['userid']],'RestAmount')['RestAmount'];
|
|
||||||
$rest = $user_rest - $post['cash_out_money'];
|
|
||||||
if ($rest < 0){
|
|
||||||
echo json_encode(['Code'=>-10000,]);
|
|
||||||
die;
|
|
||||||
} else {
|
|
||||||
$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);
|
|
||||||
$user->where(['id'=>$data['userid']])->update(['RestAmount'=>$rest]);
|
|
||||||
}
|
|
||||||
echo json_encode(['Code'=>10000,]);
|
|
||||||
} else {
|
|
||||||
echo json_encode(['Code'=>-10000,]);
|
echo json_encode(['Code'=>-10000,]);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
echo json_encode(['Code'=>10000,]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取记录
|
//获取记录
|
||||||
|
|||||||
Reference in New Issue
Block a user