Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jenkins
order-group
Commits
6f1bafb3
Commit
6f1bafb3
authored
Feb 26, 2020
by
dingkai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重量计算
parent
8109e09b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
10 deletions
+31
-10
assortment-ordercenter-sdk/src/main/java/com/freemud/sdk/api/assortment/order/adapter/OrderSdkAdapter.java
+3
-10
assortment-ordercenter-sdk/src/main/java/com/freemud/sdk/api/assortment/order/util/WeightUtils.java
+28
-0
No files found.
assortment-ordercenter-sdk/src/main/java/com/freemud/sdk/api/assortment/order/adapter/OrderSdkAdapter.java
View file @
6f1bafb3
...
@@ -25,6 +25,7 @@ import com.freemud.sdk.api.assortment.order.request.order.OrderDownloadRequest;
...
@@ -25,6 +25,7 @@ import com.freemud.sdk.api.assortment.order.request.order.OrderDownloadRequest;
import
com.freemud.sdk.api.assortment.order.request.order.*
;
import
com.freemud.sdk.api.assortment.order.request.order.*
;
import
com.freemud.sdk.api.assortment.order.response.order.*
;
import
com.freemud.sdk.api.assortment.order.response.order.*
;
import
com.freemud.sdk.api.assortment.order.response.payment.OrderPayResponse
;
import
com.freemud.sdk.api.assortment.order.response.payment.OrderPayResponse
;
import
com.freemud.sdk.api.assortment.order.util.WeightUtils
;
import
ma.glasnost.orika.MapperFacade
;
import
ma.glasnost.orika.MapperFacade
;
import
ma.glasnost.orika.impl.DefaultMapperFactory
;
import
ma.glasnost.orika.impl.DefaultMapperFactory
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
...
@@ -2734,20 +2735,12 @@ public class OrderSdkAdapter {
...
@@ -2734,20 +2735,12 @@ public class OrderSdkAdapter {
if
(
ObjectUtils
.
equals
(
ProductTypeEnum
.
SETMEAL_PRODUCT
.
getCode
(),
productRequest
.
getProductType
())
||
ObjectUtils
.
equals
(
ProductTypeEnum
.
SETMEAL_UPPRICE_PRODUCT
.
getCode
(),
productRequest
.
getProductType
()))
{
if
(
ObjectUtils
.
equals
(
ProductTypeEnum
.
SETMEAL_PRODUCT
.
getCode
(),
productRequest
.
getProductType
())
||
ObjectUtils
.
equals
(
ProductTypeEnum
.
SETMEAL_UPPRICE_PRODUCT
.
getCode
(),
productRequest
.
getProductType
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
productRequest
.
getComboProduct
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
productRequest
.
getComboProduct
()))
{
Double
comboProductTotalWeight
=
productRequest
.
getComboProduct
().
stream
().
map
(
t
->
{
Double
comboProductTotalWeight
=
productRequest
.
getComboProduct
().
stream
().
map
(
t
->
{
Double
productWeight
=
t
.
getWeight
()
==
null
?
0
D
:
t
.
getWeight
();
return
WeightUtils
.
changeToG
(
t
.
getWeight
(),
t
.
getUnit
());
if
(
ProductTypeEnum
.
WEIGHT_PRODUCT
.
getCode
().
equals
(
t
.
getProductType
()))
{
productWeight
=
productWeight
*
500
;
}
return
productWeight
;
}).
reduce
(
0
D
,
Double:
:
sum
);
}).
reduce
(
0
D
,
Double:
:
sum
);
totalWeight
+=
comboProductTotalWeight
;
totalWeight
+=
comboProductTotalWeight
;
}
}
}
else
{
}
else
{
Double
productWeight
=
productRequest
.
getWeight
()
==
null
?
0
D
:
productRequest
.
getWeight
();
totalWeight
+=
WeightUtils
.
changeToG
(
productRequest
.
getWeight
(),
productRequest
.
getUnit
());;
if
(
ProductTypeEnum
.
WEIGHT_PRODUCT
.
getCode
().
equals
(
productRequest
.
getProductType
()))
{
productWeight
=
productWeight
*
500
;
}
totalWeight
+=
productWeight
;
}
}
}
}
return
totalWeight
;
return
totalWeight
;
...
...
assortment-ordercenter-sdk/src/main/java/com/freemud/sdk/api/assortment/order/util/WeightUtils.java
0 → 100644
View file @
6f1bafb3
package
com
.
freemud
.
sdk
.
api
.
assortment
.
order
.
util
;
import
org.apache.commons.lang.StringUtils
;
public
class
WeightUtils
{
public
static
Double
changeToG
(
Double
weight
,
String
unit
)
{
weight
=
weight
==
null
?
0
D
:
weight
;
if
(
unit
==
null
)
{
return
weight
;
}
switch
(
unit
)
{
case
"g"
:
case
"克"
:
return
weight
;
case
"千克"
:
return
weight
*
1000
;
case
"两"
:
return
weight
*
50
;
case
"斤"
:
return
weight
*
500
;
case
"磅"
:
return
weight
*
453.59237d
;
default
:
return
weight
;
}
}
}
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