|  |  |  | 
|---|
|  |  |  | package com.matrix.system.fenxiao.action; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.hutool.core.util.ObjectUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.StrUtil; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.matrix.biz.bean.BizUser; | 
|---|
|  |  |  | import com.matrix.biz.dao.BizUserDao; | 
|---|
|  |  |  | import com.matrix.core.constance.MatrixConstance; | 
|---|
|  |  |  | import com.matrix.core.pojo.AjaxResult; | 
|---|
|  |  |  | import com.matrix.core.tools.StringUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao; | 
|---|
|  |  |  | import com.matrix.system.fenxiao.dto.*; | 
|---|
|  |  |  | import com.matrix.system.fenxiao.entity.ShopSalesmanApply; | 
|---|
|  |  |  | import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; | 
|---|
|  |  |  | import com.matrix.system.fenxiao.service.ShopSalesmanApplyService; | 
|---|
|  |  |  | import com.matrix.system.fenxiao.vo.*; | 
|---|
|  |  |  | import com.matrix.system.hive.action.util.QueryUtil; | 
|---|
|  |  |  | import com.matrix.system.hive.bean.SysVipInfo; | 
|---|
|  |  |  | import com.matrix.system.hive.dao.SysVipInfoDao; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import io.swagger.annotations.ApiResponse; | 
|---|
|  |  |  | import io.swagger.annotations.ApiResponses; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ShopSalesmanApplyDao shopSalesmanApplyDao; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BizUserDao bizUserDao; | 
|---|
|  |  |  | private SysVipInfoDao sysVipInfoDao; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ShopSalesmanGradeDao shopSalesmanGradeDao; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | @ApiResponses({ | 
|---|
|  |  |  | @ApiResponse(code = 200, message = "OK",  response = ShopSalesmanDetailVo.class) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @PostMapping(value = "/findShopSalesmanDetail") | 
|---|
|  |  |  | @PostMapping(value = "/loadParamSettingBasic") | 
|---|
|  |  |  | public @ResponseBody | 
|---|
|  |  |  | AjaxResult findShopSalesmanDetail(@RequestBody ShopSalesmanDetailDto shopSalesmanDetailDto) { | 
|---|
|  |  |  | AjaxResult findShopSalesmanDetail(@RequestBody LoadParamSettingBasicDto loadParamSettingBasicDto) { | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(shopSalesmanDetailDto); | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(loadParamSettingBasicDto); | 
|---|
|  |  |  | AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); | 
|---|
|  |  |  | //根据OPENID查询基础信息 | 
|---|
|  |  |  | String userId = shopSalesmanDetailDto.getUserId(); | 
|---|
|  |  |  | String applyId = shopSalesmanDetailDto.getApplyId(); | 
|---|
|  |  |  | SalesmanBasicDetailVo salesmanBasicDetailVo = shopSalesmanApplyService.selectShopSalesmanDetailByOpenId(userId,Long.parseLong(applyId)); | 
|---|
|  |  |  | SalesmanBasicDetailVo salesmanBasicDetailVo = shopSalesmanApplyService.selectShopSalesmanDetailByOpenId(loadParamSettingBasicDto.getUserId(),loadParamSettingBasicDto.getApplyId()); | 
|---|
|  |  |  | result.putInMap("basicdetail", salesmanBasicDetailVo); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分销员详情页面绑定客户 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation(value = "分销员详情页面绑定客户") | 
|---|
|  |  |  | @PostMapping(value = "/loadParamSetting") | 
|---|
|  |  |  | public @ResponseBody | 
|---|
|  |  |  | AjaxResult loadParamSetting(@RequestBody LoadParamSettingDto loadParamSettingDto) { | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(loadParamSettingDto); | 
|---|
|  |  |  | AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); | 
|---|
|  |  |  | //排序 | 
|---|
|  |  |  | if(StringUtils.isBlank(shopSalesmanDetailDto.getSort())){ | 
|---|
|  |  |  | shopSalesmanDetailDto.setSort("create_time"); | 
|---|
|  |  |  | shopSalesmanDetailDto.setOrder("desc"); | 
|---|
|  |  |  | if(StringUtils.isBlank(loadParamSettingDto.getSort())){ | 
|---|
|  |  |  | loadParamSettingDto.setSort("create_time"); | 
|---|
|  |  |  | loadParamSettingDto.setOrder("desc"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询绑定客户信息 | 
|---|
|  |  |  | Page<ShopCustomDetailVo> page = new Page(shopSalesmanDetailDto.getPageNum(), shopSalesmanDetailDto.getPageSize()); | 
|---|
|  |  |  | IPage<ShopCustomDetailVo> customDetailRows = shopSalesmanApplyService.findCustomDetail(page,shopSalesmanDetailDto); | 
|---|
|  |  |  | Page<ShopCustomDetailVo> page = new Page(loadParamSettingDto.getPageNum(), loadParamSettingDto.getPageSize()); | 
|---|
|  |  |  | IPage<ShopCustomDetailVo> customDetailRows = shopSalesmanApplyService.findCustomDetail(page,loadParamSettingDto); | 
|---|
|  |  |  | result.putInMap("customDetailRecords", customDetailRows.getRecords()); | 
|---|
|  |  |  | result.putInMap("customDetailTotal", customDetailRows.getTotal()); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分销员详情页面邀请下级 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation(value = "分销员详情页面邀请下级") | 
|---|
|  |  |  | @PostMapping(value = "/loadParamSettinglow") | 
|---|
|  |  |  | public @ResponseBody | 
|---|
|  |  |  | AjaxResult loadParamSettinglow(@RequestBody ShopSalesmanDetailDto shopSalesmanDetailDto) { | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(shopSalesmanDetailDto); | 
|---|
|  |  |  | AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); | 
|---|
|  |  |  | //排序 | 
|---|
|  |  |  | if(StringUtils.isBlank(shopSalesmanDetailDto.getSort())){ | 
|---|
|  |  |  | shopSalesmanDetailDto.setSort("create_time"); | 
|---|
|  |  |  | shopSalesmanDetailDto.setOrder("desc"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询邀请下级信息 | 
|---|
|  |  |  | Page<ShopCustomDetailVo> pageLow = new Page(shopSalesmanDetailDto.getPageNum(), shopSalesmanDetailDto.getPageSize()); | 
|---|
|  |  |  | IPage<ShopCustomDetailVo> customLowRows = shopSalesmanApplyService.findCustomLow(pageLow,shopSalesmanDetailDto); | 
|---|
|  |  |  | result.putInMap("customLowRecords", customLowRows.getRecords()); | 
|---|
|  |  |  | result.putInMap("customLowTotal", customLowRows.getTotal()); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分销员详情页面收益订单 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation(value = "分销员详情页面收益订单") | 
|---|
|  |  |  | @PostMapping(value = "/loadParamSettingOrder") | 
|---|
|  |  |  | public @ResponseBody | 
|---|
|  |  |  | AjaxResult loadParamSettingOrder(@RequestBody ShopSalesmanDetailDto shopSalesmanDetailDto) { | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(shopSalesmanDetailDto); | 
|---|
|  |  |  | AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); | 
|---|
|  |  |  | //排序 | 
|---|
|  |  |  | if(StringUtils.isBlank(shopSalesmanDetailDto.getSort())){ | 
|---|
|  |  |  | shopSalesmanDetailDto.setSort("create_time"); | 
|---|
|  |  |  | shopSalesmanDetailDto.setOrder("desc"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询收益订单 | 
|---|
|  |  |  | Page<ShopOrderDetailVo> pageOrder = new Page(shopSalesmanDetailDto.getPageNum(), shopSalesmanDetailDto.getPageSize()); | 
|---|
|  |  |  | IPage<ShopOrderDetailVo> orderRows = shopSalesmanApplyService.findShopOrderDetail(pageOrder,shopSalesmanDetailDto); | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping(value = "/addSaleManApply") | 
|---|
|  |  |  | public @ResponseBody | 
|---|
|  |  |  | AjaxResult addSaleManApply(@RequestBody AddSaleManApplyDto addSaleManApplyDto) { | 
|---|
|  |  |  | String gradeId = addSaleManApplyDto.getGradeId(); | 
|---|
|  |  |  | if(StrUtil.isBlankOrUndefined(gradeId)) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("请选择分销等级"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ShopSalesmanGrade selectById = shopSalesmanGradeDao.selectById(Long.parseLong(gradeId)); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(selectById)) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("请选择分销等级"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(addSaleManApplyDto); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | shopSalesmanApplyService.addSaleManApply(addSaleManApplyDto.getOpenId(),gradeId); | 
|---|
|  |  |  | if(addSaleManApplyDto.getGradeId()==null) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("请选择分销等级"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | shopSalesmanApplyService.addSaleManApply(addSaleManApplyDto.getUserId(), addSaleManApplyDto.getGradeId()); | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance("设置成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | AjaxResult examineSaleManApply(@RequestBody ExamineSaleManApplyDto examineSaleManApplyDto) { | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(examineSaleManApplyDto); | 
|---|
|  |  |  | String userId = examineSaleManApplyDto.getUserId(); | 
|---|
|  |  |  | //待审核状态才允许提交 | 
|---|
|  |  |  | ShopSalesmanApply shopSalesmanApply = shopSalesmanApplyDao.selectById(examineSaleManApplyDto.getApplyId()); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(shopSalesmanApply)) { | 
|---|
|  |  |  | return  AjaxResult.buildFailInstance("当前记录有误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BizUser bizUser = bizUserDao.findByOpenId(userId); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(bizUser)) { | 
|---|
|  |  |  | SysVipInfo sysVipInfo = sysVipInfoDao.selectById(examineSaleManApplyDto.getUserId()); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(sysVipInfo)) { | 
|---|
|  |  |  | return  AjaxResult.buildFailInstance("当前记录有误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|