| | |
| | | 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); |
| | | 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()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | VerificationResult.buildVerificationResult(true); |
| | | 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,"不符合申请条件,请消费指定产品后再申请!"); |
| | | } |
| | | |
| | | 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,"不符合申请条件,请消费任意产品后再申请!"); |
| | | } |
| | | |
| | | 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); |
| | | default: |
| | | VerificationResult.buildVerificationResult(true); |