|
|
@@ -238,6 +238,10 @@ class BalanceLogService extends BaseService
|
|
|
$checkStatus = isset($params['status'])? $params['status'] : 0;
|
|
|
$remark = isset($params['audit_remark'])? trim($params['audit_remark']) : '';
|
|
|
$payImg = isset($params['pay_img'])? trim($params['pay_img']) : '';
|
|
|
+ if(!in_array($checkStatus,[2,3])){
|
|
|
+ $this->error = 1073;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
$info = $this->model->with(['member','merchant','acceptor'])->where(['id'=> $id,'mark'=>1])->first();
|
|
|
$type = isset($info['type'])? $info['type'] : 0;
|
|
|
@@ -248,7 +252,7 @@ class BalanceLogService extends BaseService
|
|
|
$money = isset($info['money'])? $info['money'] : 0;
|
|
|
$actualMoney = isset($info['actual_money'])? $info['actual_money'] : 0;
|
|
|
$status = isset($info['status'])? $info['status'] : 0;
|
|
|
- if(empty($info) || $accountId<=0){
|
|
|
+ if($id<=0 || empty($info) || $accountId<=0){
|
|
|
$this->error = 4001;
|
|
|
return false;
|
|
|
}
|
|
|
@@ -299,14 +303,12 @@ class BalanceLogService extends BaseService
|
|
|
}
|
|
|
|
|
|
// 审核通过到账处理
|
|
|
- $title = '';
|
|
|
- $message = '';
|
|
|
$dateTime = date('Y-m-d H:i:s');
|
|
|
$coinTypes = [1=>'USDT余额',2=>'星豆余额',3=>'交易额度'];
|
|
|
$accountTypes = [1=>'会员账户',2=>'商家账户',3=>'承兑商账户'];
|
|
|
$coinName = isset($coinTypes[$coinType])? $coinTypes[$coinType] : '账户';
|
|
|
$accountName = isset($accountTypes[$userType])? $accountTypes[$userType] : '会员账户';
|
|
|
- if($status == 2) {
|
|
|
+ if($checkStatus == 2) {
|
|
|
// 线下交易
|
|
|
if($payType == 30){
|
|
|
if(!in_array($userType,[1,3]) && !in_array($coinType,[1,6])){
|
|
|
@@ -395,6 +397,10 @@ class BalanceLogService extends BaseService
|
|
|
$checkStatus = isset($params['status'])? $params['status'] : 0;
|
|
|
$remark = isset($params['audit_remark'])? trim($params['audit_remark']) : '';
|
|
|
$payImg = isset($params['pay_img'])? trim($params['pay_img']) : '';
|
|
|
+ if(!in_array($checkStatus,[2,3])){
|
|
|
+ $this->error = 1073;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
$info = $this->model->with(['member','merchant','acceptor'])->where(['id'=> $id,'mark'=>1])->first();
|
|
|
$type = isset($info['type'])? $info['type'] : 0;
|
|
|
@@ -406,7 +412,7 @@ class BalanceLogService extends BaseService
|
|
|
$actualMoney = isset($info['actual_money'])? $info['actual_money'] : 0;
|
|
|
$fee = isset($info['fee'])? $info['fee'] : 0;
|
|
|
$status = isset($info['status'])? $info['status'] : 0;
|
|
|
- if(empty($info) || $accountId<=0){
|
|
|
+ if($id<=0 || empty($info) || $accountId<=0){
|
|
|
$this->error = 4001;
|
|
|
return false;
|
|
|
}
|
|
|
@@ -450,8 +456,6 @@ class BalanceLogService extends BaseService
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
// 审核通过到账处理
|
|
|
- $title = '';
|
|
|
- $message = '';
|
|
|
$dateTime = date('Y-m-d H:i:s');
|
|
|
$accountTypes = [1=>'会员账户',2=>'商家账户',3=>'承兑商账户'];
|
|
|
$coinName = 'USDT余额';
|
|
|
@@ -463,7 +467,7 @@ class BalanceLogService extends BaseService
|
|
|
$coinName = '交易额度';
|
|
|
}
|
|
|
$accountName = isset($accountTypes[$userType])? $accountTypes[$userType] : '会员账户';
|
|
|
- if($status == 2) {
|
|
|
+ if($checkStatus == 2) {
|
|
|
// USDT链上打款
|
|
|
$hash = '';
|
|
|
if($payType == 20){
|
|
|
@@ -637,205 +641,4 @@ class BalanceLogService extends BaseService
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 添加会编辑会员
|
|
|
- * @return array
|
|
|
- * @since 2020/11/11
|
|
|
- * @author laravel开发员
|
|
|
- */
|
|
|
- public function edit()
|
|
|
- {
|
|
|
- // 请求参数
|
|
|
- $data = request()->all();
|
|
|
-
|
|
|
- $balanceLog = BalanceLogModel::where(['id' => $data['id']])->first();
|
|
|
- DB::beginTransaction();
|
|
|
- try {
|
|
|
- // 提现 审核通过
|
|
|
- if ($balanceLog['type'] == 2 && isset($data['status'])) {
|
|
|
- if ($data['status'] == 2) {
|
|
|
- if ($data['user_type'] == 1) {
|
|
|
- // 会员
|
|
|
- $this->withdrawMember($data);
|
|
|
- } else if ($data['user_type'] == 2) {
|
|
|
- // 商家
|
|
|
- $this->withdrawMerchat($data);
|
|
|
- } else if ($data['user_type'] == 3) {
|
|
|
- // 承兑商
|
|
|
- $this->withdrawAcceptor($data);
|
|
|
- }
|
|
|
- } else if ($data['status'] == 3) {
|
|
|
- $money = $data['money'];
|
|
|
- $userId = $data['user_id'];
|
|
|
- $accountLog = AccountLogModel::where(['source_order_no' => $balanceLog['order_no']])->first();
|
|
|
- if ($accountLog) {
|
|
|
- AccountLogModel::where(['source_order_no' => $balanceLog])->update([
|
|
|
- 'status' => 3,
|
|
|
- 'update_time' => time(),
|
|
|
- ]);
|
|
|
-
|
|
|
- $updateData = ['usdt' => DB::raw("usdt - {$money}"), 'update_time' => time()];
|
|
|
- if (!MerchantModel::where(['user_id' => $userId, 'mark' => 1])->update($updateData)) {
|
|
|
- DB::rollBack();
|
|
|
- return message('审核不通过操作失败');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (\Exception $e) {
|
|
|
- DB::rollBack();
|
|
|
- return message('操作失败');
|
|
|
- }
|
|
|
- DB::commit();
|
|
|
- return parent::edit($data); // TODO: Change the autogenerated stub
|
|
|
- }
|
|
|
-
|
|
|
- private function withdrawMember(array $data)
|
|
|
- {
|
|
|
- $trcUrl = $data['trc_url'];
|
|
|
- $realUsdt = $data['actual_money'];
|
|
|
- $orderNo = $data['order_no'];
|
|
|
- $userType = $data['user_type'];
|
|
|
- $dateTime = $dateTime = date('Y-m-d H:i:s');
|
|
|
- $money = $data['money'];
|
|
|
- $userId = $data['user_id'];
|
|
|
- $fee = $data['fee'];
|
|
|
-
|
|
|
- // 打款处理
|
|
|
- $result = WalletService::make()->usdtTrcTransfer($trcUrl, $realUsdt);
|
|
|
- $txID = isset($result['txId']) ? $result['txId'] : '';
|
|
|
- $payAddress = isset($result['address']) ? $result['address'] : '';
|
|
|
- if ($txID && $payAddress) {
|
|
|
- $updateData = ['hash' => $txID, 'wallet_url' => $payAddress, 'audit_remark' => '审核打款', 'status' => 2, 'update_time' => time()];
|
|
|
- if (BalanceLogModel::where(['order_no' => $orderNo, 'user_type' => $userType])->update($updateData)) {
|
|
|
- $title = $userType == 1 ? 'USDT余额提现审核成功' : '商户余额提现审核成功';
|
|
|
- $message = $userType == 1 ? "您在{$dateTime}(UTC+8)申请提现{$money}USDT余额审核成功,请耐心等候打款到账!!!" : "您在{$dateTime}(UTC+8)申请提现{$money}USDT商户余额审核成功,请耐心等候打款到账!!!";
|
|
|
- MessageService::make()->pushMessage($userId, $title, $message);
|
|
|
- AccountLogModel::where(['source_order_no' => $orderNo])->update(['hash' => $txID, 'update_time' => time()]);
|
|
|
-
|
|
|
- // 平台明细
|
|
|
- $log = [
|
|
|
- 'user_id' => 0,
|
|
|
- 'source_id' => $userId,
|
|
|
- 'source_order_no' => $orderNo,
|
|
|
- 'type' => 5,
|
|
|
- 'coin_type' => 1,
|
|
|
- 'user_type' => 4,
|
|
|
- 'money' => $fee,
|
|
|
- 'actual_money' => $fee,
|
|
|
- 'balance' => 0,
|
|
|
- 'create_time' => time(),
|
|
|
- 'update_time' => time(),
|
|
|
- 'hash' => $txID,
|
|
|
- 'remark' => "USDT余额提现",
|
|
|
- 'status' => 1,
|
|
|
- 'mark' => 1,
|
|
|
- ];
|
|
|
-
|
|
|
- AccountLogModel::insertGetId($log);
|
|
|
-
|
|
|
- // 平台流水
|
|
|
- FinanceService::make()->saveLog(0, $fee, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private function withdrawMerchat(array $data)
|
|
|
- {
|
|
|
- $trcUrl = $data['trc_url'];
|
|
|
- $realUsdt = $data['actual_money'];
|
|
|
- $orderNo = $data['order_no'];
|
|
|
- $userType = $data['user_type'];
|
|
|
- $dateTime = $dateTime = date('Y-m-d H:i:s');
|
|
|
- $money = $data['money'];
|
|
|
- $userId = $data['user_id'];
|
|
|
- $fee = $data['fee'];
|
|
|
- // 打款处理
|
|
|
- $result = WalletService::make()->usdtTrcTransfer($trcUrl, $realUsdt);
|
|
|
- $txID = isset($result['txId']) ? $result['txId'] : '';
|
|
|
- $payAddress = isset($result['address']) ? $result['address'] : '';
|
|
|
- if ($txID && $payAddress) {
|
|
|
- $updateData = ['hash' => $txID, 'wallet_url' => $payAddress, 'audit_remark' => '审核打款', 'status' => 2, 'update_time' => time()];
|
|
|
- if (BalanceLogModel::where(['order_no' => $orderNo, 'user_type' => $userType])->update($updateData)) {
|
|
|
- $title = $userType == 1 ? 'USDT余额提现审核成功' : '商户余额提现审核成功';
|
|
|
- $message = $userType == 1 ? "您在{$dateTime}(UTC+8)申请提现{$money}USDT余额审核成功,请耐心等候打款到账!!!" : "您在{$dateTime}(UTC+8)申请提现{$money}USDT商户余额审核成功,请耐心等候打款到账!!!";
|
|
|
- MessageService::make()->pushMessage($userId, $title, $message);
|
|
|
- AccountLogModel::where(['source_order_no' => $orderNo])->update(['hash' => $txID, 'update_time' => time()]);
|
|
|
-
|
|
|
- // 平台明细
|
|
|
- $log = [
|
|
|
- 'user_id' => 0,
|
|
|
- 'source_id' => $userId,
|
|
|
- 'source_order_no' => $orderNo,
|
|
|
- 'type' => 5,
|
|
|
- 'coin_type' => 1,
|
|
|
- 'user_type' => 4,
|
|
|
- 'money' => $fee,
|
|
|
- 'actual_money' => $fee,
|
|
|
- 'balance' => 0,
|
|
|
- 'create_time' => time(),
|
|
|
- 'update_time' => time(),
|
|
|
- 'hash' => $txID,
|
|
|
- 'remark' => "USDT余额提现",
|
|
|
- 'status' => 1,
|
|
|
- 'mark' => 1,
|
|
|
- ];
|
|
|
-
|
|
|
- AccountLogModel::insertGetId($log);
|
|
|
-
|
|
|
- // 平台流水
|
|
|
- FinanceService::make()->saveLog(0, $fee, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private function withdrawAcceptor(array $data)
|
|
|
- {
|
|
|
- $trcUrl = $data['trc_url'];
|
|
|
- $realUsdt = $data['actual_money'];
|
|
|
- $orderNo = $data['order_no'];
|
|
|
- $userType = $data['user_type'];
|
|
|
- $dateTime = $dateTime = date('Y-m-d H:i:s');
|
|
|
- $money = $data['money'];
|
|
|
- $userId = $data['user_id'];
|
|
|
- $fee = $data['fee'];
|
|
|
- // 打款处理
|
|
|
- $result = WalletService::make()->usdtTrcTransfer($trcUrl, $realUsdt);
|
|
|
- $txID = isset($result['txId']) ? $result['txId'] : '';
|
|
|
- $payAddress = isset($result['address']) ? $result['address'] : '';
|
|
|
- if ($txID && $payAddress) {
|
|
|
- $updateData = ['hash' => $txID, 'wallet_url' => $payAddress, 'audit_remark' => '审核打款', 'status' => 2, 'update_time' => time()];
|
|
|
- if (BalanceLogModel::where(['order_no' => $orderNo, 'user_type' => $userType])->update($updateData)) {
|
|
|
- $title = $userType == 1 ? 'USDT余额提现审核成功' : '承兑商余额提现审核成功';
|
|
|
- $message = $userType == 1 ? "您在{$dateTime}(UTC+8)申请提现{$money}USDT余额审核成功,请耐心等候打款到账!!!" : "您在{$dateTime}(UTC+8)申请提现{$money}USDT承兑商余额审核成功,请耐心等候打款到账!!!";
|
|
|
- MessageService::make()->pushMessage($userId, $title, $message, 3);
|
|
|
- AccountLogModel::where(['source_order_no' => $orderNo])->update(['hash' => $txID, 'update_time' => time()]);
|
|
|
-
|
|
|
- // 平台明细
|
|
|
- $log = [
|
|
|
- 'user_id' => 0,
|
|
|
- 'source_id' => $userId,
|
|
|
- 'source_order_no' => $orderNo,
|
|
|
- 'type' => 5,
|
|
|
- 'coin_type' => 1,
|
|
|
- 'user_type' => 4,
|
|
|
- 'money' => $fee,
|
|
|
- 'actual_money' => $fee,
|
|
|
- 'balance' => 0,
|
|
|
- 'create_time' => time(),
|
|
|
- 'update_time' => time(),
|
|
|
- 'hash' => $txID,
|
|
|
- 'remark' => "USDT余额提现",
|
|
|
- 'status' => 1,
|
|
|
- 'mark' => 1,
|
|
|
- ];
|
|
|
-
|
|
|
- AccountLogModel::insertGetId($log);
|
|
|
-
|
|
|
- // 平台流水
|
|
|
- FinanceService::make()->saveLog(0, $fee, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|