DistributionController.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\shopapi\controller;
  20. use app\common\enum\DistributionConfigEnum;
  21. use app\common\model\DistributionConfig;
  22. use app\common\service\FileService;
  23. use app\shopapi\lists\DistributionOrderGoodsLists;
  24. use app\shopapi\lists\FansLists;
  25. use app\shopapi\logic\DistributionLogic;
  26. use app\shopapi\validate\DistributionValidate;
  27. /**
  28. * 分销控制器
  29. * Class DistributionController
  30. * @package app\shopapi\controller
  31. */
  32. class DistributionController extends BaseShopController
  33. {
  34. public array $notNeedLogin = ['fixAncestorRelation'];
  35. /** 填写邀请码
  36. * @notes
  37. * @return \think\response\Json
  38. * @author Tab
  39. * @date 2021/7/16 17:53
  40. */
  41. public function code()
  42. {
  43. $params = $this->request->post();
  44. $params['user_id'] = $this->userId;
  45. try {
  46. validate(DistributionValidate::class)->scene('code')->check($params);
  47. } catch (\Exception $e) {
  48. if (isset($params['hide'])) {
  49. return $this->fail($e->getMessage(), [], 0, 0);
  50. }
  51. return $this->fail($e->getMessage());
  52. }
  53. $result = DistributionLogic::code($params);
  54. // 不弹出提示语场景
  55. if($result && isset($params['hide'])) {
  56. return $this->success('邀请成功');
  57. }
  58. // 弹出提示语场景
  59. if($result) {
  60. return $this->success('邀请成功', [], 1, 1);
  61. }
  62. // 不弹出提示语场景
  63. if (isset($params['hide'])) {
  64. return $this->fail(DistributionLogic::getError(),[], 0, 0);
  65. }
  66. // 弹出提示语场景
  67. return $this->fail(DistributionLogic::getError());
  68. }
  69. /**
  70. * @notes 申请分销
  71. * @return \think\response\Json
  72. * @author Tab
  73. * @date 2021/7/17 10:36
  74. */
  75. public function apply()
  76. {
  77. $params = (new DistributionValidate())->post()->goCheck('apply', ['user_id' => $this->userId]);
  78. DistributionLogic::apply($params);
  79. return $this->success('申请成功');
  80. }
  81. /**
  82. * @notes 查看申请详情
  83. * @return \think\response\Json
  84. * @author Tab
  85. * @date 2021/7/17 11:38
  86. */
  87. public function applyDetail()
  88. {
  89. $result = DistributionLogic::applyDetail($this->userId);
  90. return $this->data($result);
  91. }
  92. /**
  93. * @notes 查看分销推广主页
  94. * @return \think\response\Json
  95. * @author Tab
  96. * @date 2021/7/17 15:40
  97. */
  98. public function index()
  99. {
  100. $result = DistributionLogic::index($this->userId);
  101. return $this->data($result);
  102. }
  103. /**
  104. * @notes 查看分销订单列表
  105. * @return \think\response\Json
  106. * @author Tab
  107. * @date 2021/7/17 16:46
  108. */
  109. public function order()
  110. {
  111. $params = $this->request->get();
  112. $params['page_no'] = $params['page_no'] ?? 1;
  113. $params['page_size'] = $params['page_size'] ?? 25;
  114. $params['user_id'] = $this->userId;
  115. $result = DistributionLogic::order($params);
  116. return $this->data($result);
  117. }
  118. /**
  119. * @notes 查看月度账单
  120. * @return \think\response\Json
  121. * @author Tab
  122. * @date 2021/7/17 18:45
  123. */
  124. public function monthBill()
  125. {
  126. $params = $this->request->get();
  127. $params['page_no'] = $params['page_no'] ?? 1;
  128. $params['page_size'] = $params['page_size'] ?? 25;
  129. $params['user_id'] = $this->userId;
  130. $result = DistributionLogic::monthBill($params);
  131. return $this->data($result);
  132. }
  133. /**
  134. * @notes 查看月度账单明细
  135. * @return \think\response\Json
  136. * @author Tab
  137. * @date 2021/7/19 10:25
  138. */
  139. public function monthDetail()
  140. {
  141. $params = $this->request->get();
  142. $params['page_no'] = $params['page_no'] ?? 1;
  143. $params['page_size'] = $params['page_size'] ?? 25;
  144. $params['year'] = $params['year'] ?? date('Y');
  145. $params['month'] = $params['month'] ?? date('m');
  146. $params['user_id'] = $this->userId;
  147. $result = DistributionLogic::monthDetail($params);
  148. return $this->data($result);
  149. }
  150. /**
  151. * @notes 我的粉丝
  152. * @return \think\response\Json
  153. * @author Tab
  154. * @date 2021/8/5 17:11
  155. */
  156. public function fans()
  157. {
  158. return $this->dataLists(new FansLists());
  159. }
  160. /**
  161. * @notes 分销海报
  162. * @return \think\response\Json
  163. * @author Tab
  164. * @date 2021/8/6 9:52
  165. */
  166. public function poster()
  167. {
  168. $params = $this->request->post();
  169. $params['user_id'] = $this->userId;
  170. $params['terminal'] = $this->userInfo['terminal'];
  171. $result = DistributionLogic::poster($params);
  172. if($result === false) {
  173. return $this->fail(DistributionLogic::getError());
  174. }
  175. return $this->data($result);
  176. }
  177. /**
  178. * 修复旧的关系链
  179. */
  180. public function fixAncestorRelation()
  181. {
  182. $result = DistributionLogic::fixAncestorRelation();
  183. if ($result) {
  184. return $this->success('修复成功');
  185. }
  186. return $this->fail(DistributionLogic::getError());
  187. }
  188. /**
  189. * @notes 获取分享海报
  190. * @return \think\response\Json
  191. * @author cjhao
  192. * @date 2021/11/17 18:36
  193. */
  194. public function getPoster(){
  195. $poster = DistributionLogic::getPoster();
  196. return $this->success('',$poster);
  197. }
  198. }