jyy
2021-03-17 f86c8e49cf1f953843d5b436469d298fb69f3629
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java
@@ -1,5 +1,6 @@
package com.matrix.system.shopXcx.api.action;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.matrix.biz.bean.BizUser;
import com.matrix.biz.service.BizUserService;
import com.matrix.component.redis.RedisUserLoginUtils;
@@ -9,8 +10,14 @@
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.web.BaseAction;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.constance.AppConstance;
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.entity.ShopSalesmanApply;
import com.matrix.system.fenxiao.service.ShopSalesmanApplyService;
import com.matrix.system.shopXcx.api.WeChatApiTools;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,8 +32,8 @@
import java.util.Date;
/**
 * @description (用户表)
 * @author jyy
 * @description (用户表)
 * @date 2019-05-31 10:03
 */
@Controller
@@ -36,14 +43,18 @@
   @Autowired
   private BizUserService bizUserService;
    @Autowired
    private ShopSalesmanApplyService shopSalesmanApplyService;
   @Autowired
    BusParameterSettingsDao busParameterSettingsDao;
    @Autowired
   private RedisUserLoginUtils redisUserLoginUtils;
    @Autowired
    ShopSalesmanApplyDao salesmanApplyDao;
   @Autowired
   WeChatApiTools weChatApiTools;
   @Autowired
@@ -55,12 +66,12 @@
   /**
    * 小程序登录
    * 
    * @author JIANGYOUYAO
    * @email 935090232@qq.com
    * @date 2018年5月23日
    * @param code
    * @return
    * @throws Exception
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date 2018年5月23日
    */
   @RequestMapping(value = "/login/{keys}")
   public @ResponseBody
@@ -146,13 +157,29 @@
      // TODO 赋值操作
      int i = bizUserService.saveUserInfo(bizUser);
        //查询是否需要自动成为分销员
        if ((loginUser.getIsSales() == null || loginUser.getIsSales() == 2)
                && StringUtils.isNotBlank(loginUser.getNickName())) {//目前还不是分销员
            BusParameterSettings fxSwith = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_SWITCH, HostInterceptor.getCompanyId());
            if (fxSwith.getParamValue().equals("1")) {//开启分销
                BusParameterSettings applyCondition = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_APPLY_CONDITION, loginUser.getCompanyId());
                if (applyCondition.getParamValue().equals(FenxiaoSettingConstant.FX_APPLY_CONDITION_WTJ)) {//无条件可称为分销员
                    QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>();
                    queryWrapper.eq("user_id", loginUser.getOpenId());
                    queryWrapper.eq("apply_status", ShopSalesmanApply.APPLY_STATUS_DSH);
                    ShopSalesmanApply shopSalesmanApply = salesmanApplyDao.selectOne(queryWrapper);
                    if (shopSalesmanApply == null) {//没有待审核记录
                        shopSalesmanApplyService.applyToBeAnSalesman(loginUser.getOpenId(), null, null, 2);
                    }
                }
            }
        }
      if (i == 0) {
         return new AjaxResult(AjaxResult.STATUS_FAIL, "更新失败");
      }
      return new AjaxResult(AjaxResult.STATUS_SUCCESS, Collections.singletonList(bizUser));
   }
}