public function index() { $root = array(); $email = strim($GLOBALS['request']['email']); //用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); //密码 $id = intval($GLOBALS['request']['id']); $user_id = intval($GLOBALS['user_info']['id']); //检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); // if ($user_id >0){ require APP_ROOT_PATH . 'app/Lib/deal.php'; require APP_ROOT_PATH . 'app/Lib/uc_goods_func.php'; $root['user_login_status'] = 1; $root['response_code'] = 1; if ($id == 0) { app_redirect(url("index")); } $goods = get_goods_info($id, $user_id); if (!$goods) { app_redirect(url("index")); } $root['goods_description'] = $goods['description']; $root['user_can_buy_number'] = $goods['user_can_buy_number']; if ($goods['goods_type_id'] > 0) { $goods_type_attr = get_goods_attr($goods['goods_type_id'], $id); $root['has_stock'] = $goods_type_attr['has_stock']; $root['goods_type_attr'] = $goods_type_attr['goods_type_attr']; $root['json_attr_stock'] = json_encode($goods_type_attr['attr_stock']); } else { $has_stock = 1; //$GLOBALS['tmpl']->assign("has_stock",$has_stock); $root['has_stock'] = $has_stock; } $root['goods'] = $goods; // }else{ // $root['response_code'] = 0; // $root['show_err'] ="未登录"; // $root['user_login_status'] = 0; // } $root['program_title'] = "商品详情"; output($root); }
public function index() { $id = intval($_REQUEST['id']); $user_id = intval($GLOBALS['user_info']['id']); if ($id == 0) { app_redirect(url("index")); } $goods = get_goods_info($id, $user_id); if (!$goods) { app_redirect(url("index")); } if ($goods['goods_type_id'] > 0) { $result = get_goods_attr($goods['goods_type_id'], $id); $GLOBALS['tmpl']->assign("json_attr_stock", json_encode($result['attr_stock'])); $GLOBALS['tmpl']->assign("has_stock", $result['has_stock']); $GLOBALS['tmpl']->assign("goods_type_attr", $result['goods_type_attr']); } else { $has_stock = 1; $GLOBALS['tmpl']->assign("has_stock", $has_stock); } $GLOBALS['tmpl']->assign("goods", $goods); $GLOBALS['tmpl']->display("page/goods_information.html"); }
} } elseif ($_REQUEST['act'] == 'search_goods') { check_authz_json('whole_sale'); include_once ROOT_PATH . 'includes/cls_json.php'; $json = new JSON(); $filter = $json->decode($_GET['JSON']); $arr = get_goods_list($filter); if (empty($arr)) { $arr[0] = array('goods_id' => 0, 'goods_name' => $_LANG['search_result_empty']); } make_json_result($arr); } elseif ($_REQUEST['act'] == 'get_goods_info') { include_once ROOT_PATH . 'includes/cls_json.php'; $json = new JSON(); $goods_id = intval($_REQUEST['goods_id']); $goods_attr_list = array_values(get_goods_attr($goods_id)); // 将数组中的 goods_attr_list 元素下的元素的数字下标转换成字符串下标 if (!empty($goods_attr_list)) { foreach ($goods_attr_list as $goods_attr_key => $goods_attr_value) { if (isset($goods_attr_value['goods_attr_list']) && !empty($goods_attr_value['goods_attr_list'])) { foreach ($goods_attr_value['goods_attr_list'] as $key => $value) { $goods_attr_list[$goods_attr_key]['goods_attr_list']['c' . $key] = $value; unset($goods_attr_list[$goods_attr_key]['goods_attr_list'][$key]); } } } } echo $json->encode($goods_attr_list); } /* * 取得批发活动列表
/** * 商品价格阶梯 * @param int $goods_id 商品ID * @return array */ function get_price_ladder($goods_id) { /* 显示商品规格 */ $goods_attr_list = array_values(get_goods_attr($goods_id)); $sql = "SELECT prices FROM " . $GLOBALS['ecs']->table('wholesale') . "WHERE goods_id = " . $goods_id; $row = $GLOBALS['db']->getRow($sql); $arr = array(); $_arr = unserialize($row['prices']); if (is_array($_arr)) { foreach (unserialize($row['prices']) as $key => $val) { // 显示属性 if (!empty($val['attr'])) { foreach ($val['attr'] as $attr_key => $attr_val) { // 获取当前属性 $attr_key 的信息 $goods_attr = array(); foreach ($goods_attr_list as $goods_attr_val) { if ($goods_attr_val['attr_id'] == $attr_key) { $goods_attr = $goods_attr_val; break; } } // 重写商品规格的价格阶梯信息 if (!empty($goods_attr)) { $arr[$key]['attr'][] = array('attr_id' => $goods_attr['attr_id'], 'attr_name' => $goods_attr['attr_name'], 'attr_val' => isset($goods_attr['goods_attr_list'][$attr_val]) ? $goods_attr['goods_attr_list'][$attr_val] : '', 'attr_val_id' => $attr_val); } } } // 显示数量与价格 foreach ($val['qp_list'] as $index => $qp) { $arr[$key]['qp_list'][$qp['quantity']] = price_format($qp['price']); } } } return $arr; }
function get_goods_attr_txm($goods_id, $taypes) { if (empty($taypes)) { return ''; //扫描的商品没有属性,返回空 } $taypesinfo = explode('+', $taypes); $goods_attr = get_goods_attr($goods_id); if (empty($goods_attr)) { return ''; //仓库中的商品没有属性,返回空 } $attr = $price = array(); foreach ($taypesinfo as $key => $val) { foreach ($goods_attr as $gkey => $gval) { foreach ($gval['goods_attr_list'] as $akey => $aval) { if ($aval == $val) { $attr[$akey] = $gval['attr_name'] . ':' . $val; if (intval($gval['goods_attr_price'][$akey]) > 0) { $attr[$akey] .= "[" . $gval['goods_attr_price'][$akey] . "]"; $price[$akey] = $gval['goods_attr_price'][$akey]; } } } } } return array('info' => $attr, 'price' => $price); }
} } elseif ($_REQUEST['act'] == 'search_goods') { check_authz_json('whole_sale'); include_once ROOT_PATH . 'includes/cls_json.php'; $json = new JSON(); $filter = $json->decode($_GET['JSON']); $arr = get_goods_list($filter); if (empty($arr)) { $arr[0] = array('goods_id' => 0, 'goods_name' => $_LANG['search_result_empty']); } make_json_result($arr); } elseif ($_REQUEST['act'] == 'get_goods_info') { include_once ROOT_PATH . 'includes/cls_json.php'; $json = new JSON(); $goods_id = intval($_REQUEST['goods_id']); echo $json->encode(array_values(get_goods_attr($goods_id))); } /* * 取得批发活动列表 * @return array */ function wholesale_list() { /* 查询会员等级 */ $rank_list = array(); $sql = "SELECT rank_id, rank_name FROM " . $GLOBALS['ecs']->table('user_rank'); $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { $rank_list[$row['rank_id']] = $row['rank_name']; } $result = get_filter();