Commission.Class.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace JinDouYun\Controller\Commission;
  3. use JinDouYun\Controller\BaseController;
  4. use JinDouYun\Model\Commission\MCommissionCalculate;
  5. use Mall\Framework\Core\ErrorCode;
  6. class Commission extends BaseController
  7. {
  8. private $objMCommissionCalculate;
  9. /**
  10. * CommissionCalculate constructor.
  11. * @param bool $isCheckAcl
  12. * @param bool $isMustLogin
  13. * @param bool $checkToken
  14. * @param bool $getAreaCode
  15. * @throws \Exception
  16. */
  17. public function __construct($isCheckAcl = false, $isMustLogin = true, $checkToken = true, $getAreaCode = false)
  18. {
  19. parent::__construct($isCheckAcl, $isMustLogin, $checkToken, $getAreaCode);
  20. $this->objMCommissionCalculate = new MCommissionCalculate($this->onlineEnterpriseId,$this->onlineUserId);
  21. }
  22. /**
  23. * Doc: (des="")
  24. * User: XMing
  25. * Date: 2020/7/28
  26. * Time: 5:52 下午
  27. * @throws \Exception
  28. */
  29. public function createCommission()
  30. {
  31. $params = $this->request->getRawJson();
  32. if(empty($params)){
  33. parent::sendOutput('参数为空', ErrorCode::$paramError);
  34. }
  35. if (!isset($params['orderId']) || empty($params['orderId'])){
  36. parent::sendOutput('orderId参数为空', ErrorCode::$paramError);
  37. }
  38. if (!isset($params['customerId']) || empty($params['customerId'])){
  39. parent::sendOutput('customerId参数错误', ErrorCode::$paramError);
  40. }
  41. $modelResult = $this->objMCommissionCalculate->createCommission($params['customerId'],$params['orderId']);
  42. if(!$modelResult->isSuccess()){
  43. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  44. }
  45. parent::sendOutput($modelResult->getData());
  46. }
  47. /**
  48. * Doc: (des="订单完成将等待入账转移到余额")
  49. * User: XMing
  50. * Date: 2020/7/30
  51. * Time: 6:27 下午
  52. */
  53. public function updateBalance()
  54. {
  55. $params = $this->request->getRawJson();
  56. if(empty($params)){
  57. parent::sendOutput('参数为空', ErrorCode::$paramError);
  58. }
  59. if (!isset($params['orderId']) || empty($params['orderId'])){
  60. parent::sendOutput('orderId参数为空', ErrorCode::$paramError);
  61. }
  62. $modelResult = $this->objMCommissionCalculate->updateBalance($params['orderId']);
  63. if(!$modelResult->isSuccess()){
  64. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  65. }
  66. parent::sendOutput($modelResult->getData());
  67. }
  68. /**
  69. * Doc: (des="分销订单取消,扣除待入账")
  70. * User: XMing
  71. * Date: 2020/7/31
  72. * Time: 6:04 下午
  73. */
  74. public function cancelSubCommission()
  75. {
  76. $params = $this->request->getRawJson();
  77. if(empty($params)){
  78. parent::sendOutput('参数为空', ErrorCode::$paramError);
  79. }
  80. if (!isset($params['orderId']) || empty($params['orderId'])){
  81. parent::sendOutput('orderId参数为空', ErrorCode::$paramError);
  82. }
  83. $modelResult = $this->objMCommissionCalculate->cancelSubCommission($params['orderId']);
  84. if(!$modelResult->isSuccess()){
  85. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  86. }
  87. parent::sendOutput($modelResult->getData());
  88. }
  89. }