DistributionSellerController.java 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package com.zhongzheng.controller.distribution;
  2. import com.zhongzheng.common.annotation.Log;
  3. import com.zhongzheng.common.core.controller.BaseController;
  4. import com.zhongzheng.common.core.domain.AjaxResult;
  5. import com.zhongzheng.common.core.domain.model.LoginUser;
  6. import com.zhongzheng.common.core.page.TableDataInfo;
  7. import com.zhongzheng.common.enums.BusinessType;
  8. import com.zhongzheng.common.utils.ServletUtils;
  9. import com.zhongzheng.framework.web.service.SellerTokenService;
  10. import com.zhongzheng.framework.web.service.TokenService;
  11. import com.zhongzheng.framework.web.service.WxLoginService;
  12. import com.zhongzheng.modules.distribution.bo.DistributionSellerAddBo;
  13. import com.zhongzheng.modules.distribution.bo.DistributionSellerEditBo;
  14. import com.zhongzheng.modules.distribution.bo.DistributionSellerQueryBo;
  15. import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
  16. import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
  17. import com.zhongzheng.modules.user.bo.UserVisitLogAddBo;
  18. import com.zhongzheng.modules.user.entity.ClientLoginSeller;
  19. import com.zhongzheng.modules.wx.bo.WxLoginBody;
  20. import io.swagger.annotations.Api;
  21. import io.swagger.annotations.ApiOperation;
  22. import lombok.RequiredArgsConstructor;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.security.access.prepost.PreAuthorize;
  25. import org.springframework.web.bind.annotation.*;
  26. import java.util.List;
  27. /**
  28. * 分销业务员Controller
  29. *
  30. * @author hjl
  31. * @date 2023-03-13
  32. */
  33. @Api(value = "分销业务员控制器", tags = {"分销业务员管理"})
  34. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  35. @RestController
  36. @RequestMapping("/distribution/seller")
  37. public class DistributionSellerController extends BaseController {
  38. private final IDistributionSellerService iDistributionSellerService;
  39. private final TokenService tokenService;
  40. private final WxLoginService wxLoginService;
  41. /**
  42. * 查询分销业务员列表
  43. */
  44. @ApiOperation("查询分销业务员列表")
  45. @PreAuthorize("@ss.hasPermi('system:seller:list')")
  46. @GetMapping("/list")
  47. public TableDataInfo<DistributionSellerVo> list(DistributionSellerQueryBo bo) {
  48. startPage();
  49. List<DistributionSellerVo> list = iDistributionSellerService.findList(bo);
  50. return getDataTable(list);
  51. }
  52. /**
  53. * 获取分销业务员详细信息
  54. */
  55. @ApiOperation("获取分销业务员详细信息")
  56. @PreAuthorize("@ss.hasPermi('system:seller:query')")
  57. @GetMapping("/{salerId}")
  58. public AjaxResult<DistributionSellerVo> getInfo(@PathVariable("salerId" ) Long salerId) {
  59. return AjaxResult.success(iDistributionSellerService.queryById(salerId));
  60. }
  61. /**
  62. * 新增分销业务员
  63. */
  64. @ApiOperation("新增分销业务员")
  65. @PreAuthorize("@ss.hasPermi('system:seller:add')")
  66. @Log(title = "分销业务员", businessType = BusinessType.INSERT)
  67. @PostMapping()
  68. public AjaxResult<Void> add(@RequestBody DistributionSellerAddBo bo) {
  69. return toAjax(iDistributionSellerService.insertByAddBo(bo) ? 1 : 0);
  70. }
  71. /**
  72. * 修改分销业务员
  73. */
  74. @ApiOperation("修改分销业务员")
  75. @PreAuthorize("@ss.hasPermi('system:seller:edit')")
  76. @Log(title = "分销业务员", businessType = BusinessType.UPDATE)
  77. @PostMapping("/edit")
  78. public AjaxResult<Void> edit(@RequestBody DistributionSellerEditBo bo) {
  79. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  80. bo.setSellerId(loginUser.getUser().getSellerId());
  81. return toAjax(iDistributionSellerService.updateByEditBo(bo) ? 1 : 0);
  82. }
  83. /**
  84. * 管理员修改分销业务员
  85. */
  86. @ApiOperation("管理员修改分销业务员")
  87. @PreAuthorize("@ss.hasPermi('system:seller:edit')")
  88. @Log(title = "分销业务员", businessType = BusinessType.UPDATE)
  89. @PostMapping("/sysEdit")
  90. public AjaxResult<Void> sysEdit(@RequestBody DistributionSellerEditBo bo) {
  91. return toAjax(iDistributionSellerService.updateByEditBo(bo) ? 1 : 0);
  92. }
  93. /**
  94. * 新增分销业务员
  95. */
  96. @ApiOperation("批量新增关联分销业务员")
  97. @PreAuthorize("@ss.hasPermi('system:seller:add')")
  98. @Log(title = "分销业务员", businessType = BusinessType.INSERT)
  99. @PostMapping("/batchAdd")
  100. public AjaxResult<Void> batchAdd(@RequestBody DistributionSellerAddBo bo) {
  101. return toAjax(iDistributionSellerService.insertBatchByAddBo(bo) ? 1 : 0);
  102. }
  103. /**
  104. * 获取用户信息
  105. *
  106. * @return 用户信息
  107. */
  108. @ApiOperation("登录业务员用户信息")
  109. @GetMapping("getInfo")
  110. public AjaxResult<DistributionSellerVo> getInfo()
  111. {
  112. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  113. DistributionSellerVo vo = iDistributionSellerService.findDetail(loginUser.getUser().getSellerId());
  114. vo.setSelfNull();
  115. return AjaxResult.success(vo);
  116. }
  117. @ApiOperation("业务员检查是否绑定公众号")
  118. @GetMapping("/checkBindGzh")
  119. public AjaxResult<String> checkBindGzh()
  120. {
  121. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  122. DistributionSellerVo vo = iDistributionSellerService.queryById(loginUser.getUser().getSellerId());
  123. return AjaxResult.success("成功",vo.getGzhOpenId());
  124. }
  125. @ApiOperation("提现前绑定公众号openid")
  126. @PostMapping("/gzh_bind")
  127. public AjaxResult gzh_bind(@RequestBody WxLoginBody loginBody)
  128. {
  129. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  130. loginBody.setSellerId(loginUser.getUser().getSellerId());
  131. wxLoginService.bindWxGzhUnionIdSeller(loginBody);
  132. return AjaxResult.success();
  133. }
  134. }