本帖最后由 news 于 2016-1-6 15:07 编辑
1.在数据库ecs_goods中添加sales_volume_base此字段
2.编辑/admin/goods.php,添加修改销量基数(sales_volume_base)
[PHP] 纯文本查看 复制代码 /*------------------------------------------------------ */
//-- 修改商品销量基数
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_sales_volume_base')
{
check_authz_json('goods_manage');
$goods_id = intval($_POST['id']);
$sales_volume_base = json_str_iconv(trim($_POST['val']));
if ($exc->edit("sales_volume_base = '$sales_volume_base', last_update=" .gmtime(), $goods_id))
{
clear_cache_files();
make_json_result(stripslashes($sales_volume_base));
}
}
三、编辑/admin/includes/lib_goods.php,添加查询销量基数(sales_volume_base)
[PHP] 纯文本查看 复制代码 $sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, sales_volume_base, " .
" (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ".
" FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
" ORDER BY $filter[sort_by] $filter[sort_order] ".
" LIMIT " . $filter['start'] . ",$filter[page_size]";
四、编辑/admin/templates/goods_list.htm,添加显示销量基数(sales_volume_base)
[HTML] 纯文本查看 复制代码 <th><a href="javascript:listTable.sort('sales_volume_base'); ">{$lang.sales_volume_base}</a>{$sort_sales_volume_base}</th>
<td align="center"><span>{$goods.sales_volume_base}</span></td>
五、编辑/languages/zh_cn/admin/goods.php,添加语言项
[PHP] 纯文本查看 复制代码
$_LANG['sales_volume_base'] = '销量基数';
六、编辑/includes/lib_goods.php,修改get_goods_info函数,计算累计销量(sales_volume_total)
[PHP] 纯文本查看 复制代码 /* 查询该商品的实际销量 */
$sql = 'SELECT IFNULL(SUM(g.goods_number), 0) ' .
'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o, ' .
$GLOBALS['ecs']->table('order_goods') . ' AS g ' .
"WHERE o.order_id = g.order_id " .
"AND o.order_status = '" . OS_CONFIRMED . "' " .
"AND o.shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) .
" AND o.pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) .
" AND g.goods_id = '$goods_id'" ;
$sales_count = $GLOBALS['db']->getOne($sql);
/* 累计销量 = 自定义销量基数 + 实际销量 */
$row['sales_volume_total'] = $row['sales_volume_base'] + $sales_count;
七、以默认模板为例,编辑/themes/default/goods.dwt,添加显示累计销量
[PHP] 纯文本查看 复制代码 <strong>{$lang.sales_volume_total}<font color="#FE596A" size="2">{$goods.sales_volume_total}{$lang.pcs}</font></strong>
八、编辑/languages/zh_cn/common.php,添加语言项
[PHP] 纯文本查看 复制代码 $_LANG['sales_volume_total'] = '累计销量:';
$_LANG['pcs'] = '件';
由于自定义销量需要修改好几个文件,方法太麻烦就不写出来了,需要的朋友可以联系我QQ:82518223 |