callback
This commit is contained in:
parent
830173e99f
commit
2d3e878e11
91
app/Helpers/TokenHelper.php
Normal file
91
app/Helpers/TokenHelper.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use DateTimeImmutable;
|
||||
|
||||
class TokenHelper
|
||||
{
|
||||
private static $secret = 'ufutx_love_util';
|
||||
|
||||
/**
|
||||
* 生成 token
|
||||
* @param int $userId 用户ID
|
||||
* @param int $expiresIn 过期时间(分钟)
|
||||
* @return string
|
||||
*/
|
||||
public static function generate($userId, $expiresIn = 60)
|
||||
{
|
||||
$now = time();
|
||||
$expires = $now + ($expiresIn * 60);
|
||||
|
||||
$payload = [
|
||||
'user_id' => $userId,
|
||||
'iat' => $now,
|
||||
'exp' => $expires
|
||||
];
|
||||
|
||||
// 使用更简单的方式:base64 编码(避免版本兼容问题)
|
||||
$encoded = base64_encode(json_encode($payload));
|
||||
|
||||
// 添加签名
|
||||
$signature = hash_hmac('sha256', $encoded, self::$secret);
|
||||
|
||||
return $encoded . '.' . $signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证 token
|
||||
* @return array|false
|
||||
*/
|
||||
public static function verify($tokenString)
|
||||
{
|
||||
try {
|
||||
$parts = explode('.', $tokenString);
|
||||
if (count($parts) != 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($payloadEncoded, $signature) = $parts;
|
||||
|
||||
// 验证签名
|
||||
$expectedSignature = hash_hmac('sha256', $payloadEncoded, self::$secret);
|
||||
if (!hash_equals($expectedSignature, $signature)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 解码 payload
|
||||
$payload = json_decode(base64_decode($payloadEncoded), true);
|
||||
if (!$payload) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否过期
|
||||
$now = time();
|
||||
if (isset($payload['exp']) && $payload['exp'] < $now) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return [
|
||||
'user_id' => $payload['user_id'],
|
||||
'expires_at' => $payload['exp']
|
||||
];
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新 token
|
||||
*/
|
||||
public static function refresh($oldToken, $expiresIn = 60)
|
||||
{
|
||||
$payload = self::verify($oldToken);
|
||||
if (!$payload) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::generate($payload['user_id'], $expiresIn);
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,8 @@ class EarningController extends Controller
|
||||
public function updateRule(Request $request, $id)
|
||||
{
|
||||
$rule = EarningRule::find($id);
|
||||
if (empty($rule)) return $this->failure("修改失败,收益规则不存在");
|
||||
if (empty($rule))
|
||||
return $this->failure("修改失败,收益规则不存在");
|
||||
$ratio = $request->input('ratio');
|
||||
if ($request->has('ratio') && $ratio != $rule->ratio) {
|
||||
$rule->ratio = $ratio;
|
||||
@ -84,9 +85,9 @@ class EarningController extends Controller
|
||||
$keyword = $request->input('keyword');
|
||||
if ($keyword) {
|
||||
$keyword = trim($keyword);
|
||||
$accounts = $accounts->whereHas('user', function ($sql) use($keyword) {
|
||||
$sql->where('mobile', 'like', '%'.$keyword.'%')
|
||||
->orWhere('nickname', 'like', '%'.$keyword.'%');
|
||||
$accounts = $accounts->whereHas('user', function ($sql) use ($keyword) {
|
||||
$sql->where('mobile', 'like', '%' . $keyword . '%')
|
||||
->orWhere('nickname', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
$accounts = $accounts->where('user_id', '<>', 0)->orderBy('id', 'desc')->paginate();
|
||||
@ -96,7 +97,8 @@ class EarningController extends Controller
|
||||
public function accountEarnings(Request $request, $id)
|
||||
{
|
||||
$account = EarningAccount::find($id);
|
||||
if (empty($account)) return $this->failure('收益账号不存在');
|
||||
if (empty($account))
|
||||
return $this->failure('收益账号不存在');
|
||||
$earnings = $account->earnings()->with('order:id,goods')->orderBy('id', 'desc')->paginate();
|
||||
return $this->success('ok', compact('account', 'earnings'));
|
||||
}
|
||||
@ -104,7 +106,8 @@ class EarningController extends Controller
|
||||
public function accountWithdraws(Request $request, $id)
|
||||
{
|
||||
$account = EarningAccount::find($id);
|
||||
if (empty($account)) return $this->failure('收益账号不存在');
|
||||
if (empty($account))
|
||||
return $this->failure('收益账号不存在');
|
||||
$withdraws = $account->withdraws()->orderBy('id', 'desc')->paginate();
|
||||
return $this->success('ok', compact('account', 'withdraws'));
|
||||
}
|
||||
@ -114,25 +117,25 @@ class EarningController extends Controller
|
||||
$withdraws = EarningWithdraw::with("user");
|
||||
$status = $request->input('status');
|
||||
if ($status) {
|
||||
$withdraws = $withdraws->where('status',$status);
|
||||
$withdraws = $withdraws->where('status', $status);
|
||||
}
|
||||
$keyword = $request->input('keyword');
|
||||
if ($keyword) {
|
||||
$withdraws = $withdraws->where(function ($sql) use($keyword) {
|
||||
$sql->where(function ($query) use($keyword){
|
||||
$query->where('name', 'like', '%'.$keyword.'%')
|
||||
->orWhere('account', 'like', '%'.$keyword.'%');
|
||||
})->orwhereHas("user", function($query) use($keyword) {
|
||||
$query->where('nickname', 'like', '%'.$keyword.'%');
|
||||
$withdraws = $withdraws->where(function ($sql) use ($keyword) {
|
||||
$sql->where(function ($query) use ($keyword) {
|
||||
$query->where('name', 'like', '%' . $keyword . '%')
|
||||
->orWhere('account', 'like', '%' . $keyword . '%');
|
||||
})->orwhereHas("user", function ($query) use ($keyword) {
|
||||
$query->where('nickname', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
|
||||
});
|
||||
}else {
|
||||
} else {
|
||||
$withdraws = $withdraws->whereHas('user');
|
||||
}
|
||||
$withdraws = $withdraws->orderByDesc('id')->paginate();
|
||||
foreach ($withdraws as $withdraw) {
|
||||
$withdraw->name = $withdraw->name?:$withdraw->user->nickname;
|
||||
$withdraw->name = $withdraw->name ?: $withdraw->user->nickname;
|
||||
}
|
||||
return $this->success('ok', $withdraws);
|
||||
}
|
||||
@ -142,21 +145,25 @@ class EarningController extends Controller
|
||||
Log::info("审核商家提现");
|
||||
try {
|
||||
$log = EarningWithdraw::find($id);
|
||||
if (empty($log)) throw new Exception("提现记录不存在");
|
||||
if ($log->status == 'canceled' || ($log->status == 'finished' && empty($log->err_msg))) return $this->failure("该提现记录已审核");
|
||||
if (empty($log))
|
||||
throw new Exception("提现记录不存在");
|
||||
if ($log->status == 'canceled' || ($log->status == 'finished' && empty($log->err_msg)))
|
||||
return $this->failure("该提现记录已审核");
|
||||
//获取该用户的收益账号
|
||||
$account = $log->earningAccount;
|
||||
if (empty($account)) throw new Exception("提现账号不存在");
|
||||
if (empty($account))
|
||||
throw new Exception("提现账号不存在");
|
||||
$balance = $account->balance;//账户余额
|
||||
$frozen_withdraw = $account->frozen_withdraw;//账户冻结提现金额
|
||||
//如果当前用户冻结提现金额 小于 本次提现金额
|
||||
if($frozen_withdraw < $log->value) throw new Exception('当前账户异常,提现金额大于实际金额');
|
||||
if ($frozen_withdraw < $log->value)
|
||||
throw new Exception('当前账户异常,提现金额大于实际金额');
|
||||
$user = $log->user;
|
||||
if($log->way == 'alipay'){
|
||||
if ($log->way == 'alipay') {
|
||||
$transfer_way = '支付宝';
|
||||
}elseif($log->way == 'weixin'){
|
||||
} elseif ($log->way == 'weixin') {
|
||||
$transfer_way = '微信';
|
||||
}elseif($log->way == 'bank'){
|
||||
} elseif ($log->way == 'bank') {
|
||||
$transfer_way = '银行卡';
|
||||
}
|
||||
DB::beginTransaction();
|
||||
@ -164,49 +171,50 @@ class EarningController extends Controller
|
||||
$admin_id = auth()->id();
|
||||
if ($status == 'canceled') {
|
||||
$err_msg = $request->input('err_msg');
|
||||
if (empty($err_msg)) return $this->failure("请输入拒绝理由");
|
||||
EarningWithdraw::where('id',$id)->update(['status'=>$status, 'err_msg'=>$err_msg, 'admin_id'=>$admin_id, 'audit_at'=>date('Y-m-d H:i:s')]);
|
||||
if (empty($err_msg))
|
||||
return $this->failure("请输入拒绝理由");
|
||||
EarningWithdraw::where('id', $id)->update(['status' => $status, 'err_msg' => $err_msg, 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s')]);
|
||||
$account->increment('balance', $log->value);
|
||||
$account->decrement("frozen_withdraw", $log->value);
|
||||
DB::commit();
|
||||
return $this->success('ok');
|
||||
}
|
||||
$data = [
|
||||
'remark'=>"提现到账",
|
||||
'payee_account'=>$log->account,
|
||||
'payee_real_name'=>$log->name,
|
||||
'amount'=>$log->real_value,
|
||||
'out_biz_no'=>$log->trade_no,
|
||||
'remark' => "提现到账",
|
||||
'payee_account' => $log->account,
|
||||
'payee_real_name' => $log->name,
|
||||
'amount' => $log->real_value,
|
||||
'out_biz_no' => $log->trade_no,
|
||||
];
|
||||
Log::info($data);
|
||||
switch ($log->way) {
|
||||
case 'alipay':
|
||||
$ali = new LiveAlipayService();
|
||||
if($log->alipay_id){//通过支付宝id打款
|
||||
if ($log->alipay_id) {//通过支付宝id打款
|
||||
$data['payee_account'] = $log->alipay_id;
|
||||
$result = $ali->UserTransferAccount($data);
|
||||
}else{//通过支付宝账号和名字打款
|
||||
} else {//通过支付宝账号和名字打款
|
||||
$result = $ali->platTransferAccount($data);
|
||||
}
|
||||
break;
|
||||
case "weixin":
|
||||
$result = \WechatService::officialUserTransferV2($log->trade_no,$log->account,$log->real_value * 100,$data['remark']);
|
||||
$result = \WechatService::officialUserTransferV2($log->trade_no, $log->account, $log->real_value * 100, $data['remark']);
|
||||
Log::info($result);
|
||||
break;
|
||||
}
|
||||
$err_msg = null;
|
||||
if (is_array($result)) {
|
||||
$err_msg = isset($result['msg']) ? $result['msg'] : $result['err_code_des'];
|
||||
}else {
|
||||
} else {
|
||||
$account->increment('withdrawl', $log->value);
|
||||
$account->decrement("frozen_withdraw", $log->value);
|
||||
}
|
||||
|
||||
EarningWithdraw::where('id',$id)->update(['status'=>$status, 'err_msg'=>$err_msg, 'admin_id'=>$admin_id, 'audit_at'=>date('Y-m-d H:i:s')]);
|
||||
EarningWithdraw::where('id', $id)->update(['status' => $status, 'err_msg' => $err_msg, 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s')]);
|
||||
//todo 通知
|
||||
DB::commit();
|
||||
return $this->success('审核完成');
|
||||
}catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
$this->getError($e);
|
||||
return $this->failure();
|
||||
@ -236,17 +244,17 @@ class EarningController extends Controller
|
||||
$keyword = $request->input('keyword');
|
||||
if ($keyword) {
|
||||
$keyword = trim($keyword);
|
||||
$orders = $orders->where(function($sql) use($keyword) {
|
||||
$sql->where('users.nickname', 'like', '%'.$keyword.'%')
|
||||
->orWhere('users.mobile', 'like', '%'.$keyword.'%')
|
||||
->orWhere('orders.goods', 'like', '%'.$keyword.'%');
|
||||
$orders = $orders->where(function ($sql) use ($keyword) {
|
||||
$sql->where('users.nickname', 'like', '%' . $keyword . '%')
|
||||
->orWhere('users.mobile', 'like', '%' . $keyword . '%')
|
||||
->orWhere('orders.goods', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
$users = DB::table('users')->selectRaw('id as user_id, nickname as sharer_user_name, photo as sharer_user_pic, mobile as sharer_user_mobile');
|
||||
$earnings = $earnings->joinSub($orders, 'ufutx_o', function($join) {
|
||||
$join->on('earnings.order_id', '=','o.orders_id');
|
||||
})->leftJoinSub($users, 'ufutx_u', function($join) {
|
||||
$join->on('earnings.user_id', '=','u.user_id');
|
||||
$earnings = $earnings->joinSub($orders, 'ufutx_o', function ($join) {
|
||||
$join->on('earnings.order_id', '=', 'o.orders_id');
|
||||
})->leftJoinSub($users, 'ufutx_u', function ($join) {
|
||||
$join->on('earnings.user_id', '=', 'u.user_id');
|
||||
})->paginate();
|
||||
foreach ($earnings as $earning) {
|
||||
$earning->order_price = PayOrder::where('trade_no', $earning->trade_no)->value('cash');
|
||||
@ -255,52 +263,53 @@ class EarningController extends Controller
|
||||
}
|
||||
|
||||
//提现审核列表
|
||||
public function withdrawalLogs(Request $request){
|
||||
public function withdrawalLogs(Request $request)
|
||||
{
|
||||
$keyword = $request->keyword;
|
||||
$type = $request->type ??'saas';
|
||||
$type = $request->type ?? 'saas';
|
||||
$has_withdraw = 0;
|
||||
$start_time = date('Y-m-d 00:00:00');
|
||||
$end_time = date('Y-m-d 23:59:59');
|
||||
$status = $request->status??'freezing'; //freezing未审核 finished审核通过 canceled审核失败
|
||||
if($type == 'saas'){//saas 商家提现列表
|
||||
$logs = MEarningwithdraws::with('anchor:id,m_id,name,mobile,pic','admin:id,nickname,name,mobile,circle_avatar,app_avatar')->where('status',$status)->where('m_user_id',0)->where('created_at','>','2022-02-24 00:00:00');
|
||||
if($keyword){
|
||||
$status = $request->status ?? 'freezing'; //freezing未审核 finished审核通过 canceled审核失败
|
||||
if ($type == 'saas') {//saas 商家提现列表
|
||||
$logs = MEarningwithdraws::with('anchor:id,m_id,name,mobile,pic', 'admin:id,nickname,name,mobile,circle_avatar,app_avatar')->where('status', $status)->where('m_user_id', 0)->where('created_at', '>', '2022-02-24 00:00:00');
|
||||
if ($keyword) {
|
||||
$keyword = trim($keyword);
|
||||
$logs->whereHas('anchor',function($sql) use($keyword){
|
||||
$sql->where('name','like','%'.$keyword.'%')
|
||||
->orWhere('mobile','like','%'.$keyword.'%');
|
||||
$logs->whereHas('anchor', function ($sql) use ($keyword) {
|
||||
$sql->where('name', 'like', '%' . $keyword . '%')
|
||||
->orWhere('mobile', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
}elseif($type == 'h5'){//福恋h5用户提现列表
|
||||
$logs = EarningWithdraw::with('user:id,name,nickname,mobile,circle_avatar,app_avatar','admin:id,nickname,name,mobile,circle_avatar,app_avatar')->where('status',$status)->where('created_at','>','2022-02-24 00:00:00');
|
||||
if($keyword){
|
||||
} elseif ($type == 'h5') {//福恋h5用户提现列表
|
||||
$logs = EarningWithdraw::with('user:id,name,nickname,mobile,circle_avatar,app_avatar', 'admin:id,nickname,name,mobile,circle_avatar,app_avatar')->where('status', $status)->where('created_at', '>', '2022-02-24 00:00:00');
|
||||
if ($keyword) {
|
||||
$keyword = trim($keyword);
|
||||
$logs->whereHas('user',function($sql) use($keyword){
|
||||
$sql->where('name','like','%'.$keyword.'%')
|
||||
->orWhere('mobile','like','%'.$keyword.'%')
|
||||
->orWhere('nickname','like','%'.$keyword.'%');
|
||||
$logs->whereHas('user', function ($sql) use ($keyword) {
|
||||
$sql->where('name', 'like', '%' . $keyword . '%')
|
||||
->orWhere('mobile', 'like', '%' . $keyword . '%')
|
||||
->orWhere('nickname', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
}else{//saas H5用户提现列表
|
||||
$logs = MEarningwithdraws::with('user:id,nickname,mobile,pic as avatar','admin:id,nickname,name,mobile,circle_avatar,app_avatar')->where('status',$status)->where('m_user_id','<>',0)->where('created_at','>','2022-02-24 00:00:00');
|
||||
if($keyword){
|
||||
} else {//saas H5用户提现列表
|
||||
$logs = MEarningwithdraws::with('user:id,nickname,mobile,pic as avatar', 'admin:id,nickname,name,mobile,circle_avatar,app_avatar')->where('status', $status)->where('m_user_id', '<>', 0)->where('created_at', '>', '2022-02-24 00:00:00');
|
||||
if ($keyword) {
|
||||
$keyword = trim($keyword);
|
||||
$logs->whereHas('user',function($sql) use($keyword){
|
||||
$sql->where('nickname','like','%'.$keyword.'%')
|
||||
->orWhere('mobile','like','%'.$keyword.'%');
|
||||
$logs->whereHas('user', function ($sql) use ($keyword) {
|
||||
$sql->where('nickname', 'like', '%' . $keyword . '%')
|
||||
->orWhere('mobile', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
$logs = $logs->orderBy('id','desc')->paginate();
|
||||
$logs = $logs->orderBy('id', 'desc')->paginate();
|
||||
foreach ($logs as $key => $log) {
|
||||
if($log->m_id){//saas端提现
|
||||
$has_withdraw = MEarningwithdraws::where(['m_id'=>$log->m_id,'m_user_id'=>$log->m_user_id,'status'=>'finished'])->whereBetWeen('created_at',[$start_time,$end_time])->sum('value');
|
||||
}elseif($log->user_id){//h5提现
|
||||
$has_withdraw = EarningWithdraw::where(['user_id'=>$log->user_id,'status'=>'finished'])->whereBetWeen('created_at',[$start_time,$end_time])->sum('value');
|
||||
if ($log->m_id) {//saas端提现
|
||||
$has_withdraw = MEarningwithdraws::where(['m_id' => $log->m_id, 'm_user_id' => $log->m_user_id, 'status' => 'finished'])->whereBetWeen('created_at', [$start_time, $end_time])->sum('value');
|
||||
} elseif ($log->user_id) {//h5提现
|
||||
$has_withdraw = EarningWithdraw::where(['user_id' => $log->user_id, 'status' => 'finished'])->whereBetWeen('created_at', [$start_time, $end_time])->sum('value');
|
||||
}
|
||||
$log->has_withdraw = $has_withdraw;//用户当日提现金额
|
||||
}
|
||||
return $this->success('ok',$logs);
|
||||
return $this->success('ok', $logs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,64 +319,73 @@ class EarningController extends Controller
|
||||
* @param $id
|
||||
* @return JsonResponse|string
|
||||
*/
|
||||
public function auditWithdraw(Request $request,$id){
|
||||
public function auditWithdraw(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$admin_id = auth()->id();
|
||||
$log = MEarningwithdraws::where('id',$id)->where('status','freezing')->first();
|
||||
if(empty($log)) return $this->failure('该记录不存在或已被其他管理员审核');
|
||||
$log = MEarningwithdraws::where('id', $id)->where('status', 'freezing')->first();
|
||||
if (empty($log))
|
||||
return $this->failure('该记录不存在或已被其他管理员审核');
|
||||
//获取该商户的收益账号
|
||||
$account = MEarningAccount::where('m_id',$log->m_id)->where('m_user_id',0)->first();
|
||||
$account = MEarningAccount::where('m_id', $log->m_id)->where('m_user_id', 0)->first();
|
||||
$balance = $account->balance;//账户余额
|
||||
$frozen_withdraw = $account->frozen_withdraw;//账户冻结提现金额
|
||||
//如果当前用户冻结提现金额 小于 本次提现金额
|
||||
if($frozen_withdraw < $log->value) return $this->failure('当前账户异常,联系开发人员处理');
|
||||
$anchor = Anchor::where('m_id',$log->m_id)->first();
|
||||
$openid = MerchantAccount::where('id',$log->m_id)->value('openid');//商家openid
|
||||
if(empty($openid)) $openid = $anchor->openid;
|
||||
if($log->way == 'alipay'){
|
||||
if ($frozen_withdraw < $log->value)
|
||||
return $this->failure('当前账户异常,联系开发人员处理');
|
||||
$anchor = Anchor::where('m_id', $log->m_id)->first();
|
||||
$openid = MerchantAccount::where('id', $log->m_id)->value('openid');//商家openid
|
||||
if (empty($openid))
|
||||
$openid = $anchor->openid;
|
||||
if ($log->way == 'alipay') {
|
||||
$transfer_way = '支付宝';
|
||||
}elseif($log->way == 'weixin'){
|
||||
} elseif ($log->way == 'weixin') {
|
||||
$transfer_way = '微信';
|
||||
}elseif($log->way == 'bank'){
|
||||
} elseif ($log->way == 'bank') {
|
||||
$transfer_way = '银行卡';
|
||||
}
|
||||
$status = $request->status;
|
||||
if(!in_array($status,['finished','canceled','manual'])) throw new \Exception("提供审核参数有误",1);
|
||||
if (!in_array($status, ['finished', 'canceled', 'manual']))
|
||||
throw new \Exception("提供审核参数有误", 1);
|
||||
$data = [];
|
||||
$data['remark'] = '提现已到账'; //提现备注
|
||||
$data['out_biz_no'] = $log->trade_no;
|
||||
$data['amount'] = $log->real_value;//实际到账金额
|
||||
$data['payee_account'] = $log->account;//支付宝账号
|
||||
$data['payee_real_name'] = $log->name;//支付宝绑定姓名
|
||||
if($log->alipay_id) $data['payee_account'] = $log->alipay_id;
|
||||
if ($log->alipay_id)
|
||||
$data['payee_account'] = $log->alipay_id;
|
||||
$url = '';
|
||||
DB::beginTransaction();
|
||||
switch ($status){
|
||||
switch ($status) {
|
||||
case 'finished': //审核通过
|
||||
if($log->way == 'alipay'){
|
||||
if ($log->way == 'alipay') {
|
||||
$ali = new LiveAlipayService();
|
||||
if($log->alipay_id){//通过支付宝id打款
|
||||
if ($log->alipay_id) {//通过支付宝id打款
|
||||
$result = $ali->UserTransferAccount($data);
|
||||
}else{//通过支付宝账号和名字打款
|
||||
} else {//通过支付宝账号和名字打款
|
||||
$result = $ali->platTransferAccount($data);
|
||||
}
|
||||
}elseif($log->way == 'weixin'){
|
||||
$result = \WechatService::officialUserTransferV2($log->trade_no,$log->account,$log->real_value * 100,'提现已到账');
|
||||
}elseif($log->way == 'bank'){
|
||||
$result = \WechatService::bankTransfer($log->trade_no,$log->account,$log->name,$log->bank_code,$log->real_value * 100,'打款至个人银行卡');
|
||||
} elseif ($log->way == 'weixin') {
|
||||
// $result = \WechatService::officialUserTransferV2($log->trade_no,$log->account,$log->real_value * 100,'提现已到账');
|
||||
// 商家转账(需用户确认)
|
||||
$result = \WechatService::officialUserTransferV3($log);
|
||||
|
||||
} elseif ($log->way == 'bank') {
|
||||
$result = \WechatService::bankTransfer($log->trade_no, $log->account, $log->name, $log->bank_code, $log->real_value * 100, '打款至个人银行卡');
|
||||
}
|
||||
//\Log::info($result);
|
||||
//判断打款是否成功
|
||||
if(is_array($result)){//失败
|
||||
if (is_array($result)) {//失败
|
||||
//\Log::info('打款失败');
|
||||
$err_msg = isset($result['msg']) ? $result['msg'] : $result['err_code_des'];
|
||||
return $this->failure($err_msg);
|
||||
$log->update(['status'=>'canceled','admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s'),'err_msg'=>$err_msg]);
|
||||
$account->update(['frozen_withdraw'=>$frozen_withdraw - $log->value,'balance'=>$balance + $log->value]);
|
||||
$log->update(['status' => 'canceled', 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s'), 'err_msg' => $err_msg]);
|
||||
$account->update(['frozen_withdraw' => $frozen_withdraw - $log->value, 'balance' => $balance + $log->value]);
|
||||
// 短信通知 邓智锋
|
||||
$mobile = '15707534403';
|
||||
$message = '商户' . $anchor->name . ' 提现' . $log->real_value . '元失败,原因:' . $err_msg;
|
||||
$this->sentMessage($mobile,$message);
|
||||
$this->sentMessage($mobile, $message);
|
||||
//模板通知 邓智锋
|
||||
$data['touser'] = ['oPC_2vnSECnYp5p--uaq3rca3Ry0', 'oPC_2vpJd34uN2E1tTsFbf8Lhlcs'];
|
||||
$data['template_id'] = 'AqwVt0liVmQfzfnX3ZGvmVOdOh62nkCbhlOUI0NVQGs';
|
||||
@ -381,13 +399,13 @@ class EarningController extends Controller
|
||||
];
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
//短信通知
|
||||
$message = $anchor->name.',提现'.$log->real_value.'元失败,具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($anchor->mobile,$message);
|
||||
$message = $anchor->name . ',提现' . $log->real_value . '元失败,具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($anchor->mobile, $message);
|
||||
DB::commit();
|
||||
return $this->failure($err_msg);
|
||||
}else{//成功
|
||||
} else {//成功
|
||||
//\Log::info('打款成功');
|
||||
$log->update(['status'=>'finished','admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s')]);
|
||||
$log->update(['status' => 'finished', 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s')]);
|
||||
//将冻结提现金额 换成已提现金额 //冻结提现金额 0
|
||||
$account->withdrawl = $account->withdrawl + $log->value;
|
||||
$account->frozen_withdraw = $account->frozen_withdraw - $log->value;
|
||||
@ -397,23 +415,24 @@ class EarningController extends Controller
|
||||
$data['template_id'] = 'aV4ic7jr5bOlf55CgR0jmMsFYyhdRAiVmqqXEjnUqQU';
|
||||
$data['url'] = $url;
|
||||
$data['data'] = [
|
||||
'first' => '提现已到账,请在'.$transfer_way.'查收',
|
||||
'first' => '提现已到账,请在' . $transfer_way . '查收',
|
||||
'keyword1' => $log->real_value . '元',
|
||||
'keyword2' => date('Y-m-d H:i:s'),
|
||||
'keyword3' => '提现到'.$transfer_way.'余额',
|
||||
'keyword3' => '提现到' . $transfer_way . '余额',
|
||||
'remark' => '感谢您的的使用',
|
||||
];
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
//短信通知
|
||||
$message = $anchor->name.',提现金额'.$log->real_value.'元已到账,请在'.$transfer_way.'查收。';
|
||||
$this->sentMessage($anchor->mobile,$message);
|
||||
$message = $anchor->name . ',提现金额' . $log->real_value . '元已到账,请在' . $transfer_way . '查收。';
|
||||
$this->sentMessage($anchor->mobile, $message);
|
||||
}
|
||||
break;
|
||||
case 'canceled': //审核拒绝
|
||||
$reason = $request->reason;
|
||||
if(!$reason) return $this->failure('请输入拒绝理由');
|
||||
$account->update(['frozen_withdraw'=>$frozen_withdraw - $log->value,'balance'=>$balance + $log->value]);
|
||||
$log->update(['status'=>$status,'admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s'),'err_msg'=>$request->reason]);
|
||||
if (!$reason)
|
||||
return $this->failure('请输入拒绝理由');
|
||||
$account->update(['frozen_withdraw' => $frozen_withdraw - $log->value, 'balance' => $balance + $log->value]);
|
||||
$log->update(['status' => $status, 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s'), 'err_msg' => $request->reason]);
|
||||
$data['touser'] = $openid;
|
||||
$data['template_id'] = 'AqwVt0liVmQfzfnX3ZGvmVOdOh62nkCbhlOUI0NVQGs';
|
||||
$data['url'] = $url;
|
||||
@ -424,24 +443,24 @@ class EarningController extends Controller
|
||||
'keyword3' => $reason,
|
||||
'remark' => '账号信息存在异常',
|
||||
];
|
||||
$message = $anchor->name.',提现'.$log->real_value.'元失败,失败原因:'.$reason.',具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($anchor->mobile,$message);
|
||||
$message = $anchor->name . ',提现' . $log->real_value . '元失败,失败原因:' . $reason . ',具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($anchor->mobile, $message);
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
break;
|
||||
case 'manual': //手工处理
|
||||
//\Log::info('打款已经由人工处理');
|
||||
$log->update(['status'=>'finished','admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s'),'way'=>'manual']);
|
||||
$log->update(['status' => 'finished', 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s'), 'way' => 'manual']);
|
||||
//将冻结提现金额 换成已提现金额 //冻结提现金额 0
|
||||
$account->withdrawl = $account->withdrawl + $log->value;
|
||||
$account->frozen_withdraw = $account->frozen_withdraw - $log->value;
|
||||
$account->save();
|
||||
//模板通知用户
|
||||
$data['touser'] = ['oPC_2vudVLVHj2U7dNinr2IEDHR4','oPC_2vuTj7YRgUzQQY7PlSJVLBBc'];
|
||||
$data['touser'] = ['oPC_2vudVLVHj2U7dNinr2IEDHR4', 'oPC_2vuTj7YRgUzQQY7PlSJVLBBc'];
|
||||
$data['template_id'] = 'OwXPF2dKEjPQUoGyzH944ATsJ6SgxpZ8kzB-KVVxanY';
|
||||
$data['url'] = $url;
|
||||
$data['data'] = [
|
||||
'first' => '商户:' . $anchor->name . '提现人工审核通过,处理方式:手工打款,请即时处理',
|
||||
'keyword1' => $anchor->name,
|
||||
'keyword1' => $anchor->name,
|
||||
'keyword2' => date('Y-m-d H:i:s'),
|
||||
'keyword3' => $log->real_value . '元',
|
||||
'keyword4' => '手动打款处理',
|
||||
@ -462,56 +481,61 @@ class EarningController extends Controller
|
||||
}
|
||||
|
||||
//福恋h5提现审核
|
||||
public function auditWithdrawH5(Request $request,$id){
|
||||
public function auditWithdrawH5(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$admin_id = auth()->id();
|
||||
$log = EarningWithdraw::where('id',$id)->where('status','freezing')->first();
|
||||
if(empty($log)) return $this->failure('该记录不存在或已被其他管理员审核');
|
||||
$log = EarningWithdraw::where('id', $id)->where('status', 'freezing')->first();
|
||||
if (empty($log))
|
||||
return $this->failure('该记录不存在或已被其他管理员审核');
|
||||
//获取该用户的收益账号
|
||||
$account = EarningAccount::where('user_id',$log->user_id)->first();
|
||||
$account = EarningAccount::where('user_id', $log->user_id)->first();
|
||||
$balance = $account->balance;//账户余额
|
||||
$frozen_withdraw = $account->frozen_withdraw;//账户冻结提现金额
|
||||
//如果当前用户冻结提现金额 小于 本次提现金额
|
||||
if($frozen_withdraw < $log->value) return $this->failure('当前账户异常,联系开发人员处理');
|
||||
$user = User::where('id',$log->user_id)->first();
|
||||
if ($frozen_withdraw < $log->value)
|
||||
return $this->failure('当前账户异常,联系开发人员处理');
|
||||
$user = User::where('id', $log->user_id)->first();
|
||||
$openid = $user->wechat ? $user->wechat->official_openid : '';
|
||||
$transfer_way = $log->way == 'alipay' ? '支付宝' : '微信';//转账方式
|
||||
$status = $request->status;
|
||||
if(!in_array($status,['finished','canceled','manual'])) throw new \Exception("提供审核参数有误",1);
|
||||
if (!in_array($status, ['finished', 'canceled', 'manual']))
|
||||
throw new \Exception("提供审核参数有误", 1);
|
||||
$data = [];
|
||||
$data['remark'] = '提现已到账'; //提现备注
|
||||
$data['out_biz_no'] = $log->trade_no;
|
||||
$data['amount'] = $log->real_value;//实际到账金额
|
||||
$data['payee_account'] = $log->account;//支付宝账号
|
||||
$data['payee_real_name'] = $log->name;//支付宝绑定姓名
|
||||
if($log->alipay_id) $data['payee_account'] = $log->alipay_id;
|
||||
if ($log->alipay_id)
|
||||
$data['payee_account'] = $log->alipay_id;
|
||||
$ali = new LiveAlipayService();
|
||||
$url = '';
|
||||
$alipay_real_name = empty($data['payee_real_name']) ? $data['alipay_id'] :$data['payee_real_name'];
|
||||
$alipay_real_name = empty($data['payee_real_name']) ? $data['alipay_id'] : $data['payee_real_name'];
|
||||
DB::beginTransaction();
|
||||
if($status == 'finished'){//审核通过
|
||||
if ($status == 'finished') {//审核通过
|
||||
//todo 打款 发送通知
|
||||
if($log->way == 'alipay'){
|
||||
if($log->alipay_id){//通过支付宝id打款
|
||||
if ($log->way == 'alipay') {
|
||||
if ($log->alipay_id) {//通过支付宝id打款
|
||||
$result = $ali->UserTransferAccount($data);
|
||||
}else{//通过支付宝账号和名字打款
|
||||
} else {//通过支付宝账号和名字打款
|
||||
$result = $ali->platTransferAccount($data);
|
||||
}
|
||||
}elseif($log->way == 'weixin'){
|
||||
$result = \WechatService::officialUserTransferV2($log->trade_no,$log->account,$log->real_value * 100,'提现已到账');
|
||||
} elseif ($log->way == 'weixin') {
|
||||
$result = \WechatService::officialUserTransferV2($log->trade_no, $log->account, $log->real_value * 100, '提现已到账');
|
||||
}
|
||||
//\Log::info($result);
|
||||
//判断打款是否成功
|
||||
if(is_array($result)){//失败
|
||||
if (is_array($result)) {//失败
|
||||
//\Log::info('打款失败');
|
||||
$err_msg = isset($result['msg']) ? $result['msg'] : $result['err_code_des'];
|
||||
return $this->failure($err_msg);
|
||||
$log->update(['status'=>'canceled','admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s'),'err_msg'=>$err_msg]);
|
||||
$account->update(['frozen_withdraw'=>$frozen_withdraw - $log->value,'balance'=>$balance + $log->value]);
|
||||
$log->update(['status' => 'canceled', 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s'), 'err_msg' => $err_msg]);
|
||||
$account->update(['frozen_withdraw' => $frozen_withdraw - $log->value, 'balance' => $balance + $log->value]);
|
||||
// 短信通知 邓智锋
|
||||
$mobile = '15707534403';
|
||||
$message = '福恋h5用户' . $alipay_real_name . ' 提现' . $log->value . '元失败,原因:' . $err_msg;
|
||||
$this->sentMessage($mobile,$message);
|
||||
$this->sentMessage($mobile, $message);
|
||||
//模板通知 邓智锋
|
||||
$data['touser'] = ['oPC_2vnSECnYp5p--uaq3rca3Ry0', 'oPC_2vpJd34uN2E1tTsFbf8Lhlcs'];
|
||||
$data['template_id'] = 'AqwVt0liVmQfzfnX3ZGvmVOdOh62nkCbhlOUI0NVQGs';
|
||||
@ -525,13 +549,13 @@ class EarningController extends Controller
|
||||
];
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
//短信通知
|
||||
$message = $user->name.',提现'.$log->value.'元失败,具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($user->mobile,$message);
|
||||
$message = $user->name . ',提现' . $log->value . '元失败,具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($user->mobile, $message);
|
||||
DB::commit();
|
||||
return $this->failure($err_msg);
|
||||
}else{//成功
|
||||
} else {//成功
|
||||
//\Log::info('打款成功');
|
||||
$log->update(['status'=>'finished','admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s')]);
|
||||
$log->update(['status' => 'finished', 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s')]);
|
||||
//将冻结提现金额 换成已提现金额 //冻结提现金额 0
|
||||
$account->withdrawl = $account->withdrawl + $log->value;
|
||||
$account->frozen_withdraw = $account->frozen_withdraw - $log->value;
|
||||
@ -541,22 +565,23 @@ class EarningController extends Controller
|
||||
$data['template_id'] = 'aV4ic7jr5bOlf55CgR0jmMsFYyhdRAiVmqqXEjnUqQU';
|
||||
$data['url'] = $url;
|
||||
$data['data'] = [
|
||||
'first' => '提现已到账,请在'.$transfer_way.'查收',
|
||||
'first' => '提现已到账,请在' . $transfer_way . '查收',
|
||||
'keyword1' => $log->real_value . '元',
|
||||
'keyword2' => date('Y-m-d H:i:s'),
|
||||
'keyword3' => '提现到'.$transfer_way.'余额',
|
||||
'keyword3' => '提现到' . $transfer_way . '余额',
|
||||
'remark' => '感谢您的的使用',
|
||||
];
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
//短信通知
|
||||
$message = $user->name.',提现金额'.$log->real_value.'元已到账,请在'.$transfer_way.'查收。';
|
||||
$this->sentMessage($user->mobile,$message);
|
||||
$message = $user->name . ',提现金额' . $log->real_value . '元已到账,请在' . $transfer_way . '查收。';
|
||||
$this->sentMessage($user->mobile, $message);
|
||||
}
|
||||
}elseif($status == 'canceled'){//审核失败
|
||||
} elseif ($status == 'canceled') {//审核失败
|
||||
$reason = $request->reason;
|
||||
if(!$reason) return $this->failure('请输入拒绝理由');
|
||||
$account->update(['frozen_withdraw'=>$frozen_withdraw - $log->value,'balance'=>$balance + $log->value]);
|
||||
$log->update(['status'=>$status,'admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s'),'err_msg'=>$request->reason]);
|
||||
if (!$reason)
|
||||
return $this->failure('请输入拒绝理由');
|
||||
$account->update(['frozen_withdraw' => $frozen_withdraw - $log->value, 'balance' => $balance + $log->value]);
|
||||
$log->update(['status' => $status, 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s'), 'err_msg' => $request->reason]);
|
||||
//todo 短信通知 公众号通知拒绝理由
|
||||
$data['touser'] = $openid;
|
||||
$data['template_id'] = 'AqwVt0liVmQfzfnX3ZGvmVOdOh62nkCbhlOUI0NVQGs';
|
||||
@ -568,23 +593,23 @@ class EarningController extends Controller
|
||||
'keyword3' => $reason,
|
||||
'remark' => '账号信息存在异常',
|
||||
];
|
||||
$message = $user->name.',提现'.$log->real_value.'元失败,失败原因:'.$reason.',具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($user->mobile,$message);
|
||||
$message = $user->name . ',提现' . $log->real_value . '元失败,失败原因:' . $reason . ',具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($user->mobile, $message);
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
}elseif($status == 'manual'){
|
||||
} elseif ($status == 'manual') {
|
||||
//\Log::info('打款已经由人工处理');
|
||||
$log->update(['status'=>'finished','admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s'),'way'=>'manual']);
|
||||
$log->update(['status' => 'finished', 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s'), 'way' => 'manual']);
|
||||
//将冻结提现金额 换成已提现金额 //冻结提现金额 0
|
||||
$account->withdrawl = $account->withdrawl + $log->value;
|
||||
$account->frozen_withdraw = $account->frozen_withdraw - $log->value;
|
||||
$account->save();
|
||||
//模板通知用户
|
||||
$data['touser'] = ['oPC_2vudVLVHj2U7dNinr2IEDHR4','oPC_2vuTj7YRgUzQQY7PlSJVLBBc'];
|
||||
$data['touser'] = ['oPC_2vudVLVHj2U7dNinr2IEDHR4', 'oPC_2vuTj7YRgUzQQY7PlSJVLBBc'];
|
||||
$data['template_id'] = 'OwXPF2dKEjPQUoGyzH944ATsJ6SgxpZ8kzB-KVVxanY';
|
||||
$data['url'] = $url;
|
||||
$data['data'] = [
|
||||
'first' => '商户:' . $alipay_real_name . '提现人工审核通过,处理方式:手工打款,请即时处理',
|
||||
'keyword1' => $alipay_real_name,
|
||||
'keyword1' => $alipay_real_name,
|
||||
'keyword2' => date('Y-m-d H:i:s'),
|
||||
'keyword3' => $log->real_value . '元',
|
||||
'keyword4' => '手动打款处理',
|
||||
@ -608,61 +633,66 @@ class EarningController extends Controller
|
||||
* @param $id
|
||||
* @return JsonResponse|string
|
||||
*/
|
||||
public function auditWithdrawSaasH5(Request $request,$id){
|
||||
public function auditWithdrawSaasH5(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$admin_id = auth()->id();
|
||||
$log = MEarningwithdraws::where('id',$id)->where('status','freezing')->first();
|
||||
if(empty($log)) return $this->failure('该记录不存在或已被其他管理员审核');
|
||||
$log = MEarningwithdraws::where('id', $id)->where('status', 'freezing')->first();
|
||||
if (empty($log))
|
||||
return $this->failure('该记录不存在或已被其他管理员审核');
|
||||
//获取该用户的收益账号
|
||||
$account = MEarningAccount::where('m_id',$log->m_id)->where('m_user_id',$log->m_user_id)->first();
|
||||
$account = MEarningAccount::where('m_id', $log->m_id)->where('m_user_id', $log->m_user_id)->first();
|
||||
$balance = $account->balance;//账户余额
|
||||
$frozen_withdraw = $account->frozen_withdraw;//账户冻结提现金额
|
||||
//如果当前用户冻结提现金额 小于 本次提现金额
|
||||
if($frozen_withdraw < $log->value) return $this->failure('当前账户异常,联系开发人员处理');
|
||||
$merchant_user = MerchantUser::where('id',$log->m_user_id)->first();
|
||||
if ($frozen_withdraw < $log->value)
|
||||
return $this->failure('当前账户异常,联系开发人员处理');
|
||||
$merchant_user = MerchantUser::where('id', $log->m_user_id)->first();
|
||||
$status = $request->status;
|
||||
if($log->way == 'alipay'){
|
||||
if ($log->way == 'alipay') {
|
||||
$transfer_way = '支付宝';
|
||||
}elseif($log->way == 'weixin'){
|
||||
} elseif ($log->way == 'weixin') {
|
||||
$transfer_way = '微信';
|
||||
}elseif($log->way == 'bank'){
|
||||
} elseif ($log->way == 'bank') {
|
||||
$transfer_way = '银行卡';
|
||||
}
|
||||
if(!in_array($status,['finished','canceled','manual'])) throw new \Exception("提供审核参数有误",1);
|
||||
if (!in_array($status, ['finished', 'canceled', 'manual']))
|
||||
throw new \Exception("提供审核参数有误", 1);
|
||||
$data = [];
|
||||
$data['remark'] = '提现已到账'; //提现备注
|
||||
$data['out_biz_no'] = $log->trade_no;
|
||||
$data['amount'] = $log->real_value;//实际到账金额
|
||||
$data['payee_account'] = $log->account;//支付宝账号
|
||||
$data['payee_real_name'] = $log->name;//支付宝绑定姓名
|
||||
if($log->alipay_id) $data['payee_account'] = $log->alipay_id;
|
||||
if ($log->alipay_id)
|
||||
$data['payee_account'] = $log->alipay_id;
|
||||
$ali = new LiveAlipayService();
|
||||
$url = '';
|
||||
$alipay_real_name = empty($data['payee_real_name']) ? $log->alipay_id :$data['payee_real_name'];
|
||||
$alipay_real_name = empty($data['payee_real_name']) ? $log->alipay_id : $data['payee_real_name'];
|
||||
DB::beginTransaction();
|
||||
switch ($status){
|
||||
switch ($status) {
|
||||
case 'finished': //审核通过
|
||||
if($log->way == 'alipay'){
|
||||
if($log->alipay_id){//通过支付宝id打款
|
||||
if ($log->way == 'alipay') {
|
||||
if ($log->alipay_id) {//通过支付宝id打款
|
||||
$result = $ali->UserTransferAccount($data);
|
||||
}else{//通过支付宝账号和名字打款
|
||||
} else {//通过支付宝账号和名字打款
|
||||
$result = $ali->platTransferAccount($data);
|
||||
}
|
||||
}elseif($log->way == 'weixin'){
|
||||
$result = \WechatService::officialUserTransferV2($log->trade_no,$log->account,$log->real_value * 100,'提现已到账');
|
||||
} elseif ($log->way == 'weixin') {
|
||||
$result = \WechatService::officialUserTransferV2($log->trade_no, $log->account, $log->real_value * 100, '提现已到账');
|
||||
}
|
||||
//\Log::info($result);
|
||||
//判断打款是否成功
|
||||
if(is_array($result)){//失败
|
||||
if (is_array($result)) {//失败
|
||||
$err_msg = isset($result['msg']) ? $result['msg'] : $result['err_code_des'];
|
||||
//\Log::info('打款失败');
|
||||
return $this->failure($err_msg);
|
||||
$log->update(['status'=>'canceled','admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s'),'err_msg'=>$err_msg]);
|
||||
$account->update(['frozen_withdraw'=>$frozen_withdraw - $log->value,'balance'=>$balance + $log->value]);
|
||||
$log->update(['status' => 'canceled', 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s'), 'err_msg' => $err_msg]);
|
||||
$account->update(['frozen_withdraw' => $frozen_withdraw - $log->value, 'balance' => $balance + $log->value]);
|
||||
// 短信通知 邓智锋
|
||||
$mobile = '15707534403';
|
||||
$message = 's端用户' . $alipay_real_name . ' 提现' . $log->real_value . '元失败,原因:' . $err_msg;
|
||||
$this->sentMessage($mobile,$message);
|
||||
$this->sentMessage($mobile, $message);
|
||||
//模板通知 邓智锋
|
||||
$data['touser'] = ['oPC_2vnSECnYp5p--uaq3rca3Ry0', 'oPC_2vpJd34uN2E1tTsFbf8Lhlcs'];
|
||||
$data['template_id'] = 'AqwVt0liVmQfzfnX3ZGvmVOdOh62nkCbhlOUI0NVQGs';
|
||||
@ -676,13 +706,13 @@ class EarningController extends Controller
|
||||
];
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
//短信通知
|
||||
$message = $log->name.',提现'.$log->real_value.'元失败,具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($merchant_user->mobile,$message);
|
||||
$message = $log->name . ',提现' . $log->real_value . '元失败,具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($merchant_user->mobile, $message);
|
||||
DB::commit();
|
||||
return $this->failure($err_msg);
|
||||
}else{//成功
|
||||
} else {//成功
|
||||
//\Log::info('打款成功');
|
||||
$log->update(['status'=>'finished','admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s')]);
|
||||
$log->update(['status' => 'finished', 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s')]);
|
||||
//将冻结提现金额 换成已提现金额 //冻结提现金额 0
|
||||
$account->withdrawl = $account->withdrawl + $log->value;
|
||||
$account->frozen_withdraw = $account->frozen_withdraw - $log->value;
|
||||
@ -692,23 +722,24 @@ class EarningController extends Controller
|
||||
$data['template_id'] = 'aV4ic7jr5bOlf55CgR0jmMsFYyhdRAiVmqqXEjnUqQU';
|
||||
$data['url'] = $url;
|
||||
$data['data'] = [
|
||||
'first' => '提现已到账,请在'.$transfer_way.'查收',
|
||||
'first' => '提现已到账,请在' . $transfer_way . '查收',
|
||||
'keyword1' => $log->real_value . '元',
|
||||
'keyword2' => date('Y-m-d H:i:s'),
|
||||
'keyword3' => '提现到'.$transfer_way.'余额',
|
||||
'keyword3' => '提现到' . $transfer_way . '余额',
|
||||
'remark' => '感谢您的使用',
|
||||
];
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
//短信通知
|
||||
$message = $log->name.',提现金额'.$log->real_value.'元已到账,请在'.$transfer_way.'查收。';
|
||||
$this->sentMessage($merchant_user->mobile,$message);
|
||||
$message = $log->name . ',提现金额' . $log->real_value . '元已到账,请在' . $transfer_way . '查收。';
|
||||
$this->sentMessage($merchant_user->mobile, $message);
|
||||
}
|
||||
break;
|
||||
case 'canceled': //审核拒绝
|
||||
$reason = $request->reason;
|
||||
if(!$reason) return $this->failure('请输入拒绝理由');
|
||||
$account->update(['frozen_withdraw'=>$frozen_withdraw - $log->value,'balance'=>$balance + $log->value]);
|
||||
$log->update(['status'=>$status,'admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s'),'err_msg'=>$request->reason]);
|
||||
if (!$reason)
|
||||
return $this->failure('请输入拒绝理由');
|
||||
$account->update(['frozen_withdraw' => $frozen_withdraw - $log->value, 'balance' => $balance + $log->value]);
|
||||
$log->update(['status' => $status, 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s'), 'err_msg' => $request->reason]);
|
||||
//todo 短信通知 公众号通知拒绝理由
|
||||
$data['touser'] = $merchant_user->openid;
|
||||
$data['template_id'] = 'AqwVt0liVmQfzfnX3ZGvmVOdOh62nkCbhlOUI0NVQGs';
|
||||
@ -720,24 +751,24 @@ class EarningController extends Controller
|
||||
'keyword3' => $reason,
|
||||
'remark' => '账号信息存在异常',
|
||||
];
|
||||
$message = $log->name.',提现'.$log->real_value.'元失败,失败原因:'.$reason.',具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($merchant_user->mobile,$message);
|
||||
$message = $log->name . ',提现' . $log->real_value . '元失败,失败原因:' . $reason . ',具体原因请查看你的后台系统的提现反馈。';
|
||||
$this->sentMessage($merchant_user->mobile, $message);
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
break;
|
||||
case 'manual': //手工处理
|
||||
//\Log::info('打款已经由人工处理');
|
||||
$log->update(['status'=>'finished','admin_id'=>$admin_id,'audit_at'=>date('Y-m-d H:i:s'),'way'=>'manual']);
|
||||
$log->update(['status' => 'finished', 'admin_id' => $admin_id, 'audit_at' => date('Y-m-d H:i:s'), 'way' => 'manual']);
|
||||
//将冻结提现金额 换成已提现金额 //冻结提现金额 0
|
||||
$account->withdrawl = $account->withdrawl + $log->value;
|
||||
$account->frozen_withdraw = $account->frozen_withdraw - $log->value;
|
||||
$account->save();
|
||||
//模板通知用户
|
||||
$data['touser'] = ['oPC_2vudVLVHj2U7dNinr2IEDHR4','oPC_2vuTj7YRgUzQQY7PlSJVLBBc'];
|
||||
$data['touser'] = ['oPC_2vudVLVHj2U7dNinr2IEDHR4', 'oPC_2vuTj7YRgUzQQY7PlSJVLBBc'];
|
||||
$data['template_id'] = 'OwXPF2dKEjPQUoGyzH944ATsJ6SgxpZ8kzB-KVVxanY';
|
||||
$data['url'] = $url;
|
||||
$data['data'] = [
|
||||
'first' => 's端用户:' . $log->name . '提现人工审核通过,处理方式:手工打款,请即时处理',
|
||||
'keyword1' => $log->name,
|
||||
'keyword1' => $log->name,
|
||||
'keyword2' => date('Y-m-d H:i:s'),
|
||||
'keyword3' => $log->real_value . '元',
|
||||
'keyword4' => '手动打款处理',
|
||||
@ -763,15 +794,15 @@ class EarningController extends Controller
|
||||
$users = EarningUser::with('user:id,nickname,name,mobile,photo,app_avatar');
|
||||
$keyword = $request->input('keyword');
|
||||
if ($keyword) {
|
||||
$users = $users->whereHas('user', function ($sql) use($keyword) {
|
||||
$sql->where('name', 'like', '%'.$keyword.'%')
|
||||
->orWhere("nickname", 'like', '%'.$keyword.'%')
|
||||
->orWhere('mobile', 'like', '%'.$keyword.'%');
|
||||
$users = $users->whereHas('user', function ($sql) use ($keyword) {
|
||||
$sql->where('name', 'like', '%' . $keyword . '%')
|
||||
->orWhere("nickname", 'like', '%' . $keyword . '%')
|
||||
->orWhere('mobile', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
$users = $users->orderByDesc('id')->paginate();
|
||||
return $this->success('ok', $users);
|
||||
}catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->getError($e);
|
||||
return $this->failure("获取信息失败,请联系开发人员");
|
||||
}
|
||||
@ -781,16 +812,17 @@ class EarningController extends Controller
|
||||
{
|
||||
try {
|
||||
$user_id = $request->input('user_id');
|
||||
if (empty($user_id)) throw new Exception("缺少用户id参数");
|
||||
if (empty($user_id))
|
||||
throw new Exception("缺少用户id参数");
|
||||
$user = User::find($user_id);
|
||||
$euser = EarningUser::where('user_id', $user_id)->first();
|
||||
if (empty($euser)) {
|
||||
$euser = EarningUser::create(['user_id'=>$user_id]);
|
||||
$euser = EarningUser::create(['user_id' => $user_id]);
|
||||
//短信通知
|
||||
SendEasySms::dispatch(['mobile'=>$user->mobile, 'message'=>'恭喜你,已成为福恋合作老师,邀请新朋友注册产生消费,将会获得对应比例的收益,快邀请身边的单身朋友加入吧'])->onQueue('love');
|
||||
SendEasySms::dispatch(['mobile' => $user->mobile, 'message' => '恭喜你,已成为福恋合作老师,邀请新朋友注册产生消费,将会获得对应比例的收益,快邀请身边的单身朋友加入吧'])->onQueue('love');
|
||||
}
|
||||
return $this->success('ok', $euser);
|
||||
}catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->getError($e);
|
||||
return $this->failure("增加收益用户失败,请联系开发人员");
|
||||
}
|
||||
@ -800,10 +832,11 @@ class EarningController extends Controller
|
||||
{
|
||||
try {
|
||||
$user_id = $request->input('user_id');
|
||||
if (empty($user_id)) throw new Exception("缺少用户id参数");
|
||||
EarningUser::where('user_id', $user_id)->delete();
|
||||
if (empty($user_id))
|
||||
throw new Exception("缺少用户id参数");
|
||||
EarningUser::where('user_id', $user_id)->delete();
|
||||
return $this->success('ok');
|
||||
}catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->getError($e);
|
||||
return $this->failure("删除收益用户失败,请联系开发人员");
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ use App\Exports\MessengerExport;
|
||||
use App\Exports\ReportExport;
|
||||
use App\Facades\QrcodeRectService;
|
||||
use App\Facades\WechatService;
|
||||
use App\Helpers\TokenHelper;
|
||||
use App\Jobs\AddUnionUser;
|
||||
use App\Jobs\MakeSurveyQrcode;
|
||||
use App\Jobs\SaasEarningMPNotice;
|
||||
@ -41,6 +42,7 @@ use App\Models\UnionUser;
|
||||
use App\Server\ReportFile;
|
||||
use App\Services\LiveAlipayService;
|
||||
use App\Services\OrderService;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
@ -144,6 +146,8 @@ use App\Models\Server\MerchantAdmins;
|
||||
use App\Models\Server\TouristOrder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Imports\TestImport;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, ResponseJson;
|
||||
@ -2167,10 +2171,7 @@ class Controller extends BaseController
|
||||
|
||||
public function test(Request $request)
|
||||
{
|
||||
$order = TouristOrder::find($request->order_id);
|
||||
$orderService = new OrderService();
|
||||
$res = $orderService->storeUftxCustomer($order);
|
||||
dd($res);
|
||||
|
||||
}
|
||||
|
||||
public function postIndex()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user