multi-store/app/api/lists/user_sign/UserSignLists.php

88 lines
2.3 KiB
PHP

<?php
namespace app\api\lists\user_sign;
use app\api\lists\BaseApiDataLists;
use app\common\model\user_label\UserLabel;
use app\common\lists\ListsSearchInterface;
use app\common\logic\UserSignLogic;
use app\common\model\store_order\StoreOrder;
use app\common\model\user_recharge\UserRecharge;
use app\common\model\user_ship\UserShip;
use app\common\model\user_sign\UserSign;
/**
* 积分列表
* Class UserSignLists
* @package app\api\user_sign
*/
class UserSignLists extends BaseApiDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2024/06/17 17:02
*/
public function setSearch(): array
{
return [
];
}
/**
* @notes 获取用户标签列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2024/06/17 17:02
*/
public function lists(): array
{
$type=$this->request->get('type',1);
$mark=$this->request->get('mark','');
if($type==1){
$this->searchWhere[]=['type','in',[4,9,8,2]];
$this->searchWhere[]=['status','=',1];
}
if($mark==1){
$this->searchWhere[]=['financial_pm','=',1];
}elseif($mark==2){
$this->searchWhere[]=['financial_pm','=',0];
}
$this->searchWhere[]=['uid','=',$this->userId];
$list=UserSign::where($this->searchWhere)->order('id desc')
->limit($this->limitOffset, $this->limitLength)
->select()->each(function ($item){
if($item['order_type']==0){
$price=UserRecharge::where('order_id',$item['order_id'])->value('price')??0;
}else{
$price=StoreOrder::where('order_id',$item['order_id'])->value('pay_price')??0;
}
$item['title']=UserSignLogic::getTitle($item['type'],$price,$item['number']);
return $item;
});
return $list?->toArray();
}
/**
* @notes 获取用户标签数量
* @return int
* @author admin
* @date 2024/06/17 17:02
*/
public function count(): int
{
return UserSign::where($this->searchWhere)->count();
}
}