1 Star 0 Fork 1

maltYumi/cake

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
company.php 9.35 KB
一键复制 编辑 原始数据 按行查看 历史
maltYumi 提交于 2018-12-28 00:05 . Signed-off-by: malt 423498555@qq.com
<?php
/**
* ECSHOP 企业商品
* ============================================================================
* 版权所有 2005-2010 上海商派网络科技有限公司,并保留所有权利。
* 网站地址: http://www.ecshop.com;
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
* 使用;不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: hifrogs $
* $Id: company.php 17069 2018-01-24 15:03:35Z hifrogs $
*/
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
if ((DEBUG_MODE & 2) != 2) {
$smarty->caching = true;
}
/*------------------------------------------------------ */
//-- INPUT
/*------------------------------------------------------ */
$_REQUEST['step'] = empty($_REQUEST['step']) ? 'validate' : trim($_REQUEST['step']);
$_REQUEST['card_password'] = isset($_REQUEST['card_password']) ? trim($_REQUEST['card_password']) : '';
$card_password = $_REQUEST['card_password'];
/*------------------------------------------------------ */
//-- PROCESSOR
/*------------------------------------------------------ */
/* 代金卡验证 */
if ($_REQUEST['step'] == 'validate') {
if ($_SESSION['user_id'] == 0) {
setcookie('back_act', 'company.php');
ecs_header("Location: user.php\n"); // 用户没有登录且没有选定匿名购物,转向到登录页面
exit;
}
}
/* 企业及商品 */
else if ($_REQUEST['step'] == 'shop') {
/* 验证码验证 */
if (empty($_POST['captcha'])) {
show_message('请输入验证码!', '', '', 'warning');
}
include_once('includes/cls_captcha.php');
$validator = new captcha();
if (!$validator->check_word(($_POST['captcha']))) {
show_message('验证码不正确!', '', '', 'warning');
}
//获取企业代金卡数据
if (!empty($card_password)) {
$sql = 'SELECT br.business_id, bt.*, ub.* ' . 'FROM ' . $GLOBALS['ecs']->table('user_bonus') . ' AS ub ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('bonus_type') . ' AS bt ON bt.type_id = ub.bonus_type_id ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('business_relevant') . ' AS br ON br.bonus_type_id = ub.bonus_type_id ' .
"WHERE ub.bonus_pw = '$card_password' AND ub.user_id = '0' AND used_time = '0' AND ub.order_id = '0' " .
"AND ub.bonus_type_id <> '0' AND br.bonus_type_id <> '0'"; //红包以分配红包类型,红包类型已经绑定企业
$business_gift_card = $GLOBALS['db']->getRow($sql);
$business_id = $business_gift_card['business_id'];
$_SESSION["business_gift_card"] = $business_gift_card; //全局企业卡信息
// print_r($_SESSION["business_gift_card"]);exit;
}
if (empty($business_gift_card)) {
show_message('代金卡不存在或已经被使用!', '', '', 'warning');
}
/* 企业数据 */
$business = get_business_info($business_id);
if (empty($business)) {
show_message('该企业没有任何商品!', '', '', 'warning');
}
$smarty->assign('business', $business); // 企业基本信息
$smarty->assign('business_goods', get_business_goods($business_id)); // 企业所有商品
$smarty->assign('business_gift', get_business_gift($business_id)); // 企业所有赠品
$smarty->assign('keywords', htmlspecialchars($business['keywords']));
$smarty->assign('description', htmlspecialchars($business['description']));
}
assign_template();
assign_dynamic('business');
$position = assign_ur_here(0, '企业商品兑换');
$smarty->assign('page_title', $position['title']); // 页面标题
$smarty->assign('ur_here', $position['ur_here']); // 当前位置
$smarty->assign('step', $_REQUEST['step']);
$_SESSION['FROM_COMPANY'] = 1;
$smarty->display('company.dwt');
/*------------------------------------------------------ */
//-- PRIVATE FUNCTION
/*------------------------------------------------------ */
/**
* 获得指定的文章的详细信息
*
* @access private
* @param integer $article_id
* @return array
*/
function get_business_info($business_id)
{
/* 获得文章的信息 */
$sql = "SELECT * " . "FROM " . $GLOBALS['ecs']->table('business') . " AS b " . "LEFT JOIN " . $GLOBALS['ecs']->table('business_cat') . " AS bc ON bc.cat_id = b.cat_id " . "WHERE b.business_id = $business_id AND b.is_open = 1";
$row = $GLOBALS['db']->getRow($sql);
// if ($row !== false)
// {
// $row['comment_rank'] = ceil($row['comment_rank']); // 用户评论级别取整
// $row['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']); // 修正添加时间显示
// /* 作者信息如果为空,则用网站名称替换 */
// if (empty($row['author']) || $row['author'] == '_SHOPHELP')
// {
// $row['author'] = $GLOBALS['_CFG']['shop_name'];
// }
// }
return $row;
}
/**
* 获得企业关联的商品
*
* @access public
* @param integer $id
* @return array
*/
function get_business_goods($id)
{
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price, g.keywords,g.goods_indexinfo, ' . 'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' . 'FROM ' . $GLOBALS['ecs']->table('business_relevant') . ' AS br ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = br.goods_id ' . "WHERE br.business_id = '$id' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0"; //. " AND g.shop_price < '$type_money'";
$res = $GLOBALS['db']->query($sql);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res)) {
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
$arr[$row['goods_id']]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['goods_indexinfo'] = $row['goods_indexinfo'];
$arr[$row['goods_id']]['url'] = build_uri('goods', array(
'gid' => $row['goods_id']
), $row['goods_name']);
$arr[$row['goods_id']]['tag'] = explode(' ', $row['keywords']);
if ($row['promote_price'] > 0) {
$arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']);
} else {
$arr[$row['goods_id']]['promote_price'] = 0;
}
}
return $arr;
}
function get_business_gift($id)
{
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price, g.keywords,g.goods_indexinfo, ' . 'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' . 'FROM ' . $GLOBALS['ecs']->table('business_relevant') . ' AS br ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = br.gift_goods_id ' . "WHERE br.business_id = '$id' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0"; //. " AND g.shop_price < '$type_money'";
$res = $GLOBALS['db']->query($sql);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res)) {
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
$arr[$row['goods_id']]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['goods_indexinfo'] = $row['goods_indexinfo'];
$arr[$row['goods_id']]['url'] = build_uri('goods', array(
'gid' => $row['goods_id']
), $row['goods_name']);
$arr[$row['goods_id']]['tag'] = explode(' ', $row['keywords']);
if ($row['promote_price'] > 0) {
$arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']);
} else {
$arr[$row['goods_id']]['promote_price'] = 0;
}
}
return $arr;
}
/* 代码增加_start By www.dijoncake.com */
make_html();
/* 代码增加_end By www.dijoncake.com */
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/maltYumi/cake.git
git@gitee.com:maltYumi/cake.git
maltYumi
cake
cake
master

搜索帮助