提交新功能 分销商 积分 会员体系
This commit is contained in:
@ -137,6 +137,10 @@
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>transmittable-thread-local</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -194,4 +194,27 @@ public interface ShopConstants {
|
||||
|
||||
//快递查询接口Logistic
|
||||
String KDNIAO_LOGISTIC_QUERY="https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
|
||||
|
||||
/**
|
||||
* redis营销活动状态变更key
|
||||
*/
|
||||
String CAMPAIGN_CHANGE = "campaign-change-queue";
|
||||
|
||||
/**
|
||||
* redis广告弹窗状态变更key
|
||||
*/
|
||||
String POPUP_CHANGE = "popup-change-queue";
|
||||
|
||||
/**
|
||||
* redis拼团状态变更key
|
||||
*/
|
||||
String TEAMWORK_CHANGE = "teamwork-change-queue";
|
||||
|
||||
String DAY_FORMAT_STR = "yyyy-MM-dd";
|
||||
|
||||
/**
|
||||
* redis 订单收货后不可关闭售后 key
|
||||
*/
|
||||
String CLOSE_AFTER_SALE_KEY = "close-after-sale-key";
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package co.yixiang.yshop.framework.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pepis
|
||||
* @apiNote 开启关闭枚举
|
||||
**/
|
||||
@Getter
|
||||
public enum EnableEnum {
|
||||
DISABLE(0,"禁用"),
|
||||
ENABLE(1,"启用"),
|
||||
;
|
||||
private final Integer value;
|
||||
|
||||
private final String desc;
|
||||
|
||||
EnableEnum(Integer value, String desc) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
@ -20,11 +20,13 @@ public enum OrderInfoEnum {
|
||||
|
||||
STATUS_APPLY_REFUND(-1,"申请退款"),
|
||||
STATUS_REFUND_SUCCESS(-2,"退款成功"),
|
||||
STATUS_GROUP_FAILURE(-4,"成团失败"),
|
||||
STATUS_DEFAULT(0,"默认"),
|
||||
STATUS_WAIT_RECEIVED(1,"待收货"),
|
||||
STATUS_RECEIVED(2,"已收货"),
|
||||
STATUS_FINISHED(3,"已完成"),
|
||||
STATUS_CANCEL(4,"取消"),
|
||||
STATUS_WAIT_GROUP(5,"待成团"),
|
||||
|
||||
PAY_STATUS_UNPAID(0,"未支付"),
|
||||
PAY_STATUS_HAVE_PAID(1,"已支付"),
|
||||
@ -61,7 +63,9 @@ public enum OrderInfoEnum {
|
||||
SHIPPING_TYPE_STORE_PICKUP(2,"门店自提"),
|
||||
|
||||
UNABLE_AFTER_SALES(0,"不能售后"),
|
||||
ABLE_AFTER_SALES(1,"能售后");
|
||||
ABLE_AFTER_SALES(1,"能售后"),
|
||||
|
||||
CAMPAIGN_ORDER(2,"活动订单");
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package co.yixiang.yshop.framework.common.util.date;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
|
||||
import java.time.*;
|
||||
@ -170,4 +171,82 @@ public class DateUtils {
|
||||
return LocalDateTimeUtil.isSameDay(date, LocalDateTime.now());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断当前时间是否处在开始时间和结束时间之间
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return 是否
|
||||
*/
|
||||
public static boolean isBelong(LocalDateTime start,LocalDateTime end) {
|
||||
return isBefore(end) && isAfter(start);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前时间是否处在传入时间前
|
||||
*
|
||||
* @param time
|
||||
* @return 是否
|
||||
*/
|
||||
public static boolean isBefore(LocalDateTime time) {
|
||||
return toTimeStamp(time) > System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前时间是否处在传入时间后
|
||||
*
|
||||
* @param time 时间
|
||||
* @return 是否
|
||||
*/
|
||||
public static boolean isAfter(LocalDateTime time) {
|
||||
return toTimeStamp(time) < System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 传入时间累加
|
||||
*
|
||||
* @param time 时间
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static LocalDateTime getMoreMinuteAfter(LocalDateTime time, int minute) {
|
||||
return time.plusMinutes(minute);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算与当前时间的差值(毫秒)
|
||||
*
|
||||
* @param time
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static long getMoreMillisecondAfter(LocalDateTime time) {
|
||||
return toTimeStamp(time) - System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算时间戳
|
||||
*
|
||||
* @param time
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static long toTimeStamp(LocalDateTime time) {
|
||||
return time.toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断两个日期是否同一天
|
||||
* @param date1 /
|
||||
* @param date2 /
|
||||
* @return /
|
||||
*/
|
||||
public static Boolean isSameDay(Date date1,Date date2){
|
||||
return DateUtil.formatDate(date1).equals(DateUtil.formatDate(date2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,10 +3,13 @@ package co.yixiang.yshop.framework.common.util.date;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
|
||||
/**
|
||||
* 时间工具类,用于 {@link LocalDateTime}
|
||||
* 时间工具类,用于 {@link java.time.LocalDateTime}
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@ -60,4 +63,42 @@ public class LocalDateTimeUtils {
|
||||
return LocalDateTimeUtil.isIn(LocalDateTime.now(), startTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本周开始时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static LocalDateTime weekStartTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
return LocalDateTime.of(now.minusDays(now.getDayOfWeek().getValue() - 1), LocalTime.MIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本周结束时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static LocalDateTime weekEndTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
return LocalDateTime.of(now.plusDays(7 - now.getDayOfWeek().getValue()), LocalTime.MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本月开始时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static LocalDateTime monthStartTime() {
|
||||
return LocalDateTime.of(LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()), LocalTime.MIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本月结束时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static LocalDateTime monthEndTime() {
|
||||
return LocalDateTime.of(LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
package co.yixiang.yshop.framework.common.util.distancecalculator;
|
||||
|
||||
/**
|
||||
* @author pepis
|
||||
* @apiNote
|
||||
**/
|
||||
public class DistanceCalculatorUtil {
|
||||
public static void main(String[] args) {
|
||||
double lat1 = 37.7749; // 第一个点的纬度
|
||||
double lon1 = -122.4194; // 第一个点的经度
|
||||
|
||||
double lat2 = 34.0522; // 第二个点的纬度
|
||||
double lon2 = -118.2437; // 第二个点的经度
|
||||
|
||||
double distance = calculateDistance(lat1, lon1, lat2, lon2);
|
||||
System.out.println("Distance: " + distance + " m");
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两地之间距离
|
||||
* @param lat1 第一个点的纬度
|
||||
* @param lon1 第一个点的经度
|
||||
* @param lat2 第二个点的纬度
|
||||
* @param lon2 第二个点的经度
|
||||
* @return 距离单位 米
|
||||
*/
|
||||
public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
|
||||
// 地球半径,单位:千米
|
||||
final double R = 6371.0;
|
||||
|
||||
// 将经纬度转换为弧度
|
||||
double radLat1 = Math.toRadians(lat1);
|
||||
double radLon1 = Math.toRadians(lon1);
|
||||
double radLat2 = Math.toRadians(lat2);
|
||||
double radLon2 = Math.toRadians(lon2);
|
||||
|
||||
// Haversine公式计算距离
|
||||
double dlon = radLon2 - radLon1;
|
||||
double dlat = radLat2 - radLat1;
|
||||
double a = Math.pow(Math.sin(dlat / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(dlon / 2), 2);
|
||||
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
|
||||
// 计算距离
|
||||
return Math.round(R * c * 1000);
|
||||
}
|
||||
}
|
@ -5,11 +5,13 @@ import cn.hutool.core.map.TableMap;
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import okhttp3.*;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
@ -39,12 +41,11 @@ public class HttpUtils {
|
||||
|
||||
/**
|
||||
* 拼接 URL
|
||||
*
|
||||
* copy from Spring Security OAuth2 的 AuthorizationEndpoint 类的 append 方法
|
||||
*
|
||||
* @param base 基础 URL
|
||||
* @param query 查询参数
|
||||
* @param keys query 的 key,对应的原本的 key 的映射。例如说 query 里有个 key 是 xx,实际它的 key 是 extra_xx,则通过 keys 里添加这个映射
|
||||
* @param base 基础 URL
|
||||
* @param query 查询参数
|
||||
* @param keys query 的 key,对应的原本的 key 的映射。例如说 query 里有个 key 是 xx,实际它的 key 是 extra_xx,则通过 keys 里添加这个映射
|
||||
* @param fragment URL 的 fragment,即拼接到 # 中
|
||||
* @return 拼接后的 URL
|
||||
*/
|
||||
@ -109,7 +110,7 @@ public class HttpUtils {
|
||||
authorization = Base64.decodeStr(authorization);
|
||||
clientId = StrUtil.subBefore(authorization, ":", false);
|
||||
clientSecret = StrUtil.subAfter(authorization, ":", false);
|
||||
// 再从 Param 中获取
|
||||
// 再从 Param 中获取
|
||||
} else {
|
||||
clientId = request.getParameter("client_id");
|
||||
clientSecret = request.getParameter("client_secret");
|
||||
@ -122,5 +123,31 @@ public class HttpUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getAppletNoticeToken(String appid, String secret) throws IOException {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
Request request = new Request.Builder()
|
||||
.url("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret)
|
||||
.get()
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
assert response.body() != null;
|
||||
return response.body().string();
|
||||
}
|
||||
|
||||
public static String sendAppletNotice(String token,String bodyString) throws IOException {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("text/plain");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyString);
|
||||
Request request = new Request.Builder()
|
||||
.url("https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token="+token)
|
||||
.method("POST", body)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
assert response.body() != null;
|
||||
return response.body().string();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* IO 工具类,用于 {@link IoUtil} 缺失的方法
|
||||
* IO 工具类,用于 {@link cn.hutool.core.io.IoUtil} 缺失的方法
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
|
@ -3,7 +3,7 @@ package co.yixiang.yshop.framework.common.util.object;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* {@link PageParam} 工具类
|
||||
* {@link co.yixiang.yshop.framework.common.pojo.PageParam} 工具类
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
|
Reference in New Issue
Block a user