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
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
1377 additions
and
49 deletions
+1377
-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
+431
-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
package
com
.
gingersoft
.
gsa
.
cloud
.
base
.
order
.
commodity
;
import
com.gingersoft.gsa.cloud.base.order.OrderItem
;
import
com.gingersoft.gsa.cloud.base.order.bean.OrderBean
;
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.Discount
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
/**
* @author : bin
* @create date: 2020-10-14
* @update date: 2020-10-14
* @description: 堂食食品
*/
@Getter
@Setter
@ToString
public
class
MealCommodity
extends
Commodity
implements
OrderItem
{
/**
* 是否选择
* 0 未选中
* 1 被选中但不是主体
* 2 作为主体被选中
* 3 由三级菜单进入选中全部
*/
private
int
selected
=
0
;
//是否食品
private
boolean
isIsfood
=
true
;
//父級下標
private
int
parentIndex
=
0
;
//自身下標
private
int
myIndex
=
0
;
//是否是新添加的食品(未送單)
private
boolean
isNew
=
true
;
//是否顯示
private
boolean
visible
=
true
;
//新点后是否自动展开
private
int
autoMod
=
0
;
//作用于套餐下子食品的限制数量
private
int
limitQty
=
0
;
//折扣比例
private
double
PERCENTAGE
=
0.00
;
//套餐编號
private
long
comid
;
//細項編號
private
long
mid
;
//修改数量前的数量
private
int
changeBeforeQty
=
0
;
//当前食品是否有子项
private
boolean
hasChild
=
false
;
//背景色
private
int
bgColor
;
//字體色
private
int
fontColor
;
//是否组合商品 1-组合商品 2-组合商品的子商品
private
int
ComboLevel
=
0
;
//套餐食品是否自動跟餐
private
boolean
isComboAuto
=
false
;
/**
* 動態的最大選中數
*/
private
String
currentMaxNumber
=
""
;
/**
* 删除食品相关
*/
//该食品是否修改过
private
boolean
isModify
=
false
;
//修改食品前的数量
private
int
modifyBeforeNumber
=
0
;
//取消食品备注
private
String
cancelReason
;
//取消食品原因ID
private
int
reasonId
;
//取消食品数量
private
int
cancelNumber
;
//"food" or "discount" or "modifiy"
private
int
prop
=
FOOD_PROP
;
/**
* 訂單Item類型
* 1:主食品
* 2:套餐
* 3:細項
* 4:折扣
*/
public
static
final
byte
FOOD_PROP
=
1
;
public
static
final
byte
COMBO_PROP
=
2
;
public
static
final
byte
MODIFIER_PROP
=
3
;
public
static
final
byte
DISCOUNT_PROP
=
4
;
/***
* 層級
* 1:主食品
* 2:子項or細項
* 3:細項
*/
private
int
itemType
;
/**
* 父级ID
*/
private
long
parentId
;
/**
* 订单ID
*/
private
long
orderId
;
/**
* 商品id
*/
private
long
productId
;
/**
* 商品名称
*/
private
String
productName
;
/**
* 父级商品ID
*/
private
long
parentProductId
;
/**
* 商品組id
*/
private
long
topId
;
/**
* 單價
*/
private
double
unit_price
=
0
;
/**
* 餐盒費
*/
private
double
lunchboxPrice
;
/**
* 細項價格
*/
private
double
itemsPrice
;
/**
* 數量
*/
private
int
number
;
/**
* 已經使用優惠卷卷號列表逗號分割
*/
private
String
userCouponNo
;
// /**
// * 类型#1:优惠卷;2:商品;3:菜品;4:细项;5:折扣;
// */
// private byte type;
/**
*
*/
private
String
qmUseData
;
/**
* 备注
*/
private
String
remark
;
/**
* 细项(食品种类#食品id#详细分类ID#详细ID#名称#单价#位置索引#数量#细项总价格#posFid)
*/
private
String
items
;
/**
* 創建時間
*/
private
Date
createTime
=
new
Date
();
/**
* 打印設定, 用逗號分隔, *=切紙
*/
private
String
printSeting
;
/**
* 是否参与折扣#0:不參與;1:參與;
*/
private
long
ablediscount
=
1
;
/**
* 折扣實體
*/
private
Discount
discount
;
/**
* 折扣狀態#0:沒有折扣;1:折扣未送單;2:折扣已送單;
*/
private
int
discountStatus
;
/**
* 是否参与折扣#0:不參與;1:參與;
**/
private
byte
scAble
=
1
;
/**
* 額外食品加分
*/
private
double
pointsAdd
;
/**
* 換購食品所需積分
*/
private
double
pointsRedeem
;
/**
* 食品組
*/
private
String
ftName
;
/**
* 自定義組
*/
private
String
majorName
;
/**
* 状态#0:正常;1:删除;
*/
private
Byte
status
=
STATUS_NORMAL
;
/**
* 状态#0:正常;1:删除;
*/
public
static
final
byte
STATUS_NORMAL
=
0
;
public
static
final
byte
STATUS_DELETE
=
1
;
/**
* type編號#3:菜品;4:細項;5:折扣
*/
public
static
final
byte
FOOD_TYPE
=
3
;
public
static
final
byte
MODIFIER_TYPE
=
4
;
public
static
final
byte
DISCOUNT_TYPE
=
5
;
/**
* 廚房單打印主項
*/
private
long
ktPrintMainItem
;
/**
* 0=系統顏色, 1=黑色, 2=紅色
*/
private
long
printFont
;
/**
* 當金額=0時, 是否打印在帳單上
*/
private
long
printToBill
;
/**
* 0食品清单打印 账单打印//1食品清单不打印 账单不打印//2食品清单打印 账单不打印//3食品清单不打印 账单打印
*/
private
long
printTo
;
/**
* 是否打印价格
*/
private
long
ktShowPrice
;
/**
* 此食品是否包含折扣
*
* @param mealCommodityList
* @param start_position
* @param end_position
* @return
*/
public
static
boolean
hasFoodDiscount
(
List
<
MealCommodity
>
mealCommodityList
,
int
start_position
,
int
end_position
)
{
boolean
hasDiscount
=
false
;
if
(
start_position
==
0
&&
end_position
==
0
)
{
return
hasDiscount
;
}
for
(
int
i
=
mealCommodityList
.
size
()
-
1
;
i
>=
0
;
i
--)
{
if
(
start_position
<=
i
&&
i
<=
end_position
)
{
MealCommodity
mealCommodity
=
mealCommodityList
.
get
(
i
);
//添加折扣實體
if
(
mealCommodity
.
getType
()
==
MealCommodity
.
DISCOUNT_TYPE
)
{
hasDiscount
=
true
;
break
;
}
}
}
return
hasDiscount
;
}
/**
* 已送單食品轉換
*
* @param orderList
* @return
*/
public
static
List
<
Commodity
>
orderTransMealCommoditys
(
List
<
OrderBean
.
OrderDetailsBean
>
orderList
)
{
List
<
Commodity
>
mealCommodityList
=
new
ArrayList
<>();
MealCommodity
parentMealCommodity
=
null
;
long
parentId
=
0
;
//每個套餐食品折扣總額
double
discountSourcePrice
=
0
;
//已到結尾或者下一個食品是主食品
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
OrderBean
.
OrderDetailsBean
mealCommoditysBean
=
orderList
.
get
(
i
);
MealCommodity
mealCommodity
=
new
MealCommodity
();
mealCommodity
.
setOrderId
(
mealCommoditysBean
.
getOrderId
());
mealCommodity
.
setId
(
mealCommoditysBean
.
getId
());
mealCommodity
.
setProductId
(
mealCommoditysBean
.
getProductId
());
mealCommodity
.
setParentId
(
mealCommoditysBean
.
getParentId
());
mealCommodity
.
setTopId
(
mealCommoditysBean
.
getTopId
());
mealCommodity
.
setProductName
(
mealCommoditysBean
.
getProductName
());
mealCommodity
.
setNumber
(
mealCommoditysBean
.
getNumber
());
mealCommodity
.
setUnit_price
(
mealCommoditysBean
.
getPrice
());
mealCommodity
.
setPrice
(
mealCommoditysBean
.
getPrice
()
*
mealCommoditysBean
.
getNumber
());
mealCommodity
.
setVisible
(
mealCommoditysBean
.
getStatus
()
==
0
);
mealCommodity
.
setPrintSeting
(
mealCommoditysBean
.
getPrintSetIng
());
// mealCommodity.setAutomod(foods.getAutomod());
mealCommodity
.
setKtPrintMainItem
(
mealCommoditysBean
.
getKtPrintMainItem
());
mealCommodity
.
setPrintFont
(
mealCommoditysBean
.
getPrintFont
());
mealCommodity
.
setPrintToBill
(
mealCommoditysBean
.
getPrintToBill
());
mealCommodity
.
setPrintTo
(
mealCommoditysBean
.
getPrintTo
());
mealCommodity
.
setKtShowPrice
(
mealCommoditysBean
.
getKtShowPrice
());
mealCommodity
.
setAblediscount
(
mealCommoditysBean
.
getAblediscount
());
mealCommodity
.
setIsfood
(
mealCommoditysBean
.
getType
()
==
FOOD_TYPE
);
mealCommodity
.
setNew
(
false
);
mealCommodity
.
setType
(
mealCommoditysBean
.
getType
());
mealCommodity
.
setItemType
(
getItemType
(
mealCommoditysBean
,
parentMealCommodity
));
mealCommodity
.
setAblediscount
(
mealCommoditysBean
.
getAblediscount
());
mealCommodity
.
setScAble
(
mealCommoditysBean
.
getScAble
());
mealCommodity
.
setPointsAdd
(
mealCommoditysBean
.
getPointsAdd
());
mealCommodity
.
setPointsRedeem
(
mealCommoditysBean
.
getPointsRedeem
());
mealCommodityList
.
add
(
mealCommodity
);
// if (mealCommodity.isIsfood()) {
// parentMealCommodity = null;
// }
if
(
mealCommodity
.
getItemType
()
==
1
)
{
parentId
=
mealCommodity
.
getId
();
discountSourcePrice
=
0
;
}
if
(
mealCommoditysBean
.
getRestaurantDiscountVO
()
!=
null
)
{
//累加折扣總額
discountSourcePrice
=
MoneyUtil
.
sum
(
discountSourcePrice
,
mealCommodity
.
getPrice
());
//食品折扣狀態為已送單
mealCommodity
.
setDiscountStatus
(
2
);
//往下找
int
nextIndex
=
i
+
1
;
if
(
orderList
.
size
()
==
nextIndex
||
orderList
.
get
(
nextIndex
).
getParentId
()
==
0
)
{
//已到結尾或者下一個食品是主食品
Discount
discount
=
getDiscountItem
(
mealCommoditysBean
.
getRestaurantDiscountVO
());
if
(
discount
!=
null
)
{
mealCommodityList
.
add
(
discountTransMealCommodity
(
discount
,
false
,
parentId
,
discountSourcePrice
));
}
}
}
else
{
mealCommodity
.
setDiscountStatus
(
0
);
}
if
(
mealCommodity
.
isIsfood
())
{
parentMealCommodity
=
mealCommodity
;
}
}
return
mealCommodityList
;
}
//PLU可输入子项
//食品数量支持小数 例如1.25
private
static
Discount
getDiscountItem
(
OrderBean
.
OrderDetailsBean
.
RestaurantDiscountVO
discountBean
)
{
Discount
discount
=
new
Discount
();
discount
.
setId
(
discountBean
.
getId
());
discount
.
setDiscount_value
(
discountBean
.
getDiscountValue
());
discount
.
setAmount
(
discountBean
.
getDiscountAmount
());
discount
.
setType
(
discountBean
.
getType
());
discount
.
setRemark
(
discountBean
.
getRemark
());
return
discount
;
}
public
static
int
getItemType
(
OrderBean
.
OrderDetailsBean
mealCommoditysBean
,
MealCommodity
parentMealCommodity
)
{
if
(
mealCommoditysBean
!=
null
)
{
if
(
mealCommoditysBean
.
getParentId
()
==
0
)
{
return
1
;
}
if
(
mealCommoditysBean
.
getParentId
()
!=
0
&&
mealCommoditysBean
.
getType
()
==
FOOD_TYPE
)
{
return
2
;
}
if
(
mealCommoditysBean
.
getParentId
()
!=
0
&&
mealCommoditysBean
.
getType
()
==
DISCOUNT_TYPE
)
{
return
2
;
}
if
(
parentMealCommodity
!=
null
&&
mealCommoditysBean
.
getParentId
()
!=
0
)
{
if
(
parentMealCommodity
.
getId
()
==
mealCommoditysBean
.
getParentId
())
{
//是父級
if
(
parentMealCommodity
.
getParentId
()
==
0
&&
mealCommoditysBean
.
getType
()
==
FOOD_TYPE
)
{
//第二層子食品
return
2
;
}
if
(
parentMealCommodity
.
getParentId
()
==
0
&&
mealCommoditysBean
.
getType
()
==
DISCOUNT_TYPE
)
{
//第二層子食品
return
2
;
}
if
(
parentMealCommodity
.
getParentId
()
!=
0
&&
mealCommoditysBean
.
getType
()
==
MODIFIER_TYPE
)
{
//第三層細項
return
3
;
}
}
return
3
;
}
}
return
1
;
}
/**
* 折扣轉換
*
* @param discount
* @return
*/
public
static
MealCommodity
discountTransMealCommodity
(
Discount
discount
,
boolean
isNew
,
long
id
,
double
sourcePrice
)
{
double
discountPrice
=
OrderDiscount
.
calculationDiscount
(
discount
,
sourcePrice
);
MealCommodity
mealCommodity
=
new
MealCommodity
();
mealCommodity
.
setProductName
(
discount
.
getRemark
());
mealCommodity
.
setId
(
discount
.
getId
());
mealCommodity
.
setTopId
(
id
);
mealCommodity
.
setParentId
(
id
);
mealCommodity
.
setProductId
(
discount
.
getId
());
mealCommodity
.
setNumber
(
1
);
mealCommodity
.
setPrice
(
discountPrice
);
mealCommodity
.
setUnit_price
(
discountPrice
);
mealCommodity
.
setOrderId
(
MyOrderManage
.
getInstance
().
getOrderId
());
mealCommodity
.
setIsfood
(
false
);
mealCommodity
.
setNew
(
isNew
);
mealCommodity
.
setType
(
DISCOUNT_TYPE
);
mealCommodity
.
setProp
(
DISCOUNT_PROP
);
mealCommodity
.
setSelected
(
2
);
mealCommodity
.
setItemType
(
2
);
mealCommodity
.
setDiscount
(
discount
);
return
mealCommodity
;
}
}
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