Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
c0843d75
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
18
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c0843d75
编写于
10月 18, 2016
作者:
R
root
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
product tier price
上级
26018cfd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
164 addition
and
6 deletion
+164
-6
app/appadmin/modules/Catalog/block/productinfo/Manageredit.php
...ppadmin/modules/Catalog/block/productinfo/Manageredit.php
+26
-0
app/appadmin/modules/Catalog/views/productinfo/manageredit.php
...ppadmin/modules/Catalog/views/productinfo/manageredit.php
+90
-1
app/appfront/modules/Catalog/block/category/Index.php
app/appfront/modules/Catalog/block/category/Index.php
+2
-2
services/product/Price.php
services/product/Price.php
+46
-3
未找到文件。
app/appadmin/modules/Catalog/block/productinfo/Manageredit.php
浏览文件 @
c0843d75
...
...
@@ -49,6 +49,7 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdi
return
[
'baseInfo'
=>
$this
->
getBaseInfo
(),
'priceInfo'
=>
$this
->
getPriceInfo
(),
'tier_price'
=>
$this
->
_one
[
'tier_price'
],
'metaInfo'
=>
$this
->
getMetaInfo
(),
'groupAttr'
=>
$this
->
getGroupAttr
(),
'descriptionInfo'
=>
$this
->
getDescriptionInfo
(),
...
...
@@ -81,6 +82,8 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdi
return
$this
->
_lang_attr
.
$editBar
.
$this
->
_textareas
;
}
public
function
getMetaInfo
(){
$this
->
_lang_attr
=
''
;
$this
->
_textareas
=
''
;
...
...
@@ -345,6 +348,29 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdi
}
$this
->
_param
[
'custom_option'
]
=
$custom_option_af
;
}
#tier price
$tier_price
=
$this
->
_param
[
'tier_price'
];
$tier_price_arr
=
[];
if
(
$tier_price
){
$arr
=
explode
(
'||'
,
$tier_price
);
if
(
is_array
(
$arr
)
&&
!
empty
(
$arr
)){
foreach
(
$arr
as
$ar
){
list
(
$tier_qty
,
$tier_price
)
=
explode
(
'##'
,
$ar
);
if
(
$tier_qty
&&
$tier_price
){
$tier_qty
=
(
int
)
$tier_qty
;
$tier_price
=
(
float
)
$tier_price
;
$tier_price_arr
[]
=
[
'qty'
=>
$tier_qty
,
'price'
=>
$tier_price
,
];
}
}
}
}
$tier_price_arr
=
\
fec\helpers\CFunc
::
array_sort
(
$tier_price_arr
,
'qty'
,
'asc'
);
$this
->
_param
[
'tier_price'
]
=
$tier_price_arr
;
}
# 批量删除
...
...
app/appadmin/modules/Catalog/views/productinfo/manageredit.php
浏览文件 @
c0843d75
...
...
@@ -23,6 +23,29 @@ use fecadmin\models\AdminRole;
.edit_p
label
{
float
:
left
;
line-height
:
20px
;
min-width
:
110px
;}
.edit_p
input
{
width
:
700px
;}
.tabsContent
.tabsContent
.edit_p
label
{
min-width
:
104px
;}
.edit_p
.tier_price
input
{
width
:
100px
;
}
.tier_price
table
thead
tr
th
{
background
:
#ddd
none
repeat
scroll
0
0
;
border
:
1px
solid
#ccc
;
padding
:
4px
10px
;
width
:
100px
;
}
.tier_price
table
tbody
tr
td
{
background
:
#fff
;
border-right
:
1px
solid
#ccc
;
border-bottom
:
1px
solid
#ccc
;
padding
:
3px
;
width
:
100px
;
}
.edit_p
.tier_price
input
.tier_qty
{
width
:
30px
;}
</style>
<script>
...
...
@@ -140,6 +163,8 @@ function thissubmit(thiss){
cate_str
+=
cate_id
+
"
,
"
;
});
jQuery
(
"
.category_tree div.ckbox.indeterminate
"
).
each
(
function
(){
cate_id
=
jQuery
(
this
).
find
(
"
input
"
).
val
();
cate_str
+=
cate_id
+
"
,
"
;
...
...
@@ -147,7 +172,17 @@ function thissubmit(thiss){
jQuery
(
"
.inputcategory
"
).
val
(
cate_str
);
tier_price_str
=
""
;
$
(
"
.tier_price table tbody tr
"
).
each
(
function
(){
tier_qty
=
$
(
this
).
find
(
"
.tier_qty
"
).
val
();
tier_price
=
$
(
this
).
find
(
"
.tier_price
"
).
val
();
if
(
tier_qty
&&
tier_price
){
tier_price_str
+=
tier_qty
+
'
##
'
+
tier_price
+
"
||
"
;
}
});
//alert(tier_price_str);
jQuery
(
"
.tier_price_input
"
).
val
(
tier_price_str
);
//alert($(".tier_price_input").val());
return
validateCallback
(
thiss
,
dialogAjaxDoneCloseAndReflush
);
}
</script>
...
...
@@ -187,6 +222,60 @@ function thissubmit(thiss){
</div>
<div>
<?=
$priceInfo
?>
<div
class=
"edit_p"
>
<label>
Tier Price:
</label>
<input
type=
"hidden"
name=
"editFormData[tier_price]"
class=
"tier_price_input"
/>
<div
class=
"tier_price"
style=
"float:left;width:700px;"
>
<table
style=
""
>
<thead>
<tr>
<th>
Qty
</th>
<th>
Price
</th>
<th>
Action
</th>
</tr>
</thead>
<tbody>
<?php
if
(
is_array
(
$tier_price
)
&&
!
empty
(
$tier_price
)){
?>
<?php
foreach
(
$tier_price
as
$one
){
?>
<tr>
<td>
<input
class=
"tier_qty"
type=
"text"
value=
"
<?=
$one
[
'qty'
]
?>
"
>
and above
</td>
<td>
<input
class=
"tier_price"
type=
"text"
value=
"
<?=
$one
[
'price'
]
?>
"
>
</td>
<td>
<img
src=
"
<?=
\
Yii
::
$service
->
image
->
getImgUrl
(
'/images/bkg_btn-close2.gif'
)
?>
"
>
</td>
</tr>
<?php
}
?>
<?php
}
?>
</tbody>
<tfoot
style=
"text-align:right;"
>
<tr>
<td
colspan=
"100"
style=
"text-align:right;"
>
<a
rel=
"2"
style=
"text-align:right;"
href=
"javascript:void(0)"
class=
"addProductTierPrice button"
>
<span>
增加TierPrice
</span>
</a>
</td>
</tr>
</tfoot>
</table>
<script>
$
(
document
).
ready
(
function
(){
$
(
"
.addProductTierPrice
"
).
click
(
function
(){
str
=
"
<tr>
"
;
str
+=
"
<td><input class=
\"
tier_qty
\"
type=
\"
text
\"
/> and above </td>
"
;
str
+=
"
<td><input class=
\"
tier_price
\"
type=
\"
text
\"
/></td>
"
;
str
+=
"
<td><img src=
\"
<?=
\
Yii
::
$service
->
image
->
getImgUrl
(
'/images/bkg_btn-close2.gif'
)
?>
\"
/></td>
"
;
str
+=
"
</tr>
"
;
$
(
"
.tier_price table tbody
"
).
append
(
str
);
});
});
</script>
</div>
</div>
</div>
<div>
<?=
$metaInfo
?>
...
...
app/appfront/modules/Catalog/block/category/Index.php
浏览文件 @
c0843d75
...
...
@@ -315,7 +315,7 @@ class Index {
protected
function
getNumPerPage
(){
if
(
!
$this
->
_numPerPageVal
){
$numPerPage
=
Yii
::
$app
->
request
->
get
(
$this
->
_numPerPage
);
$category_query_config
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
$category_query_config
=
Yii
::
$app
->
getModule
(
'catalog'
)
->
params
[
'category_query'
];
if
(
!
$numPerPage
){
if
(
isset
(
$category_query_config
[
'numPerPage'
])){
if
(
is_array
(
$category_query_config
[
'numPerPage'
])){
...
...
@@ -351,7 +351,7 @@ class Index {
'special_from'
,
'special_to'
,
'url_key'
,
'score'
,
];
$category_query
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
$category_query
=
Yii
::
$app
->
getModule
(
'catalog'
)
->
params
[
'category_query'
];
if
(
is_array
(
$category_query
[
'sort'
])){
foreach
(
$category_query
[
'sort'
]
as
$sort_item
){
$select
[]
=
$sort_item
[
'db_columns'
];
...
...
services/product/Price.php
浏览文件 @
c0843d75
...
...
@@ -41,19 +41,62 @@ class Price extends Service
];
}
/**
* 得到单个产品的最终价格。
* 得到单个产品的最终价格。
支持tier price 如果是tier price 需要把qty 以及tier Price传递过来
* @property $price | Float 产品的价格
* @property $special_price | Float 产品的特价
* @property $special_from | Int 产品的特检开始时间
* @property $special_to | Int 产品的特检结束时间
* @property $qty | Int 产品的个数,这个用于一次性购买多个产品的优惠,这些是用于批发客户
* @property $tier_price | Array ,Example:
* $tier_price = [
* ['qty'=>2,'price'=>33],
* ['qty'=>4,'price'=>30],
* ];
*
* @return Float
*/
protected
function
actionGetFinalPrice
(
$price
,
$special_price
,
$special_from
,
$special_to
){
protected
function
actionGetFinalPrice
(
$price
,
$special_price
,
$special_from
,
$special_to
,
$qty
=
''
,
$tier_price
=
[]
){
if
(
$this
->
specialPriceisActive
(
$price
,
$special_price
,
$special_from
,
$special_to
)){
return
$special_price
;
$return_price
=
$special_price
;
}
else
{
$return_price
=
$price
;
}
if
(
$qty
>
1
){
$return_price
=
$this
->
getTierPrice
(
$qty
,
$tier_price_arr
,
$return_price
);
}
return
$return_price
;
}
/**
* @property $qty | Int
* @property $price | Float 一个产品的单价(如果有特价,那么这个值是一个产品的特价)
* @property $tier_price | Array , example:
* $tier_price = [
* ['qty'=>2,'price'=>33],
* ['qty'=>4,'price'=>30],
* ];
* 传递过来的tier_price 数组,必须是按照qty进行排序好了的数组
*/
protected
function
actionGetTierPrice
(
$qty
,
$tier_price_arr
,
$price
){
if
(
$qty
<=
1
){
return
$price
;
}
$t_price
=
$price
;
if
(
is_array
(
$tier_price_arr
)
&&
!
empty
(
$tier_price_arr
)){
foreach
(
$tier_price_arr
as
$one
){
$t_qty
=
$one
[
'qty'
];
if
(
$t_qty
<=
$qty
){
continue
;
}
else
{
return
$t_price
;
}
$t_price
=
$one
[
'price'
];
}
}
return
$t_price
;
}
/**
* 判断产品的special_price是否有效,下面几种情况会无效
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录