ExpenseSingle.Class.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Gss
  5. * Date: 2021/3/8 0008
  6. * Time: 15:40
  7. */
  8. namespace JinDouYun\Controller\Finance;
  9. use Mall\Framework\Core\ErrorCode;
  10. use Mall\Framework\Core\StatusCode;
  11. use JinDouYun\Model\Finance\MExpenseSingle;
  12. use JinDouYun\Controller\BaseController;
  13. class ExpenseSingle extends BaseController
  14. {
  15. private $objMExpenseSingle;
  16. public function __construct($isCheckAcl = true, $isMustLogin = true)
  17. {
  18. parent::__construct($isCheckAcl, $isMustLogin);
  19. $this->objMExpenseSingle = new MExpenseSingle($this->onlineEnterpriseId, $this->onlineUserId);
  20. }
  21. /**
  22. * 添加和编辑收款申请单公共字段处理方法
  23. *
  24. * @return array
  25. */
  26. public function commonFieldFilter()
  27. {
  28. $params = $this->request->getRawJson();
  29. if (empty($params)) {
  30. $this->sendOutput('参数为空', ErrorCode::$paramError);
  31. }
  32. $ExpenseSingleData = [
  33. 'currentUnitId' => getArrayItem($params, 'currentUnitId'),
  34. 'currentUnit' => getArrayItem($params, 'currentUnit',''),
  35. 'type' => getArrayItem($params, 'type',''),
  36. 'billTime' => getArrayItem($params, 'billTime'),
  37. 'manager' => getArrayItem($params, 'manager',''),
  38. 'shopId' => getArrayItem($params, 'shopId',''),
  39. 'shopName' => getArrayItem($params, 'shopName',''),
  40. 'consumeTypeId' => getArrayItem($params, 'consumeTypeId',''),
  41. 'consumeTypeName' => getArrayItem($params, 'consumeTypeName',''),
  42. 'totalCollectionAmount' => getArrayItem($params,'totalCollectionAmount',0),
  43. 'totalPreferentialAmount' => getArrayItem($params,'totalPreferentialAmount',0),
  44. 'totalActualAmount' => getArrayItem($params,'totalActualAmount',0),
  45. 'payType' =>getArrayItem($params,'payType',''),
  46. 'auditStatus' =>getArrayItem($params,'auditStatus', StatusCode::$auditStatus['auditing']),
  47. 'deleteStatus' =>getArrayItem($params,'deleteStatus', 5),
  48. 'expenseSingleAccountDate' => getArrayItem($params,'expenseSingleAccountDate', [])
  49. ];
  50. foreach ($ExpenseSingleData as $key => $value) {
  51. if (empty($value) && $value !== 0) {
  52. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  53. }
  54. }
  55. //判断expenseSingleAccountDate里面的数据是否为空
  56. foreach ($ExpenseSingleData['expenseSingleAccountDate'] as $expenseSingle) {
  57. if(!empty($expenseSingle)) {
  58. foreach ($expenseSingle as $k =>$v) {
  59. if(in_array($k, ['accountId','amount','settlementMethodId','settlementAccount']) && empty($v)) {
  60. $this->sendOutput('请输入账户'.$k, ErrorCode::$paramError);
  61. }
  62. }
  63. }
  64. }
  65. $ExpenseSingleData['createTime'] = time();
  66. $ExpenseSingleData['updateTime'] = time();
  67. return $ExpenseSingleData;
  68. }
  69. /**
  70. * 新增费用单
  71. */
  72. public function addExpenseSingle()
  73. {
  74. $expenseSingleData = $this->commonFieldFilter();
  75. $result = $this->objMExpenseSingle->addExpenseSingle($expenseSingleData);
  76. if ($result->isSuccess()) {
  77. parent::sendOutput($result->getData());
  78. } else {
  79. parent::sendOutput($result->getData(), $result->getErrorCode());
  80. }
  81. }
  82. /**
  83. * 获取指定的费用单
  84. */
  85. public function getExpenseSingleInfo()
  86. {
  87. $expenseSingleId = $this->request->param('request_id');
  88. if (!$expenseSingleId) {
  89. $this->sendOutput('参数错误', ErrorCode::$paramError);
  90. }
  91. $result = $this->objMExpenseSingle->getExpenseSingleInfo($expenseSingleId);
  92. if ($result->isSuccess()) {
  93. $this->sendOutput($result->getData());
  94. } else {
  95. $this->sendOutput($result->getData(), $result->getErrorCode());
  96. }
  97. }
  98. /**
  99. * 编辑指定的收款单
  100. */
  101. public function editExpenseSingle()
  102. {
  103. $expenseSingletId = $this->request->param('request_id');
  104. if(empty($expenseSingletId)){
  105. $this->sendOutput('参数错误', ErrorCode::$paramError);
  106. }
  107. $expenseSingletData = $this->commonFieldFilter();
  108. $expenseSingletData['id'] = $expenseSingletId;
  109. $result = $this->objMExpenseSingle->editExpenseSingle($expenseSingletData);
  110. if($result->isSuccess()){
  111. parent::sendOutput($result->getData());
  112. }else{
  113. parent::sendOutput($result->getData(), $result->getErrorCode());
  114. }
  115. }
  116. /**
  117. * 删除指定的费用单
  118. */
  119. public function delExpenseSingle()
  120. {
  121. $expenseSingleId = $this->request->param('request_id');
  122. if(!$expenseSingleId){
  123. $this->sendOutput('参数错误', ErrorCode::$paramError);
  124. }
  125. $result = $this->objMExpenseSingle->delExpenseSingle($expenseSingleId);
  126. if($result->isSuccess()){
  127. parent::sendOutput($result->getData());
  128. }else{
  129. parent::sendOutput($result->getData(), $result->getErrorCode());
  130. }
  131. }
  132. /**
  133. * 获取所有的费用单
  134. */
  135. public function getAllExpenseSingle()
  136. {
  137. $params = $this->request->getRawJson();
  138. if (empty($params)) {
  139. $this->sendOutput('参数为空', ErrorCode::$paramError);
  140. }
  141. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  142. $params['limit'] = $pageParams['limit'];
  143. $params['offset'] = $pageParams['offset'];
  144. $params['currentUnitId'] = getArrayItem($params,'currentUnitId',"");
  145. $params['consumeTypeId'] = getArrayItem($params,'consumeTypeId',"");
  146. $params['auditStatus'] = getArrayItem($params,'auditStatus',"");
  147. $params['start'] = getArrayItem($params,'start',"");
  148. $params['end'] = getArrayItem($params,'end',"");
  149. $returnData = $this->objMExpenseSingle->getAllExpenseSingle($params);
  150. if ($returnData->isSuccess()) {
  151. $returnData = $returnData->getData();
  152. $pageData = [
  153. 'pageIndex' => $params['page'],
  154. 'pageSize' => $params['pageSize'],
  155. 'pageTotal' => $returnData['total'],
  156. ];
  157. parent::sendOutput($returnData['data'], 0, $pageData);
  158. } else {
  159. parent::sendOutput($returnData->getData(), ErrorCode::$dberror);
  160. }
  161. }
  162. /**
  163. * 审核费用单
  164. */
  165. public function updateExpenseStatus()
  166. {
  167. $params = $this->request->getRawJson();
  168. if (empty($params['id']) || empty($params['createTime'])) {
  169. $this->sendOutput('参数为空', ErrorCode::$paramError);
  170. }
  171. $result = $this->objMExpenseSingle->updateExpenseStatus($params);
  172. if ($result->isSuccess()) {
  173. parent::sendOutput($result->getData());
  174. } else {
  175. parent::sendOutput($result->getData(), $result->getErrorCode());
  176. }
  177. }
  178. }