123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- namespace app\admin\model\user;
- use traits\ModelTrait;
- use basic\ModelBasic;
- use app\admin\model\user\MemberCard as MemberCardMode;
- use app\admin\model\user\MemberCardBatch;
- use app\admin\model\order\StoreOrder;
- /**
- * 会员设置 model
- * Class User
- * @package app\admin\model\user
- */
- class MemberRecord extends ModelBasic
- {
- use ModelTrait;
- public static function getPurchaseRecordList($where){
- $model = self::setWherePage(self::setWhere($where), $where, ['u.nickname', 'u.uid'], ['p.uid']);
- $model=$model->alias('p')->join('user u', 'p.uid=u.uid', 'left')->field('p.*,u.nickname');
- $list = $model ->page((int)$where['page'], (int)$where['limit'])
- ->order('p.add_time DESC')
- ->select()
- ->each(function ($item) {
- $item['overdue_time'] = date('Y-m-d H:i:s', $item['overdue_time']);
- $item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
- if($item['type']==1){
- $item['price'] ='无';
- }
- if(!$item['type']){
- switch ($item['validity']){
- case 30:
- $item['title'] = '月卡';
- break;
- case 90:
- $item['title'] = '季卡';
- break;
- case 365:
- $item['title'] = '年卡';
- break;
- case -1:
- $item['title'] = '终身卡';
- break;
- default:
- $item['title'] = '免费';
- }
- }else{
- $item['title'] = '卡密';
- }
- if (!$item['code']) {
- $item['code'] = '无';
- }
- if($item['nickname']){
- $item['uid'] =$item['nickname'].'/'.$item['uid'];
- }else{
- $item['uid'] ='用户被删除/'.$item['uid'];
- }
- if($item['oid']){
- $order=StoreOrder::where('id',$item['oid'])->where('type',1)->field('pay_type')->find();
- if($order['pay_type']=='yue'){
- $item['source'] = '赠送';
- }else{
- $item['source'] = '购买';
- }
- }else{
- $item['source'] = '会员卡';
- }
- })->toArray();
- $count = self::setWherePage(self::setWhere($where), $where,['u.nickname', 'u.uid'], ['p.uid'])->alias('p')->join('user u', 'p.uid=u.uid', 'left')->count();
- return ['count' => $count, 'data' => $list];
- }
- /**
- * 设置搜索条件
- *
- */
- public static function setWhere($where)
- {
- $model=new self;
- if ($where['title'] != '') {
- $model = $model->where('p.uid|u.nickname','like',"%$where[title]%");
- }
- if ($where['type'] != '') {
- switch ($where['type']){
- case 1:
- $model=$model->where('p.validity',30)->where('p.type',0);
- break;
- case 2:
- $model=$model->where('p.validity',90)->where('p.type',0);
- break;
- case 3:
- $model=$model->where('p.validity',365)->where('p.type',0);
- break;
- case 4:
- $model=$model->where('p.validity','<',0)->where('p.type',0);
- break;
- case 5:
- $model=$model->where('p.type',1);
- break;
- case 6:
- $model=$model->where('p.type',0)->where('p.is_free',1);
- break;
- }
- }
- return $model;
- }
- public static function userOneRecord($uid=0){
- $model = new self;
- $model = $model->where('a.uid',$uid);
- $model = $model->alias('a');
- $model = $model->field('a.*,b.nickname');
- $model = $model->join('__USER__ b', 'b.uid=a.uid', 'LEFT');
- $model = $model->order('a.id desc');
- return self::page($model,function ($item){
- $item['overdue_time'] = date('Y-m-d H:i:s', $item['overdue_time']);
- $item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
- if($item['type']==1){
- $item['price'] ='无';
- }
- if(!$item['type']){
- switch ($item['validity']){
- case 30:
- $item['title'] = '月卡';
- break;
- case 90:
- $item['title'] = '季卡';
- break;
- case 365:
- $item['title'] = '年卡';
- break;
- case -1:
- $item['title'] = '终身卡';
- break;
- default:
- $item['title'] = '免费';
- }
- }else{
- $item['title'] = '卡密';
- }
- if (!$item['code']) {
- $item['code'] = '无';
- }
- });
- }
- }
|