MerchantDetail.Class.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Gss
  5. * Date: 2021/4/7 0007
  6. * Time: 15:23
  7. */
  8. namespace JinDouYun\Controller\Merchant;
  9. use Mall\Framework\Core\ErrorCode;
  10. use JinDouYun\Controller\BaseController;
  11. use JinDouYun\Model\Merchant\MMerchantDetail;
  12. class MerchantDetail extends BaseController
  13. {
  14. private $objMMerchantDetail;
  15. public function __construct($isCheckAcl = true, $isMustLogin = true)
  16. {
  17. parent::__construct($isCheckAcl, $isMustLogin);
  18. $this->objMMerchantDetail = new MMerchantDetail($this->onlineEnterpriseId, $this->onlineUserId);
  19. }
  20. /**
  21. * 添加和编辑收支记录公共字段处理方法
  22. *
  23. * @return array
  24. */
  25. public function commonFieldFilter()
  26. {
  27. $params = $this->request->getRawJson();
  28. if (empty($params)) {
  29. $this->sendOutput('参数为空', ErrorCode::$paramError);
  30. }
  31. $ReceiptRequisitionData = [
  32. 'merchantId' => getArrayItem($params,'merchantId',''),
  33. 'merchantName' => getArrayItem($params, 'merchantName',''),
  34. 'money' => isset($params['money']) ? $params['money'] : 0.00,
  35. 'type' => isset($params['type']) ? $params['type'] : '',
  36. 'settlementId' => getArrayItem($params,'settlementId',''),
  37. ];
  38. foreach ($ReceiptRequisitionData as $key => $value) {
  39. if (empty($value) && $value !== 0) {
  40. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  41. }
  42. }
  43. $ReceiptRequisitionData['createTime'] = time();
  44. $ReceiptRequisitionData['updateTime'] = time();
  45. return $ReceiptRequisitionData;
  46. }
  47. /*
  48. * 新增收支记录
  49. * */
  50. public function addMerchantDetail()
  51. {
  52. $merchantDetailData = $this->commonFieldFilter();
  53. $result = $this->objMMerchantDetail->addMerchantDetail($merchantDetailData);
  54. if ($result->isSuccess()) {
  55. parent::sendOutput($result->getData());
  56. } else {
  57. parent::sendOutput($result->getData(), $result->getErrorCode());
  58. }
  59. }
  60. /*
  61. * 所有收支记录
  62. * */
  63. public function getAllMerchantDetail()
  64. {
  65. $params = $this->request->getRawJson();
  66. if (empty($params)) {
  67. $this->sendOutput('参数为空', ErrorCode::$paramError);
  68. }
  69. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  70. $params['limit'] = $pageParams['limit'];
  71. $params['offset'] = $pageParams['offset'];
  72. $params['merchantId'] = getArrayItem($params,'merchantId','');
  73. $params['type'] = getArrayItem($params,'type','');
  74. $params['start'] = getArrayItem($params,'start','');
  75. $params['end'] = getArrayItem($params,'end','');
  76. $returnData = $this->objMMerchantDetail->getAllMerchantDetail($params);
  77. if ($returnData->isSuccess()) {
  78. $returnData = $returnData->getData();
  79. $pageData = [
  80. 'pageIndex' => $params['page'],
  81. 'pageSize' => $params['pageSize'],
  82. 'pageTotal' => $returnData['total'],
  83. ];
  84. parent::sendOutput($returnData['data'], 0, $pageData);
  85. } else {
  86. parent::sendOutput($returnData->getData(), ErrorCode::$dberror);
  87. }
  88. }
  89. }