Ver código fonte

认证通1.7.5版本新加机构编号

JiangChongBo 2 anos atrás
pai
commit
d5f1633318

+ 10 - 10
src/main/java/com/caimei/controller/admin/auth/AuthApi.java

@@ -80,7 +80,7 @@ public class AuthApi {
     @GetMapping("/list")
     public ResponseJson<PageInfo<AuthVo>> getAuthList(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String authParty, String mobile,
                                                       Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
-                                                      Integer shopAuditStatus, Integer sendStatus,
+                                                      Integer shopAuditStatus, Integer sendStatus,String authCode,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
         // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
@@ -94,7 +94,7 @@ public class AuthApi {
         } else if (null == authUserId) {
             return ResponseJson.error("供应商用户id不能为空", null);
         }
-        return authService.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, pageNum, pageSize);
+        return authService.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus,authCode, pageNum, pageSize);
     }
 
     /**
@@ -524,7 +524,7 @@ public class AuthApi {
          * @param response
          * @throws IOException
          */
-        @GetMapping("/get/douying/code")
+        @GetMapping("/check/accesstoken")
         public ResponseJson getDouYingCode(HttpServletResponse response) throws IOException {
             return authService.getDouYingCode(response);
         }
@@ -581,17 +581,17 @@ public class AuthApi {
      *
      * @return
      */
-    @GetMapping("/sms")
-    public ResponseJson sms(String mobile,String content){//@RequestBody String params
-//         JSONObject jsonObject=JSONObject.parseObject(params);
-//         String mobile=jsonObject.getString("mobile");
-//         String content=jsonObject.getString("content");
-//         String authUser=jsonObject.getString("name");
+    @PostMapping("/sms/send/douyin")
+    public ResponseJson sms(@RequestBody String params){//String mobile,String content
+         JSONObject jsonObject=JSONObject.parseObject(params);
+         String mobile=jsonObject.getString("mobile");
+         String content=jsonObject.getString("content");
+         String authUser=jsonObject.getString("name");
         // 短信类型:1通知短信,2验证码短信,3营销短信
         String con=content.substring(0,content.indexOf("/")+1);
         String cs=content.substring(content.indexOf("com")+3);
          Integer type=1;
-         String kouLin="【上海品辉医疗科技有限公司】您在认证通抖音视频挑战赛发布的视频已成功上传至抖音平台,抖音分享口令为:"+con+" https://v.douyin.com"+cs+",您可复制该口令后去抖音平台打开【采美网提供技术支持】";
+         String kouLin="["+authUser+"]您在认证通抖音视频挑战赛发布的视频已成功上传至抖音平台,抖音分享口令为:"+con+" https://v.douyin.com"+cs+",您可复制该口令后去抖音平台打开";
         Boolean flag = SmsUtils.sendSms(type, mobile, kouLin);
         if (flag){
             return ResponseJson.success();

+ 1 - 1
src/main/java/com/caimei/mapper/cmMapper/AuthMapper.java

@@ -22,7 +22,7 @@ import java.util.List;
 @Mapper
 public interface AuthMapper {
 
-    List<AuthVo> getAuthList(@Param("listType") Integer listType, @Param("authUserId") Integer authUserId, @Param("authParty") String authParty, @Param("mobile") String mobile, @Param("status") Integer status, @Param("starFlag")  Integer starFlag, @Param("auditStatus") Integer auditStatus, @Param("lowerAuditStatus") Integer lowerAuditStatus, @Param("shopAuditStatus") Integer shopAuditStatus, @Param("sendStatus") Integer sendStatus);
+    List<AuthVo> getAuthList(@Param("listType") Integer listType, @Param("authUserId") Integer authUserId, @Param("authParty") String authParty, @Param("mobile") String mobile, @Param("status") Integer status, @Param("starFlag")  Integer starFlag, @Param("auditStatus") Integer auditStatus, @Param("lowerAuditStatus") Integer lowerAuditStatus, @Param("shopAuditStatus") Integer shopAuditStatus, @Param("sendStatus") Integer sendStatus,@Param("authCode") String authCode);
     List<AuthVo> getAuthListAll(@Param("listType") Integer listType, @Param("authUserId") Integer authUserId, @Param("authParty") String authParty, @Param("mobile") String mobile, @Param("status") Integer status, @Param("starFlag")  Integer starFlag, @Param("auditStatus") Integer auditStatus, @Param("lowerAuditStatus") Integer lowerAuditStatus, @Param("shopAuditStatus") Integer shopAuditStatus, @Param("sendStatus") Integer sendStatus,@Param("name") String name,@Param("snCode") String snCode);
 
     void updateAuthStatusByAuthId(@Param("authId") Integer authId, @Param("status") Integer status);

+ 5 - 0
src/main/java/com/caimei/model/vo/AuthVo.java

@@ -158,4 +158,9 @@ public class AuthVo {
      * 明星机构排序值(数值越大,排名越前)
      */
     private String starNum;
+    /**
+     * 认证编号
+     */
+    private String authCode;
+
 }

+ 1 - 1
src/main/java/com/caimei/service/auth/AuthService.java

@@ -37,7 +37,7 @@ public interface AuthService {
      * @param auditStatus      审核状态:0审核未通过,1审核通过,2待审核
      * @return AuthVo
      */
-    ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty, String mobile, Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize);
+    ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty, String mobile, Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus,String authCode ,Integer pageNum, Integer pageSize);
     ResponseJson<PageInfo<AuthVo>> getAuthListAll(Integer listType, Integer authUserId, String authParty, String mobile, Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, String name,String snCode,Integer pageNum, Integer pageSize);
 
     /**

+ 38 - 48
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -122,10 +122,10 @@ public class AuthServiceImpl implements AuthService {
     @Override
     public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty,
                                                       String mobile, Integer status, Integer starFlag, Integer auditStatus,
-                                                      Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus, Integer pageNum, Integer pageSize) {
+                                                      Integer lowerAuditStatus, Integer shopAuditStatus, Integer sendStatus,String authCode, Integer pageNum, Integer pageSize) {
         listType = null == listType ? 1 : listType;
         PageHelper.startPage(pageNum, pageSize);
-        List<AuthVo> authList = authMapper.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus);
+        List<AuthVo> authList = authMapper.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus,authCode);
         PageInfo<AuthVo> pageData = new PageInfo<>(authList);
         return ResponseJson.success(pageData);
     }
@@ -199,7 +199,7 @@ public class AuthServiceImpl implements AuthService {
 
     @Override
     public ResponseJson<List<AuthVo>> getAuthSelectList(Integer authUserId) {
-        List<AuthVo> authList = authMapper.getAuthList(1, authUserId, null, null, null, null, null, null, null, null);
+        List<AuthVo> authList = authMapper.getAuthList(1, authUserId, null, null, null, null, null, null, null, null,null);
         return ResponseJson.success(authList);
     }
 
@@ -786,35 +786,38 @@ public class AuthServiceImpl implements AuthService {
     @Override
     public ResponseJson getDouYingCode(HttpServletResponse response) throws IOException {
         //验证是否是第一次登录(根据redis缓存中的token验证)
-        long dYaccessTok = redisService.getExpireTime("DYaccessToken");
-        boolean s=redisService.exists("DYaccessToken");
-       String s1= redisService.get("DyopenId").toString();
-//        if(!redisService.exists("DYaccessToken")){
-            //验证token是否过期
-            long dYaccessToken = redisService.getExpireTime("DYaccessToken");
-            if(dYaccessToken<=0){ //tonken过期
-                //判断refreshToken是否过期
-                long DyrefreshToken = redisService.getExpireTime("DyrefreshToken");
-                if(DyrefreshToken>=0){ //refreshToken
-                    //根据refreshToken刷新token,重新缓存token
-                    String refreshToken=redisService.get("DyrefreshToken").toString();
-                    String accessToken = refreshAccessToken(refreshToken);
-                    redisService.set("DYaccessToken",accessToken , 60L * 60 * 24 * 15);
-                   boolean flag= redisService.exists("DYaccessToken");
-                    return  ResponseJson.success(true);
-                }else{ //根据refreshToken刷新refreshToken(总共可以刷新3次,次数完后需重新扫码授权)
-                    String refreshToken=redisService.get("DyrefreshToken").toString();
-                    String newRefreshToken = resetRefreshAccessToken(refreshToken);
-                    if(StringUtils.isNotEmpty(newRefreshToken)){
-                        String accessToken = refreshAccessToken(newRefreshToken);
-                        redisService.set("DYaccessToken",accessToken,60L * 60 * 24 * 15);
-                        return  ResponseJson.success(true);
-                    }
-                }
-            }else {
-              return  ResponseJson.success(true);
-            }
+//        long dYaccessTok = redisService.getExpireTime("DYaccessToken");
+//        boolean s=redisService.exists("DYaccessToken");
+//       String s1= redisService.get("DyopenId").toString();
+////        if(!redisService.exists("DYaccessToken")){
+//            //验证token是否过期
+//            long dYaccessToken = redisService.getExpireTime("DYaccessToken");
+//            if(dYaccessToken<=0){ //tonken过期
+//                //判断refreshToken是否过期
+//                long DyrefreshToken = redisService.getExpireTime("DyrefreshToken");
+//                if(DyrefreshToken>=0){ //refreshToken
+//                    //根据refreshToken刷新token,重新缓存token
+//                    String refreshToken=redisService.get("DyrefreshToken").toString();
+//                    String accessToken = refreshAccessToken(refreshToken);
+//                    redisService.set("DYaccessToken",accessToken , 60L * 60 * 24 * 15);
+//                   boolean flag= redisService.exists("DYaccessToken");
+//                    return  ResponseJson.success(true);
+//                }else{ //根据refreshToken刷新refreshToken(总共可以刷新3次,次数完后需重新扫码授权)
+//                    String refreshToken=redisService.get("DyrefreshToken").toString();
+//                    String newRefreshToken = resetRefreshAccessToken(refreshToken);
+//                    if(StringUtils.isNotEmpty(newRefreshToken)){
+//                        String accessToken = refreshAccessToken(newRefreshToken);
+//                        redisService.set("DYaccessToken",accessToken,60L * 60 * 24 * 15);
+//                        return  ResponseJson.success(true);
+//                    }
+//                }
+//            }else {
+//              return  ResponseJson.success(true);
+//            }
 //        }
+             //验证token是否过期
+//              long dYaccessToken = redisService.getExpireTime("DYaccessToken");
+              return redisService.getExpireTime("DYaccessToken")<0 ? ResponseJson.success(false): ResponseJson.success(true);
 //        String clintKey = "awwwvh9tsnvo54w1";//应用唯一标识
 //        String responestype = "code";//写死为'code'即可
 //        String scope = "video.data,video.list,trial.whitelist,data.external.item";//应用授权作用域,多个授权作用域以英文逗号(,)分隔
@@ -823,7 +826,6 @@ public class AuthServiceImpl implements AuthService {
 //        String code = "https://open.douyin.com/platform/oauth/connect/?client_key=" + clintKey
 //                + "&response_type=" + responestype + "&scope=" + scope + "&redirect_uri=" + redirectUrl + "&state=" + state;
 //        response.sendRedirect(code);
-        return ResponseJson.success(false);
     }
 
     /**
@@ -860,9 +862,11 @@ public class AuthServiceImpl implements AuthService {
         String accessToken = params.getString("access_token");
         String openId = params.getString("open_id");
         String refreshToken = params.getString("refresh_token");
+        String errorCode = params.getString("error_code");
+        if(Integer.valueOf(errorCode)>0){return ResponseJson.success("tonken缓存失败",null);}
         //用redis缓存access_token,refresh_token
-        redisService.set("DYaccessToken",accessToken , 60L);// * 60 * 24 * 15
-        redisService.set("DyrefreshToken",refreshToken,60l*2);
+        redisService.set("DYaccessToken",accessToken , 60L * 60 * 24 * 15);// * 60 * 24 * 15
+        redisService.set("DyrefreshToken",refreshToken,60L * 60 * 24 * 30);
         redisService.set("DyopenId",openId,60L * 60 * 24 * 30);
         EntityUtils.consume(he);
         String DYaccessToken=redisService.get("DYaccessToken").toString();
@@ -980,10 +984,6 @@ public class AuthServiceImpl implements AuthService {
             String data=jsonObject.getString("data");
             JSONObject params=JSONObject.parseObject(data);
             String accessToken=params.getString("access_token");
-            System.out.println(result);
-            System.out.println(accessToken);
-//            String accessToken = result.substring(result.indexOf("access_token") + "access_token".length() + 3, result.indexOf(",") - 1);
-//            System.out.println("access_token----"+accessToken);
             //根据accesstoken获取tiket
              schema = getDouYingTicket(accessToken, title,videoPath);
             EntityUtils.consume(he);
@@ -1014,20 +1014,17 @@ public class AuthServiceImpl implements AuthService {
             response = closeableHttpClient.execute(httpGet);
             HttpEntity he = response.getEntity();
             String result = EntityUtils.toString(he, StandardCharsets.UTF_8);
-            System.out.println(result);
             //获取ticket
             JSONObject jsonObject=JSONObject.parseObject(result);
             String data = jsonObject.getString("data");
             JSONObject params=JSONObject.parseObject(data);
             String ticket = params.getString("ticket");
-            System.out.println("ticket--"+ticket);
             //getDouYingshareId
             String shareId = getDouYingshareId(clientToken);
             //获取签名 并且用md5加密
             String signature = signatureAlgorithm(ticket, timestamp,noncestr);
             //获取schema(返回前端用于生成二维码发布视频)
              schema = appendSchema(signature, shareId, timestamp,noncestr, title, videoPath);
-            System.out.println("schema--:"+schema);
             EntityUtils.consume(he);
         } catch (IOException e) {
             e.printStackTrace();
@@ -1053,10 +1050,8 @@ public class AuthServiceImpl implements AuthService {
             stringBuffer.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
         }
         String result = stringBuffer.substring(0, stringBuffer.length() - 1);
-        System.out.println(result);
         //进行md5签名
         String signature = Md5Util.md5(result).toLowerCase();
-        System.out.println(signature);
         return signature;
     }
 
@@ -1105,8 +1100,6 @@ public class AuthServiceImpl implements AuthService {
             String data = jsonObject.getString("data");
             JSONObject params=JSONObject.parseObject(data);
             shareId = params.getString("share_id");
-            System.out.println(result);
-            System.out.println(shareId);
             EntityUtils.consume(he);
         } catch (IOException e) {
             e.printStackTrace();
@@ -1131,15 +1124,12 @@ public class AuthServiceImpl implements AuthService {
             CloseableHttpResponse execute = closeableHttpClient.execute(hg);
             HttpEntity entity = execute.getEntity();
             String result=EntityUtils.toString(entity,StandardCharsets.UTF_8);
-            System.out.println(result);
             JSONObject jsonObject = JSONObject.parseObject(result);
             String data = jsonObject.getString("data");
             JSONObject paramslist = JSONObject.parseObject(data);
             String itemIdlist = paramslist.getString("list");
-            System.out.println("list----"+itemIdlist);
             JSONArray params = JSONArray.parseArray(itemIdlist);
             String itemId = params.getJSONObject(0).get("item_id").toString();
-            System.out.println("item_id-----"+itemId);
             //根据itemid获取视频的数据(点赞,播放,评论量)
             EntityUtils.consume(entity);
         } catch (IOException e) {

+ 4 - 1
src/main/resources/mapper/AuthMapper.xml

@@ -137,7 +137,7 @@
     </delete>
     <select id="getAuthList" resultType="com.caimei.model.vo.AuthVo">
         select a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus,
-        a.createTime,
+        a.createTime,a.authCode,
         if(a.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu1.mobile) as createBy,ifnull(au.loginAccount,au.name)
         as auditBy,a.auditTime,a.invalidReason,
         ifnull(a.shopInvalidReason, a.invalidReason) as shopInvalidReason,
@@ -165,6 +165,9 @@
         <if test="authParty != null and authParty != ''">
             and a.authParty like CONCAT('%',#{authParty},'%')
         </if>
+        <if test="authCode != null and authCode != ''">
+            and a.authCode=#{authCode}
+        </if>
         <if test="status != null">
             and a.status = #{status}
         </if>