|
|
@ -5,6 +5,8 @@ namespace app\admin\service; |
|
|
|
use app\admin\validate\RechargeValidate; |
|
|
|
use app\model\AdminModel; |
|
|
|
use app\model\FileModel; |
|
|
|
use app\model\PaymentCodeConfigModel; |
|
|
|
use app\model\PaymentCodeLogModel; |
|
|
|
use app\model\PaymentListModel; |
|
|
|
use app\model\RechargeApplyModel; |
|
|
|
use app\model\UserModel; |
|
|
@ -173,4 +175,221 @@ class RechargeService extends AdminBaseService |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 支付码配置列表 & 会员支付码配置列表 (用户提交的充值订单,等待后台为其配置支付码) |
|
|
|
public function paymentCodeLogList($param, $adminId) { |
|
|
|
try { |
|
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
// payment_code_config_id = 0 表示该订单还没有为其配置支付码, 这个接口只查询待配置支付码的记录 |
|
|
|
$where = [['payment_code_config_id', '=', 0]]; |
|
|
|
// 根据用户ID过滤 |
|
|
|
if (isset($param['user_id'])) { |
|
|
|
$where[] = ['user_id', '=', $param['user_id']]; |
|
|
|
} |
|
|
|
// 根据支付渠道名称过滤 |
|
|
|
if (isset($param['channel_name'])) { |
|
|
|
$paymentCodeConfig = PaymentCodeConfigModel::where(['channel_name'=>$param['channel_name']])->find(); // bot_payment_code_config 表找对应的主键ID |
|
|
|
if (empty($paymentCodeConfig)){ |
|
|
|
return $this->toData('400', '查询的渠道名称不存在'); |
|
|
|
} |
|
|
|
$where[] = ['payment_code_config_id', '=', $paymentCodeConfig->id]; |
|
|
|
} |
|
|
|
|
|
|
|
$list = PaymentCodeLogModel::where($where)->order('id', 'desc')->paginate([ |
|
|
|
'list_rows' => $param['limit'], |
|
|
|
'page' => $param['page'], |
|
|
|
]); |
|
|
|
if (!empty($list->items())) { |
|
|
|
$uidList = []; |
|
|
|
foreach ($list->items() as $key => $value) { |
|
|
|
$uidList[] = $value['user_id']; |
|
|
|
} |
|
|
|
// 查询用户信息 |
|
|
|
$userList = UserModel::where('user_id', 'in', $uidList)->select()->toArray(); |
|
|
|
// 填充用户信息字段 |
|
|
|
foreach ($list->items() as &$item) { |
|
|
|
foreach ($userList as $user) { |
|
|
|
if ($item['user_id'] == $user['user_id']) { |
|
|
|
$item['user_no'] = $user['user_no']; |
|
|
|
$item['nick_name'] = $user['nick_name']; |
|
|
|
$item['agent_id'] = $user['agent_id']; |
|
|
|
$item['customer_id'] = $user['customer_id']; |
|
|
|
$item['customer_remark'] = $user['customer_remark']; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
unset($item); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
|
'total' => $list->total(), // 总记录数 |
|
|
|
'last_page' => $list->lastPage(), // 最后一页页码 |
|
|
|
]); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 给用户的充值订单配置支付码 |
|
|
|
public function paymentCodeLogUpdate($param, $adminId) { |
|
|
|
try { |
|
|
|
if (empty($param['id']) || empty($param['payment_code_config_id'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
// 检查支付码配置信息 |
|
|
|
$paymentCodeConfig = PaymentCodeConfigModel::where(['id'=>$param['payment_code_config_id']])->find(); |
|
|
|
if (empty($paymentCodeConfig)) { |
|
|
|
return $this->toData('400', '支付渠道配数据为空'); |
|
|
|
} |
|
|
|
// 更新该比订单的支付码配置字段 |
|
|
|
$info = PaymentCodeLogModel::where(['id'=>$param['id']])->find(); |
|
|
|
if (empty($info)) { |
|
|
|
return $this->toData('400', '数据不存在'); |
|
|
|
} |
|
|
|
$info->payment_code_config_id = $param['payment_code_config_id']; |
|
|
|
$info->is_vip_config = $paymentCodeConfig->is_vip == 1 ? 1 : 0; // 是否为vip配置渠道 |
|
|
|
$info->save(); |
|
|
|
return $this->toData('0', 'SUCCESS', []); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 获取支付码配置列表下拉框 |
|
|
|
public function paymentCodeConfigSelect() |
|
|
|
{ |
|
|
|
try { |
|
|
|
$list = PaymentCodeConfigModel::where(['status' => 1])->field('id,channel_name')->select()->toArray(); |
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'list' => $list |
|
|
|
]); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 支付码管理 (包含普通股支付码 & vip支付码) |
|
|
|
public function paymentCodeConfigList($param, $adminId) { |
|
|
|
try { |
|
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
$where = []; |
|
|
|
if (isset($param['channel_name'])) { |
|
|
|
$where['channel_name'] = $param['channel_name']; |
|
|
|
} |
|
|
|
// 查询vip支付码配置列表 |
|
|
|
if (!empty($param['is_vip'])) { |
|
|
|
$where['is_vip'] = $param['is_vip']; |
|
|
|
} |
|
|
|
|
|
|
|
$list = PaymentCodeConfigModel::where($where)->order('id', 'desc')->paginate([ |
|
|
|
'list_rows' => $param['limit'], |
|
|
|
'page' => $param['page'], |
|
|
|
]); |
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
|
'total' => $list->total(), // 总记录数 |
|
|
|
'last_page' => $list->lastPage(), // 最后一页页码 |
|
|
|
]); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 新增支付码配置 |
|
|
|
public function paymentCodeConfigAdd($param, $adminId) |
|
|
|
{ |
|
|
|
try { |
|
|
|
if (empty($param['channel_name']) || empty($param['qr_code']) || empty($param['total_amount']) || !isset($param['is_vip'])) { |
|
|
|
return $this->toData('400', '缺少参数'); |
|
|
|
} |
|
|
|
PaymentCodeConfigModel::create([ |
|
|
|
'channel_name' => $param['channel_name'], |
|
|
|
'qr_code' => $param['qr_code'], |
|
|
|
'total_amount' => $param['total_amount'], |
|
|
|
'is_vip' => $param['is_vip'], |
|
|
|
]); |
|
|
|
return $this->toData('0', 'SUCCESS', []); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 支付码管理 - 编辑 |
|
|
|
public function paymentCodeConfigUpdate($param, $adminId) { |
|
|
|
try { |
|
|
|
if (empty($param['id']) || !isset($param['status'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
if (!in_array($param['status'], [0,1])) { |
|
|
|
return $this->toData('400', 'status参数不在允许范围内'); |
|
|
|
} |
|
|
|
$info = PaymentCodeConfigModel::where(['id'=>$param['id']])->find(); |
|
|
|
if (empty($info)) { |
|
|
|
return $this->toData('400', '编辑的数据不存在'); |
|
|
|
} |
|
|
|
$info->status = $param['status']; |
|
|
|
$info->save(); |
|
|
|
return $this->toData('0', 'SUCCESS', []); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 支付码流水查询 |
|
|
|
public function userPaymentCodeLogList($param) |
|
|
|
{ |
|
|
|
try { |
|
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
|
|
|
|
$where = []; |
|
|
|
// 根据用户ID过滤 |
|
|
|
if (isset($param['user_id'])) { |
|
|
|
$where[] = ['user_id', '=', $param['user_id']]; |
|
|
|
} |
|
|
|
// 根据支付渠道名称过滤 |
|
|
|
if (isset($param['channel_name'])) { |
|
|
|
$paymentCodeConfig = PaymentCodeConfigModel::where(['channel_name'=>$param['channel_name']])->find(); // bot_payment_code_config 表找对应的主键ID |
|
|
|
if (empty($paymentCodeConfig)){ |
|
|
|
return $this->toData('400', '查询的渠道名称不存在'); |
|
|
|
} |
|
|
|
$where[] = ['payment_code_config_id', '=', $paymentCodeConfig->id]; |
|
|
|
} |
|
|
|
// 过滤VIP支付码的流水记录 |
|
|
|
if (isset($param['is_vip'])) { |
|
|
|
$where[] = ['is_vip_config', '=', 1]; |
|
|
|
} |
|
|
|
|
|
|
|
$list = PaymentCodeLogModel::where($where)->order('id', 'desc')->paginate([ |
|
|
|
'list_rows' => $param['limit'], |
|
|
|
'page' => $param['page'], |
|
|
|
]); |
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'list' => $list->items(), // 当前页的数据 |
|
|
|
'page' => $list->currentPage(), // 当前页码 |
|
|
|
'total' => $list->total(), // 总记录数 |
|
|
|
'last_page' => $list->lastPage(), // 最后一页页码 |
|
|
|
]); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |