提交 c0843d75 编写于 作者: R root

product tier price

上级 26018cfd
......@@ -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;
}
# 批量删除
......
......@@ -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 ?>
......
......@@ -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'];
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册