Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
oms
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
oms
Commits
f7826a26
提交
f7826a26
authored
5月 29, 2023
作者:
张小凤
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
user(add)
上级
9b63feb2
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
259 行增加
和
329 行删除
+259
-329
pom.xml
pom.xml
+19
-16
AuthHandler.java
src/main/java/com/mmc/oms/common/AuthHandler.java
+1
-28
RentalOrdersController.java
...n/java/com/mmc/oms/controller/RentalOrdersController.java
+2
-2
JwtUtil.java
src/main/java/com/mmc/oms/jwt/JwtUtil.java
+0
-58
RentalOrdersServiceImpl.java
...ava/com/mmc/oms/service/Impl/RentalOrdersServiceImpl.java
+233
-224
RentalOrdersService.java
src/main/java/com/mmc/oms/service/RentalOrdersService.java
+3
-1
application-local.yml
src/main/resources/application-local.yml
+1
-0
没有找到文件。
pom.xml
浏览文件 @
f7826a26
...
...
@@ -18,6 +18,17 @@
</properties>
<dependencies>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.2
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpcore
</artifactId>
<version>
4.4.5
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
3.10.2
</version>
...
...
@@ -49,12 +60,6 @@
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
easyexcel-core
</artifactId>
<version>
3.1.3
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
...
...
@@ -103,10 +108,6 @@
<version>
0.9.1
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.4.3.4
</version>
...
...
@@ -117,12 +118,6 @@
<version>
3.0.0
</version>
<!--<scope>compile</scope>-->
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
2.0.32
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
...
...
@@ -144,6 +139,14 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
11
</source>
<target>
11
</target>
</configuration>
</plugin>
</plugins>
</build>
...
...
src/main/java/com/mmc/oms/common/AuthHandler.java
浏览文件 @
f7826a26
...
...
@@ -2,7 +2,7 @@ package com.mmc.oms.common;
import
com.alibaba.fastjson.JSONArray
;
import
com.mmc.oms.jwt.JwtConstant
;
import
com.mmc.oms.jwt.JwtUtil
;
import
com.mmc.oms.model.dto.BaseAccountDTO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
...
...
@@ -55,33 +55,6 @@ public class AuthHandler {
return
account
;
}
public
String
addLoginCache
(
Integer
userId
,
Integer
roleId
,
String
tokenType
,
BaseAccountDTO
loginInfo
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
JwtConstant
.
USERIDKEY
,
userId
);
map
.
put
(
JwtConstant
.
ROLEIDKEY
,
roleId
);
map
.
put
(
JwtConstant
.
TOKEN_TYPE
,
tokenType
);
String
token
=
JwtUtil
.
createJwt
(
map
);
// loginInfo.setTokenPort(tokenType);
// 缓存登录token-jwt
stringRedisTemplate
.
opsForValue
().
set
(
RedisConstant
.
createLoginTokenKey
(
tokenType
,
roleId
.
toString
(),
userId
.
toString
()),
token
,
JwtConstant
.
EXPIRATION
,
TimeUnit
.
MILLISECONDS
);
// 平台PC管理端登录保存-单位的id及无限下级id集合
if
(
JwtConstant
.
SXTB_ACCOUNT_TOKEN
.
equals
(
tokenType
))
{
/*if (loginInfo.getCompanyInfo() != null && !CollectionUtils.isEmpty(loginInfo.getCompanyInfo().getCompanys())) {
List<Integer> companys = loginInfo.getCompanyInfo().getCompanys();
this.refreshCompanys(companys, loginInfo.getCompanyInfo().getId());
// 置为null--省内存
loginInfo.getCompanyInfo().setCompanys(null);
}*/
}
// 缓存登录对象
stringRedisTemplate
.
opsForValue
().
set
(
token
,
JsonUtil
.
parseObjToJson
(
loginInfo
),
JwtConstant
.
EXPIRATION
,
TimeUnit
.
MILLISECONDS
);
return
token
;
}
/**
* 更新单位缓存
...
...
src/main/java/com/mmc/oms/controller/RentalOrdersController.java
浏览文件 @
f7826a26
...
...
@@ -24,8 +24,8 @@ public class RentalOrdersController extends BaseController{
@ApiOperation
(
value
=
"租赁-下单"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
OrderInfoDTO
.
class
)})
@PostMapping
(
"feignAddLease"
)
public
OrderInfoDTO
feignAddLease
(
@RequestBody
LeaseOrderVO
param
)
{
return
rentalOrdersService
.
feignAddLease
(
param
);
public
OrderInfoDTO
feignAddLease
(
HttpServletRequest
request
,
@RequestBody
LeaseOrderVO
param
)
{
return
rentalOrdersService
.
feignAddLease
(
request
,
param
);
}
@ApiOperation
(
value
=
"订单-详情"
)
...
...
src/main/java/com/mmc/oms/jwt/JwtUtil.java
deleted
100644 → 0
浏览文件 @
9b63feb2
package
com
.
mmc
.
oms
.
jwt
;
import
com.mmc.oms.common.CodeUtil
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.JwtBuilder
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.xml.bind.DatatypeConverter
;
import
java.security.Key
;
import
java.util.Date
;
import
java.util.Map
;
/**
* @Author small
* @Date 2023/5/24 16:01
* @Version 1.0
*/
public
class
JwtUtil
{
/**
* 根据map中的信息生成token, tokenId为随机生成码,有效时间为24h
*
* @param claims 封装到token中的map
* @return
*/
public
static
String
createJwt
(
Map
<
String
,
Object
>
claims
)
{
return
createJwt
(
claims
,
JwtConstant
.
EXPIRATION
);
}
public
static
String
createJwt
(
Map
<
String
,
Object
>
claims
,
long
expiration
)
{
SignatureAlgorithm
signatureAlgorithm
=
SignatureAlgorithm
.
HS256
;
byte
[]
apiKeySecretBytes
=
DatatypeConverter
.
parseBase64Binary
(
JwtConstant
.
BASE64KEY
);
Key
signingKey
=
new
SecretKeySpec
(
apiKeySecretBytes
,
signatureAlgorithm
.
getJcaName
());
long
nowMillis
=
System
.
currentTimeMillis
();
long
expMillis
=
nowMillis
+
expiration
;
Date
now
=
new
Date
(
nowMillis
);
Date
exp
=
new
Date
(
expMillis
);
JwtBuilder
builder
=
Jwts
.
builder
().
setClaims
(
claims
).
setId
(
CodeUtil
.
randomCode
(
6
)).
setIssuedAt
(
now
)
.
setSubject
(
JwtConstant
.
SUBJECT
).
setIssuer
(
JwtConstant
.
ISSUER
).
signWith
(
signatureAlgorithm
,
signingKey
)
.
setExpiration
(
exp
);
return
builder
.
compact
();
}
/**
* 解析前端传来的token,解析成功则返回Claims,解析失败返回null;解析成功后可通过claims获取信息
*
* @param jwt
* @return
*/
public
static
Claims
parseJwt
(
String
jwt
)
{
Claims
claims
=
Jwts
.
parser
().
setSigningKey
(
DatatypeConverter
.
parseBase64Binary
(
JwtConstant
.
BASE64KEY
))
.
parseClaimsJws
(
jwt
).
getBody
();
return
claims
;
}
}
src/main/java/com/mmc/oms/service/Impl/RentalOrdersServiceImpl.java
浏览文件 @
f7826a26
...
...
@@ -12,12 +12,17 @@ import com.mmc.oms.model.vo.RentalOrderVO;
import
com.mmc.oms.service.RentalOrdersService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.ResponseEntity
;
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.RestTemplate
;
import
javax.servlet.http.HttpServletRequest
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -29,260 +34,264 @@ import java.util.stream.Collectors;
@Service
public
class
RentalOrdersServiceImpl
implements
RentalOrdersService
{
@Autowired
private
RestTemplate
restTemplate
;
@Autowired
private
RestTemplate
restTemplate
;
@Autowired
private
RentalOrdersDao
rentalOrdersDao
;
@Autowired
private
RentalOrdersDao
rentalOrdersDao
;
@Autowired
private
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
StringRedisTemplate
stringRedisTemplate
;
@Override
public
OrderInfoDTO
feignAddLease
(
LeaseOrderVO
param
)
{
OrderInfoDO
orderInfo
=
new
OrderInfoDO
(
param
);
// 每天单价
BigDecimal
unitPrice
=
orderInfo
.
getUnitPrice
();
int
i
=
12
;
BigDecimal
bigDecimal
=
BigDecimal
.
valueOf
(
i
);
orderInfo
.
setUnitPrice
(
bigDecimal
);
// 天数
orderInfo
.
setPayDay
(
2
);
@Override
public
OrderInfoDTO
feignAddLease
(
HttpServletRequest
request
,
LeaseOrderVO
param
)
{
OrderInfoDO
orderInfo
=
new
OrderInfoDO
(
param
);
// 每天单价
BigDecimal
unitPrice
=
orderInfo
.
getUnitPrice
();
int
i
=
12
;
BigDecimal
bigDecimal
=
BigDecimal
.
valueOf
(
i
);
orderInfo
.
setUnitPrice
(
bigDecimal
);
// 天数
orderInfo
.
setPayDay
(
2
);
rentalOrdersDao
.
insertOrderInfo
(
orderInfo
);
// 添加收货地址
Date
cdate
=
new
Date
();
OrderReceiptVO
rv
=
param
.
getOrderReceipt
();
OrderReceiptDO
receipt
=
new
OrderReceiptDO
(
rv
);
receipt
.
setOrderInfoId
(
orderInfo
.
getId
());
receipt
.
setCreateTime
(
cdate
);
rentalOrdersDao
.
insertOrderReceipt
(
receipt
);
orderInfo
.
setBalance
(
getRemainingBalance
(
param
.
getRepoAccountId
()));
// 将当前的用户id及订单编号存入redis
OrderInfoDTO
dto
=
orderInfo
.
buildOrderInfoDTO
();
stringRedisTemplate
.
opsForValue
().
set
(
orderInfo
.
getOrderNo
(),
JsonUtil
.
parseObjToJson
(
dto
));
return
dto
;
}
rentalOrdersDao
.
insertOrderInfo
(
orderInfo
);
// 添加收货地址
Date
cdate
=
new
Date
();
OrderReceiptVO
rv
=
param
.
getOrderReceipt
();
OrderReceiptDO
receipt
=
new
OrderReceiptDO
(
rv
);
receipt
.
setOrderInfoId
(
orderInfo
.
getId
());
receipt
.
setCreateTime
(
cdate
);
rentalOrdersDao
.
insertOrderReceipt
(
receipt
);
orderInfo
.
setBalance
(
getRemainingBalance
(
request
,
param
.
getRepoAccountId
()));
// 将当前的用户id及订单编号存入redis
OrderInfoDTO
dto
=
orderInfo
.
buildOrderInfoDTO
();
stringRedisTemplate
.
opsForValue
().
set
(
orderInfo
.
getOrderNo
(),
JsonUtil
.
parseObjToJson
(
dto
));
return
dto
;
}
@Override
@Transactional
public
ResultBody
addLease
(
BaseAccountDTO
account
,
RentalOrderVO
param
)
{
@Override
@Transactional
public
ResultBody
addLease
(
BaseAccountDTO
account
,
RentalOrderVO
param
)
{
// 通过用户获取渠道等级id 未完善
Integer
channelLevelId
=
getChannelLevel
(
account
.
getUserAccountId
());
// 通过用户获取渠道等级id 未完善
Integer
channelLevelId
=
getChannelLevel
(
account
.
getUserAccountId
());
// 通过渠道等级获取每一天的单价 未完善
Double
unitPrice
=
getUnitPrice
(
param
,
channelLevelId
);
// 通过渠道等级获取每一天的单价 未完善
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
;
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);
// 下单
OrderInfoDO
orderInfoDO
=
new
OrderInfoDO
();
// rentalOrdersDao.insertOrderInfo(orderInfo);
return
ResultBody
.
success
();
}
return
ResultBody
.
success
();
}
/**
* 通过用户id 获取用户剩余的金额
*
* @param repoAccountId
* @return
*/
public
BigDecimal
getRemainingBalance
(
Integer
repoAccountId
)
{
ResponseEntity
<
String
>
response
=
restTemplate
.
getForEntity
(
"http://localhost:8088/payment/repocash/RemainingBalance?repoAccountId="
+
repoAccountId
,
String
.
class
);
String
body
=
response
.
getBody
();
BigDecimal
bigDecimal
=
new
BigDecimal
(
body
);
return
bigDecimal
;
}
/**
* 通过用户id 获取用户剩余的金额
*
* @param repoAccountId
* @return
*/
public
BigDecimal
getRemainingBalance
(
HttpServletRequest
request
,
Integer
repoAccountId
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
//封装请求头
headers
.
add
(
"token"
,
request
.
getHeader
(
"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
,
HttpMethod
.
GET
,
formEntity
,
String
.
class
);
String
body
=
result4
.
getBody
();
BigDecimal
bigDecimal
=
new
BigDecimal
(
body
);
return
bigDecimal
;
}
/**
* 获取渠道等级
*
* @param userId
* @return
*/
public
Integer
getChannelLevel
(
Integer
userId
)
{
// 远程接口调用 传一个userId获取到渠道等级的id 接口找洁
// 需要调整
/**
* 获取渠道等级
*
* @param userId
* @return
*/
public
Integer
getChannelLevel
(
Integer
userId
)
{
// 远程接口调用 传一个userId获取到渠道等级的id 接口找洁
// 需要调整
/* ResponseEntity<String> response =
restTemplate.getForEntity("http://localhost:35150/userapp/user-account/feignGetUserSimpleInfo?userAccountId=1",String.class);
String body1 = response.getBody();
UserAccountSimpleDTO account = JSON.parseObject(body1, UserAccountSimpleDTO.class);*/
return
1
;
}
/**
* 获取每一天的价格
*
* @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
;
// 需要支付的价格
return
12.09
;
}
return
1
;
}
public
Integer
day
(
RentalOrderVO
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
;
return
i
;
}
/**
* 获取每一天的价格
*
* @param param
* @param channelLevelId
* @return
*/
private
Double
getUnitPrice
(
RentalOrderVO
param
,
Integer
channelLevelId
)
{
PriceAcquisition
priceAcquisition
=
new
PriceAcquisition
();
private
LeaseOrderVO
buildLease
(
RepoAccountDTO
account
,
RentalOrderVO
param
,
SkuOrderDTO
sku
,
OrderReceiptVO
rv
)
{
Date
cdate
=
new
Date
();
return
LeaseOrderVO
.
builder
()
.
orderNo
(
CodeUtil
.
createRepoOrderNo
())
.
wareInfoId
(
sku
.
getWareInfoId
())
.
wareTitle
(
sku
.
getWareTitle
())
.
wareNo
(
sku
.
getWareNo
())
.
skuInfoId
(
sku
.
getSkuInfoId
())
.
skuTitle
(
sku
.
getSkuTitle
())
.
repoAccountId
(
account
.
getId
())
.
uid
(
account
.
getUid
())
.
buyerName
(
account
.
getAccountName
())
.
buyerPhone
(
account
.
getPhoneNum
())
.
unitPrice
(
sku
.
getUnitPrice
())
.
wareNum
(
sku
.
getWareNum
())
.
shouldPay
(
sku
.
getShouldPay
())
.
actualPay
(
BigDecimal
.
ZERO
)
.
orderType
(
0
)
.
deposit
(
sku
.
getDeposit
())
.
rentPrice
(
sku
.
getRentPrice
())
.
startDate
(
param
.
getStartDate
())
.
endDate
(
param
.
getEndDate
())
.
payDay
(
sku
.
getRentDay
())
.
tranStatus
(
TranStatusDic
.
INIT
.
getStatus
())
.
remark
(
param
.
getRemark
())
.
rcdCompanyId
(
account
.
getRcdCompanyId
())
.
exWare
(
sku
.
getPayStatus
())
.
wareImg
(
sku
.
getMainImg
())
.
createTime
(
cdate
)
.
orderReceipt
(
rv
)
.
build
();
}
// 传 规格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
;
@Transactional
public
ResultBody
computeStockNum
(
Integer
wareInfoId
,
Integer
skuInfoId
,
Integer
addStock
,
Integer
addSale
)
{
if
(
addStock
!=
null
&&
addStock
<
0
)
{
int
stock
=
(
addStock
*
-
1
);
WareInfoDO
ware
=
null
;
// wareInfoDao.getWareSimpleInfo(wareInfoId);
if
(
ware
.
getTotalStock
()
<
stock
)
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_NOT_ENOUGH_ERROR
);
}
int
newStock
=
ware
.
getTotalStock
()
-
stock
;
if
(
newStock
==
0
)
{
// 下架
// wareInfoDao.updateDownWare(wareInfoId);
}
// 调用远程接口获取单价 计算方式 单价 乘以 数量*天数 减去优惠券的价格最后得到需要支付的价格是吗
// 单价
Integer
unitPrice
=
1
;
// 需要支付的价格
return
12.09
;
}
if
(
addStock
==
null
)
{
addStock
=
0
;
public
Integer
day
(
RentalOrderVO
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
;
return
i
;
}
int
count
=
0
;
// skuInfoDao.updateSkuNumInfo(skuInfoId,addStock,addSale);
if
(
count
!=
1
)
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
ResultBody
.
error
(
ResultEnum
.
OPERATION_SYS_ERROR
);
private
LeaseOrderVO
buildLease
(
RepoAccountDTO
account
,
RentalOrderVO
param
,
SkuOrderDTO
sku
,
OrderReceiptVO
rv
)
{
Date
cdate
=
new
Date
();
return
LeaseOrderVO
.
builder
()
.
orderNo
(
CodeUtil
.
createRepoOrderNo
())
.
wareInfoId
(
sku
.
getWareInfoId
())
.
wareTitle
(
sku
.
getWareTitle
())
.
wareNo
(
sku
.
getWareNo
())
.
skuInfoId
(
sku
.
getSkuInfoId
())
.
skuTitle
(
sku
.
getSkuTitle
())
.
repoAccountId
(
account
.
getId
())
.
uid
(
account
.
getUid
())
.
buyerName
(
account
.
getAccountName
())
.
buyerPhone
(
account
.
getPhoneNum
())
.
unitPrice
(
sku
.
getUnitPrice
())
.
wareNum
(
sku
.
getWareNum
())
.
shouldPay
(
sku
.
getShouldPay
())
.
actualPay
(
BigDecimal
.
ZERO
)
.
orderType
(
0
)
.
deposit
(
sku
.
getDeposit
())
.
rentPrice
(
sku
.
getRentPrice
())
.
startDate
(
param
.
getStartDate
())
.
endDate
(
param
.
getEndDate
())
.
payDay
(
sku
.
getRentDay
())
.
tranStatus
(
TranStatusDic
.
INIT
.
getStatus
())
.
remark
(
param
.
getRemark
())
.
rcdCompanyId
(
account
.
getRcdCompanyId
())
.
exWare
(
sku
.
getPayStatus
())
.
wareImg
(
sku
.
getMainImg
())
.
createTime
(
cdate
)
.
orderReceipt
(
rv
)
.
build
();
}
int
updateCount
=
0
;
// wareInfoDao.updateWareNumInfo(wareInfoId,addStock,addSale);
if
(
updateCount
!=
1
)
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
ResultBody
.
error
(
ResultEnum
.
OPERATION_SYS_ERROR
);
@Transactional
public
ResultBody
computeStockNum
(
Integer
wareInfoId
,
Integer
skuInfoId
,
Integer
addStock
,
Integer
addSale
)
{
if
(
addStock
!=
null
&&
addStock
<
0
)
{
int
stock
=
(
addStock
*
-
1
);
WareInfoDO
ware
=
null
;
// wareInfoDao.getWareSimpleInfo(wareInfoId);
if
(
ware
.
getTotalStock
()
<
stock
)
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_NOT_ENOUGH_ERROR
);
}
int
newStock
=
ware
.
getTotalStock
()
-
stock
;
if
(
newStock
==
0
)
{
// 下架
// wareInfoDao.updateDownWare(wareInfoId);
}
}
if
(
addStock
==
null
)
{
addStock
=
0
;
}
int
count
=
0
;
// skuInfoDao.updateSkuNumInfo(skuInfoId,addStock,addSale);
if
(
count
!=
1
)
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
ResultBody
.
error
(
ResultEnum
.
OPERATION_SYS_ERROR
);
}
int
updateCount
=
0
;
// wareInfoDao.updateWareNumInfo(wareInfoId,addStock,addSale);
if
(
updateCount
!=
1
)
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
ResultBody
.
error
(
ResultEnum
.
OPERATION_SYS_ERROR
);
}
return
ResultBody
.
success
();
}
return
ResultBody
.
success
();
}
@Override
public
OrderInfoDTO
getOrderDetail
(
String
orderNo
)
{
OrderInfoDO
order
=
rentalOrdersDao
.
getOrderDetail
(
orderNo
);
OrderInfoDTO
orderInfo
=
order
.
buildOrderInfoDTO
();
OrderReceiptDO
rd
=
rentalOrdersDao
.
getOrderReceiptInfo
(
order
.
getId
());
OrderReceiptDTO
receipt
=
rd
.
buildOrderReceiptDTO
();
orderInfo
.
setReceipt
(
receipt
);
// 查询-最新的退款详情单
OrderRefundDO
orderRefund
=
rentalOrdersDao
.
getNewOrderRefund
(
order
.
getId
());
if
(
orderRefund
!=
null
)
{
OrderRefundDTO
refund
=
orderRefund
.
buildOrderRefundDTO
();
orderInfo
.
setOrderRefund
(
refund
);
@Override
public
OrderInfoDTO
getOrderDetail
(
String
orderNo
)
{
OrderInfoDO
order
=
rentalOrdersDao
.
getOrderDetail
(
orderNo
);
OrderInfoDTO
orderInfo
=
order
.
buildOrderInfoDTO
();
OrderReceiptDO
rd
=
rentalOrdersDao
.
getOrderReceiptInfo
(
order
.
getId
());
OrderReceiptDTO
receipt
=
rd
.
buildOrderReceiptDTO
();
orderInfo
.
setReceipt
(
receipt
);
// 查询-最新的退款详情单
OrderRefundDO
orderRefund
=
rentalOrdersDao
.
getNewOrderRefund
(
order
.
getId
());
if
(
orderRefund
!=
null
)
{
OrderRefundDTO
refund
=
orderRefund
.
buildOrderRefundDTO
();
orderInfo
.
setOrderRefund
(
refund
);
}
return
orderInfo
;
}
return
orderInfo
;
}
@Override
public
PageResult
listPcOrderInfo
(
OrderInfoQO
param
,
BaseAccountDTO
cuser
)
{
@Override
public
PageResult
listPcOrderInfo
(
OrderInfoQO
param
,
BaseAccountDTO
cuser
)
{
Integer
count
=
rentalOrdersDao
.
countPcOrderInfo
(
param
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
Integer
count
=
rentalOrdersDao
.
countPcOrderInfo
(
param
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
OrderInfoDTO
>
data
=
rentalOrdersDao
.
listPcOrderInfo
(
param
).
stream
()
.
map
(
d
->
{
return
d
.
buildOrderInfoDTO
();
})
.
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
data
);
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
OrderInfoDTO
>
data
=
rentalOrdersDao
.
listPcOrderInfo
(
param
).
stream
()
.
map
(
d
->
{
return
d
.
buildOrderInfoDTO
();
})
.
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
data
);
}
@Override
public
PageResult
listPageWechatOrder
(
BaseAccountDTO
account
,
OrderInfoQO
param
)
{
param
.
setRepoAccountId
(
account
.
getUserAccountId
());
int
count
=
rentalOrdersDao
.
countPageOrderInfo
(
param
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
@Override
public
PageResult
listPageWechatOrder
(
BaseAccountDTO
account
,
OrderInfoQO
param
)
{
param
.
setRepoAccountId
(
account
.
getUserAccountId
());
int
count
=
rentalOrdersDao
.
countPageOrderInfo
(
param
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
OrderInfoDTO
>
data
=
rentalOrdersDao
.
listPageOrderInfo
(
param
).
stream
()
.
map
(
d
->
{
return
d
.
buildOrderInfoDTO
();
})
.
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
data
);
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
OrderInfoDTO
>
data
=
rentalOrdersDao
.
listPageOrderInfo
(
param
).
stream
()
.
map
(
d
->
{
return
d
.
buildOrderInfoDTO
();
})
.
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
data
);
}
}
src/main/java/com/mmc/oms/service/RentalOrdersService.java
浏览文件 @
f7826a26
...
...
@@ -8,6 +8,8 @@ import com.mmc.oms.model.qo.OrderInfoQO;
import
com.mmc.oms.model.vo.LeaseOrderVO
;
import
com.mmc.oms.model.vo.RentalOrderVO
;
import
javax.servlet.http.HttpServletRequest
;
/**
* @Author small @Date 2023/5/26 10:52 @Version 1.0
*/
...
...
@@ -16,7 +18,7 @@ public interface RentalOrdersService {
OrderInfoDTO
getOrderDetail
(
String
orderNo
);
OrderInfoDTO
feignAddLease
(
LeaseOrderVO
param
);
OrderInfoDTO
feignAddLease
(
HttpServletRequest
request
,
LeaseOrderVO
param
);
PageResult
listPcOrderInfo
(
OrderInfoQO
param
,
BaseAccountDTO
cuser
);
...
...
src/main/resources/application-local.yml
浏览文件 @
f7826a26
...
...
@@ -51,3 +51,4 @@ rabbitmq:
workFlyerInfoKey
:
TEST_WORK_FLYER_INFO
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论