团购卷卷码表
原订单列表逻辑 店铺营业时间 团购卷订单 团购卷卷码表 资源管理 字典管理 通用门店 个人中心 支付
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class BigDecimalUtils {
|
||||
|
||||
/**
|
||||
* 折扣计算
|
||||
* @param orPrice 原价
|
||||
* @param saPrice 现价
|
||||
* @return
|
||||
*/
|
||||
public static BigDecimal getDiscount(BigDecimal orPrice,BigDecimal saPrice){
|
||||
BigDecimal discountRate = saPrice.divide(orPrice, 2, BigDecimal.ROUND_HALF_UP);
|
||||
// 将折扣率转换为百分比形式
|
||||
BigDecimal discountPercentage = discountRate.multiply(BigDecimal.TEN);
|
||||
return discountPercentage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -269,6 +269,16 @@ public class DateUtils {
|
||||
cal.set(Calendar.MILLISECOND, 999);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
public static Long getDayStartLong() {
|
||||
// 获取今天的日期和时间(00:00:00)
|
||||
LocalDateTime todayStart = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||
// 转换为UTC时间戳(毫秒)
|
||||
long timestampInMillis = todayStart.toInstant(ZoneOffset.UTC).toEpochMilli();
|
||||
|
||||
return timestampInMillis;
|
||||
}
|
||||
|
||||
public static Long getDayEndLong() {
|
||||
// 获取今天的日期和时间(00:00:00)
|
||||
LocalDateTime todayStart = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
@@ -9,7 +11,27 @@ import static java.lang.Math.*;
|
||||
import static java.lang.Math.sin;
|
||||
|
||||
public class LocationUtils {
|
||||
/**
|
||||
* 通过Ip获取定位信息
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
public static String getGPSByIp(String ip) {
|
||||
Map<String, String> param = new HashMap<>();
|
||||
//超掌柜生活-用户端
|
||||
param.put("key", "7a7f2e4790ea222660a027352ee3af39");
|
||||
if(StringUtils.isNotBlank(ip)){
|
||||
param.put("ip", ip);
|
||||
}
|
||||
String s = HttpClientUtil.doGet("https://restapi.amap.com/v3/ip", param);
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 行政区域查询
|
||||
* @param keywords
|
||||
* @return
|
||||
*/
|
||||
public static String district(String keywords) {
|
||||
Map<String, String> param = new HashMap<>();
|
||||
//超掌柜生活-用户端
|
||||
@@ -57,20 +79,23 @@ public class LocationUtils {
|
||||
* 右上顶点 double[] leftTopPoints = stringMap.get("rightTopPoint");
|
||||
* 左下点 double[] leftBottomPoints = stringMap.get("leftBottomPoint");
|
||||
*/
|
||||
public static Map<String, double[]> returnLLSquarePoint(double longitude, double latitude, double distanceInKm) {
|
||||
public static Map<String, double[]> returnLLSquarePoint(double longitude, double latitude, String distanceInKm) {
|
||||
BigDecimal distanceKm = new BigDecimal(10);
|
||||
if (StringUtils.isNotBlank(distanceInKm)) {
|
||||
distanceKm = new BigDecimal(distanceInKm);
|
||||
}
|
||||
Map<String, double[]> squareMap = new HashMap<>();
|
||||
BigDecimal bdlongitude = new BigDecimal(longitude);
|
||||
// 地球平均半径,单位:千米
|
||||
BigDecimal earthRadius = new BigDecimal("6378.137");
|
||||
// 将距离转换为弧度
|
||||
|
||||
BigDecimal radialDistance = BigDecimal.valueOf(distanceInKm).divide(earthRadius, 10, RoundingMode.HALF_UP);
|
||||
BigDecimal radialDistance = distanceKm.divide(earthRadius, 10, RoundingMode.HALF_UP);
|
||||
// 计算纬度上变化对应的角度
|
||||
BigDecimal dLatitude = BigDecimal.valueOf(Math.toDegrees(2 * Math.asin(Math.sin(radialDistance.divide(BigDecimal.valueOf(2)).doubleValue()) / Math.cos(Math.toRadians(latitude)))));
|
||||
// 计算经度上变化对应的角度,这里需要考虑纬度对距离的影响
|
||||
// 使用Haversine公式来估算在给定纬度上,距离对应的经度变化
|
||||
BigDecimal estimatedLongitudeDistance = getDistanceFrom2LngLat(latitude, longitude, latitude, bdlongitude.add(BigDecimal.valueOf(0.01)).doubleValue()); // 假设0.01度经度变化对应的距离
|
||||
BigDecimal dLongitude = BigDecimal.valueOf(distanceInKm).divide(estimatedLongitudeDistance, 10, RoundingMode.HALF_UP).multiply(new BigDecimal("0.0192736")); // 根据比例计算经度变化
|
||||
BigDecimal dLongitude = distanceKm.divide(estimatedLongitudeDistance, 10, RoundingMode.HALF_UP).multiply(new BigDecimal("0.0192736")); // 根据比例计算经度变化
|
||||
// 正方形四个顶点的坐标
|
||||
double[] rightTopPoint = {BigDecimal.valueOf(latitude).add(dLatitude.divide(BigDecimal.valueOf(2))).doubleValue(), BigDecimal.valueOf(longitude).add(dLongitude.divide(BigDecimal.valueOf(2))).doubleValue()};
|
||||
double[] leftBottomPoint = {BigDecimal.valueOf(latitude).subtract(dLatitude.divide(BigDecimal.valueOf(2))).doubleValue(), BigDecimal.valueOf(longitude).subtract(dLongitude.divide(BigDecimal.valueOf(2))).doubleValue()};
|
||||
@@ -93,7 +118,7 @@ public class LocationUtils {
|
||||
}
|
||||
//1KM
|
||||
public static void main(String[] args) {
|
||||
Map<String, double[]> stringMap = returnLLSquarePoint(108.975418, 34.280890, 5);
|
||||
Map<String, double[]> stringMap = returnLLSquarePoint(108.975418, 34.280890, "5");
|
||||
double[] leftTopPoints = stringMap.get("rightTopPoint");
|
||||
double[] leftBottomPoints = stringMap.get("leftBottomPoint");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user