Purchase.Class.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <?php
  2. /**
  3. * 采购订单
  4. * Created by PhpStorm.
  5. * User: XiaoMing
  6. * Date: 2019/11/11
  7. * Time: 17:51
  8. */
  9. namespace JinDouYun\Controller\Purchase;
  10. use Exception;
  11. use JinDouYun\Controller\BaseController;
  12. use Mall\Framework\Core\ErrorCode;
  13. use JinDouYun\Model\Purchase\MPurchase;
  14. use Mall\Framework\Core\ResultWrapper;
  15. use Mall\Framework\Core\StatusCode;
  16. class Purchase extends BaseController
  17. {
  18. private $objMPurchase;
  19. /**
  20. * Purchase constructor.
  21. * @param bool $isCheckAcl
  22. * @param bool $isMustLogin
  23. * @throws Exception
  24. */
  25. public function __construct($isCheckAcl = true, $isMustLogin = true)
  26. {
  27. parent::__construct($isCheckAcl, $isMustLogin);
  28. $this->objMPurchase = new MPurchase($this->onlineUserId, $this->onlineEnterpriseId);
  29. }
  30. /**
  31. * 添加,编辑采购订单
  32. * @return array
  33. */
  34. public function commonFieldFilter()
  35. {
  36. $params = $this->request->getRawJson();
  37. if (empty($params)) {
  38. $this->sendOutput('参数为空', ErrorCode::$paramError);
  39. }
  40. $data = [
  41. 'warehouseId' => isset($params['warehouseId']) ? $params['warehouseId'] : '',
  42. 'buyerId' => isset($params['buyerId']) ? $params['buyerId'] : '',
  43. 'buyerName' => isset($params['buyerName']) ? $params['buyerName'] : '',
  44. 'operatorName' => isset($params['operatorName']) ? $params['operatorName'] : '',
  45. 'goodsData' => isset($params['goodsData']) ? $params['goodsData'] : '',//采购商品详情json
  46. 'operatorId' => $this->onlineUserId,
  47. 'couponAmount' => isset($params['couponAmount']) ? sprintf("%.4f", $params['couponAmount']) : '',
  48. 'otherAmount' => isset($params['otherAmount']) ? sprintf("%.4f", $params['otherAmount']) : '',
  49. 'purchaseType' => isset($params['purchaseType']) ? $params['purchaseType'] : StatusCode::$delete,
  50. ];
  51. foreach ($data as $key => $value) {
  52. if (empty($value) && $value !== 0) {
  53. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  54. }
  55. }
  56. if(isset($params['departmentPath'])){
  57. $data['extends'] = json_encode(['departmentPath' => $params['departmentPath']]);
  58. }
  59. $data['deleteArray'] = isset($params['deleteArray']) ? $params['deleteArray'] : [];//删除的采购商品id
  60. $goodsData = [];
  61. foreach ($data['goodsData'] as $key => $val) {
  62. $goodsData[$key] = [
  63. 'basicGoodsId' => isset($val['basicGoodsId']) ? $val['basicGoodsId'] : '',
  64. 'goodsCode' => isset($val['goodsCode']) ? $val['goodsCode'] : '',
  65. 'goodsName' => isset($val['goodsName']) ? $val['goodsName'] : '',
  66. 'skuId' => isset($val['skuId']) ? $val['skuId'] : '',
  67. 'buyerNum' => isset($val['buyerNum']) ? abs($val['buyerNum']) : '',
  68. 'buyerUnitPrice' => isset($val['buyerUnitPrice']) ? abs($val['buyerUnitPrice']) : '',
  69. 'subtotalPrice' => isset($val['subtotalPrice']) ? abs($val['subtotalPrice']) : '',
  70. ];
  71. foreach ($goodsData[$key] as $k => $v) {
  72. if (empty($v)) {
  73. $this->sendOutput($k . '参数错误', ErrorCode::$paramError);
  74. }
  75. }
  76. if (isset($val['id'])) $goodsData[$key]['id'] = $val['id'];
  77. $goodsData[$key]['couponAmount'] = isset($val['couponAmount']) ? $val['couponAmount'] : 0;
  78. $goodsData[$key]['otherAmount'] = isset($val['otherAmount']) ? $val['otherAmount'] : 0;
  79. $goodsData[$key]['categoryId'] = isset($val['categoryId']) ? $val['categoryId'] : 0;
  80. $goodsData[$key]['categoryName'] = isset($val['categoryName']) ? $val['categoryName'] : 0;
  81. $goodsData[$key]['unitName'] = isset($val['unitName']) ? $val['unitName'] : '';
  82. $goodsData[$key]['skuName'] = isset($val['skuName']) ? $val['skuName'] : '';
  83. $goodsData[$key]['otherNum'] = isset($val['otherNum']) ? $val['otherNum'] : '';
  84. }
  85. $data['goodsData'] = $goodsData;
  86. $data['remark'] = isset($params['remark']) ? $params['remark'] : null;
  87. if( $data['purchaseType'] == StatusCode::$standard ){
  88. $data['merchantId'] = isset($params['merchantId']) ? $params['merchantId'] : 0;
  89. $data['merchantName'] = isset($params['merchantName']) ? $params['merchantName'] : 0;
  90. if( empty($data['merchantId']) ){
  91. parent::sendOutput('merchantId参数错误', ErrorCode::$paramError);
  92. }
  93. } else {
  94. $data['supplierId'] = isset($params['supplierId']) ? $params['supplierId'] : '';
  95. $data['supplierName'] = isset($params['supplierName']) ? $params['supplierName'] : '';
  96. if( empty($data['supplierId']) ){
  97. parent::sendOutput('supplierId参数错误', ErrorCode::$paramError);
  98. }
  99. }
  100. $data['warehouseName'] = isset($params['warehouseName']) ? $params['warehouseName'] : '';
  101. return $data;
  102. }
  103. /**
  104. * 添加采购订单
  105. * @throws Exception
  106. */
  107. public function addPurchase()
  108. {
  109. $data = $this->commonFieldFilter();
  110. $this->shopId && $data['shopId'] = $this->shopId;
  111. $result = $this->objMPurchase->addPurchase($data);
  112. if ($result->isSuccess()) {
  113. parent::sendOutput($result->getData());
  114. } else {
  115. parent::sendOutput($result->getData(), $result->getErrorCode());
  116. }
  117. }
  118. /**
  119. * 采购订单信息
  120. * @throws Exception
  121. */
  122. public function getPurchaseInfoById()
  123. {
  124. $id = $this->request->param('request_id');
  125. if (!$id) {
  126. $this->sendOutput('参数错误', ErrorCode::$paramError);
  127. }
  128. $result = $this->objMPurchase->getPurchaseInfoById($id);
  129. if ($result->isSuccess()) {
  130. $resultData = $result->getData();
  131. parent::sendOutput($resultData);
  132. }
  133. parent::sendOutput($result->getData(), $result->getErrorCode());
  134. }
  135. /**
  136. * 采购订单详情和批次数据(采购退货单用)
  137. * @throws Exception
  138. */
  139. public function getPurchaseAndBatchInfoById()
  140. {
  141. $params = $this->request->getRawJson();
  142. $where = [
  143. 'id' => isset($params['id']) ? $params['id'] : '',
  144. 'warehouseId' => isset($params['warehouseId']) ? $params['warehouseId'] : '',
  145. ];
  146. foreach($where as $key => $value){
  147. if(empty($where)) parent::sendOutput($key.'参数错误', ErrorCode::$paramError);
  148. }
  149. $result = $this->objMPurchase->getPurchaseAndBatchInfoById($where);
  150. if ($result->isSuccess()) {
  151. $resultData = $result->getData();
  152. parent::sendOutput($resultData);
  153. }
  154. parent::sendOutput($result->getData(), $result->getErrorCode());
  155. }
  156. /**
  157. * 编辑采购订单
  158. * @throws Exception
  159. */
  160. public function editPurchase()
  161. {
  162. $id = $this->request->param('request_id');
  163. if (empty($id)) {
  164. $this->sendOutput('参数错误', ErrorCode::$paramError);
  165. }
  166. $data = $this->commonFieldFilter();
  167. $data['id'] = $id;
  168. $result = $this->objMPurchase->editPurchase($data);
  169. if ($result->isSuccess()) {
  170. parent::sendOutput($result->getData());
  171. } else {
  172. parent::sendOutput($result->getData(), $result->getErrorCode());
  173. }
  174. }
  175. /**
  176. * 更新审核状态
  177. */
  178. public function updateAuditStatus()
  179. {
  180. $id = $this->request->param('request_id');
  181. $params = $this->request->getRawJson();
  182. $data = [
  183. 'id' => $id,
  184. 'auditStatus' => $params['auditStatus'],
  185. 'auditName' => $params['auditName'],
  186. 'auditId' => $this->onlineUserId,
  187. 'auditTime' => time(),
  188. ];
  189. foreach ($data as $key => $value) {
  190. if (empty($value)) {
  191. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  192. }
  193. }
  194. $result = $this->objMPurchase->updateAuditStatus($data);
  195. if ($result->isSuccess()) {
  196. parent::sendOutput($result->getData());
  197. }
  198. parent::sendOutput($result->getData(), $result->getErrorCode());
  199. }
  200. /**
  201. * 删除采购单
  202. */
  203. public function delPurchase()
  204. {
  205. $id = $this->request->param('request_id');
  206. if (!$id) {
  207. $this->sendOutput('参数错误', ErrorCode::$paramError);
  208. }
  209. if (!is_array($id)) {
  210. $id = [$id];
  211. }
  212. $result = $this->objMPurchase->delPurchase($id);
  213. if ($result->isSuccess()) {
  214. parent::sendOutput($result->getData());
  215. }
  216. parent::sendOutput($result->getData(), $result->getErrorCode());
  217. }
  218. /**
  219. * 采购单列表
  220. * @throws Exception
  221. */
  222. public function getAllPurchase()
  223. {
  224. $params = $this->request->getRawJson();
  225. $page = isset($params['page']) ? $params['page'] : 1;
  226. $pageSize = isset($params['pageSize']) ? $params['pageSize'] : 10;
  227. $offset = ($page - 1) * $pageSize;
  228. $selectParams = [
  229. 'limit' => $pageSize,
  230. 'offset' => $offset,
  231. ];
  232. (isset($params['deleteStatus']) && !empty($params['deleteStatus'])) && $selectParams['deleteStatus'] = $params['deleteStatus'];
  233. if(isset($params['returnStatus']) && !empty($params['returnStatus'])){
  234. $selectParams['returnStatus'] = strpos($params['returnStatus'],',') ? explode(',',$params['returnStatus']) : $params['returnStatus'];
  235. }
  236. if(isset($params['inStatus']) && !empty($params['inStatus'])){
  237. $selectParams['inStatus'] = strpos($params['inStatus'],',') ? explode(',',$params['inStatus']) : $params['inStatus'];
  238. }
  239. if (isset($params['warehouseId']) && !empty($params['warehouseId'])) {
  240. $selectParams['warehouseId'] = $params['warehouseId'];
  241. }
  242. if (isset($params['isSelectInventory']) && !empty($params['isSelectInventory'])) {
  243. $selectParams['isSelectInventory'] = $params['isSelectInventory'];
  244. }
  245. $selectParams['purchaseType'] = isset($params['purchaseType']) ? $params['purchaseType'] : 4;
  246. if (isset($params['merchantId']) && !empty($params['merchantId'])) {
  247. $selectParams['merchantId'] = $params['merchantId'];
  248. }
  249. if (isset($params['keyword']) && !empty($params['keyword'])) {
  250. $selectParams['no']= substr($params['keyword'],strpos($params['keyword'],'-')+1);
  251. }
  252. if (isset($params['auditStatus']) && !empty($params['auditStatus'])) {
  253. if ($params['auditStatus']) $selectParams['auditStatus']=$params['auditStatus'] ;
  254. }
  255. if (isset($params['supplierId']) && !empty($params['supplierId'])) {
  256. $selectParams['supplierId']= $params['supplierId']; //供应商id
  257. }
  258. if (isset($params['buyerId']) && !empty($params['buyerId'])) {
  259. $selectParams['buyerId']= $params['buyerId']; //采购员id
  260. }
  261. !empty($this->shopId) && $selectParams['shopId'] = $this->shopId;
  262. //判断是否是打印
  263. $export = isset($params['export']) ? $params['export'] : 0;
  264. !empty($this->supplierId) && $selectParams['supplierId'] = $this->supplierId;
  265. if (isset($params['start']) && !empty($params['start'])) {
  266. $selectParams[] = ['createTime', '>=', $params['start']];
  267. }
  268. if (isset($params['end']) && !empty($params['end'])) {
  269. $selectParams[] = ['createTime', '<=', $params['end']];
  270. }
  271. $orderData = $this->objMPurchase->getAllPurchase($selectParams, $export);
  272. if ($orderData->isSuccess()) {
  273. $returnData = $orderData->getData();
  274. $pageData = [
  275. 'pageIndex' => $page,
  276. 'pageSize' => $pageSize,
  277. 'pageTotal' => $returnData['total'],
  278. ];
  279. parent::sendOutput($returnData['data'], 0, $pageData);
  280. }
  281. parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
  282. }
  283. /**
  284. * 根据采购单查询批次商品sku剩余库存数量
  285. */
  286. public function getInventoryBatchNum()
  287. {
  288. $id = $this->request->param('request_id');
  289. if(empty($id)){
  290. parent::sendOutput('参数为空', ErrorCode::$paramError);
  291. }
  292. $result = $this->objMPurchase->getInventoryBatchNum($id);
  293. if(!$result->isSuccess()){
  294. parent::sendOutput($result->getData(), $result->getErrorCode());
  295. }
  296. parent::sendOutput($result->getData());
  297. }
  298. /**
  299. * 采购汇总
  300. * @throws Exception
  301. */
  302. public function getAllPurchaseByFields()
  303. {
  304. $params = $this->request->getRawJson();
  305. $page = $params['page'] ?: 1;
  306. $pageSize = $params['pageSize'] ?: 10;
  307. $offset = ($page - 1) * $pageSize;
  308. $selectParams = [
  309. 'limit' => $pageSize,
  310. 'offset' => $offset,
  311. ];
  312. isset($params['inStatus']) && $selectParams['inStatus'] = $params['inStatus'];
  313. isset($params['goodsName']) && $selectParams['goodsName'] = $params['goodsName'];
  314. isset($params['categoryId']) && $selectParams['categoryId'] = $params['categoryId'];
  315. isset($params['warehouseId']) && $selectParams['warehouseId'] = $params['warehouseId'];
  316. isset($params['start']) && $selectParams['start'] = $params['start'];
  317. isset($params['end']) && $selectParams['end'] = $params['end'];
  318. isset($params['supplierId']) && $selectParams['supplierId'] = $params['supplierId'];//供应商id
  319. isset($params['buyerId']) && $selectParams['buyerId'] = $params['buyerId'];//采购员id
  320. isset($params['shopId']) && $selectParams['shopId'] = $params['shopId'];//门店id
  321. $selectParams['onReturn'] = isset($params['onReturn']) ? $params['onReturn'] : 0;
  322. $type = isset($params['type']) ? $params['type'] : 0;
  323. $export = isset($params['export']) ? $params['export'] : 0;
  324. $orderData = $this->objMPurchase->getAllPurchaseByFields($selectParams, $type ,$export);
  325. if ($orderData->isSuccess()) {
  326. $returnData = $orderData->getData();
  327. $pageData = [
  328. 'pageIndex' => $page,
  329. 'pageSize' => $pageSize,
  330. 'pageTotal' => $returnData['total'],
  331. ];
  332. parent::sendOutput($returnData['data'], 0, $pageData);
  333. }
  334. parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
  335. }
  336. /**
  337. * 汇总搜索 (暂未使用)
  338. */
  339. public function searchAllPurchaseByFields()
  340. {
  341. $params = $this->request->getRawJson();
  342. if( empty($params) ){
  343. $this->sendOutput('参数为空', ErrorCode::$paramError );
  344. }
  345. $selectParams = [
  346. 'categoryId' => isset($params['categoryId']) ? $params['categoryId'] : '',
  347. 'shopId' => isset($params['shopId']) ? $params['shopId'] : '',
  348. 'inStatus' => isset($params['inStatus']) ? $params['inStatus'] : '',
  349. 'start' => isset($params['start']) ? $params['start'] : '',
  350. 'end' => isset($params['end']) ? $params['end'] : '',
  351. 'search' => isset($params['search']) ? $params['search'] : '',
  352. ];
  353. $pageParams = pageToOffset($params['page'] ? : 1, $params['pageSize'] ? : 10);
  354. $selectParams['limit'] = $pageParams['limit'];
  355. $selectParams['offset'] = $pageParams['offset'];
  356. $selectParams['onReturn'] = isset($params['onReturn']) ? $params['onReturn'] : 0;
  357. $type = isset($params['type']) ? $params['type'] : 0;
  358. $export = isset($params['export']) ? $params['export'] : 0;
  359. $result = $this->objMPurchase->searchAllPurchaseByFields($selectParams, $type, $export);
  360. if($result->isSuccess()){
  361. $returnData = $result->getData();
  362. $pageData = [
  363. 'pageIndex' => $params['page'],
  364. 'pageSize' => $params['pageSize'],
  365. 'pageTotal' => $returnData['total'],
  366. ];
  367. parent::sendOutput($returnData['data'], 0, $pageData);
  368. }else{
  369. parent::sendOutput($result->getData(), $result->getErrorCode());
  370. }
  371. }
  372. /**
  373. * 查询采购数据和入库数据
  374. * @throws Exception
  375. */
  376. public function getAllPurchaseAndDetails()
  377. {
  378. $params = $this->request->getRawJson();
  379. $page = $params['page'] ?: 1;
  380. $pageSize = $params['pageSize'] ?: 10;
  381. $offset = ($page - 1) * $pageSize;
  382. $selectParams = [
  383. 'limit' => $pageSize,
  384. 'offset' => $offset,
  385. ];
  386. (isset($params['orderStatus']) && !empty($params['orderStatus'])) && $selectParams['orderStatus'] = $params['orderStatus'];
  387. $orderData = $this->objMPurchase->getAllPurchaseAndDetails($selectParams);
  388. if ($orderData->isSuccess()) {
  389. $returnData = $orderData->getData();
  390. $pageData = [
  391. 'pageIndex' => $page,
  392. 'pageSize' => $pageSize,
  393. 'pageTotal' => $returnData['total'],
  394. ];
  395. parent::sendOutput($returnData['data'], 0, $pageData);
  396. }
  397. parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
  398. }
  399. /**
  400. * 采购明细
  401. * @throws Exception
  402. */
  403. public function getAllPurchaseDetails()
  404. {
  405. $params = $this->request->getRawJson();
  406. $page = $params['page'] ?: 1;
  407. $pageSize = $params['pageSize'] ?: 10;
  408. $offset = ($page - 1) * $pageSize;
  409. $selectParams = [
  410. 'merchantId' => isset($params['merchantId']) ? $params['merchantId'] : '',
  411. 'limit' => $pageSize,
  412. 'offset' => $offset,
  413. ];
  414. $export = isset($params['export']) ? $params['export'] : 0;
  415. if(!empty($this->shopId)){
  416. $selectParams["shopId"] = $this->shopId;
  417. }
  418. $orderData = $this->objMPurchase->getAllPurchaseDetails($selectParams, $export);
  419. if ($orderData->isSuccess()) {
  420. $returnData = $orderData->getData();
  421. $pageData = [
  422. 'pageIndex' => $page,
  423. 'pageSize' => $pageSize,
  424. 'pageTotal' => $returnData['total'],
  425. ];
  426. parent::sendOutput($returnData['data'], 0, $pageData);
  427. }
  428. parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
  429. }
  430. /**
  431. * 采购明细搜索
  432. */
  433. public function searchAllPurchaseDetails()
  434. {
  435. $params = $this->request->getRawJson();
  436. if( empty($params) ){
  437. $this->sendOutput('参数为空', ErrorCode::$paramError );
  438. }
  439. $selectParams = [
  440. 'categoryId' => isset($params['categoryId']) ? $params['categoryId'] : '',
  441. 'supplierId' => isset($params['supplierId']) ? $params['supplierId'] : '',
  442. 'auditStatus' => isset($params['auditStatus']) ? $params['auditStatus'] : '',
  443. 'start' => isset($params['start']) ? $params['start'] : '',
  444. 'end' => isset($params['end']) ? $params['end'] : '',
  445. 'search' => isset($params['search']) ? $params['search'] : '',
  446. 'merchantId' => isset($params['merchantId']) ? $params['merchantId'] : '',
  447. 'shopId'=>isset($params['shopId']) ? $params['shopId'] : '',
  448. ];
  449. $pageParams = pageToOffset($params['page'] ? : 1, $params['pageSize'] ? : 10);
  450. $selectParams['limit'] = $pageParams['limit'];
  451. $selectParams['offset'] = $pageParams['offset'];
  452. $export = isset($params['export']) ? $params['export'] : 0;
  453. $result = $this->objMPurchase->getAllPurchaseDetails($selectParams, $export);
  454. if($result->isSuccess()){
  455. $returnData = $result->getData();
  456. $pageData = [
  457. 'pageIndex' => $params['page'],
  458. 'pageSize' => $params['pageSize'],
  459. 'pageTotal' => $returnData['total'],
  460. ];
  461. parent::sendOutput($returnData['data'], 0, $pageData);
  462. }else{
  463. parent::sendOutput($result->getData(), $result->getErrorCode());
  464. }
  465. }
  466. /**
  467. * 采购明细统计数据
  468. * @throws Exception
  469. */
  470. public function getAllData()
  471. {
  472. $modelResult = $this->objMPurchase->getAllData();
  473. if (!$modelResult->isSuccess()) {
  474. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  475. }
  476. parent::sendOutput($modelResult->getData());
  477. }
  478. /**
  479. * 采购订单再次入库
  480. */
  481. public function reStockIn()
  482. {
  483. $purchaseId = $this->request->param('request_id');
  484. if (empty($purchaseId)){
  485. parent::sendOutput('purchaseId参数错误',ErrorCode::$paramError);
  486. }
  487. $result = $this->objMPurchase->reStockIn($purchaseId);
  488. if (!$result->isSuccess()){
  489. parent::sendOutput($result->getData(),$result->getErrorCode());
  490. }
  491. parent::sendOutput($result->getData());
  492. }
  493. /**
  494. * 采购订单直接退款
  495. */
  496. public function retMoney()
  497. {
  498. $purchaseId = $this->request->param('request_id');
  499. if (empty($purchaseId)){
  500. parent::sendOutput('purchaseId参数错误',ErrorCode::$paramError);
  501. }
  502. $result = $this->objMPurchase->retMoney($purchaseId);
  503. if (!$result->isSuccess()){
  504. parent::sendOutput($result->getData(),$result->getErrorCode());
  505. }
  506. parent::sendOutput($result->getData());
  507. }
  508. /**
  509. * 智能采购列表
  510. */
  511. public function getAllOrderPurchase()
  512. {
  513. $params = $this->request->getRawJson();
  514. if( empty($params) ){
  515. $this->sendOutput('参数为空', ErrorCode::$paramError );
  516. }
  517. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  518. $params['limit'] = $pageParams['limit'];
  519. $params['offset'] = $pageParams['offset'];
  520. $params['no'] = getArrayItem($params,'no',"");
  521. if( isset($params['no']) || !empty($params['no']) ){
  522. $tmpSelectParams['no'] = explode('-',$params['no']);
  523. if(count($tmpSelectParams['no'])==3){
  524. $params['no'] = $tmpSelectParams['no'][1].'-'.$tmpSelectParams['no'][2];
  525. }
  526. }
  527. $params['customerName'] = getArrayItem($params,'customerName',"");
  528. $params['payStatus'] = getArrayItem($params,'payStatus',StatusCode::$standard);
  529. $params['orderStatus'] = getArrayItem($params,'orderStatus',StatusCode::$orderStatus['waitDelivery']);
  530. $params['auditStatus'] = getArrayItem($params,'auditStatus',StatusCode::$auditStatus['auditPass']);
  531. $params['start'] = getArrayItem($params,'start',"");
  532. $params['end'] = getArrayItem($params,'end',"");
  533. $returnData = $this->objMPurchase->getAllOrderPurchase($params);
  534. if ($returnData->isSuccess()) {
  535. $returnData = $returnData->getData();
  536. $pageData = [
  537. 'pageIndex' => $params['page'],
  538. 'pageSize' => $params['pageSize'],
  539. 'pageTotal' => $returnData['total'],
  540. ];
  541. parent::sendOutput($returnData['data'], 0, $pageData);
  542. } else {
  543. parent::sendOutput($returnData->getData(), ErrorCode::$dberror);
  544. }
  545. }
  546. }