From 4705f9b4084d9ccddb601569b223f0fb41778a94 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Thu, 12 Aug 2021 15:28:46 +0800 Subject: [PATCH] fix --- zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoUserAction.java | 358 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 333 insertions(+), 25 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoUserAction.java b/zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoUserAction.java index dbfae36..5ba6f89 100644 --- a/zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoUserAction.java +++ b/zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoUserAction.java @@ -1,26 +1,36 @@ 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.core.tools.WebUtil; +import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.bean.SysUsers; -import com.matrix.system.fenxiao.dto.AddSaleManApplyDto; -import com.matrix.system.fenxiao.dto.ShopSalesmanAppliingDto; -import com.matrix.system.fenxiao.dto.ShopSalesmanApplyDto; +import com.matrix.system.common.dao.BusParameterSettingsDao; +import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant; +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.entity.ShopSalesmanGrade; import com.matrix.system.fenxiao.service.ShopSalesmanApplyService; -import com.matrix.system.fenxiao.vo.ShopSalesmanAppliingVo; -import com.matrix.system.fenxiao.vo.ShopSalesmanApplyVo; -import com.matrix.system.fenxiao.vo.ShopSalesmanGradeVo; +import com.matrix.system.fenxiao.vo.*; import com.matrix.system.hive.action.util.QueryUtil; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; @RestController @@ -29,6 +39,254 @@ @Autowired private ShopSalesmanApplyService shopSalesmanApplyService; + @Autowired + private ShopSalesmanApplyDao shopSalesmanApplyDao; + @Autowired + private BizUserDao bizUserDao; + @Autowired + private ShopSalesmanGradeDao shopSalesmanGradeDao; + @Autowired + private BusParameterSettingsDao busParameterSettingsDao; + + /** + * 分销员详情页面信息 + */ + @ApiOperation(value = "分销员详情页面信息") + @ApiResponses({ + @ApiResponse(code = 200, message = "OK", response = ShopSalesmanDetailVo.class) + }) + @PostMapping(value = "/loadParamSettingBasic") + public @ResponseBody + AjaxResult findShopSalesmanDetail(@RequestBody LoadParamSettingBasicDto loadParamSettingBasicDto) { + //设置用户公司ID + QueryUtil.setQueryLimitCom(loadParamSettingBasicDto); + AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); + //根据OPENID查询基础信息 + String userId = loadParamSettingBasicDto.getUserId(); + String applyId = loadParamSettingBasicDto.getApplyId(); + SalesmanBasicDetailVo salesmanBasicDetailVo = shopSalesmanApplyService.selectShopSalesmanDetailByOpenId(userId,Long.parseLong(applyId)); + 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(loadParamSettingDto.getSort())){ + loadParamSettingDto.setSort("create_time"); + loadParamSettingDto.setOrder("desc"); + } + //查询绑定客户信息 + 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); + 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 = "推广图片") + @PostMapping(value = "/updateTgtp") + public @ResponseBody + AjaxResult updateTgtp(@RequestBody UpdateTgtpDto updateTgtpDto) { + return shopSalesmanApplyService.updateTgtp(updateTgtpDto); + } + + /** + *推广图片 + */ + @RequestMapping(value = "/loadTgtpSetting") + public AjaxResult loadTgtpSetting() { + + AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + Long companyId = user.getCompanyId(); + + //推广文案 + String[] FXKGCode={FenxiaoSettingConstant.FX_TG_POSTER}; + String[] FXKGName={"推广图片"}; + List<FenXiaoSettingVo> fxkgRuleSettingsVo = getRuleSettingsVo(FXKGCode,FXKGName,companyId); + result.putInMap("tgtp", fxkgRuleSettingsVo.get(0)); + return result; + } + + /** + *推广计划更新 + */ + @ApiOperation(value = "推广计划更新") + @PostMapping(value = "/updateTgjh") + public @ResponseBody + AjaxResult updateTgjh(@RequestBody UpdateTgjhDto updateTgjhDto) { + return shopSalesmanApplyService.updateTgjh(updateTgjhDto); + } + /** + *查询推广计划 + */ + @RequestMapping(value = "/loadTgwaSetting") + public AjaxResult loadTgwaSetting() { + + AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + Long companyId = user.getCompanyId(); + + //推广文案 + String[] FXKGCode={FenxiaoSettingConstant.FX_TG_PLAN}; + String[] FXKGName={"推广文案"}; + List<FenXiaoSettingVo> fxkgRuleSettingsVo = getRuleSettingsVo(FXKGCode,FXKGName,companyId); + result.putInMap("tgwa", fxkgRuleSettingsVo.get(0)); + return result; + } + + /** + *获取对应的规则设置数据 + * @param ArrayCode + * @param ArrayName + * @param companyId + * @return + */ + private List<FenXiaoSettingVo> getRuleSettingsVo(String[] ArrayCode,String[] ArrayName,Long companyId){ + List<BusParameterSettings> dataList = busParameterSettingsDao.selectByCodesAndCompanyId(Arrays.asList(ArrayCode), companyId); + List<FenXiaoSettingVo> scoreRuleSettingsVos=new ArrayList<FenXiaoSettingVo>(); + int index=0; + for (BusParameterSettings item:dataList){ + FenXiaoSettingVo paramVo=new FenXiaoSettingVo(); + BeanUtils.copyProperties(item,paramVo); + paramVo.setParamName(ArrayName[index]); + scoreRuleSettingsVos.add(paramVo); + index++; + } + return scoreRuleSettingsVos; + } + + /** + * 分佣方案 + */ + @ApiOperation(value = "查询分佣方案") + @ApiResponses({ + @ApiResponse(code = 200, message = "OK", response = FyfaManageVo.class) + }) + @PostMapping(value = "/findFyfaManageList") + public @ResponseBody + AjaxResult findFyfaManageList(@RequestBody FyfaManageDto fyfaManageDto) { + //设置用户公司ID + QueryUtil.setQueryLimitCom(fyfaManageDto); + //排序 + if(StringUtils.isBlank(fyfaManageDto.getSort())){ + fyfaManageDto.setSort("create_time"); + fyfaManageDto.setOrder("asc"); + } + Page<FyfaManageVo> page = new Page(fyfaManageDto.getPageNum(), fyfaManageDto.getPageSize()); + IPage<FyfaManageVo> rows = shopSalesmanApplyService.findFyfaManageList(page,fyfaManageDto); + AjaxResult result = AjaxResult.buildSuccessInstance(rows.getRecords(),rows.getTotal()); + return result; + } + + /** + *新增分佣方案 + */ + @ApiOperation(value = "新增分佣方案") + @RequestMapping(value = "/addFyfa") + private @ResponseBody AjaxResult addFyfa(){ + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + shopSalesmanApplyService.addFyfa(user); + return AjaxResult.buildSuccessInstance("新增成功"); + } + + /** + *修改分佣方案 + */ + @ApiOperation(value = "修改分佣方案") + @PostMapping(value = "/updateFyfa") + public @ResponseBody + AjaxResult updateFyfa(@RequestBody UpdateFyfaDto updateFyfaDto) { + return shopSalesmanApplyService.updateFyfa(updateFyfaDto); + } + + /** + *删除分佣方案 + */ + @ApiOperation(value = "删除分佣方案") + @PostMapping(value = "/delFyfaApply") + public @ResponseBody + AjaxResult delFyfaApply(@RequestBody DelFyfaApplyDto delFyfaApplyDto) { + return shopSalesmanApplyService.delFyfaApply(delFyfaApplyDto); + } /** * 查询分销员审核记录 @@ -47,7 +305,6 @@ shopSalesmanApplyDto.setSort("create_time"); shopSalesmanApplyDto.setOrder("desc"); } - Page<ShopSalesmanApplyVo> page = new Page(shopSalesmanApplyDto.getPageNum(), shopSalesmanApplyDto.getPageSize()); IPage<ShopSalesmanApplyVo> rows = shopSalesmanApplyService.findShopSalesmanApplyList(page,shopSalesmanApplyDto); AjaxResult result = AjaxResult.buildSuccessInstance(rows.getRecords(),rows.getTotal()); @@ -58,7 +315,7 @@ /** *获取分销员待审核记录 */ - @ApiOperation(value = "查询分销员审核记录") + @ApiOperation(value = "获取分销员待审核记录") @ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ShopSalesmanAppliingVo.class) }) @@ -82,29 +339,80 @@ } /** - *获取对应的分销员等级 - */ - @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; - } - - /** *新增分销员 */ @ApiOperation(value = "新增分销员") @PostMapping(value = "/addSaleManApply") public @ResponseBody - AjaxResult findShopSalesmanAppliingList(@RequestBody AddSaleManApplyDto addSaleManApplyDto) { - AjaxResult result= AjaxResult.buildSuccessInstance("设置成功"); + 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); + return AjaxResult.buildSuccessInstance("设置成功"); + } + + /** + *删除---设置成不是分销员 + */ + @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(); + //待审核状态才允许提交 + ShopSalesmanApply shopSalesmanApply = shopSalesmanApplyDao.selectById(examineSaleManApplyDto.getApplyId()); + 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); - shopSalesmanApplyService.addSaleManApply(addSaleManApplyDto.getUserId(),addSaleManApplyDto.getGradeId()); - return result; + + List<ShopSalesmanGradeVo> dataList = shopSalesmanApplyService.getShopSalesmanGradeVo(user.getCompanyId()); + result.putInMap("salesGrade", dataList); + return result; } } -- Gitblit v1.9.1