935090232@qq.com
2021-03-12 c1bcebc75e3a057ffe21c1c6e580e1f2cf1fbf79
zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java
@@ -1,6 +1,5 @@
package com.matrix.system.fenxiao.service;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -13,7 +12,6 @@
import com.matrix.core.tools.StringUtils;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant;
import com.matrix.system.fenxiao.dao.ShopSalesmanApplyDao;
import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao;
@@ -26,6 +24,7 @@
import com.matrix.system.fenxiao.vo.ShopSalesmanGradeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@@ -43,7 +42,7 @@
    BusParameterSettingsDao busParameterSettingsDao;
    @Autowired
    ShopSalesmanApplyDao salesmanApplyDao;
    ShopSalesmanApplyDao shopSalesmanApplyDao;
    
    @Autowired
    ShopSalesmanGradeDao shopSalesmanGradeDao;
@@ -60,13 +59,13 @@
     * @param invitationId
     * @return
     */
    public ShopSalesmanApply applyToBeAnSalesman(String openId,String gradeId,String invitationId) {
    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());
        ShopSalesmanApply checkApply = salesmanApplyDao.selectOne(queryWrapper);
        ShopSalesmanApply checkApply = shopSalesmanApplyDao.selectOne(queryWrapper);
        if(checkApply==null||
                checkApply.getApplyStatus()==ShopSalesmanApply.APPLY_STATUS_WTG){
@@ -98,8 +97,9 @@
                ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectOne(queryWrapperOrepool);
               shopSalesmanApply.setGradeId(shopSalesmanGrade.getId());
            }
            BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_AUDIT_METHOD, HostInterceptor.getCompanyId());
            shopSalesmanApply.setApplyWay(applyWay);
            BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_AUDIT_METHOD, loginUser.getCompanyId());
            if(busParameterSettings!=null
                    &&busParameterSettings.getParamValue().equals("1")){
                //自动审核
@@ -109,7 +109,7 @@
            }else{
                shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_DSH);
            }
            salesmanApplyDao.insert(shopSalesmanApply);
            shopSalesmanApplyDao.insert(shopSalesmanApply);
            return  shopSalesmanApply;
        }else{
            throw  new GlobleException("不能重复申请");
@@ -118,29 +118,49 @@
    }
    public IPage<ShopSalesmanApplyVo> findShopSalesmanApplyList(Page<ShopSalesmanApplyVo> page, ShopSalesmanApplyDto shopSalesmanApplyDto) {
        return salesmanApplyDao.findShopSalesmanApplyList(page,shopSalesmanApplyDto);
        return shopSalesmanApplyDao.findShopSalesmanApplyList(page,shopSalesmanApplyDto);
    }
   public IPage<ShopSalesmanAppliingVo> findShopSalesmanAppliingList(Page<ShopSalesmanAppliingVo> page,
         ShopSalesmanAppliingDto shopSalesmanAppliingDto) {
      return salesmanApplyDao.findShopSalesmanAppliingList(page,shopSalesmanAppliingDto);
      return shopSalesmanApplyDao.findShopSalesmanAppliingList(page,shopSalesmanAppliingDto);
   }
    public IPage<ShopSalesmanAppliingVo> selectBizUserApplyList(Page<ShopSalesmanAppliingVo> page, ShopSalesmanAppliingDto shopSalesmanAppliingDto) {
        return salesmanApplyDao.selectBizUserApplyList(page,shopSalesmanAppliingDto);
        return shopSalesmanApplyDao.selectBizUserApplyList(page,shopSalesmanAppliingDto);
    }
   public List<ShopSalesmanGradeVo> getShopSalesmanGradeVo(Long companyId) {
      return shopSalesmanGradeDao.getShopSalesmanGradeVo(companyId);
   }
   public void addSaleManApply(String userId,long gradeId) {
   @Transactional(rollbackFor = Exception.class)
   public void addSaleManApply(String userId,String gradeId) {
      BizUser user = bizUserDao.selectById(userId);
      applyToBeAnSalesman(user.getOpenId(),gradeId+"", "");
      applyToBeAnSalesman(user.getOpenId(),gradeId, "",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.selectById(userId);
      //修改审核记录
      if(ShopSalesmanApply.APPLY_STATUS_TG == applyState) {
         shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_TG);
         bizUser.setIsSales(BizUser.IS_SALES);
      }else {
         shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_WTG);
         bizUser.setIsSales(BizUser.NOT_SALES);
      }
      shopSalesmanApplyDao.updateById(shopSalesmanApply);
      //修改USER的状态
      bizUser.setParentOpenId(parentUserId);
      bizUser.setBindingParentTime(new Date());
      bizUserDao.updateByModel(bizUser);
   }