|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.matrix.biz.bean.BizUser; | 
|---|
|  |  |  | import com.matrix.biz.dao.BizUserDao; | 
|---|
|  |  |  | import com.matrix.biz.service.BizUserService; | 
|---|
|  |  |  | import com.matrix.core.constance.MatrixConstance; | 
|---|
|  |  |  | import com.matrix.core.exception.GlobleException; | 
|---|
|  |  |  | import com.matrix.core.pojo.AjaxResult; | 
|---|
|  |  |  | import com.matrix.core.pojo.VerificationResult; | 
|---|
|  |  |  | 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.dao.BusParameterSettingsDao; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; | 
|---|
|  |  |  | 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 com.matrix.system.hive.service.SysVipInfoService; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.dao.ShopOrderV2Dao; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | 
|---|
|  |  |  | ShopSalesmanGradeDao shopSalesmanGradeDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BizUserDao bizUserDao; | 
|---|
|  |  |  | SysVipInfoDao sysVipInfoDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | BizUserService bizUserService; | 
|---|
|  |  |  | SysVipInfoService sysVipInfoService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | ShopOrderV2Dao shopOrderV2Dao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 申请成为推广员 | 
|---|
|  |  |  | * @param openId | 
|---|
|  |  |  | * @param userId | 
|---|
|  |  |  | * @param invitationId | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public ShopSalesmanApply applyToBeAnSalesman(String openId,String gradeId,String invitationId,int applyWay) { | 
|---|
|  |  |  | public ShopSalesmanApply applyToBeAnSalesman(Long userId,Long gradeId,Long invitationId,int applyWay) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BizUser loginUser=bizUserDao.findByOpenId(openId); | 
|---|
|  |  |  | SysVipInfo loginUser=sysVipInfoDao.selectById(userId); | 
|---|
|  |  |  | //验证申请条件 | 
|---|
|  |  |  | VerificationResult verificationResult = isAbleToBeAnSalesman(openId,loginUser.getCompanyId()); | 
|---|
|  |  |  | VerificationResult verificationResult = isAbleToBeAnSalesman(userId,loginUser.getCompanyId()); | 
|---|
|  |  |  | if(verificationResult.isJudgeResult()){ | 
|---|
|  |  |  | //校验审核状态,和是否重复发起 | 
|---|
|  |  |  | QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.eq("user_id",loginUser.getOpenId()); | 
|---|
|  |  |  | queryWrapper.eq("user_id",loginUser.getId()); | 
|---|
|  |  |  | queryWrapper.in("apply_status",Arrays.asList("1,2".split(","))); | 
|---|
|  |  |  | ShopSalesmanApply checkApply = shopSalesmanApplyDao.selectOne(queryWrapper); | 
|---|
|  |  |  | if(checkApply==null|| | 
|---|
|  |  |  | checkApply.getApplyStatus()==ShopSalesmanApply.APPLY_STATUS_WTG){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShopSalesmanApply shopSalesmanApply=new ShopSalesmanApply(); | 
|---|
|  |  |  | shopSalesmanApply.setUserId(openId); | 
|---|
|  |  |  | shopSalesmanApply.setUserId(userId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | shopSalesmanApply.setCreateBy(MatrixConstance.SYSTEM_USER); | 
|---|
|  |  |  | shopSalesmanApply.setApplyWay(ShopSalesmanApply.APPLY_WAY_SELF); | 
|---|
|  |  |  | 
|---|
|  |  |  | shopSalesmanApply.setCreateTime(date); | 
|---|
|  |  |  | shopSalesmanApply.setUpdateTime(date); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(StringUtils.isNotBlank(invitationId)){ | 
|---|
|  |  |  | if(invitationId!=null){ | 
|---|
|  |  |  | shopSalesmanApply.setParentUserId(invitationId); | 
|---|
|  |  |  | }else if(StringUtils.isNotBlank(loginUser.getParentOpenId())){ | 
|---|
|  |  |  | }else if(loginUser.getRecommendId()!=null){ | 
|---|
|  |  |  | //如果曾经是被邀请进来的则自动绑定为之前邀请人的下级 | 
|---|
|  |  |  | shopSalesmanApply.setParentUserId(loginUser.getParentOpenId()); | 
|---|
|  |  |  | shopSalesmanApply.setParentUserId(loginUser.getRecommendId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(gradeId)){ | 
|---|
|  |  |  | shopSalesmanApply.setGradeId(Long.parseLong(gradeId)); | 
|---|
|  |  |  | if(gradeId!=null){ | 
|---|
|  |  |  | shopSalesmanApply.setGradeId(gradeId); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //获取初始等级ID(公司id,是否为初始等级) | 
|---|
|  |  |  | QueryWrapper<ShopSalesmanGrade> queryWrapperOrepool = new QueryWrapper<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(busParameterSettings!=null | 
|---|
|  |  |  | &&busParameterSettings.getParamValue().equals("1")){ | 
|---|
|  |  |  | //自动审核 | 
|---|
|  |  |  | //初始等级ID(公司id,是否为初始等级) | 
|---|
|  |  |  | QueryWrapper<ShopSalesmanGrade> queryWrapperOrepool = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapperOrepool.eq("company_id", loginUser.getCompanyId()); | 
|---|
|  |  |  | queryWrapperOrepool.eq("is_default", 1); | 
|---|
|  |  |  | ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectOne(queryWrapperOrepool); | 
|---|
|  |  |  | shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_TG); | 
|---|
|  |  |  | bizUserService.setToBeAnSalesman(loginUser.getOpenId(),invitationId); | 
|---|
|  |  |  | sysVipInfoService.setToBeAnSalesman(loginUser.getId(),invitationId,shopSalesmanGrade.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_DSH); | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 判断是否满足申请成为分销员的条件 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public VerificationResult isAbleToBeAnSalesman(String openId,Long companyId) { | 
|---|
|  |  |  | public VerificationResult isAbleToBeAnSalesman(Long userId,Long companyId) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | VerificationResult verificationResult=null; | 
|---|
|  |  |  | //申请条件 | 
|---|
|  |  |  | BusParameterSettings applyCondition = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_APPLY_CONDITION, companyId); | 
|---|
|  |  |  | switch (applyCondition.getParamValue()){ | 
|---|
|  |  |  | case FenxiaoSettingConstant.FX_APPLY_CONDITION_WTJ: | 
|---|
|  |  |  | VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case FenxiaoSettingConstant.FX_APPLY_CONDITION_XFZDCP: | 
|---|
|  |  |  | VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | int buyZdcpCount= shopOrderV2Dao.countBuyZdcp(openId,applyCondition.getParamValue1()); | 
|---|
|  |  |  | if(buyZdcpCount>0){ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费指定产品后再申请!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case FenxiaoSettingConstant.FX_APPLY_CONDITION_XFRYCP: | 
|---|
|  |  |  | //判断用户是否有确认收货的产品 | 
|---|
|  |  |  | int receivedOrderCount= shopOrderV2Dao.selectReceivedOrderCount(openId); | 
|---|
|  |  |  | if(receivedOrderCount>0){ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费任意产品后再申请!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case FenxiaoSettingConstant.FX_APPLY_CONDITION_XCZDJE: | 
|---|
|  |  |  | Double zdje=Double.parseDouble(applyCondition.getParamValue2()); | 
|---|
|  |  |  | Double yxfje=shopOrderV2Dao.countOrderAmount(openId); | 
|---|
|  |  |  | if(zdje<yxfje){ | 
|---|
|  |  |  | verificationResult=VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费满"+zdje+"元后再申请!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //申请模式 | 
|---|
|  |  |  | BusParameterSettings applyWay = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_APPLY_WAY, companyId); | 
|---|
|  |  |  | if (FenxiaoSettingConstant.FX_APPLY_WAY_AUTO.equals(applyWay.getParamValue())) { | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //申请条件 | 
|---|
|  |  |  | BusParameterSettings applyCondition = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_APPLY_CONDITION, companyId); | 
|---|
|  |  |  | switch (applyCondition.getParamValue()){ | 
|---|
|  |  |  | case FenxiaoSettingConstant.FX_APPLY_CONDITION_WTJ: | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case FenxiaoSettingConstant.FX_APPLY_CONDITION_XFZDCP: | 
|---|
|  |  |  | int buyZdcpCount= shopOrderV2Dao.countBuyZdcp(userId,applyCondition.getParamValue1()); | 
|---|
|  |  |  | if(buyZdcpCount>0){ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费指定产品后再申请!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case FenxiaoSettingConstant.FX_APPLY_CONDITION_XFRYCP: | 
|---|
|  |  |  | //判断用户是否有确认收货的产品 | 
|---|
|  |  |  | int receivedOrderCount= shopOrderV2Dao.selectReceivedOrderCount(userId); | 
|---|
|  |  |  | if(receivedOrderCount>0){ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费任意产品后再申请!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case FenxiaoSettingConstant.FX_APPLY_CONDITION_XCZDJE: | 
|---|
|  |  |  | Double zdje=Double.parseDouble(applyCondition.getParamValue2()); | 
|---|
|  |  |  | Double yxfje=shopOrderV2Dao.countOrderAmount(userId); | 
|---|
|  |  |  | if(zdje<yxfje){ | 
|---|
|  |  |  | verificationResult=VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费满"+zdje+"元后再申请!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | verificationResult= VerificationResult.buildVerificationResult(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return verificationResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public void addSaleManApply(String userId,String gradeId) { | 
|---|
|  |  |  | BizUser user = bizUserDao.findByOpenId(userId); | 
|---|
|  |  |  | applyToBeAnSalesman(user.getOpenId(),gradeId, "",ShopSalesmanApply.APPLY_WAY_HAND_ADD); | 
|---|
|  |  |  | public void addSaleManApply(Long userId,Long gradeId) { | 
|---|
|  |  |  | SysVipInfo user = sysVipInfoDao.selectById(userId); | 
|---|
|  |  |  | applyToBeAnSalesman(user.getId(),gradeId, null,ShopSalesmanApply.APPLY_WAY_HAND_ADD); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public void examineSaleManApply(ShopSalesmanApply shopSalesmanApply, Integer applyState) { | 
|---|
|  |  |  | String userId = shopSalesmanApply.getUserId(); | 
|---|
|  |  |  | String parentUserId = shopSalesmanApply.getParentUserId(); | 
|---|
|  |  |  | BizUser bizUser = bizUserDao.findByOpenId(userId); | 
|---|
|  |  |  | Long userId = shopSalesmanApply.getUserId(); | 
|---|
|  |  |  | Long parentUserId = shopSalesmanApply.getParentUserId(); | 
|---|
|  |  |  | SysVipInfo sysVipInfo = sysVipInfoDao.selectById(userId); | 
|---|
|  |  |  | //修改审核记录 | 
|---|
|  |  |  | if(ShopSalesmanApply.APPLY_STATUS_TG == applyState) { | 
|---|
|  |  |  | shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_TG); | 
|---|
|  |  |  | bizUser.setIsSales(BizUser.IS_SALES); | 
|---|
|  |  |  | sysVipInfo.setIsSales(SysVipInfo.IS_SALES); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_WTG); | 
|---|
|  |  |  | bizUser.setIsSales(BizUser.NOT_SALES); | 
|---|
|  |  |  | sysVipInfo.setIsSales(SysVipInfo.NOT_SALES); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | shopSalesmanApplyDao.updateById(shopSalesmanApply); | 
|---|
|  |  |  | //修改USER的状态 | 
|---|
|  |  |  | bizUser.setParentOpenId(parentUserId); | 
|---|
|  |  |  | bizUser.setBindingParentTime(new Date()); | 
|---|
|  |  |  | bizUserDao.updateByModel(bizUser); | 
|---|
|  |  |  | sysVipInfo.setRecommendId(parentUserId); | 
|---|
|  |  |  | sysVipInfo.setBindingParentTime(new Date()); | 
|---|
|  |  |  | sysVipInfo.setSalesmanGrade(shopSalesmanApply.getGradeId()); | 
|---|
|  |  |  | sysVipInfoDao.update(sysVipInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public IPage<ShopSalesmanApplyVo> findShopSalesmanDetail(Page<ShopSalesmanApplyVo> page, | 
|---|
|  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public SalesmanBasicDetailVo selectShopSalesmanDetailByOpenId(String userId, long applyId) { | 
|---|
|  |  |  | public SalesmanBasicDetailVo selectShopSalesmanDetailByOpenId(Long userId, long applyId) { | 
|---|
|  |  |  | //获取个人信息 | 
|---|
|  |  |  | BizUser bizUser = bizUserDao.findByOpenId(userId); | 
|---|
|  |  |  | Long companyId = bizUser.getCompanyId(); | 
|---|
|  |  |  | return shopSalesmanApplyDao.selectShopSalesmanDetailByOpenId(userId,companyId,applyId); | 
|---|
|  |  |  | SysVipInfo sysVipInfo = sysVipInfoDao.selectById(userId); | 
|---|
|  |  |  | Long companyId = sysVipInfo.getCompanyId(); | 
|---|
|  |  |  | return shopSalesmanApplyDao.selectShopSalesmanDetailByOpenId(sysVipInfo.getId(),companyId,applyId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public IPage<ShopCustomDetailVo> findCustomDetail(Page<ShopCustomDetailVo> page,LoadParamSettingDto loadParamSettingDto) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public AjaxResult changeSaleManGrade(ChangeSaleManGradeDto changeSaleManGradeDto) { | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(changeSaleManGradeDto); | 
|---|
|  |  |  | String userId = changeSaleManGradeDto.getUserId(); | 
|---|
|  |  |  | Long companyId = changeSaleManGradeDto.getCompanyId(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SysVipInfo vipInfo = sysVipInfoDao.selectById(changeSaleManGradeDto.getUserId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取对应的公司的等级 | 
|---|
|  |  |  | QueryWrapper<ShopSalesmanGrade> queryWrapperOrepool = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapperOrepool.eq("is_default", 1); | 
|---|
|  |  |  | queryWrapperOrepool.eq("company_id", companyId); | 
|---|
|  |  |  | queryWrapperOrepool.eq("company_id", vipInfo.getCompanyId()); | 
|---|
|  |  |  | ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectOne(queryWrapperOrepool); | 
|---|
|  |  |  | //修改Biz_User的salesman_grade | 
|---|
|  |  |  | BizUser findByOpenId = bizUserDao.findByOpenId(userId); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(findByOpenId)) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("当前用户已不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //不是分销员不允许修改 | 
|---|
|  |  |  | Integer isSales = findByOpenId.getIsSales(); | 
|---|
|  |  |  | if(BizUser.IS_SALES != isSales) { | 
|---|
|  |  |  | Integer isSales = vipInfo.getIsSales(); | 
|---|
|  |  |  | if(SysVipInfo.IS_SALES != isSales) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("当前用户未通过审核,不允许修改"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //修改申请记录的等级 | 
|---|
|  |  |  | QueryWrapper<ShopSalesmanApply> queryShopSalesmanApply = new QueryWrapper<>(); | 
|---|
|  |  |  | queryShopSalesmanApply.eq("apply_status", 2); | 
|---|
|  |  |  | queryShopSalesmanApply.eq("user_id", userId); | 
|---|
|  |  |  | queryShopSalesmanApply.eq("company_id", companyId); | 
|---|
|  |  |  | queryShopSalesmanApply.eq("user_id", vipInfo.getId()); | 
|---|
|  |  |  | queryShopSalesmanApply.eq("company_id", vipInfo.getCompanyId()); | 
|---|
|  |  |  | ShopSalesmanApply shopSalesmanApply = shopSalesmanApplyDao.selectOne(queryShopSalesmanApply); | 
|---|
|  |  |  | Long gradeId = changeSaleManGradeDto.getGradeId(); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(gradeId)) { | 
|---|
|  |  |  | findByOpenId.setSalesmanGrade(shopSalesmanGrade.getId()); | 
|---|
|  |  |  | vipInfo.setSalesmanGrade(shopSalesmanGrade.getId()); | 
|---|
|  |  |  | shopSalesmanApply.setGradeId(shopSalesmanGrade.getId()); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | findByOpenId.setSalesmanGrade(gradeId); | 
|---|
|  |  |  | vipInfo.setSalesmanGrade(gradeId); | 
|---|
|  |  |  | shopSalesmanApply.setGradeId(gradeId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bizUserDao.updateByModel(findByOpenId); | 
|---|
|  |  |  | sysVipInfoDao.update(vipInfo); | 
|---|
|  |  |  | shopSalesmanApplyDao.updateById(shopSalesmanApply); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance("修改等级成功"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public AjaxResult unbundlingSaleMan(UnbundlingSaleManDto unbundlingSaleManDto) { | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(unbundlingSaleManDto); | 
|---|
|  |  |  | String userId = unbundlingSaleManDto.getUserId(); | 
|---|
|  |  |  | //将Biz_User的parent_open_id置空 | 
|---|
|  |  |  | BizUser findByOpenId = bizUserDao.findByOpenId(userId); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(findByOpenId)) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("当前用户已不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | findByOpenId.setParentOpenId(""); | 
|---|
|  |  |  | bizUserDao.updateByModel(findByOpenId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Long userId = unbundlingSaleManDto.getUserId(); | 
|---|
|  |  |  | sysVipInfoDao.unbundlingSaleMan(userId); | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance("解绑成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public AjaxResult delSaleManGradeApply(DelSaleManGradeApplyDto delSaleManGradeApplyDto) { | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(delSaleManGradeApplyDto); | 
|---|
|  |  |  | String userId = delSaleManGradeApplyDto.getUserId(); | 
|---|
|  |  |  | Long applyid = delSaleManGradeApplyDto.getApplyId(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //将biz_user的is_sale设置成否 | 
|---|
|  |  |  | BizUser findByOpenId = bizUserDao.findByOpenId(userId); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(findByOpenId)) { | 
|---|
|  |  |  | SysVipInfo vipInfo = sysVipInfoDao.selectById(delSaleManGradeApplyDto.getUserId()); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(vipInfo)) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("当前用户已不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | findByOpenId.setIsSales(BizUser.NOT_SALES); | 
|---|
|  |  |  | bizUserDao.updateByModel(findByOpenId); | 
|---|
|  |  |  | vipInfo.setIsSales(SysVipInfo.NOT_SALES); | 
|---|
|  |  |  | sysVipInfoDao.update(vipInfo); | 
|---|
|  |  |  | //将记录设置成系统取消 | 
|---|
|  |  |  | ShopSalesmanApply selectById = shopSalesmanApplyDao.selectById(applyid); | 
|---|
|  |  |  | ShopSalesmanApply selectById = shopSalesmanApplyDao.selectById(delSaleManGradeApplyDto.getApplyId()); | 
|---|
|  |  |  | selectById.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_XTQX); | 
|---|
|  |  |  | shopSalesmanApplyDao.updateById(selectById); | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance("操作成功"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public AjaxResult updateFyfa(UpdateFyfaDto updateFyfaDto) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(updateFyfaDto); | 
|---|
|  |  |  | ShopSalesmanGrade selectById = shopSalesmanGradeDao.selectById(updateFyfaDto.getId()); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(selectById)) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("当前行数据不存在,请刷新页面"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String name = updateFyfaDto.getName(); | 
|---|
|  |  |  | if(StrUtil.isEmpty(name)) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("请输入方案名称"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Double selfCommission = updateFyfaDto.getSelfCommission(); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(selfCommission)) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("请输入正确的自购返佣"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Double sealesCommission = updateFyfaDto.getSealesCommission(); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(sealesCommission)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(invitationCommission)) { | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("请输入正确的邀请提成"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //设置用户公司ID | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(updateFyfaDto); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(selectById)) { | 
|---|
|  |  |  | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|---|
|  |  |  | ShopSalesmanGrade shopSalesmanGrade = new ShopSalesmanGrade(); | 
|---|
|  |  |  | shopSalesmanGrade.setCompanyId(updateFyfaDto.getCompanyId()); | 
|---|
|  |  |  | shopSalesmanGrade.setName(updateFyfaDto.getName()); | 
|---|
|  |  |  | shopSalesmanGrade.setSelfCommission(selfCommission); | 
|---|
|  |  |  | shopSalesmanGrade.setSealesCommission(sealesCommission); | 
|---|
|  |  |  | shopSalesmanGrade.setInvitationCommission(invitationCommission); | 
|---|
|  |  |  | shopSalesmanGrade.setGradeCondition(updateFyfaDto.getGradeCondition()); | 
|---|
|  |  |  | shopSalesmanGrade.setIsDefault(2); | 
|---|
|  |  |  | shopSalesmanGrade.setCreateBy(user.getSuName()); | 
|---|
|  |  |  | shopSalesmanGrade.setUpdateBy(user.getSuName()); | 
|---|
|  |  |  | shopSalesmanGrade.setCreateTime(new Date()); | 
|---|
|  |  |  | shopSalesmanGrade.setUpdateTime(new Date()); | 
|---|
|  |  |  | shopSalesmanGrade.setCompanyId(user.getCompanyId()); | 
|---|
|  |  |  | shopSalesmanGradeDao.insert(shopSalesmanGrade); | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance("操作成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | selectById.setCompanyId(updateFyfaDto.getCompanyId()); | 
|---|
|  |  |  | selectById.setName(updateFyfaDto.getName()); | 
|---|
|  |  |  | selectById.setSelfCommission(selfCommission); | 
|---|
|  |  |  | selectById.setSealesCommission(sealesCommission); | 
|---|
|  |  |  | selectById.setInvitationCommission(invitationCommission); | 
|---|
|  |  |  | selectById.setGradeCondition(updateFyfaDto.getGradeCondition()); | 
|---|