Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
holmes
Commits
782fe9eb
Commit
782fe9eb
authored
Mar 01, 2022
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增企业购提交订单mock接口
parent
c3656c97
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
418 additions
and
0 deletions
+418
-0
OrderController.java
...n/qg/holmes/controller/mock/keystone/OrderController.java
+106
-0
BizSku.java
src/main/java/cn/qg/holmes/entity/mock/keystone/BizSku.java
+64
-0
SubmitOrderRequest.java
...cn/qg/holmes/entity/mock/keystone/SubmitOrderRequest.java
+248
-0
No files found.
src/main/java/cn/qg/holmes/controller/mock/keystone/OrderController.java
0 → 100644
View file @
782fe9eb
package
cn
.
qg
.
holmes
.
controller
.
mock
.
keystone
;
import
cn.qg.holmes.entity.mock.keystone.BizSku
;
import
cn.qg.holmes.entity.mock.keystone.SubmitOrderRequest
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.RandomStringUtils
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@RestController
public
class
OrderController
{
/**
* 商品税率
*/
private
final
BigDecimal
TAX
=
new
BigDecimal
(
"0.13"
);
/**
* SKU分配,随便MOCK一个
*/
private
final
Integer
SKU_CATEGORY
=
15924
;
/**
* 企业购提交订单接口
* @param submitOrderRequest 请求参数
* @return
*/
@PostMapping
(
"/api/order/submitOrder"
)
public
JSONObject
qygSubmitOrder
(
SubmitOrderRequest
submitOrderRequest
)
{
log
.
info
(
"收到企业购提交订单请求:{}"
,
JSON
.
toJSONString
(
submitOrderRequest
));
JSONObject
response
=
new
JSONObject
();
List
<
SubmitOrderRequest
.
JdSkuPriceInfo
>
orderPriceSnaps
=
(
List
<
SubmitOrderRequest
.
JdSkuPriceInfo
>)
JSONObject
.
parse
(
submitOrderRequest
.
getOrderPriceSnap
());
List
<
SubmitOrderRequest
.
JdSkuInfo
>
skuInfos
=
(
List
<
SubmitOrderRequest
.
JdSkuInfo
>)
JSONObject
.
parse
(
submitOrderRequest
.
getSku
());
Map
<
String
,
BigDecimal
>
skuPriceMap
=
convertSkuPriceMap
(
orderPriceSnaps
);
// 计算订单总金额
BigDecimal
orderPrice
=
new
BigDecimal
(
0
);
for
(
SubmitOrderRequest
.
JdSkuInfo
jdSkuInfo:
skuInfos
)
{
BigDecimal
skuNum
=
new
BigDecimal
(
jdSkuInfo
.
getNum
());
String
skuId
=
jdSkuInfo
.
getSkuId
();
BigDecimal
price
=
skuPriceMap
.
get
(
skuId
);
orderPrice
=
orderPrice
.
add
(
price
.
multiply
(
skuNum
));
}
response
.
put
(
"success"
,
true
);
response
.
put
(
"resultCode"
,
"0001"
);
response
.
put
(
"resultMessage"
,
"下单成功"
);
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"jdOrderId"
,
RandomStringUtils
.
randomNumeric
(
12
));
result
.
put
(
"freight"
,
calculateFreight
(
orderPrice
));
result
.
put
(
"orderPrice"
,
orderPrice
);
BigDecimal
orderNakedPrice
=
orderPrice
.
divide
(
TAX
.
add
(
new
BigDecimal
(
1
)),
BigDecimal
.
ROUND_HALF_UP
);
result
.
put
(
"orderNakedPrice"
,
orderNakedPrice
);
List
<
BizSku
>
bizSkuList
=
new
ArrayList
<>();
for
(
SubmitOrderRequest
.
JdSkuInfo
sku:
skuInfos
)
{
BizSku
bizSku
=
new
BizSku
();
String
skuId
=
sku
.
getSkuId
();
bizSku
.
setSkuId
(
Long
.
valueOf
(
skuId
));
bizSku
.
setNum
(
sku
.
getNum
());
bizSku
.
setCategory
(
SKU_CATEGORY
);
BigDecimal
price
=
skuPriceMap
.
get
(
skuId
);
bizSku
.
setPrice
(
price
);
bizSku
.
setName
(
"xxx商品"
);
bizSku
.
setTax
(
TAX
.
multiply
(
new
BigDecimal
(
102
)));
BigDecimal
nakedPrice
=
price
.
divide
(
TAX
.
add
(
new
BigDecimal
(
1
)),
BigDecimal
.
ROUND_HALF_UP
);
bizSku
.
setNakedPrice
(
nakedPrice
);
bizSku
.
setTaxPrice
(
price
.
subtract
(
nakedPrice
));
bizSku
.
setType
(
0
);
bizSku
.
setOid
(
0L
);
bizSkuList
.
add
(
bizSku
);
}
result
.
put
(
"sku"
,
bizSkuList
);
result
.
put
(
"orderTaxPrice"
,
orderNakedPrice
.
multiply
(
TAX
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
response
.
put
(
"result"
,
result
);
return
response
;
}
public
Map
<
String
,
BigDecimal
>
convertSkuPriceMap
(
List
<
SubmitOrderRequest
.
JdSkuPriceInfo
>
orderPriceSnaps
)
{
Map
<
String
,
BigDecimal
>
map
=
new
HashMap
<>();
for
(
SubmitOrderRequest
.
JdSkuPriceInfo
jdSkuPriceInfo:
orderPriceSnaps
)
{
map
.
put
(
jdSkuPriceInfo
.
getSkuId
(),
jdSkuPriceInfo
.
getPrice
());
}
return
map
;
}
/**
* 计算运费
* @param totalPrice 总价格
* @return
*/
public
BigDecimal
calculateFreight
(
BigDecimal
totalPrice
)
{
if
(
totalPrice
.
compareTo
(
new
BigDecimal
(
"99"
))
>=
0
)
{
return
new
BigDecimal
(
"0"
);
}
else
{
return
new
BigDecimal
(
"6"
);
}
}
}
src/main/java/cn/qg/holmes/entity/mock/keystone/BizSku.java
0 → 100644
View file @
782fe9eb
package
cn
.
qg
.
holmes
.
entity
.
mock
.
keystone
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* 提交订单到京东接口,mock返回结果中的sku实体类
* @author libo
* 2022-03-01
*/
@Data
public
class
BizSku
{
/**
* 京东商品编号
*/
private
Long
skuId
;
/**
* 购买商品数量
*/
private
Integer
num
;
/**
* 商品分类编号
*/
private
Integer
category
;
/**
* 商品单价
*/
private
BigDecimal
price
;
/**
* 商品名称
*/
private
String
name
;
/**
* 商品税率
*/
private
BigDecimal
tax
;
/**
* 商品税额
*/
private
BigDecimal
taxPrice
;
/**
* 商品未税价
*/
private
BigDecimal
nakedPrice
;
/**
* 商品类型:0普通、1附件、2赠品、3延保
*/
private
Integer
type
;
/**
* 主商品skuid,如果本身是主商品,则oid为0
*/
private
Long
oid
;
}
src/main/java/cn/qg/holmes/entity/mock/keystone/SubmitOrderRequest.java
0 → 100644
View file @
782fe9eb
package
cn
.
qg
.
holmes
.
entity
.
mock
.
keystone
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
* @author wudi
* @since 2020/12/29.
*/
@Data
public
class
SubmitOrderRequest
{
/**
* 第三方订单号
*/
private
String
thirdOrder
;
/**
* 下单商品信息
*/
private
String
sku
;
/**
* 收件人姓名
*/
private
String
name
;
/**
* 一级地址
*/
private
Long
province
;
/**
* 二级地址
*/
private
Long
city
;
/**
* 三级地址
*/
private
Long
county
;
/**
* 四级地址
*/
private
Long
town
=
0L
;
/**
* 收货人详细地址
*/
private
String
address
;
/**
* 手机号
*/
private
String
mobile
;
/**
* 邮箱
*/
private
String
email
;
/**
* 备注(少于100字)
*/
private
String
remark
;
/**
* 下单商品价格信息
*/
private
String
orderPriceSnap
;
/**
* 支付方式 (1:货到付款, 4:在线支付,5:公司转账, 101:金采支付)
*/
private
Integer
paymentType
=
4
;
/**
* 使用余额 paymentType=4时,此值固定是1 其他支付方式 0
*/
private
Integer
isUseBalance
=
1
;
/**
* 是否预占库存,0是预占库存(需要调用确认订单接口),1是不预占库存
*/
private
Integer
submitState
=
1
;
/**
* 开票方式(2为集中开票,4 订单完成后开票)
*/
private
Integer
invoiceState
=
2
;
/**
* 发票类型(2增值税专用发票;3 电子票) 当发票类型为2时,开票方式只支持2集中开票
*/
private
Integer
invoiceType
=
2
;
/**
* 发票类型:4:个人,5:单位
*/
private
Integer
selectedInvoiceTitle
=
5
;
/**
* 发票抬头 (如果selectedInvoiceTitle=5则此字段必须)
*/
private
String
companyName
=
"北京量化派科技有限公司"
;
/**
* 1:明细,100:大类
*/
private
Integer
invoiceContent
=
1
;
/**
* 1价格校验(建议传1);0 不需要
*/
private
Integer
doOrderPriceMode
=
1
;
/**
* 增专票收票人姓名
*/
private
String
invoiceName
=
"张起跃"
;
/**
* 收票人电话
*/
private
String
invoicePhone
=
"15243149899"
;
/**
* 增专票收票人所在省(京东地址编码) 当发票了类型为2增值税专用发票时,该字段必填。
*/
private
Integer
invoiceProvice
=
1
;
/**
* 增专票收票人所在市(京东地址编码) 当invoiceType =2时,该字段必填。
*/
private
Integer
invoiceCity
=
2800
;
/**
* 增专票收票人所在区/县(京东地址编码) 当invoiceType =2时,该字段必填。
*/
private
Integer
invoiceCounty
=
2849
;
/**
* 增专票收票人所在地址当invoiceType =2时,该字段必填。
*/
private
String
invoiceAddress
=
"北京市海淀区中国电子大厦b座17层"
;
/**
* 专票资质公司名称 当invoiceType =2时,该字段必填。
*/
private
String
regCompanyName
=
"北京量化派科技有限公司"
;
/**
* 专票资质纳税人识别号 当invoiceType =2时,该字段必填。
*/
private
String
regCode
=
"91110108MA00D16A0J"
;
/**
* 专票资质注册地址 当invoiceType =2时,该字段必填。
*/
private
String
regAddr
=
"北京市海淀区苏州街49号1层111室"
;
/**
* 专票资质注册电话 当invoiceType =2时,该字段必填。
*/
private
String
regPhone
=
"010-82194732"
;
/**
* 专票资质注册银行 当invoiceType =2时,该字段必填。
*/
private
String
regBank
=
"平安银行北京海淀支行"
;
/**
* 专票资质银行账号 当invoiceType =2时,该字段必填。
*/
private
String
regBankAccount
=
"15000083085234"
;
/**
* 大家电配送日期:默认值为-1,0表示当天,1表示明天,2:表示后天; 如果为-1表示不使用大家电预约日历
*/
private
Integer
reservingDate
;
/**
* 大家电安装日期:默认按-1处理,0表示当天,1表示明天,2:表示后天
*/
private
Integer
installDate
;
/**
* 是否选择了安装,默认为true,选择了“暂缓安装”,此为必填项,必填值为false。
*/
private
boolean
needInstall
;
/**
* 中小件配送预约日期,格式:yyyy-MM-dd
*/
private
String
promiseDate
;
/**
* 中小件配送预约时间段,时间段如: 9:00-15:00
*/
private
String
promiseTimeRange
;
/**
* 中小件预约时间段的标记
*/
private
Integer
promiseTimeRangeCode
;
/**
* 家电配送预约日期,格式:yyyy-MM-dd
*/
private
String
reservedDateStr
;
/**
* 大家电配送预约时间段,如果:9:00-15:00
*/
private
String
reservedTimeRange
;
/**
* 循环日历, 客户传入最近一周可配送的时间段,客户入参:{"3": "09:00-10:00,12:00-19:00","4": "09:00-15:00"}
*/
private
String
cycleCalendar
;
/**
* 采购单号,长度范围[1-26]
*/
private
String
poNo
;
/**
* 节假日不可配送,默认值为false,表示节假日可以配送,为true表示节假日不配送
*/
private
boolean
validHolidayVocation
;
@Data
public
static
class
JdSkuInfo
{
private
String
skuId
;
private
Integer
num
;
private
boolean
bNeedGift
=
false
;
}
@Data
public
static
class
JdSkuPriceInfo
{
private
String
skuId
;
private
BigDecimal
price
;
}
}
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