Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supplier
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
王宇航
supplier
Commits
d6728069
Commit
d6728069
authored
Oct 22, 2020
by
宁斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
order-base模塊代碼遷移
parent
27732b86
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
946 additions
and
49 deletions
+946
-49
base-module/4ML4O`02K2Y%F(U_21@3P8Y.jpg
+0
-0
base-module/build.gradle
+0
-3
base-module/src/main/java/com/gingersoft/gsa/cloud/bean/expandInfo/ExpandInfoSetting.java
+0
-5
cc-settings.gradle
+8
-14
database-module/build.gradle
+13
-8
delivery_pick_module/build.gradle
+0
-3
main-module/build.gradle
+0
-3
manager-module/build.gradle
+0
-1
order-base/build.gradle
+0
-3
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/Member.java
+19
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/OrderItem.java
+10
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/bean/OrderDetail.java
+2
-1
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/billItem/BillItem.java
+46
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/billItem/DiscountItem.java
+27
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/billItem/RoundingItem.java
+30
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/billItem/ServiceChargeItem.java
+26
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/cart/ShoppingCart.java
+255
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/commodity/Commodity.java
+26
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/commodity/MealCommodity.java
+0
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/commodity/MealTakeaway.java
+13
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/discount/CouponDiscount.java
+79
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/discount/MemberDiscount.java
+48
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/discount/MultyDiscount.java
+30
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/discount/NomalDiscount.java
+61
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/order/BaseOrder.java
+37
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/order/DoshokuOrder.java
+66
-0
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/order/TakeawayOrder.java
+28
-0
table-module/build.gradle
+0
-3
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/BaseOrderPresenter.java
+122
-5
No files found.
base-module/4ML4O`02K2Y%F(U_21@3P8Y.jpg
deleted
100644 → 0
View file @
27732b86
53.5 KB
base-module/build.gradle
View file @
d6728069
...
...
@@ -110,9 +110,6 @@ dependencies {
implementation
'cn.bingoogolapple:bga-baseadapter:1.2.9@aar'
implementation
'cn.bingoogolapple:bga-flowlayout:1.0.0@aar'
implementation
'org.projectlombok:lombok:1.18.8'
annotationProcessor
'org.projectlombok:lombok:1.18.8'
api
'androidx.core:core-ktx:+'
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api
'com.github.huangyanbin:SmartTable:2.2.0'
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/bean/expandInfo/ExpandInfoSetting.java
View file @
d6728069
...
...
@@ -3,12 +3,9 @@ package com.gingersoft.gsa.cloud.bean.expandInfo;
import
com.gingersoft.gsa.cloud.base.Api
;
import
com.gingersoft.gsa.cloud.base.utils.JsonUtils
;
import
com.gingersoft.gsa.cloud.base.utils.ReflectionUtils
;
import
com.gingersoft.gsa.cloud.base.utils.RestaurantExpandInfoUtils
;
import
com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils
;
import
com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils
;
import
com.gingersoft.gsa.cloud.constans.HttpsConstans
;
import
com.gingersoft.gsa.cloud.database.bean.ExpandInfo
;
import
com.gingersoft.gsa.cloud.database.utils.ExpandInfoDaoUtils
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationTargetException
;
...
...
@@ -16,14 +13,12 @@ import java.lang.reflect.Method;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
io.reactivex.Observable
;
import
io.reactivex.functions.Consumer
;
import
io.reactivex.schedulers.Schedulers
;
import
lombok.Builder
;
import
lombok.Getter
;
import
lombok.Setter
;
import
me.jessyan.retrofiturlmanager.RetrofitUrlManager
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
...
...
cc-settings.gradle
View file @
d6728069
...
...
@@ -12,28 +12,24 @@ dependencies {
if
(
project
.
name
!=
'base-module'
&&
project
.
name
!=
'database-module'
&&
project
.
name
!=
'arms'
&&
project
.
name
!=
'fragmentation_core'
&&
project
.
name
!=
'qm-qmui'
&&
project
.
name
!=
'qm-arch'
&&
project
.
name
!=
'qm-skin-maker'
)
{
api
project
(
':base-module'
)
}
if
(
project
.
name
!=
'base-module'
&&
project
.
name
!=
'table-base'
&&
(
project
.
name
==
'table-module'
||
project
.
name
==
'manager-module'
||
project
.
name
==
'order-base'
))
{
if
(
project
.
name
!=
'base-module'
&&
project
.
name
!=
'
database-module'
&&
project
.
name
!=
'
table-base'
&&
(
project
.
name
==
'table-module'
||
project
.
name
==
'manager-module'
||
project
.
name
==
'order-base'
))
{
api
project
(
':table-base'
)
}
if
(
project
.
name
!=
'base-module'
&&
project
.
name
!=
'order-base'
&&
(
project
.
name
==
'table-module'
||
project
.
name
==
'print-module'
||
if
(
project
.
name
!=
'base-module'
&&
project
.
name
!=
'order-base'
&&
project
.
name
!=
'database-module'
&&
(
project
.
name
==
'table-module'
||
project
.
name
==
'print-module'
||
project
.
name
==
'coldchain-module'
||
project
.
name
==
'delivery_pick_module'
||
project
.
name
==
'order-advance-module'
))
{
api
project
(
':order-base'
)
}
if
(
project
.
name
==
'table-module'
)
{
api
project
(
':pay-module'
)
}
if
(
project
.
name
!=
'database-module'
&&
project
.
name
!=
'arms'
&&
project
.
name
!=
'fragmentation_core'
&&
project
.
name
!=
'qm-qmui'
&&
project
.
name
!=
'qm-arch'
&&
project
.
name
!=
'qm-skin-maker'
)
{
if
(
project
.
name
!=
'database-module'
&&
project
.
name
!=
'arms'
&&
project
.
name
!=
'fragmentation_core'
&&
project
.
name
!=
'qm-qmui'
&&
project
.
name
!=
'qm-arch'
&&
project
.
name
!=
'qm-skin-maker'
)
{
api
project
(
':database-module'
)
}
if
(
project
.
name
!=
'arms'
&&
project
.
name
!=
'fragmentation_core'
&&
project
.
name
!=
'qm-qmui'
&&
project
.
name
!=
'qm-arch'
&&
project
.
name
!=
'qm-skin-maker'
)
{
if
(
project
.
name
!=
'arms'
&&
project
.
name
!=
'fragmentation_core'
&&
project
.
name
!=
'qm-qmui'
&&
project
.
name
!=
'qm-arch'
&&
project
.
name
!=
'qm-skin-maker'
)
{
api
project
(
':arms'
)
}
//
if
(
project
.
name
!=
'qm-qmui'
&&
project
.
name
!=
'arms'
&&
project
.
name
!=
'fragmentation_core'
&&
project
.
name
!=
'qm-arch'
&&
project
.
name
!=
'qm-skin-maker'
)
{
// if (project.name != 'arms') {
api
project
(
':qm-qmui'
)
// implementation rootProject.ext.dependencies["qmui"]
}
if
(
project
.
name
!=
'qm-arch'
&&
project
.
name
!=
'qm-qmui'
&&
project
.
name
!=
'base-module'
&&
project
.
name
!=
'qm-skin-maker'
)
{
api
project
(
':qm-arch'
)
...
...
@@ -41,12 +37,6 @@ dependencies {
if
(
project
.
name
!=
'qm-skin-maker'
&&
project
.
name
!=
'qm-arch'
&&
project
.
name
!=
'qm-qmui'
)
{
api
project
(
':qm-skin-maker'
)
}
// if (project.name == 'main-module') {
// api project(':updateApk')
// }
// if (project.name == 'arms') {
// api project(':fragmentation_core')
// }
implementation
rootProject
.
ext
.
dependencies
[
"retrofit-url-manager"
]
annotationProcessor
rootProject
.
ext
.
dependencies
[
"butterknife-compiler"
]
// annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]//依赖插件
...
...
@@ -56,6 +46,10 @@ dependencies {
implementation
'org.jetbrains:annotations:15.0'
//日誌管理
implementation
'com.elvishew:xlog:1.6.1'
//lombok
implementation
'org.projectlombok:lombok:1.18.10'
annotationProcessor
'org.projectlombok:lombok:1.18.10'
}
//此文件是作为组件化配置的公共gradle脚本文件,在每个组件中都apply此文件,下载到工程根目录后,可以在下方添加一些自己工程中通用的配置
...
...
database-module/build.gradle
View file @
d6728069
ext
.
alwaysLib
=
true
//虽然apply了cc-settings-2.gradle,但一直作为library编译,否则别的组件依赖此module时会报错
apply
from:
rootProject
.
file
(
"cc-settings.gradle"
)
apply
plugin:
'com.jakewharton.butterknife'
apply
plugin:
'org.greenrobot.greendao'
android
{
compileSdkVersion
rootProject
.
ext
.
android
[
"compileSdkVersion"
]
...
...
@@ -65,16 +67,19 @@ android {
}
dependencies
{
implementation
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
debugImplementation
rootProject
.
ext
.
dependencies
[
"canary-debug"
]
releaseImplementation
rootProject
.
ext
.
dependencies
[
"canary-release"
]
testImplementation
rootProject
.
ext
.
dependencies
[
"canary-release"
]
testImplementation
rootProject
.
ext
.
dependencies
[
"junit"
]
if
(
project
.
ext
.
runAsApp
)
{
annotationProcessor
rootProject
.
ext
.
dependencies
[
"dagger2-compiler"
]
debugImplementation
rootProject
.
ext
.
dependencies
[
"canary-debug"
]
releaseImplementation
rootProject
.
ext
.
dependencies
[
"canary-release"
]
testImplementation
rootProject
.
ext
.
dependencies
[
"canary-release"
]
}
else
{
compileOnly
rootProject
.
ext
.
dependencies
[
"dagger2-compiler"
]
compileOnly
rootProject
.
ext
.
dependencies
[
"canary-debug"
]
compileOnly
rootProject
.
ext
.
dependencies
[
"canary-release"
]
compileOnly
rootProject
.
ext
.
dependencies
[
"canary-release"
]
}
// 數據庫
implementation
'org.greenrobot:greendao:3.2.2'
implementation
'org.greenrobot:greendao-generator:3.2.2'
implementation
'org.projectlombok:lombok:1.18.10'
annotationProcessor
'org.projectlombok:lombok:1.18.10'
}
delivery_pick_module/build.gradle
View file @
d6728069
...
...
@@ -71,7 +71,4 @@ dependencies {
if
(
project
.
ext
.
runAsApp
)
{
addComponent
'print-module'
}
implementation
'org.projectlombok:lombok:1.18.10'
annotationProcessor
'org.projectlombok:lombok:1.18.10'
}
main-module/build.gradle
View file @
d6728069
...
...
@@ -69,9 +69,6 @@ dependencies {
implementation
"androidx.core:core-ktx:+"
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation
'org.projectlombok:lombok:1.18.10'
annotationProcessor
'org.projectlombok:lombok:1.18.10'
}
repositories
{
mavenCentral
()
...
...
manager-module/build.gradle
View file @
d6728069
...
...
@@ -52,5 +52,4 @@ dependencies {
testImplementation
rootProject
.
ext
.
dependencies
[
"junit"
]
implementation
rootProject
.
ext
.
dependencies
[
"BaseRecyclerViewAdapter"
]
// implementation "androidx.core:core-ktx:+"
}
order-base/build.gradle
View file @
d6728069
...
...
@@ -56,7 +56,4 @@ dependencies {
releaseImplementation
rootProject
.
ext
.
dependencies
[
"canary-release"
]
testImplementation
rootProject
.
ext
.
dependencies
[
"canary-release"
]
testImplementation
rootProject
.
ext
.
dependencies
[
"junit"
]
implementation
'org.projectlombok:lombok:1.18.10'
annotationProcessor
'org.projectlombok:lombok:1.18.10'
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/Member.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
;
import
com.gingersoft.gsa.cloud.base.common.bean.MemberInfo
;
/**
* @author : bin
* @create date: 2020-10-15
* @update date: 2020-10-15
* @description:會員接口 需要使用到會員須實現這個接口
*
*/
public
interface
Member
{
/**
* 會員會員信息
* @return
*/
MemberInfo
getMemberInfo
();
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/OrderItem.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
;
/**
* @author : bin
* @create date: 2020-10-15
* @update date: 2020-10-15
* @description:餐牌下單 食品,折扣都需要實現這個接口
* */
public
interface
OrderItem
{
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/bean/OrderDetail.java
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
bean
;
import
com.gingersoft.gsa.cloud.base.order.bean.discount.OrderDiscount
;
import
com.gingersoft.gsa.cloud.base.order.bean.mealManger.MyOrderManage
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
import
com.gingersoft.gsa.cloud.database.bean.ComboItem
;
...
...
@@ -1236,7 +1237,7 @@ public class OrderDetail implements Serializable {
*/
public
static
OrderDetail
discountTransOrderDetail
(
Discount
discount
,
boolean
isNew
,
long
id
,
double
sourcePrice
)
{
double
discountPrice
=
Discount
.
calculationDiscount
(
discount
,
sourcePrice
);
double
discountPrice
=
Order
Discount
.
calculationDiscount
(
discount
,
sourcePrice
);
OrderDetail
orderDetail
=
new
OrderDetail
();
orderDetail
.
setProductName
(
discount
.
getRemark
());
...
...
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/billItem/BillItem.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
billItem
;
import
lombok.Data
;
/**
* @author : bin
* @create date: 2020-10-14
* @update date: 2020-10-14
* @description: 賬單項抽象類{@link BillItem}
*/
@Data
public
abstract
class
BillItem
{
protected
String
name
;
protected
double
money
=
0.0
;
public
byte
type
=
ORDER_DISCOUNT_TYPE
;
/**整單折扣*/
public
static
final
byte
ORDER_DISCOUNT_TYPE
=
0
;
/**會員等級折扣*/
public
static
final
byte
MEMBER_DISCOUNT_TYPE
=
1
;
/**優惠券折扣*/
public
static
final
byte
COUPON_DISCOUNT_TYPE
=
2
;
/**服務費*/
public
static
final
byte
SERVERCHARGE_TYPE
=
3
;
/**賬單小數*/
public
static
final
byte
ROUNDING_TYPE
=
4
;
public
BillItem
()
{
}
public
BillItem
(
String
name
)
{
this
.
name
=
name
;
}
public
BillItem
(
byte
type
,
String
name
)
{
this
.
type
=
type
;
this
.
name
=
name
;
}
public
BillItem
(
String
name
,
double
money
)
{
this
.
name
=
name
;
this
.
money
=
money
;
}
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/billItem/DiscountItem.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
billItem
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @author : bin
* @create date: 2020-10-15
* @update date: 2020-10-15
* @description:
*/
@Getter
@Setter
public
class
DiscountItem
extends
BillItem
{
public
DiscountItem
()
{
}
public
DiscountItem
(
String
name
,
double
money
)
{
super
(
name
,
money
);
}
public
void
updateBillItem
()
{
}
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/billItem/RoundingItem.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
billItem
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
/**
* @author : bin
* @create date: 2020-10-14
* @update date: 2020-10-14
* @description:賬單小數項
*/
public
class
RoundingItem
extends
BillItem
{
public
RoundingItem
(
String
name
,
double
totalAmout
)
{
super
(
BillItem
.
ROUNDING_TYPE
,
name
);
updateBillItem
(
totalAmout
);
}
public
void
updateBillItem
(
double
totalAmout
)
{
double
m2
=
MoneyUtil
.
getOrderRounding
(
totalAmout
);
double
roundingMoney
=
0.0
;
if
(
m2
!=
0
)
{
roundingMoney
=
MoneyUtil
.
sub
(
m2
,
MoneyUtil
.
get_ItemDecimals_money
(
totalAmout
));
}
if
(
roundingMoney
!=
0.0
)
{
setMoney
(
roundingMoney
);
}
}
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/billItem/ServiceChargeItem.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
billItem
;
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
/**
* @author : bin
* @create date: 2020-10-14
* @update date: 2020-10-14
* @description:服務費項
*/
public
class
ServiceChargeItem
extends
BillItem
{
public
ServiceChargeItem
(
String
name
,
double
totalAmout
,
int
serviceCharge
)
{
super
(
BillItem
.
SERVERCHARGE_TYPE
,
name
);
updateBillItem
(
totalAmout
,
serviceCharge
);
}
public
void
updateBillItem
(
double
totalAmout
,
int
serviceCharge
)
{
double
serviceAmount
=
MoneyUtil
.
divide
(
MoneyUtil
.
multiply
(
totalAmout
,
serviceCharge
).
doubleValue
(),
100
,
GsaCloudApplication
.
functionConfiguration
.
getItemDecimals
());
if
(
serviceAmount
>
0
)
{
setMoney
(
serviceAmount
);
}
}
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/cart/ShoppingCart.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
cart
;
import
com.gingersoft.gsa.cloud.base.common.bean.MemberInfo
;
import
com.gingersoft.gsa.cloud.base.order.bean.discount.CouponDiscountBean
;
import
com.gingersoft.gsa.cloud.base.order.billItem.BillItem
;
import
com.gingersoft.gsa.cloud.base.order.commodity.Commodity
;
import
com.gingersoft.gsa.cloud.base.order.commodity.MealCommodity
;
import
com.gingersoft.gsa.cloud.base.order.commodity.MealTakeaway
;
import
com.gingersoft.gsa.cloud.base.order.discount.CouponDiscount
;
import
com.gingersoft.gsa.cloud.base.order.discount.MemberDiscount
;
import
com.gingersoft.gsa.cloud.base.order.discount.MultyDiscount
;
import
com.gingersoft.gsa.cloud.base.order.discount.NomalDiscount
;
import
com.jess.arms.utils.Preconditions
;
import
java.util.ArrayList
;
import
java.util.List
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-09-19
* 修订历史:2020-09-19
* 描述: 購物車
*/
@Setter
@Getter
public
class
ShoppingCart
{
private
static
ShoppingCart
shoppingCart
;
public
static
ShoppingCart
getInstance
()
{
if
(
shoppingCart
==
null
)
{
shoppingCart
=
new
ShoppingCart
();
}
return
shoppingCart
;
}
/**
* 商品列表
*/
protected
List
<
Commodity
>
orderCommodityList
=
new
ArrayList
<>();
/**
* 賬單項列表
*/
protected
List
<
BillItem
>
billItemList
=
new
ArrayList
<>();
/**
* 折扣列表
*
* @see NomalDiscount
* @see MemberDiscount
* @see CouponDiscount
*/
protected
List
<
MultyDiscount
>
multyDiscountList
=
new
ArrayList
<>();
/**
* 所有折扣實體
*/
private
MultyDiscount
multyDiscounts
;
/**
* 服務費
*/
protected
Integer
serviceCharge
;
/**
* 合計
*/
protected
double
wholeAmount
=
0.0
;
/**
* 總金額
*/
protected
double
totalAmount
=
0.0
;
/**
* 將商品添加到購物車
*
* @param commodityList
*/
public
void
addCommodityList
(
List
<
Commodity
>
commodityList
)
{
orderCommodityList
.
addAll
(
commodityList
);
}
/**
* 將商品添加到購物車
*
* @param commodity
*/
public
void
addCommodity
(
Commodity
commodity
)
{
orderCommodityList
.
add
(
commodity
);
}
/**
* 將商品移出購物車
*
* @param commodity
*/
public
void
delCommodity
(
Commodity
commodity
)
{
orderCommodityList
.
remove
(
commodity
);
}
/**
* 修改商品數量
*
* @param commodity
*/
public
void
setCommodityNum
(
Commodity
commodity
,
int
number
)
{
for
(
Commodity
c
:
orderCommodityList
)
{
if
(
c
==
commodity
)
{
c
.
setNumber
(
number
);
break
;
}
}
}
/**
* 添加賬單項
*
* @param billItem
*/
public
void
addBillItem
(
BillItem
billItem
)
{
billItemList
.
add
(
billItem
);
}
/**
* 刪除張單項
*
* @param billItem
*/
public
void
delBillItem
(
BillItem
billItem
)
{
billItemList
.
remove
(
billItem
);
}
/**
* 獲取堂食數據
*
* @param position
* @return
*/
public
MealCommodity
getMealCommodity
(
int
position
)
{
Preconditions
.
checkElementIndex
(
orderCommodityList
.
size
(),
position
);
return
(
MealCommodity
)
orderCommodityList
.
get
(
position
);
}
/**
* 獲取外賣數據
*
* @param position
* @return
*/
public
MealTakeaway
getMealTakeaway
(
int
position
)
{
Preconditions
.
checkElementIndex
(
orderCommodityList
.
size
(),
position
);
return
(
MealTakeaway
)
orderCommodityList
.
get
(
position
);
}
/**
* 添加折扣
*
* @param multyDiscount
*/
public
void
addMultyDiscount
(
MultyDiscount
multyDiscount
)
{
multyDiscountList
.
add
(
multyDiscount
);
}
/**
* 將普通折扣添加到鏈條中
*
* @param discount
* @return
*/
// public MultyDiscount addNomalDiscount(Discount discount) {
// multyDiscounts = new NomalDiscount(discount.getRemark(), multyDiscounts, discount);
// return multyDiscounts;
// }
/**
* 將會員等級折扣添加到鏈條中
*
* @param discount
* @return
*/
public
MultyDiscount
addMemberDiscount
(
MemberInfo
discount
)
{
multyDiscounts
=
new
MemberDiscount
(
discount
.
getMemberName
(),
multyDiscounts
,
discount
);
return
multyDiscounts
;
}
/**
* 將優惠券折扣添加到鏈條中
*
* @param discount
* @return
*/
public
MultyDiscount
addCouponDiscount
(
CouponDiscountBean
discount
)
{
multyDiscounts
=
new
CouponDiscount
(
discount
.
getName
(),
multyDiscounts
,
discount
);
return
multyDiscounts
;
}
/**
* 計算折扣鏈金額
*/
public
double
calculateLinkedDiscounts
(
double
money
)
{
MultyDiscount
multyDiscounts
=
null
;
for
(
int
i
=
multyDiscountList
.
size
()
-
1
;
i
>=
0
;
i
--)
{
MultyDiscount
discount
=
multyDiscountList
.
get
(
i
);
// if (discount instanceof NomalDiscount) {
// multyDiscounts = addNomalDiscount(((NomalDiscount) discount).getDiscount());
// } else
if
(
discount
instanceof
MemberDiscount
)
{
multyDiscounts
=
addMemberDiscount
(((
MemberDiscount
)
discount
).
getMemberDiscount
());
}
else
if
(
discount
instanceof
CouponDiscount
)
{
multyDiscounts
=
addCouponDiscount
(((
CouponDiscount
)
discount
).
getCouponDiscount
());
}
}
if
(
multyDiscounts
!=
null
)
{
money
=
multyDiscounts
.
calculate
(
money
);
}
return
money
;
}
public
static
void
main
(
String
[]
args
)
{
ShoppingCart
shoppingCart
=
new
ShoppingCart
();
MemberInfo
memberInfo1
=
new
MemberInfo
();
memberInfo1
.
setMemberName
(
"黃金會員10%"
);
memberInfo1
.
setMemberDiscount
(
10
);
MultyDiscount
memberDiscount
=
shoppingCart
.
addMemberDiscount
(
memberInfo1
);
shoppingCart
.
addMultyDiscount
(
memberDiscount
);
CouponDiscountBean
couponDiscountBean
=
new
CouponDiscountBean
();
couponDiscountBean
.
setCouponTypeName1
(
"魚屋立減50元券"
);
couponDiscountBean
.
setAmount
(
50
);
couponDiscountBean
.
setCouponType
((
byte
)
2
);
MultyDiscount
couponDiscount
=
shoppingCart
.
addCouponDiscount
(
couponDiscountBean
);
shoppingCart
.
addMultyDiscount
(
couponDiscount
);
MemberInfo
memberInfo2
=
new
MemberInfo
();
memberInfo2
.
setMemberName
(
"白金會員20%"
);
memberInfo2
.
setMemberDiscount
(
20
);
MultyDiscount
memberDiscount2
=
shoppingCart
.
addMemberDiscount
(
memberInfo2
);
shoppingCart
.
addMultyDiscount
(
memberDiscount2
);
double
discountAfterMoney
=
shoppingCart
.
calculateLinkedDiscounts
(
200
);
System
.
out
.
println
(
"折扣後的金額:"
+
discountAfterMoney
);
}
/**
* 具體支付類需要實現的方法
*/
public
void
pay
(
double
money
)
{
}
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/commodity/Commodity.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
commodity
;
import
lombok.Data
;
/**
* @作者: bin
* @創建時間: 2020-10-14
* @更新時間: 2020-10-14
* @描述:商品接口 所有商品都需要實現這個類
*/
@Data
public
abstract
class
Commodity
{
protected
Long
id
;
protected
String
name
;
protected
String
name2
;
protected
String
name3
;
protected
double
price
;
protected
int
number
;
/**
* 类型#1:优惠卷;2:商品;3:菜品;4:细项;5:折扣;
*/
protected
byte
type
;
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/commodity/MealCommodity.java
0 → 100644
View file @
d6728069
This diff is collapsed.
Click to expand it.
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/commodity/MealTakeaway.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
commodity
;
import
com.gingersoft.gsa.cloud.base.order.OrderItem
;
/**
* @author : bin
* @create date: 2020-10-15
* @update date: 2020-10-15
* @description:外賣食品
*/
public
class
MealTakeaway
extends
MealCommodity
implements
OrderItem
{
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/discount/CouponDiscount.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
discount
;
import
com.gingersoft.gsa.cloud.base.order.bean.discount.CouponDiscountBean
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
import
lombok.Getter
;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-09-19
* 修订历史:2020-09-19
* 描述: 優惠券折扣{@link CouponDiscountBean}
*/
@Getter
public
class
CouponDiscount
extends
MultyDiscount
{
private
CouponDiscountBean
couponDiscount
;
/**
* 本次折扣金额
*/
private
Double
discountMoney
;
public
CouponDiscount
(
String
name
,
MultyDiscount
nextMultyDiscount
,
CouponDiscountBean
couponDiscount
)
{
super
(
name
,
nextMultyDiscount
);
this
.
couponDiscount
=
couponDiscount
;
}
@Override
public
double
calculate
(
double
money
)
{
if
(
couponDiscount
!=
null
)
{
//配置了消費滿減
double
totalAmount
=
money
;
if
(
couponDiscount
.
getSpend
()
!=
null
&&
totalAmount
>
couponDiscount
.
getSpend
())
{
//未滿足消費滿條件
}
else
{
discountMoney
=
calculationCoupon
(
couponDiscount
,
money
);
money
=
MoneyUtil
.
sum
(
money
,
discountMoney
);
}
}
return
super
.
calculate
(
money
);
}
/**
* 計算優惠券金額
*
* @param couponDiscount
* @param sourceMoney
* @return
*/
public
static
double
calculationCoupon
(
CouponDiscountBean
couponDiscount
,
double
sourceMoney
)
{
double
discountMoney
=
0
;
if
(
couponDiscount
.
getCouponType
()
==
2
)
{
//金額折扣
discountMoney
=
couponDiscount
.
getAmount
();
}
else
{
//百分比折扣
discountMoney
=
MoneyUtil
.
divide
(
MoneyUtil
.
multiply
(
sourceMoney
,
couponDiscount
.
getDiscount
()),
100
).
doubleValue
();
}
if
(
sourceMoney
<
discountMoney
)
{
//折扣金額不能超出總額
discountMoney
=
sourceMoney
;
}
return
-
MoneyUtil
.
get_ItemDecimals_money
(
Math
.
abs
(
discountMoney
));
}
/**
* 獲取優惠券折扣ID
*
* @return
*/
public
Long
getCouponDiscountId
()
{
if
(
couponDiscount
!=
null
)
{
return
couponDiscount
.
getId
();
}
return
null
;
}
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/discount/MemberDiscount.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
discount
;
import
com.gingersoft.gsa.cloud.base.common.bean.MemberInfo
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
import
lombok.Getter
;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-09-19
* 修订历史:2020-09-19
* 描述: 會員折扣{@link MemberInfo#memberDiscount}
*/
@Getter
public
class
MemberDiscount
extends
MultyDiscount
{
private
MemberInfo
memberDiscount
;
/**
* 本次折扣金额
*/
private
Double
discountMoney
;
public
MemberDiscount
(
String
name
,
MultyDiscount
nextMultyDiscount
,
MemberInfo
memberDiscount
)
{
super
(
name
,
nextMultyDiscount
);
this
.
memberDiscount
=
memberDiscount
;
}
@Override
public
double
calculate
(
double
money
)
{
if
(
memberDiscount
!=
null
)
{
discountMoney
=
calculationMemberDiscount
(
memberDiscount
.
getMemberDiscount
(),
money
);
money
=
MoneyUtil
.
sum
(
money
,
discountMoney
);
}
return
super
.
calculate
(
money
);
}
public
static
double
calculationMemberDiscount
(
int
discountRate
,
double
sourceMoney
)
{
double
discountMoney
=
MoneyUtil
.
divide
(
MoneyUtil
.
multiply
(
sourceMoney
,
discountRate
),
100
).
doubleValue
();
if
(
sourceMoney
<
discountMoney
)
{
//折扣金額不能超出總額
discountMoney
=
sourceMoney
;
}
return
-
MoneyUtil
.
get_ItemDecimals_money
(
Math
.
abs
(
discountMoney
));
}
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/discount/MultyDiscount.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
discount
;
import
com.gingersoft.gsa.cloud.base.order.billItem.BillItem
;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-09-19
* 修订历史:2020-09-19
* 描述: 折扣抽象類{@link MultyDiscount}
*/
public
abstract
class
MultyDiscount
extends
BillItem
{
/**責任鏈中的下一個對象*/
protected
MultyDiscount
nextMultyDiscount
;
public
MultyDiscount
(
String
name
,
MultyDiscount
nextMultyDiscount
)
{
super
(
name
);
this
.
nextMultyDiscount
=
nextMultyDiscount
;
}
public
double
calculate
(
double
money
)
{
if
(
nextMultyDiscount
!=
null
)
{
return
nextMultyDiscount
.
calculate
(
money
);
}
return
money
;
}
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/discount/NomalDiscount.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
discount
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
import
com.gingersoft.gsa.cloud.database.bean.Discount
;
import
lombok.Getter
;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-09-19
* 修订历史:2020-09-19
* 描述: 整單折扣{@link Discount}
*/
@Getter
public
class
NomalDiscount
extends
MultyDiscount
{
private
Discount
discount
;
/**
* 本次折扣金额
*/
private
Double
discountMoney
;
public
NomalDiscount
(
String
name
,
MultyDiscount
nextMultyDiscount
,
Discount
discount
)
{
super
(
name
,
nextMultyDiscount
);
this
.
discount
=
discount
;
}
@Override
public
double
calculate
(
double
money
)
{
if
(
discount
!=
null
){
discountMoney
=
calculationDiscount
(
discount
,
money
);
money
=
MoneyUtil
.
sum
(
money
,
discountMoney
);
}
return
super
.
calculate
(
money
);
}
/**
* 計算整单折扣金額
*
* @param discount
* @param sourceMoney
* @return
*/
public
static
double
calculationDiscount
(
Discount
discount
,
double
sourceMoney
)
{
double
discountMoney
;
if
(
discount
.
getType
()
==
0
)
{
//金額折扣
discountMoney
=
discount
.
getAmount
();
}
else
{
//百分比折扣
discountMoney
=
MoneyUtil
.
divide
(
MoneyUtil
.
multiply
(
sourceMoney
,
discount
.
getDiscount_value
()),
100
).
doubleValue
();
}
if
(
sourceMoney
<
discountMoney
)
{
//折扣金額不能超出總額
discountMoney
=
sourceMoney
;
}
return
-
MoneyUtil
.
get_ItemDecimals_money
(
Math
.
abs
(
discountMoney
));
}
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/order/BaseOrder.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
order
;
import
com.gingersoft.gsa.cloud.base.order.cart.ShoppingCart
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @作者: bin
* @創建時間: 2020-10-14
* @更新時間: 2020-10-14
* @描述:
*/
@Getter
@Setter
public
abstract
class
BaseOrder
{
public
BaseOrder
()
{
shoppingCart
=
ShoppingCart
.
getInstance
();
}
/**
* 訂單ID
*/
protected
long
id
=
-
1
;
/**
* 訂單編號
*/
protected
String
orderNo
;
/**
* 購物車數據
*/
protected
ShoppingCart
shoppingCart
;
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/order/DoshokuOrder.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
order
;
import
com.gingersoft.gsa.cloud.base.common.bean.MemberInfo
;
import
com.gingersoft.gsa.cloud.base.order.Member
;
import
com.gingersoft.gsa.cloud.base.order.bean.DeleteOrderRequest
;
import
com.gingersoft.gsa.cloud.base.order.bean.OrderBean
;
import
com.gingersoft.gsa.cloud.base.table.bean.TableBean
;
import
java.util.List
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @作者: bin
* @創建時間: 2020-10-14
* @更新時間: 2020-10-14
* @描述: 堂食訂單
*/
@Getter
@Setter
public
class
DoshokuOrder
extends
BaseOrder
implements
Member
{
private
static
DoshokuOrder
doshokuOrder
;
public
static
DoshokuOrder
getInstance
()
{
if
(
doshokuOrder
==
null
)
{
doshokuOrder
=
new
DoshokuOrder
();
}
return
doshokuOrder
;
}
private
DoshokuOrder
()
{
super
();
}
/**
* 記錄刪除的食品以及原因
*/
private
List
<
DeleteOrderRequest
>
deleteMealOrders
;
/**
* 已下單信息
*/
private
OrderBean
orderPlaced
;
/**
* 開台信息
*/
private
TableBean
.
DataBean
openTableInfo
;
/**
* 會員信息
*/
private
MemberInfo
memberInfo
;
/**
* 是否需要更新會員信息(如開台有然後清除: "true:false" 這種情況需要重新送單更新會員信息)
*/
private
String
memberUpdateStatus
=
true
+
"-"
+
true
;
/**
* 記錄修改訂單操作
* false#送單
* true#修改訂單
*/
private
boolean
modifyOrder
=
false
;
}
order-base/src/main/java/com/gingersoft/gsa/cloud/base/order/order/TakeawayOrder.java
0 → 100644
View file @
d6728069
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
order
;
import
lombok.Data
;
/**
* @作者: bin
* @創建時間: 2020-10-14
* @更新時間: 2020-10-14
* @描述: 外賣訂單
*/
@Data
public
class
TakeawayOrder
extends
BaseOrder
{
private
static
TakeawayOrder
takeawayOrder
;
public
static
TakeawayOrder
getInstance
()
{
if
(
takeawayOrder
==
null
)
{
takeawayOrder
=
new
TakeawayOrder
();
}
return
takeawayOrder
;
}
private
TakeawayOrder
()
{
super
();
}
}
table-module/build.gradle
View file @
d6728069
...
...
@@ -67,9 +67,6 @@ dependencies {
testImplementation
rootProject
.
ext
.
dependencies
[
"junit"
]
implementation
rootProject
.
ext
.
dependencies
[
"BaseRecyclerViewAdapter"
]
implementation
'org.projectlombok:lombok:1.18.10'
annotationProcessor
'org.projectlombok:lombok:1.18.10'
annotationProcessor
rootProject
.
ext
.
dependencies
[
"dagger2-compiler"
]
annotationProcessor
rootProject
.
ext
.
dependencies
[
"butterknife-compiler"
]
}
table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/BaseOrderPresenter.java
View file @
d6728069
...
...
@@ -15,6 +15,17 @@ import com.gingersoft.gsa.cloud.base.order.bean.discount.CouponDiscountBean;
import
com.gingersoft.gsa.cloud.base.order.bean.discount.OrderDiscount
;
import
com.gingersoft.gsa.cloud.base.order.bean.mealManger.MyOrderManage
;
import
com.gingersoft.gsa.cloud.base.order.bean.mealManger.OpenTableManage
;
import
com.gingersoft.gsa.cloud.base.order.billItem.BillItem
;
import
com.gingersoft.gsa.cloud.base.order.billItem.DiscountItem
;
import
com.gingersoft.gsa.cloud.base.order.billItem.RoundingItem
;
import
com.gingersoft.gsa.cloud.base.order.billItem.ServiceChargeItem
;
import
com.gingersoft.gsa.cloud.base.order.cart.ShoppingCart
;
import
com.gingersoft.gsa.cloud.base.order.commodity.Commodity
;
import
com.gingersoft.gsa.cloud.base.order.commodity.MealCommodity
;
import
com.gingersoft.gsa.cloud.base.order.discount.NomalDiscount
;
import
com.gingersoft.gsa.cloud.base.order.order.BaseOrder
;
import
com.gingersoft.gsa.cloud.base.order.order.DoshokuOrder
;
import
com.gingersoft.gsa.cloud.base.order.order.TakeawayOrder
;
import
com.gingersoft.gsa.cloud.base.table.bean.TableBean
;
import
com.gingersoft.gsa.cloud.base.utils.LanguageUtils
;
import
com.gingersoft.gsa.cloud.base.utils.MoneyUtil
;
...
...
@@ -109,6 +120,31 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
private
final
String
noFoodDeliveryTip
=
"賬單沒有食品,是否開台?"
;
/**
* 訂單信息
*/
protected
BaseOrder
mOrder
;
/**
* 堂食訂單信息
*/
protected
DoshokuOrder
mDoshokuOrder
;
/**
* 外賣訂單信息
*/
protected
TakeawayOrder
mTakeawayOrder
;
/**
* 美食購物車
*/
protected
ShoppingCart
mShoppingCart
;
/**
* 美食列表
*/
protected
List
<
Commodity
>
mOrderMealList
;
/**
* 賬單項列表
*/
protected
List
<
BillItem
>
mBillItemList
;
public
abstract
void
createOrder
(
boolean
isPrint
,
Class
afterToActivity
);
public
abstract
void
addOrderFood
(
boolean
isPrint
,
Class
afterToActivity
);
...
...
@@ -141,6 +177,21 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
mMealStandPresenter
=
(
MealStandPresenter
)
this
;
}
/****************************************************/
if
(
IActivity
instanceof
OrderContentActivity
)
{
mOrder
=
DoshokuOrder
.
getInstance
();
mDoshokuOrder
=
(
DoshokuOrder
)
mOrder
;
}
else
{
mOrder
=
TakeawayOrder
.
getInstance
();
mTakeawayOrder
=
(
TakeawayOrder
)
mOrder
;
}
mShoppingCart
=
mOrder
.
getShoppingCart
();
mOrderMealList
=
mShoppingCart
.
getOrderCommodityList
();
mBillItemList
=
mShoppingCart
.
getBillItemList
();
/****************************************************/
resetSelected
();
initOrderAdapter
();
initItemClickListener
();
...
...
@@ -158,6 +209,40 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
}
}
/**
* 更新賬單信息
* 1、更新食品折扣
* 2、更新服務費項
* 3、更新賬單折扣項{@link NomalDiscount}
* 4、更新賬單小數項
* 4、總金額
*/
protected
void
updateBillInfo
()
{
if
(!
containsTableService
())
{
addTableServiceAmount
();
}
updateBillItem
();
mShoppingCart
.
setTotalAmount
(
getTotalAmount
());
}
protected
void
updateBillItem
()
{
double
wholeAmount
=
getFoodTotal
();
double
discountableMoney
=
getDiscountableFoodTotal2
();
for
(
BillItem
item
:
mBillItemList
)
{
if
(
item
instanceof
ServiceChargeItem
)
{
//更新服務費項
((
ServiceChargeItem
)
item
).
updateBillItem
(
wholeAmount
,
mShoppingCart
.
getServiceCharge
());
}
else
if
(
item
instanceof
DiscountItem
)
{
//調用折扣鏈進行計算
mShoppingCart
.
calculateLinkedDiscounts
(
discountableMoney
);
}
else
if
(
item
instanceof
RoundingItem
)
{
//更新賬單小數項
((
RoundingItem
)
item
).
updateBillItem
(
wholeAmount
);
}
}
}
private
boolean
containsTableService
()
{
for
(
int
i
=
mOrderMoneyList
.
size
()
-
1
;
i
>=
0
;
i
--)
{
BillOrderMoney
billOrderMoney
=
mOrderMoneyList
.
get
(
i
);
...
...
@@ -511,7 +596,7 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
removeBillOrderItemByType
(
BillOrderMoney
.
ORDER_DISCOUNT_TYPE
);
double
totalMoney
=
getDiscountableFoodTotal
(
BillOrderMoney
.
ORDER_DISCOUNT_TYPE
,
true
);
double
discountPrice
=
Discount
.
calculationDiscount
(
discount
,
totalMoney
);
double
discountPrice
=
Order
Discount
.
calculationDiscount
(
discount
,
totalMoney
);
BillOrderMoney
orderMoney
=
new
BillOrderMoney
();
orderMoney
.
setMoney
(
discountPrice
);
orderMoney
.
setTitle
(
discount
.
getRemark
());
...
...
@@ -543,7 +628,7 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
BillOrderMoney
orderMoney
=
getBillOrderItemByType
(
BillOrderMoney
.
ORDER_DISCOUNT_TYPE
);
if
(
orderMoney
!=
null
)
{
double
totalMoney
=
getDiscountableFoodTotal
(
BillOrderMoney
.
ORDER_DISCOUNT_TYPE
,
false
);
double
discountPrice
=
Discount
.
calculationDiscount
(
orderMoney
.
getDiscount
(),
totalMoney
);
double
discountPrice
=
Order
Discount
.
calculationDiscount
(
orderMoney
.
getDiscount
(),
totalMoney
);
orderMoney
.
setMoney
(
discountPrice
);
}
}
...
...
@@ -564,7 +649,7 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
if
(!
TextUtils
.
isEmpty
(
levelName
))
{
memberName
=
memberName
+
"("
+
levelName
+
")"
;
}
double
discountPrice
=
Discount
.
calculationMemberDiscount
(
discountRate
,
totalMoney
);
double
discountPrice
=
Order
Discount
.
calculationMemberDiscount
(
discountRate
,
totalMoney
);
BillOrderMoney
orderMoney
=
new
BillOrderMoney
();
orderMoney
.
setMoney
(
discountPrice
);
orderMoney
.
setTitle
(
memberName
+
discountRate
+
"%"
);
...
...
@@ -591,7 +676,7 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
BillOrderMoney
orderMoney
=
getBillOrderItemByType
(
BillOrderMoney
.
MEMBER_DISCOUNT_TYPE
);
if
(
orderMoney
!=
null
)
{
double
totalMoney
=
getDiscountableFoodTotal
(
BillOrderMoney
.
MEMBER_DISCOUNT_TYPE
,
false
);
double
discountPrice
=
Discount
.
calculationDiscount
(
orderMoney
.
getDiscount
(),
totalMoney
);
double
discountPrice
=
Order
Discount
.
calculationDiscount
(
orderMoney
.
getDiscount
(),
totalMoney
);
orderMoney
.
setMoney
(
discountPrice
);
}
}
...
...
@@ -696,7 +781,7 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
OrderDetail
orderDetailsBean
=
orderDetailList
.
get
(
i
);
if
(
orderDetailsBean
.
getDiscount
()
!=
null
&&
orderDetailsBean
.
getType
()
==
DISCOUNT_TYPE
)
{
updateData
=
true
;
double
discountPrice
=
Discount
.
calculationDiscount
(
orderDetailsBean
.
getDiscount
(),
totalMoney
);
double
discountPrice
=
Order
Discount
.
calculationDiscount
(
orderDetailsBean
.
getDiscount
(),
totalMoney
);
//更新折扣金額
orderDetailsBean
.
setPrice
(-
discountPrice
);
break
;
...
...
@@ -842,6 +927,7 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
return
MoneyUtil
.
get_ItemDecimals_money
(
total
);
}
/**
* 獲取所有可折扣食品合計
*
...
...
@@ -927,6 +1013,37 @@ public abstract class BaseOrderPresenter<M extends BaseOrderContract.Model, V ex
return
MoneyUtil
.
get_ItemDecimals_money
(
total
);
}
public
double
getDiscountableFoodTotal2
()
{
double
total
=
0.0
;
int
orderSize
=
mOrderMealList
.
size
();
for
(
int
i
=
0
;
i
<
orderSize
;
i
++)
{
MealCommodity
food
=
(
MealCommodity
)
mOrderMealList
.
get
(
i
);
if
(
food
.
getNumber
()
==
0
)
{
continue
;
}
if
(
food
.
getItemType
()
==
1
)
{
if
(
food
.
getAblediscount
()
==
1
)
{
total
=
MoneyUtil
.
sum
(
total
,
food
.
getPrice
());
}
}
else
{
int
parentIndex
=
food
.
getParentIndex
()
-
1
;
MealCommodity
parentFood
=
(
MealCommodity
)
mOrderMealList
.
get
(
parentIndex
);
if
(
orderSize
>
parentIndex
&&
parentFood
.
getAblediscount
()
==
1
)
{
if
(
food
.
getType
()
==
MealCommodity
.
DISCOUNT_TYPE
)
{
//主食品参与折扣,折扣金额直接减掉
total
=
MoneyUtil
.
sub
(
total
,
Math
.
abs
(
food
.
getPrice
()));
}
else
{
//主食品可參與折扣 子食品才能參與折扣
if
(
food
.
getAblediscount
()
==
1
)
{
total
=
MoneyUtil
.
sum
(
total
,
food
.
getPrice
());
}
}
}
}
}
return
total
;
}
/**
* 獲取所有可服务费食品合計
*
...
...
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