123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Gss
- * Date: 2021/3/8 0008
- * Time: 15:40
- */
- namespace JinDouYun\Controller\Finance;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Model\Finance\MExpenseSingle;
- use JinDouYun\Controller\BaseController;
- class ExpenseSingle extends BaseController
- {
- private $objMExpenseSingle;
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMExpenseSingle = new MExpenseSingle($this->onlineEnterpriseId, $this->onlineUserId);
- }
- /**
- * 添加和编辑收款申请单公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $ExpenseSingleData = [
- 'currentUnitId' => getArrayItem($params, 'currentUnitId'),
- 'currentUnit' => getArrayItem($params, 'currentUnit',''),
- 'type' => getArrayItem($params, 'type',''),
- 'billTime' => getArrayItem($params, 'billTime'),
- 'manager' => getArrayItem($params, 'manager',''),
- 'shopId' => getArrayItem($params, 'shopId',''),
- 'shopName' => getArrayItem($params, 'shopName',''),
- 'consumeTypeId' => getArrayItem($params, 'consumeTypeId',''),
- 'consumeTypeName' => getArrayItem($params, 'consumeTypeName',''),
- 'totalCollectionAmount' => getArrayItem($params,'totalCollectionAmount',0),
- 'totalPreferentialAmount' => getArrayItem($params,'totalPreferentialAmount',0),
- 'totalActualAmount' => getArrayItem($params,'totalActualAmount',0),
- 'payType' =>getArrayItem($params,'payType',''),
- 'auditStatus' =>getArrayItem($params,'auditStatus', StatusCode::$auditStatus['auditing']),
- 'deleteStatus' =>getArrayItem($params,'deleteStatus', 5),
- 'expenseSingleAccountDate' => getArrayItem($params,'expenseSingleAccountDate', [])
- ];
- foreach ($ExpenseSingleData as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- //判断expenseSingleAccountDate里面的数据是否为空
- foreach ($ExpenseSingleData['expenseSingleAccountDate'] as $expenseSingle) {
- if(!empty($expenseSingle)) {
- foreach ($expenseSingle as $k =>$v) {
- if(in_array($k, ['accountId','amount','settlementMethodId','settlementAccount']) && empty($v)) {
- $this->sendOutput('请输入账户'.$k, ErrorCode::$paramError);
- }
- }
- }
- }
- $ExpenseSingleData['createTime'] = time();
- $ExpenseSingleData['updateTime'] = time();
- return $ExpenseSingleData;
- }
- /**
- * 新增费用单
- */
- public function addExpenseSingle()
- {
- $expenseSingleData = $this->commonFieldFilter();
- $result = $this->objMExpenseSingle->addExpenseSingle($expenseSingleData);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 获取指定的费用单
- */
- public function getExpenseSingleInfo()
- {
- $expenseSingleId = $this->request->param('request_id');
- if (!$expenseSingleId) {
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMExpenseSingle->getExpenseSingleInfo($expenseSingleId);
- if ($result->isSuccess()) {
- $this->sendOutput($result->getData());
- } else {
- $this->sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 编辑指定的收款单
- */
- public function editExpenseSingle()
- {
- $expenseSingletId = $this->request->param('request_id');
- if(empty($expenseSingletId)){
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $expenseSingletData = $this->commonFieldFilter();
- $expenseSingletData['id'] = $expenseSingletId;
- $result = $this->objMExpenseSingle->editExpenseSingle($expenseSingletData);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 删除指定的费用单
- */
- public function delExpenseSingle()
- {
- $expenseSingleId = $this->request->param('request_id');
- if(!$expenseSingleId){
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMExpenseSingle->delExpenseSingle($expenseSingleId);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 获取所有的费用单
- */
- public function getAllExpenseSingle()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $params['limit'] = $pageParams['limit'];
- $params['offset'] = $pageParams['offset'];
- $params['currentUnitId'] = getArrayItem($params,'currentUnitId',"");
- $params['consumeTypeId'] = getArrayItem($params,'consumeTypeId',"");
- $params['auditStatus'] = getArrayItem($params,'auditStatus',"");
- $params['start'] = getArrayItem($params,'start',"");
- $params['end'] = getArrayItem($params,'end',"");
- $returnData = $this->objMExpenseSingle->getAllExpenseSingle($params);
- if ($returnData->isSuccess()) {
- $returnData = $returnData->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($returnData->getData(), ErrorCode::$dberror);
- }
- }
- /**
- * 审核费用单
- */
- public function updateExpenseStatus()
- {
- $params = $this->request->getRawJson();
- if (empty($params['id']) || empty($params['createTime'])) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $result = $this->objMExpenseSingle->updateExpenseStatus($params);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- }
|