package com.zhongzheng.controller.distribution; import com.zhongzheng.common.annotation.Log; import com.zhongzheng.common.core.controller.BaseController; import com.zhongzheng.common.core.domain.AjaxResult; import com.zhongzheng.common.core.domain.model.LoginUser; import com.zhongzheng.common.core.page.TableDataInfo; import com.zhongzheng.common.enums.BusinessType; import com.zhongzheng.common.utils.ServletUtils; import com.zhongzheng.framework.web.service.TokenService; import com.zhongzheng.framework.web.service.WxLoginService; import com.zhongzheng.modules.distribution.bo.DistributionSellerAddBo; import com.zhongzheng.modules.distribution.bo.DistributionSellerEditBo; import com.zhongzheng.modules.distribution.bo.DistributionSellerQueryBo; import com.zhongzheng.modules.distribution.bo.SellerOrderQueryBo; import com.zhongzheng.modules.distribution.service.IDistributionSellerService; import com.zhongzheng.modules.distribution.vo.DistributionSellerVo; import com.zhongzheng.modules.distribution.vo.SellerOrderVo; import com.zhongzheng.modules.wx.bo.WxLoginBody; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.List; /** * 分销业务员Controller * * @author hjl * @date 2023-03-13 */ @Api(value = "分销业务员控制器", tags = {"分销业务员管理"}) @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController @RequestMapping("/distribution/seller") public class DistributionSellerController extends BaseController { private final IDistributionSellerService iDistributionSellerService; private final TokenService tokenService; private final WxLoginService wxLoginService; /** * 查询分销业务员列表 */ @ApiOperation("查询分销业务员列表") @PreAuthorize("@ss.hasPermi('system:seller:list')") @GetMapping("/list") public TableDataInfo list(DistributionSellerQueryBo bo) { startPage(); List list = iDistributionSellerService.findList(bo); return getDataTable(list); } /** * 获取分销业务员详细信息 */ @ApiOperation("获取分销业务员详细信息") @PreAuthorize("@ss.hasPermi('system:seller:query')") @GetMapping("/{salerId}") public AjaxResult getInfo(@PathVariable("salerId" ) Long salerId) { return AjaxResult.success(iDistributionSellerService.queryById(salerId)); } /** * 新增分销业务员 */ @ApiOperation("新增分销业务员") @PreAuthorize("@ss.hasPermi('system:seller:add')") @Log(title = "分销业务员", businessType = BusinessType.INSERT) @PostMapping() public AjaxResult add(@RequestBody DistributionSellerAddBo bo) { return toAjax(iDistributionSellerService.insertByAddBo(bo) ? 1 : 0); } /** * 修改分销业务员 */ @ApiOperation("修改分销业务员") @PreAuthorize("@ss.hasPermi('system:seller:edit')") @Log(title = "分销业务员", businessType = BusinessType.UPDATE) @PostMapping("/edit") public AjaxResult edit(@RequestBody DistributionSellerEditBo bo) { LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); bo.setSysUserId(loginUser.getUser().getUserId()); return toAjax(iDistributionSellerService.updateByEditBo(bo) ? 1 : 0); } /** * 管理员修改分销业务员 */ @ApiOperation("管理员修改分销业务员") @PreAuthorize("@ss.hasPermi('system:seller:edit')") @Log(title = "分销业务员", businessType = BusinessType.UPDATE) @PostMapping("/sysEdit") public AjaxResult sysEdit(@RequestBody DistributionSellerEditBo bo) { return toAjax(iDistributionSellerService.updateByEditBo(bo) ? 1 : 0); } /** * 新增分销业务员 */ @ApiOperation("批量新增关联分销业务员") @PreAuthorize("@ss.hasPermi('system:seller:add')") @Log(title = "分销业务员", businessType = BusinessType.INSERT) @PostMapping("/batchAdd") public AjaxResult batchAdd(@RequestBody DistributionSellerAddBo bo) { return toAjax(iDistributionSellerService.insertBatchByAddBo(bo) ? 1 : 0); } /** * 获取用户信息 * * @return 用户信息 */ @ApiOperation("登录业务员用户信息") @GetMapping("getInfo") public AjaxResult getInfo() { LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); DistributionSellerVo vo = iDistributionSellerService.findDetail(loginUser.getUser().getSellerId()); vo.setSelfNull(); return AjaxResult.success(vo); } @ApiOperation("业务员检查是否绑定公众号") @GetMapping("/checkBindGzh") public AjaxResult checkBindGzh() { LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); DistributionSellerVo vo = iDistributionSellerService.queryById(loginUser.getUser().getSellerId()); return AjaxResult.success("成功",vo.getGzhOpenId()); } @ApiOperation("提现前绑定公众号openid") @PostMapping("/gzh_bind") public AjaxResult gzh_bind(@RequestBody WxLoginBody loginBody) { LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); loginBody.setSellerId(loginUser.getUser().getSellerId()); wxLoginService.bindWxGzhUnionIdSeller(loginBody); return AjaxResult.success(); } @ApiOperation("业务员佣金") @GetMapping("/cash/list") public TableDataInfo getCashList(SellerOrderQueryBo bo) { startPage(); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); bo.setSellerId(loginUser.getUser().getSellerId()); List list = iDistributionSellerService.getCashList(bo); return getDataTable(list); } }