From 0bcfecbfb194ab908fc33dee9cae43c7a77b608d Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 17 Mar 2021 14:35:43 +0800
Subject: [PATCH] Merge branch 'score_shop' of http://120.27.238.55:7000/r/beauty-erp into score_shop
---
zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java | 6
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java | 2
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java | 256 +++++++++++++++++++++++++++++---------------------
3 files changed, 151 insertions(+), 113 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java b/zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java
index ab7ec23..e1aca9d 100644
--- a/zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java
+++ b/zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java
@@ -142,10 +142,9 @@
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);
@@ -170,10 +169,9 @@
}else{
verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费满"+zdje+"元后再申请!");
}
- VerificationResult.buildVerificationResult(true);
break;
default:
- VerificationResult.buildVerificationResult(true);
+ verificationResult= VerificationResult.buildVerificationResult(true);
}
return verificationResult;
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
index 90d3e69..f7b2266 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
@@ -301,4 +301,6 @@
+
+
}
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java
index 7a523f3..81a6904 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java
+++ b/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,150 +10,187 @@
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;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
import java.util.Collections;
import java.util.Date;
/**
- * @description (用户表)
* @author jyy
+ * @description (用户表)
* @date 2019-05-31 10:03
*/
@Controller
@RequestMapping(value = "wxapi/user")
public class WxUserAction extends BaseAction {
- @Autowired
- private BizUserService bizUserService;
+ @Autowired
+ private BizUserService bizUserService;
+
+ @Autowired
+ private ShopSalesmanApplyService shopSalesmanApplyService;
+
+ @Autowired
+ BusParameterSettingsDao busParameterSettingsDao;
+ @Autowired
+ private RedisUserLoginUtils redisUserLoginUtils;
+ @Autowired
+ ShopSalesmanApplyDao salesmanApplyDao;
+
+ @Autowired
+ WeChatApiTools weChatApiTools;
- @Autowired
- private RedisUserLoginUtils redisUserLoginUtils;
+ @Autowired
+ private WeixinServiceUtil weixinServiceUtil;
+ @Value("${debug}")
+ private String isDebug;
- @Autowired
- WeChatApiTools weChatApiTools;
-
-
-
- @Autowired
- private WeixinServiceUtil weixinServiceUtil;
-
- @Value("${debug}")
- private String isDebug;
-
- /**
- * 小程序登录
- *
- * @author JIANGYOUYAO
- * @email 935090232@qq.com
- * @date 2018年5月23日
- * @param code
- * @return
- * @throws Exception
- */
- @RequestMapping(value = "/login/{keys}")
- public @ResponseBody
+ /**
+ * 小程序登录
+ *
+ * @param code
+ * @return
+ * @throws Exception
+ * @author JIANGYOUYAO
+ * @email 935090232@qq.com
+ * @date 2018年5月23日
+ */
+ @RequestMapping(value = "/login/{keys}")
+ public @ResponseBody
AjaxResult wxLogin(@PathVariable("keys") String code) throws Exception {
- AjaxResult res = new AjaxResult();
- LogUtil.info("code:{}" + code);
- if (StringUtils.isNotBlank(code)) {
- String requrl = weChatApiTools.getXcxLoginUrl(code, HostInterceptor.getCompanyId());
- String reslutData = HttpCurlUtil.sendGetHttp(requrl, null);
- JSONObject json = JSONObject.fromObject(reslutData);
- LogUtil.debug("微信登录获取到登录信息={}", json);
+ AjaxResult res = new AjaxResult();
+ LogUtil.info("code:{}" + code);
+ if (StringUtils.isNotBlank(code)) {
+ String requrl = weChatApiTools.getXcxLoginUrl(code, HostInterceptor.getCompanyId());
+ String reslutData = HttpCurlUtil.sendGetHttp(requrl, null);
+ JSONObject json = JSONObject.fromObject(reslutData);
+ LogUtil.debug("微信登录获取到登录信息={}", json);
- if(json.containsKey("errcode")){
- res.setStatus(AjaxResult.STATUS_FAIL);
- res.setInfo("自动登录失败");
- LogUtil.debug("微信登录获取到异常信息errcode");
- return res;
- }
+ if (json.containsKey("errcode")) {
+ res.setStatus(AjaxResult.STATUS_FAIL);
+ res.setInfo("自动登录失败");
+ LogUtil.debug("微信登录获取到异常信息errcode");
+ return res;
+ }
- String openId = json.getString("openid");
- String sessionKey = json.getString("session_key");
- LogUtil.debug("openId={},sessionKey={}", openId, sessionKey);
- // 查询用户是否存在
- BizUser bizUser = null;
- synchronized(this){
- bizUser = bizUserService.findByOpenId(openId);
- if (bizUser == null) {
- // 新增用户
- bizUser = new BizUser();
- bizUser.setSessionKey(sessionKey);
- bizUser.setIsSales(BizUser.NOT_SALES);
- bizUser.setOpenId(openId);
- bizUser.setLastLoginTime(new Date());
- bizUser.setUserType(AppConstance.USER_TYPE_CUSTOMER);
- bizUser.setCompanyId(HostInterceptor.getCompanyId());
- bizUserService.add(bizUser);
+ String openId = json.getString("openid");
+ String sessionKey = json.getString("session_key");
+ LogUtil.debug("openId={},sessionKey={}", openId, sessionKey);
+ // 查询用户是否存在
+ BizUser bizUser = null;
+ synchronized (this) {
+ bizUser = bizUserService.findByOpenId(openId);
+ if (bizUser == null) {
+ // 新增用户
+ bizUser = new BizUser();
+ bizUser.setSessionKey(sessionKey);
+ bizUser.setIsSales(BizUser.NOT_SALES);
+ bizUser.setOpenId(openId);
+ bizUser.setLastLoginTime(new Date());
+ bizUser.setUserType(AppConstance.USER_TYPE_CUSTOMER);
+ bizUser.setCompanyId(HostInterceptor.getCompanyId());
+ bizUserService.add(bizUser);
- } else {
- bizUser.setSessionKey(sessionKey);
- bizUser.setLastLoginTime(new Date());
- // 更新用户sessionKey
- bizUserService.modifyByModel(bizUser);
- }
- }
- // 存放redis
- String token = redisUserLoginUtils.saveUserInfo(bizUser);
- LogUtil.info("用户token={}", token);
- res.putInMap("token", token);
- res.putInMap("userInfo", bizUser);
- res.setStatus(AjaxResult.STATUS_SUCCESS);
- } else {
- res.setStatus(AjaxResult.STATUS_FAIL);
- res.setInfo("自动登录失败");
- }
- return res;
- }
+ } else {
+ bizUser.setSessionKey(sessionKey);
+ bizUser.setLastLoginTime(new Date());
+ // 更新用户sessionKey
+ bizUserService.modifyByModel(bizUser);
+ }
+ }
+ // 存放redis
+ String token = redisUserLoginUtils.saveUserInfo(bizUser);
+ LogUtil.info("用户token={}", token);
+ res.putInMap("token", token);
+ res.putInMap("userInfo", bizUser);
+ res.setStatus(AjaxResult.STATUS_SUCCESS);
+ } else {
+ res.setStatus(AjaxResult.STATUS_FAIL);
+ res.setInfo("自动登录失败");
+ }
+ return res;
+ }
- /**
- * 查询用户信息
- */
- @RequestMapping(value = "/findUserInfo")
- public @ResponseBody
+ /**
+ * 查询用户信息
+ */
+ @RequestMapping(value = "/findUserInfo")
+ public @ResponseBody
AjaxResult findUserInfo() {
- BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
- String openId = loginUser.getOpenId();
- BizUser bizUser = bizUserService.findByOpenId(openId);
- AjaxResult res = new AjaxResult();
- res.putInMap("userInfo", bizUser);
- res.setStatus(AjaxResult.STATUS_SUCCESS);
- return res;
- }
+ BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
+ String openId = loginUser.getOpenId();
+ BizUser bizUser = bizUserService.findByOpenId(openId);
+ AjaxResult res = new AjaxResult();
+ res.putInMap("userInfo", bizUser);
+ res.setStatus(AjaxResult.STATUS_SUCCESS);
+ return res;
+ }
+
+ /**
+ * 根据OpenID查询用户信息
+ */
+ @GetMapping(value = "/findUserInfo/{openId}")
+ public @ResponseBody
+ AjaxResult findUserInfo(@PathVariable String openId) {
+ BizUser bizUser = bizUserService.findByOpenId(openId);
+ BizUser bizUserQuery=new BizUser();
+ bizUserQuery.setNickName(bizUser.getNickName());
+ bizUserQuery.setAvatarUrl(bizUser.getAvatarUrl());
+ bizUserQuery.setOpenId(openId);
+ return AjaxResult.buildSuccessInstance(bizUserQuery);
+ }
- /**
- * 接收用户信息
- */
- @RequestMapping(value = "/saveUserInfo")
- public @ResponseBody
+ /**
+ * 接收用户信息
+ */
+ @RequestMapping(value = "/saveUserInfo")
+ public @ResponseBody
AjaxResult saveUserInfo(@RequestBody BizUser bizUser) {
- BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
- bizUser.setUserId(loginUser.getUserId());
- // TODO 赋值操作
- int i = bizUserService.saveUserInfo(bizUser);
-
- if (i == 0) {
- return new AjaxResult(AjaxResult.STATUS_FAIL, "更新失败");
- }
- return new AjaxResult(AjaxResult.STATUS_SUCCESS, Collections.singletonList(bizUser));
- }
+ BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
+ bizUser.setUserId(loginUser.getUserId());
+ // 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));
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1