diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/AliyunServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/AliyunServiceImpl.java index 224bdc2a5..9701c5e5e 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/AliyunServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/AliyunServiceImpl.java @@ -13,15 +13,11 @@ import com.cool.store.enums.IDCardSideEnum; import com.cool.store.exception.ApiException; import com.cool.store.exception.ServiceException; import com.cool.store.service.AliyunService; -import com.cool.store.utils.RedisConstantUtil; -import com.cool.store.utils.RedisUtilPool; -import com.cool.store.utils.UUIDUtils; import com.cool.store.vo.cuser.IdentityCardInfoVO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; - -import javax.annotation.Resource; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; @@ -30,7 +26,6 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Objects; import java.util.Optional; -import java.util.Random; /** * @author zhangchenbiao @@ -42,16 +37,24 @@ import java.util.Random; @Service public class AliyunServiceImpl implements AliyunService { + @Value("${aliyun.accessKeyId:null}") + private String accessKeyId; + + @Value("${aliyun.accessKeySecret:null}") + private String accessKeySecret; + + @Value("${aliyun.authCode:null}") + private String authCode; + @Override public DescribePhoneNumberDTO getPhoneNumberAttribute(String phoneNumber) { try { Config config = new Config(); - //todo zcb ak sk替换 - config.accessKeyId = "LTAI5t9RaXvABZbHvoXjDFJ1"; - config.accessKeySecret = "zhOK7WWo3yGoUWkOMaatty19k25CMd"; + config.accessKeyId = accessKeyId; + config.accessKeySecret = accessKeySecret; Client client = new Client(config); DescribePhoneNumberOperatorAttributeRequest request = new DescribePhoneNumberOperatorAttributeRequest(); - request.authCode = "Y81FVZepk6"; + request.authCode = authCode; request.inputNumber = phoneNumber; request.mask = "NORMAL"; DescribePhoneNumberOperatorAttributeResponse response = client.describePhoneNumberOperatorAttribute(request); @@ -71,15 +74,11 @@ public class AliyunServiceImpl implements AliyunService { public IdentityCardInfoVO getIdentityCardInfo(String faceImageUrl, IDCardSideEnum sideEnum) throws ApiException { //todo zcb ak sk替换 com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config() - .setAccessKeyId("LTAI5t9RaXvABZbHvoXjDFJ1") - .setAccessKeySecret("zhOK7WWo3yGoUWkOMaatty19k25CMd"); + .setAccessKeyId(accessKeyId) + .setAccessKeySecret(accessKeySecret); // 访问的域名 config.endpoint = "ocr.cn-shanghai.aliyuncs.com"; try { - if(StringUtils.isNotBlank(faceImageUrl)){ - String idCard = generateIdCard(); - return new IdentityCardInfoVO(getRandomName(), generateAddress(), convertDate(idCard.substring(6, 14), "yyyyMMdd"), UUIDUtils.get8UUID().hashCode() % 2 == 0 ? "男":"女", idCard, "汉"); - } com.aliyun.ocr20191230.Client client = new com.aliyun.ocr20191230.Client(config); URL url = new URL(faceImageUrl); InputStream inputStream = url.openConnection().getInputStream(); @@ -129,85 +128,6 @@ public class AliyunServiceImpl implements AliyunService { throw new ServiceException(ErrorCodeEnum.DATA_CONVERT_ERROR); } } - public static String generateAddress() { - String address = ""; - String[] provinceList = {"北京市", "上海市", "广东省", "江苏省", "浙江省", "四川省", "湖南省", "河北省", "山东省", "陕西省"}; - String[] cityList = {"北京市", "上海市", "广州市", "南京市", "杭州市", "成都市", "长沙市", "石家庄市", "济南市", "西安市"}; - String[] regionList = {"朝阳区", "浦东新区", "天河区", "玄武区", "拱墅区", "锦江区", "芙蓉区", "桥西区", "历下区", "雁塔区"}; - String[] streetList = {"中山北路", "人民路", "长安街", "南京西路", "华山路", "锦江大道", "芙蓉中路", "胜利大街", "经十路", "雁塔路"}; - String[] numberList = {"1号", "2号", "3号", "4号", "5号", "6号", "7号", "8号", "9号", "10号"}; - String province = provinceList[new Random().nextInt(provinceList.length)]; - String city = cityList[new Random().nextInt(cityList.length)]; - String region = regionList[new Random().nextInt(regionList.length)]; - String street = streetList[new Random().nextInt(streetList.length)]; - String number = numberList[new Random().nextInt(numberList.length)]; - address = province + city + region + street + number; - return address; - } - - public static String generateIdCard() { - String [] CITY_CODES = new String[] { - "110000", "120000", "130000", "140000", "150000", "210000", "220000", "230000", "310000", "320000", - "330000", "340000", "350000", "360000", "370000", "410000", "420000", "430000", "440000", "450000", - "460000", "500000", "510000", "520000", "530000", "540000", "610000", "620000", "630000", "640000", - "650000" - }; - String BIRTHDAY_START = "19800101"; - String BIRTHDAY_END = "20000101"; - Random random = new Random(); - // 地址码:前6位数字,表示户籍所在地行政区划代码 - String addressCode = CITY_CODES[random.nextInt(CITY_CODES.length)]; - // 出生日期码:7到14位数字,表示出生年月日 - LocalDate birthday = LocalDate.ofEpochDay(random.nextInt( - (int)(LocalDate.parse(BIRTHDAY_END, DateTimeFormatter.BASIC_ISO_DATE).toEpochDay() - LocalDate.parse(BIRTHDAY_START, DateTimeFormatter.BASIC_ISO_DATE).toEpochDay()) - ) + LocalDate.parse(BIRTHDAY_START, DateTimeFormatter.BASIC_ISO_DATE).toEpochDay()); - String birthdayCode = birthday.format(DateTimeFormatter.ofPattern("yyyyMMdd")); - // 顺序码:15到17位数字,表示在同一地址码所在区域范围内,对同年同月同日出生的人的顺序编号 - String sequenceCode = String.format("%03d", random.nextInt(1000)); - // 计算校验码 - String body = addressCode + birthdayCode + sequenceCode; - int[] weight = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}; - String[] checkCode = {"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"}; - int sum = 0; - for (int i = 0; i < body.length(); i++) { - sum += (body.charAt(i) - '0') * weight[i]; - } - int remainder = sum % 11; - String checkCodeStr = checkCode[remainder]; - - // 构造身份证号码 - return body + checkCodeStr; - } - - private static char[] lastNames = { '赵', '钱', '孙', '李', '周', '吴', '郑', '王', '冯', '陈', '褚', '卫', '蒋', '沈', '韩', '杨', '朱', '秦', '尤', '许', '何', '吕', '施', '张', '孔', '曹', '严', '华', '金', '魏', '陶', '姜', '戚', '谢', '邹', '喻', '柏', '水', '窦', '章', '云', '苏', '潘', '葛', '奚', '范', '彭', '郎', '鲁', '韦', '昌', '马', '苗', '凤', '花', '方', '俞', '任', '袁', '柳', '酆', '鲍', '史', '唐', '费', '廉', '岑', '薛', '雷', '贺', '倪', '汤', '滕', '殷', '罗', '毕', '郝', '邬', '安', '常', '乐', '于', '时', '傅', '皮', '卞', '齐', '康', '伍', '余', '元', '卜', '顾', '孟', '平', '黄', '和', '穆', '肖', '尹', '营', '姚', '邵', '湛', '汪', '祁', '毛', '禹', '狄', '米', '贝', '明', '臧', '计', '伏', '成', '戴', '谈', '宋', '茅', '庞', '熊', '纪', '舒', '屈', '项', '祝', '董', '粱', '杜', '阮', '蓝', '闵', '席', '季', '麻', '强', '贾', '路', '娄', '危', '江', '童', '颜', '郭', '梅', '盛', '林', '刁', '钟', '徐', '邱', '骆', '高', '夏', '蔡', '田', '樊', '胡', '凌', '霍', '虞', '万', '支', '柯', '昝', '管', '卢', '莫', '经', '房', '裘', '缪', '干', '解', '应', '宗', '丁', '宣', '贲', '郁', '单', '杭', '洪', '包', '诸', '左', '石', '崔', '吉', '钮', '龚', '程', '嵇', '邢', '滑', '裴', '陆', '荣', '翁', '荀', '羊', '於', '惠', '甄', '加', '封', '芮', '麴', '井', '牟', '乘', '裘', '栾', '于', '冷', '甘', '归', '海', '嵩', '福', '景', '祖', '武', '符', '文', '御', '卫', '安', '柴', '颛', '段', '侯', '叶', '孟', '平', '呼', '南', '仇', '胥', '戊', '缑', '雍', '却', '璩', '桑', '桂', '濮', '閻', '充', '慕', '连', '茹', '习', '宦', '艾', '鱼', '容', '向', '古', '易', '慎', '戈', '廖', '庾', '终', '暨', '居', '衡', '步', '都', '耿', '满', '弘', '匡', '国', '文', '寇', '广', '禄', '阙', '东', '欧', '殳', '沃', '利', '蔚', '越', '夔', '隆', '师', '巩', '厍', '聂', '晁', '勾', '敖', '融', '冷', '訾', '辛', '阚', '那', '简', '饶', '空', '曾', '毋', '沙', '乜', '养', '鞠', '须', '丰', '巢', '关', '蒯', '相', '查', '后', '荆', '红', '游', '竺', '权', '逯', '盖', '益', '桓', '公', '牛', '应', '冉', '司', '马'}; - - private static char getRandomChar() { - Random rand = new Random(); - return (char) (0x4e00 + rand.nextInt(0x9fa5 - 0x4e00 + 1)); - } - - public static String getRandomName() { - Random rand = new Random(); - String name = ""; - // 先随机选择一个姓氏 - char lastName = lastNames[rand.nextInt(lastNames.length)]; - name += lastName; - - // 再随机生成1-2个名字 - int nameLen = rand.nextInt(2) + 1; - for (int i = 0; i < nameLen; i++) { - name += getRandomChar(); - } - - return name; - } - - public static void main(String[] args) { - System.out.println(generateIdCard().substring(6, 14)); - System.out.println(getRandomName()); - System.out.println(generateAddress()); - } - } diff --git a/coolstore-partner-webb/src/main/resources/application-ab.properties b/coolstore-partner-webb/src/main/resources/application-ab.properties index 4e26bb2be..ddd3bd6c6 100644 --- a/coolstore-partner-webb/src/main/resources/application-ab.properties +++ b/coolstore-partner-webb/src/main/resources/application-ab.properties @@ -81,5 +81,9 @@ hs.sms.accessKeyId = LTAI4GEZKz9PBqqKa3hjup3W hs.sms.accessKeySecret = iVOiK74k7C1wVbuUbipgJbfpAh1Zdb hs.sms.templateCode = SMS_461530041 +ec.baseUrl=https://oapi-gateway.shpr.top/basic -ec.baseUrl=https://oapi-gateway.shpr.top/basic \ No newline at end of file +#阿里云ak sk +aliyun.accessKeyId=LTAI5t9RaXvABZbHvoXjDFJ1 +aliyun.accessKeySecret=zhOK7WWo3yGoUWkOMaatty19k25CMd +aliyun.authCode=Y81FVZepk6 \ No newline at end of file diff --git a/coolstore-partner-webb/src/main/resources/application-local.properties b/coolstore-partner-webb/src/main/resources/application-local.properties index ed31db487..917b733fc 100644 --- a/coolstore-partner-webb/src/main/resources/application-local.properties +++ b/coolstore-partner-webb/src/main/resources/application-local.properties @@ -85,4 +85,9 @@ xxl.job.accessToken = ec.baseUrl=http://127.0.0.1:8017 #飞书通知 -feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench \ No newline at end of file +feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench + +#阿里云ak sk +aliyun.accessKeyId=LTAI5t9RaXvABZbHvoXjDFJ1 +aliyun.accessKeySecret=zhOK7WWo3yGoUWkOMaatty19k25CMd +aliyun.authCode=Y81FVZepk6 \ No newline at end of file diff --git a/coolstore-partner-webb/src/main/resources/application-online.properties b/coolstore-partner-webb/src/main/resources/application-online.properties index 8981186df..4fa84ad9e 100644 --- a/coolstore-partner-webb/src/main/resources/application-online.properties +++ b/coolstore-partner-webb/src/main/resources/application-online.properties @@ -57,4 +57,9 @@ trtc.video.callback.secretKey=1ECEAD34DBD84E838BF07FC7360EA4D8 weixin.appId=wx6f984e535e571818 weixin.appSecret=245a483747e6e9f8762d3e8539cf0318 -signKey=d851f2a9ac90474abecdc2fbb148d4d7 \ No newline at end of file +signKey=d851f2a9ac90474abecdc2fbb148d4d7 + +#阿里云ak sk +aliyun.accessKeyId= +aliyun.accessKeySecret= +aliyun.authCode= \ No newline at end of file diff --git a/coolstore-partner-webc/src/main/resources/application-ab.properties b/coolstore-partner-webc/src/main/resources/application-ab.properties index 2ec82d81d..ef55e653f 100644 --- a/coolstore-partner-webc/src/main/resources/application-ab.properties +++ b/coolstore-partner-webc/src/main/resources/application-ab.properties @@ -63,4 +63,9 @@ weixin.appSecret=77abdcae754add92889566b543e5ad79 signKey=77fea013c3a6459685b83c21a2fc3411 #飞书通知 -feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench \ No newline at end of file +feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench + +#阿里云ak sk +aliyun.accessKeyId=LTAI5t9RaXvABZbHvoXjDFJ1 +aliyun.accessKeySecret=zhOK7WWo3yGoUWkOMaatty19k25CMd +aliyun.authCode=Y81FVZepk6 \ No newline at end of file diff --git a/coolstore-partner-webc/src/main/resources/application-local.properties b/coolstore-partner-webc/src/main/resources/application-local.properties index 0619f7aa1..14cc8be5d 100644 --- a/coolstore-partner-webc/src/main/resources/application-local.properties +++ b/coolstore-partner-webc/src/main/resources/application-local.properties @@ -66,4 +66,9 @@ weixin.appSecret=77abdcae754add92889566b543e5ad79 signKey=77fea013c3a6459685b83c21a2fc3411 #飞书通知 -feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench \ No newline at end of file +feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench + +#阿里云ak sk +aliyun.accessKeyId=LTAI5t9RaXvABZbHvoXjDFJ1 +aliyun.accessKeySecret=zhOK7WWo3yGoUWkOMaatty19k25CMd +aliyun.authCode=Y81FVZepk6 \ No newline at end of file diff --git a/coolstore-partner-webc/src/main/resources/application-online.properties b/coolstore-partner-webc/src/main/resources/application-online.properties index 08400e97f..966cd77aa 100644 --- a/coolstore-partner-webc/src/main/resources/application-online.properties +++ b/coolstore-partner-webc/src/main/resources/application-online.properties @@ -55,4 +55,9 @@ trtc.secretKey=4854bab106c2ca2a2fda16a8c966933e28a078a34e458999d6227e8cd8ab8219 weixin.appId=wxb2a0addf956ad4b7 weixin.appSecret=77abdcae754add92889566b543e5ad79 -signKey=d851f2a9ac90474abecdc2fbb148d4d7 \ No newline at end of file +signKey=d851f2a9ac90474abecdc2fbb148d4d7 + +#阿里云ak sk +aliyun.accessKeyId= +aliyun.accessKeySecret= +aliyun.authCode= \ No newline at end of file