} /* 拆分商品名称样式 */ $goods_name_style = explode('+', empty($goods['goods_name_style']) ? '+' : $goods['goods_name_style']); /* 创建 html editor */ create_html_editor('goods_desc', $goods['goods_desc']); /* 模板赋值 */ $smarty->assign('code', $code); $smarty->assign('ur_here', $is_add ? empty($code) ? $_LANG['02_goods_add'] : $_LANG['51_virtual_card_add'] : ($_REQUEST['act'] == 'edit' ? $_LANG['edit_goods'] : $_LANG['copy_goods'])); $smarty->assign('action_link', list_link($is_add, $code)); $smarty->assign('goods', $goods); $smarty->assign('goods_name_color', $goods_name_style[0]); $smarty->assign('goods_name_style', $goods_name_style[1]); $smarty->assign('cat_list', cat_list(0, $goods['cat_id'])); $smarty->assign('brand_list', get_brand_list()); $smarty->assign('unit_list', get_unit_list()); $smarty->assign('user_rank_list', get_user_rank_list()); $smarty->assign('weight_unit', $is_add ? '1' : ($goods['goods_weight'] >= 1 ? '1' : '0.001')); $smarty->assign('cfg', $_CFG); $smarty->assign('form_act', $is_add ? 'insert' : ($_REQUEST['act'] == 'edit' ? 'update' : 'insert')); if ($_REQUEST['act'] == 'add' || $_REQUEST['act'] == 'edit') { $smarty->assign('is_add', true); } if (!$is_add) { $smarty->assign('member_price_list', get_member_price_list($_REQUEST['goods_id'])); } $smarty->assign('link_goods_list', $link_goods_list); $smarty->assign('group_goods_list', $group_goods_list); $smarty->assign('goods_article_list', $goods_article_list); $smarty->assign('img_list', $img_list); $smarty->assign('goods_type_list', goods_type_list($goods['goods_type'])); $smarty->assign('gd', gd_version());
$form_act = 'update'; break; case 'special_edit': $form_act = 'special_update'; break; default: $form_act = 'insert'; break; } $smarty->assign('form_act', $form_act); if ($_REQUEST['act'] == 'add' || $_REQUEST['act'] == 'edit' || $_REQUEST['act'] == 'special_edit') { $smarty->assign('is_add', true); } /* 分配用户等级及对应的起购数量的数据 add by zenghd for date 2014-08-18 */ $user_rank_list = array(); $user_rank_list = get_user_rank_list(); if ($_REQUEST['act'] == 'add') { foreach ($user_rank_list as $k => $num) { $user_rank_list[$k]['rank_start_num'] = 0; } } else { if ($_REQUEST['act'] == 'copy' || $_REQUEST['act'] == 'edit') { $sql = "SELECT user_rank,rank_goods_start_num FROM" . $ecs->table('member_price') . " WHERE goods_id = '{$_REQUEST['goods_id']}' "; $rank_goods_start_num = $db->getAll($sql); //dump($goods_start_num); foreach ($rank_goods_start_num as $k => $num) { if ($rank_goods_start_num[$k]['user_rank'] == $user_rank_list[$k]['rank_id']) { $user_rank_list[$k]['def_rank_start_num'] = $rank_goods_start_num[$k]['rank_goods_start_num'] ? 0 : $user_rank_list[$k]['rank_start_num']; $user_rank_list[$k]['rank_start_num'] = $rank_goods_start_num[$k]['rank_goods_start_num']; } }
function get_vip_goods_recommend($type = 'vip_only') { if ($type == 'vip_only') { $user_rank_list = get_user_rank_list(); //var_dump($user_rank_list);exit; foreach ($user_rank_list as $useRanKey => $useRankVal) { if ($useRankVal['rank_name'] == '代销用户' || $useRankVal['rank_name'] == 'VIP0') { continue; } $sql = 'SELECT ur.rank_name,vmp.user_price,g.goods_id, g.goods_name, vg.begin_time,g.market_price, g.shop_price, g.goods_name_style, ' . 'g.goods_brief, g.goods_thumb, goods_img, b.brand_name ' . 'FROM ' . $GLOBALS['ecs']->table('vip_goods') . ' AS vg ' . 'JOIN ' . $GLOBALS['ecs']->table('vip_member_price') . ' AS vmp on vmp.goods_id = vg.goods_id ' . " join " . $GLOBALS['ecs']->table('user_rank') . " as ur on vmp.user_rank = ur.rank_id " . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = vg.goods_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . 'WHERE vmp.user_rank = "' . $useRankVal['rank_id'] . '" AND vg.is_integral_buy = 0 AND vg.is_exchange = 1 AND g.is_delete = 0 AND is_next = 0 order by vg.goods_id asc limit 2 ;'; // ECHO $sql.'<br/>'; $tmpGoods[] = $GLOBALS['db']->getAll($sql); } foreach ($tmpGoods as $tmpGoodsVal) { if (!$tmpGoodsVal[0]) { continue; } $tmpGoodsVal[0]['user_price'] = price_format($tmpGoodsVal[0]['user_price']); $tmpGoodsVal[0]['shop_price'] = price_format($tmpGoodsVal[0]['shop_price']); $tmpGoodsVal[0]['market_price'] = price_format($tmpGoodsVal[0]['market_price']); $tmpGoodsVal[0]['url'] = build_uri('vip_goods', array('act' => 'view', 'id' => $tmpGoodsVal[0]['goods_id'])); $more_goods[] = $tmpGoodsVal[0]; } foreach ($tmpGoods as $tmpGoodsVal) { if (!$tmpGoodsVal[1]) { continue; } $tmpGoodsVal[1]['user_price'] = price_format($tmpGoodsVal[1]['user_price']); $tmpGoodsVal[1]['shop_price'] = price_format($tmpGoodsVal[1]['shop_price']); $tmpGoodsVal[1]['market_price'] = price_format($tmpGoodsVal[1]['market_price']); $tmpGoodsVal[1]['url'] = build_uri('vip_goods', array('act' => 'view', 'id' => $tmpGoodsVal[1]['goods_id'])); $more_goods[] = $tmpGoodsVal[1]; } } else { if ($type == 'integral_buy') { $sql = 'SELECT g.goods_id, g.goods_name, vg.begin_time,g.market_price, g.shop_price, g.goods_name_style, ' . 'g.goods_brief, g.goods_thumb, goods_img, b.brand_name ' . 'FROM ' . $GLOBALS['ecs']->table('vip_goods') . ' AS vg ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = vg.goods_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . 'WHERE vg.is_integral_buy = 1 AND vg.is_exchange = 1 AND g.is_delete = 0 AND is_next = 0 order by g.shop_price DESC limit 8;'; $more_goods = $GLOBALS['db']->getAll($sql); foreach ($more_goods as $more_goodsKey => $more_goodsVal) { $sql = "select rank_name,user_price,user_integral from " . $GLOBALS['ecs']->table('vip_member_price') . " as vmp " . " join " . $GLOBALS['ecs']->table('user_rank') . " as ur on vmp.user_rank=ur.rank_id" . " where goods_id=" . $more_goodsVal['goods_id'] . " and ur.rank_id in(7,4,5,6)"; $vip_goods = $GLOBALS['db']->getAll($sql); foreach ($vip_goods as $k => $v) { $vip_goods[$k]['user_price'] = price_format($v['user_price']); } $more_goods[$more_goodsKey]['market_price'] = price_format($more_goods[$more_goodsKey]['market_price']); $more_goods[$more_goodsKey]['shop_price'] = price_format($more_goods[$more_goodsKey]['shop_price']); $more_goods[$more_goodsKey]['vip_goods'] = $vip_goods; $more_goods[$more_goodsKey]['url'] = build_uri('vip_goods', array('act' => 'view', 'id' => $more_goods[$more_goodsKey]['goods_id'])); } } } return $more_goods; }