Kaynağa Gözat

Merge remote-tracking branch 'origin/developer' into developerL

kaick 1 yıl önce
ebeveyn
işleme
085ab7ff0b

+ 45 - 0
src/main/java/com/caimei365/user/components/WeChatService.java

@@ -648,4 +648,49 @@ public class WeChatService {
         return ResponseJson.success(result);
     }
 
+    /**
+     * 获取微信urlscheme 联合丽格
+     *
+     * @param path
+     * @param query
+     * @return
+     */
+    public ResponseJson getOpenLinkMcare(String path, String query, String env) {
+        String token = null;
+        try {
+            String link = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
+            link = link.replace("APPID", mcareAppId);
+            link = link.replace("APPSECRET", mcareAppSecret);
+            String result = RequestUtil.sendGet(link);
+            log.info("微信公众号获取access_token>>>" + result);
+            Map<String, Object> map = JSONObject.parseObject(result, Map.class);
+            token = (String) map.get("access_token");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        String url = "https://api.weixin.qq.com/wxa/generatescheme?access_token=" + token;
+        JSONObject jumpWxa = new JSONObject();
+        jumpWxa.put("path", path);
+        jumpWxa.put("query", query);
+        //正式版为"release",体验版为"trial",开发版为"develop"
+        jumpWxa.put("env_version", env);
+
+        JSONObject reqMap = new JSONObject();
+        reqMap.put("jump_wxa", jumpWxa);
+        String result = "";
+        try {
+            // 发起请求
+            HttpRequest request = HttpUtil.createPost(url);
+            request.contentType("application/json");
+            request.body(reqMap.toJSONString());
+            result = request.execute().body();
+            result = URLDecoder.decode(result, "UTF-8");
+            log.info("微信获取getOpenLink回调报文" + result);
+            result = JSONObject.parseObject(result).getString("openlink");
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return ResponseJson.success(result);
+    }
+
 }

+ 6 - 0
src/main/java/com/caimei365/user/controller/BaseApi.java

@@ -256,6 +256,12 @@ public class BaseApi {
         return weChatService.getOpenLink(path, query, env);
     }
 
+    @ApiOperation("获取微信跳转url  联合丽格")
+    @GetMapping("/wechat/link/mcare")
+    public ResponseJson getWechatLinkMcare(String path, String query, String env) {
+        return weChatService.getOpenLinkMcare(path, query, env);
+    }
+
     @ApiOperation("获取Dict")
     @GetMapping("/getDict")
     public ResponseJson getDict(String type) {

+ 9 - 0
src/main/java/com/caimei365/user/controller/ShopApi.java

@@ -34,6 +34,15 @@ public class ShopApi {
 
     private final ShopService shopService;
 
+    @ApiOperation("供应商快捷登录")
+    @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
+    @GetMapping("/shortcutLogin")
+    public ResponseJson<UserLoginVo> shortcutLogin(Integer userId) {
+        if (null == userId) {
+            return ResponseJson.error(-1, "用户Id不能为空", null);
+        }
+        return shopService.shortcutLogin(userId);
+    }
     /**
      * 根据用户Id查询供应商资料
      * <p>

+ 7 - 0
src/main/java/com/caimei365/user/mapper/LoginMapper.java

@@ -74,6 +74,12 @@ public interface LoginMapper {
      */
     void updateServiceProviderUnionId(@Param("userId") Integer userId, @Param("unionId") String unionId);
 
+    /**
+     * 供应商商品上架平台属性
+     * @param shopId
+     * @return
+     */
+    List<String> getShopProductGroudMall(@Param("shopId") Integer shopId);
     /**
      * 根据userId获取协销
      * @param userId
@@ -171,6 +177,7 @@ public interface LoginMapper {
      */
     void updateLogin(Integer userId);
 
+
     /**
      * 会员机构类型:1医美,2生
      */

+ 7 - 0
src/main/java/com/caimei365/user/mapper/ShopMapper.java

@@ -20,6 +20,13 @@ import java.util.Map;
  */
 @Mapper
 public interface ShopMapper {
+
+    /**
+     * 供应商快捷登录
+     * @param userId
+     * @return
+     */
+    UserLoginVo getShopByUserId(Integer userId);
     /**
      * 根据Id查询供应商
      * @param shopId    供应商Id

+ 5 - 0
src/main/java/com/caimei365/user/model/vo/UserLoginVo.java

@@ -121,6 +121,11 @@ public class UserLoginVo implements Serializable {
      */
     @ApiModelProperty("协销状态: 90:已上线")
     private Integer serviceStatus;
+    /**
+     * 供应商是否可以帮机构下单
+     */
+    @ApiModelProperty("供应商能否帮机构下单")
+    private Boolean shopIsOrder;
     /**
      * 运营人员状态:1未绑定,2已绑定
      */

+ 7 - 0
src/main/java/com/caimei365/user/service/ShopService.java

@@ -19,6 +19,13 @@ import java.util.Map;
  * @date : 2021/3/9
  */
 public interface ShopService {
+
+    /**
+     * 供应商快捷登录
+     * @param userId
+     * @return
+     */
+    ResponseJson<UserLoginVo> shortcutLogin(Integer userId);
     /**
      * 根据用户Id查询供应商资料
      *

+ 16 - 0
src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java

@@ -867,6 +867,22 @@ public class LoginServiceImpl implements LoginService {
             if (92 == loginUser.getShopStatus()) {
                 return ResponseJson.error(-3, "您的企业账号审核未通过", loginUser);
             }
+            // 是否可为机构下单
+            boolean flag = false;
+            // 供应商商品上架平台信息
+            List<String> shopProductList = loginMapper.getShopProductGroudMall(loginUser.getShopId());
+            if (null != shopProductList) {
+                for(String product : shopProductList ) {
+                    if (StringUtils.isNotBlank(product)) {
+                        if (product.contains("4")) {
+                            flag = true;
+                        }
+                    }
+                }
+            } else {
+                flag = false;
+            }
+            loginUser.setShopIsOrder(flag);
         }
         // 会员机构类型:1医美,2生
         if (null != loginUser.getUserIdentity() && loginUser.getUserIdentity() == 2) {

+ 60 - 4
src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java

@@ -2,6 +2,7 @@ package com.caimei365.user.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.caimei365.user.components.RedisService;
 import com.caimei365.user.feign.CommodityFeign;
 import com.caimei365.user.mapper.*;
 import com.caimei365.user.model.ResponseJson;
@@ -12,10 +13,7 @@ import com.caimei365.user.model.dto.ShopUpdateDto;
 import com.caimei365.user.model.po.*;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.ShopService;
-import com.caimei365.user.utils.DateUtil;
-import com.caimei365.user.utils.GenerateUtils;
-import com.caimei365.user.utils.ImageUtils;
-import com.caimei365.user.utils.OssUtil;
+import com.caimei365.user.utils.*;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
@@ -42,12 +40,16 @@ public class ShopServiceImpl implements ShopService {
     @Value("${caimei.wwwDomain}")
     private String wwwDomain;
     @Resource
+    private RedisService redisService;
+    @Resource
     private CommodityFeign commodityFeign;
     @Resource
     private BaseMapper baseMapper;
     @Resource
     private ShopMapper shopMapper;
     @Resource
+    private LoginMapper loginMapper;
+    @Resource
     private ArticleMapper articleMapper;
     @Resource
     private BaikeProductMapper baikeProductMapper;
@@ -57,6 +59,60 @@ public class ShopServiceImpl implements ShopService {
     private String active;
 
 
+    /**
+     * 供应商快捷登录
+     *
+     * @param userId
+     * @return
+     */
+    @Override
+    public ResponseJson<UserLoginVo> shortcutLogin(Integer userId) {
+        UserLoginVo userLoginVo = shopMapper.getShopByUserId(userId);
+        // 生成token给用户
+        String token = JwtUtil.createToken(userId);
+        // 为了过期续签,将token存入redis,并设置超时时间
+        redisService.set(token, token, JwtUtil.getExpireTime());
+        userLoginVo.setToken(token);
+        if (null != userLoginVo) {
+            if (null != userLoginVo.getShopId()) {
+                if (null != userLoginVo.getShopStatus() && null != userLoginVo.getUserIdentity() && 3 == userLoginVo.getUserIdentity()) {
+
+                    if (3 == userLoginVo.getShopStatus()) {
+                        return ResponseJson.error(-1, "您的企业账号正在加速审核中,审核通过后即可登录", userLoginVo);
+                    }
+                    if (91 == userLoginVo.getShopStatus()) {
+                        return ResponseJson.error(-1, "您的企业账号已被冻结,请联系客服处理", userLoginVo);
+                    }
+                    if (92 == userLoginVo.getShopStatus()) {
+                        return ResponseJson.error(-3, "您的企业账号审核未通过", userLoginVo);
+                    }
+                }
+                // 是否可为机构下单
+                boolean flag = false;
+                // 供应商商品上架平台信息
+                List<String> shopProductList = loginMapper.getShopProductGroudMall(userLoginVo.getShopId());
+                if (null != shopProductList) {
+                    for(String product : shopProductList ) {
+                        if (StringUtils.isNotBlank(product)) {
+                            // 商品上架平台是否在联合丽格上架
+                            if (product.contains("4")) {
+                                flag = true;
+                            }
+                        }
+                    }
+                } else {
+                    flag = false;
+                }
+                userLoginVo.setShopIsOrder(flag);
+            } else {
+                return ResponseJson.error(-1, "该账号未成为供应商", null);
+            }
+        } else {
+            return ResponseJson.error(-1, "用户数据异常", null);
+        }
+        return ResponseJson.success("登录成功", userLoginVo);
+    }
+
     /**
      * 根据用户Id查询供应商资料
      *

+ 8 - 0
src/main/resources/mapper/LoginMapper.xml

@@ -352,6 +352,14 @@
         set loginTime = now()
         where userID = #{userId}
     </update>
+
+    <select id="getShopProductGroudMall" resultType="java.lang.String">
+        select p.groundMall AS groundMall
+        from product p
+                 left join cm_organize_product_info copi on copi.productId = p.productID
+        where p.shopId = #{shopId} and copi.validFlag = 2
+    </select>
+
     <select id="getUserIdByOpenId" resultType="java.lang.Integer">
         select o.userID as userId
         from

+ 23 - 0
src/main/resources/mapper/ShopMapper.xml

@@ -96,6 +96,29 @@
     <select id="getShopCert" resultType="java.lang.String">
         SELECT image FROM shopcert WHERE shopID = #{shopId} AND shopCertTypeID = #{shopCertTypeId}
     </select>
+
+    <select id="getShopByUserId" resultType="com.caimei365.user.model.vo.UserLoginVo">
+        select
+            u.userID             as userId,
+            u.userOrganizeID     as organizeId,
+            u.clubID             as clubId,
+            u.shopID             as shopId,
+            u.serviceProviderId  as serviceProviderId,
+            u.userName           as userName,
+            u.name               as name,
+            u.mobile             as mobile,
+            u.bindMobile         as bindMobile,
+            u.email              as email,
+            u.userPermission     as userPermission,
+            u.userIdentity       as userIdentity,
+            u.password           as password,
+            u.guideFlag          as guideFlag,
+            u.clubStatus         as clubStatus,
+            u.manufacturerStatus as shopStatus
+        from user u
+        where u.userId = #{userId}
+    </select>
+
     <select id="getShopById" resultType="com.caimei365.user.model.vo.ShopVo">
         select userID as userId, shopID as shopId, name, sname as shortName, linkMan, contractMobile,
                contractEmail, contractEmail as email, provinceID as proviceId, cityID as cityId, townID as townId,