Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
oms-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
oms-ci-test
Commits
641b4e4f
提交
641b4e4f
authored
6月 02, 2023
作者:
张小凤
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rental(add)
上级
8826de2a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
97 行增加
和
61 行删除
+97
-61
RentalOrdersDao.java
src/main/java/com/mmc/oms/dao/RentalOrdersDao.java
+2
-0
RentalOrdersServiceImpl.java
...ava/com/mmc/oms/service/Impl/RentalOrdersServiceImpl.java
+57
-59
RentalOrdersService.java
src/main/java/com/mmc/oms/service/RentalOrdersService.java
+5
-2
application-local.yml
src/main/resources/application-local.yml
+3
-0
RentalOrdersDao.xml
src/main/resources/mapper/RentalOrdersDao.xml
+30
-0
没有找到文件。
src/main/java/com/mmc/oms/dao/RentalOrdersDao.java
浏览文件 @
641b4e4f
...
...
@@ -52,4 +52,6 @@ public interface RentalOrdersDao {
OrderRefundDO
getApplicationInformation
(
Integer
id
);
CouponDO
couponMoney
(
Integer
couponId
);
}
src/main/java/com/mmc/oms/service/Impl/RentalOrdersServiceImpl.java
浏览文件 @
641b4e4f
...
...
@@ -48,21 +48,28 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
@Value
(
"${userapp.url}"
)
private
String
userAppUrl
;
@Value
(
"${pms.url}"
)
private
String
pmsUrl
;
@Value
(
"${payment.url}"
)
private
String
paymentUrl
;
@Override
public
OrderInfoDTO
feignAddLease
(
BaseAccountDTO
user
,
LeaseOrderVO
param
)
{
//用户信息的远程调用
ResponseEntity
<
String
>
responseEntity
=
UserId
(
user
.
getUserAccountId
());
UserAccountSimpleDTO
account
=
JSON
.
parseObject
(
responseEntity
.
getBody
(),
UserAccountSimpleDTO
.
class
);
OrderInfoDO
orderInfo
=
new
OrderInfoDO
(
param
);
//优惠券id获取优惠券面值
// 每天单价
BigDecimal
unitPrice
=
orderInfo
.
getUnitPrice
(
);
int
i
=
12
;
BigDecimal
bigDecimal
=
BigDecimal
.
valueOf
(
i
);
orderInfo
.
setUnitPrice
(
bigDecimal
);
OrderInfoDO
orderInfo
=
new
OrderInfoDO
(
param
);
PriceAcquisition
priceAcquisition
=
getPriceAcquisition
(
param
,
account
);
BigDecimal
unitPrice
=
getUnitPrice
(
priceAcquisition
)
;
//每天单价
orderInfo
.
setUnitPrice
(
unitPrice
);
// 天数
orderInfo
.
set
PayDay
(
2
);
orderInfo
.
set
ActualPay
(
extracted
(
param
,
unitPrice
)
);
orderInfo
.
setPayDay
(
day
(
param
));
orderInfo
.
setRepoAccountId
(
user
.
getUserAccountId
());
orderInfo
.
setUid
(
user
.
getUid
());
orderInfo
.
setBuyerName
(
user
.
getUserName
());
...
...
@@ -83,6 +90,34 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
return
dto
;
}
/**
* 实际需要支付价格计算
*
* @param param
*/
private
BigDecimal
extracted
(
LeaseOrderVO
param
,
BigDecimal
unitPrice
)
{
CouponDO
couponDO
=
rentalOrdersDao
.
couponMoney
(
param
.
getCouponId
());
BigDecimal
couponMoney
=
BigDecimal
.
valueOf
(
0
);
if
(
couponDO
!=
null
)
{
couponMoney
=
couponDO
.
getCouponMoney
();
}
//实际需要支付的价格
BigDecimal
dayDecimal
=
BigDecimal
.
valueOf
(
day
(
param
));
BigDecimal
multiply
=
dayDecimal
.
multiply
(
unitPrice
);
BigDecimal
actualPay
=
multiply
.
subtract
(
couponMoney
);
return
actualPay
;
}
//远程设置
private
PriceAcquisition
getPriceAcquisition
(
LeaseOrderVO
param
,
UserAccountSimpleDTO
account
)
{
PriceAcquisition
priceAcquisition
=
new
PriceAcquisition
();
priceAcquisition
.
setUserId
(
account
.
getId
());
priceAcquisition
.
setDay
(
day
(
param
));
priceAcquisition
.
setSpecsId
(
param
.
getSpecsId
());
priceAcquisition
.
setChannelLevelId
(
account
.
getCooperationTagId
());
return
priceAcquisition
;
}
private
ResponseEntity
<
String
>
UserId
(
Integer
repoAccountId
)
{
// 用户信息
...
...
@@ -95,38 +130,6 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
return
response
;
}
@Override
@Transactional
public
ResultBody
addLease
(
BaseAccountDTO
account
,
RentalOrderVO
param
)
{
// 通过用户获取渠道等级id 未完善
Integer
channelLevelId
=
getChannelLevel
(
account
.
getUserAccountId
());
// 通过渠道等级获取每一天的单价 未完善
Double
unitPrice
=
getUnitPrice
(
param
,
channelLevelId
);
Integer
day
=
day
(
param
);
// 计算方式 单价 乘以 数量*天数 减去优惠券的价格最后得到需要支付的价格是吗
// 需要支付的价格
Double
payment
=
null
;
payment
=
unitPrice
*
param
.
getWareNum
()
*
day
;
CouponUserDO
coupon
=
rentalOrdersDao
.
coupon
(
param
.
getCouponId
());
// 优惠券是否过期
long
now
=
System
.
currentTimeMillis
();
long
time
=
coupon
.
getEndTime
().
getTime
();
if
(
now
>
time
)
{
return
ResultBody
.
error
(
"优惠券过期"
);
}
BigDecimal
couponMoney
=
coupon
.
getCouponMoney
();
double
v
=
couponMoney
.
doubleValue
();
payment
-=
v
;
// 下单
OrderInfoDO
orderInfoDO
=
new
OrderInfoDO
();
// rentalOrdersDao.insertOrderInfo(orderInfo);
return
ResultBody
.
success
();
}
/**
* 通过用户id 获取用户剩余的金额
...
...
@@ -139,7 +142,7 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
//封装请求头
headers
.
add
(
"token"
,
token
);
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
formEntity
=
new
HttpEntity
<
MultiValueMap
<
String
,
Object
>>(
headers
);
ResponseEntity
<
String
>
result4
=
restTemplate
.
exchange
(
"http://localhost:8088/payment/
repocash/RemainingBalance?repoAccountId="
+
repoAccountId
,
ResponseEntity
<
String
>
result4
=
restTemplate
.
exchange
(
paymentUrl
+
"
repocash/RemainingBalance?repoAccountId="
+
repoAccountId
,
HttpMethod
.
GET
,
formEntity
,
String
.
class
);
String
body
=
result4
.
getBody
();
BigDecimal
bigDecimal
=
new
BigDecimal
(
body
);
...
...
@@ -162,38 +165,33 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
return
1
;
}
/**
* 获取每一天的价格
*
* @param
* @param param
* @param channelLevelId
* @return
*/
private
Double
getUnitPrice
(
RentalOrderVO
param
,
Integer
channelLevelId
)
{
PriceAcquisition
priceAcquisition
=
new
PriceAcquisition
();
// 传 规格id ,用户id,天数,渠道等级id 给刘,获取到价格
Date
startDate
=
param
.
getStartDate
();
Date
endDate
=
param
.
getEndDate
();
long
start
=
startDate
.
getTime
();
long
end
=
endDate
.
getTime
();
long
day
=
end
-
start
;
int
i
=
(
int
)
day
;
// 调用远程接口获取单价 计算方式 单价 乘以 数量*天数 减去优惠券的价格最后得到需要支付的价格是吗
// 单价
Integer
unitPrice
=
1
;
private
BigDecimal
getUnitPrice
(
PriceAcquisition
param
)
{
// 需要支付的价格
return
12.09
;
/* ResponseEntity<String> responseEntity = restTemplate.postForEntity(pmsUrl + "product/spec/getSpecLeaseUnitPrice"
, param, String.class);
String body = responseEntity.getBody();
BigDecimal bigDecimal = new BigDecimal(body);*/
// 模拟
int
i
=
12
;
BigDecimal
bigDecimal
=
BigDecimal
.
valueOf
(
i
);
return
bigDecimal
;
}
public
Integer
day
(
Rental
OrderVO
param
)
{
public
Integer
day
(
Lease
OrderVO
param
)
{
Date
startDate
=
param
.
getStartDate
();
Date
endDate
=
param
.
getEndDate
();
long
start
=
startDate
.
getTime
();
long
end
=
endDate
.
getTime
();
long
day
=
end
-
start
;
int
i
=
(
int
)
day
;
Integer
i
=
(
int
)
day
/
24
/
60
/
60
/
1000
;
return
i
;
}
...
...
src/main/java/com/mmc/oms/service/RentalOrdersService.java
浏览文件 @
641b4e4f
...
...
@@ -5,13 +5,16 @@ import com.mmc.oms.common.ResultBody;
import
com.mmc.oms.model.dto.BaseAccountDTO
;
import
com.mmc.oms.model.dto.OrderInfoDTO
;
import
com.mmc.oms.model.qo.OrderInfoQO
;
import
com.mmc.oms.model.vo.*
;
import
com.mmc.oms.model.vo.LeaseOrderVO
;
import
com.mmc.oms.model.vo.OrderStatusVO
;
import
com.mmc.oms.model.vo.OrderVcuVO
;
import
com.mmc.oms.model.vo.ReturnWareVO
;
/**
* @Author small @Date 2023/5/26 10:52 @Version 1.0
*/
public
interface
RentalOrdersService
{
ResultBody
addLease
(
BaseAccountDTO
account
,
RentalOrderVO
rentalOrderVO
);
OrderInfoDTO
getOrderDetail
(
String
orderNo
);
...
...
src/main/resources/application-local.yml
浏览文件 @
641b4e4f
...
...
@@ -56,4 +56,7 @@ userapp:
payment
:
url
:
http://localhost:8088/payment/
pms
:
url
:
http://localhost:8099/pms/
src/main/resources/mapper/RentalOrdersDao.xml
浏览文件 @
641b4e4f
...
...
@@ -583,4 +583,34 @@
FROM order_refund
where order_info_id = #{id}
</select>
<select
id=
"couponMoney"
resultType=
"com.mmc.oms.entity.CouponDO"
>
select id,
coupon_name,
coupon_money AS couponMoney,
coupon_discount,
is_limited,
restricted_access,
coupon_total,
last_total,
coupon_type,
use_type,
min_price,
primary_key,
is_fixed_time,
use_start_time,
use_end_time,
coupon_day,
get_type,
user_tag,
coupon_status,
is_del,
create_time,
update_time,
preferential_limit,
verification_type
from coupon
where is_del = false
and id = #{couponId}
</select>
</mapper>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论