| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services\Api;
- use App\Models\MemberPaymentModel;
- use App\Services\BaseService;
- /**
- * 会员收款方式-服务类
- * Class MemberPaymentService
- * @package App\Services\Api
- */
- class MemberPaymentService extends BaseService
- {
- // 静态对象
- protected static $instance = null;
- /**
- * 构造函数
- * @since 2020/11/10
- * LoginService constructor.
- */
- public function __construct()
- {
- $this->model = new MemberPaymentModel();
- }
- /**
- * 静态入口
- * @return static|null
- */
- public static function make()
- {
- if(!self::$instance){
- self::$instance = (new static());
- }
- return self::$instance;
- }
- /**
- * 获取选项列表
- * @param $userId
- * @return mixed
- */
- public function getOptionList($userId)
- {
- $list = $this->model->where(['user_id'=> $userId,'status'=>1])
- ->whereRaw('(trade_num-used_num>0 and trade_quota-used_quota>0)')
- ->selectRaw('id,type,real_name,bank_name,account,bank_card,trade_quota,used_quota,(trade_quota - used_quota) as credit')
- ->get()
- ->each(function($item,$k){
- $item['realname_text'] = $item['real_name']? format_realname($item['real_name']) : '';
- $item['account_text'] = $item['account']? format_account($item['account']) : '';
- $item['bank_card_text'] = $item['bank_card']? '*'.substr($item['bank_card'], -4, 4) : '';
- if($item['type'] == 1){
- $item['show_text'] = $item['bank_name'].' '.$item['realname_text'].' '.$item['bank_card_text'];
- }else{
- $item['show_text'] = $item['realname_text'].' '.$item['account_text'];
- }
- });
- return $list? $list->toArray() : [];
- }
- /**
- * 是否已经设置了收款方式
- * @param $userId
- * @return mixed
- */
- public function checkHasByUser($userId){
- return $this->model->where(['user_id'=> $userId,'status'=>1])->count('id');
- }
- }
|