param=new HashMap<>();
+ //超掌柜生活-用户端
+ param.put("key","7a7f2e4790ea222660a027352ee3af39");
+ param.put("keywords",keywords);
+ param.put("subdistrict","1");
+ param.put("extensions","base");
+ String s = HttpClientUtil.doGet("https://restapi.amap.com/v3/config/district", param);
+ return s;
+ }
+
+ /**
+ * 将角度转化为弧度
+ */
+ public static double radians(double d) {
+ return d * Math.PI / 180.0;
+ }
+ /**
+ * 根据两点经纬度坐标计算直线距离
+ *
+ * S = 2arcsin√sin²(a/2)+cos(lat1)*cos(lat2)*sin²(b/2) ̄*6378.137
+ *
+ * 1. lng1 lat1 表示A点经纬度,lng2 lat2 表示B点经纬度;
+ * 2. a=lat1 – lat2 为两点纬度之差 b=lng1 -lng2 为两点经度之差;
+ * 3. 6378.137为地球赤道半径,单位为千米;
+ *
+ * @param lng1 点1经度
+ * @param lat1 点1纬度
+ * @param lng2 点2经度
+ * @param lat2 点2纬度
+ * @return 距离,单位千米(KM)
+ * @see 半正矢(Haversine)公式
+ */
+ public static double getDistanceFrom2LngLat(double lng1, double lat1, double lng2, double lat2) {
+ //将角度转化为弧度
+ double radLng1 = radians(lng1);
+ double radLat1 = radians(lat1);
+ double radLng2 = radians(lng2);
+ double radLat2 = radians(lat2);
+
+ double a = radLat1 - radLat2;
+ double b = radLng1 - radLng2;
+
+ return 2 * asin(sqrt(sin(a / 2) * sin(a / 2) + cos(radLat1) * cos(radLat2) * sin(b / 2) * sin(b / 2))) * 6378.137;
+ }
+
+// public static void main(String[] args) {
+// // 示例经纬度坐标
+// double lat1 = 108.954398;
+// double lon1 = 34.308687;
+//
+// double lat2 = 108.953555;
+// double lon2 = 34.276169;
+//
+// // 计算距离
+// double distance = getDistanceFrom2LngLat(lat1, lon1, lat2, lon2);
+// System.out.println("Distance between the two points is: " + distance + " km");
+// }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/RedisUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/RedisUtils.java
index d2edcde..01261dc 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/util/RedisUtils.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/RedisUtils.java
@@ -294,10 +294,10 @@ public class RedisUtils {
* @param timeUnit 类型
* @return true成功 false 失败
*/
- public boolean set(String key, Object value, long time, TimeUnit timeUnit) {
+ public boolean set(String key, String value, long time, TimeUnit timeUnit) {
try {
if (time > 0) {
- redisTemplate.opsForValue().set(key, value, time, timeUnit);
+ stringRedisTemplate.opsForValue().set(key, value, time, timeUnit);
} else {
set(key, value);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java
index f049832..922be6c 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java
@@ -51,4 +51,14 @@ public class StringUtil {
return JSON.parseArray(listString);
}
+
+ 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;
+ }
+
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java
new file mode 100644
index 0000000..75189f0
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java
@@ -0,0 +1,85 @@
+package com.chaozhanggui.system.cashierservice.util;
+
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.aliyun.dysmsapi20170525.Client;
+import com.aliyun.teaopenapi.models.Config;
+import com.chaozhanggui.system.cashierservice.sign.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
+
+/**
+ * 获取验证码相关工具
+ * @author 12847
+ */
+@Component
+public class ValidateCodeUtil {
+ /**
+ * 阿里云key
+ */
+ @Value("${aliyun.keyid}")
+ private String ACCESSKEYID;
+ /**
+ * 阿里云secret
+ */
+ @Value("${aliyun.keysecret}")
+ private String ACCESSKEYSECRET;
+ /**
+ * 十小时
+ */
+ protected static final long MILLIS_MINUTE = 10 *60 * 60 *1000;
+
+ @Autowired
+ private HttpServletRequest request;
+
+
+ /**
+ * 获取验证码(阿里云)
+ */
+ public Result requestValidateCodeAli(String phone, String checkCode) {
+ Client client = null;
+ try {
+ client = createClient();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ // 1.发送短信
+ com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest()
+ .setSignName("银收客")
+ .setTemplateCode("SMS_244665149")
+ .setTemplateParam("{\"code\":" +"'"+checkCode +"'"+"}")
+ .setPhoneNumbers(phone);
+ com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
+ try {
+ assert client != null;
+ return Result.success(SUCCESS,client.sendSmsWithOptions(sendSmsRequest, runtime));
+ } catch (Exception e) {
+ return Result.fail(e.getMessage());
+ }
+
+ }
+ /**
+ * 发送短信(阿里云)
+ *
+ * @return
+ * @throws Exception
+ */
+ public Client createClient() throws Exception {
+ Config config = new Config();
+ config.accessKeyId = ACCESSKEYID;
+ config.accessKeySecret = ACCESSKEYSECRET;
+ return new com.aliyun.dysmsapi20170525.Client(config);
+ }
+
+
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index d5c4870..4f818e0 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -13,7 +13,7 @@ wx:
#
spring:
profiles:
- active: prod
+ active: dev
websocket:
port: 6001
action: ws://127.0.0.1
@@ -47,3 +47,7 @@ logging:
# 如果是压缩包,里面会多一个名log/ota.2021-11-05.0的日志文件
# 如下面的例子,打包之后为: log/2021-11/cashier-client.2020-11-5.0.log,这是一个日志文件
file-name-pattern: log/%d{yyyy-MM}/cashierService.%d{yyyy-MM-dd}.%i.log
+#阿里云相关配置
+aliyun:
+ keyid: LTAI5tPdEfYSZcqHbjCrtPRD
+ keysecret: DZjyHBq3nTujF0NMLxnZgsecU8ZCvy
\ No newline at end of file
diff --git a/src/main/resources/mapper/TbPlatformDictMapper.xml b/src/main/resources/mapper/TbPlatformDictMapper.xml
new file mode 100644
index 0000000..fa4182b
--- /dev/null
+++ b/src/main/resources/mapper/TbPlatformDictMapper.xml
@@ -0,0 +1,248 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort)
+ values (#{name}, #{type}, #{coverImg}, #{shareImg}, #{video}, #{videoCoverImg}, #{relUrl}, #{absUrl}, #{createdAt}, #{updatedAt}, #{isShowCash}, #{isShowMall}, #{isShowApp}, #{sort})
+
+
+
+ insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort)
+ values
+
+ (#{entity.name}, #{entity.type}, #{entity.coverImg}, #{entity.shareImg}, #{entity.video}, #{entity.videoCoverImg}, #{entity.relUrl}, #{entity.absUrl}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.isShowCash}, #{entity.isShowMall}, #{entity.isShowApp}, #{entity.sort})
+
+
+
+
+ insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort)
+ values
+
+ (#{entity.name}, #{entity.type}, #{entity.coverImg}, #{entity.shareImg}, #{entity.video}, #{entity.videoCoverImg}, #{entity.relUrl}, #{entity.absUrl}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.isShowCash}, #{entity.isShowMall}, #{entity.isShowApp}, #{entity.sort})
+
+ on duplicate key update
+ name = values(name),
+ type = values(type),
+ cover_img = values(cover_img),
+ share_img = values(share_img),
+ video = values(video),
+ video_cover_img = values(video_cover_img),
+ rel_url = values(rel_url),
+ abs_url = values(abs_url),
+ created_at = values(created_at),
+ updated_at = values(updated_at),
+ is_show_cash = values(is_show_cash),
+ is_show_mall = values(is_show_mall),
+ is_show_app = values(is_show_app),
+ sort = values(sort)
+
+
+
+
+ update tb_platform_dict
+
+
+ name = #{name},
+
+
+ type = #{type},
+
+
+ cover_img = #{coverImg},
+
+
+ share_img = #{shareImg},
+
+
+ video = #{video},
+
+
+ video_cover_img = #{videoCoverImg},
+
+
+ rel_url = #{relUrl},
+
+
+ abs_url = #{absUrl},
+
+
+ created_at = #{createdAt},
+
+
+ updated_at = #{updatedAt},
+
+
+ is_show_cash = #{isShowCash},
+
+
+ is_show_mall = #{isShowMall},
+
+
+ is_show_app = #{isShowApp},
+
+
+ sort = #{sort},
+
+
+ where id = #{id}
+
+
+
+
+ delete from tb_platform_dict where id = #{id}
+
+
+
+
diff --git a/src/main/resources/mapper/TbProductSkuMapper.xml b/src/main/resources/mapper/TbProductSkuMapper.xml
index 6ba93af..969e918 100644
--- a/src/main/resources/mapper/TbProductSkuMapper.xml
+++ b/src/main/resources/mapper/TbProductSkuMapper.xml
@@ -355,4 +355,19 @@
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/mapper/TbShopInfoMapper.xml b/src/main/resources/mapper/TbShopInfoMapper.xml
index bad0fbf..0634beb 100644
--- a/src/main/resources/mapper/TbShopInfoMapper.xml
+++ b/src/main/resources/mapper/TbShopInfoMapper.xml
@@ -617,4 +617,31 @@
+
+
\ No newline at end of file
diff --git a/src/main/resources/mapper/TbUserInfoMapper.xml b/src/main/resources/mapper/TbUserInfoMapper.xml
index a52332a..4e494b9 100644
--- a/src/main/resources/mapper/TbUserInfoMapper.xml
+++ b/src/main/resources/mapper/TbUserInfoMapper.xml
@@ -3,6 +3,7 @@
+
@@ -47,15 +48,16 @@
+
- id, amount, charge_amount, line_of_credit, consume_amount, consume_number, total_score,
+ id,user_id, amount, charge_amount, line_of_credit, consume_amount, consume_number, total_score,
lock_score, card_no, card_password, level_id, head_img, nick_name, telephone, wx_ma_app_id,
birth_day, sex, mini_app_open_id, open_id, union_id, code, type, identify, status,
parent_id, parent_level, parent_type, project_id, merchant_id, is_resource, is_online,
is_vip, vip_effect_at, tips, source_path, is_sales_person, is_attention_mp, city,
search_word, last_log_in_at, last_leave_at, created_at, updated_at, bind_parent_at,
- grand_parent_id
+ grand_parent_id,password
+
+
+ select * from tb_user_info where telephone=#{phone} AND source_path=#{source}
+
+
+
+ select * from tb_user_info where telephone=#{phone} AND source_path='APP' AND user_id is null
+
\ No newline at end of file