From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SMSController.java |  474 ++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 277 insertions(+), 197 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SMSController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SMSController.java
index 1407f19..603866b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SMSController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SMSController.java
@@ -1,197 +1,277 @@
-package com.yeshi.fanli.controller.client.v1;
-
-import java.io.PrintWriter;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.yeshi.utils.JsonUtil;
-
-import com.yeshi.fanli.entity.accept.AcceptData;
-import com.yeshi.fanli.entity.bus.user.UserInfo;
-import com.yeshi.fanli.exception.config.SMSException;
-import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
-import com.yeshi.fanli.service.inter.user.SMSService;
-import com.yeshi.fanli.service.inter.user.UserInfoService;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.RedisKeyEnum;
-import com.yeshi.fanli.util.RedisManager;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
-
-@Controller
-@RequestMapping("api/v1/sms")
-public class SMSController {
-
-	@Resource
-	private SMSService smsService;
-
-	@Resource
-	private RedisManager redisManager;
-
-	@Resource
-	private UserInfoService userInfoService;
-
-	@Resource
-	private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
-
-	// 鍙戦�佺煭淇�
-
-	@RequestSerializableByKey(key = "#phone+'-'+#uid+'-'+#type")
-	@RequestMapping(value = "sendSMS", method = RequestMethod.POST)
-	public void sendMSM(AcceptData acceptData, String phone, Long uid, Integer type, PrintWriter out) {
-		if (Constant.IS_TEST) {
-			out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
-			return;
-		}
-		sendMSM(acceptData, phone, uid, type, StringUtil.Md5(phone + "-" + "-" + uid + "-" + type), out);
-	}
-
-	public void sendMSM(AcceptData acceptData, String phone, Long uid, Integer type, String key, PrintWriter out) {
-		try {
-			if (phone.contains("**") && uid != null && uid > 0) {
-				UserInfo userInfo = userInfoService.getUserById(uid);
-				if (userInfo == null) {
-					out.print(JsonUtil.loadFalseResult(2, "鐢ㄦ埛涓嶅瓨鍦�"));
-					return;
-				} else if (StringUtil.isNullOrEmpty(userInfo.getPhone())) {
-					out.print(JsonUtil.loadFalseResult(3, "灏氭湭缁戝畾鐢佃瘽鍙风爜"));
-					return;
-				}
-				phone = userInfo.getPhone();
-			}
-
-			if (!StringUtil.isMobile(phone)) {
-				out.print(JsonUtil.loadFalseResult(4, "鐢佃瘽鍙风爜鏍煎紡涓嶆纭�"));
-				return;
-			}
-			smsService.sendLoginVCode(phone, 6);
-
-			out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
-		} catch (SMSException e) {
-			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
-		}
-	}
-
-	/**
-	 * 1.5.3 鐧诲綍鍙戦�佺煭淇�
-	 * 
-	 * @param acceptData
-	 * @param phone
-	 * @param uid
-	 * @param out
-	 */
-	@RequestMapping(value = "sendMSMLogin", method = RequestMethod.POST)
-	public void sendMSMLogin(AcceptData acceptData, String phone, boolean slideVerify, PrintWriter out) {
-		if (phone == null || !StringUtil.isMobile(phone.replaceAll(" ", ""))) {
-			out.print(JsonUtil.loadFalseResult(1, "鎵嬫満鍙疯緭鍏ユ湁璇紝璇蜂慨鏀�"));
-			return;
-		}
-		phone = phone.replaceAll(" ", "");
-
-		if (Constant.IS_TEST) {
-			out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
-			return;
-		}
-
-		sendMSNnew(phone, slideVerify, 1, StringUtil.Md5(phone + "-" + acceptData.getDevice()), out);
-	}
-
-	/**
-	 * 1.5.3 缁戝畾鍙戦�佺煭淇�
-	 * 
-	 * @param acceptData
-	 * @param phone
-	 * @param uid
-	 * @param out
-	 */
-	@RequestSerializableByKey(key = "#acceptData.device+'-'+#phone")
-	@RequestMapping(value = "sendMSMBind", method = RequestMethod.POST)
-	public void sendMSMBind(AcceptData acceptData, String phone, boolean slideVerify, Long uid, PrintWriter out) {
-		if (phone == null || !StringUtil.isMobile(phone.replaceAll(" ", ""))) {
-			out.print(JsonUtil.loadFalseResult(1, "鎵嬫満鍙疯緭鍏ユ湁璇紝璇蜂慨鏀�"));
-			return;
-		}
-		phone = phone.replaceAll(" ", "");
-
-		// 鍒ゆ柇鎵嬫満鍙风爜鏄惁琚皝绂�
-		// ForbiddenUserIdentifyCode identifyCode1 =
-		// forbiddenUserIdentifyCodeService
-		// .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone,
-		// phone);
-		// if (identifyCode1 != null && identifyCode1.getEffective() != null &&
-		// identifyCode1.getEffective()) {
-		// out.print(JsonUtil.loadFalseResult(9001,"璇ョ數璇濆彿鐮佽鍗犵敤"));
-		// return;
-		// }
-		//
-		// 鍒ゆ柇鎵嬫満鍙风爜鏄惁琚皝绂�
-		UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone);
-		if (phoneUser != null && uid != null) {
-			out.print(JsonUtil.loadFalseResult(9001, "璇ョ數璇濆彿鐮佽鍗犵敤"));
-			return;
-		}
-
-		if (Constant.IS_TEST) {
-			out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
-			return;
-		}
-
-		sendMSNnew(phone, slideVerify, 2, StringUtil.Md5(phone + "-" + acceptData.getDevice()), out);
-	}
-
-	public void sendMSNnew(String phone, boolean slideVerify, int type, String key, PrintWriter out) {
-		try {
-			int count = 0;
-			String cachekey = null;
-			if (type == 1) {
-				// 鐧诲綍楠岃瘉鐮�
-				cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLoginCount, phone + "");
-			} else if (type == 2) {
-				// 缁戝畾楠岃瘉鐮�
-				cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSBindCount, phone + "");
-			}
-
-			if (cachekey == null) {
-				out.print(JsonUtil.loadFalseResult(1, "鍙戦�佸け璐�"));
-				return;
-			}
-
-			String cacheValue = redisManager.getCommonString(cachekey);
-			if (!StringUtil.isNullOrEmpty(cacheValue)) {
-				count = Integer.parseInt(cacheValue);
-				// 闄愬埗3娆�
-				if (count >= 3) {
-					out.print(JsonUtil.loadFalseResult(3, "楠岃瘉鐮佹鏁拌秴闄�,璇风◢鍚庡啀璇�"));
-					return;
-				}
-			}
-
-			if (count == 2 && !slideVerify) {
-				out.print(JsonUtil.loadFalseResult(2, "闇�瑕佹粦鍔ㄩ獙璇�"));
-				return;
-			}
-			// 缂撳瓨涓�涓皬鏃�
-			count++;
-			redisManager.cacheCommonString(cachekey, count + "", 60 * 60);
-
-			if (type == 1) {
-				// 鐧诲綍楠岃瘉鐮�
-				smsService.sendLoginVCode(phone, 4);
-			} else if (type == 2) {
-				// 缁戝畾楠岃瘉鐮�
-				smsService.sendBindVCode(phone, 4);
-			}
-
-			out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
-
-		} catch (SMSException e) {
-			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
-		} catch (Exception e) {
-			out.print(JsonUtil.loadFalseResult(1, "鍙戦�佸け璐�"));
-			e.printStackTrace();
-		}
-	}
-}
+package com.yeshi.fanli.controller.client.v1;
+
+import java.io.PrintWriter;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.util.*;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.yeshi.utils.JsonUtil;
+
+import com.yeshi.fanli.entity.accept.AcceptData;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.exception.config.SMSException;
+import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
+import com.yeshi.fanli.service.inter.user.SMSService;
+import com.yeshi.fanli.service.inter.user.UserInfoService;
+import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
+
+@Controller
+@RequestMapping("api/v1/sms")
+public class SMSController {
+
+    @Resource
+    private SMSService smsService;
+
+    @Resource
+    private RedisManager redisManager;
+
+    @Resource
+    private UserInfoService userInfoService;
+
+    @Resource
+    private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
+
+    // 鍙戦�佺煭淇�
+
+    @RequestSerializableByKey(key = "#phone+'-'+#uid+'-'+#type")
+    @RequestMapping(value = "sendSMS", method = RequestMethod.POST)
+    public void sendMSM(AcceptData acceptData, String phone, Long uid, Integer type, PrintWriter out) {
+        if (Constant.IS_TEST) {
+            out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
+            return;
+        }
+        sendMSM(acceptData, phone, uid, type, StringUtil.Md5(phone + "-" + "-" + uid + "-" + type), out);
+    }
+
+    public void sendMSM(AcceptData acceptData, String phone, Long uid, Integer type, String key, PrintWriter out) {
+        try {
+            if (phone.contains("**") && uid != null && uid > 0) {
+                UserInfo userInfo = userInfoService.getUserById(uid);
+                if (userInfo == null) {
+                    out.print(JsonUtil.loadFalseResult(2, "鐢ㄦ埛涓嶅瓨鍦�"));
+                    return;
+                } else if (StringUtil.isNullOrEmpty(userInfo.getPhone())) {
+                    out.print(JsonUtil.loadFalseResult(3, "灏氭湭缁戝畾鐢佃瘽鍙风爜"));
+                    return;
+                }
+                phone = userInfo.getPhone();
+            }
+
+            if (!StringUtil.isMobile(phone)) {
+                out.print(JsonUtil.loadFalseResult(4, "鐢佃瘽鍙风爜鏍煎紡涓嶆纭�"));
+                return;
+            }
+            smsService.sendLoginVCode(acceptData.getSystem(), phone, 6);
+            out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
+        } catch (SMSException e) {
+            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+        }
+    }
+
+    /**
+     * 1.5.3 鐧诲綍鍙戦�佺煭淇�
+     *
+     * @param acceptData
+     * @param phone
+     * @param out
+     */
+    @RequestMapping(value = "sendMSMLogin", method = RequestMethod.POST)
+    public void sendMSMLogin(AcceptData acceptData, String phone, boolean slideVerify, PrintWriter out) {
+        if (phone == null || !StringUtil.isMobile(phone.replaceAll(" ", ""))) {
+            out.print(JsonUtil.loadFalseResult(1, "鎵嬫満鍙疯緭鍏ユ湁璇紝璇蜂慨鏀�"));
+            return;
+        }
+        phone = phone.replaceAll(" ", "");
+
+        if (Constant.IS_TEST) {
+            out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
+            return;
+        }
+
+        sendMSNnew(acceptData.getSystem(), phone, slideVerify, 1, StringUtil.Md5(phone + "-" + acceptData.getDevice()), out);
+    }
+
+    /**
+     * 1.5.3 缁戝畾鍙戦�佺煭淇�
+     *
+     * @param acceptData
+     * @param phone
+     * @param uid
+     * @param out
+     */
+    @RequestSerializableByKey(key = "#acceptData.device+'-'+#phone")
+    @RequestMapping(value = "sendMSMBind", method = RequestMethod.POST)
+    public void sendMSMBind(AcceptData acceptData, String phone, boolean slideVerify, Long uid, PrintWriter out) {
+        if (phone == null || !StringUtil.isMobile(phone.replaceAll(" ", ""))) {
+            out.print(JsonUtil.loadFalseResult(1, "鎵嬫満鍙疯緭鍏ユ湁璇紝璇蜂慨鏀�"));
+            return;
+        }
+        phone = phone.replaceAll(" ", "");
+
+        // 鍒ゆ柇鎵嬫満鍙风爜鏄惁琚皝绂�
+        // ForbiddenUserIdentifyCode identifyCode1 =
+        // forbiddenUserIdentifyCodeService
+        // .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone,
+        // phone);
+        // if (identifyCode1 != null && identifyCode1.getEffective() != null &&
+        // identifyCode1.getEffective()) {
+        // out.print(JsonUtil.loadFalseResult(9001,"璇ョ數璇濆彿鐮佽鍗犵敤"));
+        // return;
+        // }
+        //
+        // 鍒ゆ柇鎵嬫満鍙风爜鏄惁琚皝绂�
+        UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
+        if (phoneUser != null && uid != null) {
+            out.print(JsonUtil.loadFalseResult(9001, "璇ョ數璇濆彿鐮佽鍗犵敤"));
+            return;
+        }
+
+        if (Constant.IS_TEST) {
+            out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
+            return;
+        }
+
+        sendMSNnew(acceptData.getSystem(), phone, slideVerify, 2, StringUtil.Md5(phone + "-" + acceptData.getDevice()), out);
+    }
+
+    public void sendMSNnew(SystemEnum system, String phone, boolean slideVerify, int type, String key, PrintWriter out) {
+        try {
+            int count = 0;
+            String cachekey = null;
+            if (type == 1) {
+                // 鐧诲綍楠岃瘉鐮�
+                cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLoginCount, phone + "");
+            } else if (type == 2) {
+                // 缁戝畾楠岃瘉鐮�
+                cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSBindCount, phone + "");
+            }
+
+            if (cachekey == null) {
+                out.print(JsonUtil.loadFalseResult(1, "鍙戦�佸け璐�"));
+                return;
+            }
+
+            String cacheValue = redisManager.getCommonString(cachekey);
+            if (!StringUtil.isNullOrEmpty(cacheValue)) {
+                count = Integer.parseInt(cacheValue);
+                // 闄愬埗3娆�
+                if (count >= 3) {
+                    out.print(JsonUtil.loadFalseResult(3, "楠岃瘉鐮佹鏁拌秴闄�,璇风◢鍚庡啀璇�"));
+                    return;
+                }
+            }
+
+            if (count == 2 && !slideVerify) {
+                out.print(JsonUtil.loadFalseResult(2, "闇�瑕佹粦鍔ㄩ獙璇�"));
+                return;
+            }
+            // 缂撳瓨涓�涓皬鏃�
+            count++;
+            redisManager.cacheCommonString(cachekey, count + "", 60 * 60);
+
+            if (type == 1) {
+                // 鐧诲綍楠岃瘉鐮�
+                smsService.sendLoginVCode(system, phone, 4);
+            } else if (type == 2) {
+                // 缁戝畾楠岃瘉鐮�
+                smsService.sendBindVCode(system, phone, 4);
+            }
+
+            out.print(JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
+
+        } catch (SMSException e) {
+            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+        } catch (Exception e) {
+            out.print(JsonUtil.loadFalseResult(1, "鍙戦�佸け璐�"));
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * 娉ㄩ攢璐︽埛鐭俊楠岃瘉
+     *
+     * @param acceptData
+     * @param uid
+     * @param phone
+     * @param out
+     */
+    @RequestMapping(value = "sendMSMRemove")
+    public void sendMSMRemove(String callback, AcceptData acceptData, Long uid, String phone, PrintWriter out) {
+        if (Constant.IS_TEST) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
+            return;
+        }
+
+        if (uid == null || uid <= 0) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+            return;
+        }
+
+        if (phone == null || !StringUtil.isMobile(phone.replaceAll(" ", ""))) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "璇疯緭鍏ユ纭墜鏈哄彿"));
+            return;
+        }
+        phone = phone.replaceAll(" ", "").trim();
+
+        UserInfo userInfo = userInfoService.selectAvailableByPrimaryKey(uid);
+        if (userInfo == null) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "鐢ㄦ埛涓嶅瓨鍦�"));
+            return;
+        }
+
+        if (!phone.equals(userInfo.getPhone())) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "璇疯緭鍏ユ纭墜鏈哄彿"));
+            return;
+        }
+
+        try {
+            int count = 0;
+            String cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSBindRemove, phone + "");
+            String cacheValue = redisManager.getCommonString(cachekey);
+            if (!StringUtil.isNullOrEmpty(cacheValue)) {
+                count = Integer.parseInt(cacheValue);
+                // 闄愬埗3娆�
+                if (count >= 3) {
+                    JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "楠岃瘉鐮佹鏁拌秴闄�,璇风◢鍚庡啀璇�"));
+                    return;
+                }
+            }
+            // 缂撳瓨涓�涓皬鏃�
+            count++;
+            redisManager.cacheCommonString(cachekey, count + "", 60 * 60);
+            // 鍙戦�侀獙璇佺爜
+            smsService.sendRemoveVCode(acceptData.getSystem(), phone, 4);
+            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍙戦�佹垚鍔�"));
+        } catch (SMSException e) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+        } catch (Exception e) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "鍙戦�佸け璐�"));
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * 璁惧鏄惁鍏佽涓�閿櫥褰�
+     *
+     * @param acceptData
+     * @param out
+     */
+    @RequestMapping(value = "allowOneKeyLogin", method = RequestMethod.POST)
+    public void allowOneKeyLogin(AcceptData acceptData, PrintWriter out) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.oneKeyLoginCount, StringUtil.Md5(StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid()));
+        //姣忓ぉ鍙兘鐢�10娆�
+        String value = redisManager.getCommonString(key);
+        if (!StringUtil.isNullOrEmpty(value) && Integer.parseInt(value) >= 10) {
+            out.print(JsonUtil.loadFalseResult("涓�閿櫥褰曟瘡鏃ュ彧鑳界敤10娆�"));
+            return;
+        }
+        out.print(JsonUtil.loadTrueResult(""));
+    }
+
+}

--
Gitblit v1.8.0