转自:http://www.phpally.com/ecshop%E8%87%AA%E5%AE%9A%E4%B9%89%E9%94%80%E9%87%8F/
本补丁以假乱真,对网站销售有一定帮助,计算公式:前台显示销量 = 后台自定义销量 = 实际销量,以下讲解以官方默认模板(default)为例
后台商品列表
前台效果
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiYAAACfCAIAAABC9oWFAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAARzklEQVR4nO3df2zc5n3H8S+jdDHiymki/2x8WG0nXRzp7DlWakdDg51RBNal18b24gLCXAyYAjhT7AUK6mEw0qT1NGwGoqVx3WaxMCT2IKDOVDvVcsrSzRe4gGbBdhvvat8Ko05bOZFsVc4fRhajmcb9QYmm+JA8Ho96Trp7v/4QeM89fEgBx/vwefiQZ5imKUCV+nB8/M6GhkrvBTCDrl+/7vdWfX29zj0J45ZK7wAAoFYQOQAATYgcAIAmRA4AQBMiBwCgCZEDANCEyAEAaELkAAA0ubXSO1BJZluHiBi9B0OWa9gZP5p3BgBmglH+0wdSqZSI5HK5gHdVrvpqI37NOsuDNx2Gmi4VyRvMEJ4+gKo3t54+EKWX45kirkJXDKhZ4pLL5VKpVCqViitLQjJ6D5ptHWZbh5Uxvv2efS9K4eLki0UNxne+Pbl87C3z9f7J5Yc3Gjt3RCwHgBoQ5VpOLpezwyDnoL4bkhU2wct2SSKRsGOps7NT/DtSIU0GzLG3fPPm5SNSuCgPbzR6D8rqe2Vs3Hz5iIjImXNWfkyucvKUnDkXpRwAakP0azmx90v8xtA8WW9lMplMJuPcjWisvo4Ej6eNjYuI0XSfOdXdMc/8l4jIwxsn/548ZQ7kjOa1JZcHXsVx7WeUf6+GMaoGzCoRI8cZBupySeERYaOurbjCz1kzlqE5Y+cOmRoBM6+MiYjRvEZErKE2Y8ki668pIr+9FqHc70oSV5UAVJnovZyWlpauri5rdKu7u1umvvpd1eK6HqNuKJYOlquHYb/0/qI/c05OnpKHN0rz2gjbAoAaV9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Ci2CLmTWj2w0k9m833vNR3966BQ+l8zxNP9CQ8ex9qnTBrAUDtiG3G2qfqbh0dHX3p7V//34L5Nz6Rj39n3i4y77bfm5iYuOWWkq8YqV/6zkhw1ZT4RsB8Miw/NCTbdqdFJLlhg/QNi6jhodaREGsBQA2JIXIWLlw4Njb28IPJnmM/Hj/+ffnSX/yvKcaPv3/bpz+z6aEHrl27dtddd4VvzfWl73rpOfAV14QCK9W8Umf48uW7v2DlRfKzd7/0Qd4jPTzqqCV7wg0hAkBViiFy7lm16peXLj2w7oG97X/yN4f+5ZMf7TNM+dTt9f/w1zuXLV54amjonlWryt9KdfCLTJIGQC2IIXIaGxv7fvjDwrwLX8s8svGBpvMXf1N3a936xs8vWXjnu+++OzIy0vLQQ9FaVr+LnR2aGGdLu5qyX05tPbF8+bHJrk3+g/fv/qzXAJlaJzFUfC0AqCExRE5dXd2j6fSb2ezHN26s+NznvvKlPxKR0dHR/zx1amRk5NF0OswDCKx08RtGCyiJhWuMTtlKcsMGeWko355M5oeGZPlurzbUOmHWAoAaEs8z1ubPn79t69Y7Fiw4+9OfvnLo0CuHDp0+ffqOBQu2bd1a0qMHnFPXSurEzPT9ocn23RuG9rS2tu65vMWaeJZ9vrX1iZ58YB21xN5bz+zkLlcA1S22GWt1dXVr1qxZs2ZNhHU9L2yonZ7Ihg609h2IdHPMTcn2QwPtjtfp5weUttx1vEqKX7lx3AraHlANAOaceJ6xFgvPQS31Dk2/1efEFfii/Zs58V8A0KmabgWdRZEDAFBVU+TwezkAAE2IHACAJkQOAEATIgcAoAmRAwDQhMgBAGhC5AAANCFyAACa/D9UUsLpTk8g6QAAAABJRU5ErkJggg==" alt="" width="550" height="159" />
开发指南
一、将安装文件覆盖到网站根目录(覆盖前注意备份),输入”站点路径/db_patch.php”,如”http://ecshop.phpally.com/db_patch.php”一键完成数据库补丁的安装,安装完成后,请立即删除db_patch.php。
<?php
/**
* ECSHOP 自定义销量 数据库补丁
* ----------------------------------------------------------------------------
* http://www.phpally.com
* Jacklee的博客 致力于php技术
* ----------------------------------------------------------------------------
* 作者: Jacklee
* 邮箱: 349392900#qq.com
* 创建时间: 2013-09-27
* 最后修改时间: 2013-09-27
*/ define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php'); $sql = "
ALTER TABLE `{$prefix}goods` ADD `sales_volume_base` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0' COMMENT '销量基数'
";
$db->query($sql);
echo '数据库补丁程序执行成功,请立即删除此补丁文件(db_patch.php)。';
二、编辑/admin/goods.php,添加修改销量基数(sales_volume_base)
*------------------------------------------------------ */
//-- 修改商品销量基数
/*------------------------------------------------------ */
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)
ql = "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)
<table cellpadding="3" cellspacing="1">
<tr>
<th>
<input onclick='listTable.selectAll(this, "checkboxes")' type="checkbox" />
<a href="javascript:listTable.sort('goods_id'); ">{$lang.record_id}</a>{$sort_goods_id}
</th>
<th><a href="javascript:listTable.sort('goods_name'); ">{$lang.goods_name}</a>{$sort_goods_name}</th>
<th><a href="javascript:listTable.sort('goods_sn'); ">{$lang.goods_sn}</a>{$sort_goods_sn}</th>
<th><a href="javascript:listTable.sort('shop_price'); ">{$lang.shop_price}</a>{$sort_shop_price}</th>
<th><a href="javascript:listTable.sort('is_on_sale'); ">{$lang.is_on_sale}</a>{$sort_is_on_sale}</th>
<th><a href="javascript:listTable.sort('is_best'); ">{$lang.is_best}</a>{$sort_is_best}</th>
<th><a href="javascript:listTable.sort('is_new'); ">{$lang.is_new}</a>{$sort_is_new}</th>
<th><a href="javascript:listTable.sort('is_hot'); ">{$lang.is_hot}</a>{$sort_is_hot}</th>
<th><a href="javascript:listTable.sort('sort_order'); ">{$lang.sort_order}</a>{$sort_sort_order}</th>
{if $use_storage}
<th><a href="javascript:listTable.sort('goods_number'); ">{$lang.goods_number}</a>{$sort_goods_number}</th>
{/if}
<th><a href="javascript:listTable.sort('sales_volume_base'); ">{$lang.sales_volume_base}</a>{$sort_sales_volume_base}</th>
<th>{$lang.handler}</th>
<tr>
{foreach from=$goods_list item=goods}
<tr>
<td><input type="checkbox" name="checkboxes[]" value="{$goods.goods_id}" />{$goods.goods_id}</td>
<td class="first-cell" style="{if $goods.is_promote}color:red;{/if}"><span onclick="listTable.edit(this, 'edit_goods_name', {$goods.goods_id})">{$goods.goods_name|escape:html}</span></td>
<td><span onclick="listTable.edit(this, 'edit_goods_sn', {$goods.goods_id})">{$goods.goods_sn}</span></td>
<td align="right"><span onclick="listTable.edit(this, 'edit_goods_price', {$goods.goods_id})">{$goods.shop_price} </span></td>
<td align="center"><img src="data:images/{if $goods.is_on_sale}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_on_sale', {$goods.goods_id})" /></td>
<td align="center"><img src="data:images/{if $goods.is_best}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_best', {$goods.goods_id})" /></td>
<td align="center"><img src="data:images/{if $goods.is_new}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_new', {$goods.goods_id})" /></td>
<td align="center"><img src="data:images/{if $goods.is_hot}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_hot', {$goods.goods_id})" /></td>
<td align="center"><span onclick="listTable.edit(this, 'edit_sort_order', {$goods.goods_id})">{$goods.sort_order}</span></td>
{if $use_storage}
<td align="right"><span onclick="listTable.edit(this, 'edit_goods_number', {$goods.goods_id})">{$goods.goods_number}</span></td>
{/if}
<td align="center"><span onclick="listTable.edit(this, 'edit_sales_volume_base', {$goods.goods_id})">{$goods.sales_volume_base}</span></td>
<td align="center">
<a href="../goods.php?id={$goods.goods_id}" target="_blank" title="{$lang.view}"><img src="data:images/icon_view.gif" width="16" height="16" border="0" /></a>
<a href="goods.php?act=edit&goods_id={$goods.goods_id}{if $code neq 'real_goods'}&extension_code={$code}{/if}" title="{$lang.edit}"><img src="data:images/icon_edit.gif" width="16" height="16" border="0" /></a>
<a href="goods.php?act=copy&goods_id={$goods.goods_id}{if $code neq 'real_goods'}&extension_code={$code}{/if}" title="{$lang.copy}"><img src="data:images/icon_copy.gif" width="16" height="16" border="0" /></a>
<a href="javascript:;" onclick="listTable.remove({$goods.goods_id}, '{$lang.trash_goods_confirm}')" title="{$lang.trash}"><img src="data:images/icon_trash.gif" width="16" height="16" border="0" /></a>
{if $specifications[$goods.goods_type] neq ''}<a href="goods.php?act=product_list&goods_id={$goods.goods_id}" title="{$lang.item_list}"><img src="data:images/icon_docs.gif" width="16" height="16" border="0" /></a>{else}<img src="data:images/empty.gif" width="16" height="16" border="0" />{/if}
{if $add_handler}
|
{foreach from=$add_handler item=handler}
<a href="{$handler.url}&goods_id={$goods.goods_id}" title="{$handler.title}"><img src="data:images/{$handler.img}" width="16" height="16" border="0" /></a>
{/foreach}
{/if}
</td>
</tr>
{foreachelse}
<tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
{/foreach}
</table>
五、编辑/languages/zh_cn/admin/goods.php,添加语言项
$_LANG['sales_volume_base'] = '销量基数';
六、编辑/includes/lib_goods.php,修改get_goods_info函数,计算累计销量(sales_volume_total)
/**
* 获得商品的详细信息
*
* @access public
* @param integer $goods_id
* @return void
*/
function get_goods_info($goods_id)
{
$time = gmtime();
$sql = 'SELECT g.*, c.measure_unit, b.brand_id, b.brand_name AS goods_brand, m.type_money AS bonus_money, ' .
'IFNULL(AVG(r.comment_rank), 0) AS comment_rank, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS rank_price " .
'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON g.cat_id = c.cat_id ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON g.brand_id = b.brand_id ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('comment') . ' AS r '.
'ON r.id_value = g.goods_id AND comment_type = 0 AND r.parent_id = 0 AND r.status = 1 ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('bonus_type') . ' AS m ' .
"ON g.bonus_type_id = m.type_id AND m.send_start_date <= '$time' AND m.send_end_date >= '$time'" .
" LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
"WHERE g.goods_id = '$goods_id' AND g.is_delete = 0 " .
"GROUP BY g.goods_id";
$row = $GLOBALS['db']->getRow($sql); /* 查询该商品的实际销量 */
$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; if ($row !== false)
{
/* 用户评论级别取整 */
$row['comment_rank'] = ceil($row['comment_rank']) == 0 ? 5 : ceil($row['comment_rank']); /* 获得商品的销售价格 */
$row['market_price'] = price_format($row['market_price']);
$row['shop_price_formated'] = price_format($row['shop_price']); /* 修正促销价格 */
if ($row['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
}
else
{
$promote_price = 0;
} /* 处理商品水印图片 */
$watermark_img = ''; if ($promote_price != 0)
{
$watermark_img = "watermark_promote";
}
elseif ($row['is_new'] != 0)
{
$watermark_img = "watermark_new";
}
elseif ($row['is_best'] != 0)
{
$watermark_img = "watermark_best";
}
elseif ($row['is_hot'] != 0)
{
$watermark_img = 'watermark_hot';
} if ($watermark_img != '')
{
$row['watermark_img'] = $watermark_img;
} $row['promote_price_org'] = $promote_price;
$row['promote_price'] = price_format($promote_price); /* 修正重量显示 */
$row['goods_weight'] = (intval($row['goods_weight']) > 0) ?
$row['goods_weight'] . $GLOBALS['_LANG']['kilogram'] :
($row['goods_weight'] * 1000) . $GLOBALS['_LANG']['gram']; /* 修正上架时间显示 */
$row['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']); /* 促销时间倒计时 */
$time = gmtime();
if ($time >= $row['promote_start_date'] && $time <= $row['promote_end_date'])
{
$row['gmt_end_time'] = $row['promote_end_date'];
}
else
{
$row['gmt_end_time'] = 0;
} /* 是否显示商品库存数量 */
$row['goods_number'] = ($GLOBALS['_CFG']['use_storage'] == 1) ? $row['goods_number'] : ''; /* 修正积分:转换为可使用多少积分(原来是可以使用多少钱的积分) */
$row['integral'] = $GLOBALS['_CFG']['integral_scale'] ? round($row['integral'] * 100 / $GLOBALS['_CFG']['integral_scale']) : 0; /* 修正优惠券 */
$row['bonus_money'] = ($row['bonus_money'] == 0) ? 0 : price_format($row['bonus_money'], false); /* 修正商品图片 */
$row['goods_img'] = get_image_path($goods_id, $row['goods_img']);
$row['goods_thumb'] = get_image_path($goods_id, $row['goods_thumb'], true); return $row;
}
else
{
return false;
}
}
七、以默认模板为例,编辑/themes/default/goods.dwt,添加显示累计销量
<li class="clearfix">
<dd>
<strong>{$lang.sales_volume_total}<font color="#FE596A" size="2">{$goods.sales_volume_total}{$lang.pcs}</font></strong>
</dd>
<dd>
</dd>
</li>
八、编辑/languages/zh_cn/common.php,添加语言项
$_LANG['sales_volume_total'] = '累计销量:';
$_LANG['pcs'] = '件';