Receive.Class.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?php
  2. /**
  3. * 应收单管理模块
  4. * Created by PhpStorm.
  5. * User: tpl
  6. * Date: 2019/10/30
  7. * Time: 13:54
  8. */
  9. namespace JinDouYun\Controller\Finance;
  10. use Mall\Framework\Core\ErrorCode;
  11. use Mall\Framework\Core\StatusCode;
  12. use JinDouYun\Controller\BaseController;
  13. use JinDouYun\Model\Finance\MReceive;
  14. class Receive extends BaseController
  15. {
  16. private $objMReceive;
  17. public function __construct($isCheckAcl = true, $isMustLogin = true)
  18. {
  19. parent::__construct($isCheckAcl, $isMustLogin);
  20. $this->objMReceive = new MReceive($this->onlineEnterpriseId, $this->onlineUserId);
  21. }
  22. /**
  23. * 添加和编辑应收单管理公共字段处理方法
  24. *
  25. * @return array
  26. */
  27. public function commonFieldFilter()
  28. {
  29. $params = $this->request->getRawJson();
  30. if (empty($params)) {
  31. $this->sendOutput('参数为空', ErrorCode::$paramError);
  32. }
  33. $receiveData = [
  34. 'customerId' => isset($params['customerId']) ? $params['customerId'] : '',//int(11) DEFAULT NULL COMMENT '客户Id',
  35. 'customerName' => isset($params['customerName']) ? $params['customerName'] : '',//varchar(50) DEFAULT NULL COMMENT '客户名称',
  36. 'orderId' => isset($params['orderId']) ? $params['orderId'] : '',//varchar(50) DEFAULT NULL COMMENT '单据编号',
  37. 'sourceNo' => isset($params['sourceNo']) ? $params['sourceNo'] : '',//varchar(50) DEFAULT NULL COMMENT '订单号',
  38. 'financeTypeId' => isset($params['financeTypeId']) ? $params['financeTypeId'] : '',//int(10) DEFAULT NULL COMMENT '财务类型id',
  39. 'financeType' => isset($params['financeType']) ? $params['financeType'] : '',
  40. 'discountMoney' => isset($params['discountMoney']) ? $params['discountMoney'] : '',//float(10,2) DEFAULT NULL COMMENT '优惠金额',
  41. 'receiveMoney' => isset($params['receiveMoney']) ? $params['receiveMoney'] : '',//float(10,2) DEFAULT NULL COMMENT '实际应收金额',
  42. 'shopId' => isset($params['shopId']) ? $params['shopId'] : '',//int(11) DEFAULT NULL COMMENT '商铺Id',
  43. 'shopName' => isset($params['shopName']) ? $params['shopName'] : '',//varchar(50) DEFAULT NULL COMMENT '商铺名称',
  44. 'receiptTypeId' => isset($params['receiptTypeId']) ? $params['receiptTypeId'] : '',//tinyint(2) DEFAULT NULL COMMENT '单据状态',
  45. 'auditStatus' => isset($params['auditStatus']) ? $params['auditStatus'] : '',//tinyint(2) DEFAULT NULL COMMENT '单据状态',
  46. 'offsetStatus' => getArrayItem($params, 'offsetStatus',4),
  47. ];
  48. foreach ($receiveData as $key => $value) {
  49. if (empty($value) && $value !== 0) {
  50. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  51. }
  52. }
  53. $receiveData['deleteStatus'] = StatusCode::$standard;
  54. $receiveData['createTime'] = time();
  55. $receiveData['updateTime'] = time();
  56. return $receiveData;
  57. }
  58. /**
  59. * 添加应收单
  60. */
  61. public function addReceive()
  62. {
  63. $receiveData = $this->commonFieldFilter();
  64. $result = $this->objMReceive->addReceive($receiveData);
  65. if ($result->isSuccess()) {
  66. parent::sendOutput($result->getData());
  67. } else {
  68. parent::sendOutput($result->getData(), $result->getErrorCode());
  69. }
  70. }
  71. /**
  72. * 获取指定应收单信息
  73. */
  74. public function getReceiveInfo()
  75. {
  76. $params = $this->request->getRawJson();
  77. if (empty($params['id']) || empty($params['createTime'])) {
  78. $this->sendOutput('参数为空', ErrorCode::$paramError);
  79. }
  80. $result = $this->objMReceive->getReceiveInfo($params);
  81. if ($result->isSuccess()) {
  82. $this->sendOutput($result->getData());
  83. } else {
  84. $this->sendOutput($result->getData(), $result->getErrorCode());
  85. }
  86. }
  87. /**
  88. * 应收单审核
  89. */
  90. public function updateReceiveStatus()
  91. {
  92. $params = $this->request->getRawJson();
  93. if (empty($params['id']) || empty($params['createTime'])) {
  94. $this->sendOutput('参数为空', ErrorCode::$paramError);
  95. }
  96. $result = $this->objMReceive->updateReceiveStatus($params);
  97. if ($result->isSuccess()) {
  98. parent::sendOutput($result->getData());
  99. } else {
  100. parent::sendOutput($result->getData(), $result->getErrorCode());
  101. }
  102. }
  103. /**
  104. * 后台所有应收单列表
  105. */
  106. public function getAllReceive()
  107. {
  108. $params = $this->request->getRawJson();
  109. if (empty($params)) {
  110. $this->sendOutput('参数为空', ErrorCode::$paramError);
  111. }
  112. $selectParams = [
  113. 'customerId' => getArrayItem($params, 'customerId', 0),
  114. 'auditStatus' => getArrayItem($params, 'auditStatus', 0),
  115. 'offsetStatus' => getArrayItem($params, 'offsetStatus', []),
  116. 'shopId' => getArrayItem($params, 'shopId', 0),
  117. 'receiveReceiptIds' => getArrayItem($params, 'receiveReceiptIds', []),
  118. 'start' => getArrayItem($params, 'start', 0),
  119. 'end' => getArrayItem($params, 'end', 0),
  120. ];
  121. $isExport = false;
  122. if(isset($params['isExport'])) {
  123. $isExport = $params['isExport'];
  124. }
  125. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  126. $selectParams['limit'] = $pageParams['limit'];
  127. $selectParams['offset'] = $pageParams['offset'];
  128. $result = $this->objMReceive->getAllReceive($selectParams, $isExport);
  129. if ($result->isSuccess()) {
  130. $returnData = $result->getData();
  131. $pageData = [
  132. 'pageIndex' => $params['page'],
  133. 'pageSize' => $params['pageSize'],
  134. 'pageTotal' => $returnData['total'],
  135. ];
  136. parent::sendOutput($returnData['data'], 0, $pageData);
  137. } else {
  138. parent::sendOutput($result->getData(), $result->getErrorCode());
  139. }
  140. }
  141. /**
  142. * 搜索
  143. */
  144. public function search()
  145. {
  146. $params = $this->request->getRawJson();
  147. if (empty($params)) {
  148. $this->sendOutput('参数为空', ErrorCode::$paramError);
  149. }
  150. $selectParams = [
  151. 'keyword' => isset($params['keyword']) ? $params['keyword'] : '',
  152. 'shopId' => isset($params['shopId']) ? $params['shopId'] : '',
  153. 'start' => isset($params['start']) ? $params['start'] : '',
  154. 'end' => isset($params['end']) ? $params['end'] : '',
  155. 'receiptTypeId' => isset($params['receiptTypeId']) ? $params['receiptTypeId'] : '',
  156. 'auditStatus' => isset($params['auditStatus']) ? $params['auditStatus'] : '',
  157. 'isExport' => isset($params['isExport']) ? $params['isExport'] : 0,
  158. ];
  159. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  160. $selectParams['limit'] = $pageParams['limit'];
  161. $selectParams['offset'] = $pageParams['offset'];
  162. $result = $this->objMReceive->search($selectParams);
  163. if ($result->isSuccess()) {
  164. $returnData = $result->getData();
  165. $pageData = [
  166. 'pageIndex' => $params['page'],
  167. 'pageSize' => $params['pageSize'],
  168. 'pageTotal' => $returnData['total'],
  169. ];
  170. parent::sendOutput($returnData['data'], 0, $pageData);
  171. } else {
  172. parent::sendOutput($result->getData(), $result->getErrorCode());
  173. }
  174. }
  175. }