记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
f69d27f6
Commit
f69d27f6
authored
Jan 05, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交下单接口(待测试)
parent
293994bc
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
302 additions
and
104 deletions
+302
-104
GoblinOrderParam.java
...liquidnet/service/goblin/dto/manage/GoblinOrderParam.java
+1
-1
GoblinOrderSkuParam.java
...uidnet/service/goblin/dto/manage/GoblinOrderSkuParam.java
+3
-1
GoblinOrderStoreParam.java
...dnet/service/goblin/dto/manage/GoblinOrderStoreParam.java
+3
-3
SyncOrderParam.java
...iquidnet/service/goblin/dto/manage/vo/SyncOrderParam.java
+35
-0
IDGenerator.java
...ain/java/com/liquidnet/commons/lang/util/IDGenerator.java
+4
-0
application-dev.yml
liquidnet-bus-config/liquidnet-config/application-dev.yml
+1
-0
GoblinOrderAttr.java
.../com/liquidnet/service/goblin/entity/GoblinOrderAttr.java
+9
-1
GoblinOrderSku.java
...a/com/liquidnet/service/goblin/entity/GoblinOrderSku.java
+9
-1
GoblinStoreOrder.java
...com/liquidnet/service/goblin/entity/GoblinStoreOrder.java
+5
-0
GoblinAppOrderController.java
...t/service/goblin/controller/GoblinAppOrderController.java
+22
-2
GoblinAppOrderServiceImpl.java
...ervice/goblin/service/impl/GoblinAppOrderServiceImpl.java
+207
-92
GoblinRedisUtils.java
...a/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
+3
-3
No files found.
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/manage/GoblinOrderParam.java
View file @
f69d27f6
...
...
@@ -31,6 +31,6 @@ public class GoblinOrderParam {
private
String
returnUrl
;
@ApiModelProperty
(
value
=
"商品相关参数集合"
)
private
List
<
GoblinOrderS
puParam
>
goblinOrderSpu
ParamList
;
private
List
<
GoblinOrderS
toreParam
>
goblinOrderStore
ParamList
;
}
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/manage/GoblinOrderSkuParam.java
View file @
f69d27f6
...
...
@@ -11,7 +11,9 @@ import java.util.ArrayList;
@Data
public
class
GoblinOrderSkuParam
{
@ApiModelProperty
(
required
=
true
,
value
=
"skuId"
)
private
String
skuIds
;
private
String
skuId
;
@ApiModelProperty
(
required
=
true
,
value
=
"spuId"
)
private
String
spuId
;
@ApiModelProperty
(
required
=
true
,
value
=
"数量"
)
private
Integer
number
;
}
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/manage/GoblinOrderS
pu
Param.java
→
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/manage/GoblinOrderS
tore
Param.java
View file @
f69d27f6
...
...
@@ -10,10 +10,10 @@ import java.util.ArrayList;
@ApiModel
(
value
=
"GoblinOrderParam"
)
@Data
public
class
GoblinOrderS
pu
Param
{
public
class
GoblinOrderS
tore
Param
{
@ApiModelProperty
(
required
=
true
,
value
=
"spuI
d"
)
private
String
s
pu
Id
;
@ApiModelProperty
(
value
=
"商铺i
d"
)
private
String
s
tore
Id
;
@ApiModelProperty
(
value
=
"平台券码"
)
private
String
platVoucherCode
;
@ApiModelProperty
(
value
=
"商品券码"
)
...
...
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/manage/vo/SyncOrderParam.java
0 → 100644
View file @
f69d27f6
package
com
.
liquidnet
.
service
.
goblin
.
dto
.
manage
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
@Data
public
class
SyncOrderParam
implements
Cloneable
{
@ApiModelProperty
(
value
=
"status"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"type"
)
private
String
type
;
@ApiModelProperty
(
value
=
"code"
)
private
String
code
;
@ApiModelProperty
(
value
=
"paymentId"
)
private
String
paymentId
;
@ApiModelProperty
(
value
=
"orderCode"
)
private
String
orderCode
;
@ApiModelProperty
(
value
=
"price"
)
private
BigDecimal
price
;
@ApiModelProperty
(
value
=
"paymentType"
)
private
String
paymentType
;
@ApiModelProperty
(
value
=
"paymentAt"
)
private
String
paymentAt
;
private
static
final
SyncOrderParam
obj
=
new
SyncOrderParam
();
public
static
SyncOrderParam
getNew
()
{
try
{
return
(
SyncOrderParam
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
SyncOrderParam
();
}
}
}
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/IDGenerator.java
View file @
f69d27f6
...
...
@@ -68,6 +68,10 @@ public class IDGenerator {
return
ticketOrderCode
(
orderId
);
}
public
static
String
getWriteOffCode
(){
return
""
;
}
/**
* 根据订单id生成总订单号
*
...
...
liquidnet-bus-config/liquidnet-config/application-dev.yml
View file @
f69d27f6
...
...
@@ -90,6 +90,7 @@ liquidnet:
pay
:
http://devdragon.zhengzai.tv/dragon/pay/dragonPay
check
:
http://devdragon.zhengzai.tv/dragon/pay/checkOrder
localUrl
:
http://devorder.zhengzai.tv/order/order/syncOrder
goblinUrl
:
http://devorder.zhengzai.tv/order/goblin/syncOrder
candy
:
url
:
http://devcandy.zhengzai.tv/candy
goblin
:
...
...
liquidnet-bus-do/liquidnet-service-goblin-do/src/main/java/com/liquidnet/service/goblin/entity/GoblinOrderAttr.java
View file @
f69d27f6
...
...
@@ -17,7 +17,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
GoblinOrderAttr
implements
Serializable
{
public
class
GoblinOrderAttr
implements
Serializable
,
Cloneable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -130,5 +130,13 @@ public class GoblinOrderAttr implements Serializable {
private
String
comment
;
private
static
final
GoblinOrderAttr
obj
=
new
GoblinOrderAttr
();
public
static
GoblinOrderAttr
getNew
()
{
try
{
return
(
GoblinOrderAttr
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
GoblinOrderAttr
();
}
}
}
liquidnet-bus-do/liquidnet-service-goblin-do/src/main/java/com/liquidnet/service/goblin/entity/GoblinOrderSku.java
View file @
f69d27f6
...
...
@@ -18,7 +18,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
GoblinOrderSku
implements
Serializable
{
public
class
GoblinOrderSku
implements
Serializable
,
Cloneable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -116,5 +116,13 @@ public class GoblinOrderSku implements Serializable {
private
String
comment
;
private
static
final
GoblinOrderSku
obj
=
new
GoblinOrderSku
();
public
static
GoblinOrderSku
getNew
()
{
try
{
return
(
GoblinOrderSku
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
GoblinOrderSku
();
}
}
}
liquidnet-bus-do/liquidnet-service-goblin-do/src/main/java/com/liquidnet/service/goblin/entity/GoblinStoreOrder.java
View file @
f69d27f6
...
...
@@ -170,6 +170,11 @@ public class GoblinStoreOrder implements Serializable,Cloneable {
*/
private
String
version
;
/**
* 是否会员
*/
private
Integer
isMember
;
/**
* 订单类型[0-普通订单|1-定金预售订单|2-全款预售订单|3-拼团订单|4-众筹全款|5-众筹1元|6-众筹无回报|7-虚拟商品订单|8-社区团购订单|9-正在下单]
*/
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/controller/GoblinAppOrderController.java
View file @
f69d27f6
package
com
.
liquidnet
.
service
.
goblin
.
controller
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.codec.vo.EncryptedReq
;
import
com.liquidnet.service.goblin.dto.manage.GoblinOrderParam
;
import
com.liquidnet.service.goblin.dto.manage.vo.GoblinPayInnerResultVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinSelfMarketingVo
;
import
com.liquidnet.service.goblin.service.IGoblinAppOrderService
;
import
com.liquidnet.service.goblin.service.IGoblinAppZhengzaiService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@Slf4j
@Api
(
tags
=
"订单相关"
)
...
...
@@ -16,4 +23,17 @@ public class GoblinAppOrderController {
@Autowired
IGoblinAppOrderService
goblinAppOrderService
;
@PostMapping
(
"pre"
)
@ApiOperation
(
"下单"
)
public
ResponseDto
<
GoblinPayInnerResultVo
>
getZhengzaiMarketList
(
@RequestBody
EncryptedReq
<
GoblinOrderParam
>
param
)
{
GoblinOrderParam
payOrderParam
=
param
.
getData
();
return
goblinAppOrderService
.
checkOrder
(
payOrderParam
);
}
@PostMapping
(
"fc7bce6d6c2213b866f76493f92224b7"
)
@ApiOperation
(
"fc7bce6d6c2213b866f76493f92224b7"
)
public
ResponseDto
<
GoblinPayInnerResultVo
>
getZhengzaiMarketList
(
@RequestBody
GoblinOrderParam
param
)
{
return
goblinAppOrderService
.
checkOrder
(
param
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinAppOrderServiceImpl.java
View file @
f69d27f6
package
com
.
liquidnet
.
service
.
goblin
.
service
.
impl
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.CurrentUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.google.gson.JsonObject
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.service.adam.dto.vo.AdamAddressesVo
;
import
com.liquidnet.service.adam.dto.vo.AdamEntersVo
;
import
com.liquidnet.service.adam.dto.vo.AdamRscPolymer01Vo
;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.UserPathDto
;
import
com.liquidnet.service.goblin.constant.GoblinStatusConst
;
import
com.liquidnet.service.goblin.dto.GoblinGoodsSpecDto
;
import
com.liquidnet.service.goblin.dto.manage.GoblinOrderParam
;
import
com.liquidnet.service.goblin.dto.manage.GoblinOrderSkuParam
;
import
com.liquidnet.service.goblin.dto.manage.GoblinOrderS
pu
Param
;
import
com.liquidnet.service.goblin.dto.manage.GoblinOrderS
tore
Param
;
import
com.liquidnet.service.goblin.dto.manage.vo.GoblinPayInnerResultVo
;
import
com.liquidnet.service.goblin.dto.
vo.GoblinGoodsInfoVo
;
import
com.liquidnet.service.goblin.dto.
manage.vo.SyncOrderParam
;
import
com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo
;
import
com.liquidnet.service.goblin.entity.GoblinOrderAttr
;
import
com.liquidnet.service.goblin.entity.GoblinOrderSku
;
import
com.liquidnet.service.goblin.entity.GoblinStoreOrder
;
import
com.liquidnet.service.goblin.service.IGoblinAppOrderService
;
import
com.liquidnet.service.goblin.service.IGoblinAppZhengzaiService
;
import
com.liquidnet.service.goblin.util.*
;
import
io.github.classgraph.json.JSONUtils
;
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
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.LinkedMultiValueMap
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
@Service
...
...
@@ -42,15 +49,20 @@ public class GoblinAppOrderServiceImpl implements IGoblinAppOrderService {
@Autowired
GoblinOrderUtils
orderUtils
;
@Value
(
"${liquidnet.service.order.url-pay.pay}"
)
private
String
payUrl
;
@Value
(
"${liquidnet.service.order.url-pay.check}"
)
private
String
checkUrl
;
@Value
(
"${liquidnet.service.order.url-pay.goblinUrl}"
)
private
String
synUrl
;
@Override
public
ResponseDto
<
GoblinPayInnerResultVo
>
checkOrder
(
GoblinOrderParam
param
)
{
boolean
isDownGeneral
=
false
;
//是否需要回滚库存
List
<
AdamEntersVo
>
entersVoList
=
ObjectUtil
.
cloneArrayListObject
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
List
<
String
>
skuAndPreListAndNumber
=
CollectionUtil
.
arrayListString
();
try
{
String
orderMasterCode
=
IDGenerator
.
storeMasterCode
();
//总订单id
List
<
GoblinOrderS
puParam
>
goblinOrderSpuParamList
=
param
.
getGoblinOrderSpu
ParamList
();
//分订单
List
<
GoblinOrderS
toreParam
>
goblinOrderStoreParamList
=
param
.
getGoblinOrderStore
ParamList
();
//分订单
//获取用户相关
String
addressId
;
if
(
param
.
getAddressIds
()
==
null
||
param
.
getAddressIds
().
size
()
==
0
)
{
...
...
@@ -76,109 +88,145 @@ public class GoblinAppOrderServiceImpl implements IGoblinAppOrderService {
break
;
}
}
for
(
GoblinOrderS
puParam
spuParam
:
goblinOrderSpuParamList
)
{
for
(
GoblinOrderS
toreParam
storeParam
:
goblinOrderStoreParamList
)
{
//商铺维度循环
String
orderId
=
IDGenerator
.
nextSnowId
();
String
orderCode
=
IDGenerator
.
storeCode
(
orderId
);
String
spuId
=
spuParam
.
getSpuId
();
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
redisUtils
.
getGoodsInfoVo
(
spuId
);
if
(
goblinGoodsInfoVo
==
null
)
{
return
null
;
//参数异常
}
if
(!(
goblinGoodsInfoVo
.
getStatus
().
equals
(
"3"
)
&&
goblinGoodsInfoVo
.
getShelvesStatus
().
equals
(
"3"
)))
{
return
null
;
//该spu不可购买
}
String
storeId
=
goblinGoodsInfoVo
.
getStoreId
();
String
platVoucherCode
=
spuParam
.
getPlatVoucherCode
();
String
storeVoucherCode
=
spuParam
.
getStoreVoucherCode
();
for
(
GoblinOrderSkuParam
skuParam
:
spuParam
.
getGoblinOrderSkuParamArrayList
())
{
String
skuId
=
skuParam
.
getSkuIds
();
for
(
GoblinOrderSkuParam
skuParam
:
storeParam
.
getGoblinOrderSkuParamArrayList
())
{
//商品维度循环
String
skuId
=
skuParam
.
getSkuId
(
);
// String spuId = skuParam.getSpuId();
// GoblinGoodsInfoVo goblinGoodsInfoVo = redisUtils.getGoodsInfoVo(spuId);
// if (goblinGoodsInfoVo == null) {
// return null;//参数异常
// }
// if (!(goblinGoodsInfoVo.getStatus().equals("3") && goblinGoodsInfoVo.getShelvesStatus().equals("3"))) {
// return null;//该spu不可购买
// }
// if (!goblinGoodsInfoVo.getSkuIdList().contains(skuId)) {
// return null;//参数异常
// }
int
number
=
skuParam
.
getNumber
();
if
(!
goblinGoodsInfoVo
.
getSkuIdList
().
contains
(
skuId
))
{
return
null
;
//参数异常
}
GoblinGoodsSkuInfoVo
skuVo
=
redisUtils
.
getGoodsSkuInfoVo
(
skuId
);
if
(!(
skuVo
.
getStatus
().
equals
(
"3"
)
&&
skuVo
.
getShelvesStatus
().
equals
(
"3"
)))
{
return
null
;
//该sku不可购买
throw
new
Exception
(
"不可购买"
);
}
// 判断库存
String
pre
=
GoblinStatusConst
.
MarketPreStatus
.
getPre
(
skuId
);
int
limitCount
=
skuVo
.
getBuyLimit
()
==
0
?
Integer
.
MAX_VALUE
:
skuVo
.
getBuyLimit
();
int
surplusGeneral
=
redisUtils
.
decrSkuStock
(
pre
,
skuId
,
number
);
if
(
surplusGeneral
<
0
)
{
//库存回滚
redisUtils
.
incrSkuStock
(
pre
,
skuId
,
number
);
return
null
;
//售罄
}
else
{
skuAndPreListAndNumber
.
add
(
skuId
+
","
+
pre
+
","
+
number
);
isDownGeneral
=
true
;
//判断限购
String
res1
=
orderUtils
.
judgeOrderLimit
(
uid
,
skuId
,
number
,
limitCount
);
if
(!
res1
.
equals
(
""
))
{
redisUtils
.
incrSkuStock
(
pre
,
skuId
,
number
);
return
ResponseDto
.
failure
(
res1
);
//乱七八糟异常
}
//下单
ResponseDto
<
GoblinPayInnerResultVo
>
resultData
=
order
(
param
,
skuVo
,
uid
,
isMember
,
addressesVo
,
orderMasterCode
,
orderId
,
orderCode
,
storeId
,
number
,
pre
,
spuParam
.
getPlatVoucherCode
());
isDownGeneral
=
false
;
return
resultData
;
skuAndPreListAndNumber
.
add
(
skuId
+
","
+
pre
+
","
+
number
);
//判断限购
String
res1
=
orderUtils
.
judgeOrderLimit
(
uid
,
skuId
,
number
,
limitCount
);
if
(!
res1
.
equals
(
""
))
{
throw
new
Exception
(
"已超出限购数量"
);
}
//库存回滚
if
(
surplusGeneral
<
0
)
{
throw
new
Exception
(
"已售罄"
);
}
}
//GoblinOrderSkuParam
}
//GoblinOrderSpuParam
return
null
;
//参数异常
//下单
return
order
(
param
,
storeParam
,
uid
,
isMember
,
addressesVo
,
orderMasterCode
,
orderId
,
orderCode
);
}
//GoblinOrderStoreParam
throw
new
Exception
(
"参数异常"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Kylin Order Pay Error = {}"
,
e
);
if
(
isDownGeneral
)
{
//回顾限购 回滚库存
for
(
String
item
:
skuAndPreListAndNumber
)
{
String
[]
array
=
item
.
split
(
","
);
String
skuId
=
array
[
0
];
String
pre
=
array
[
1
];
int
number
=
Integer
.
parseInt
(
array
[
2
]);
redisUtils
.
incrSkuStock
(
pre
,
skuId
,
number
);
redisUtils
.
decrSkuCountByUid
(
uid
,
skuId
,
number
);
}
log
.
error
(
"回滚库存"
);
//回顾限购 回滚库存
for
(
String
item
:
skuAndPreListAndNumber
)
{
String
[]
array
=
item
.
split
(
","
);
String
skuId
=
array
[
0
];
String
pre
=
array
[
1
];
int
number
=
Integer
.
parseInt
(
array
[
2
]);
redisUtils
.
incrSkuStock
(
pre
,
skuId
,
number
);
redisUtils
.
decrSkuCountByUid
(
uid
,
skuId
,
number
);
}
log
.
error
(
"回滚库存"
);
if
(
e
.
getMessage
()
==
null
)
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20018"
));
//乱七八糟异常
}
else
if
(
e
.
getMessage
().
equals
(
"券不可用"
))
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20030"
));
//券不可用
return
ResponseDto
.
failure
(
e
.
getMessage
());
}
else
if
(
e
.
getMessage
().
equals
(
"不可购买"
))
{
return
ResponseDto
.
failure
(
e
.
getMessage
());
}
else
if
(
e
.
getMessage
().
equals
(
"参数异常"
))
{
return
ResponseDto
.
failure
(
e
.
getMessage
());
}
else
if
(
e
.
getMessage
().
equals
(
"已售罄"
))
{
return
ResponseDto
.
failure
(
e
.
getMessage
());
}
else
if
(
e
.
getMessage
().
equals
(
"已超出限购数量"
))
{
return
ResponseDto
.
failure
(
e
.
getMessage
());
}
else
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20018"
));
//乱七八糟异常
}
}
}
private
ResponseDto
<
GoblinPayInnerResultVo
>
order
(
GoblinOrderParam
param
,
GoblinGoodsSkuInfoVo
skuInfoVo
,
String
uid
,
boolean
isMember
,
AdamAddressesVo
addressesVo
,
String
orderMasterCode
,
String
orderId
,
String
orderCode
,
String
storeId
,
int
number
,
String
pre
,
String
platVoucherCode
)
throws
Exception
{
private
ResponseDto
<
GoblinPayInnerResultVo
>
order
(
GoblinOrderParam
param
,
GoblinOrderStoreParam
storeParam
,
String
uid
,
boolean
isMember
,
AdamAddressesVo
addressesVo
,
String
orderMasterCode
,
String
orderId
,
String
orderCode
)
throws
Exception
{
String
platVoucherCode
=
storeParam
.
getPlatVoucherCode
();
String
storeId
=
storeParam
.
getStoreId
();
LinkedList
<
String
>
sqls
=
CollectionUtil
.
linkedListString
();
Map
token
=
CurrentUtil
.
getTokenClaims
();
String
headerCliSource
=
CurrentUtil
.
getHeaderCliSource
(),
headerCliVersion
=
CurrentUtil
.
getHeaderCliVersion
();
String
source
=
headerCliSource
==
null
?
""
:
headerCliSource
;
String
version
=
headerCliVersion
==
null
?
""
:
headerCliVersion
;
LocalDateTime
now
=
LocalDateTime
.
now
();
//价格判断
BigDecimal
price
=
skuInfoVo
.
getPrice
();
BigDecimal
priceBase
=
skuInfoVo
.
getPrice
();
if
(
pre
!=
null
)
{
priceBase
=
redisUtils
.
getGoodsSkuInfoVo
(
skuInfoVo
.
getSkuId
().
split
(
pre
)[
0
]).
getPrice
();
String
skuName
=
""
;
BigDecimal
price
;
//sku应付价格
BigDecimal
priceBase
;
//sku原价
BigDecimal
storeTotalPrice
=
BigDecimal
.
ZERO
;
//订单总金额
BigDecimal
voucherMarket
=
BigDecimal
.
ZERO
;
//活动优惠金额
String
writeOffCode
=
""
;
//取货码
for
(
GoblinOrderSkuParam
skuParam
:
storeParam
.
getGoblinOrderSkuParamArrayList
())
{
String
pre
=
GoblinStatusConst
.
MarketPreStatus
.
getPre
(
skuParam
.
getSkuId
());
GoblinGoodsSkuInfoVo
skuVo
=
redisUtils
.
getGoodsSkuInfoVo
(
skuParam
.
getSkuId
());
skuName
=
skuName
.
concat
(
skuVo
.
getName
()).
concat
(
","
);
if
(
pre
!=
null
&&
pre
.
contains
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
()))
{
writeOffCode
=
IDGenerator
.
getWriteOffCode
();
}
//获得 商品原价和活动价格
priceBase
=
skuVo
.
getPrice
();
if
(
isMember
)
{
priceBase
=
sku
Info
Vo
.
getPriceMember
();
priceBase
=
skuVo
.
getPriceMember
();
}
if
(
pre
!=
null
)
{
GoblinGoodsSkuInfoVo
skuMarketVo
=
redisUtils
.
getGoodsSkuInfoVo
(
skuParam
.
getSkuId
().
split
(
pre
)[
0
]);
price
=
skuMarketVo
.
getPrice
();
if
(
isMember
)
{
price
=
skuMarketVo
.
getPriceMember
();
}
}
else
{
price
=
skuVo
.
getPrice
();
if
(
isMember
)
{
price
=
skuVo
.
getPriceMember
();
}
}
//获得活动优惠价格
voucherMarket
=
voucherMarket
.
add
(
priceBase
.
subtract
(
price
));
storeTotalPrice
=
storeTotalPrice
.
add
(
price
);
//订单sku
GoblinOrderSku
orderSku
=
GoblinOrderSku
.
getNew
();
orderSku
.
setOrderSkuId
(
IDGenerator
.
nextTimeId2
());
orderSku
.
setOrderId
(
orderId
);
orderSku
.
setSpuId
(
skuParam
.
getSpuId
());
orderSku
.
setSkuId
(
skuParam
.
getSkuId
());
orderSku
.
setNum
(
skuParam
.
getNumber
());
orderSku
.
setSkuPrice
(
priceBase
);
orderSku
.
setSkuPriceActual
(
price
);
orderSku
.
setSkuName
(
skuVo
.
getName
());
orderSku
.
setSkuNo
(
skuVo
.
getSkuNo
());
orderSku
.
setSkuImage
(
skuVo
.
getSkuPic
());
orderSku
.
setSkuSpecs
(
JSON
.
toJSONString
(
skuVo
.
getSkuSpecList
()));
orderSku
.
setPriceVoucher
(
priceBase
.
subtract
(
price
));
orderSku
.
setCreatedAt
(
now
);
}
if
(
isMember
)
{
price
=
skuInfoVo
.
getPriceMember
();
}
BigDecimal
voucherMarket
=
priceBase
.
subtract
(
price
).
multiply
(
BigDecimal
.
valueOf
(
number
));
//优惠券
BigDecimal
voucherPrice
=
BigDecimal
.
ZERO
;
if
(
platVoucherCode
!=
null
&&
platVoucherCode
!=
""
)
{
HashMap
<
String
,
Object
>
hashMap
=
orderUtils
.
useCoupon
(
platVoucherCode
,
"购买商品
spu"
,
priceBase
.
multiply
(
BigDecimal
.
valueOf
(
number
))
,
""
);
//todo
if
(
platVoucherCode
!=
null
&&
!
platVoucherCode
.
equals
(
""
)
)
{
HashMap
<
String
,
Object
>
hashMap
=
orderUtils
.
useCoupon
(
platVoucherCode
,
"购买商品
["
+
orderCode
+
"]"
,
storeTotalPrice
,
""
);
//todo
voucherPrice
=
(
BigDecimal
)
hashMap
.
get
(
"voucher"
);
Integer
typeVoucher
=
(
Integer
)
hashMap
.
get
(
"type"
);
if
(
typeVoucher
.
equals
(-
1
))
{
throw
new
Exception
(
"券不可用"
);
}
}
//生成订单
GoblinStoreOrder
storeOrder
=
GoblinStoreOrder
.
getNew
();
storeOrder
.
setMasterOrderCode
(
orderMasterCode
);
...
...
@@ -188,11 +236,11 @@ public class GoblinAppOrderServiceImpl implements IGoblinAppOrderService {
storeOrder
.
setUserId
(
uid
);
storeOrder
.
setUserName
(
StringUtils
.
defaultString
(((
String
)
token
.
get
(
"nickname"
)),
""
));
storeOrder
.
setUserMobile
(
StringUtils
.
defaultString
(((
String
)
token
.
get
(
"mobile"
)),
""
));
storeOrder
.
setPriceTotal
(
priceBase
.
multiply
(
BigDecimal
.
valueOf
(
number
))
);
storeOrder
.
setPriceTotal
(
storeTotalPrice
);
storeOrder
.
setPriceActual
(
storeOrder
.
getPriceTotal
().
subtract
(
voucherMarket
).
subtract
(
voucherPrice
));
storeOrder
.
setPriceRefund
(
BigDecimal
.
ZERO
);
storeOrder
.
setPreSalePrice
(
BigDecimal
.
ZERO
);
storeOrder
.
setPriceExpress
(
BigDecimal
.
ZERO
);
//todo 快递费
storeOrder
.
setPriceExpress
(
BigDecimal
.
TEN
);
//todo 快递费 暂时写死
storeOrder
.
setPriceModify
(
BigDecimal
.
ZERO
);
storeOrder
.
setPricePoint
((
BigDecimal
.
ZERO
));
storeOrder
.
setPriceCoupon
(
voucherPrice
);
...
...
@@ -209,26 +257,93 @@ public class GoblinAppOrderServiceImpl implements IGoblinAppOrderService {
storeOrder
.
setPreDepositPay
(
0
);
storeOrder
.
setSource
(
source
);
storeOrder
.
setVersion
(
version
);
storeOrder
.
setIsMember
(
isMember
?
1
:
0
);
storeOrder
.
setOrderType
(
0
);
storeOrder
.
setLotteryStatus
(
"0"
);
storeOrder
.
setWriteOffCode
(
""
);
//todo
storeOrder
.
setWriteOffCode
(
writeOffCode
);
storeOrder
.
setPayCountdownMinute
(
5
);
storeOrder
.
setIpAddress
(
CurrentUtil
.
getCliIpAddr
());
storeOrder
.
setCreatedAt
(
now
);
// storeOrder.setMailNo();
// storeOrder.setDeliveryTime();
// storeOrder.setLogisticsCompany();
// storeOrder.setLogisticsCode();
// storeOrder.setPayTime();
// storeOrder.setCancelTime();
// storeOrder.setModifyTime();
// storeOrder.setEvaluationTime();
// storeOrder.setPreSaleTime();
// storeOrder.setRecommendedId();
// storeOrder.setSRecommendedId();
// storeOrder.setCrowdfundingId();
// storeOrder.setPayCode();
// storeOrder.setPayStoreId();
return
null
;
//订单attr
GoblinOrderAttr
orderAttr
=
GoblinOrderAttr
.
getNew
();
orderAttr
.
setOrderAttrId
(
IDGenerator
.
nextTimeId2
());
orderAttr
.
setOrderId
(
orderId
);
orderAttr
.
setExpressContacts
(
addressesVo
.
getName
());
orderAttr
.
setExpressAddress
(
addressesVo
.
getProvince
()
+
","
+
addressesVo
.
getCounty
()
+
","
+
addressesVo
.
getCity
());
orderAttr
.
setExpressAddressDetail
(
addressesVo
.
getAddress
());
orderAttr
.
setExpressPhone
(
addressesVo
.
getPhone
());
orderAttr
.
setExpressType
(
1
);
orderAttr
.
setCreatedAt
(
now
);
//是否免费
boolean
isFree
=
false
;
GoblinPayInnerResultVo
payInnerResultVo
;
if
(
storeOrder
.
getPriceActual
().
compareTo
(
BigDecimal
.
valueOf
(
0
))
>
0
)
{
// 调用支付
LinkedMultiValueMap
<
String
,
String
>
httpData
=
CollectionUtil
.
linkedMultiValueMapStringString
();
httpData
.
add
(
"type"
,
"PRODUCT"
);
httpData
.
add
(
"price"
,
storeOrder
.
getPriceActual
().
toString
());
httpData
.
add
(
"name"
,
redisUtils
.
getStoreInfoVo
(
storeParam
.
getStoreId
()).
getStoreName
());
httpData
.
add
(
"detail"
,
skuName
);
httpData
.
add
(
"orderCode"
,
storeOrder
.
getOrderCode
());
httpData
.
add
(
"clientIp"
,
storeOrder
.
getIpAddress
());
httpData
.
add
(
"notifyUrl"
,
synUrl
);
httpData
.
add
(
"createDate"
,
storeOrder
.
getCreatedAt
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
httpData
.
add
(
"expireTime"
,
storeOrder
.
getPayCountdownMinute
().
toString
());
httpData
.
add
(
"payType"
,
storeOrder
.
getPayType
());
httpData
.
add
(
"deviceFrom"
,
param
.
getDeviceFrom
());
if
(
param
.
getDeviceFrom
().
equals
(
"js"
)
||
param
.
getDeviceFrom
().
equals
(
"applet"
))
{
httpData
.
add
(
"openId"
,
param
.
getOpenId
());
}
if
(
param
.
getPayType
().
equals
(
"alipay"
)
&&
param
.
getDeviceFrom
().
equals
(
"wap"
))
{
httpData
.
add
(
"showUrl"
,
param
.
getShowUrl
()
+
storeOrder
.
getOrderId
());
httpData
.
add
(
"returnUrl"
,
param
.
getReturnUrl
()
+
storeOrder
.
getOrderId
());
}
if
(
param
.
getPayType
().
equals
(
"douyinpay"
))
{
httpData
.
add
(
"showUrl"
,
param
.
getShowUrl
()
+
storeOrder
.
getOrderId
());
httpData
.
add
(
"returnUrl"
,
param
.
getReturnUrl
()
+
storeOrder
.
getOrderId
());
}
if
(
param
.
getPayType
().
equals
(
"unionpay"
))
{
httpData
.
add
(
"returnUrl"
,
param
.
getReturnUrl
()
+
storeOrder
.
getOrderId
());
}
String
returnData
=
HttpUtil
.
post
(
payUrl
,
httpData
);
log
.
info
(
"调用 DRAGON 结果 = "
+
returnData
);
ResponseDto
<
GoblinPayInnerResultVo
>
dto
=
JsonUtils
.
fromJson
(
returnData
,
new
TypeReference
<
ResponseDto
<
GoblinPayInnerResultVo
>>()
{
});
payInnerResultVo
=
GoblinPayInnerResultVo
.
getNew
();
payInnerResultVo
.
setCode
(
dto
.
getData
().
getCode
());
payInnerResultVo
.
setOrderCode
(
dto
.
getData
().
getOrderCode
());
payInnerResultVo
.
setPayData
(
dto
.
getData
().
getPayData
());
payInnerResultVo
.
setOrderId
(
storeOrder
.
getOrderId
());
payInnerResultVo
.
setPayType
(
storeOrder
.
getPayType
());
payInnerResultVo
.
setPrice
(
storeOrder
.
getPriceActual
());
storeOrder
.
setPayCode
(
payInnerResultVo
.
getCode
());
payInnerResultVo
.
setShowUrl
(
param
.
getShowUrl
()
+
storeOrder
.
getOrderId
());
payInnerResultVo
.
setReturnUrl
(
param
.
getReturnUrl
()
+
storeOrder
.
getOrderId
());
}
else
{
isFree
=
true
;
storeOrder
.
setPayType
(
"FREE"
);
storeOrder
.
setPayCode
(
"FREE_PAY_CODE"
);
payInnerResultVo
=
GoblinPayInnerResultVo
.
getNew
();
payInnerResultVo
.
setPrice
(
BigDecimal
.
valueOf
(
0
));
payInnerResultVo
.
setOrderId
(
storeOrder
.
getOrderId
());
payInnerResultVo
.
setPayType
(
storeOrder
.
getPayType
());
}
//todo vo redisList
log
.
info
(
UserPathDto
.
setData
(
"下单(唤起支付)"
,
param
,
payInnerResultVo
));
if
(
isFree
)
{
SyncOrderParam
syncOrderParam
=
SyncOrderParam
.
getNew
();
syncOrderParam
.
setOrderCode
(
storeOrder
.
getOrderCode
());
syncOrderParam
.
setPaymentAt
(
DateUtil
.
format
(
LocalDateTime
.
now
(),
DateUtil
.
Formatter
.
yyyyMMddHHmmss
));
syncOrderParam
.
setCode
(
storeOrder
.
getPayCode
());
syncOrderParam
.
setPrice
(
storeOrder
.
getPriceActual
());
syncOrderParam
.
setPaymentId
(
"FREE_PAYMENT_ID"
);
syncOrderParam
.
setPaymentType
(
null
);
syncOrderParam
.
setStatus
(
1
);
// syncOrder(syncOrderParam);
return
ResponseDto
.
success
(
payInnerResultVo
);
}
else
{
return
ResponseDto
.
success
(
payInnerResultVo
);
}
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
View file @
f69d27f6
...
...
@@ -32,7 +32,7 @@ public class GoblinRedisUtils {
public
int
getSkuStock
(
String
marketPre
,
String
skuId
)
{
String
rk
=
GoblinRedisConst
.
REAL_STOCK_SKU
;
if
(
marketPre
!=
null
)
{
if
(
marketPre
!=
null
&&
!
marketPre
.
equals
(
"null"
)
)
{
rk
=
rk
.
concat
(
marketPre
+
":"
);
}
rk
=
rk
.
concat
(
skuId
);
...
...
@@ -46,7 +46,7 @@ public class GoblinRedisUtils {
public
int
incrSkuStock
(
String
marketPre
,
String
skuId
,
Integer
stock
)
{
String
rk
=
GoblinRedisConst
.
REAL_STOCK_SKU
;
if
(
marketPre
!=
null
)
{
if
(
marketPre
!=
null
&&
!
marketPre
.
equals
(
"null"
)
)
{
rk
=
rk
.
concat
(
marketPre
+
":"
);
}
rk
=
rk
.
concat
(
skuId
);
...
...
@@ -55,7 +55,7 @@ public class GoblinRedisUtils {
public
int
decrSkuStock
(
String
marketPre
,
String
skuId
,
Integer
stock
)
{
String
rk
=
GoblinRedisConst
.
REAL_STOCK_SKU
;
if
(
marketPre
!=
null
)
{
if
(
marketPre
!=
null
&&
!
marketPre
.
equals
(
"null"
)
)
{
rk
=
rk
.
concat
(
marketPre
+
":"
);
}
rk
=
rk
.
concat
(
skuId
);
...
...
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