123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- /**
- * Created by PhpStorm.
- * User: kang
- * Date: 2021/3/6
- * Time: 15:14
- */
- namespace JinDouYun\Controller\Finance;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Finance\MAccountType;
- class AccountType extends BaseController
- {
- private $objMAccountType;
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMAccountType = new MAccountType($this->onlineEnterpriseId, $this->onlineUserId);
- }
-
- /**
- * 添加和编辑费用类型公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter(){
-
- $params = $this->request->getRawJson();
- if( empty($params) ){
- $this->sendOutput('参数为空', ErrorCode::$paramError );
- }
- $accounTypeData = [
- 'enterpriseId' => $this->onlineEnterpriseId,
- 'name' => getArrayItem($params,'name'),
- 'type' => getArrayItem($params,'type' ,0),
-
- ];
- foreach($accounTypeData as $key => $value){
- if(empty($value) && $value !== 0){
- $this->sendOutput($key.'参数错误', ErrorCode::$paramError );
- }
- }
- $accounTypeData['remarks'] = getArrayItem($params,'remarks','');
- return $accounTypeData;
- }
-
- /**
- * 添加费用类型
- */
- public function addAccountType()
- {
- $accounTypeData = $this->commonFieldFilter();
- $result = $this->objMAccountType ->addAccountType($accounTypeData);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
-
- }
- /**
- * 获取指定费用类型
- */
- public function getAccountTypeInfo()
- {
- $accountTypeId = $this->request->param('request_id');
- if ( !$accountTypeId ) {
- $this->sendOutput('参数错误', ErrorCode::$paramError );
- }
- $result = $this->objMAccountType->getAccountTypeInfo($accountTypeId);
- if($result->isSuccess()){
- $this->sendOutput($result->getData());
- }else{
- $this->sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 编辑费用类型
- */
- public function editAccountType()
- {
- $params = $this->request->getRawJson();
- if(empty($params)){
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMAccountType->editAccountType($params);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
-
- }
-
- /**
- * 删除费用类型
- */
- public function delAccountType()
- {
- $accountTypeId = $this->request->param('request_id');
- if ( !$accountTypeId ) {
- $this->sendOutput('参数错误', ErrorCode::$paramError );
- }
- $result = $this->objMAccountType->delAccountType($accountTypeId);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
-
- /**
- * 后台所有费用类型
- */
- public function getAllAccountType()
- {
- $params = $this->request->getRawJson();
- if(empty($params)){
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $conditon = [
- 'type' => getArrayItem($params, 'type', 0)
- ];
-
- $result = $this->objMAccountType->getAllAccountType($conditon);
- if($result->isSuccess()){
- parent::sendOutput($result->getData(), 0);
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- }
|