| | |
| | | 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.shopXcx.dao.ShopOrderDaoV2; |
| | | import com.matrix.system.shopXcx.dao.ShopOrderV2Dao; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | BizUserService bizUserService; |
| | | |
| | | @Autowired |
| | | ShopOrderDaoV2 shopOrderDaoV2; |
| | | ShopOrderV2Dao shopOrderV2Dao; |
| | | |
| | | /** |
| | | * 申请成为推广员 |
| | |
| | | public ShopSalesmanApply applyToBeAnSalesman(String openId,String gradeId,String invitationId,int applyWay) { |
| | | |
| | | BizUser loginUser=bizUserDao.findByOpenId(openId); |
| | | //校验审核状态,和是否重复发起 |
| | | QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("user_id",loginUser.getOpenId()); |
| | | queryWrapper.in("apply_status",Arrays.asList("1,2".split(","))); |
| | | ShopSalesmanApply checkApply = shopSalesmanApplyDao.selectOne(queryWrapper); |
| | | if(checkApply==null|| |
| | | checkApply.getApplyStatus()==ShopSalesmanApply.APPLY_STATUS_WTG){ |
| | | //验证申请条件 |
| | | VerificationResult verificationResult = isAbleToBeAnSalesman(openId,loginUser.getCompanyId()); |
| | | if(verificationResult.isJudgeResult()){ |
| | | //校验审核状态,和是否重复发起 |
| | | QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("user_id",loginUser.getOpenId()); |
| | | 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.setCreateBy(MatrixConstance.SYSTEM_USER); |
| | | shopSalesmanApply.setApplyWay(ShopSalesmanApply.APPLY_WAY_SELF); |
| | | ShopSalesmanApply shopSalesmanApply=new ShopSalesmanApply(); |
| | | shopSalesmanApply.setUserId(openId); |
| | | |
| | | shopSalesmanApply.setCompanyId(loginUser.getCompanyId()); |
| | | shopSalesmanApply.setUpdateBy(MatrixConstance.SYSTEM_USER); |
| | | Date date = new Date(); |
| | | shopSalesmanApply.setCreateTime(date); |
| | | shopSalesmanApply.setUpdateTime(date); |
| | | shopSalesmanApply.setCreateBy(MatrixConstance.SYSTEM_USER); |
| | | shopSalesmanApply.setApplyWay(ShopSalesmanApply.APPLY_WAY_SELF); |
| | | |
| | | if(StringUtils.isNotBlank(invitationId)){ |
| | | shopSalesmanApply.setParentUserId(invitationId); |
| | | }else if(StringUtils.isNotBlank(loginUser.getParentOpenId())){ |
| | | //如果曾经是被邀请进来的则自动绑定为之前邀请人的下级 |
| | | shopSalesmanApply.setParentUserId(loginUser.getParentOpenId()); |
| | | } |
| | | if(StringUtils.isNotBlank(gradeId)){ |
| | | shopSalesmanApply.setGradeId(Long.parseLong(gradeId)); |
| | | shopSalesmanApply.setCompanyId(loginUser.getCompanyId()); |
| | | shopSalesmanApply.setUpdateBy(MatrixConstance.SYSTEM_USER); |
| | | Date date = new Date(); |
| | | shopSalesmanApply.setCreateTime(date); |
| | | shopSalesmanApply.setUpdateTime(date); |
| | | |
| | | if(StringUtils.isNotBlank(invitationId)){ |
| | | shopSalesmanApply.setParentUserId(invitationId); |
| | | }else if(StringUtils.isNotBlank(loginUser.getParentOpenId())){ |
| | | //如果曾经是被邀请进来的则自动绑定为之前邀请人的下级 |
| | | shopSalesmanApply.setParentUserId(loginUser.getParentOpenId()); |
| | | } |
| | | if(StringUtils.isNotBlank(gradeId)){ |
| | | shopSalesmanApply.setGradeId(Long.parseLong(gradeId)); |
| | | }else{ |
| | | //获取初始等级ID(公司id,是否为初始等级) |
| | | QueryWrapper<ShopSalesmanGrade> queryWrapperOrepool = new QueryWrapper<>(); |
| | | queryWrapperOrepool.eq("company_id", loginUser.getCompanyId()); |
| | | queryWrapperOrepool.eq("is_default", 1); |
| | | ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectOne(queryWrapperOrepool); |
| | | shopSalesmanApply.setGradeId(shopSalesmanGrade.getId()); |
| | | } |
| | | shopSalesmanApply.setApplyWay(applyWay); |
| | | |
| | | BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_AUDIT_METHOD, loginUser.getCompanyId()); |
| | | if(busParameterSettings!=null |
| | | &&busParameterSettings.getParamValue().equals("1")){ |
| | | //自动审核 |
| | | shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_TG); |
| | | bizUserService.setToBeAnSalesman(loginUser.getOpenId(),invitationId); |
| | | |
| | | }else{ |
| | | shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_DSH); |
| | | } |
| | | shopSalesmanApplyDao.insert(shopSalesmanApply); |
| | | return shopSalesmanApply; |
| | | }else{ |
| | | //获取初始等级ID(公司id,是否为初始等级) |
| | | QueryWrapper<ShopSalesmanGrade> queryWrapperOrepool = new QueryWrapper<>(); |
| | | queryWrapperOrepool.eq("company_id", loginUser.getCompanyId()); |
| | | queryWrapperOrepool.eq("is_default", 1); |
| | | ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectOne(queryWrapperOrepool); |
| | | shopSalesmanApply.setGradeId(shopSalesmanGrade.getId()); |
| | | throw new GlobleException("不能重复申请"); |
| | | } |
| | | shopSalesmanApply.setApplyWay(applyWay); |
| | | |
| | | BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_AUDIT_METHOD, loginUser.getCompanyId()); |
| | | if(busParameterSettings!=null |
| | | &&busParameterSettings.getParamValue().equals("1")){ |
| | | //自动审核 |
| | | shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_TG); |
| | | bizUserService.setToBeAnSalesman(loginUser.getOpenId(),invitationId); |
| | | |
| | | }else{ |
| | | shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_DSH); |
| | | } |
| | | shopSalesmanApplyDao.insert(shopSalesmanApply); |
| | | return shopSalesmanApply; |
| | | }else{ |
| | | throw new GlobleException("不能重复申请"); |
| | | throw new GlobleException(verificationResult.getMsg()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断是否满足申请成为分销员的条件 |
| | | */ |
| | | public VerificationResult isAbleToBeAnSalesman(String openId) { |
| | | BizUser bizUser = bizUserDao.findByOpenId(openId); |
| | | public VerificationResult isAbleToBeAnSalesman(String openId,Long companyId) { |
| | | |
| | | VerificationResult verificationResult=null; |
| | | //申请条件 |
| | | BusParameterSettings applyCondition = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_APPLY_CONDITION, bizUser.getCompanyId()); |
| | | BusParameterSettings applyCondition = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_APPLY_CONDITION, companyId); |
| | | switch (applyCondition.getParamValue()){ |
| | | case FenxiaoSettingConstant.FX_APPLY_CONDITION_WTJ: |
| | | VerificationResult.buildVerificationResult(true); |
| | | verificationResult= 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= shopOrderDaoV2.selectReceivedOrderCount(openId); |
| | | |
| | | int receivedOrderCount= shopOrderV2Dao.selectReceivedOrderCount(openId); |
| | | if(receivedOrderCount>0){ |
| | | verificationResult= VerificationResult.buildVerificationResult(true); |
| | | }else{ |
| | | verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费任意产品后再申请!"); |
| | | } |
| | | |
| | | break; |
| | | case FenxiaoSettingConstant.FX_APPLY_CONDITION_XCZDJE: |
| | | VerificationResult.buildVerificationResult(true); |
| | | Double zdje=Double.parseDouble(applyCondition.getParamValue2()); |
| | | Double yxfje=shopOrderV2Dao.countOrderAmount(openId); |
| | | if(zdje<yxfje){ |
| | | verificationResult=VerificationResult.buildVerificationResult(true); |
| | | }else{ |
| | | verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费满"+zdje+"元后再申请!"); |
| | | } |
| | | break; |
| | | default: |
| | | VerificationResult.buildVerificationResult(true); |
| | | verificationResult= VerificationResult.buildVerificationResult(true); |
| | | |
| | | } |
| | | return verificationResult; |
| | | } |
| | |
| | | return shopSalesmanApplyDao.selectShopSalesmanDetailByOpenId(userId,companyId,applyId); |
| | | } |
| | | |
| | | public IPage<ShopCustomDetailVo> findCustomDetail(Page<ShopCustomDetailVo> page, |
| | | ShopSalesmanDetailDto shopSalesmanDetailDto) { |
| | | return shopSalesmanApplyDao.findCustomDetail(page,shopSalesmanDetailDto); |
| | | public IPage<ShopCustomDetailVo> findCustomDetail(Page<ShopCustomDetailVo> page,LoadParamSettingDto loadParamSettingDto) { |
| | | return shopSalesmanApplyDao.findCustomDetail(page,loadParamSettingDto); |
| | | } |
| | | |
| | | public IPage<ShopCustomDetailVo> findCustomLow(Page<ShopCustomDetailVo> pageLow, |
| | |
| | | bizUserDao.updateByModel(findByOpenId); |
| | | shopSalesmanApplyDao.updateById(shopSalesmanApply); |
| | | |
| | | return AjaxResult.buildFailInstance("修改等级成功"); |
| | | return AjaxResult.buildSuccessInstance("修改等级成功"); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | } |
| | | findByOpenId.setParentOpenId(""); |
| | | bizUserDao.updateByModel(findByOpenId); |
| | | return AjaxResult.buildFailInstance("解绑成功"); |
| | | return AjaxResult.buildSuccessInstance("解绑成功"); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | ShopSalesmanApply selectById = shopSalesmanApplyDao.selectById(applyid); |
| | | selectById.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_XTQX); |
| | | shopSalesmanApplyDao.updateById(selectById); |
| | | return AjaxResult.buildFailInstance("操作成功"); |
| | | return AjaxResult.buildSuccessInstance("操作成功"); |
| | | } |
| | | |
| | | public IPage<FyfaManageVo> findFyfaManageList(Page<FyfaManageVo> page, FyfaManageDto fyfaManageDto) { |
| | |
| | | return AjaxResult.buildFailInstance("当前行数据不存在,请刷新页面"); |
| | | } |
| | | shopSalesmanGradeDao.deleteById(gradeId); |
| | | return AjaxResult.buildFailInstance("操作成功"); |
| | | return AjaxResult.buildSuccessInstance("操作成功"); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | selectById.setInvitationCommission(invitationCommission); |
| | | selectById.setGradeCondition(updateFyfaDto.getGradeCondition()); |
| | | shopSalesmanGradeDao.updateById(selectById); |
| | | return AjaxResult.buildFailInstance("操作成功"); |
| | | return AjaxResult.buildSuccessInstance("操作成功"); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_PLAN, companyId); |
| | | busParameterSettings.setParamValue3(updateTgjhDto.getTgfa()); |
| | | busParameterSettingsDao.updateByModel(busParameterSettings); |
| | | return AjaxResult.buildFailInstance("保存成功"); |
| | | return AjaxResult.buildSuccessInstance("保存成功"); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_POSTER, companyId); |
| | | busParameterSettings.setParamValue(updateTgtpDto.getImageUrl()); |
| | | busParameterSettingsDao.updateByModel(busParameterSettings); |
| | | return AjaxResult.buildFailInstance("保存成功"); |
| | | return AjaxResult.buildSuccessInstance("保存成功"); |
| | | } |
| | | |
| | | |