| | |
| | | package com.matrix.system.fenxiao.action; |
| | | |
| | | import com.matrix.core.anotations.RemoveRequestToken; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.core.tools.WebUtil; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.tools.DataAuthUtil; |
| | | import com.matrix.system.fenxiao.dao.ShopSalesmanApplyDao; |
| | | 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.service.ShopSalesmanApplyService; |
| | | import com.matrix.system.fenxiao.vo.*; |
| | | import com.matrix.system.hive.action.util.QueryUtil; |
| | | import com.matrix.system.hive.bean.ShoppingGoods; |
| | | import com.matrix.system.hive.bean.SysShopInfo; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | | import io.swagger.annotations.ApiResponses; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant; |
| | | import com.matrix.system.fenxiao.dto.ShopSalesmanApplyDto; |
| | | import com.matrix.system.fenxiao.service.FenXiaoSettingService; |
| | | import com.matrix.system.fenxiao.service.ShopSalesmanApplyService; |
| | | import com.matrix.system.fenxiao.vo.FenXiaoSettingVo; |
| | | import com.matrix.system.fenxiao.vo.ShopSalesmanApplyVo; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | |
| | | |
| | | @Autowired |
| | | private ShopSalesmanApplyService shopSalesmanApplyService; |
| | | @Autowired |
| | | private ShopSalesmanApplyDao shopSalesmanApplyDao; |
| | | @Autowired |
| | | private BizUserDao bizUserDao; |
| | | @Autowired |
| | | private ShopSalesmanGradeDao shopSalesmanGradeDao; |
| | | |
| | | /** |
| | | * 分销员详情页面信息 |
| | | */ |
| | | @ApiOperation(value = "分销员详情页面信息") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "OK", response = ShopSalesmanDetailVo.class) |
| | | }) |
| | | @PostMapping(value = "/findShopSalesmanDetail") |
| | | public @ResponseBody |
| | | AjaxResult findShopSalesmanDetail(@RequestBody ShopSalesmanDetailDto shopSalesmanDetailDto) { |
| | | //设置用户公司ID |
| | | QueryUtil.setQueryLimitCom(shopSalesmanDetailDto); |
| | | AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); |
| | | //根据OPENID查询基础信息 |
| | | String userId = shopSalesmanDetailDto.getUserId(); |
| | | SalesmanBasicDetailVo salesmanBasicDetailVo = shopSalesmanApplyService.selectShopSalesmanDetailByOpenId(userId); |
| | | result.putInMap("basicdetail", salesmanBasicDetailVo); |
| | | //排序 |
| | | if(StringUtils.isBlank(shopSalesmanDetailDto.getSort())){ |
| | | shopSalesmanDetailDto.setSort("create_time"); |
| | | shopSalesmanDetailDto.setOrder("desc"); |
| | | } |
| | | //查询绑定客户信息 |
| | | Page<ShopCustomDetailVo> page = new Page(shopSalesmanDetailDto.getPageNum(), shopSalesmanDetailDto.getPageSize()); |
| | | IPage<ShopCustomDetailVo> customDetailRows = shopSalesmanApplyService.findCustomDetail(page,shopSalesmanDetailDto); |
| | | result.putInMap("customDetailRecords", customDetailRows.getRecords()); |
| | | result.putInMap("customDetailTotal", customDetailRows.getTotal()); |
| | | //查询邀请下级信息 |
| | | 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()); |
| | | //查询收益订单 |
| | | Page<ShopOrderDetailVo> pageOrder = new Page(shopSalesmanDetailDto.getPageNum(), shopSalesmanDetailDto.getPageSize()); |
| | | IPage<ShopOrderDetailVo> orderRows = shopSalesmanApplyService.findShopOrderDetail(pageOrder,shopSalesmanDetailDto); |
| | | result.putInMap("orderRecords", orderRows.getRecords()); |
| | | result.putInMap("orderTotal", orderRows.getTotal()); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | *修改等级 |
| | | */ |
| | | @ApiOperation(value = "修改等级") |
| | | @PostMapping(value = "/changeSaleManGrade") |
| | | public @ResponseBody |
| | | AjaxResult changeSaleManGrade(@RequestBody ChangeSaleManGradeDto changeSaleManGradeDto) { |
| | | return shopSalesmanApplyService.changeSaleManGrade(changeSaleManGradeDto); |
| | | } |
| | | |
| | | /** |
| | | *解绑 |
| | | */ |
| | | @ApiOperation(value = "解绑") |
| | | @PostMapping(value = "/unbundlingSaleMan") |
| | | public @ResponseBody |
| | | AjaxResult unbundlingSaleMan(@RequestBody UnbundlingSaleManDto unbundlingSaleManDto) { |
| | | return shopSalesmanApplyService.unbundlingSaleMan(unbundlingSaleManDto); |
| | | } |
| | | |
| | | /** |
| | | * 查询分销员审核记录 |
| | | */ |
| | | |
| | | @ApiOperation(value = "查询分销员审核记录") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "OK", response = ShopSalesmanApplyVo.class) |
| | |
| | | AjaxResult findShopSalesmanApplyList(@RequestBody ShopSalesmanApplyDto shopSalesmanApplyDto) { |
| | | //设置用户公司ID |
| | | QueryUtil.setQueryLimitCom(shopSalesmanApplyDto); |
| | | |
| | | //排序 |
| | | if(StringUtils.isBlank(shopSalesmanApplyDto.getSort())){ |
| | | shopSalesmanApplyDto.setSort("createTime"); |
| | | shopSalesmanApplyDto.setSort("create_time"); |
| | | shopSalesmanApplyDto.setOrder("desc"); |
| | | } |
| | | |
| | | List<ShopSalesmanApplyVo> rows = shopSalesmanApplyService.findShopSalesmanApplyList(shopSalesmanApplyDto); |
| | | Integer total = shopSalesmanApplyService.findShopSalesmanApplyListTotal(shopSalesmanApplyDto); |
| | | AjaxResult result = AjaxResult.buildSuccessInstance(rows, total); |
| | | Page<ShopSalesmanApplyVo> page = new Page(shopSalesmanApplyDto.getPageNum(), shopSalesmanApplyDto.getPageSize()); |
| | | IPage<ShopSalesmanApplyVo> rows = shopSalesmanApplyService.findShopSalesmanApplyList(page,shopSalesmanApplyDto); |
| | | AjaxResult result = AjaxResult.buildSuccessInstance(rows.getRecords(),rows.getTotal()); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | *获取分销员审核记录 |
| | | *获取分销员待审核记录 |
| | | */ |
| | | @RequestMapping(value = "/fenXiaoUserApply") |
| | | public AjaxResult selectFenXiaoUserApply() { |
| | | @ApiOperation(value = "获取分销员待审核记录") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "OK", response = ShopSalesmanAppliingVo.class) |
| | | }) |
| | | @PostMapping(value = "/findShopSalesmanAppliingList") |
| | | public @ResponseBody |
| | | AjaxResult findShopSalesmanAppliingList(@RequestBody ShopSalesmanAppliingDto shopSalesmanAppliingDto) { |
| | | //设置用户公司ID |
| | | QueryUtil.setQueryLimitCom(shopSalesmanAppliingDto); |
| | | //排序 |
| | | if(StringUtils.isBlank(shopSalesmanAppliingDto.getSort())){ |
| | | shopSalesmanAppliingDto.setSort("create_time"); |
| | | shopSalesmanAppliingDto.setOrder("desc"); |
| | | } |
| | | |
| | | AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | Long companyId = user.getCompanyId(); |
| | | |
| | | //分销员审核记录 |
| | | List<ShopSalesmanApplyVo> shopSalesmanApplyVos = shopSalesmanApplyService.selectFenXiaoUserApplyByCompanyId(companyId); |
| | | result.putInMap("fxshjl", shopSalesmanApplyVos); |
| | | Page<ShopSalesmanAppliingVo> page = new Page(shopSalesmanAppliingDto.getPageNum(), shopSalesmanAppliingDto.getPageSize()); |
| | | IPage<ShopSalesmanAppliingVo> rows = shopSalesmanApplyService.selectBizUserApplyList(page,shopSalesmanAppliingDto); |
| | | |
| | | return result; |
| | | //IPage<ShopSalesmanAppliingVo> rows = shopSalesmanApplyService.findShopSalesmanAppliingList(page,shopSalesmanAppliingDto); |
| | | AjaxResult result = AjaxResult.buildSuccessInstance(rows.getRecords(),rows.getTotal()); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | *新增分销员 |
| | | */ |
| | | @ApiOperation(value = "新增分销员") |
| | | @PostMapping(value = "/addSaleManApply") |
| | | public @ResponseBody |
| | | AjaxResult findShopSalesmanAppliingList(@RequestBody AddSaleManApplyDto addSaleManApplyDto) { |
| | | //设置用户公司ID |
| | | QueryUtil.setQueryLimitCom(addSaleManApplyDto); |
| | | AjaxResult result= AjaxResult.buildSuccessInstance("设置成功"); |
| | | |
| | | shopSalesmanApplyService.addSaleManApply(addSaleManApplyDto.getUserId(),addSaleManApplyDto.getGradeId()); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | *删除---设置成不是分销员 |
| | | */ |
| | | @ApiOperation(value = "删除---设置成不是分销员") |
| | | @PostMapping(value = "/delSaleManGradeApply") |
| | | public @ResponseBody |
| | | AjaxResult delSaleManGradeApply(@RequestBody DelSaleManGradeApplyDto delSaleManGradeApplyDto) { |
| | | return shopSalesmanApplyService.delSaleManGradeApply(delSaleManGradeApplyDto); |
| | | } |
| | | |
| | | /** |
| | | *审核分销员 |
| | | */ |
| | | @ApiOperation(value = "审核分销员") |
| | | @PostMapping(value = "/examineSaleManApply") |
| | | public @ResponseBody |
| | | AjaxResult examineSaleManApply(@RequestBody ExamineSaleManApplyDto examineSaleManApplyDto) { |
| | | //设置用户公司ID |
| | | QueryUtil.setQueryLimitCom(examineSaleManApplyDto); |
| | | String userId = examineSaleManApplyDto.getUserId(); |
| | | //待审核状态才允许提交 |
| | | QueryWrapper<ShopSalesmanApply> queryWrapperOrepool = new QueryWrapper<>(); |
| | | queryWrapperOrepool.eq("user_id", userId); |
| | | queryWrapperOrepool.eq("company_id", examineSaleManApplyDto.getCompanyId()); |
| | | ShopSalesmanApply shopSalesmanApply = shopSalesmanApplyDao.selectOne(queryWrapperOrepool); |
| | | if(ObjectUtil.isEmpty(shopSalesmanApply)) { |
| | | return AjaxResult.buildFailInstance("当前记录有误"); |
| | | } |
| | | |
| | | BizUser bizUser = bizUserDao.findByOpenId(userId); |
| | | if(ObjectUtil.isEmpty(bizUser)) { |
| | | return AjaxResult.buildFailInstance("当前记录有误"); |
| | | } |
| | | |
| | | Integer applyStatus = shopSalesmanApply.getApplyStatus(); |
| | | if(ObjectUtil.isNotEmpty(applyStatus) && ShopSalesmanApply.APPLY_STATUS_DSH == applyStatus) { |
| | | Integer applyState = examineSaleManApplyDto.getApplyState(); |
| | | shopSalesmanApplyService.examineSaleManApply(shopSalesmanApply,applyState); |
| | | return AjaxResult.buildSuccessInstance("审核成功"); |
| | | }else{ |
| | | return AjaxResult.buildFailInstance("当前记录不是待审核状态"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | *获取对应的分销员等级 |
| | | */ |
| | | @RequestMapping(value = "/getShopSalesmanGrade") |
| | | private @ResponseBody AjaxResult getShopSalesmanGradeVo(){ |
| | | AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | List<ShopSalesmanGradeVo> dataList = shopSalesmanApplyService.getShopSalesmanGradeVo(user.getCompanyId()); |
| | | result.putInMap("salesGrade", dataList); |
| | | return result; |
| | | } |
| | | |
| | | } |