Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qianhe-slsy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xuwenhao
qianhe-slsy
Commits
d1fffc15
Commit
d1fffc15
authored
Feb 23, 2024
by
xuwenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.23修改下单默认就近站点
parent
8a531aa8
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
115 additions
and
11 deletions
+115
-11
qianhe-admin/pom.xml
+7
-0
qianhe-admin/src/main/java/com/qianhe/system/controller/WaterOrderController.java
+5
-1
qianhe-admin/src/main/java/com/qianhe/system/domain/WaterOrder.java
+6
-0
qianhe-admin/src/main/java/com/qianhe/system/domain/WaterUserAddress.java
+6
-0
qianhe-admin/src/main/java/com/qianhe/system/service/impl/WaterOrderServiceImpl.java
+49
-0
qianhe-admin/src/main/java/com/qianhe/system/vo/WaterOrderVo.java
+6
-0
qianhe-admin/src/main/resources/application.yml
+19
-7
qianhe-admin/src/main/resources/mapper/WaterOrderMapper.xml
+8
-2
qianhe-admin/src/main/resources/mapper/WaterUserAddressMapper.xml
+9
-1
No files found.
qianhe-admin/pom.xml
View file @
d1fffc15
...
...
@@ -107,6 +107,13 @@
<version>
6.6.14
</version>
</dependency>
<!--微信支付-->
<dependency>
<groupId>
com.github.wechatpay-apiv3
</groupId>
<artifactId>
wechatpay-java
</artifactId>
<version>
0.2.12
</version>
</dependency>
</dependencies>
...
...
qianhe-admin/src/main/java/com/qianhe/system/controller/WaterOrderController.java
View file @
d1fffc15
...
...
@@ -210,7 +210,11 @@ public class WaterOrderController extends BaseController
@RepeatSubmit
(
message
=
"订单已提交,请勿重复操作!"
)
public
AjaxResult
add
(
@RequestBody
WaterOrderVo
waterOrderVo
)
{
return
toAjax
(
waterOrderService
.
insertWaterOrder
(
waterOrderVo
));
int
i
=
waterOrderService
.
insertWaterOrder
(
waterOrderVo
);
if
(
i
==
-
1
){
return
AjaxResult
.
error
(
"该地址超出配送范围,请重新选择地址!"
);
}
return
toAjax
(
i
);
}
/**
...
...
qianhe-admin/src/main/java/com/qianhe/system/domain/WaterOrder.java
View file @
d1fffc15
...
...
@@ -134,6 +134,12 @@ public class WaterOrder extends BaseEntity
@Excel
(
name
=
"详细地址"
)
private
String
address
;
/** 收货地址经度 */
private
double
lon
;
/** 收货地址纬度 */
private
double
lat
;
/** 收货人手机号 */
@Excel
(
name
=
"收货人手机号"
)
private
Long
mobile
;
...
...
qianhe-admin/src/main/java/com/qianhe/system/domain/WaterUserAddress.java
View file @
d1fffc15
...
...
@@ -46,4 +46,10 @@ public class WaterUserAddress
/** 是否默认地址(1是,0否) */
private
String
isDefault
;
/** 经度 */
private
double
lon
;
/** 纬度 */
private
double
lat
;
}
qianhe-admin/src/main/java/com/qianhe/system/service/impl/WaterOrderServiceImpl.java
View file @
d1fffc15
...
...
@@ -6,8 +6,11 @@ import com.qianhe.common.utils.StringUtils;
import
com.qianhe.system.domain.*
;
import
com.qianhe.system.mapper.*
;
import
com.qianhe.system.service.IWaterOrderService
;
import
com.qianhe.system.utils.PositionUtil
;
import
com.qianhe.system.vo.WaterOrderVo
;
import
com.qianhe.system.vo.WaterStationVo
;
import
io.swagger.models.auth.In
;
import
org.gavaghan.geodesy.Ellipsoid
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -16,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* 订单Service业务层处理
...
...
@@ -36,6 +40,10 @@ public class WaterOrderServiceImpl implements IWaterOrderService
private
WaterGoodsImgMapper
waterGoodsImgMapper
;
@Autowired
private
WaterGoodsCartMapper
waterGoodsCartMapper
;
@Autowired
private
WaterUserAddressMapper
waterUserAddressMapper
;
@Autowired
private
WaterStationMapper
waterStationMapper
;
/**
* 查询订单
...
...
@@ -110,6 +118,20 @@ public class WaterOrderServiceImpl implements IWaterOrderService
if
(
StringUtils
.
isNull
(
waterOrderVo
.
getUserAddressId
())){
throw
new
ServiceException
(
"未选择地址!"
);
}
//判断用户地址是否在配送范围之内
List
<
WaterStationVo
>
stations
=
getStation
(
waterOrderVo
);
if
(
stations
.
size
()
<=
0
){
return
-
1
;
}
WaterStationVo
station
=
stations
.
get
(
0
);
waterOrderVo
.
setStationId
(
station
.
getId
());
waterOrderVo
.
setStationName
(
station
.
getStationName
());
waterOrderVo
.
setStationPhone
(
station
.
getPhoneNum
());
waterOrderVo
.
setStationProvince
(
station
.
getProvince
());
waterOrderVo
.
setStationCity
(
station
.
getCity
());
waterOrderVo
.
setStationArea
(
station
.
getArea
());
waterOrderVo
.
setStationAddress
(
station
.
getStationAddress
());
waterOrderVo
.
setCreateUser
(
waterOrderVo
.
getUserId
().
toString
());
waterOrderVo
.
setCreateTime
(
DateUtils
.
getNowDate
());
waterOrderVo
.
setOrderNum
(
getOrerNum
());
...
...
@@ -132,6 +154,33 @@ public class WaterOrderServiceImpl implements IWaterOrderService
}
/**
* 获取与用户收货地址最近的站点信息
*/
public
List
<
WaterStationVo
>
getStation
(
WaterOrderVo
waterOrderVo
){
//查询用户地址详细信息
WaterUserAddress
waterUserAddress
=
waterUserAddressMapper
.
selectWaterUserAddressById
(
waterOrderVo
.
getUserAddressId
());
//查询所有站点信息
List
<
WaterStation
>
waterStationList
=
waterStationMapper
.
selectWaterStationList
(
new
WaterStation
());
//获取距离用户收货地址最近的站点
List
<
WaterStationVo
>
waterStationVoList
=
new
ArrayList
<>();
for
(
WaterStation
waterStation
:
waterStationList
)
{
//计算距离
double
distance
=
PositionUtil
.
getDistance
(
waterUserAddress
.
getLon
(),
waterUserAddress
.
getLat
(),
waterStation
.
getStationLonTen
(),
waterStation
.
getStationLatTen
(),
Ellipsoid
.
WGS84
);
//换算成千米
double
distance1
=
distance
/
1000
;
if
(
distance1
<=
5
){
WaterStationVo
waterStationVo
=
new
WaterStationVo
();
BeanUtils
.
copyProperties
(
waterStation
,
waterStationVo
);
waterStationVo
.
setDistance
(
distance1
);
waterStationVoList
.
add
(
waterStationVo
);
}
}
//根据距离升序排序
List
<
WaterStationVo
>
collect
=
waterStationVoList
.
stream
().
sorted
(
Comparator
.
comparing
(
WaterStationVo:
:
getDistance
)).
collect
(
Collectors
.
toList
());
return
collect
;
}
/**
* 生成订单编号
* @return
*/
...
...
qianhe-admin/src/main/java/com/qianhe/system/vo/WaterOrderVo.java
View file @
d1fffc15
...
...
@@ -110,6 +110,12 @@ public class WaterOrderVo {
/** 详细地址 */
private
String
address
;
/** 收货地址经度 */
private
double
lon
;
/** 收货地址纬度 */
private
double
lat
;
/** 收货人手机号 */
private
Long
mobile
;
...
...
qianhe-admin/src/main/resources/application.yml
View file @
d1fffc15
...
...
@@ -131,16 +131,28 @@ xss:
# 匹配链接
urlPatterns
:
/system/*,/monitor/*,/tool/*
# 订水端小程序
# 订水端小程序
(含微信支付)
wx
:
#测试
# appId: wxcabea5c944c4327c
# appSecret: bd486fd54bd1ea5e9b198911d765ce6a
# access-token-uri: https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${wx.appId}&secret=${wx.appSecret}
#正式
appId
:
wx75635671bf9fe9bb
appSecret
:
5ac4f25af14d7cfb3e62870fa1719459
access-token-uri
:
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${wx.appId}&secret=${wx.appSecret}
#微信小程序qppid
appId
:
wx3c0181d9800dfbf2
#小程序密钥
appSecret
:
d1382ba5e014038ee38eda00d737ac43
access-token-uri
:
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${sswx.appId}&secret=${sswx.appSecret}
#商户号
mchId
:
xxx
#证书序列号
mch-serial-no
:
xxx
#api密钥
api-key
:
xxx
#回调接口地址
notify-url
:
xxx
#证书地址
key-path
:
xxx
# 送水端小程序
sswx
:
...
...
@@ -149,6 +161,6 @@ sswx:
# appSecret: 27ebe3778435c719cc1b97f260b7e026
# access-token-uri: https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${sswx.appId}&secret=${sswx.appSecret}
#正式
appId
:
wx
3c0181d9800dfbf2
appSecret
:
d1382ba5e014038ee38eda00d737ac43
access-token-uri
:
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${
sswx.appId}&secret=${ss
wx.appSecret}
appId
:
wx
75635671bf9fe9bb
appSecret
:
5ac4f25af14d7cfb3e62870fa1719459
access-token-uri
:
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${
wx.appId}&secret=${
wx.appSecret}
qianhe-admin/src/main/resources/mapper/WaterOrderMapper.xml
View file @
d1fffc15
...
...
@@ -35,6 +35,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"city"
column=
"city"
/>
<result
property=
"area"
column=
"area"
/>
<result
property=
"address"
column=
"address"
/>
<result
property=
"lon"
column=
"lon"
/>
<result
property=
"lat"
column=
"lat"
/>
<result
property=
"mobile"
column=
"mobile"
/>
<result
property=
"delieverTime"
column=
"deliever_time"
/>
<result
property=
"delieverName"
column=
"deliever_name"
/>
...
...
@@ -51,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql
id=
"selectWaterOrderVo"
>
select id, order_num, user_id, user_name, user_phone, user_province, user_city, user_area, user_address, station_id, station_name, station_phone, station_province, station_city, station_area, station_address, order_goods_type, order_state, complete_state, confirm_state, pay_state, pay_type, pay_num, cancel_result, user_address_id, name, province, city, area, address, mobile, deliever_time, deliever_name, deliever_mobile, create_time, create_user, deliever_over, take_time, finish_time, remark, goods_val, order_type, return_order_result from water_order
select id, order_num, user_id, user_name, user_phone, user_province, user_city, user_area, user_address, station_id, station_name, station_phone, station_province, station_city, station_area, station_address, order_goods_type, order_state, complete_state, confirm_state, pay_state, pay_type, pay_num, cancel_result, user_address_id, name, province, city, area, address,
lon, lat,
mobile, deliever_time, deliever_name, deliever_mobile, create_time, create_user, deliever_over, take_time, finish_time, remark, goods_val, order_type, return_order_result from water_order
</sql>
<select
id=
"selectWaterOrderList"
parameterType=
"com.qianhe.system.vo.WaterOrderVo"
resultMap=
"WaterOrderResult"
>
...
...
@@ -141,7 +143,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"payState != null"
>
pay_state,
</if>
<if
test=
"payType != null"
>
pay_type,
</if>
<if
test=
"payNum != null"
>
pay_num,
</if>
<if
test=
"userAddressId != null"
>
user_address_id,name,province,city,area,address,mobile,
</if>
<if
test=
"userAddressId != null"
>
user_address_id,name,province,city,area,address,
lon,lat,
mobile,
</if>
<if
test=
"delieverTime != null"
>
deliever_time,
</if>
<if
test=
"delieverName != null"
>
deliever_name,
</if>
<if
test=
"delieverMobile != null"
>
deliever_mobile,
</if>
...
...
@@ -187,6 +189,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(select city from water_user_address where id = #{userAddressId}),
(select area from water_user_address where id = #{userAddressId}),
(select user_address from water_user_address where id = #{userAddressId}),
(select lon from water_user_address where id = #{userAddressId}),
(select lat from water_user_address where id = #{userAddressId}),
(select phone from water_user_address where id = #{userAddressId}),
</if>
<if
test=
"delieverTime != null"
>
#{delieverTime},
</if>
...
...
@@ -240,6 +244,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
city = (select city from water_user_address where id = #{userAddressId}),
area = (select area from water_user_address where id = #{userAddressId}),
address = (select user_address from water_user_address where id = #{userAddressId}),
lon = (select lon from water_user_address where id = #{userAddressId}),
lat = (select lat from water_user_address where id = #{userAddressId}),
mobile = (select phone from water_user_address where id = #{userAddressId}),
</if>
<if
test=
"delieverTime != null"
>
deliever_time = #{delieverTime},
</if>
...
...
qianhe-admin/src/main/resources/mapper/WaterUserAddressMapper.xml
View file @
d1fffc15
...
...
@@ -14,10 +14,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"name"
column=
"name"
/>
<result
property=
"phone"
column=
"phone"
/>
<result
property=
"isDefault"
column=
"is_default"
/>
<result
property=
"lon"
column=
"lon"
/>
<result
property=
"lat"
column=
"lat"
/>
</resultMap>
<sql
id=
"selectWaterUserAddressVo"
>
select id, water_user_id, user_address, province, city, area, name, phone, is_default from water_user_address
select id, water_user_id, user_address, province, city, area, name, phone, is_default
, lon, lat
from water_user_address
</sql>
<select
id=
"selectWaterUserAddressList"
parameterType=
"WaterUserAddress"
resultMap=
"WaterUserAddressResult"
>
...
...
@@ -56,6 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"name != null"
>
name,
</if>
<if
test=
"phone != null"
>
phone,
</if>
<if
test=
"isDefault != null"
>
is_default,
</if>
<if
test=
"lon != null"
>
lon,
</if>
<if
test=
"lat != null"
>
lat,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"waterUserId != null"
>
#{waterUserId},
</if>
...
...
@@ -66,6 +70,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"name != null"
>
#{name},
</if>
<if
test=
"phone != null"
>
#{phone},
</if>
<if
test=
"isDefault != null"
>
#{isDefault},
</if>
<if
test=
"lon != null"
>
#{lon},
</if>
<if
test=
"lat != null"
>
#{lat},
</if>
</trim>
</insert>
...
...
@@ -80,6 +86,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"name != null"
>
name = #{name},
</if>
<if
test=
"phone != null"
>
phone = #{phone},
</if>
<if
test=
"isDefault != null"
>
is_default = #{isDefault},
</if>
<if
test=
"lon != null"
>
lon = #{lon},
</if>
<if
test=
"lat != null"
>
lat = #{lat},
</if>
</trim>
where id = #{id}
</update>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment