DistributionController.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * 商城 C 端分销接口
  4. * 用途:mallApp 我的分红页
  5. */
  6. namespace mall\controllers;
  7. use bizHd\distribution\classes\DistributionDepositClass;
  8. use bizHd\distribution\classes\DistributionFlowClass;
  9. use bizHd\distribution\classes\DistributionOrderClass;
  10. use bizHd\distribution\classes\DistributionUserClass;
  11. use common\components\util;
  12. use Yii;
  13. class DistributionController extends BaseController
  14. {
  15. /**
  16. * 我的分红汇总
  17. */
  18. public function actionGetMyStat()
  19. {
  20. if (empty($this->customId)) {
  21. util::fail('请先选择花店');
  22. }
  23. try {
  24. $data = DistributionUserClass::getMallMyStat($this->shopId, $this->customId);
  25. util::success($data);
  26. } catch (\Exception $e) {
  27. util::fail($e->getMessage());
  28. }
  29. }
  30. /**
  31. * 分红变动明细
  32. */
  33. public function actionGetFlowList()
  34. {
  35. if (empty($this->customId)) {
  36. util::fail('请先选择花店');
  37. }
  38. try {
  39. $data = DistributionFlowClass::getFlowList($this->shopId, $this->customId);
  40. util::success($data);
  41. } catch (\Exception $e) {
  42. util::fail($e->getMessage());
  43. }
  44. }
  45. /**
  46. * 拉新客户列表(当前登录客户为邀请人)
  47. */
  48. public function actionGetInviteList()
  49. {
  50. if (empty($this->customId)) {
  51. util::fail('请先选择花店');
  52. }
  53. try {
  54. $data = DistributionUserClass::getInviteList($this->shopId, $this->customId);
  55. util::success($data);
  56. } catch (\Exception $e) {
  57. util::fail($e->getMessage());
  58. }
  59. }
  60. /**
  61. * 下线贡献分红明细(xhDistributionOrder)
  62. */
  63. public function actionGetContribOrderList()
  64. {
  65. if (empty($this->customId)) {
  66. util::fail('请先选择花店');
  67. }
  68. $buyerId = (int)Yii::$app->request->get('buyerId', 0);
  69. try {
  70. $data = DistributionOrderClass::getContribOrderList($this->shopId, $this->customId, $buyerId);
  71. util::success($data);
  72. } catch (\Exception $e) {
  73. util::fail($e->getMessage());
  74. }
  75. }
  76. /**
  77. * 可存分红全额存入花店余额
  78. */
  79. public function actionDepositAvail()
  80. {
  81. if (empty($this->customId)) {
  82. util::fail('请先选择花店');
  83. }
  84. if (empty($this->hdId)) {
  85. util::fail('花店信息无效');
  86. }
  87. try {
  88. $result = DistributionDepositClass::depositAvailFull(
  89. (int)$this->shopId,
  90. (int)$this->mainId,
  91. (int)$this->hdId,
  92. (int)$this->customId
  93. );
  94. $stat = DistributionUserClass::getMallMyStat($this->shopId, $this->customId);
  95. util::success(array_merge($result, ['stat' => $stat]));
  96. } catch (\Exception $e) {
  97. util::fail($e->getMessage());
  98. }
  99. }
  100. }