ApiCommissionWithdrawals.Class.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * 分销体现记录Model
  4. * Created by PhpStorm.
  5. * User: phperstar
  6. * Date: 2020/07/22
  7. * Time: 15:00
  8. */
  9. namespace JinDouYun\Controller\Commission;
  10. use Mall\Framework\Core\ErrorCode;
  11. use Mall\Framework\Core\StatusCode;
  12. use JinDouYun\Controller\BaseController;
  13. use JinDouYun\Model\Commission\MCommissionWithdrawals;
  14. class ApiCommissionWithdrawals extends BaseController
  15. {
  16. private $objMCommissionWithdrawals;
  17. public function __construct($isCheckAcl = false, $isMustLogin = true, $checkToken = true)
  18. {
  19. parent::__construct($isCheckAcl, $isMustLogin, $checkToken);
  20. $this->objMCommissionWithdrawals = new MCommissionWithdrawals($this->onlineUserId, $this->onlineEnterpriseId);
  21. }
  22. /**
  23. * 添加提现记录
  24. */
  25. public function add()
  26. {
  27. $paramsData = $this->request->getRawJson();
  28. $params = [
  29. 'userCenterId' => $this->onlineUserId,
  30. 'businessmanId' => isset($paramsData['businessmanId']) ? $paramsData['businessmanId'] : '',
  31. 'type' => isset($paramsData['type']) ? $paramsData['type'] : '',
  32. 'accountContent' => isset($paramsData['accountContent']) ? $paramsData['accountContent'] : '',
  33. 'money' => isset($paramsData['money']) ? $paramsData['money'] : '',
  34. 'nowMoney' => isset($paramsData['nowMoney']) ? $paramsData['nowMoney'] : '',
  35. 'createTime' => time(),
  36. 'updateTime' => time(),
  37. ];
  38. foreach ($params as $k => $v) {
  39. if (empty($v) && $v !== 0) {
  40. $this->sendOutput($k . '参数错误', ErrorCode::$paramError);
  41. }
  42. }
  43. $result = $this->objMCommissionWithdrawals->add($params);
  44. if ($result->isSuccess()) {
  45. parent::sendOutput($result->getData());
  46. } else {
  47. parent::sendOutput($result->getData(), $result->getErrorCode());
  48. }
  49. }
  50. /**
  51. * 获取所有的体现记录
  52. */
  53. public function getAll()
  54. {
  55. $paramsData = $this->request->getRawJson();
  56. $selectParams = [
  57. 'page' => isset($paramsData['page']) ? $paramsData['page'] : 1,
  58. 'pageSize' => isset($paramsData['pageSize']) ? $paramsData['pageSize'] : 10,
  59. 'auditStatus' => isset($paramsData['auditStatus']) ? $paramsData['auditStatus'] : '',
  60. ];
  61. foreach ($selectParams as $k => $v) {
  62. if (empty($v) && $v !== 0) {
  63. $this->sendOutput($k . '参数错误', ErrorCode::$paramError);
  64. }
  65. }
  66. $pageParams = pageToOffset($selectParams['page'], $selectParams['pageSize']);
  67. $selectParams['limit'] = $pageParams['limit'];
  68. $selectParams['offset'] = $pageParams['offset'];
  69. $result = $this->objMCommissionWithdrawals->getAll($selectParams);
  70. if ($result->isSuccess()) {
  71. $returnData = $result->getData();
  72. $pageData = [
  73. 'pageIndex' => $paramsData['page'],
  74. 'pageSize' => $paramsData['pageSize'],
  75. 'pageTotal' => $returnData['total'],
  76. ];
  77. parent::sendOutput($returnData['data'], 0, $pageData);
  78. } else {
  79. parent::sendOutput($result->getData(), ErrorCode::$dberror);
  80. }
  81. }
  82. /**
  83. * 详情接口
  84. */
  85. public function detail()
  86. {
  87. $id = $this->request->param('request_id');
  88. if (!$id) {
  89. parent::sendOutput('请指定要审核的数据id', ErrorCode::$paramError);
  90. }
  91. $result = $this->objMCommissionWithdrawals->detail($id);
  92. if ($result->isSuccess()) {
  93. parent::sendOutput($result->getData());
  94. } else {
  95. parent::sendOutput($result->getData(), $result->getErrorCode());
  96. }
  97. }
  98. }