| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- /**
- *
- * @author: xaboy<365615158@qq.com>
- * @day: 2018/3/3
- */
- namespace app\models\user;
- use crmeb\basic\BaseModel;
- use crmeb\services\workerman\ChannelService;
- use crmeb\traits\ModelTrait;
- /**
- * TODO 用户提现
- * Class UserExtract
- * @package app\models\user
- */
- class UserExtract extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'user_extract';
- use ModelTrait;
- //审核中
- const AUDIT_STATUS = 0;
- //未通过
- const FAIL_STATUS = -1;
- //已提现
- const SUCCESS_STATUS = 1;
- protected static $extractType = ['alipay','bank','weixin'];
- protected static $extractTypeMsg = ['alipay'=>'支付宝','bank'=>'银行卡','weixin'=>'微信'];
- protected static $status = array(
- -1=>'未通过',
- 0 =>'审核中',
- 1 =>'已提现'
- );
- /**
- * 用户自主提现记录提现记录,后台执行审核
- * @param array $userInfo 用户个人信息
- * @param array $data 提现详细信息
- * @return bool
- */
- public static function userExtract($userInfo,$data){
- if(!in_array($data['extract_type'],self::$extractType))
- return self::setErrorInfo('提现方式不存在');
- $userInfo = User::get($userInfo['uid']);
- $extractPrice = $userInfo['brokerage_price'];
- if($extractPrice < 0) return self::setErrorInfo('提现佣金不足'.$data['money']);
- }
- /**
- * 获得用户最后一次提现信息
- * @param $openid
- * @return mixed
- */
- public static function userLastInfo($uid)
- {
- return self::where(compact('uid'))->order('add_time DESC')->find();
- }
- /**
- * 获得用户提现总金额
- * @param $uid
- * @return mixed
- */
- public static function userExtractTotalPrice($uid,$status=self::SUCCESS_STATUS)
- {
- return self::where('uid',$uid)->where('status',$status)->value('SUM(extract_price)')?:0;
- }
- /**
- * 用户提现记录列表
- * @param int $uid 用户uid
- * @param int $first 截取行数
- * @param int $limit 截取数
- * @return \think\Collection
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public static function extractList($uid,$first = 0,$limit = 8)
- {
- $list=UserExtract::where('uid',$uid)->order('add_time desc')->limit($first,$limit)->select();
- foreach($list as &$v){
- $v['add_time']=date('Y/m/d',$v['add_time']);
- }
- return $list;
- }
- /**
- * 获取累计已提现佣金
- * @param $uid
- * @return float
- */
- public static function extractSum($uid)
- {
- return self::where('uid',$uid)->where('status',1)->sum('extract_price');
- }
- }
|