CustomerBalance.Class.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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\MCustomerBalance;
  14. class CustomerBalance extends BaseController
  15. {
  16. private $objMCustomerBalance;
  17. public function __construct($isCheckAcl = true, $isMustLogin = true)
  18. {
  19. parent::__construct($isCheckAcl, $isMustLogin);
  20. $this->objMCustomerBalance = new MCustomerBalance($this->onlineEnterpriseId, $this->onlineUserId);
  21. }
  22. //测试勿用
  23. public function addCustomerBalance() {
  24. $result = $this->objMCustomerBalance->addCustomerBalance(6,-100);
  25. V($result);
  26. }
  27. /**
  28. * 后台所有客户余额列表
  29. */
  30. public function getAllCustomerBalance()
  31. {
  32. $params = $this->request->getRawJson();
  33. if (empty($params)) {
  34. $this->sendOutput('参数为空', ErrorCode::$paramError);
  35. }
  36. //接收客户Id
  37. //接收开始日期和结束日期
  38. $selectParams = [
  39. 'customerId' => isset($params['customerId']) ? $params['customerId'] : '',
  40. 'start' => isset($params['start']) ? $params['start'] : '',
  41. 'end' => isset($params['end']) ? $params['end'] : ''
  42. ];
  43. if($selectParams['start'] && $selectParams['end']) {
  44. if(empty($selectParams['customerId'])) {
  45. $this->sendOutput('请选择客户', ErrorCode::$paramError);
  46. }
  47. }
  48. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  49. $selectParams['limit'] = $pageParams['limit'];
  50. $selectParams['offset'] = $pageParams['offset'];
  51. $selectParams['tag'] = isset($params['tag']) ? $params['tag'] : '';//有无财产纠纷 5有 4没有
  52. $export = isset($params['export']) ? $params['export'] : 0;
  53. $result = $this->objMCustomerBalance->getAllCustomerBalance($selectParams,$export);
  54. if ($result->isSuccess()) {
  55. $returnData = $result->getData();
  56. $pageData = [
  57. 'pageIndex' => $params['page'],
  58. 'pageSize' => $params['pageSize'],
  59. 'pageTotal' => $returnData['total'],
  60. ];
  61. parent::sendOutput($returnData['data'], 0, $pageData);
  62. } else {
  63. parent::sendOutput($result->getData(), $result->getErrorCode());
  64. }
  65. }
  66. }