From 222c206acae8bd6175ab437c27da72c6f8656421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E9=B9=8F=E8=BE=89?= <18322780655@163.com> Date: Fri, 4 Aug 2023 15:54:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8B=89=E5=8D=A1=E6=8B=89?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/system/util/DateUtils.java | 1046 ++++++++++------- newadmin/lkl-service-api/pom.xml | 61 + .../system/lkl/config/LakalaConfig.java | 252 ++++ .../system/lkl/model/AccountVO.java | 32 + .../system/lkl/model/AttchmentsVo.java | 9 + .../system/lkl/model/BankBranchLklVO.java | 18 + .../system/lkl/model/BankCardVO.java | 44 + .../system/lkl/model/BankRegionLklVO.java | 17 + .../system/lkl/model/Constant.java | 250 ++++ .../system/lkl/model/FeesSetVo.java | 10 + .../system/lkl/model/IdCardVO.java | 38 + .../system/lkl/model/MccReflectVO.java | 22 + .../system/lkl/model/MerchantBackLklVO.java | 26 + .../system/lkl/model/MerchantBaseInfoVO.java | 108 ++ .../lkl/model/MerchantChannelStatusVO.java | 90 ++ .../system/lkl/model/MerchantImageVO.java | 25 + .../system/lkl/model/MerchantOrderVO.java | 122 ++ .../system/lkl/model/RegionLklVO.java | 16 + .../lkl/service/MerchantLklService.java | 392 ++++++ .../system/lkl/service/OrderPayService.java | 430 +++++++ .../system/lkl/util/HtmlUtil.java | 129 ++ .../system/lkl/util/StringUtil.java | 407 +++++++ newadmin/pom.xml | 3 +- 23 files changed, 3129 insertions(+), 418 deletions(-) create mode 100644 newadmin/lkl-service-api/pom.xml create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/config/LakalaConfig.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/AccountVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/AttchmentsVo.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankBranchLklVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankCardVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankRegionLklVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/Constant.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/FeesSetVo.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/IdCardVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MccReflectVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantBackLklVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantBaseInfoVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantChannelStatusVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantImageVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantOrderVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/RegionLklVO.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/service/MerchantLklService.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/service/OrderPayService.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/util/HtmlUtil.java create mode 100644 newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/util/StringUtil.java diff --git a/newadmin/common-api/src/main/java/com/chaozhanggui/common/system/util/DateUtils.java b/newadmin/common-api/src/main/java/com/chaozhanggui/common/system/util/DateUtils.java index 47de9d4..5083747 100644 --- a/newadmin/common-api/src/main/java/com/chaozhanggui/common/system/util/DateUtils.java +++ b/newadmin/common-api/src/main/java/com/chaozhanggui/common/system/util/DateUtils.java @@ -1,471 +1,683 @@ package com.chaozhanggui.common.system.util; +import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; +import java.util.*; /** - * Created by SEELE on 2018/4/19. + * @author hkj + * @category @see 日期工具 */ public class DateUtils { - private final static SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); - private final static SimpleDateFormat sdfDay = new SimpleDateFormat("yyyy-MM-dd"); - private final static SimpleDateFormat sdfDays = new SimpleDateFormat("yyyyMMdd"); - private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - private final static SimpleDateFormat sdfTimeSS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - private final static SimpleDateFormat sdfTimes = new SimpleDateFormat("yyyyMMddHHmmss"); - private final static SimpleDateFormat times=new SimpleDateFormat("HH:mm:ss"); + public final static String DEFAULT_FORMAT = "yyyy-MM-dd"; - private final static SimpleDateFormat sdfTimesSS = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + public static String formatDateDefault(Date date, String pattern) { + if (date == null) { + return ""; + } - public static int daysOfTwoDate(String startTime, String endTime) { - SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd"); - Date date1=null; - Date date = null; - Long l = 0L; - try { - date = formatter.parse(startTime); - long startLongTime = date.getTime(); - date1 = formatter.parse(endTime); - long endLongTime = date1.getTime(); + try { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } catch (Exception e) { + return ""; + } + } - l = (endLongTime - startLongTime) / (1000 * 60 * 60 * 24); + /** + * 根据给定的格式化参数,将字符串转换为日期 + * + * @param dateString + * @param dateFormat + * @return java.util.Date + */ + public static Date parse(String dateString, String dateFormat) { + if ("".equals(dateString.trim()) || dateString == null) { + return null; + } + DateFormat sdf = new SimpleDateFormat(dateFormat); + Date date = null; + try { + date = sdf.parse(dateString); - } catch (ParseException e) { - e.printStackTrace(); - } - return l.intValue(); - } + } catch (Exception e) { + e.printStackTrace(); + } - public static Date getNewDate(Date date, Integer type, Integer interval) throws ParseException { - Calendar c = Calendar.getInstance(); - c.setTime(date); - switch (type) { - case 1: - c.set(Calendar.YEAR, (c.get(Calendar.YEAR) + interval)); - break; - case 2: - c.set(Calendar.MONTH, (c.get(Calendar.MONTH) + interval)); - break; - case 3: - c.set(Calendar.DATE, (c.get(Calendar.DATE) + interval)); - break; - case 4: - c.set(Calendar.HOUR, (c.get(Calendar.HOUR) + interval)); - break; - case 5: - c.set(Calendar.MINUTE, (c.get(Calendar.MINUTE) + interval)); - break; - default: - c.set(Calendar.SECOND, (c.get(Calendar.SECOND) + interval)); - break; - } - Date newDate = c.getTime(); - return sdfTime.parse(sdfTime.format(newDate)); - } + return date; + } - public static Date getEndDate(Date date) throws ParseException { - return sdfTime.parse(sdfDay.format(date).concat(" 23:59:59")); - } + /** + * + * 默认将字符串转换为日期,格式(yyyy-MM-dd) + * + * @param dateString + * @return + */ + public static Date parse(String dateString) { + return parse(dateString, DEFAULT_FORMAT); + } - public static Date getNewDateH(Date date, Integer type, Integer interval) throws ParseException { - Calendar c = Calendar.getInstance(); - c.setTime(date); - switch (type) { - case 1: - c.set(Calendar.YEAR, (c.get(Calendar.YEAR) + interval)); - break; - case 2: - c.set(Calendar.MONTH, (c.get(Calendar.MONTH) + interval)); - break; - case 3: - c.set(Calendar.DATE, (c.get(Calendar.DATE) + interval)); - break; - case 4: - c.set(Calendar.HOUR, (c.get(Calendar.HOUR) + interval)); - break; - case 5: - c.set(Calendar.MINUTE, (c.get(Calendar.MINUTE) + interval)); - break; - default: - c.set(Calendar.SECOND, (c.get(Calendar.SECOND) + interval)); - break; - } - Date newDate = c.getTime(); - return sdfDay.parse(sdfDay.format(newDate)); - } + /** + * 根据给定的格式化参数,将日期转换为字符串 + * + * @param date + * @param dateFormat + * @return String + */ + public static String toString(Date date, String dateFormat) { + if ("".equals(date) || date == null) { + return "bug: date is null"; + } + DateFormat sdf = new SimpleDateFormat(dateFormat); + String str = sdf.format(date); - public static String getNewDate2(Date date, Integer type, Integer interval) throws ParseException { - Calendar c = Calendar.getInstance(); - c.setTime(date); - switch (type) { - case 1: - c.set(Calendar.YEAR, (c.get(Calendar.YEAR) + interval)); - break; - case 2: - c.set(Calendar.MONTH, (c.get(Calendar.MONTH) + interval)); - break; - case 3: - c.set(Calendar.DATE, (c.get(Calendar.DATE) + interval)); - break; - case 4: - c.set(Calendar.HOUR, (c.get(Calendar.HOUR) + interval)); - break; - case 5: - c.set(Calendar.MINUTE, (c.get(Calendar.MINUTE) + interval)); - break; - default: - c.set(Calendar.SECOND, (c.get(Calendar.SECOND) + interval)); - break; - } - Date newDate = c.getTime(); - return sdfDay.format(newDate); - } + return str; + } - public static Date getNewDate3(Date date, Integer type, Integer interval) throws ParseException { - Calendar c = Calendar.getInstance(); - c.setTime(date); - switch (type) { - case 1: - c.set(Calendar.YEAR, (c.get(Calendar.YEAR) + interval)); - break; - case 2: - c.set(Calendar.MONTH, (c.get(Calendar.MONTH) + interval)); - break; - case 3: - c.set(Calendar.DATE, (c.get(Calendar.DATE) + interval)); - break; - case 4: - c.set(Calendar.HOUR, (c.get(Calendar.HOUR) + interval)); - break; - case 5: - c.set(Calendar.MINUTE, (c.get(Calendar.MINUTE) + interval)); - break; - default: - c.set(Calendar.SECOND, (c.get(Calendar.SECOND) + interval)); - break; - } - Date newDate = c.getTime(); - return newDate; - } + /** + * 默认将日期转换为字符串,格式(yyyy-MM-dd) + * + * @param date + * @return String + */ + public static String toString(Date date) { + return toString(date, DEFAULT_FORMAT); + } - public static String getNewDate4(Date date, Integer type, Integer interval) throws ParseException { - Calendar c = Calendar.getInstance(); - c.setTime(date); - switch (type) { - case 1: - c.set(Calendar.YEAR, (c.get(Calendar.YEAR) + interval)); - break; - case 2: - c.set(Calendar.MONTH, (c.get(Calendar.MONTH) + interval)); - break; - case 3: - c.set(Calendar.DATE, (c.get(Calendar.DATE) + interval)); - break; - case 4: - c.set(Calendar.HOUR, (c.get(Calendar.HOUR) + interval)); - break; - case 5: - c.set(Calendar.MINUTE, (c.get(Calendar.MINUTE) + interval)); - break; - default: - c.set(Calendar.SECOND, (c.get(Calendar.SECOND) + interval)); - break; - } - Date newDate = c.getTime(); - return sdfDays.format(newDate); - } + /** + * 将日期转换为长整型? + * + * @param date + * @return long + */ + public static long toLong(Date date) { + if (date == null) { + return 0; + } + long d = date.getTime(); - /** - * 获取YYYY格式 - * @return - */ - public static String getSdfTimes() { - return sdfTimes.format(new Date()); - } + return d; + } - public static String getSdfTimesSS() { - return sdfTimesSS.format(new Date()); - } + /** + * 将长整型转换为日期对象 + * + * @param time + * @return date + */ + public static Date toDate(long time) { + if ("".equals(time)) { + return new Date(); + } + Date date = new Date(time); - /** - * 获取YYYY格式 - * @return - */ - public static String getYear() { - return sdfYear.format(new Date()); - } + return date; + } - /** - * 获取YYYY-MM-DD格式 - * @return - */ - public static String getDay() { - return sdfDay.format(new Date()); - } + /** + * 获得系统当前时间 + * + * @return java.util.Date + */ + public static String currentStringDate() { + Date date = new Date(); - /** - * 获取YYYYMMDD格式 - * @return - */ - public static String getDays(){ - return sdfDays.format(new Date()); - } + return toString(date); + } - /** - * 获取YYYY-MM-DD HH:mm:ss格式 - * @return - */ - public static String getTime() { - return sdfTime.format(new Date()); - } + /** + * 获得系统当前时间(按用户自己格式) + * + * @return java.util.Date + */ + public static String currentYourDate(String formate) { + Date date = new Date(); + return toString(date, formate); + } - /** - * @Title: compareDate - * @Description: TODO(日期比较,如果s>=e 返回true 否则返回false) - * @param s - * @param e - * @return boolean - * @throws - * @author fh - */ - public static boolean compareDate(String s, String e) { - if(fomatDate(s)==null||fomatDate(e)==null){ - return false; - } - return fomatDate(s).getTime() >=fomatDate(e).getTime(); - } + public static String currentYourDate() { + Date date = new Date(); + return toString(date, DEFAULT_FORMAT); + } - /** - * 格式化日期 - * @return - */ - public static Date fomatDate(String date) { - DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); - try { - return fmt.parse(date); - } catch (ParseException e) { - e.printStackTrace(); - return null; - } - } + /** + * 获得系统当前时间 + * + * @return java.util.Date + */ + public static Date currentDate() { + Date date = new Date(); - /** - * 校验日期是否合法 - * @return - */ - public static boolean isValidDate(String s) { - DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); - try { - fmt.parse(s); - return true; - } catch (Exception e) { - // 如果throw java.text.ParseException或者NullPointerException,就说明格式不对 - return false; - } - } + return date; + } - /** - * @param startTime - * @param endTime - * @return - */ - public static int getDiffYear(String startTime, String endTime) { - DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); - try { - //long aa=0; - int years=(int) (((fmt.parse(endTime).getTime()-fmt.parse(startTime).getTime())/ (1000 * 60 * 60 * 24))/365); - return years; - } catch (Exception e) { - // 如果throw java.text.ParseException或者NullPointerException,就说明格式不对 - return 0; - } - } + /** + * 根据日历的规则,为给定的日历字段添加或减去指定的时间�? + * + * @param field 指定的日历字段 + * @param date 需要操作的日期对象 + * @param value 更改的时间值 + * @return java.util.Date + */ + public static Date add(int field, Date date, int value) { + Calendar ca = Calendar.getInstance(); + ca.setTime(date); + ca.add(field, value); + Date newDate = ca.getTime(); - /** - *
  • 功能描述:时间相减得到天数 - * @param beginDateStr - * @param endDateStr - * @return - * long - * @author Administrator - */ - public static long getDaySub(String beginDateStr, String endDateStr){ - long day=0; - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - Date beginDate = null; - Date endDate = null; + return newDate; + } - try { - beginDate = format.parse(beginDateStr); - endDate= format.parse(endDateStr); - } catch (ParseException e) { - e.printStackTrace(); - } - day=(endDate.getTime()-beginDate.getTime())/(24*60*60*1000); - //System.out.println("相隔的天数="+day); + /** + * 返回给定日历字段的值 + * + * @param field 指定的日历字段 + * @param date 给定的日期对象 + * @return java.util.Date + */ + public static int get(int field, Date date) { + Calendar ca = Calendar.getInstance(); + ca.setTime(date); + int value = ca.get(field); - return day; - } + return value; + } - /** - * 得到n天之后的日期 - * @param days - * @return - */ - public static String getAfterDayDate(String days) { - int daysInt = Integer.parseInt(days); + /** + * 返回前N个月的日期值 + * + * @param month + * @return + */ + public static Date getLastMonth(String month) { + Calendar ca = Calendar.getInstance(); + int m = 0; + try { + m = Integer.parseInt(month); + } catch (NumberFormatException e) { + e.printStackTrace(); + } + ca.add(Calendar.MONTH, -m); + return ca.getTime(); + } - Calendar canlendar = Calendar.getInstance(); // java.util包 - canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动 - Date date = canlendar.getTime(); + /** + * 返回当前日期的前一天 + * + * @param date + * @return + */ + public static String getPreDate(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.DAY_OF_MONTH, -1); + date = calendar.getTime(); + return toString(date, DEFAULT_FORMAT); + } - SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String dateStr = sdfd.format(date); + /** + * 验证字符串是否匹配日期 + */ + public static boolean isDate(String str, String formate) { + try { + DateFormat sdf = new SimpleDateFormat(formate); + sdf.parse(str); + return true; + } catch (Exception e) { + // 如果throw java.text.ParseException或者NullPointerException,就说明格式不对 + return false; + } + } - return dateStr; - } - /** - * 得到n天之后的日期 - * @param days - * @return - */ - public static String getAfterDate(Date openDate, String days) { - int daysInt = Integer.parseInt(days); + /** + * 获取偏移日期 + * + * @param offset + * @return + */ + public static Date getOffsetDate(int offset) { - Calendar canlendar = Calendar.getInstance(); // java.util包 - canlendar.setTime(openDate); - canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动 - Date date = canlendar.getTime(); - SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String dateStr = sdfd.format(date); - return dateStr; - } - public static String getAfterDate1(Date openDate, String year) { - int daysInt = Integer.parseInt(year); + SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd"); + Date beginDate = new Date(); + Calendar date = Calendar.getInstance(); + date.setTime(beginDate); + date.set(Calendar.DATE, date.get(Calendar.DATE) + offset); + Date endDate = null; + try { + endDate = dft.parse(dft.format(date.getTime())); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return endDate; + } - Calendar canlendar = Calendar.getInstance(); // java.util包 - canlendar.setTime(openDate); - canlendar.add(Calendar.YEAR, daysInt); // 日期减 如果不够减会将月变动 - Date date = canlendar.getTime(); - SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String dateStr = sdfd.format(date); - return dateStr; - } - public static Date getAfterDateStr(Date openDate, String days) { - int daysInt = Integer.parseInt(days); + /** + * 返回日时分秒 + * + * @param second + * @return + */ + public static String secondToTime(long second) { + long days = second / 86400;// 转换天数 + second = second % 86400;// 剩余秒数 + long hours = second / 3600;// 转换小时数 + second = second % 3600;// 剩余秒数 + long minutes = second / 60;// 转换分钟 + second = second % 60;// 剩余秒数 + String min = minutes + ""; + if (minutes < 10) { + min = "0" + minutes; + } + String sec = second + ""; + if (second < 10) { + sec = "0" + second; + } - Calendar canlendar = Calendar.getInstance(); // java.util包 - canlendar.setTime(openDate); - canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动 - Date date = canlendar.getTime(); - return date; - } + if (0 < days) { + return days + "天," + hours + "小时," + minutes + "分," + second + "秒"; + } else { + return hours + ":" + min + ":" + sec; + } + } - /** - * 得到n天之后是周几 - * @param days - * @return - */ - public static String getAfterDayWeek(String days) { - int daysInt = Integer.parseInt(days); - Calendar canlendar = Calendar.getInstance(); // java.util包 - canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动 - Date date = canlendar.getTime(); - SimpleDateFormat sdf = new SimpleDateFormat("E"); - String dateStr = sdf.format(date); - return dateStr; - } + // 获取当天的开始时间 + public static Date getDayBegin() { + Calendar cal = new GregorianCalendar(); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } - /** - * 格式化日期为时分秒 - * @param date - * @return - */ - public static Date fomatDateTime(String date) { - DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - try { - return fmt.parse(date); - } catch (ParseException e) { - e.printStackTrace(); - return null; - } - } + // 获取当天的结束时间 + public static Date getDayEnd() { + Calendar cal = new GregorianCalendar(); + cal.set(Calendar.HOUR_OF_DAY, 23); + cal.set(Calendar.MINUTE, 59); + cal.set(Calendar.SECOND, 59); + cal.set(Calendar.MILLISECOND, 999); + return cal.getTime(); + } - public static String formatDateToStr(Date date) { - return sdfTime.format(date); - } + // 获取昨天的开始时间 + public static Date getBeginDayOfYesterday() { + Calendar cal = new GregorianCalendar(); + cal.setTime(getDayBegin()); + cal.add(Calendar.DAY_OF_MONTH, -1); + return cal.getTime(); + } - /** 功能描述:获取前一天日期 - * @params: [date] - * @return: java.lang.String - * @Author: Administrator - * @Date: 2020-10-09 15:51 - */ - public static String getYsetDate(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.add(Calendar.DATE, -1); - Date start = cal.getTime(); - String day= sdfDay.format(start); - return day; - } + // 获取昨天的结束时间 + public static Date getEndDayOfYesterDay() { + Calendar cal = new GregorianCalendar(); + cal.setTime(getDayEnd()); + cal.add(Calendar.DAY_OF_MONTH, -1); + return cal.getTime(); + } - /** 功能描述:获取前一天日期 - * @params: [date] - * @return: java.lang.String - * @Author: Administrator - * @Date: 2020-10-09 15:51 - */ - public static String getYsetDates(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.add(Calendar.DATE, -1); - Date start = cal.getTime(); - String day= sdfDays.format(start); - return day; - } + // 获取明天的开始时间 + public static Date getBeginDayOfTomorrow() { + Calendar cal = new GregorianCalendar(); + cal.setTime(getDayBegin()); + cal.add(Calendar.DAY_OF_MONTH, 1); + return cal.getTime(); + } - public static boolean getThreadTime(String quittime, String DZtime) { - boolean flag = false; - String quitT[] = quittime.split(":"); - String DZT[] = DZtime.split(":"); - Calendar ca = Calendar.getInstance(); - Calendar ca1 = Calendar.getInstance(); - Calendar ca2 = Calendar.getInstance(); - ca1.set(ca.get(Calendar.YEAR), ca.get(Calendar.MONTH), ca.get(Calendar.DAY_OF_MONTH), Integer.valueOf(quitT[0]), Integer.valueOf(quitT[1]), Integer.valueOf(quitT[2])); - ca2.set(ca.get(Calendar.YEAR), ca.get(Calendar.MONTH), ca.get(Calendar.DAY_OF_MONTH), Integer.valueOf(DZT[0]), Integer.valueOf(DZT[1]), Integer.valueOf(DZT[2])); - if (ca1.after(ca2)) { - if (ca.equals(ca1) || ca.after(ca1) || ca.before(ca2) || ca.equals(ca2)) { - flag = true; - } else { - flag = false; - } - } else if (ca1.before(ca2)) { - if ((ca.equals(ca1) || ca.after(ca1)) && (ca.equals(ca2) || ca.before(ca2))) { - flag = true; - } else { - flag = false; - } - } else if (ca1.equals(ca2)) { - flag = false; - } - return flag; - } + // 获取明天的结束时间 + public static Date getEndDayOfTomorrow() { + Calendar cal = new GregorianCalendar(); + cal.setTime(getDayEnd()); + cal.add(Calendar.DAY_OF_MONTH, 1); + return cal.getTime(); + } + + // 获取本周的开始时间 + public static Date getBeginDayOfWeek() { + Date date = new Date(); + + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + int dayofweek = cal.get(Calendar.DAY_OF_WEEK); + if (dayofweek == 1) { + dayofweek += 7; + } + cal.add(Calendar.DATE, 2 - dayofweek); + return getDayStartTime(cal.getTime()); + } + + // 获取本周的结束时间 + public static Date getEndDayOfWeek() { + Calendar cal = Calendar.getInstance(); + cal.setTime(getBeginDayOfWeek()); + cal.add(Calendar.DAY_OF_WEEK, 6); + Date weekEndSta = cal.getTime(); + return getDayEndTime(weekEndSta); + } + + // 获取本月的开始时间 + public static Date getBeginDayOfMonth() { + Calendar calendar = Calendar.getInstance(); + calendar.set(getNowYear(), getNowMonth() - 1, 1); + return getDayStartTime(calendar.getTime()); + } + + // 获取本月的结束时间 + public static Date getEndDayOfMonth() { + Calendar calendar = Calendar.getInstance(); + calendar.set(getNowYear(), getNowMonth() - 1, 1); + int day = calendar.getActualMaximum(5); + calendar.set(getNowYear(), getNowMonth() - 1, day); + return getDayEndTime(calendar.getTime()); + } + + // 获取本年的开始时间 + public static Date getBeginDayOfYear() { + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, getNowYear()); + // cal.set + cal.set(Calendar.MONTH, Calendar.JANUARY); + cal.set(Calendar.DATE, 1); + + return getDayStartTime(cal.getTime()); + } + + // 获取本年的结束时间 + public static Date getEndDayOfYear() { + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, getNowYear()); + cal.set(Calendar.MONTH, Calendar.DECEMBER); + cal.set(Calendar.DATE, 31); + return getDayEndTime(cal.getTime()); + } + + // 获取某个日期的开始时间 + public static Timestamp getDayStartTime(Date d) { + Calendar calendar = Calendar.getInstance(); + if (null != d) { + calendar.setTime(d); + } + calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, + 0, 0); + calendar.set(Calendar.MILLISECOND, 0); + return new Timestamp(calendar.getTimeInMillis()); + } + + // 获取某个日期的结束时间 + public static Timestamp getDayEndTime(Date d) { + Calendar calendar = Calendar.getInstance(); + if (null != d) { + calendar.setTime(d); + } + calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 23, + 59, 59); + calendar.set(Calendar.MILLISECOND, 999); + return new Timestamp(calendar.getTimeInMillis()); + } + + // 获取今年是哪一年 + public static Integer getNowYear() { + Date date = new Date(); + GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance(); + gc.setTime(date); + return Integer.valueOf(gc.get(1)); + } + + // 获取本月是哪一月 + public static int getNowMonth() { + Date date = new Date(); + GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance(); + gc.setTime(date); + return gc.get(2) + 1; + } + + // 获取上一月的开始时间 + public static Date getBeginDayOfPreMonth() { + Calendar calendar = Calendar.getInstance(); + calendar.set(getNowYear(), getNowMonth() - 2, 1); + return getDayStartTime(calendar.getTime()); + } + + // 获取某个月的开始时间 + public static String getBeginMonth(int i) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal_1 = Calendar.getInstance();// 获取当前日期 + cal_1.add(Calendar.MONTH, i); + cal_1.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天 + String firstDay = format.format(cal_1.getTime()) + " 00:00:00"; + return firstDay; + } + + // 获取某个月的结束时间 + public static String getEndMonth(int i) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cale = Calendar.getInstance(); + cale.add(Calendar.MONTH, i + 1);// 设置为1号,当前日期既为本月第一天 + cale.set(Calendar.DAY_OF_MONTH, 0);// 设置为1号,当前日期既为本月第一天 + String lastDay = format.format(cale.getTime()) + " 23:59:59"; + return lastDay; + } + + // 获取某个月的开始时间 + public static Date getMonth(int i) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal_1 = Calendar.getInstance();// 获取当前日期 + cal_1.add(Calendar.MONTH, i); + cal_1.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天 +// String firstDay = format.format(cal_1.getTime())+" 00:00:00"; + return cal_1.getTime(); + } + + /** + * + * getLastDay:(获取距离指定时间的指定距离天数 的时间 +[正]为后 -[负]为前).
    + * + * @author Administrator + * @param time + * @param i + * @return + * @since JDK 1.8 + */ + public static String getDay(String time,int i){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + Date date=null; + try { + date = sdf.parse(time); + } catch (ParseException e) { + e.printStackTrace(); + } + calendar.setTime(date); + int day=calendar.get(Calendar.DATE); + // 此处修改为+1则是获取后一天 + calendar.set(Calendar.DATE,day+i); + + String lastDay = sdf.format(calendar.getTime()); + return lastDay; + } - public static String getTimes(Date date){ - return times.format(date); - } + /** + * isBoolean:(当前时间大于活动开始时间,并且当前时间小于活动结束时间).
    + * + * @return + * + * @author Administrator + * @since JDK 1.8 + */ + public static boolean isBoolean(Date startTime, Date endTime) { + boolean flag = false; + boolean start = new Date().getTime() >= startTime.getTime(); + boolean end = new Date().getTime() <= endTime.getTime(); + if (start && end) { + flag = true; + } + return flag; + } - public static void main(String[] args){ - System.out.println(getSdfTimesSS()); - } + public static boolean isValidDate(String str) { + boolean convertSuccess=true; + // 指定日期格式为四位年/两位月份/两位日期,注意yyyy/MM/dd区分大小写; + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + // 设置lenient为false. 否则SimpleDateFormat会比较宽松地验证日期,比如2007/02/29会被接受,并转换成2007/03/01 + //format.setLenient(false); + format.parse(str); + } catch (ParseException e) { + // e.printStackTrace(); + // 如果throw java.text.ParseException或者NullPointerException,就说明格式不对 + convertSuccess = false; + } + return convertSuccess; + } + public static List> getLast6Months() throws ParseException { + Calendar c = Calendar.getInstance(); + c.add(Calendar.MONTH, -5); + String before_six = c.get(Calendar.YEAR) + "-" + c.get(Calendar.MONTH);//六个月前 + ArrayList result = new ArrayList(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");// 格式化为年月 + Calendar min = Calendar.getInstance(); + Calendar max = Calendar.getInstance(); + min.setTime(sdf.parse(before_six)); + min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1); + max.setTime(sdf.parse(sdf.format(new Date()))); + max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2); + Calendar curr = min; + while (curr.before(max)) { + result.add(sdf.format(curr.getTime())); + curr.add(Calendar.MONTH, 1); + } + String nowYear = String.valueOf(c.get(Calendar.YEAR)); + List> nowChilds = new ArrayList<>(); + List> prevChilds = new ArrayList<>(); + Map prevYearMap = new HashMap<>(); + Map nowYearMap = new HashMap<>(); + List> yearList = new ArrayList<>(); + for (String o:result) { + String year = o.split("-")[0]; + String month = o.split("-")[1]; + if(nowYear.equals(year)){ + Map childsMap = new HashMap<>(); + childsMap.put("value",month); + nowChilds.add(childsMap); + nowYearMap.put("value",year); + //yearList.add(); + }else{ + Map childsMap = new HashMap<>(); + childsMap.put("value",month); + prevChilds.add(childsMap); + prevYearMap.put("value",year); + } + } + nowYearMap.put("childs",nowChilds); + if(!prevChilds.isEmpty()){ + prevYearMap.put("childs",prevChilds); + yearList.add(prevYearMap); + } + yearList.add(nowYearMap); + return yearList; + } + + /** + * 判断两个时间相差的天数 + * @param date1 + * @param date2 + * @return + */ + public static int differentDaysByMillisecond(Date date1,Date date2) + { + int days = (int) ((date2.getTime() - date1.getTime()) / (1000*3600*24)); + return days; + } + + /** + * 判断两个时间相差的小时数 + * @param date1 + * @param date2 + * @return + */ + public static int differentDaysByHours(Date date1,Date date2) + { + int hours = (int) ((date2.getTime() - date1.getTime()) / (1000*3600)); + return Math.abs(hours); + } + private final static SimpleDateFormat sdfTimes = new SimpleDateFormat("yyyyMMddHHmmss"); + private final static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + + public static String getSdfTimes() { + return sdfTimes.format(new Date()); + } + + public static Date convertDate(String date) { + try { + return sdf.parse(date); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + public static String convertString(String str){ + StringBuilder stringBuilder=new StringBuilder(); + stringBuilder.append(str.substring(0,4)); + stringBuilder.append("-"); + stringBuilder.append(str.substring(4,6)); + stringBuilder.append("-"); + stringBuilder.append(str.substring(6,8)); + return stringBuilder.toString(); + } + + + + public static void main(String[] args) throws ParseException { + + + System.out.println(DateUtils.parse("20230707172528","yyyyMMddHHmmss")); + //List last6Months = getLast6Months(); +// List last6Months = new ArrayList<>(); +// last6Months.add("2019-11"); +// last6Months.add("2019-12"); +// last6Months.add("2020-01"); +// last6Months.add("2020-02"); +// last6Months.add("2020-03"); +// last6Months.add("2020-04"); + /*Calendar c = Calendar.getInstance(); + String nowYear = String.valueOf(c.get(Calendar.YEAR)); + List> nowChilds = new ArrayList<>(); + List> prevChilds = new ArrayList<>(); + + Map prevYearMap = new HashMap<>(); + Map nowYearMap = new HashMap<>(); + List> yearList = new ArrayList<>(); + for (String o:last6Months) { + String year = o.split("-")[0]; + String month = o.split("-")[1]; + if(nowYear.equals(year)){ + Map childsMap = new HashMap<>(); + childsMap.put("value",month); + nowChilds.add(childsMap); + nowYearMap.put("value",year); + //yearList.add(); + }else{ + Map childsMap = new HashMap<>(); + childsMap.put("value",month); + prevChilds.add(childsMap); + prevYearMap.put("value",year); + } + } + nowYearMap.put("childs",nowChilds); + prevYearMap.put("childs",prevChilds); + yearList.add(nowYearMap); + yearList.add(prevYearMap); + System.out.println(yearList);*/ + } + } diff --git a/newadmin/lkl-service-api/pom.xml b/newadmin/lkl-service-api/pom.xml new file mode 100644 index 0000000..18b6dc0 --- /dev/null +++ b/newadmin/lkl-service-api/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + com.chaozhanggui.system + ysk-system + 1.0.0 + + + lkl-service-api + jar + + + 8 + 8 + UTF-8 + + + + + + com.chaozhanggui.system + common-api + 1.0.0 + + + org.springframework + spring-test + + + + org.springframework.boot + spring-boot-starter-freemarker + + + + net.coobird + thumbnailator + 0.4.14 + + + + + org.apache.httpcomponents + httpcore + 4.4.14 + + + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + + + + \ No newline at end of file diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/config/LakalaConfig.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/config/LakalaConfig.java new file mode 100644 index 0000000..e671c6b --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/config/LakalaConfig.java @@ -0,0 +1,252 @@ +package com.chaozhanggui.system.lkl.config; + +import com.alipay.api.internal.util.file.IOUtils; +import com.chaozhanggui.common.system.config.MsgException; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.Base64; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.DefaultHttpClient; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.io.*; +import java.security.*; +import java.security.cert.*; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; + + +@Configuration +@ConfigurationProperties(prefix = "lkl") +@Data +@Slf4j +public class LakalaConfig { + + + /** + * API schema ,固定 LKLAPI-SHA256withRSA + */ + public final static String SCHEMA = "LKLAPI-SHA256withRSA"; + + private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + private static final SecureRandom RANDOM = new SecureRandom(); + + private String privateKey; + private String appletsAppid; + private String appid; + private String mchSerialNo; + private String merchantNo; + private String vposId; + private String termNo; + private String apiUrl; + private String privateKeyPath; + private String certificatePath; + private String returncatePath; + private String callBackUrl; + private String pubKey; + + + + public String request(String body,String mothod) { + String encode = encode("client_id:client_secret".getBytes()); + System.out.println("base64:" + encode); + + try { + + String authorization = getAuthorization(body, this.getAppid(), this.getMchSerialNo(), this.getPrivateKeyPath()); + HttpResponse lakalaResponse = post(this.apiUrl + mothod, body, authorization, "utf-8"); + if (lakalaResponse.getStatusLine().getStatusCode() != 200) { + log.error("请求失败,statusCode:{},message:{}", lakalaResponse.getStatusLine(), IOUtils.toString(lakalaResponse.getEntity().getContent(), "utf-8")); + MsgException.throwException(IOUtils.toString(lakalaResponse.getEntity().getContent(), "utf-8")); + } + + String appid = getHeadValue(lakalaResponse, "Lklapi-Appid"); + String lklapiSerial = getHeadValue(lakalaResponse, "Lklapi-Serial"); + String timestamp = getHeadValue(lakalaResponse, "Lklapi-Timestamp"); + String nonce = getHeadValue(lakalaResponse, "Lklapi-Nonce"); + String signature = getHeadValue(lakalaResponse, "Lklapi-Signature"); + String responseStr = IOUtils.toString(lakalaResponse.getEntity().getContent(), "utf-8"); + log.info("返回的信息为 responseStr:{}", responseStr); + + String source = appid + "\n" + lklapiSerial + "\n" + timestamp + "\n" + nonce + "\n" + responseStr + "\n"; + log.info("请求的数据为:{}", source); + X509Certificate lklCertificate = loadCertificate(new FileInputStream(new File(this.getCertificatePath()))); + boolean verify = verify(lklCertificate, source.getBytes("utf-8"), signature); + + if (verify) { + log.info("验签通过"); + return responseStr; + } else { + return null; + } + + } catch (Exception e) { + e.printStackTrace(); + return null; + } + + } + + + private static String encode(byte[] content) { + return new sun.misc.BASE64Encoder().encode(content); + } + + private static String getHeadValue(HttpResponse response, String key) { + return (response.containsHeader(key)) ? response.getFirstHeader(key).getValue() : ""; + } + + + private static X509Certificate loadCertificate(InputStream inputStream) { + try { + CertificateFactory cf = CertificateFactory.getInstance("X509"); + X509Certificate cert = (X509Certificate) cf.generateCertificate(inputStream); + + cert.checkValidity(); + return cert; + } catch (CertificateExpiredException e) { + throw new RuntimeException("证书已过期", e); + } catch (CertificateNotYetValidException e) { + throw new RuntimeException("证书尚未生效", e); + } catch (CertificateException e) { + throw new RuntimeException("无效的证书", e); + } + } + + private static boolean verify(X509Certificate certificate, byte[] message, String signature) { + try { + Signature sign = Signature.getInstance("SHA256withRSA"); + sign.initVerify(certificate); + sign.update(message); + byte[] signatureB = Base64.decodeBase64(signature); + return sign.verify(signatureB); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("当前Java环境不支持SHA256withRSA", e); + } catch (SignatureException e) { + throw new RuntimeException("签名验证过程发生了错误", e); + } catch (InvalidKeyException e) { + throw new RuntimeException("无效的证书", e); + } + } + + + + private static HttpResponse post(String url, String message, String authorization, String ENCODING) throws Exception { + SSLContext ctx = SSLContext.getInstance("TLS"); + X509TrustManager tm = new X509TrustManager() { + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + @Override + public void checkClientTrusted(X509Certificate[] xcs, String str) { + } + + @Override + public void checkServerTrusted(X509Certificate[] xcs, String str) { + } + }; + HttpClient http = new DefaultHttpClient(); + ClientConnectionManager ccm = http.getConnectionManager(); + ctx.init(null, new TrustManager[]{tm}, null); + SSLSocketFactory ssf = new SSLSocketFactory(ctx); + ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + SchemeRegistry registry = ccm.getSchemeRegistry(); + registry.register(new Scheme("https", ssf, 443)); + HttpPost post = new HttpPost(url); + StringEntity myEntity = new StringEntity(message, ENCODING); + post.setEntity(myEntity); + post.setHeader("Authorization", SCHEMA + " " + authorization); + post.setHeader("Accept", "application/json"); + post.setHeader("Content-Type", "application/json"); + return http.execute(post); + } + + + + private static final String getAuthorization(String body, String appid, String mchSerialNo, String merchantPrivateKeyPath) throws IOException { + String nonceStr = generateNonceStr(); + long timestamp = generateTimestamp(); + + String message = appid + "\n" + mchSerialNo + "\n" + timestamp + "\n" + nonceStr + "\n" + body + "\n"; + + System.out.println("getToken message : " + message); + + PrivateKey merchantPrivateKey = loadPrivateKey(new FileInputStream(new File(merchantPrivateKeyPath))); + + String signature = sign(message.getBytes("utf-8"), merchantPrivateKey); + + String authorization = "appid=\"" + appid + "\"," + "serial_no=\"" + mchSerialNo + "\"," + "timestamp=\"" + + timestamp + "\"," + "nonce_str=\"" + nonceStr + "\"," + "signature=\"" + signature + "\""; + System.out.println("authorization message :" + authorization); + + return authorization; + } + + + private static long generateTimestamp() { + return System.currentTimeMillis() / 1000; + } + + private static String generateNonceStr() { + char[] nonceChars = new char[32]; + for (int index = 0; index < nonceChars.length; ++index) { + nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length())); + } + return new String(nonceChars); + } + + + private static PrivateKey loadPrivateKey(InputStream inputStream) { + try { + ByteArrayOutputStream array = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int length; + while ((length = inputStream.read(buffer)) != -1) { + array.write(buffer, 0, length); + } + + String privateKey = array.toString("utf-8").replace("-----BEGIN PRIVATE KEY-----", "") + .replace("-----END PRIVATE KEY-----", "").replaceAll("\\s+", ""); + KeyFactory kf = KeyFactory.getInstance("RSA"); + return kf.generatePrivate(new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKey))); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("当前Java环境不支持RSA", e); + } catch (InvalidKeySpecException e) { + throw new RuntimeException("无效的密钥格式"); + } catch (IOException e) { + throw new RuntimeException("无效的密钥"); + } + } + + + private static String sign(byte[] message, PrivateKey privateKey) { + try { + Signature sign = Signature.getInstance("SHA256withRSA"); + sign.initSign(privateKey); + sign.update(message); + return new String(Base64.encodeBase64(sign.sign())); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("当前Java环境不支持SHA256withRSA", e); + } catch (SignatureException e) { + throw new RuntimeException("签名计算失败", e); + } catch (InvalidKeyException e) { + throw new RuntimeException("无效的私钥", e); + } + } + + +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/AccountVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/AccountVO.java new file mode 100644 index 0000000..ab110ae --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/AccountVO.java @@ -0,0 +1,32 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class AccountVO implements Serializable { + + private Integer id; + + private String userid; + + private String idcardid; + + private String bankcardid; + + private String certificateurl; + + private String settletype; + + private Date createtime; + + private Date updatetime; + + private String channeltype; + + private Integer valid; + + private String bak; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/AttchmentsVo.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/AttchmentsVo.java new file mode 100644 index 0000000..bc2f409 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/AttchmentsVo.java @@ -0,0 +1,9 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +@Data +public class AttchmentsVo { + private String id; + private String type; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankBranchLklVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankBranchLklVO.java new file mode 100644 index 0000000..7b68703 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankBranchLklVO.java @@ -0,0 +1,18 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class BankBranchLklVO implements Serializable { + private String id; + private String createTime; + private String optimistic; + private String updateTime; + private String areaCode; + private String bankNo; + private String branchBankName; + private String branchBankNo; + private String clearNo; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankCardVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankCardVO.java new file mode 100644 index 0000000..abd5d62 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankCardVO.java @@ -0,0 +1,44 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class BankCardVO implements Serializable { + + private Integer id; + + private String userid; + + private String bankholder; + + private String bankcardno; + + private String bankname; + + private String branchname; + + private String accounttype; + + private String contactline; + + private String branchprovince; + + private String branchcity; + + private String brancharea; + + private String bankaddressno; + + private String phone; + + private String imgurl; + + private String licenseurl; + + private Date createtime; + + private Date updatetime; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankRegionLklVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankRegionLklVO.java new file mode 100644 index 0000000..3cc65b1 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/BankRegionLklVO.java @@ -0,0 +1,17 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class BankRegionLklVO implements Serializable { + + private String id; + private String createTime; + private String optimistic; + private String updateTime; + private String code; + private String name; + private String parentCode; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/Constant.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/Constant.java new file mode 100644 index 0000000..834cafa --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/Constant.java @@ -0,0 +1,250 @@ +package com.chaozhanggui.system.lkl.model; + + +import java.math.BigDecimal; + +public class Constant { + + + public static String INDUSTRY_TYPE = "industry"; + public static String VIDEO_TYPE = "video"; + public static String REQUST_RETIRN_JUMP = ""; + public static String session_user = "session_user"; + + public static String MESSAGE_TYPE_BACK = "back";//回执 + public static String MESSAGE_TYPE_MESSAGE = "message";//消息 + public static String MESSAGE_TYPE_PING = "ping";//心跳 + public static String MESSAGE_TYPE_BIND = "bind";//绑定 + public static String MESSAGE_TYPE_RECEIVE = "receive";//暂存消息 收取 + public static String QR_LIMIT_SCENE = "QR_LIMIT_SCENE";//微信创建二维码 永久 int + + public static String RESULT_CODE_SUCCESS = "SUCCESS";//返回结果成功 + public static String RESULT_CODE_FAIL = "FAIL";//返回结果失败 + public static String RESULT_CODE_NONE = "NONE";//收到回执 什么不用做 + public static String RESULT_CODE_OK = "OK";//服务端已接受 + + public static String FILE_SAVE_PATH = "/home/trade/talkfile/save";//服务端已接受 + + + public static long MESSAGE_PING_CLOCK = 30;//心跳时钟 单位是秒 + + + //支付状态 + public static String PAY_RESULT_CODE_SUCCESS = "1"; + public static String PAY_RESULT_CODE_FAIL = "2"; + public static String PAY_RESULT_CODE_NONE = "0"; + + + //支付方式 + public static final String PAY_TYPE_WECHAT = "wechatPay"; + public static final String PAY_TYPE_NAME_WECHAT = "微信"; + public static final String PAY_TYPE_ALIPAY = "aliPay"; + public static final String PAY_TYPE_NAME_ALIPAY = "支付宝"; + + public static final String PAY_TYPE_YSFPAY = "bank"; + + public static final String PAY_TYPE_NAME_YSFPAY = "云闪付"; + + //订单号前缀 + public final static String PREFIX_ORDER = "11"; + //日期格式 + public final static String WECHATDATEFORMAT = "yyyyMMddHHmmss"; + + public final static String WEIXIN_PAY_UNIFIED_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder"; + + public final static String TENCENT_GET_ADDRESS_URL = "https://apis.map.qq.com/ws/geocoder/v1"; + + public static String sync_type_dml = "dml";//同步类型 + public static String sync_type_ddl = "ddl";//同步类型 + public static String sync_definition_action_insert = "insert"; + public static String sync_definition_action_update = "update"; + public static String sync_definition_action_delete = "delete"; + public static String sync_definition_action_alter = "alter"; + public static String sync_definition_action_create = "create"; + public static String sync_definition_action_save = "save"; + + + public static String sync_definition_entity_MerchantProductCategory = "MerchantProductCategory"; + public static String sync_definition_entity_MerchantProductCombo = "MerchantProductCombo"; + public static String sync_definition_entity_MerchantProduct = "MerchantProduct"; + public static String sync_definition_entity_MerchantRole = "MerchantRole"; + public static String sync_definition_entity_MerchantRoleMenu = "MerchantRoleMenu"; + public static String sync_definition_entity_MerchantRoleUser = "MerchantRoleUser"; + public static String sync_definition_entity_MerchantBaseInfo = "MerchantBaseInfo"; + public static String sync_definition_entity_MerchantArea = "MerchantArea"; + public static String sync_definition_entity_MerchantAreaClass = "MerchantAreaClass"; + + /** + * 百度短信模板 + */ + //注册成功 + public static String baidu_template_regist_success = "smsTpl:6c248ad7-921b-417a-869b-e43a78795700"; + //带评阅 + public static String baidu_template_waitfor_read = "smsTpl:e8e3651a-d7b7-4870-a70a-eeefd18f90eb"; + //参赛成 + public static String baidu_template_join_batter = "smsTpl:c7bcd897-6bee-4822-8823-be0e506ff334"; + //中榜 + public static String baidu_template_on_list = "smsTpl:466d88ca-317e-4af1-875d-d1ebe2258304"; + //评阅成功 + public static String baidu_template_read_success = "smsTpl:591e7f62-8a13-49b8-88b9-7dc9f9f6cf8f"; + /** + * 微信公众号模板 + */ + /** + * 注册成功 + */ + public static String wechat_template_regist_success = " UNeuf5QpriPfLVCJvXLhneBq3NVNQi2KKXIhCIjkz8Y"; + /** + * 待评阅 + */ + public static String wechat_template_waitfor_read = "ncbyBjSDhvF3NQ-25OStNS7lohq_ZI_QLBjpS2Bj7NA"; + /** + * 活动报名成功 + */ + public static String wechat_template_join_batter = "OKX7nmg0YPAicELVQn3DXMtHWowVS1jc0ZdAjmuYVqs"; + /** + * 中榜 + */ + public static String wechat_template_on_list = "9TWvGm19CuV1Wk4fuGu-SUfkuKsR9Yi77OXm234w8Tw"; + /** + * 评阅成功 + */ + public static String wechat_template_read_success = "D6eGbZ8GO36KCXCAe6CwNjG7RRHZxcDDxkOCbeYcIRk"; + /** + * 登录成功提醒 + */ + public static String wechat_template_login_success = "iZugTWBgboOdqttfmHvgv_NR_QTFjp88GREmu5JUC7c"; + + /** + * 充值成功 + */ + public static String wechat_template_pay_success = "3TzSZHbyRMxG3e5x5KxTCMD_BTP8hJHTGllOnSaCpf0"; + /** + * 消费成功 + */ + public static String wechat_consume_success = "JFIaSWscb_KKCHN_3cCO4ctlDrbsRs0MywjScpYk0bA"; + + /** + * 图形验证码key + * @date: 2021/12/20 10:24 + */ + public static final String LOGIN_VALIDATE_CODE = "login_validate_code"; + + /** + * 用户最高等级等级LV10 + * @date: 2022/1/22 15:16 + */ + public static final String USER_MAX_LEVEL_CODE = "LV10"; + + /** + * 最小结算底价 + * @date: 2022/3/9 18:08 + */ + public static final BigDecimal MIX_SETTLE_RATE = BigDecimal.valueOf(21); + + /** + * 缴费通 + * @date: 2022/3/9 18:08 + */ + public static final BigDecimal JFT_MIX_SETTLE_RATE = BigDecimal.valueOf(28); + + /** + * 默认收款商户号 + */ + public static final String DEFUALT_CASHIER_MERCHANT = "M800202207078584958"; + + /** + * 默认收款商户属性key + */ + public static final String SYSTEM_MERCHANT_KEY = "cashier_merchant"; + + /** + * 默认通道 + */ + public static final Integer DEFAULT_CHANNEL = 1; + + /** + * 支付宝H5支付前缀 + */ + public static final String ALIPAY_H5_PAY_URL_PRIFIX = "alipays://platformapi/startapp?appId=2021003175619219&url="; + + /** + * 收款通道类型 + */ + public static final String PAYMENT_CHANNEL_TYPE = "payment_channel_type"; + + /** + * 原生通道 + */ + public static final Integer PRIMORDIAL_CHANNEL = 5; + + /** + * 小程序默认支付路径 + */ + public static final String DEFAULT_APPLET_PATH = "/pages/pay/index"; + + /** + * 小程序默认支付参数名 + */ + public static final String DEFAULT_APPLET_PARAM_NAME_PREFIX = "orderId="; + + /** + * 积分商城用户同步URL + */ + public static final String JF_SHOP_USER_SYNC_URL = "http://jf.shouyinbei.com/addons/shopro/syb_merchant/sysnmerchant"; + /** + * 会员活动(充值活动) + */ + public static final String MEMBER_RECHARGE_ACTIVITY = "http://192.168.1.116/javaApi/java-api/get-vip-sdata"; + + /** + * 会员活动(消费活动) + */ + public static final String MEMBER_CONSUME_ACTIVITY = "http://192.168.1.116/javaApi/java-api/get-vip-xfdata"; + /** + * 会员活动(激活送) + */ + public static final String MEMBER_ACTIVATION_ACTIVITY = "http://192.168.1.116/javaApi/java-api/get-vip-jhdata"; + + /** + * 生活圈会员卡默认过期时间 5(单位分钟) + */ + public static final Integer DEFAULT_LIFE_MEMBER_CARD_REFRESH_TIME = 5; + + /** + * 缴费通成本费率 + */ + public static final BigDecimal DEFAULT_JFT_COST_RATE = BigDecimal.valueOf(30); + + /** + * 缴费通固定提现费率 + */ + public static final BigDecimal DEFAULT_JFT_CASH_RATE = BigDecimal.valueOf(0.001); + + /** + * 缴费通固定提现费 + */ + public static final BigDecimal DEFAULT_JFT_CASH_FEE = BigDecimal.valueOf(0.01); + + + /** + * 银盛交易回传字段key + */ + public static final String YS_PAY_ECHO_KEY_NAME = "extra_common_param"; + + /** + * 随行付回传字段key + */ + public static final String SXF_PAY_ECHO_KEY_NAME = "extend"; + + /** + * 瑞银信交易回传字段 + */ + public static final String RYX_PAY_ECHO_KEY_NAME = "extend1"; + + /** + * 默认秘钥设置 + */ + public static final String DEFAULT_MD5_KEY = "4c8d277b0f274604af68e590cc0b3e6b"; + +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/FeesSetVo.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/FeesSetVo.java new file mode 100644 index 0000000..436c817 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/FeesSetVo.java @@ -0,0 +1,10 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +@Data +public class FeesSetVo { + private String feeCode; + private Double feeValue; + private Double topFee; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/IdCardVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/IdCardVO.java new file mode 100644 index 0000000..2cd3195 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/IdCardVO.java @@ -0,0 +1,38 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class IdCardVO implements Serializable { + + private Integer id; + + private Integer userid; + + private String usertype; + + private String certtype; + + private String certno; + + private String certname; + + private String certstarttime; + + private String certendtime; + + private String certaddress; + + private Date createtime; + + private Date updatetime; + + private String imgpositive; + + private String imgnegative; + + private String virtypeflag; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MccReflectVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MccReflectVO.java new file mode 100644 index 0000000..0cb7514 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MccReflectVO.java @@ -0,0 +1,22 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class MccReflectVO implements Serializable { + + private Integer id; + + private String standardMccCode; + + private String mccCode; + + private Integer channelId; + + private Date createTime; + + private Date updateTime; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantBackLklVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantBackLklVO.java new file mode 100644 index 0000000..d5b3393 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantBackLklVO.java @@ -0,0 +1,26 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class MerchantBackLklVO implements Serializable { + + private Integer id; + private String merchantCode; + private String merchantId; + private String channel; + private String userNo; + private String customerNo; + private String externalCustomerNo; + private String termNos; + private String agencyNo; + private String activeNo; + private String contractId; + private String coreTermIds; + private Date createTime; + private Date updateTime; + +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantBaseInfoVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantBaseInfoVO.java new file mode 100644 index 0000000..0b39b12 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantBaseInfoVO.java @@ -0,0 +1,108 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class MerchantBaseInfoVO implements Serializable { + + + private Integer id; + + private String bindingcode; + + private Integer userid; + + private String aliaccount; + + private String merchantcode; + + private String merchantname; + + private String merchanttype; + + private String productdesc; + + private String alimcc; + + private String mcc; + + private String mccname; + + private String alias; + + private String contactmobile; + + private String contactname; + + private String addressno; + + private String province; + + private String city; + + private String district; + + private String address; + + private String email; + + private String principalmobile; + + private String principalcerttype; + + private String principalcertno; + + private String principalperson; + + private String bussauthname; + + private String bussauthnum; + + private String bussauthaddress; + + private String bussauthstarttime; + + private String bussauthendtime; + + private String certorgcode; + + private Date createdt; + + private Date updatedt; + + private String creator; + + private String buslictype; + + private String isvoice; + + private String allowbanklarge; + + private String wxcertstatus; + + private String ispushwxmessage; + + private String isunionpay; + + private String md5key; + + private String limitpay; + + private String subappid; + + private String appid; + + private Date firsttradetime; + + private Date lasttradetime; + + private Byte splitflag; + + private Byte validflag; + + + +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantChannelStatusVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantChannelStatusVO.java new file mode 100644 index 0000000..5b77363 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantChannelStatusVO.java @@ -0,0 +1,90 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class MerchantChannelStatusVO implements Serializable { + + + //审核中 + public static final String AUDIT_STATUS_EXAMINING = "1"; + + //三方审核中 + public static final String AUDIT_THIRD_STATUS_WAITING = "-100"; + + + /** + * 审核通过 + */ + public static final String AUDIT_STATUS_SUCCESS = "3"; + + public static final String AUDIT_STATUS_DATA_EDIT = "6"; + + /** + * 秒审通过 + */ + public static final String AUDIT_STATUS_FIRST_TRIAL_SUCCESS = "4"; + + private Integer id; + + private Integer channel; + + private String merchantcode; + + private String merchantid; + + private String settlementtype; + + private String status; + + private String thirdstatus; + + private String remark; + + private Date createtime; + + private Date updatetime; + + private String applicationid; + + private String callbackstatus; + + private Integer valid; + + private String authorizationstatus; + + private String mercname; + + private String virchannelflag; + + private String virstatusflag; + + private String srcmerchantno; + + private String interfaceversion; + + private String aliauthorizationstatus; + + private String wxcerturl; + + private String alicerturl; + + private Date auditsuccesstime; + + private String extra; + + + + public static boolean isAudited(MerchantChannelStatusVO mcs) { + if (mcs == null) { + return false; + } + + return MerchantChannelStatusVO.AUDIT_STATUS_SUCCESS.equals(mcs.getStatus()) || + MerchantChannelStatusVO.AUDIT_STATUS_DATA_EDIT.equals(mcs.getStatus()) || + MerchantChannelStatusVO.AUDIT_STATUS_FIRST_TRIAL_SUCCESS.equals(mcs.getStatus()); + } +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantImageVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantImageVO.java new file mode 100644 index 0000000..253ed23 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantImageVO.java @@ -0,0 +1,25 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class MerchantImageVO implements Serializable { + private Integer id; + + private String merchantcode; + + private String phototype; + + private String photourl; + + private String picurl; + + private Date createdt; + + private Date updatedt; + + private String aisleswitch; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantOrderVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantOrderVO.java new file mode 100644 index 0000000..954164a --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/MerchantOrderVO.java @@ -0,0 +1,122 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class MerchantOrderVO implements Serializable { + + private Integer id; + + private String ordernumber; + + private String userimg; + + private String nickname; + + private String ordertype; + + private String merchantcode; + + private String merchantname; + + private String paytypecode; + + private String paytypename; + + private String thirdtransno; + + private String storeid; + + private String storename; + + private Double consumefee; + + private String transno; + + private String membercode; + + private Date createdt; + + private Date transdt; + + private String staffcode; + + private String staffname; + + private String status; + + private Double enterfee; + + private String aisleswitch; + + private String remark; + + private Date updatetime; + + private BigDecimal rate; + + private BigDecimal marketamt; + + private String mercorderno; + + private String mercnotifyurl; + + private String mercuserid; + + private String mercnotifystatus; + + private String mercremark; + + private String isrecharge; + + private String snno; + + private Integer cashplaceid; + + private Boolean settlementtype; + + private Double fanssharemoney; + + private Double profitsharemoney; + + private String drtype; + + private BigDecimal channelrate; + + private BigDecimal channelfee; + + private BigDecimal mercfee; + + private String ip; + + private String ipaddress; + + private String mercreturnurl; + + private String channeltype; + + private Date createdate; + + private Date updatedate; + + private String preauthstatus; + + private BigDecimal refundamt; + + private String refundNo; + + private BigDecimal cashfee; + + private String thirdsendno; + + private String paydata; + + private String scanType; + + private String authCode; + +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/RegionLklVO.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/RegionLklVO.java new file mode 100644 index 0000000..034cc2b --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/model/RegionLklVO.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.lkl.model; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class RegionLklVO implements Serializable { + private String id; + private String createTime; + private String optimistic; + private String updateTime; + private String code; + private String name; + private String parentCode; +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/service/MerchantLklService.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/service/MerchantLklService.java new file mode 100644 index 0000000..4e6bd78 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/service/MerchantLklService.java @@ -0,0 +1,392 @@ +package com.chaozhanggui.system.lkl.service; + + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.extra.template.TemplateException; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.chaozhanggui.common.system.config.MsgException; +import com.chaozhanggui.common.system.util.DateUtils; +import com.chaozhanggui.system.lkl.model.*; +import com.chaozhanggui.system.lkl.util.HtmlUtil; +import lombok.SneakyThrows; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.*; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.stereotype.Service; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.util.ObjectUtils; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentMap; + +@Service +public class MerchantLklService { + + private static final Logger log= LoggerFactory.getLogger(MerchantLklService.class); + public static final String userNo = "22265868"; + + + private static final String client_id = "chaozhanggui"; + private static final String client_secret = "Y54Gqy6aLpxld3dp"; + private static final String grant_type = "client_credentials"; + + + //商户进件地址 + private static final String tuoKeMerchat = "https://htkactvi.lakala.com/registration/merchant"; + + + + //进件接口 + public JSONObject merchantAduit(MerchantBaseInfoVO merchantBaseInfo, MerchantChannelStatusVO merchantChannelStatusVO + , ConcurrentMap regionLklVOConcurrentMap, AccountVO accountVO, BankCardVO bankCardVO,IdCardVO idCardVO + ,ConcurrentMap imageVOConcurrentMap,MccReflectVO mccReflectVO,BankBranchLklVO bankBranchLklVO, + BankRegionLklVO parentCode,BankRegionLklVO bankParentCode + ) throws Exception { + + MsgException.checkNull(merchantBaseInfo,"商户基本信息不存在"); + MsgException.checkNull(merchantChannelStatusVO,"商户未提交审核"); + if (merchantChannelStatusVO.getStatus().equals(MerchantChannelStatusVO.AUDIT_STATUS_EXAMINING) && !merchantChannelStatusVO.getStatus().equals(MerchantChannelStatusVO.AUDIT_THIRD_STATUS_WAITING)) { + MsgException.throwException("进件审核中,请等待审核结果"); + } + + if (merchantChannelStatusVO.isAudited(merchantChannelStatusVO)) { + MsgException.throwException("商户已进件成功,请勿重复进件"); + } + + MsgException.checkNull(regionLklVOConcurrentMap,"商户地址信息不存在"); + MsgException.checkNull(regionLklVOConcurrentMap.get("provinceCode"),"商户省份信息不存在"); + MsgException.checkNull(regionLklVOConcurrentMap.get("cityCode"),"商户城市信息不存在"); + MsgException.checkNull(regionLklVOConcurrentMap.get("countyCode"),"商户区县细信息不存在"); + MsgException.checkNull(accountVO,"商户结算信息未提交"); + MsgException.checkNull(bankCardVO,"商户结算卡信息未提交"); + MsgException.checkNull(idCardVO,"商户基本信息不完整"); + MsgException.checkNull(imageVOConcurrentMap,"商户基本信息不完整"); + MsgException.checkNull(imageVOConcurrentMap.get("BUSINESS_LICENCE"),"商户基本信息不完整"); + MsgException.checkNull(bankBranchLklVO,"结算卡对应的分行支行信息不存在"); + + JSONObject object1 = new JSONObject(); + JSONObject object2 = new JSONObject(); + object1.put("userNo", userNo); //合作机构信息 由拓客SAAS提供 + object1.put("email", "chaozhanggui2023@163.com"); //商户邮箱 + object1.put("busiCode", "KLYX");//业务类型 BPOS:传统POS, ZPOS:电签,ZPOS4G:4G电签,SUPER_POS:智能pos,B_WIZARD:蓝精灵,PAPER_CODE:码牌,WECHAT_PAY:专业化扫码,KLYX:云音箱,QRCODE:收款王,MONEY_BOX:收钱宝盒根据业务开放取值 + object1.put("merRegName", merchantBaseInfo.getAlias()); //商户注册名称 不能少于七个中文 + object1.put("merType", (merchantBaseInfo.getMerchanttype().equals(1) || merchantBaseInfo.getMerchanttype().equals("2")) ? "TP_PERSONAL" : "TP_MERCHANT"); //商户注册类型 TP_MERCHANT:企业 TP_PERSONAL:⼩微个⼈ + object1.put("merName", merchantBaseInfo.getAlias()); //商户名称(经营名称) 不能少于七个中文 + object1.put("merAddr", merchantBaseInfo.getAddress()); //去掉省,市区后的详细地址 + object1.put("provinceCode", regionLklVOConcurrentMap.get("provinceCode").getCode()); //省代码 通过【地区信息→获取地区查询】接口获取 对应 code字段 + object1.put("cityCode", regionLklVOConcurrentMap.get("cityCode").getCode()); // 市代码 通过【地区信息→获取地区查询】接口获取 对应 code字段 + object1.put("countyCode", regionLklVOConcurrentMap.get("countyCode").getCode()); // 区县代码 通过【地区信息→获取地区查询】接口获取 对应 code字段 + Set attchmentsVoSet = new HashSet<>(); + + //企业进件必传资料 + if(merchantBaseInfo.getMerchanttype().equals("3")){ + conventIdCardTime(object1,attchmentsVoSet,merchantBaseInfo,idCardVO,bankCardVO,imageVOConcurrentMap.get("BUSINESS_LICENCE").getPicurl(),bankCardVO.getLicenseurl(),mccReflectVO); + } + + object1.put("latitude", "108.94647"); //经度 进件所在地址经度 + object1.put("longtude", "34.34727"); //纬度 进件所在地址纬度 + object1.put("source", "APP"); //进件来源 APP: app H5: h5 + object1.put("businessContent", merchantBaseInfo.getMccname()); //商户经营内容 + object1.put("larName", idCardVO.getCertname()); //法⼈姓名 + object1.put("larIdType", "01"); //法⼈证件类型 01 身份证 暂时只支持身份证 + object1.put("larIdCard", idCardVO.getCertno()); //法⼈证件号码 + object1.put("larIdCardStart", DateUtils.convertString(idCardVO.getCertstarttime())); //法⼈证件开始⽇期 格式yyyy-MM-dd + object1.put("larIdCardEnd", DateUtils.convertString(idCardVO.getCertendtime())); //法⼈证件过期时间 格式yyyy-MM-dd + object1.put("contactMobile", merchantBaseInfo.getContactmobile()); //商户联系⼈⼿机号码 + object1.put("contactName", merchantBaseInfo.getContactname()); //商户联系⼈姓名 + + + object1.put("openningBankCode", bankBranchLklVO.getBranchBankNo()); //结算账户开户⾏号 通过【银行列表查询】接口获取 对应 branchBankNo字段 + object1.put("openningBankName", bankBranchLklVO.getBranchBankName()); //结算账户开户⾏名称 通过【银行列表查询】接口获取 对应 branchBankName字段 + object1.put("clearingBankCode", bankBranchLklVO.getClearNo()); //结算账户清算⾏号 通过【银行列表查询】接口获取 对应 clearNo字段 + + object1.put("settleProvinceCode", parentCode.getCode()); //结算信息省份名称 通过【地区信息→获取银行地区查询】接口获取 对应 code字段 + object1.put("settleProvinceName", parentCode.getName()); //结算信息省份代码 通过【地区信息→获取银行地区查询】接口获取 对应 name字段 + object1.put("settleCityCode", bankParentCode.getCode()); //结算信息城市名称 通过【地区信息→获取银行地区查询】接口获取 对应 code字段 + object1.put("settleCityName", bankParentCode.getName()); //结算信息城市代码 通过【地区信息→获取银行地区查询】接口获取 对应 name字段 + + if("02".equals(accountVO.getSettletype())){ + AttchmentsVo opening_permit = new AttchmentsVo(); //图片set + opening_permit.setId(laKaLaFileUpload(accountVO.getCertificateurl(), "LETTER_OF_AUTHORIZATION"));//对私非法人授权函 + opening_permit.setType("LETTER_OF_AUTHORIZATION");//对私非法人授权函 + attchmentsVoSet.add(opening_permit); + } + + object1.put("accountNo", bankCardVO.getBankcardno()); //结算人银行卡号 + object1.put("accountName", bankCardVO.getBankholder()); //结算人账户名称 + object1.put("accountType", bankCardVO.getAccounttype().equals("01") ? "58" : "57"); //结算账户类型 57 对公 58 对私 + object1.put("accountIdCard", idCardVO.getCertno()); //结算⼈证件号码 + + if (bankCardVO.getAccounttype().equals("2")) { + //对公收银台照片 + AttchmentsVo checkstand_img = new AttchmentsVo(); + checkstand_img.setId(laKaLaFileUpload(idCardVO.getImgnegative(), "CHECKSTAND_IMG")); //收银台照片 + checkstand_img.setType("CHECKSTAND_IMG");//收银台照片 + attchmentsVoSet.add(checkstand_img); + + + //门头照片 + MerchantImageVO image =imageVOConcurrentMap.get("SHOP_OUTSIDE_IMG"); + MsgException.checkNull(image, "门头照片不存在"); + + AttchmentsVo shop_outside_img = new AttchmentsVo(); + shop_outside_img.setId(laKaLaFileUpload(image.getPicurl(), "SHOP_OUTSIDE_IMG"));//门头照片 + shop_outside_img.setType("SHOP_OUTSIDE_IMG"); + attchmentsVoSet.add(shop_outside_img); + + //商铺内部照片 + image =imageVOConcurrentMap.get("SHOP_INSIDE_IMG"); + MsgException.checkNull(image, "商铺内部照片不存在"); + AttchmentsVo shop_inside_img = new AttchmentsVo(); + + shop_inside_img.setId(laKaLaFileUpload(image.getPicurl(), "SHOP_INSIDE_IMG"));//商铺内部照片 + shop_inside_img.setType("SHOP_INSIDE_IMG"); + attchmentsVoSet.add(shop_inside_img); + } + + JSONArray array = new JSONArray(); + + Set feesSet = new HashSet<>(); + FeesSetVo w = new FeesSetVo(); + w.setFeeCode("WECHAT"); + w.setFeeValue(0.38d); + array.add(w); + + FeesSetVo a = new FeesSetVo(); + a.setFeeCode("ALIPAY"); + a.setFeeValue(0.38d); + array.add(a); + + FeesSetVo u = new FeesSetVo(); + u.setFeeCode("SCAN_PAY_SECOND"); + u.setFeeValue(0.38d); + array.add(u); + feesSet.add(w); + feesSet.add(a); + feesSet.add(u); + + object2.put("termNum", "1"); //终端数量 1-5 最⼤ 5个终端 + object2.put("fees", feesSet); //费率集合 + + object2.put("mcc","12007"); +// object2.put("mcc", ObjectUtils.isEmpty(mccReflect) ? "7399" : mccReflect.getMccCode()); //商户MCC编号 通过 【商户类别查询→查询小类】接口获取 对应 code字段 + object2.put("activityId", "37"); //归属活动信息 由拓客SAAS分配 + object1.put("bizContent", object2); //业务扩展信息 参⻅ 业务扩展信息 + + + AttchmentsVo frontLegalPerson = new AttchmentsVo(); //图片set + frontLegalPerson.setId(laKaLaFileUpload(idCardVO.getImgpositive(), "ID_CARD_FRONT"));//法人身份证图片地址 + frontLegalPerson.setType("ID_CARD_FRONT");//身份证正⾯ + attchmentsVoSet.add(frontLegalPerson); + + AttchmentsVo reverseLegalPerson = new AttchmentsVo(); + reverseLegalPerson.setId(laKaLaFileUpload(idCardVO.getImgnegative(), "ID_CARD_BEHIND")); //法人身份证图片地址 + reverseLegalPerson.setType("ID_CARD_BEHIND");//身份证反⾯ + attchmentsVoSet.add(reverseLegalPerson); + + + object1.put("attchments", attchmentsVoSet); //附件信息集合 参⻅ 附件信息 + object1.put("settleType", "D1"); //结算类型 D0秒到 D1次日结算 + + log.info("请求地址:{},请求参数:{},",tuoKeMerchat,object1); + + Map map = getToken(); + + String result = cn.hutool.http.HttpRequest.post(tuoKeMerchat) + .header("Authorization", "bearer " + map.get("access_token")).header("content-type", "application/json") + .body(object1.toString()).execute().body(); + log.info("拉卡拉返回的进件结果信息:{}",result); + if(ObjectUtil.isEmpty(result)){ + return null; + } + return JSONObject.parseObject(result); + } + + + + + + + + + private void conventIdCardTime(JSONObject jsonObject,Set attchmentsVoSet,MerchantBaseInfoVO merchantBaseInfo,IdCardVO idCardVO,BankCardVO bankCardVO,String businessLicence,String openingPermit,MccReflectVO mccReflect) throws Exception{ + StringBuffer startSb = new StringBuffer(); + StringBuffer endSb = new StringBuffer(); + + if (merchantBaseInfo.getBussauthstarttime().contains("年")) { + startSb.append(merchantBaseInfo.getBussauthstarttime().substring(0, 4)); + startSb.append("-"); + startSb.append(merchantBaseInfo.getBussauthstarttime().substring(5, 7)); + startSb.append("-"); + startSb.append(merchantBaseInfo.getBussauthstarttime().substring(8, 10)); + } else { + startSb.append(merchantBaseInfo.getBussauthstarttime()); + } + + if (ObjectUtil.isEmpty(merchantBaseInfo.getBussauthendtime()) || "长期".equals(merchantBaseInfo.getBuslictype())) { + endSb.append("2099-12-31"); + } else { + if (merchantBaseInfo.getBussauthendtime().contains("年")) { + endSb.append(merchantBaseInfo.getBussauthendtime().substring(0, 4)); + endSb.append("-"); + endSb.append(merchantBaseInfo.getBussauthendtime().substring(5, 7)); + endSb.append("-"); + endSb.append(merchantBaseInfo.getBussauthendtime().substring(8, 10)); + } else { + endSb.append(merchantBaseInfo.getBussauthendtime()); + } + } + + jsonObject.put("licenseDtStart", startSb); //营业执照开始时间⼩微商户可不传, 其他必传,格式yyyy-MM-dd + jsonObject.put("licenseDtEnd", endSb); //⼩微商户可不传, 其他必传,格式yyyy-MM-dd + + + AttchmentsVo business_licence = new AttchmentsVo(); //图片set + business_licence.setId(laKaLaFileUpload(businessLicence, "BUSINESS_LICENCE"));//营业执照 + business_licence.setType("BUSINESS_LICENCE");//营业执照 + attchmentsVoSet.add(business_licence); + + //开户许可证 + AttchmentsVo opening_permit = new AttchmentsVo(); //图片set + + opening_permit.setId(laKaLaFileUpload(openingPermit, "OPENING_PERMIT"));//开户许可证 + opening_permit.setType("OPENING_PERMIT");//开户许可证 + attchmentsVoSet.add(opening_permit); + Map data = new HashMap<>(); + data.put("customerName", merchantBaseInfo.getMerchantname()); + data.put("licenseNo", merchantBaseInfo.getBussauthnum()); + data.put("legalName", idCardVO.getCertname()); + data.put("licenseName", merchantBaseInfo.getMerchantname()); + data.put("identityNo", idCardVO.getCertno()); + data.put("address", merchantBaseInfo.getProvince().concat(merchantBaseInfo.getCity()).concat(merchantBaseInfo.getDistrict())); + data.put("receiveDetail", merchantBaseInfo.getProvince().concat(merchantBaseInfo.getCity()).concat(merchantBaseInfo.getDistrict()).concat(merchantBaseInfo.getAddress())); + data.put("identityNoExpire", endSb); + data.put("accountName", bankCardVO.getBankholder()); + data.put("accountIdCard", idCardVO.getCertno()); + data.put("accountNo", bankCardVO.getBankcardno()); + + data.put("accountIdDtEnd", idCardVO.getCertendtime().equals("长期") ? "2099-12-31" : DateUtils.convertString(idCardVO.getCertendtime())); + data.put("bankName", bankCardVO.getBankname()); + data.put("mail", "chaozhanggui2023@163.com"); + data.put("contactManName", bankCardVO.getPhone()); + data.put("channelType", ObjectUtils.isEmpty(mccReflect) ? "7399" : mccReflect.getMccCode()); + data.put("phone", bankCardVO.getPhone()); + data.put("agencyName", merchantBaseInfo.getMerchantname()); + //协议 + AttchmentsVo agree_ment = new AttchmentsVo(); //图片set + agree_ment.setId(laKaLaFileUpload(HtmlUtil.createAgreementPicture(HtmlUtil.writeHtml(data)),"AGREE_MENT"));//协议 + agree_ment.setType("AGREE_MENT");//协议 + attchmentsVoSet.add(agree_ment); + } + + + + + + @SneakyThrows + public static String laKaLaFileUpload(String url1, String type) { + String url = "https://htkactvi.lakala.com/registration/file/upload"; + Map params = new HashMap<>(); + URI uri = null; + try { + uri = new URI(url1); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + RestTemplate restTemplate1 = new RestTemplate(); + ResponseEntity exchange = restTemplate1.exchange(uri, HttpMethod.GET, null, byte[].class); + MultipartFile file1 = new MockMultipartFile("file", exchange.getBody()); + File file = convert(file1); + + params.put("file", file); + params.put("imgType", type); + params.put("sourcechnl", "0"); + params.put("isOcr", "false"); + + Map token = getToken(); + String result = HttpRequest.post(url) + .header("Authorization", "bearer " + token.get("access_token")) + .form(params).execute().body(); + Map parse = (Map) JSONArray.parse(result); + log.info("拉卡拉图片上传返回信息:{}", result); + return parse.get("url").toString(); + } + + + @SneakyThrows + public static String laKaLaFileUpload(File file, String type) { + String url = "https://htkactvi.lakala.com/registration/file/upload"; + Map params = new HashMap<>(); + + params.put("file", file); + params.put("imgType", type); + params.put("sourcechnl", "0"); + params.put("isOcr", "false"); + + Map token = getToken(); + String result = HttpRequest.post(url) + .header("Authorization", "bearer " + token.get("access_token")) + .form(params).execute().body(); + Map parse = (Map) JSONArray.parse(result); + log.info("拉卡拉图片上传返回信息:{}", result); + return parse.get("url").toString(); + } + + + public static File convert(MultipartFile multipartFile) throws IOException { + InputStream inputStream = multipartFile.getInputStream(); + File file = File.createTempFile(ObjectUtil.isEmpty(multipartFile.getOriginalFilename()) ? System.currentTimeMillis() + "" : multipartFile.getOriginalFilename(), ".png"); + FileOutputStream outputStream = new FileOutputStream(file); + byte[] buffer = new byte[1024]; + int bytesRead = 0; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + outputStream.close(); + file.deleteOnExit(); + return file; + } + + public static Map getToken() { + RestTemplate client = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + // 表单提交 + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + headers.set("Authorization", "Basic " + getBase64()); + // 封装参数 + MultiValueMap params = new LinkedMultiValueMap(); + params.add("grant_type", grant_type); + params.add("client_id", client_id); + params.add("client_secret", client_secret); + HttpEntity> requestEntity = new HttpEntity>(params, headers); + // 执行HTTP请求 + ResponseEntity response = client.exchange("https://tkapi.lakala.com/auth/oauth/token", HttpMethod.POST, requestEntity, String.class); + + Map map = (Map) JSONArray.parse(response.getBody()); + return map; + } + + public static String getBase64() { + + String encodeBase64String = org.apache.commons.codec.binary.Base64.encodeBase64String((client_id + ":" + client_secret).getBytes()); + + return encodeBase64String; + } + + +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/service/OrderPayService.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/service/OrderPayService.java new file mode 100644 index 0000000..eac0eae --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/service/OrderPayService.java @@ -0,0 +1,430 @@ +package com.chaozhanggui.system.lkl.service; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.chaozhanggui.common.system.config.MsgException; +import com.chaozhanggui.common.system.util.DateUtils; +import com.chaozhanggui.system.lkl.config.LakalaConfig; +import com.chaozhanggui.system.lkl.model.*; +import com.chaozhanggui.system.lkl.util.StringUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.Map; + +@Service +@Slf4j +public class OrderPayService { + + + @Autowired + LakalaConfig lakalaConfig; + + private static long changeY2F(double price) { + DecimalFormat df = new DecimalFormat("#.00"); + price = Double.valueOf(df.format(price)); + long money = (long)(price * 100); + return money; + } + + + /** + * 被扫 + * @param orderVO + * @param statusVO + * @param baseInfoVO + * @param merchantBackLklVO + * @return + */ + public JSONObject tradePay(MerchantOrderVO orderVO, MerchantChannelStatusVO statusVO, MerchantBaseInfoVO baseInfoVO, MerchantBackLklVO merchantBackLklVO){ + + MsgException.checkNull(orderVO, "订单信息为空"); + MsgException.checkNull(statusVO, "进件信息为空"); + MsgException.checkNull(baseInfoVO, "商户基本信息为空"); + MsgException.checkNull(merchantBackLklVO, "拉卡拉渠道信息为空"); + String account_type = "WECHAT"; + if (ObjectUtil.isNotEmpty(orderVO.getScanType()) && "01".equals(orderVO.getScanType())) { + account_type = "wechatPay".equals(orderVO.getPaytypecode()) ? "WECHAT" : "aliPay".equals(orderVO.getPaytypecode()) ? "ALIPAY" : "UQRCODEPAY"; + } else { + account_type = "wechatPay".equals(orderVO.getPaytypecode()) ? "WECHAT" : "aliPay".equals(orderVO.getPaytypecode()) ? "ALIPAY" : "UQRCODEPAY"; + } + String transType = account_type.equals("WECHAT") ? "71" : account_type.equals("ALIPAY") ? "41" : "51"; + + + + String req_time = DateUtils.getSdfTimes(); + + Long order_amt = changeY2F(orderVO.getConsumefee()); + String body = null; + if (account_type.equals("WECHAT")) { + body="{\n" + + "\t\"out_org_code\": \""+lakalaConfig.getAppid()+"\",\n" + + "\t\"req_data\": {\n" + + "\t\t\"acc_busi_fields\": {\n" + + "\t\t\t\"user_id\": \""+orderVO.getMercuserid()+"\",\n" + + "\t\t\t\"sub_appid\": \""+lakalaConfig.getAppletsAppid()+"\"\n" + + "\t\t},\n" + + "\t\t\"account_type\": \""+account_type+"\",\n" + + "\t\t\"location_info\": {\n" + + "\t\t\t\"request_ip\": \""+orderVO.getIp()+"\"\n" + + "\t\t},\n" + + "\t\t\"merchant_no\": \""+merchantBackLklVO.getExternalCustomerNo()+"\",\n" + + "\t\t\"notify_url\": \""+lakalaConfig.getCallBackUrl()+"\",\n" + + "\t\t\"out_trade_no\": \""+orderVO.getOrdernumber()+"\",\n" + + "\t\t\"term_no\": \""+merchantBackLklVO.getTermNos()+"\",\n" + + "\t\t\"total_amount\": \""+order_amt+"\",\n" + + "\t\t\"trans_type\": \""+transType+"\"\n" + + "\t},\n" + + "\t\"req_time\": \""+req_time+"\",\n" + + "\t\"version\": \"3.0\"\n" + + "}"; + + } + + if (account_type.equals("ALIPAY")) { + body = "{\n" + + "\t\"out_org_code\": \"" + lakalaConfig.getAppid() + "\",\n" + + "\t\"req_data\": {\n" + + "\t\t\"account_type\": \"" + account_type + "\",\n" + + "\t\t\"location_info\": {\n" + + "\t\t\t\"request_ip\": \"" + orderVO.getIp() + "\"\n" + + "\t\t},\n" + + "\t\t\"merchant_no\": \"" + merchantBackLklVO.getExternalCustomerNo() + "\",\n" + + "\t\t\"notify_url\": \"" + lakalaConfig.getCallBackUrl() + "\",\n" + + "\t\t\"out_trade_no\": \"" + orderVO.getOrdernumber() + "\",\n" + + "\t\t\"term_no\": \"" + merchantBackLklVO.getTermNos() + "\",\n" + + "\t\t\"total_amount\": \"" + order_amt + "\",\n" + + "\t\t\"trans_type\": \"" + transType + "\"\n" + + "\t},\n" + + "\t\"req_time\": \"" + req_time + "\",\n" + + "\t\"version\": \"3.0\"\n" + + "}"; + } + + + String response = lakalaConfig.request(body, "api/v3/labs/trans/preorder"); + + + JSONObject resp = new JSONObject(); + if (ObjectUtil.isNotEmpty(response)) { + JSONObject payData = new JSONObject(); + JSONObject object = JSONObject.parseObject(response); + + if (object.containsKey("code") && "BBS00000".equals(object.getString("code"))) { + if (!(ObjectUtil.isNotEmpty(orderVO.getScanType()) && "01".equals(orderVO.getScanType()))) { + JSONObject acc_resp_fields = object.getJSONObject("resp_data").getJSONObject("acc_resp_fields"); + if (Constant.PAY_TYPE_ALIPAY.equals(orderVO.getPaytypecode())) { + payData.put("source", acc_resp_fields.getString("code")); + } else if (Constant.PAY_TYPE_WECHAT.equals(orderVO.getPaytypecode())) { + + payData.put("payAppId", acc_resp_fields.getString("app_id")); + payData.put("payTimeStamp", acc_resp_fields.getString("time_stamp")); + payData.put("paynonceStr", acc_resp_fields.getString("nonce_str")); + payData.put("payPackage", acc_resp_fields.getString("package")); + payData.put("paySignType", acc_resp_fields.getString("sign_type")); + payData.put("paySign", acc_resp_fields.getString("pay_sign")); + } else { + payData.put("redirectUrl", acc_resp_fields.containsKey("redirect_url") ? acc_resp_fields.getString("redirect_url") : null); + } + + } else { + payData.put("payUrl", object.get("code")); + payData.put("orderNumber", orderVO.getOrdernumber()); + payData.put("mercOrderNo", orderVO.getMercorderno()); + } + resp.put("code", 200); + payData.put("channel", statusVO.getChannel()); + payData.put("transNo",(object.getJSONObject("resp_data").containsKey("log_no") && ObjectUtil.isNotEmpty(object.getJSONObject("resp_data").getString("log_no"))) ? object.getString("log_no") : ""); + resp.put("payData", payData); + return resp; + + } else if (object.containsKey("code") && "BBS16270".equals(object.getString("code"))) { + resp.put("code", 400); + resp.put("msg", object.getString("msg")); + return resp; + } + } + + + resp.put("code", 400); + resp.put("msg", "失败"); + return resp; + + } + + + /** + * 主扫 + * @param orderVO + * @param baseInfoVO + * @param merchantBackLklVO + * @return + */ + public JSONObject tradePay(MerchantOrderVO orderVO, MerchantBaseInfoVO baseInfoVO, MerchantBackLklVO merchantBackLklVO){ + + MsgException.checkNull(orderVO, "订单信息为空"); + MsgException.checkNull(baseInfoVO, "商户基本信息为空"); + MsgException.checkNull(merchantBackLklVO, "拉卡拉渠道信息为空"); + + JSONObject obj = new JSONObject(6); + + String req_time = DateUtils.getSdfTimes(); + Long order_amt = changeY2F(orderVO.getConsumefee()); + + String body = "{\n" + + "\t\"req_data\": {\n" + + "\t\t\"merchant_no\": \"" + merchantBackLklVO.getExternalCustomerNo() + "\",\n" + + "\t\t\"term_no\": \"" + merchantBackLklVO.getTermNos() + "\",\n" + + "\t\t\"out_trade_no\": \"" + orderVO.getOrdernumber() + "\",\n" + + "\t\t\"total_amount\": \"" + order_amt + "\",\n" + + "\t\t\"subject\": \"" + baseInfoVO.getMccname() + "\",\n" + + "\t\t\"acc_busi_fields\": {},\n" + + "\t\t\"notify_url\": \"" + lakalaConfig.getCallBackUrl() + "\",\n" + + "\t\t\"location_info\": {\n" + + "\t\t\t\"request_ip\": \"" + orderVO.getIp() + "\"\n" + + "\t\t},\n" + + "\t\t\"auth_code\": \"" + orderVO.getAuthCode() + "\"\n" + + "\t},\n" + + "\t\"out_org_code\": \"" + lakalaConfig.getAppid() + "\",\n" + + "\t\"version\": \"3.0\",\n" + + "\t\"req_time\": " + req_time + "\n" + + "}"; + + + String response = lakalaConfig.request(body, "api/v3/labs/trans/micropay"); + if (ObjectUtil.isNotEmpty(response)) { + JSONObject object = JSON.parseObject(response); + if (object.containsKey("code") && "BBS10000".equals(object.get("code"))) { + obj.put("code", 202); + obj.put("msg", "用户支付中"); + obj.put("channelOrderNo", object.getJSONObject("resp_data").get("trade_no")); + obj.put("transNo", object.getJSONObject("resp_data").get("log_no")); + obj.put("payStatus", "7"); + return obj; + } else if (object.containsKey("code") && "BBS00000".equals(object.get("code"))) { + obj.put("code", 200); + obj.put("msg", "成功"); + obj.put("channelOrderNo", object.getJSONObject("resp_data").get("trade_no")); + obj.put("transNo", object.getJSONObject("resp_data").get("log_no")); + obj.put("payStatus", "1"); + obj.put("payTime", DateUtils.convertDate(object.getJSONObject("resp_data").getString("trade_time"))); + return obj; + } else { + obj.put("code", 400); + obj.put("msg", object.get("msg")); + return obj; + } + } + obj.put("code", 400); + obj.put("msg", "失败"); + return obj; + } + + + /** + * 退款 + * @param orderVO + * @param merchantBackLklVO + * @return + */ + public Map refundPay(MerchantOrderVO orderVO,MerchantBackLklVO merchantBackLklVO){ + + + MsgException.checkNull(orderVO, "订单信息为空"); + MsgException.checkNull(merchantBackLklVO, "拉卡拉渠道信息为空"); + + String req_time = DateUtils.getSdfTimes(); + Long order_amt = changeY2F(orderVO.getConsumefee()); + + + String refundNo = "LKLR" + StringUtil.getBillno(); + + String body="{\n" + + " \"req_time\":\""+req_time+"\",\n" + + " \"version\":\"3.0\",\n" + + " \"out_org_code\":\""+lakalaConfig.getAppid()+"\",\n" + + " \"req_data\":{\n" + + " \"merchant_no\":\""+merchantBackLklVO.getExternalCustomerNo()+"\",\n" + + " \"term_no\":\""+merchantBackLklVO.getTermNos()+"\",\n" + + " \"out_trade_no\":\""+refundNo+"\",\n" + + " \"refund_amount\":\""+order_amt+"\",\n" + + " \"refund_reason\":\"退款\",\n" + + " \"origin_out_trade_no\":\""+orderVO.getOrdernumber()+"\",\n" + + " \"location_info\":{\n" + + " \"request_ip\":\""+orderVO.getIp()+"\",\n" + + " \"location\":\"+37.123456789,-121.123456789\"\n" + + " }\n" + + " }\n" + + "}\n" + + "\n"; + + Map result = new HashMap<>(4); + result.put("refundNo", refundNo); + result.put("status", "3"); + result.put("code", 400); + + String response = lakalaConfig.request(body, "api/v3/labs/relation/refund"); + if(ObjectUtil.isNotEmpty(response)){ + JSONObject object=JSONObject.parseObject(response); + if(object.containsKey("code")&&"BBS00000".equals(object.getString("code"))){ + result.put("msg", "退款成功!"); + result.put("data", object.getJSONObject("resp_data")); + result.put("status", "1"); + result.put("code", 200); + return result; + }else { + result.put("msg", object.getString("msg")); + return result; + } + } + result.put("msg", "退款失败!"); + return result; + } + + /** + * 订单查询 + * @param orderVO + * @param merchantBackLklVO + * @return + */ + public JSONObject tradeQuery(MerchantOrderVO orderVO, MerchantBackLklVO merchantBackLklVO) { + + MsgException.checkNull(orderVO, "订单信息为空"); + MsgException.checkNull(merchantBackLklVO, "拉卡拉渠道信息为空"); + + String req_time = DateUtils.getSdfTimes(); + + String body = "{\n" + + "\"req_time\":\"" + req_time + "\",\n" + + "\"version\":\"3.0\",\n" + + "\"out_org_code\":\"" + lakalaConfig.getAppid() + "\",\n" + + "\"req_data\":{\n" + + "\"merchant_no\":\"" + merchantBackLklVO.getExternalCustomerNo() + "\",\n" + + "\"term_no\":\"" + merchantBackLklVO.getTermNos() + "\",\n" + + "\"out_trade_no\":\"" + orderVO.getOrdernumber() + "\"\n" + + "}\n" + + "}\n"; + + JSONObject result = new JSONObject(); + String response = lakalaConfig.request(body, "api/v3/labs/query/tradequery"); + if (ObjectUtil.isNotEmpty(response)) { + JSONObject object = JSONObject.parseObject(response); + if (object.containsKey("code") && "BBS00000".equals(object.getString("code"))) { + result.put("channelOrderNo", object.get("trade_no")); + result.put("payTime", DateUtils.parse(object.getString("trade_time"), "yyyyMMddHHmmss")); + result.put("transNo", object.get("log_no")); + result.put("code", 200); + result.put("payStatus", "1"); + result.put("msg", "查询成功!"); + result.put("buyerId", object.get("user_id1")); + return result; + } else { + result.put("code", 400); + result.put("msg", object.getString("msg")); + return result; + } + } + log.error("==============>【拉卡拉】交易订单查询失败<=================="); + result.put("code", 400); + result.put("msg", "订单查询异常"); + return result; + } + + + public JSONObject refundQuery(MerchantOrderVO orderVO,MerchantBackLklVO merchantBackLklVO) { + + MsgException.checkNull(orderVO, "订单信息为空"); + MsgException.checkNull(merchantBackLklVO, "拉卡拉渠道信息为空"); + + + String req_time = DateUtils.getSdfTimes(); + + String body="{\n" + + " \"req_time\":\""+req_time+"\",\n" + + " \"version\":\"3.0\",\n" + + " \"out_org_code\":\""+lakalaConfig.getAppid()+"\",\n" + + " \"req_data\":{\n" + + " \"merchant_no\":\""+merchantBackLklVO.getExternalCustomerNo()+"\",\n" + + " \"term_no\":\""+merchantBackLklVO.getTermNos()+"\",\n" + + " \"out_refund_order_no\":\""+orderVO.getRefundNo()+"\"\n" + + " }\n" + + "}\n" + + "\n"; + + JSONObject result = new JSONObject(); + String response = lakalaConfig.request(body, "api/v3/labs/query/idmrefundquery"); + if (ObjectUtil.isNotEmpty(response)) { + JSONObject object = JSONObject.parseObject(response); + if (object.containsKey("code") && "BBS00000".equals(object.getString("code"))) { + result.put("refundTime", object.getString("trade_time")); + result.put("code", 200); + result.put("status", "1"); + result.put("msg", "查询成功!"); + return result; + } else { + result.put("code", 400); + result.put("msg", object.getString("msg")); + return result; + } + } + log.error("==============>【拉卡拉】交易订单查询失败<=================="); + result.put("code", 400); + result.put("msg", "退款订单查询异常"); + return result; + } + + + /** + * 微信获取用户标识 + * @param userAuthCode + * @param paymentApp + * @param merchantBackLklVO + * @return + * @throws Exception + */ + public Map getUnionInfo(String userAuthCode, String paymentApp,MerchantBackLklVO merchantBackLklVO) throws Exception { + Map result = new HashMap<>(); + String req_time = DateUtils.getSdfTimes(); + + MsgException.checkNull(merchantBackLklVO, "拉卡拉渠道信息为空"); + + String body = "{\n" + + "\"ver\":\"1.0.0\",\n" + + "\"timestamp\":\"" + System.currentTimeMillis() + "\",\n" + + "\"reqId\":\"" + req_time + "\",\n" + + "\"reqData\":{\n" + + "\"mercId\":\"" + merchantBackLklVO.getExternalCustomerNo() + "\",\n" + + "\"termNo\":\"" + merchantBackLklVO.getTermNos() + "\",\n" + + "\"authCode\":\"" + userAuthCode + "\",\n" + + "\"tradeCode\":\"030304\"\n" + + "}\n" + + "}\n"; + String response = lakalaConfig.request(body, "api/v2/saas/query/wx_openid_query"); + if (ObjectUtil.isNotEmpty(response)) { + JSONObject object = JSONObject.parseObject(response); + if (object.containsKey("retCode") && "BBS00000".equals(object.getString("retCode"))) { + + JSONObject reqData = new JSONObject(2); + reqData.put("data", object.getJSONObject("respData").getString("openId")); + reqData.put("userAuthCode", userAuthCode); + reqData.put("appUpIdentifier", paymentApp); + result.put("data", reqData); + result.put("code", "1"); + result.put("msg", "获取成功"); + } + } + result.put("code","0"); + result.put("msg", "获取失败"); + return result; + } + + + + + + +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/util/HtmlUtil.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/util/HtmlUtil.java new file mode 100644 index 0000000..fa471d4 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/util/HtmlUtil.java @@ -0,0 +1,129 @@ +package com.chaozhanggui.system.lkl.util; + +import cn.hutool.core.io.FileUtil; +import freemarker.template.Template; +import freemarker.template.TemplateException; +import lombok.extern.slf4j.Slf4j; +import net.coobird.thumbnailator.Thumbnails; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; + +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +@Component +@Slf4j +public class HtmlUtil { + + @Autowired + FreeMarkerConfigurer freeMarkerConfigurer; + static Template template =null; + + + public void initHtml(){ + try { + template = freeMarkerConfigurer.getConfiguration().getTemplate("indexHTKWECHAT_PAY.html"); + + System.out.println(template.getName()); + + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + + //html 替换占位符 + public static File writeHtml(Map data) throws IOException, TemplateException { + String fileName = UUID.randomUUID().toString(); + File htmlFile = new File(FileUtil.getTmpDir(), fileName + ".html"); + FileWriter sw = new FileWriter(htmlFile); + log.info("生成协议html, 地址:{}, 参数:{} ", htmlFile.getAbsolutePath(), data); + template.process(data, sw); + return htmlFile; + } + + + //html 转png 示例代码 + public static File createAgreementPicture(File htmlFile) throws IOException { + File outputFile = new File(FileUtil.getTmpDir(), htmlFile.getName() + ".jpg"); + log.info("生成图片开始, HTML地址 {}, 图片地址:{}", htmlFile.getAbsolutePath(), outputFile.getAbsolutePath()); + String commandProcess = "wkhtmltoimage --width 400 --quality 94 " + htmlFile.getPath() + " " + outputFile.getPath(); + log.info("协议执行procommand:{}", commandProcess); + long startTime = System.currentTimeMillis(); //获取开始时间 + Process process = Runtime.getRuntime().exec(commandProcess); + try { + int exitVal = process.waitFor(); + log.info("协议html转换png结果:{}", exitVal); + } catch (InterruptedException e) { + e.printStackTrace(); + log.info("协议html转换png错误:{}", e.getMessage()); + throw new IOException(e); + } + long endTime = System.currentTimeMillis(); //获取结束时间 + log.info("程序运行时间: " + (endTime - startTime) + "ms"); + log.info("生成图片结束,地址: {}", outputFile.getPath()); + Thumbnails.of(outputFile).scale(1).outputQuality(0.9).toFile(outputFile); + return outputFile; + } + + + // 合并两张图片示例代码 + public BufferedImage mergeImage(BufferedImage img1, BufferedImage img2, boolean isHorizontal) throws IOException { + int w1 = img1.getWidth(); + int h1 = img1.getHeight(); + int w2 = img2.getWidth(); + int h2 = img2.getHeight(); + // 从图片中读取RGB + int[] ImageArrayOne = new int[w1 * h1]; + ImageArrayOne = img1.getRGB(0, 0, w1, h1, ImageArrayOne, 0, w1); // 逐行扫描图像中各个像素的RGB到数组中 + int[] ImageArrayTwo = new int[w2 * h2]; + ImageArrayTwo = img2.getRGB(0, 0, w2, h2, ImageArrayTwo, 0, w2); + // 生成新图片 + BufferedImage DestImage = null; + if (isHorizontal) { // 水平方向合并 + // DestImage = new BufferedImage(w1+w2, h1, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = null; + if (h1 >= h2) { + DestImage = new BufferedImage(w1 + w2, h1, BufferedImage.TYPE_INT_RGB); + g2d = DestImage.createGraphics(); + g2d.setPaint(Color.WHITE); + g2d.fillRect(0, 0, w1 + w2, h1); + g2d.dispose(); + } else { + DestImage = new BufferedImage(w2, h1, BufferedImage.TYPE_INT_RGB);// TYPE_INT_RGB + g2d = DestImage.createGraphics(); + g2d.setPaint(Color.WHITE); + g2d.fillRect(0, 0, w2 + w1, h1); + g2d.dispose(); + } + DestImage.setRGB(0, 0, w1, h1, ImageArrayOne, 0, w1); // 设置上半部分或左半部分的RGB + DestImage.setRGB(w1, 0, w2, h2, ImageArrayTwo, 0, w2); + } else { // 垂直方向合并 + Graphics2D g2d = null; + if (w1 >= w2) { + DestImage = new BufferedImage(w1, h1 + h2, BufferedImage.TYPE_INT_RGB);// TYPE_INT_RGB + g2d = DestImage.createGraphics(); + g2d.setPaint(Color.WHITE); + g2d.fillRect(0, 0, w1 + w2, h1 + h2); + g2d.dispose(); + } else { + DestImage = new BufferedImage(w2, h1 + h2, BufferedImage.TYPE_INT_RGB);// TYPE_INT_RGB + g2d = DestImage.createGraphics(); + g2d.setPaint(Color.WHITE); + g2d.fillRect(0, 0, w2 + w1, h1 + h2); + g2d.dispose(); + } + DestImage.setRGB(0, 0, w1, h1, ImageArrayOne, 0, w1); // 设置上半部分或左半部分的RGB + DestImage.setRGB(0, h1, w2, h2, ImageArrayTwo, 0, w2); // 设置下半部分的RGB + } + return DestImage; + } + +} diff --git a/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/util/StringUtil.java b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/util/StringUtil.java new file mode 100644 index 0000000..24f9f31 --- /dev/null +++ b/newadmin/lkl-service-api/src/main/java/com/chaozhanggui/system/lkl/util/StringUtil.java @@ -0,0 +1,407 @@ +package com.chaozhanggui.system.lkl.util; + +import cn.hutool.crypto.digest.MD5; +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class StringUtil extends StringUtils { + + /** + * 根据身份证号获取性别 + * + * @param certNo 身份证号 + * @return 0 男;1 女 + */ + public static String getSexFromCertNo(String certNo) { + String in17 = String.valueOf(certNo.charAt(16)); + int intIn17 = Integer.parseInt(in17); + return (intIn17 % 2) >= 1 ? "0" : "1"; + } + + public static final String letterChar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + public static String random6() { + Random random = new Random(); + String result = ""; + for (int i = 0; i < 6; i++) { + result += random.nextInt(10); + } + return result; + } + + public static String random6V2() { + return new MD5().digestHex(UUID.randomUUID().toString()).substring(0, 6); + } + + public static String random(int length) { + Random random = new Random(); + String result = ""; + for (int i = 0; i < length; i++) { + result += random.nextInt(10); + } + return result; + } + + //生产随机8位userCode + public static String genRandomNum() { + int maxNum = 36; + int i; + int count = 0; + char[] str = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', + 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; + StringBuffer pwd = new StringBuffer(""); + Random r = new Random(); + while (count < 8) { + i = Math.abs(r.nextInt(maxNum)); + if (i >= 0 && i < str.length) { + pwd.append(str[i]); + count++; + } + } + return pwd.toString(); + } + + //生成指定长度的随机数 + public static String genRandomNum(int length) { + int maxNum = 36; + int i; + int count = 0; + char[] str = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', + 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; + StringBuffer pwd = new StringBuffer(""); + Random r = new Random(); + while (count < length) { + i = Math.abs(r.nextInt(maxNum)); + pwd.append(str[i]); + count++; + } + return pwd.toString(); + } + + public static String genUuid(){ + return UUID.randomUUID().toString().replace("-","").toUpperCase(Locale.ROOT); + } + + /** + * 生成订单号 + * + * @return + */ + public static synchronized String getBillno() { + StringBuilder billno = new StringBuilder(); + + // 日期(格式:20080524) + SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + billno.append(format.format(new Date())); + return billno.toString(); + } + + public static boolean isEmpty(Object content) { + if (content == null) { + return true; + } + + if (content instanceof String) { + return "".equals(content); + } else { + return false; + } + } + + public static String replaceNonLegalChar(String str) { + if (str == null) { + return null; + } + + str = str.replace("(", "("); + str = str.replace(")", ")"); + str = str.replaceAll("\\s*", ""); + + return str; + } + + public static boolean isNotEmpty(Object content) { + return !isEmpty(content); + } + + + /** + * 计算分页数量 + * + * @param count + * @param pageSize + * @return + */ + public static int getPageCount(int count, int pageSize) { + // TODO Auto-generated method stub + int pageCount = 0; + if (count == 0) { + return 0; + } + + // 页长不能为0 + if (pageSize == 0) { + return -1; + } + + if (count % pageSize == 0) { + pageCount = count / pageSize; + } else { + pageCount = count / pageSize + 1; + + } + return pageCount; + + } + + /** + * 计算分页数量 + * + * @param count + * @param pageSize + * @return + */ + public static long getPageCount(long count, int pageSize) { + // TODO Auto-generated method stub + long pageCount = 0; + if (count == 0) { + return 0; + } + + // 页长不能为0 + if (pageSize == 0) { + return -1; + } + + if (count % pageSize == 0) { + pageCount = count / pageSize; + } else { + pageCount = count / pageSize + 1; + + } + return pageCount; + + } + + public static boolean equals(String str1, String str2) { + // TODO Auto-generated method stub + return str1 == null ? str2 == null : str1.equals(str2); + } + + /** + * 返回一个定长的随机纯字母字符串(只包含大小写字母) + * + * @param length 随机字符串长度 + * @return 随机字符串 + */ + public static String generateMixStr(int length) { + StringBuffer sb = new StringBuffer(); + Random random = new Random(); + for (int i = 0; i < length; i++) { + sb.append(letterChar.charAt(random.nextInt(letterChar.length()))); + } + return sb.toString(); + } + + + /** + * 返回日时分秒 + * + * @param second + * @return + */ + public static String secondToTime(long second) { + long days = second / 86400;//转换天数 + second = second % 86400;//剩余秒数 + long hours = second / 3600;//转换小时数 + second = second % 3600;//剩余秒数 + long minutes = second / 60;//转换分钟 + second = second % 60;//剩余秒数 + String min = minutes + ""; + if (minutes < 10) { + min = "0" + minutes; + } + String sec = second + ""; + if (second < 10) { + sec = "0" + second; + } + + if (0 < days) { + return days + ""; + } else { + return hours + ""; + } + } + + public static double bigDecimal(Double d) { + if (d == null) { + return 0d; + } + return new BigDecimal(d).setScale(2, RoundingMode.HALF_UP).doubleValue(); + } + + public static double bigDecimal(Double d, RoundingMode roundingMode) { + if (d == null) { + return 0d; + } + return new BigDecimal(d).setScale(2, roundingMode).doubleValue(); + } + + public static String isHideMobile(String mobile) { + if (mobile.length() == 11) { + mobile = mobile.substring(0, 3) + "****" + mobile.substring(7); + } + return mobile; + } + + public static boolean isNumber(String str) { + String regex = "^([0-9]+(.[0-9]{1,2})?)|(-[0-9]+(.[0-9]{1,2})?)$"; + Pattern pattern = Pattern.compile(regex); + Matcher match = pattern.matcher(str); + // match.find() + return match.matches(); + } + + /** + * 隐藏隐私信息。 + * + * @param param + * @return + */ + public static String hideSecret(String param) { + int len = param.length(); + if (isContainChinese(param)) { + String replaceValue = "**"; + if (param.length() == 2) { + replaceValue = "*"; + } + return param.replaceAll("(.{1})(.*)(.{0})", "$1" + replaceValue + "$3"); + } + return param.replaceAll("(.{" + (len < 12 ? 3 : 6) + "})(.*)(.{4})", "$1" + "****" + "$3"); + } + + private static boolean isContainChinese(String str) { + Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); + Matcher m = p.matcher(str); + if (m.find()) { + return true; + } + return false; + } + + public static String buildPostForm(String baseUrl, Map parameters) { + StringBuffer sb = new StringBuffer(); + sb.append("
    \n"); + sb.append(buildHiddenFields(parameters)); + sb.append("\n"); + sb.append("
    \n"); + sb.append(""); + String form = sb.toString(); + return form; + } + + public static String buildHiddenFields(Map parameters) { + if (parameters == null || parameters.isEmpty()) { + return ""; + } + StringBuffer sb = new StringBuffer(); + Set keys = parameters.keySet(); + for (String key : keys) { + String value = parameters.get(key); + // 除去参数中的空值 + if (key == null || value == null) { + continue; + } + sb.append("\n"); + + } + return sb.toString(); + } + + /** + * @param src + * @param replaceSrc 需要替换的字符 + * @param replacementList 替换后的字符 + * @return + */ + public static String replaceOneByOne(String src, String[] replaceSrc, String[] replacementList) { + if (replaceSrc == null) { + throw new IllegalArgumentException("replaceSrc 不能为空"); + } + + if (replacementList == null) { + throw new IllegalArgumentException("replacementList 不能为空"); + } + + if (replaceSrc.length != replacementList.length) { + throw new IllegalArgumentException("replaceSrc 和 replacementList的长度必须相等"); + } + + StringBuffer sb = new StringBuffer(); + + int start = 0; + + if (replacementList.length == 0) { + return src; + } + + for (int i = 0; i < replaceSrc.length; i++) { + int position = src.indexOf(replaceSrc[i], start); + + if (position == -1) { + continue; + } + + sb.append(src, start, position); + sb.append(replacementList[i]); + start = position + 1; + } + sb.append(src, start, src.length()); + + return sb.toString(); + } + + /** + * 密码校验 + * @param password + * @return + */ + public static String passwordCheck(String password){ + int length = password.length(); + if (length >= 7 && length <= 16){ + return password; + }else { + return null; + } + } + + /** + * 金额校验 + * @param str + * @return + */ + public static boolean isMoney(String str) { + // 判断小数点后2位的数字的正则表达式 + Pattern pattern = Pattern.compile("^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,2})?$"); + Matcher match = pattern.matcher(str); + return match.matches(); + } + +} diff --git a/newadmin/pom.xml b/newadmin/pom.xml index 03f94c2..5bdba31 100644 --- a/newadmin/pom.xml +++ b/newadmin/pom.xml @@ -19,7 +19,8 @@ oss-service admin merchant-service-api - + lkl-service-api +