CustomerBalanceDetail.Class.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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\MCustomerBalanceDetail;
  14. class CustomerBalanceDetail extends BaseController
  15. {
  16. private $objMCustomerBalanceDetail;
  17. public function __construct($isCheckAcl = true, $isMustLogin = true)
  18. {
  19. parent::__construct($isCheckAcl, $isMustLogin);
  20. $this->objMCustomerBalanceDetail = new MCustomerBalanceDetail($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. $customerBalanceDetailData = [
  34. 'name' => isset($params['name']) ? $params['name'] : '',
  35. 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : '',
  36. 'images' => isset($params['images']) ? $params['images'] : '',
  37. 'images' => isset($params['images']) ? $params['images'] : '',
  38. 'images' => isset($params['images']) ? $params['images'] : '',
  39. ];
  40. foreach ($customerBalanceDetailData as $key => $value) {
  41. if (empty($value) && $value !== 0) {
  42. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  43. }
  44. }
  45. $customerBalanceDetailData['deleteStatus'] = StatusCode::$standard;
  46. $customerBalanceDetailData['createTime'] = time();
  47. $customerBalanceDetailData['updateTime'] = time();
  48. return $customerBalanceDetailData;
  49. }
  50. /**
  51. * 添加客户余额明细
  52. */
  53. public function addCustomerBalanceDetail()
  54. {
  55. $customerBalanceDetailData = $this->commonFieldFilter();
  56. $result = $this->objMCustomerBalanceDetail->addCustomerBalanceDetail($customerBalanceDetailData);
  57. if ($result->isSuccess()) {
  58. parent::sendOutput($result->getData());
  59. } else {
  60. parent::sendOutput($result->getData(), $result->getErrorCode());
  61. }
  62. }
  63. /**
  64. * 获取指定客户余额明细信息
  65. */
  66. public function getCustomerBalanceDetailInfo()
  67. {
  68. $customerBalanceDetailId = $this->request->param('request_id');
  69. if (!$customerBalanceDetailId) {
  70. $this->sendOutput('参数错误', ErrorCode::$paramError);
  71. }
  72. $result = $this->objMCustomerBalanceDetail->getCustomerBalanceDetailInfo($customerBalanceDetailId);
  73. if ($result->isSuccess()) {
  74. $this->sendOutput($result->getData());
  75. } else {
  76. $this->sendOutput($result->getData(), $result->getErrorCode());
  77. }
  78. }
  79. /**
  80. * 后台所有客户余额明细列表
  81. */
  82. public function getAllCustomerBalanceDetail()
  83. {
  84. $params = $this->request->getRawJson();
  85. if (empty($params)) {
  86. $this->sendOutput('参数为空', ErrorCode::$paramError);
  87. }
  88. $selectParams = [
  89. 'customerId' => isset($params['customerId']) ? $params['customerId'] : '',
  90. ];
  91. foreach ($selectParams as $key => $value) {
  92. if (empty($value) && $value !== 0) {
  93. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  94. }
  95. }
  96. $selectParams['start'] = !empty($params['start']) ? $params['start'] : 0;
  97. $selectParams['end'] = !empty($params['end']) ? strtotime(date('Y-m-d', $params['end']).'23:59:59') : time();
  98. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  99. $selectParams['limit'] = $pageParams['limit'];
  100. $selectParams['offset'] = $pageParams['offset'];
  101. $export = isset($params['export']) ? $params['export'] : 0;
  102. $result = $this->objMCustomerBalanceDetail->getAllCustomerBalanceDetail($selectParams,$export);
  103. if ($result->isSuccess()) {
  104. $returnData = $result->getData();
  105. $pageData = [
  106. 'pageIndex' => $params['page'],
  107. 'pageSize' => $params['pageSize'],
  108. 'pageTotal' => $returnData['total'],
  109. 'openingBalance' => $returnData['openingBalance'],
  110. 'endingBalance' => $returnData['endingBalance'],
  111. 'shouldReceiveTotal' => $returnData['shouldReceiveTotal'],
  112. 'actualReceiveTotal' => $returnData['actualReceiveTotal'],
  113. ];
  114. parent::sendOutput($returnData['data'], 0, $pageData);
  115. } else {
  116. parent::sendOutput($result->getData(), $result->getErrorCode());
  117. }
  118. }
  119. }