DistributionController.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\distribution\classes\DistributionRuleClass;
  4. use bizHd\distribution\classes\DistributionUserClass;
  5. use bizHd\distribution\classes\DistributionFlowClass;
  6. use bizHd\distribution\classes\DistributionOrderClass;
  7. use bizHd\distribution\classes\DistributionReportClass;
  8. use Yii;
  9. use common\components\util;
  10. /**
  11. * 分销(hdApp 门店设置-分销规则 / 客户详情-分销统计)
  12. */
  13. class DistributionController extends BaseController
  14. {
  15. /**
  16. * 获取当前门店分销规则
  17. */
  18. public function actionGetRule()
  19. {
  20. try {
  21. $data = DistributionRuleClass::getRule($this->shopId, $this->mainId);
  22. util::success($data);
  23. } catch (\Exception $e) {
  24. util::fail($e->getMessage());
  25. }
  26. }
  27. /**
  28. * 保存分销规则
  29. */
  30. public function actionSaveRule()
  31. {
  32. $post = Yii::$app->request->post();
  33. try {
  34. DistributionRuleClass::saveRule($this->shopId, $this->mainId, $post);
  35. util::complete('保存成功');
  36. } catch (\Exception $e) {
  37. util::fail($e->getMessage());
  38. }
  39. }
  40. /**
  41. * 客户分销统计(客户详情页)
  42. */
  43. public function actionGetUserStat()
  44. {
  45. $customId = (int)Yii::$app->request->get('customId', 0);
  46. try {
  47. $data = DistributionUserClass::getUserStat($this->shopId, $customId);
  48. util::success($data);
  49. } catch (\Exception $e) {
  50. util::fail($e->getMessage());
  51. }
  52. }
  53. /**
  54. * 客户分红变动明细(xhDistributionFlow)
  55. * customId=0 且 scope=shop 时查门店全部流水
  56. */
  57. public function actionGetFlowList()
  58. {
  59. $customId = (int)Yii::$app->request->get('customId', 0);
  60. $scope = trim(Yii::$app->request->get('scope', ''));
  61. if ($scope === 'shop') {
  62. $customId = 0;
  63. }
  64. try {
  65. $data = DistributionFlowClass::getFlowList($this->shopId, $customId);
  66. util::success($data);
  67. } catch (\Exception $e) {
  68. util::fail($e->getMessage());
  69. }
  70. }
  71. /**
  72. * 拉新客户列表(xhDistributionUser)
  73. */
  74. public function actionGetInviteList()
  75. {
  76. $customId = (int)Yii::$app->request->get('customId', 0);
  77. try {
  78. $data = DistributionUserClass::getInviteList($this->shopId, $customId);
  79. util::success($data);
  80. } catch (\Exception $e) {
  81. util::fail($e->getMessage());
  82. }
  83. }
  84. /**
  85. * 下线贡献分红明细(xhDistributionOrder)
  86. * distId/customId 可选;scope=shop 时查门店全部订单
  87. */
  88. public function actionGetContribOrderList()
  89. {
  90. $scope = trim(Yii::$app->request->get('scope', ''));
  91. $distId = (int)Yii::$app->request->get('distId', 0);
  92. if ($distId <= 0) {
  93. $distId = (int)Yii::$app->request->get('customId', 0);
  94. }
  95. if ($scope === 'shop') {
  96. $distId = 0;
  97. }
  98. $buyerId = (int)Yii::$app->request->get('buyerId', 0);
  99. try {
  100. $data = DistributionOrderClass::getContribOrderList($this->shopId, $distId, $buyerId);
  101. util::success($data);
  102. } catch (\Exception $e) {
  103. util::fail($e->getMessage());
  104. }
  105. }
  106. /**
  107. * 门店分销报表汇总
  108. */
  109. public function actionGetReportStat()
  110. {
  111. try {
  112. $data = DistributionReportClass::getReportStat($this->shopId);
  113. util::success($data);
  114. } catch (\Exception $e) {
  115. util::fail($e->getMessage());
  116. }
  117. }
  118. /**
  119. * 门店获佣人数明细
  120. */
  121. public function actionGetShopDistList()
  122. {
  123. try {
  124. $data = DistributionUserClass::getShopDistList($this->shopId);
  125. util::success($data);
  126. } catch (\Exception $e) {
  127. util::fail($e->getMessage());
  128. }
  129. }
  130. /**
  131. * 门店拉新明细
  132. */
  133. public function actionGetShopInviteList()
  134. {
  135. try {
  136. $data = DistributionUserClass::getShopInviteList($this->shopId);
  137. util::success($data);
  138. } catch (\Exception $e) {
  139. util::fail($e->getMessage());
  140. }
  141. }
  142. }