Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
oms
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
oms
Commits
2198e12b
提交
2198e12b
authored
7月 06, 2023
作者:
张小凤
提交者:
余乾开
7月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Price(update)
上级
1e3600fb
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
80 行增加
和
41 行删除
+80
-41
ResultEnum.java
src/main/java/com/mmc/oms/common/ResultEnum.java
+2
-1
PriceAcquisition.java
...ain/java/com/mmc/oms/model/vo/order/PriceAcquisition.java
+3
-1
RentalOrdersServiceImpl.java
...ava/com/mmc/oms/service/Impl/RentalOrdersServiceImpl.java
+74
-37
application-local.yml
src/main/resources/application-local.yml
+1
-2
没有找到文件。
src/main/java/com/mmc/oms/common/ResultEnum.java
浏览文件 @
2198e12b
...
...
@@ -404,7 +404,8 @@ public enum ResultEnum implements BaseErrorInfoInterface {
NO_PERMISSION_TEMPORARILY
(
"2016"
,
"当前账号没有权限,只有后台账号拥有权限"
),
THERE_IS_NO_SUCH_ORDER
(
"2017"
,
"没有当前订单,请输入正确的订单编号"
),
THE_TOKEN_CANNOT_BE_NULL
(
"2018"
,
"token不能为null"
),
THE_CURRENT_ACCOUNT_CANNOT_PLACE_ORDERS
(
"2019"
,
"后台管理账号不能下单"
);
THE_CURRENT_ACCOUNT_CANNOT_PLACE_ORDERS
(
"2019"
,
"后台管理账号不能下单"
),
THIRD_PARTY_ERRORS
(
"2020"
,
"第三方接口错误或者第三接口正在更新"
);
/**
* 错误码
...
...
src/main/java/com/mmc/oms/model/vo/order/PriceAcquisition.java
浏览文件 @
2198e12b
...
...
@@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
/**
* @Author small
* @Date 2023/5/26 14:10
...
...
@@ -24,6 +26,6 @@ public class PriceAcquisition {
private
Integer
day
;
@ApiModelProperty
(
value
=
"渠道等级id"
)
private
Integer
channelLevelId
;
private
List
<
Integer
>
channelLevelId
;
}
src/main/java/com/mmc/oms/service/Impl/RentalOrdersServiceImpl.java
浏览文件 @
2198e12b
...
...
@@ -18,6 +18,7 @@ import com.mmc.oms.entity.order.OrderReceiptDO;
import
com.mmc.oms.entity.order.OrderRefundDO
;
import
com.mmc.oms.entity.order.OrderVcuDO
;
import
com.mmc.oms.entity.ware.WareInfoDO
;
import
com.mmc.oms.model.dto.mall.CooperationTagVO
;
import
com.mmc.oms.model.dto.order.*
;
import
com.mmc.oms.model.dto.repo.RepoAccountDTO
;
import
com.mmc.oms.model.dto.transtatus.TranStatusDicDTO
;
...
...
@@ -28,6 +29,7 @@ import com.mmc.oms.model.vo.coupon.AppletMsgVO;
import
com.mmc.oms.model.vo.order.*
;
import
com.mmc.oms.service.RentalOrdersService
;
import
com.mmc.oms.wx.WxMsgTemplete
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -40,9 +42,11 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestClientException
;
import
org.springframework.web.client.RestTemplate
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -51,6 +55,7 @@ import java.util.stream.Collectors;
* @Author small @Date 2023/5/26 10:53 @Version 1.0
*/
@Service
@Slf4j
public
class
RentalOrdersServiceImpl
implements
RentalOrdersService
{
@Autowired
...
...
@@ -79,13 +84,20 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
return
ResultBody
.
error
(
ResultEnum
.
THE_CURRENT_ACCOUNT_CANNOT_PLACE_ORDERS
);
}
//用户信息的远程调用
ResponseEntity
<
String
>
responseEntity
=
UserId
(
user
.
getUserAccountId
(),
user
.
getToken
());
ResultBody
<
ResponseEntity
<
String
>>
responseEntityResultBody
=
UserId
(
user
.
getUserAccountId
(),
user
.
getToken
());
if
(
ResultEnum
.
THIRD_PARTY_ERRORS
.
getResultCode
().
equals
(
responseEntityResultBody
.
getCode
())){
return
ResultBody
.
error
(
ResultEnum
.
THIRD_PARTY_ERRORS
);
}
ResponseEntity
<
String
>
responseEntity
=
responseEntityResultBody
.
getResult
();
UserAccountSimpleDTO
account
=
JSON
.
parseObject
(
responseEntity
.
getBody
(),
UserAccountSimpleDTO
.
class
);
//优惠券id获取优惠券面值
OrderInfoDO
orderInfo
=
new
OrderInfoDO
(
param
);
PriceAcquisition
priceAcquisition
=
getPriceAcquisition
(
param
,
account
);
BigDecimal
unitPrice
=
getUnitPrice
(
priceAcquisition
);
ResultBody
<
BigDecimal
>
bigDecimalResultBody
=
getUnitPrice
(
priceAcquisition
);
if
(
ResultEnum
.
THIRD_PARTY_ERRORS
.
getResultCode
().
equals
(
bigDecimalResultBody
.
getCode
())){
return
ResultBody
.
error
(
ResultEnum
.
THIRD_PARTY_ERRORS
);
}
BigDecimal
unitPrice
=
bigDecimalResultBody
.
getResult
();
//每天单价
orderInfo
.
setUnitPrice
(
unitPrice
);
// 天数
...
...
@@ -96,6 +108,11 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
orderInfo
.
setBuyerName
(
user
.
getUserName
());
orderInfo
.
setBuyerPhone
(
user
.
getPhoneNum
());
orderInfo
.
setNickName
(
user
.
getNickName
());
//获取剩余的余额
ResultBody
<
BigDecimal
>
remainingBalance
=
getRemainingBalance
(
user
.
getToken
(),
user
.
getUserAccountId
());
if
(
ResultEnum
.
THIRD_PARTY_ERRORS
.
getResultCode
().
equals
(
remainingBalance
.
getCode
()))
{
return
ResultBody
.
error
(
ResultEnum
.
THIRD_PARTY_ERRORS
);
}
rentalOrdersDao
.
insertOrderInfo
(
orderInfo
);
// 添加收货地址
Date
cdate
=
new
Date
();
...
...
@@ -104,8 +121,7 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
receipt
.
setOrderInfoId
(
orderInfo
.
getId
());
receipt
.
setCreateTime
(
cdate
);
rentalOrdersDao
.
insertOrderReceipt
(
receipt
);
//获取剩余的余额
orderInfo
.
setBalance
(
getRemainingBalance
(
user
.
getToken
(),
user
.
getUserAccountId
()));
orderInfo
.
setBalance
(
remainingBalance
.
getResult
());
// 将当前的用户id及订单编号存入redis
OrderInfoDTO
dto
=
orderInfo
.
buildOrderInfoDTO
();
stringRedisTemplate
.
opsForValue
().
set
(
orderInfo
.
getOrderNo
(),
JsonUtil
.
parseObjToJson
(
dto
));
...
...
@@ -132,25 +148,36 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
//远程设置
private
PriceAcquisition
getPriceAcquisition
(
LeaseOrderVO
param
,
UserAccountSimpleDTO
account
)
{
List
<
CooperationTagVO
>
cooperationTagVOS
=
account
.
getCooperationTagVOS
();
List
<
Integer
>
list
=
new
ArrayList
<>();
if
(
cooperationTagVOS
!=
null
&&
!
cooperationTagVOS
.
isEmpty
()){
for
(
CooperationTagVO
cooperationTagVO
:
cooperationTagVOS
)
{
list
.
add
(
cooperationTagVO
.
getId
());
}
}
PriceAcquisition
priceAcquisition
=
new
PriceAcquisition
();
priceAcquisition
.
setUserId
(
account
.
getId
());
priceAcquisition
.
setDay
(
day
(
param
));
priceAcquisition
.
setSpecsId
(
param
.
getSpecsId
());
priceAcquisition
.
setChannelLevelId
(
account
.
getCooperationTagId
()
);
priceAcquisition
.
setChannelLevelId
(
list
);
return
priceAcquisition
;
}
private
ResponseEntity
<
String
>
UserId
(
Integer
repoAccountId
,
String
token
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
//封装请求头
headers
.
add
(
"token"
,
token
);
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
formEntity
=
new
HttpEntity
<
MultiValueMap
<
String
,
Object
>>(
headers
);
ResponseEntity
<
String
>
response
=
restTemplate
.
exchange
(
userAppUrl
+
"user-account/feignGetUserSimpleInfo?userAccountId="
+
repoAccountId
,
HttpMethod
.
GET
,
formEntity
,
String
.
class
);
private
ResultBody
<
ResponseEntity
<
String
>>
UserId
(
Integer
repoAccountId
,
String
token
)
{
ResponseEntity
<
String
>
response
=
null
;
try
{
HttpHeaders
headers
=
new
HttpHeaders
();
//封装请求头
headers
.
add
(
"token"
,
token
);
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
formEntity
=
new
HttpEntity
<
MultiValueMap
<
String
,
Object
>>(
headers
);
response
=
restTemplate
.
exchange
(
userAppUrl
+
"user-account/feignGetUserSimpleInfo?userAccountId="
+
repoAccountId
,
HttpMethod
.
GET
,
formEntity
,
String
.
class
);
log
.
info
(
String
.
valueOf
(
formEntity
));
}
catch
(
RestClientException
e
)
{
return
ResultBody
.
error
(
ResultEnum
.
THIRD_PARTY_ERRORS
);
}
// 用户信息
/* ResponseEntity<String> response =
restTemplate.getForEntity(
...
...
@@ -158,7 +185,7 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
+ "user-account/feignGetUserSimpleInfo?userAccountId="
+ repoAccountId,
String.class);*/
return
response
;
return
ResultBody
.
success
(
response
)
;
}
...
...
@@ -168,19 +195,24 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
* @param repoAccountId
* @return
*/
public
BigDecimal
getRemainingBalance
(
String
token
,
Integer
repoAccountId
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
//封装请求头
headers
.
add
(
"token"
,
token
);
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
formEntity
=
new
HttpEntity
<
MultiValueMap
<
String
,
Object
>>(
headers
);
ResponseEntity
<
String
>
result4
=
restTemplate
.
exchange
(
paymentUrl
+
"repocash/RemainingBalance?repoAccountId="
+
repoAccountId
,
HttpMethod
.
GET
,
formEntity
,
String
.
class
);
String
body
=
result4
.
getBody
();
if
(
body
==
null
)
{
body
=
"0"
;
public
ResultBody
<
BigDecimal
>
getRemainingBalance
(
String
token
,
Integer
repoAccountId
)
{
BigDecimal
bigDecimal
=
null
;
try
{
HttpHeaders
headers
=
new
HttpHeaders
();
//封装请求头
headers
.
add
(
"token"
,
token
);
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
formEntity
=
new
HttpEntity
<
MultiValueMap
<
String
,
Object
>>(
headers
);
ResponseEntity
<
String
>
result4
=
restTemplate
.
exchange
(
paymentUrl
+
"repocash/RemainingBalance?repoAccountId="
+
repoAccountId
,
HttpMethod
.
GET
,
formEntity
,
String
.
class
);
String
body
=
result4
.
getBody
();
if
(
body
==
null
)
{
body
=
"0"
;
}
bigDecimal
=
new
BigDecimal
(
body
);
}
catch
(
RestClientException
e
)
{
return
ResultBody
.
error
(
ResultEnum
.
THIRD_PARTY_ERRORS
);
}
BigDecimal
bigDecimal
=
new
BigDecimal
(
body
);
return
bigDecimal
;
return
ResultBody
.
success
(
bigDecimal
);
}
/**
...
...
@@ -207,19 +239,24 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
* @param param
* @return
*/
private
BigDecimal
getUnitPrice
(
PriceAcquisition
param
)
{
private
ResultBody
<
BigDecimal
>
getUnitPrice
(
PriceAcquisition
param
)
{
// 需要支付的价格
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
postForEntity
(
pmsUrl
+
"/product/spec/feignGetSpecLeaseUnitPrice"
,
param
,
String
.
class
);
String
body
=
responseEntity
.
getBody
();
if
(
null
==
body
)
{
body
=
"0"
;
BigDecimal
bigDecimal
=
null
;
try
{
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
postForEntity
(
pmsUrl
+
"product/spec/feignGetSpecLeaseUnitPrice"
,
param
,
String
.
class
);
String
body
=
responseEntity
.
getBody
();
if
(
null
==
body
)
{
body
=
"0"
;
}
bigDecimal
=
new
BigDecimal
(
body
);
}
catch
(
RestClientException
e
)
{
return
ResultBody
.
error
(
ResultEnum
.
THIRD_PARTY_ERRORS
);
}
BigDecimal
bigDecimal
=
new
BigDecimal
(
body
);
// 模拟
// int i = 12;
// BigDecimal bigDecimal = BigDecimal.valueOf(i);
return
bigDecimal
;
return
ResultBody
.
success
(
bigDecimal
)
;
}
public
Integer
day
(
LeaseOrderVO
param
)
{
...
...
src/main/resources/application-local.yml
浏览文件 @
2198e12b
...
...
@@ -7,9 +7,8 @@ spring:
password
:
MMC@2022&MYSQL
redis
:
database
:
1
host
:
r-wz9ke310fs684hacn1pd.redis.rds.aliyuncs.com
host
:
127.0.0.1
port
:
6379
password
:
MMC@2022&REDIS
jedis
:
pool
:
max-active
:
2
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论