Browse Source

烂代码

master
主管理员 1 month ago
parent
commit
2e902a23b1
8 changed files with 236 additions and 139 deletions
  1. +121
    -116
      ruoyi-admin/src/main/resources/application-druid.yml
  2. +70
    -9
      ruoyi-catdog/src/main/java/com/ruoyi/applet/service/impl/IMallOrderServiceImpl.java
  3. +2
    -8
      ruoyi-catdog/src/main/java/com/ruoyi/applet/tencent/TaskConsumer.java
  4. +6
    -0
      ruoyi-mall/src/main/java/com/cyl/h5/pojo/vo/H5OrderVO.java
  5. +5
    -0
      ruoyi-mall/src/main/java/com/cyl/h5/service/H5OrderService.java
  6. +8
    -0
      ruoyi-mall/src/main/java/com/cyl/manager/oms/domain/Order.java
  7. +1
    -1
      ruoyi-mall/src/main/java/com/cyl/manager/ums/domain/MemberAddress.java
  8. +23
    -5
      ruoyi-mall/src/main/resources/mapper/oms/OrderMapper.xml

+ 121
- 116
ruoyi-admin/src/main/resources/application-druid.yml View File

@ -1,96 +1,101 @@
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源 jdbc:mysql://localhost:3306/catmdogf?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
master:
url: jdbc:mysql://47.97.158.59:3306/catmdogf_prod20225?useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
username: root
password: Qweruiop@123
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
statViewServlet:
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
# redis 配置
redis:
# 地址
host: 47.97.158.59
# 端口,默认为6379
port: 6379
# 数据库索引
database: 5
# 密码
password: Qweruiop@123
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源 jdbc:mysql://localhost:3306/catmdogf?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
master:
url: jdbc:mysql://124.222.255.146:3306/catmdogf?useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
username: root
password: Tc$GePcZ
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
statViewServlet:
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
# redis 配置
redis:
# 地址
host: 124.222.255.146
# 端口,默认为6379
port: 6379
# 数据库索引
database: 5
# 密码
password: Abc.123456
redisson:
address: "47.97.158.59"
password: "Qweruiop@123" # 如果有密码的话
connectionPoolSize: 10
idleConnectionTimeout: 10000
timeout: 3000
address: "redis://124.222.255.146"
password: "Abc.123456" # 如果有密码的话
connectionPoolSize: 10
idleConnectionTimeout: 10000
timeout: 3000
ruoyi:
# 文件路径 示例( Windows配置C:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: /Users/daixiande/Work/ruoyi/uploadPath
# 文件路径 示例( Windows配置C:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: /Users/daixiande/Work/ruoyi/uploadPath
scheduling:
enabled: false
enabled: false
#aliyun:
# accessKeyId: LTAI5tQSs47izVy8DLVdwUU9 # 阿里云的accessKeyId
# secretAccessKey: qHI7C3PaXYZySr84HTToviC71AYlFq # accessKey 密码
# oss:
# endPoint: oss-cn-shenzhen.aliyuncs.com # Endpoint:在阿里云oss控制台查看自己使用的endpoint
# bucketName: hanhaiimage # bucket 名称
# cdnName: image.hhlm1688.com
#操作oss需要的一些参数
aliyun:
accessKeyId: LTAI5tQSs47izVy8DLVdwUU9 # 阿里云的accessKeyId
secretAccessKey: qHI7C3PaXYZySr84HTToviC71AYlFq # accessKey 密码
oss:
endPoint: oss-cn-shenzhen.aliyuncs.com # Endpoint:在阿里云oss控制台查看自己使用的endpoint
bucketName: hanhaiimage # bucket 名称
cdnName: image.hhlm1688.com
accessKeyId: LTAI5tD3bjTBDvgmgXLTKL5X # 阿里云的accessKeyId
secretAccessKey: wCPlCO5nnnqBekd3wxAPU6CSUto6fQ # accessKey 密码
oss:
endPoint: oss-cn-shanghai.aliyuncs.com # Endpoint:在阿里云oss控制台查看自己使用的endpoint
bucketName: catmdogf # bucket 名称
cdnName: cdn.catmdogd.com
wechat:
enabled: true
appId: wxd1a6ba7b5e17a5b6
secret: 你的微信服务号密钥
merchantId: 1665639691
# privateKeyPath: /data/software/app/key/apiclient_key.pem
# privateKeyPath: /root/pem/apiclient_key.pem
# privateKeyPath: E:\\file\\2025\\1\\pet-admin\\ruoyi-admin\\src\\main\\resources\\apiclient_cert.p12
privateKeyPath: E:\\file\\2025\\1\pet-admin\\ruoyi-admin\\src\\main\\resources\\apiclient_key.pem
# privateKeyPath: F:\\java_work\\team_work_java\\pet-admin-25-01-25\\pet-admin\\ruoyi-admin\\src\\main\\resources\\apiclient_key.pem
#privateKeyPath: /Users/daixiande/Work/杂七杂八/1665639691_20240111_cert/apiclient_key.pem
merchantSerialNumber: 6050244FC18200362585F1F9FD6557A1B291E8C0
apiV3key: 19971022197001121966060120240731
apiV2key: 19961022196901121965060120230731
# notifyUrl: https://api.catmdogd.com/prod-api/no-auth/wechat/notify
# notifyUrlForBCHSH: https://api.catmdogd.com/prod-api/no-auth/wechat/notifyForBCHSH
# notifyUrl: https://pet-admin.hhlm1688.com/api/no-auth/wechat/notify
# notifyUrlForBCHSH: https://pet-admin.hhlm1688.com/api/no-auth/wechat/notifyForBCHSH
notifyUrl: http://h5.xzaiyp.top/no-auth/wechat/notify
notifyUrlForBCHSH: http://h5.xzaiyp.top/no-auth/wechat/notifyForBCHSH
miniProgramAppId: wxd1a6ba7b5e17a5b6
miniProgramSecret: 06e946a2c9010f8eb9e306018a779a7f
staffAppId: wx01f0f43759922fda
staffSecret: b0a5617e6e4c387262a32af2b355c8b6
pay:
v3:
# 租户id
miniapp:
# 应用appId 服务商模式下为服务商的appid 必填
app-id: wxd1a6ba7b5e17a5b6
# v2 api 密钥 1.0.5版本以后如果用到V2的接口时必填
app-secret: 06e946a2c9010f8eb9e306018a779a7f
# api v3 密钥 必填
app-v3-secret: 19971022197001121966060120240731
# 微信支付商户号 服务商模式下为服务商的mchid 必填
mch-id: 1665639691
# 商户服务器域名 用于回调 需要放开回调接口的安全策略 必填
domain: https://api-test.catmdogd.com
# 商户 api 证书路径 必填 填写classpath路径 位于 maven项目的resources文件下
cert-path: apiclient_cert.p12
#cert-path: /data/software/app/key/apiclient_cert.p12
enabled: true
appId: wxd1a6ba7b5e17a5b6
secret: 你的微信服务号密钥
merchantId: 1665639691
# privateKeyPath: ruoyi-admin/src/main/resources/apiclient_cert.p12
# privateKeyPath: /root/pem/apiclient_key.pem
privateKeyPath: F:\\java_work\\team_work_java\\pet-admin-25-01-25\\pet-admin\\ruoyi-admin\\src\\main\\resources\\apiclient_key.pem
#privateKeyPath: /Users/daixiande/Work/杂七杂八/1665639691_20240111_cert/apiclient_key.pem
merchantSerialNumber: 6050244FC18200362585F1F9FD6557A1B291E8C0
apiV3key: 19971022197001121966060120240731
apiV2key: 19961022196901121965060120230731
# notifyUrl: https://api.catmdogd.com/prod-api/no-auth/wechat/notify
# notifyUrlForBCHSH: https://api.catmdogd.com/prod-api/no-auth/wechat/notifyForBCHSH
# notifyUrl: https://pet-admin.hhlm1688.com/api/no-auth/wechat/notify
# notifyUrlForBCHSH: https://pet-admin.hhlm1688.com/api/no-auth/wechat/notifyForBCHSH
notifyUrl: http://h5.xzaiyp.top/no-auth/wechat/notify
notifyUrlForBCHSH: http://h5.xzaiyp.top/no-auth/wechat/notifyForBCHSH
miniProgramAppId: wxd1a6ba7b5e17a5b6
miniProgramSecret: 06e946a2c9010f8eb9e306018a779a7f
staffAppId: wx01f0f43759922fda
staffSecret: b0a5617e6e4c387262a32af2b355c8b6
pay:
v3:
# 租户id
miniapp:
# 应用appId 服务商模式下为服务商的appid 必填
app-id: wxd1a6ba7b5e17a5b6
# v2 api 密钥 1.0.5版本以后如果用到V2的接口时必填
app-secret: 06e946a2c9010f8eb9e306018a779a7f
# api v3 密钥 必填
app-v3-secret: 19971022197001121966060120240731
# 微信支付商户号 服务商模式下为服务商的mchid 必填
mch-id: 1665639691
# 商户服务器域名 用于回调 需要放开回调接口的安全策略 必填
domain: https://api-test.catmdogd.com
# 商户 api 证书路径 必填 填写classpath路径 位于 maven项目的resources文件下
cert-path: apiclient_cert.p12
#cert-path: /data/software/app/key/apiclient_cert.p12
sms:
@ -116,38 +121,38 @@ aes:
# 伴宠师-相关配置信息
wechat-admin:
enabled: true
appId: wx01f0f43759922fda
secret: b0a5617e6e4c387262a32af2b355c8b6
merchantId: 1665639691
privateKeyPath: ruoyi-admin/src/main/resources/apiclient_cert.p12
#privateKeyPath: /Users/daixiande/Work/杂七杂八/1665639691_20240111_cert/apiclient_key.pem
merchantSerialNumber: 6050244FC18200362585F1F9FD6557A1B291E8C0
apiV3key: 19971022197001121966060120240731
apiV2key: 19961022196901121965060120230731
notifyUrl: https://api.catmdogd.com/prod-api/no-auth/wechat/notify
notifyUrlForBCHSH: https://api.catmdogd.com/prod-api/no-auth/wechat/notifyForBCHSH
miniProgramAppId: wxd1a6ba7b5e17a5b6
miniProgramSecret: 06e946a2c9010f8eb9e306018a779a7f
staffAppId: wx01f0f43759922fda
staffSecret: b0a5617e6e4c387262a32af2b355c8b6
pay:
v3:
# 租户id
miniapp:
# 应用appId 服务商模式下为服务商的appid 必填
app-id: wxd1a6ba7b5e17a5b6
# v2 api 密钥 1.0.5版本以后如果用到V2的接口时必填
app-secret: 06e946a2c9010f8eb9e306018a779a7f
# api v3 密钥 必填
app-v3-secret: 19971022197001121966060120240731
# 微信支付商户号 服务商模式下为服务商的mchid 必填
mch-id: 1665639691
# 商户服务器域名 用于回调 需要放开回调接口的安全策略 必填
domain: https://api-test.catmdogd.com
# 商户 api 证书路径 必填 填写classpath路径 位于 maven项目的resources文件下
cert-path: apiclient_cert.p12
#cert-path: /data/software/app/key/apiclient_cert.p12
enabled: true
appId: wx01f0f43759922fda
secret: b0a5617e6e4c387262a32af2b355c8b6
merchantId: 1665639691
privateKeyPath: ruoyi-admin/src/main/resources/apiclient_cert.p12
#privateKeyPath: /Users/daixiande/Work/杂七杂八/1665639691_20240111_cert/apiclient_key.pem
merchantSerialNumber: 6050244FC18200362585F1F9FD6557A1B291E8C0
apiV3key: 19971022197001121966060120240731
apiV2key: 19961022196901121965060120230731
notifyUrl: https://api.catmdogd.com/prod-api/no-auth/wechat/notify
notifyUrlForBCHSH: https://api.catmdogd.com/prod-api/no-auth/wechat/notifyForBCHSH
miniProgramAppId: wxd1a6ba7b5e17a5b6
miniProgramSecret: 06e946a2c9010f8eb9e306018a779a7f
staffAppId: wx01f0f43759922fda
staffSecret: b0a5617e6e4c387262a32af2b355c8b6
pay:
v3:
# 租户id
miniapp:
# 应用appId 服务商模式下为服务商的appid 必填
app-id: wxd1a6ba7b5e17a5b6
# v2 api 密钥 1.0.5版本以后如果用到V2的接口时必填
app-secret: 06e946a2c9010f8eb9e306018a779a7f
# api v3 密钥 必填
app-v3-secret: 19971022197001121966060120240731
# 微信支付商户号 服务商模式下为服务商的mchid 必填
mch-id: 1665639691
# 商户服务器域名 用于回调 需要放开回调接口的安全策略 必填
domain: https://api-test.catmdogd.com
# 商户 api 证书路径 必填 填写classpath路径 位于 maven项目的resources文件下
cert-path: apiclient_cert.p12
#cert-path: /data/software/app/key/apiclient_cert.p12


+ 70
- 9
ruoyi-catdog/src/main/java/com/ruoyi/applet/service/impl/IMallOrderServiceImpl.java View File

@ -3,16 +3,13 @@ package com.ruoyi.applet.service.impl;
import com.cyl.h5.pojo.vo.H5OrderVO;
import com.cyl.h5.service.H5OrderService;
import com.cyl.manager.oms.domain.OmsOrderService;
import com.cyl.manager.oms.mapper.OrderMapper;
import com.ruoyi.applet.service.IMallOrderService;
import com.ruoyi.common.config.properties.SmsProperties;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.model.domain.AppUsers;
import com.ruoyi.model.domain.AppletOrder;
import com.ruoyi.model.domain.AppletOrderItem;
import com.ruoyi.model.domain.AppletOrderItemDate;
import com.ruoyi.model.service.IAppUsersService;
import com.ruoyi.model.service.IAppletOrderItemDateService;
import com.ruoyi.model.service.IAppletOrderService;
import com.ruoyi.model.service.IAppletUsersTeacherService;
import com.ruoyi.common.core.sms.AliyunSmsUtils;
import com.ruoyi.model.domain.*;
import com.ruoyi.model.service.*;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
@ -31,6 +29,8 @@ public class IMallOrderServiceImpl implements IMallOrderService {
//下单小程序那边来的订单信息
@Autowired
private H5OrderService h5OrderService;
@Autowired
private OrderMapper orderMapper;
//伴宠师小程序获取已经认证好的伴宠师微信信息以及认证信息
@Autowired
private IAppUsersService appUsersService;
@ -39,8 +39,12 @@ public class IMallOrderServiceImpl implements IMallOrderService {
private IAppletOrderService appletOrderService;
@Autowired
private IAppletOrderItemDateService appletOrderItemDateService;
private IAppletAddressService appletAddressService;
@Autowired
private IAppletOrderItemDateService appletOrderItemDateService;
@Autowired
private SmsProperties smsProperties;
//点击派单进入派单逻辑
@ -192,6 +196,63 @@ public class IMallOrderServiceImpl implements IMallOrderService {
//系统派单逻辑
public String acceptDispatch(AppletOrder order) {
//得到关联的订单标识
Long orderId = order.getOrderId();
//获取经纬度
H5OrderVO h5OrderVO = orderMapper.selectOrderDetail(orderId);
log.info("订单数据:{}",h5OrderVO);
// 获取经度
String longitudeStr = h5OrderVO.getLongitude();
longitudeStr = "112.89175415039062";
// 获取纬度
String latitudeStr = h5OrderVO.getLatitude();
latitudeStr = "28.18972396850586";
// 转换为double
double longitude = Double.parseDouble(longitudeStr);
double latitude = Double.parseDouble(latitudeStr);
// 查询所有地址或添加基本筛选条件减少数据量
List<AppletAddress> allAddresses = appletAddressService.selectAppletAddressList(new AppletAddress());
// 筛选15公里内的地址
List<AppletAddress> nearbyAddresses = allAddresses.stream()
.filter(address -> {
double addrLon = Double.parseDouble(address.getLongitude());
double addrLat = Double.parseDouble(address.getLatitude());
return calculateDistance(latitude, longitude, addrLat, addrLon) <= 15;
})
.collect(Collectors.toList());
//如果15公里范围内没有伴宠师
if (nearbyAddresses.isEmpty()) {
//短信提醒
AliyunSmsUtils util = new AliyunSmsUtils(smsProperties);
util.sendBcshHasOrderSMS("17674618290");
return "no_teacher";
}
return "success";
}
// 计算两个经纬度之间的距离单位公里
private double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
final int R = 6371; // 地球半径公里
double latDistance = Math.toRadians(lat2 - lat1);
double lonDistance = Math.toRadians(lon2 - lon1);
double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2)
+ Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2))
* Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return R * c;
}


