|
@@ -0,0 +1,61 @@
|
|
|
+package com.caimei365.user.service.impl;
|
|
|
+
|
|
|
+import com.caimei365.user.components.RedisService;
|
|
|
+import com.caimei365.user.mapper.SellerMapper;
|
|
|
+import com.caimei365.user.model.ResponseJson;
|
|
|
+import com.caimei365.user.model.vo.UserLoginVo;
|
|
|
+import com.caimei365.user.service.SellerService;
|
|
|
+import com.caimei365.user.utils.JwtUtil;
|
|
|
+import com.caimei365.user.utils.Md5Util;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Description
|
|
|
+ *
|
|
|
+ * @author : Charles
|
|
|
+ * @date : 2021/3/24
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class SellerServiceImpl implements SellerService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RedisService redisService;
|
|
|
+ @Resource
|
|
|
+ private SellerMapper sellerMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 协销登录(手机号,密码)
|
|
|
+ *
|
|
|
+ * @param mobile 手机号
|
|
|
+ * @param password 密码
|
|
|
+ * @param unionId 微信unionId
|
|
|
+ * @return UserLoginVo
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<UserLoginVo> passwordLogin(String mobile, String password, String unionId) {
|
|
|
+ if (StringUtils.isBlank(mobile) || StringUtils.isBlank(password)) {
|
|
|
+ return ResponseJson.error("请输入账号密码", null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(unionId)) {
|
|
|
+ return ResponseJson.error("请输入微信unionId", null);
|
|
|
+ }
|
|
|
+ UserLoginVo seller = sellerMapper.getLoginSellerByMobile(mobile);
|
|
|
+ if (null == seller || !Md5Util.md5(password).equals(seller.getPassword())) {
|
|
|
+ return ResponseJson.error("密码和账户名不匹配" ,null);
|
|
|
+ }
|
|
|
+ String token = JwtUtil.createToken(seller.getUserId());
|
|
|
+ seller.setToken(token);
|
|
|
+ Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
|
|
|
+ String openId = (String) infoData.get("openId");
|
|
|
+ sellerMapper.updateServiceProviderByUserId(seller.getUserId(), openId, unionId);
|
|
|
+ log.info("协销账号密码登录openid>>>>" + openId + " ,unionId>>>>>" + unionId);
|
|
|
+ return ResponseJson.success(seller);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|