修复提现不显示 问题
This commit is contained in:
parent
8b8958d71e
commit
be870ad1d7
|
@ -9,7 +9,7 @@ use GuzzleHttp\Client;
|
||||||
*/
|
*/
|
||||||
class Payment
|
class Payment
|
||||||
{
|
{
|
||||||
function generate_encrypt_value($data, $secret_key) {
|
public static function generate_encrypt_value($data, $secret_key) {
|
||||||
// 1. 过滤掉 EncryptValue 和值为 null 的参数
|
// 1. 过滤掉 EncryptValue 和值为 null 的参数
|
||||||
$filtered_data = array_filter($data, function($v, $k) {
|
$filtered_data = array_filter($data, function($v, $k) {
|
||||||
return $k !== "EncryptValue" && $v !== null;
|
return $k !== "EncryptValue" && $v !== null;
|
||||||
|
@ -57,7 +57,7 @@ class Payment
|
||||||
"ShopUserLongId" => "776ae472-d4fc-435c-9639-be5763138d95"
|
"ShopUserLongId" => "776ae472-d4fc-435c-9639-be5763138d95"
|
||||||
];
|
];
|
||||||
$secret_key = "sZ2wAfh1lMkxBVrlY4uZY8Fj92E4scFf";
|
$secret_key = "sZ2wAfh1lMkxBVrlY4uZY8Fj92E4scFf";
|
||||||
$encrypt_value = Payment::generate_encrypt_value($payload, $secret_key);
|
$encrypt_value = self::generate_encrypt_value($payload, $secret_key);
|
||||||
$payload["EncryptValue"] = $encrypt_value;
|
$payload["EncryptValue"] = $encrypt_value;
|
||||||
|
|
||||||
$json_payload = json_encode($payload);
|
$json_payload = json_encode($payload);
|
||||||
|
|
|
@ -22,7 +22,7 @@ use Carbon\Carbon;
|
||||||
|
|
||||||
class WithdrawController
|
class WithdrawController
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Apidoc\Title("1.0 查询当前用户提现订单")
|
* @Apidoc\Title("1.0 查询当前用户提现订单")
|
||||||
* @Apidoc\Url("api/withdraw/withdrawCashList")
|
* @Apidoc\Url("api/withdraw/withdrawCashList")
|
||||||
|
@ -30,46 +30,61 @@ class WithdrawController
|
||||||
*/
|
*/
|
||||||
public function withdrawCashList(Request $request)
|
public function withdrawCashList(Request $request)
|
||||||
{
|
{
|
||||||
$page = $request->post('page');
|
$page = $request->post('page', 1); // 默认第一页
|
||||||
$size = $request->post('size');
|
$size = $request->post('size', 15); // 默认每页15条
|
||||||
$status = $request->post('status');
|
$status = $request->post('status', 0); // 默认状态为0(全部)
|
||||||
$time = $request->post('time');
|
$time = $request->post('time', null); // 默认时间不做过滤
|
||||||
|
|
||||||
$userId = $request->data['id'];
|
$userId = $request->data['id'];
|
||||||
// 初始化查询构建器
|
|
||||||
$query = Withdraw::query();
|
|
||||||
|
|
||||||
// 根据状态过滤
|
// 初始化查询构建器
|
||||||
if ($status != 0) {
|
$query = Withdraw::query();
|
||||||
$query->where('status', $status);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据时间过滤
|
// 根据状态过滤
|
||||||
if (!is_null($time)) {
|
if ($status != 0) {
|
||||||
$todayStart = Carbon::now()->startOfDay(); // 今天的开始时间 (00:00:00)
|
$query->where('status', $status);
|
||||||
$todayEnd = Carbon::now()->endOfDay(); // 今天的结束时间 (23:59:59)
|
|
||||||
$yesterdayStart = Carbon::now()->subDay()->startOfDay(); // 昨天的开始时间
|
|
||||||
$sevenDaysAgoStart = Carbon::now()->subDays(7)->startOfDay(); // 七天前的开始时间
|
|
||||||
|
|
||||||
switch ($time) {
|
|
||||||
case 1:
|
|
||||||
$query->whereBetween('createtime2', [$todayStart, $todayEnd]);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$query->whereBetween('createtime2', [$yesterdayStart, $todayStart]);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$query->whereBetween('createtime2', [$sevenDaysAgoStart, $todayEnd]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 添加用户ID过滤条件
|
// 根据时间过滤
|
||||||
$query->where('user_id', $userId);
|
if (!is_null($time)) {
|
||||||
$withdrawOrders = $query->orderBy('createtime2', 'desc')->get();
|
$todayStart = Carbon::now()->startOfDay(); // 今天的开始时间 (00:00:00)
|
||||||
return ApiResponseApp::success($withdrawOrders);
|
$todayEnd = Carbon::now()->endOfDay(); // 今天的结束时间 (23:59:59)
|
||||||
}
|
$yesterdayStart = Carbon::now()->subDay()->startOfDay(); // 昨天的开始时间
|
||||||
|
$sevenDaysAgoStart = Carbon::now()->subDays(7)->startOfDay(); // 七天前的开始时间
|
||||||
|
|
||||||
|
switch ($time) {
|
||||||
|
case 1:
|
||||||
|
$query->whereBetween('createtime2', [$todayStart, $todayEnd]);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$query->whereBetween('createtime2', [$yesterdayStart, $todayEnd]);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$query->whereBetween('createtime2', [$sevenDaysAgoStart, $todayEnd]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加用户ID过滤条件
|
||||||
|
$query->where('user_id', $userId);
|
||||||
|
|
||||||
|
// 查询结果
|
||||||
|
$withdrawOrders = $query->orderBy('createtime2', 'desc')
|
||||||
|
->skip(($page - 1) * $size)
|
||||||
|
->take($size)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// 手动映射字段
|
||||||
|
$withdrawOrders = $withdrawOrders->map(function ($item) {
|
||||||
|
// 将 money 字段映射为 amount
|
||||||
|
$item->amount = $item->money;
|
||||||
|
unset($item->money); // 删除原始的 money 字段
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 返回成功响应
|
||||||
|
return ApiResponseApp::success($withdrawOrders);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Apidoc\Title("小于1000直接转账,大于1000生成审批")
|
* @Apidoc\Title("小于1000直接转账,大于1000生成审批")
|
||||||
|
@ -81,16 +96,16 @@ class WithdrawController
|
||||||
$money_no = $request->post('money');
|
$money_no = $request->post('money');
|
||||||
//不知道啥用
|
//不知道啥用
|
||||||
$bank_id = $request->post('bank_id');
|
$bank_id = $request->post('bank_id');
|
||||||
$user_id=$request->data['id'];
|
$user_id = $request->data['id'];
|
||||||
$user=User::find($user_id);
|
$user = User::find($user_id);
|
||||||
//提现金额
|
//提现金额
|
||||||
$rate = ExchangeRate::where('type','BDT')->get();
|
$rate = ExchangeRate::where('type', 'BDT')->get();
|
||||||
$money = $money_no/100*$rate[0]['points'];
|
$money = $money_no / 100 * $rate[0]['points'];
|
||||||
var_dump($money);
|
var_dump($money);
|
||||||
//用户积分减少$money
|
//用户积分减少$money
|
||||||
UserRewardDao::base($user_id, 1, -($money_no+300), '提现');
|
UserRewardDao::base($user_id, 1, - ($money_no + 300), '提现');
|
||||||
//大于1000等待管理员审核
|
//大于1000等待管理员审核
|
||||||
if($money>=1000){
|
if ($money >= 1000) {
|
||||||
Withdraw::create([
|
Withdraw::create([
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
'amount' => $money,
|
'amount' => $money,
|
||||||
|
@ -99,11 +114,12 @@ class WithdrawController
|
||||||
'username' => $user->username,
|
'username' => $user->username,
|
||||||
'status_text' => '申请中',
|
'status_text' => '申请中',
|
||||||
]);
|
]);
|
||||||
return ApiResponseApp::success(null,'等待管理员审核');
|
return ApiResponseApp::success(null, '等待管理员审核');
|
||||||
}
|
}
|
||||||
$userbank = Userbank::where('user_id',$user_id)->first();
|
$userbank = Userbank::where('user_id', $user_id)->first();
|
||||||
$res = Payment::pushMoney($money,$userbank->bank_username,$userbank->account,$userbank->bank_name);
|
$res = Payment::pushMoney($money, $userbank->bank_username, $userbank->account, $userbank->bank_name);
|
||||||
var_dump($res);
|
var_dump($res);
|
||||||
|
//逻辑错误需要修改
|
||||||
if ($res['Success'] == 200) {
|
if ($res['Success'] == 200) {
|
||||||
Withdraw::create([
|
Withdraw::create([
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
|
@ -113,14 +129,14 @@ class WithdrawController
|
||||||
'username' => $user->username,
|
'username' => $user->username,
|
||||||
'status_text' => '已到账',
|
'status_text' => '已到账',
|
||||||
]);
|
]);
|
||||||
return ApiResponseApp::success(null,'转账成功');
|
return ApiResponseApp::success(null, '转账成功');
|
||||||
}else{
|
} else {
|
||||||
return ApiResponseApp::error(null,'转账失败');
|
return ApiResponseApp::error(null, '转账失败');
|
||||||
}
|
}
|
||||||
return ApiResponseApp::success(null,'转账成功');
|
return ApiResponseApp::success(null, '转账成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Apidoc\Title("管理员同意转账")
|
* @Apidoc\Title("管理员同意转账")
|
||||||
* @Apidoc\Url("api/withdraw/pushMoney")
|
* @Apidoc\Url("api/withdraw/pushMoney")
|
||||||
* @Apidoc\Method("POST")
|
* @Apidoc\Method("POST")
|
||||||
|
@ -140,32 +156,31 @@ class WithdrawController
|
||||||
//管理员审批结果
|
//管理员审批结果
|
||||||
$type = $request->post('type');
|
$type = $request->post('type');
|
||||||
|
|
||||||
if($type == 1){
|
if ($type == 1) {
|
||||||
$res = Payment::pushMoney($amount,$bank_username,$account,$bank_name);
|
$res = Payment::pushMoney($amount, $bank_username, $account, $bank_name);
|
||||||
var_dump($res);
|
var_dump($res);
|
||||||
if ($res['Success'] == 200) {
|
if ($res['Success'] == 200) {
|
||||||
$Withdraw = Withdraw::where('id',$id)->first();
|
$Withdraw = Withdraw::where('id', $id)->first();
|
||||||
$Withdraw->status = 2;
|
$Withdraw->status = 2;
|
||||||
$Withdraw->status_text = '已到账';
|
$Withdraw->status_text = '已到账';
|
||||||
$Withdraw->save();
|
$Withdraw->save();
|
||||||
return ApiResponseApp::success(null,'转账成功');
|
return ApiResponseApp::success(null, '转账成功');
|
||||||
}else{
|
} else {
|
||||||
return ApiResponseApp::error(null,'转账失败');
|
return ApiResponseApp::error(null, '转账失败');
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$Withdraw = Withdraw::where('id',$id)->first();
|
$Withdraw = Withdraw::where('id', $id)->first();
|
||||||
$Withdraw->status = 3;
|
$Withdraw->status = 3;
|
||||||
$Withdraw->status_text = '已驳回';
|
$Withdraw->status_text = '已驳回';
|
||||||
$Withdraw->save();
|
$Withdraw->save();
|
||||||
$rate = ExchangeRate::where('type','BDT')->get();
|
$rate = ExchangeRate::where('type', 'BDT')->get();
|
||||||
//计算积分
|
//计算积分
|
||||||
$money = $amount*100/$rate[0]['points']+300;
|
$money = $amount * 100 / $rate[0]['points'] + 300;
|
||||||
//用户id
|
//用户id
|
||||||
$user_id=$request->data['id'];
|
$user_id = $request->data['id'];
|
||||||
//用户积分增加$money
|
//用户积分增加$money
|
||||||
UserRewardDao::base($user_id, 1, $money, '提现失败返还');
|
UserRewardDao::base($user_id, 1, $money, '提现失败返还');
|
||||||
return ApiResponseApp::error(null,'操作成功');
|
return ApiResponseApp::error(null, '操作成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use app\model\GetLodeLog;
|
||||||
use app\model\User;
|
use app\model\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户是否在线类
|
* 获取今天在线时间超过6小时的用户
|
||||||
*/
|
*/
|
||||||
class Task3
|
class Task3
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,6 @@ class Task3
|
||||||
// });
|
// });
|
||||||
// // 每5秒执行一次
|
// // 每5秒执行一次
|
||||||
new Crontab('0 */5 * * * *', function () {
|
new Crontab('0 */5 * * * *', function () {
|
||||||
echo date('Y-m-d H:i:s')."\n";
|
|
||||||
//获取今天在线时间超过6小时的用户
|
//获取今天在线时间超过6小时的用户
|
||||||
$today = date('Y-m-d');
|
$today = date('Y-m-d');
|
||||||
$UserPhone = UserPhone::where('time', '>=', 3600)::where('time', '<', 4200)::where('created_at','>=',$today)->get();
|
$UserPhone = UserPhone::where('time', '>=', 3600)::where('time', '<', 4200)::where('created_at','>=',$today)->get();
|
||||||
|
|
Loading…
Reference in New Issue