Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
hf
9 years ago
Commit
da7adc44a7053301e128b691940303c50b504189
1 parent
de5c322d
code review by hf: fixes bug to add shopping to cart
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
View file @
da7adc4
...
...
@@ -34,7 +34,7 @@ class DetailModel
// 通过ID获取
if
(
is_numeric
(
$productId
)
&&
is_numeric
(
$goodsId
))
{
$baseInfo
=
DetailData
::
baseInfo
(
$productId
,
$uid
);
}
}
// 通过SKN获取
elseif
(
is_numeric
(
$productSkn
))
{
$baseInfo
=
DetailData
::
baseInfo
(
null
,
$uid
,
$productSkn
);
...
...
@@ -184,6 +184,7 @@ class DetailModel
}
// 商品的尺码列表
$colorStorageGroup
[
$value
[
'productSkc'
]]
=
array
();
if
(
isset
(
$value
[
'goodsSizeBoList'
]))
{
foreach
(
$value
[
'goodsSizeBoList'
]
as
$size
)
{
$sizeList
[
$value
[
'productSkc'
]][]
=
array
(
...
...
@@ -196,7 +197,7 @@ class DetailModel
);
$colorStorageNum
+=
intval
(
$size
[
'goodsSizeStorageNum'
]);
$sizeStorageStr
.=
$size
[
'goodsSizeStorageNum'
]
.
'/'
;
$colorStorageGroup
[
$
size
[
'sizeName'
]][
$value
[
'productSkc
'
]]
=
$size
[
'goodsSizeStorageNum'
];
$colorStorageGroup
[
$
value
[
'productSkc'
]][
$size
[
'sizeName
'
]]
=
$size
[
'goodsSizeStorageNum'
];
}
// 颜色分组
...
...
@@ -213,20 +214,28 @@ class DetailModel
// 缩略图
$thumbImageList
[]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$value
[
'colorImage'
],
60
,
60
));
// 添加尺码对应的各个颜色的库存量
foreach
(
$sizeList
as
$skc
=>
$sizeArr
)
{
foreach
(
$sizeArr
as
$key
=>
$value
)
{
$sizeList
[
$skc
][
$key
][
'colorNumStr'
]
=
implode
(
'/'
,
array_values
(
$colorStorageGroup
[
$value
[
'name'
]]));
}
}
// 商品库存总数
$totalStorageNum
+=
$colorStorageNum
;
}
// 遍历所有尺码,统计出该尺码的每个颜色的库存量,没有时添0,不能空着,因为JS中需要判断
foreach
(
$sizeList
as
$skc
=>
$sizeArr
)
{
foreach
(
$sizeArr
as
$key
=>
$value
)
{
$sizeStorageStr
=
''
;
foreach
(
$colorStorageGroup
as
$colorArr
)
{
if
(
isset
(
$colorArr
[
$value
[
'name'
]
]))
{
$sizeStorageStr
.=
$colorArr
[
$value
[
'name'
]
]
.
'/'
;
}
else
{
$sizeStorageStr
.=
'0/'
;
}
}
$sizeList
[
$skc
][
$key
][
'colorNumStr'
]
=
rtrim
(
$sizeStorageStr
,
'/'
);
}
}
// 格式化尺码对应的各个颜色分组
foreach
(
$colorGroup
as
$value
)
{
$sizeGroup
[][
'size'
]
=
$sizeList
[
$value
[
'skcId'
]
];
$sizeGroup
[][
'size'
]
=
$sizeList
[
$value
[
'skcId'
]
];
}
// 商品图: 多个
...
...
@@ -284,6 +293,13 @@ class DetailModel
$result
[
'introUrl'
]
=
Helpers
::
url
(
'/product/intro_'
.
$baseInfo
[
'erpProductId'
]
.
'/'
.
$baseInfo
[
'cnAlphabet'
]
.
'.html'
,
null
,
''
);
$result
[
'id'
]
=
$productId
;
// 清空变量,释放内存
$baseInfo
=
array
();
$goodsGroup
=
array
();
$sizeGroup
=
array
();
$colorGroup
=
array
();
$sizeList
=
array
();
return
$result
;
}
...
...
@@ -488,6 +504,9 @@ class DetailModel
);
}
}
// 清空变量,释放内存
$sizeInfo
=
array
();
}
return
$result
;
...
...
Please
register
or
login
to post a comment