123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- <?php
- /**
- * 分销商Controller
- * Created by PhpStorm.
- * User: haoren
- * Date: 2020/07/22
- * Time: 15:00
- */
- namespace JinDouYun\Controller\Commission;
- use Exception;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Commission\MCommissionBusinessman;
- class CommissionBusinessman extends BaseController
- {
- private $objMCommissionBusinessman;
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMCommissionBusinessman = new MCommissionBusinessman($this->onlineEnterpriseId, $this->onlineUserId);
- }
- /**
- * 获取参数
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $data = [
- 'customerId' => isset($params['customerId']) ? $params['customerId'] : '',
- ];
- foreach($data as $key => $value){
- if(empty($value) && $value !== 0){
- parent::sendOutput($key.'参数错误', ErrorCode::$paramError);
- }
- }
- (isset($params['info']) && !empty($params['info'])) && $data['info'] = $params['info'];
- (isset($params['gradeId']) && !empty($params['gradeId'])) && $data['gradeId'] = $params['gradeId'];
- (isset($params['grade']) && !empty($params['grade'])) && $data['grade'] = $params['grade'];
- return $data;
- }
- /**
- * 新增分销商
- * @throws Exception
- */
- public function addBusinessman()
- {
- $data = self::commonFieldFilter();
- $modelResult = $this->objMCommissionBusinessman->addBusinessman($data);
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 删除分销商
- * @throws Exception
- */
- public function delBusinessman()
- {
- $params = $this->request->getRawJson();
- $where = [];
- isset($params['userCenterId']) && $where['userCenterId'] = $params['userCenterId'];
- if(!isset($where['userCenterId'])){
- parent::sendOutput('userCenterId参数错误', ErrorCode::$paramError);
- }
- $update = [
- 'deleteStatus' => StatusCode::$delete
- ];
- $modelResult = $this->objMCommissionBusinessman->updateBusinessman($update, $where);
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 分销商审核
- * @throws Exception
- */
- public function auditBusinessman()
- {
- $params = $this->request->getRawJson();
- $where = [];
- isset($params['userCenterId']) && $where['userCenterId'] = $params['userCenterId'];
- $update = [
- 'auditStatus' => StatusCode::$auditStatus['auditPass']
- ];
- if(empty($where)){
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- if(!isset($where['userCenterId'])){
- parent::sendOutput('userCenterId参数错误', ErrorCode::$paramError);
- }
- $modelResult = $this->objMCommissionBusinessman->updateBusinessman($update, $where);
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 修改分销商
- * @throws Exception
- */
- public function updateBusinessman()
- {
- $id = $this->request->param('request_id');
- if(empty($id)){
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $data = self::commonFieldFilter();
- $modelResult = $this->objMCommissionBusinessman->updateBusinessman($data, ['userCenterId' => $id]);
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 分销商列表
- */
- public function getAllBusinessman()
- {
- $params = $this->request->getRawJson();
- if(empty($params)){
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $selectParams = [];
- $params['page'] = isset($params['page']) ? $params['page'] : 1;
- $params['pageSize'] = isset($params['pageSize']) ? $params['pageSize'] : 10;
- $pageParams = pageToOffset($params['page'], $params['pageSize']);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- if(isset($params['auditStatus']) && !empty($params['auditStatus'])){
- $selectParams['auditStatus'] = $params['auditStatus'];
- }
- if(isset($params['search']) && !empty($params['search'])){
- $selectParams['search'] = $params['search'];
- }
- if(isset($params['grade']) && !empty($params['grade'])){
- $selectParams['grade'] = $params['grade'];
- }
- if(isset($params['createStar']) && !empty($params['createStar']) && isset($params['createEnd']) && !empty($params['createEnd'])){
- $selectParams['createStar'] = $params['createStar'];
- $selectParams['createEnd'] = $params['createEnd'];
- }
- if(isset($params['applicationStar']) && !empty($params['applicationStar']) && isset($params['applicationEnd']) && !empty($params['applicationEnd'])){
- $selectParams['applicationStar'] = $params['applicationStar'];
- $selectParams['applicationEnd'] = $params['applicationEnd'];
- }
- if(isset($params['auditStar']) && !empty($params['auditStar']) && isset($params['auditEnd']) && !empty($params['auditEnd'])){
- $selectParams['auditStar'] = $params['auditStar'];
- }
- $export = isset($params['export']) ? $params['export'] : 0;// 导出未审核
- $distribution = isset($params['distribution']) ? $params['distribution'] : 0; // 导出分销商
- $modelResult = $this->objMCommissionBusinessman->getAllBusinessman($selectParams,$export,$distribution);
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- $returnData = $modelResult->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- /**
- * 查询分销商的所有下级
- * @throws Exception
- */
- public function getAllSub()
- {
- $params = $this->request->getRawJson();
- if(empty($params)){
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $data = [
- 'id' => isset($params['id']) ? $params['id'] : '',
- 'level' => isset($params['level']) ? $params['level'] : '',
- 'page' => isset($params['page']) ? $params['page'] : '',
- 'pageSize' => isset($params['pageSize']) ? $params['pageSize'] : '',
- ];
- foreach($data as $key => $value){
- if(empty($value) && $value !== 0){
- parent::sendOutput($key.'参数错误', ErrorCode::$paramError);
- }
- }
- $pageParams = pageToOffset($params['page'],$params['pageSize']);
- $data['limit'] = $pageParams['limit'];
- $data['offset'] = $pageParams['offset'];
- $modelResult = $this->objMCommissionBusinessman->getAllSub($data);
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- $returnData = $modelResult->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- 'subTotal' => $returnData['subTotal'],
- 'businessmanTotal' => $returnData['businessmanTotal'],
- 'subBusinessmanTotal' => $returnData['subBusinessmanTotal'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- /**
- * 分销商详情
- */
- public function getInfoBusinessman()
- {
- $where = [];
- $params = $this->request->getRawJson();
- isset($params['userCenterId']) && $where['userCenterId'] = $params['userCenterId'];
- if(empty($where)){
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $modelResult = $this->objMCommissionBusinessman->getInfoBusinessman($where);
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 首页统计
- */
- public function statisticsCommissionOne()
- {
- $modelResult = $this->objMCommissionBusinessman->statisticsCommissionOne();
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 首页统计(新增分销商数)
- */
- public function statisticsCommissionTwo()
- {
- $modelResult = $this->objMCommissionBusinessman->statisticsCommissionTwo();
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 首页统计(TOP)
- */
- public function statisticsCommissionThree()
- {
- $modelResult = $this->objMCommissionBusinessman->statisticsCommissionThree();
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * 查询分销商下级人数
- */
- public function getBusinessmanSubLevelNum()
- {
- $modelResult = $this->objMCommissionBusinessman->getBusinessmanSubLevelNum();
- if(!$modelResult->isSuccess()){
- parent::sendOutput($modelResult->getData(),$modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- }
|