+ 2
- 8
ruoyi-catdog/src/main/java/com/ruoyi/applet/tencent/TaskConsumer.java View File

@ -104,21 +104,15 @@ public class TaskConsumer implements QueueConsumer {
//如果为空则为系统派单
if (model.getOrder().getTeacherId() == null) {
//系统派单
log.info("系统派单");
log.info("系统派单======================================");
mallOrderService.acceptDispatchAll(h5OrderVO);
}else if (model.getOrder().getTeacherId() != null) {
//指定派单
log.info("指定派单");
log.info("指定派单---------------------------------------");
mallOrderService.acceptDispatch(model.getOrder().getTeacherId(), h5OrderVO);
}
//进行派单操作
dispatchedOrdersService.dispatch(model.getOrder().getId());
//TODO 等待订单逻辑完成


+ 6
- 0
ruoyi-mall/src/main/java/com/cyl/h5/pojo/vo/H5OrderVO.java View File

@ -94,6 +94,12 @@ public class H5OrderVO {
private Integer companionLevel;
private Long addressId;
/** 经度 */
private String longitude;
/** 纬度 */
private String latitude;
// @TableField(exist = false)
// private AppletUsersTeacher usersTeacher;
}

+ 5
- 0
ruoyi-mall/src/main/java/com/cyl/h5/service/H5OrderService.java View File

@ -241,6 +241,11 @@ public class H5OrderService {
order.setReceiverDistrictId(memberAddress.getDistrictId());
order.setReceiverDetailAddress(memberAddress.getDetailAddress());
order.setAddressId(addressId);
order.setLongitude(memberAddress.getLongitude());
order.setLatitude(memberAddress.getLatitude());
//设置伴宠师ID和下单方式
if(form.getServicerId() != null){
order.setServicerId(form.getServicerId());


+ 8
- 0
ruoyi-mall/src/main/java/com/cyl/manager/oms/domain/Order.java View File

@ -175,4 +175,12 @@ public class Order extends BaseAudit {
private Long addressId;
/** 经度 */
private String longitude;
/** 纬度 */
private String latitude;
}

+ 1
- 1
ruoyi-mall/src/main/java/com/cyl/manager/ums/domain/MemberAddress.java View File

@ -110,7 +110,7 @@ public class MemberAddress extends BaseAudit {
@Excel(name = "STAFF_ID")
private Long staffId;
private String longitude;
/** 纬度 */
@Excel(name = "纬度")
private String latitude;


+ 23
- 5
ruoyi-mall/src/main/resources/mapper/oms/OrderMapper.xml View File

@ -47,10 +47,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="teacherId" column="teacher_id"/>
<result property="companionLevel" column="companion_level"/>
<result property="addressId" column="address_id"/>
<result property="longitude" column="longitude"/>
<result property="latitude" column="latitude"/>
</resultMap>
<sql id="selectOrderVo">
select id, member_id, member_username, total_amount, purchase_price, pay_amount, freight_amount, pay_type, status, aftersale_status, delivery_company, delivery_sn, auto_confirm_day, receiver_name, receiver_phone, receiver_post_code, receiver_province, receiver_city, receiver_district, receiver_province_id, receiver_city_id, receiver_district_id, receiver_detail_address, note, confirm_status, delete_status, payment_time, delivery_time, receive_time, create_by, create_time, update_by, update_time, need_pre_familiarize, wechat_member_coupon_id,servicer_id,order_method,teacher_id,companion_level from oms_order
select id, member_id, member_username, total_amount, purchase_price, pay_amount, freight_amount, pay_type, status, aftersale_status, delivery_company, delivery_sn, auto_confirm_day, receiver_name, receiver_phone, receiver_post_code, receiver_province, receiver_city, receiver_district, receiver_province_id, receiver_city_id, receiver_district_id, receiver_detail_address, note, confirm_status, delete_status, payment_time, delivery_time, receive_time, create_by, create_time, update_by, update_time, need_pre_familiarize, wechat_member_coupon_id,servicer_id,order_method,teacher_id,companion_level, address_id, longitude, latitude from oms_order
</sql>
<update id="cancelBatch">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
@ -95,6 +98,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="orderMethod != null "> and order_method = #{orderMethod}</if>
<if test="teacherId != null "> and teacher_id = #{teacherId}</if>
<if test="companionLevel != null "> and companion_level = #{companionLevel}</if>
<if test="addressId != null "> and address_id = #{addressId}</if>
<if test="longitude != null and longitude != ''"> and longitude = #{longitude}</if>
<if test="latitude != null and latitude != ''"> and latitude = #{latitude}</if>
,
</where>
</select>
@ -188,7 +194,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
receiver_province,
receiver_city,
receiver_district,
receiver_detail_address
receiver_detail_address,
address_id,
longitude,
latitude
from oms_order
where
delete_status=0
@ -227,7 +236,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
receiver_district,
receiver_detail_address,
teacher_id,
companion_level
companion_level,
address_id,
longitude,
latitude
from oms_order
where
delete_status=0
@ -264,7 +276,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
receiver_district,
receiver_detail_address,
teacher_id,
companion_level
companion_level,
address_id,
longitude,
latitude
from oms_order
where
delete_status=0
@ -299,7 +314,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
receiver_district,
receiver_detail_address,
teacher_id,
companion_level
companion_level,
address_id,
longitude,
latitude
from oms_order
where
delete_status=0


Loading…
Cancel
Save