| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\extra\service\cutter;
- use app\extra\basic\Service;
- use app\extra\dao\cutter\CutterLabelDao;
- use app\extra\service\user\UserBrokerageService;
- use support\exception\BusinessException;
- class CutterLabelService extends Service
- {
- /**
- * 设置模型
- * @return string
- */
- public function __construct()
- {
- $this->dao = new CutterLabelDao();
- }
- /**
- * 列表
- * @param array $param
- */
- public function getList(array $param = [],string $field = '*', int $page = 0,int $limit = 0,string $order = 'id desc')
- {
- $list = $this->dao->getList($this->searchFilter($param),$field,$page,$limit,$order);
- $count = $this->dao->count($this->searchFilter($param));
- return compact('list','count');
- }
- protected function searchFilter(array $param = []): array
- {
- $filter = [];
- !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
- !empty($param['is_del']) && $filter[] = ["is_del", '=', $param['is_del']];
- !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
- return $filter;
- }
- public function getUserInfo(array $data):array
- {
- $user = $this->dao->getOne(['openid'=>$data['openid'],'is_del'=>0]);
- if($user->isEmpty()){
- $user = $this->dao->save(['openid'=>$data['openid'],'nickname'=>'wx'.time().rand(1000,9999),'login_ip'=>$data['login_ip'],'login_at'=>$data['login_at']]);
- }else if($user['status'] == 0){
- throw new BusinessException('用户已被封禁');
- }
- return $user->toArray();
- }
- public function getUserProfile(array $user)
- {
- if($user['is_del'])
- throw new BusinessException('用户已注销');
- if(!$user['status'])
- throw new BusinessException('用户已被封禁');
- $cutterOrderService = new CutterOrderService();
- $userBrokerageService = new UserBrokerageService();
- $user['order_count'] = $cutterOrderService->count(['uid'=>$user['uid']]);
- $user['brokerage_sum'] = $userBrokerageService->sum([['uid','=',$user['uid']],['pm','=',1],['type','not in',['extract_fail']]],'number');
- return $user;
- }
- }
|