SupplierWithdrawal.Class.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace JinDouYun\Controller\Purchase;
  3. use JinDouYun\Controller\BaseController;
  4. use JinDouYun\Model\Purchase\MSupplierWithdraw;
  5. use Mall\Framework\Core\ErrorCode;
  6. /**
  7. * @copyright Copyright (c) https://www.qianniaovip.com All rights reserved
  8. * Description:
  9. * Class SupplierWithdrawal
  10. * @package JinDouYun\Controller\Purchase
  11. */
  12. class SupplierWithdrawal extends BaseController
  13. {
  14. private $objMSupplierWithdraw;
  15. public function __construct($isCheckAcl = true, $isMustLogin = false, $checkToken = true, $getAreaCode = false, $checkShopToken = true, $checkSupplierToken = true)
  16. {
  17. parent::__construct($isCheckAcl, $isMustLogin, $checkToken, $getAreaCode, $checkShopToken, $checkSupplierToken);
  18. $this->objMSupplierWithdraw = new MSupplierWithdraw($this->onlineUserId,$this->onlineEnterpriseId);
  19. }
  20. /**
  21. * Doc: (des="")
  22. * User: XMing
  23. * Date: 2020/12/18
  24. * Time: 6:00 下午
  25. */
  26. public function add()
  27. {
  28. $paramsData = $this->request->getRawJson();
  29. $params = [
  30. 'type' => isset($paramsData['type']) ? $paramsData['type'] : '',
  31. 'accountContent' => isset($paramsData['accountContent']) ? $paramsData['accountContent'] : '',
  32. 'money' => isset($paramsData['money']) ? $paramsData['money'] : '',
  33. //'nowMoney' => isset($paramsData['nowMoney']) ? $paramsData['nowMoney'] : '',
  34. 'createTime' => time(),
  35. 'updateTime' => time(),
  36. ];
  37. foreach ($params as $k => $v) {
  38. if (empty($v) && $v !== 0) {
  39. parent::sendOutput($k . '参数错误', ErrorCode::$paramError);
  40. }
  41. }
  42. $result = $this->objMSupplierWithdraw->add($params,$this->supplierId);
  43. if ($result->isSuccess()) {
  44. parent::sendOutput($result->getData());
  45. }
  46. parent::sendOutput($result->getData(), $result->getErrorCode());
  47. }
  48. /**
  49. * Doc: (des="提现记录")
  50. * User: XMing
  51. * Date: 2020/12/8
  52. * Time: 3:54 下午
  53. */
  54. public function getAll()
  55. {
  56. $paramsData = (array)$this->request->getRawJson();
  57. $selectParams = [
  58. 'page' => isset($paramsData['page']) ? $paramsData['page'] : 1,
  59. 'pageSize' => isset($paramsData['pageSize']) ? $paramsData['pageSize'] : 10,
  60. 'startTime' => isset($paramsData['startTime']) ? $paramsData['startTime'] : 0,
  61. 'endTime' => isset($paramsData['endTime']) ? $paramsData['endTime'] : 0,
  62. 'supplierId' => getArrayItem($paramsData,'supplierId',0),
  63. ];
  64. foreach ($selectParams as $k => $v) {
  65. if (empty($v) && $v != 0) {
  66. parent::sendOutput($k . '参数错误', ErrorCode::$paramError);
  67. }
  68. }
  69. isset($paramsData['type']) && $selectParams['type'] = $paramsData['type'];
  70. (isset($paramsData['auditStatus']) && !empty($paramsData['auditStatus'])) && $selectParams['auditStatus'] = $paramsData['auditStatus'];
  71. $pageParams = pageToOffset($selectParams['page'], $selectParams['pageSize']);
  72. $selectParams['limit'] = $pageParams['limit'];
  73. $selectParams['offset'] = $pageParams['offset'];
  74. !empty($this->supplierId) && $selectParams['supplierId'] = $this->supplierId;
  75. $result = $this->objMSupplierWithdraw->getAll($selectParams);
  76. if ($result->isSuccess()) {
  77. $returnData = $result->getData();
  78. $pageData = [
  79. 'pageIndex' => getArrayItem($paramsData,'page',1),
  80. 'pageSize' => getArrayItem($paramsData,'pageSize',10),
  81. 'pageTotal' => $returnData['total'],
  82. ];
  83. parent::sendOutput($returnData['data'], 0, $pageData);
  84. }
  85. parent::sendOutput($result->getData(), ErrorCode::$dberror);
  86. }
  87. /**
  88. * Doc: (des="更新提现记录状态")
  89. * User: XMing
  90. * Date: 2020/12/8
  91. * Time: 3:55 下午
  92. * @throws \Exception
  93. */
  94. public function updateAuditStatus()
  95. {
  96. $id = $this->request->param('request_id');
  97. if (!$id) {
  98. parent::sendOutput('请指定要审核的数据id', ErrorCode::$paramError);
  99. }
  100. $status = $this->request->param('status');
  101. $reason = $this->request->param('reason');
  102. if(!$status){
  103. parent::sendOutput('请指定要修改的状态', ErrorCode::$paramError);
  104. }
  105. $result = $this->objMSupplierWithdraw->updateAuditStatus($id,$status,$reason);
  106. if ($result->isSuccess()) {
  107. parent::sendOutput($result->getData());
  108. }
  109. parent::sendOutput($result->getData(), ErrorCode::$dberror);
  110. }
  111. }