Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
machine
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hooloo
android
machine
Commits
0f8ff26c
Commit
0f8ff26c
authored
Jun 06, 2022
by
wjg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改购物车数据格式
parent
235a6e22
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
44 deletions
+73
-44
app/src/main/java/com/ihaoin/hooloo/device/config/AppConfig.java
+5
-4
app/src/main/java/com/ihaoin/hooloo/device/view/GoodsDetailDialog.java
+65
-38
app/src/main/java/com/ihaoin/hooloo/device/view/SettingsActivity.java
+1
-1
app/src/main/java/com/ihaoin/hooloo/device/view/TrolleyView.java
+1
-1
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/com/ihaoin/hooloo/device/config/AppConfig.java
View file @
0f8ff26c
...
...
@@ -3,12 +3,13 @@ package com.ihaoin.hooloo.device.config;
public
class
AppConfig
{
public
static
Boolean
DEBUG
=
true
;
// TODO false
public
static
String
TAG
=
"HL_TEST"
;
public
static
String
TAG_PUSH
=
TAG
+
"_PUSH"
;
public
static
String
TAG_NETWORK
=
TAG
+
"_NETWORK"
;
public
static
String
HL
=
"HL"
;
public
static
String
TAG
=
HL
+
"_TEST"
;
public
static
String
TAG_PUSH
=
HL
+
"_PUSH"
;
public
static
String
TAG_NETWORK
=
HL
+
"_NETWORK"
;
/** 点单屏编码 */
public
static
String
DEFAULT_SCREEN_NO
=
"
A
"
;
public
static
String
DEFAULT_SCREEN_NO
=
"
1
"
;
/** 机器编码 */
public
static
String
MACHINE_CODE
=
""
;
/** 打开微信网址 */
...
...
app/src/main/java/com/ihaoin/hooloo/device/view/GoodsDetailDialog.java
View file @
0f8ff26c
...
...
@@ -23,12 +23,14 @@ import androidx.viewpager.widget.ViewPager;
import
com.ihaoin.hooloo.device.HLApplication
;
import
com.ihaoin.hooloo.device.R
;
import
com.ihaoin.hooloo.device.component.IntroViewPager
;
import
com.ihaoin.hooloo.device.component.NetworkHandler
;
import
com.ihaoin.hooloo.device.config.Base
;
import
com.ihaoin.hooloo.device.data.enums.SkuState
;
import
com.ihaoin.hooloo.device.data.vo.Goods
;
import
com.ihaoin.hooloo.device.data.vo.GoodsRule
;
import
com.ihaoin.hooloo.device.data.vo.Sku
;
import
com.ihaoin.hooloo.device.data.vo.SkuRule
;
import
com.ihaoin.hooloo.device.network.HttpUtil
;
import
com.ihaoin.hooloo.device.util.CollectionUtils
;
import
com.ihaoin.hooloo.device.util.StringUtils
;
import
com.ihaoin.hooloo.device.util.Utils
;
...
...
@@ -40,8 +42,10 @@ import java.util.Map;
import
java.util.stream.Collectors
;
public
class
GoodsDetailDialog
extends
Dialog
{
private
Goods
goods
;
private
Sku
checkSku
;
private
Goods
mGoods
;
private
Sku
mSku
;
private
Integer
mCount
=
1
;
private
View
butnClose
;
private
IntroViewPager
introPager
;
private
RadioGroup
introIndicator
;
...
...
@@ -60,12 +64,11 @@ public class GoodsDetailDialog extends Dialog {
private
View
layoutButns
;
private
View
txtSellout
;
private
Integer
count
=
1
;
private
List
<
View
>
introViews
;
public
GoodsDetailDialog
(
@NonNull
Context
context
,
Goods
goods
)
{
super
(
context
);
this
.
g
oods
=
goods
;
this
.
mG
oods
=
goods
;
}
@Override
...
...
@@ -97,9 +100,9 @@ public class GoodsDetailDialog extends Dialog {
butnClose
.
setOnClickListener
(
x
->
dismiss
());
introViews
=
new
ArrayList
<>();
if
(
goods
.
getPics
()
!=
null
&&
!
CollectionUtils
.
isEmpty
(
g
oods
.
getPics
().
getIntroImages
()))
{
for
(
int
i
=
0
;
i
<
g
oods
.
getPics
().
getIntroImages
().
size
();
i
++)
{
String
url
=
g
oods
.
getPics
().
getIntroImages
().
get
(
i
);
if
(
mGoods
.
getPics
()
!=
null
&&
!
CollectionUtils
.
isEmpty
(
mG
oods
.
getPics
().
getIntroImages
()))
{
for
(
int
i
=
0
;
i
<
mG
oods
.
getPics
().
getIntroImages
().
size
();
i
++)
{
String
url
=
mG
oods
.
getPics
().
getIntroImages
().
get
(
i
);
View
imgIntro
=
getIntroImage
(
url
);
View
btnIntro
=
getIntroButton
(
i
);
introViews
.
add
(
imgIntro
);
...
...
@@ -130,9 +133,9 @@ public class GoodsDetailDialog extends Dialog {
}
}
txtName
.
setText
(
g
oods
.
getName
());
txtPrice
.
setText
(
Utils
.
toString
(
g
oods
.
getPrice
()));
txtDiscount
.
setText
(
Utils
.
toString
(
g
oods
.
getDiscount
()));
txtName
.
setText
(
mG
oods
.
getName
());
txtPrice
.
setText
(
Utils
.
toString
(
mG
oods
.
getPrice
()));
txtDiscount
.
setText
(
Utils
.
toString
(
mG
oods
.
getDiscount
()));
butnSubtract
.
setOnClickListener
(
v
->
subtractGoods
());
butnAdd
.
setOnClickListener
(
v
->
addGoods
());
...
...
@@ -231,46 +234,70 @@ public class GoodsDetailDialog extends Dialog {
return
imgIntro
;
}
class
CheckGoodsHandler
extends
NetworkHandler
{
private
Goods
goods
;
private
Sku
sku
;
private
Integer
count
;
public
CheckGoodsHandler
(
Goods
goods
,
Sku
sku
,
Integer
count
)
{
super
();
this
.
goods
=
goods
;
this
.
sku
=
sku
;
this
.
count
=
count
;
}
@Override
public
void
handleMessage
(
@NonNull
Message
msg
)
{
super
.
handleMessage
(
msg
);
if
(
msg
.
what
!=
1
)
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
error_check_sku
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
Utils
.
showConfirmOrder
(
getContext
(),
goods
,
sku
,
count
);
dismiss
();
}
}
private
void
buyNow
()
{
if
(
check
Sku
==
null
)
{
if
(
m
Sku
==
null
)
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
not_found_goods
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
Utils
.
showConfirmOrder
(
getContext
(),
goods
,
checkSku
,
c
ount
);
dismiss
(
);
CheckGoodsHandler
handler
=
new
CheckGoodsHandler
(
mGoods
,
mSku
,
mC
ount
);
HttpUtil
.
checkSku
(
mSku
.
getSkuId
(),
handler
);
}
private
void
addTrolley
()
{
if
(
check
Sku
==
null
)
{
if
(
m
Sku
==
null
)
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
not_found_goods
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
Utils
.
sendAddGoodsBroadcast
(
getContext
(),
goods
,
checkSku
,
c
ount
);
Utils
.
sendAddGoodsBroadcast
(
getContext
(),
mGoods
,
mSku
,
mC
ount
);
dismiss
();
}
private
void
addGoods
()
{
if
(
c
ount
>=
HLApplication
.
getMainData
().
getCountOfOrder
())
{
if
(
mC
ount
>=
HLApplication
.
getMainData
().
getCountOfOrder
())
{
Toast
.
makeText
(
this
.
getContext
(),
getContext
().
getString
(
R
.
string
.
count_limit
,
HLApplication
.
getMainData
().
getCountOfOrder
().
toString
()),
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
c
ount
++;
txtCount
.
setText
(
String
.
valueOf
(
c
ount
));
mC
ount
++;
txtCount
.
setText
(
String
.
valueOf
(
mC
ount
));
}
private
void
subtractGoods
()
{
if
(
c
ount
<=
1
)
{
if
(
mC
ount
<=
1
)
{
return
;
}
c
ount
--;
txtCount
.
setText
(
String
.
valueOf
(
c
ount
));
mC
ount
--;
txtCount
.
setText
(
String
.
valueOf
(
mC
ount
));
}
private
void
buildSpecs
()
{
if
(
CollectionUtils
.
isEmpty
(
g
oods
.
getSpecs
()))
{
if
(
CollectionUtils
.
isEmpty
(
mG
oods
.
getSpecs
()))
{
return
;
}
g
oods
.
getSpecs
().
forEach
(
spec
->
{
mG
oods
.
getSpecs
().
forEach
(
spec
->
{
if
(
CollectionUtils
.
isEmpty
(
spec
.
getRules
()))
{
return
;
}
...
...
@@ -341,13 +368,13 @@ public class GoodsDetailDialog extends Dialog {
}
rules
.
add
((
GoodsRule
)
view
.
getTag
());
}
check
Sku
=
matchSku
(
rules
);
if
(
check
Sku
==
null
)
{
m
Sku
=
matchSku
(
rules
);
if
(
m
Sku
==
null
)
{
// Toast.makeText(getContext(), R.string.not_found_goods, Toast.LENGTH_SHORT).show();
return
;
}
txtPrice
.
setText
(
Utils
.
toString
(
check
Sku
.
getPrice
()));
txtDiscount
.
setText
(
Utils
.
toString
(
check
Sku
.
getDiscount
()));
txtPrice
.
setText
(
Utils
.
toString
(
m
Sku
.
getPrice
()));
txtDiscount
.
setText
(
Utils
.
toString
(
m
Sku
.
getDiscount
()));
}
private
View
getSelectedView
(
LinearLayout
layoutRules
)
{
...
...
@@ -367,11 +394,11 @@ public class GoodsDetailDialog extends Dialog {
if
(
CollectionUtils
.
isEmpty
(
rules
))
{
return
null
;
}
if
(
CollectionUtils
.
isEmpty
(
g
oods
.
getSkus
()))
{
if
(
CollectionUtils
.
isEmpty
(
mG
oods
.
getSkus
()))
{
return
null
;
}
List
<
Integer
>
checkRuleIds
=
rules
.
stream
().
map
(
GoodsRule:
:
getRuleId
).
sorted
().
collect
(
Collectors
.
toList
());
for
(
Sku
sku
:
g
oods
.
getSkus
())
{
for
(
Sku
sku
:
mG
oods
.
getSkus
())
{
List
<
Integer
>
skuRuleIds
=
sku
.
getRules
().
stream
().
map
(
SkuRule:
:
getRuleId
).
sorted
().
collect
(
Collectors
.
toList
());
if
(
skuRuleIds
.
toString
().
equals
(
checkRuleIds
.
toString
()))
{
return
sku
;
...
...
@@ -381,29 +408,29 @@ public class GoodsDetailDialog extends Dialog {
}
private
void
buildDetails
()
{
if
(
goods
.
getPics
()
==
null
||
CollectionUtils
.
isEmpty
(
g
oods
.
getPics
().
getDetailImages
()))
{
if
(
mGoods
.
getPics
()
==
null
||
CollectionUtils
.
isEmpty
(
mG
oods
.
getPics
().
getDetailImages
()))
{
return
;
}
g
oods
.
getPics
().
getDetailImages
().
forEach
(
url
->
{
mG
oods
.
getPics
().
getDetailImages
().
forEach
(
url
->
{
if
(
StringUtils
.
isEmpty
(
url
))
{
return
;
}
ImageView
imageView
=
new
ImageView
(
getContext
());
imageView
.
setAdjustViewBounds
(
true
);
LinearLayout
.
LayoutParams
layoutParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
layoutParams
.
bottomMargin
=
Utils
.
getDimens
(
getContext
(),
R
.
dimen
.
padding5
);
//
layoutParams.bottomMargin = Utils.getDimens(getContext(), R.dimen.padding5);
Utils
.
getGlide
(
getContext
()).
load
(
url
).
into
(
imageView
);
layoutImages
.
addView
(
imageView
,
layoutParams
);
});
}
private
void
processSpecRules
()
{
if
(
goods
==
null
||
CollectionUtils
.
isEmpty
(
goods
.
getSpecs
())
||
CollectionUtils
.
isEmpty
(
g
oods
.
getSkus
()))
{
if
(
mGoods
==
null
||
CollectionUtils
.
isEmpty
(
mGoods
.
getSpecs
())
||
CollectionUtils
.
isEmpty
(
mG
oods
.
getSkus
()))
{
showSelloutViews
();
return
;
}
// 将商品所有SKU列表按售罄和未售罄分组
Map
<
Integer
,
List
<
Sku
>>
map
=
g
oods
.
getSkus
().
stream
().
collect
(
Collectors
.
groupingBy
(
Sku:
:
getState
));
Map
<
Integer
,
List
<
Sku
>>
map
=
mG
oods
.
getSkus
().
stream
().
collect
(
Collectors
.
groupingBy
(
Sku:
:
getState
));
if
(
CollectionUtils
.
isEmpty
(
map
))
{
return
;
}
...
...
@@ -452,10 +479,10 @@ public class GoodsDetailDialog extends Dialog {
/** 设备商品规格 选项状态 */
private
void
setRuleState
(
SkuRule
skuRule
,
Integer
ruleState
)
{
if
(
goods
==
null
||
CollectionUtils
.
isEmpty
(
g
oods
.
getSpecs
()))
{
if
(
mGoods
==
null
||
CollectionUtils
.
isEmpty
(
mG
oods
.
getSpecs
()))
{
return
;
}
g
oods
.
getSpecs
().
forEach
(
spec
->
{
mG
oods
.
getSpecs
().
forEach
(
spec
->
{
// 选项为空的规格不处理
if
(
CollectionUtils
.
isEmpty
(
spec
.
getRules
()))
{
return
;
...
...
@@ -477,10 +504,10 @@ public class GoodsDetailDialog extends Dialog {
}
private
void
setAllRuleSellouts
()
{
if
(
goods
==
null
||
CollectionUtils
.
isEmpty
(
g
oods
.
getSpecs
()))
{
if
(
mGoods
==
null
||
CollectionUtils
.
isEmpty
(
mG
oods
.
getSpecs
()))
{
return
;
}
g
oods
.
getSpecs
().
forEach
(
spec
->
{
mG
oods
.
getSpecs
().
forEach
(
spec
->
{
if
(
CollectionUtils
.
isEmpty
(
spec
.
getRules
()))
{
return
;
}
...
...
app/src/main/java/com/ihaoin/hooloo/device/view/SettingsActivity.java
View file @
0f8ff26c
...
...
@@ -72,7 +72,7 @@ public class SettingsActivity extends Activity {
private
void
showEditScreen
()
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
builder
.
setTitle
(
"修改点单屏编码"
);
String
[]
items
=
new
String
[]{
"
A"
,
"B
"
};
String
[]
items
=
new
String
[]{
"
1"
,
"2
"
};
builder
.
setSingleChoiceItems
(
items
,
StringUtils
.
indexOf
(
items
,
SharedPreferencesUtils
.
getScreenNo
(
SettingsActivity
.
this
)),
(
dialog
,
which
)
->
{
SharedPreferencesUtils
.
setScreenNo
(
SettingsActivity
.
this
,
items
[
which
]);
txtScreenNo
.
setText
(
SharedPreferencesUtils
.
getScreenNo
(
SettingsActivity
.
this
));
...
...
app/src/main/java/com/ihaoin/hooloo/device/view/TrolleyView.java
View file @
0f8ff26c
...
...
@@ -94,7 +94,7 @@ public class TrolleyView extends RelativeLayout {
public
void
handleMessage
(
@NonNull
Message
msg
)
{
super
.
handleMessage
(
msg
);
if
(
msg
.
what
!=
1
)
{
Toast
.
makeText
(
getContext
(),
((
Exception
)
msg
.
obj
).
getMessage
()
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getContext
(),
R
.
string
.
error_check_sku
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
addGoods
(
goods
,
sku
,
count
);
...
...
app/src/main/res/values/strings.xml
View file @
0f8ff26c
...
...
@@ -10,4 +10,5 @@
<string
name=
"error_price"
>
商品金额错误
</string>
<string
name=
"error_sku_state"
>
本商品已售罄或已经下架
</string>
<string
name=
"error_load_main_data"
>
获取数据失败
</string>
<string
name=
"error_check_sku"
>
商品状态获取失败
</string>
</resources>
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