ReceiptTemplate.Class.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace JinDouYun\Controller\System;
  3. use JinDouYun\Controller\BaseController;
  4. use JinDouYun\Model\System\MReceiptTemplate;
  5. use Mall\Framework\Core\ErrorCode;
  6. use Mall\Framework\Core\StatusCode;
  7. /**
  8. * Description:
  9. * Class ReceiptTemplate
  10. * @package JinDouYun\Controller\System
  11. */
  12. class ReceiptTemplate extends BaseController
  13. {
  14. /**
  15. * @var MReceiptTemplate
  16. */
  17. private $objMReceiptTemplate;
  18. public function __construct($isCheckAcl = true, $isMustLogin = true, $checkToken = true, $getAreaCode = false)
  19. {
  20. parent::__construct($isCheckAcl, $isMustLogin, $checkToken, $getAreaCode);
  21. $this->objMReceiptTemplate = new MReceiptTemplate($this->onlineEnterpriseId,$this->onlineUserId);
  22. }
  23. /**
  24. * Doc: (des="")
  25. * User: XMing
  26. * Date: 2020/8/26
  27. * Time: 10:24 上午
  28. */
  29. public function getAll()
  30. {
  31. $result = $this->objMReceiptTemplate->getAll();
  32. if($result->isSuccess()){
  33. $pageData = [
  34. 'pageIndex' => 1,
  35. 'pageSize' => 10,
  36. 'pageTotal' => count($result->getData()),
  37. ];
  38. parent::sendOutput($result->getData(),0,$pageData);
  39. }
  40. parent::sendOutput($result->getData(), $result->getErrorCode());
  41. }
  42. /**
  43. * Doc: (des="")
  44. * User: XMing
  45. * Date: 2020/8/26
  46. * Time: 10:46 上午
  47. */
  48. public function save()
  49. {
  50. $params = $this->request->getRawJson();
  51. if (empty($params)) {
  52. parent::sendOutput('参数为空', ErrorCode::$paramError);
  53. }
  54. $data = [
  55. 'id' => isset($params['id']) ? $params['id'] : null,
  56. 'title' => isset($params['title']) ? $params['title'] : null,
  57. 'describe' => isset($params['describe']) ? $params['describe'] : '',
  58. 'fieldsData' => isset($params['fieldsData']) ? json_encode($params['fieldsData']) : [],
  59. ];
  60. foreach ($data as $key => $value) {
  61. if (empty($value) && $value != '') {
  62. parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
  63. }
  64. }
  65. $id = $data['id'];
  66. unset($data['id']);
  67. $result = $this->objMReceiptTemplate->save($data,$id);
  68. if($result->isSuccess()){
  69. parent::sendOutput($result->getData());
  70. }
  71. parent::sendOutput($result->getData(), $result->getErrorCode());
  72. }
  73. public function getInfo()
  74. {
  75. $id = $this->request->param('request_id');
  76. if (empty($id)){
  77. parent::sendOutput('id参数为空', ErrorCode::$paramError);
  78. }
  79. $result = $this->objMReceiptTemplate->getInfo($id);
  80. if($result->isSuccess()){
  81. parent::sendOutput($result->getData());
  82. }
  83. parent::sendOutput($result->getData(), $result->getErrorCode());
  84. }
  85. /**
  86. * Doc: (des="")
  87. * User: XMing
  88. * Date: 2020/8/29
  89. * Time: 4:48 下午
  90. */
  91. public function getTemplateInfo()
  92. {
  93. $id = $this->request->param('request_id');
  94. if (empty($id)){
  95. parent::sendOutput('id参数为空', ErrorCode::$paramError);
  96. }
  97. $result = $this->objMReceiptTemplate->getTemplateInfo($id);
  98. if($result->isSuccess()){
  99. parent::sendOutput($result->getData());
  100. }
  101. parent::sendOutput($result->getData(), $result->getErrorCode());
  102. }
  103. }