[PHP] 纯文本查看 复制代码 <?php
global $_GPC, $_W;
$data["uniacid"] = $_W["uniacid"];
$data["user_id"] = $_GPC["user_id"];
$data["goods_id"] = $_GPC["goods_id"];
$data["goods_name"] = $_GPC["goods_name"];
$data["goods_image"] = $_GPC["goods_image"];
$data["retail_price"] = $_GPC["retail_price"];
$data["goods_specifition_name_value"] = $_GPC["goods_specifition_name_value"];
$data["goods_specifition_ids"] = $_GPC["goods_specifition_ids"];
$data["product_id"] = $_GPC["goods_specifition_ids"];
$data["total"] = $_GPC["total"];
$data["number"] = $_GPC["number"];
$data["is_limit"] = $_GPC["is_limit"];
$data["is_raise"] = $_GPC["is_raise"];
$data["is_border"] = $_GPC["is_border"];
$data["fh_way"] = $_GPC["fh_way"];
$data["shop_id"] = $_GPC["extract_shop_id"];
$data["share_user_id"] = $_GPC["share_user_id"];
$data["fx_total"] = $_GPC["fx_total"];
$data["tg_total"] = $_GPC["tg_total"];
$data["attribute"] = $_GPC["attribute"];
$goods_specifition_ids = $_GPC["goods_specifition_ids"];
$goods_id = $_GPC["goods_id"];
$number = $_GPC["number"];
$res = pdo_get("meike_shop_cart", array("goods_id" => $goods_id, "user_id" => $_GPC["user_id"]));
$num = $res["number"];
$newNum = $num + $number;
if (empty($res)) {
$res11 = pdo_insert("meike_shop_cart", $data);
$message = "添加成功1";
$errno = 0;
return $this->result($errno, $message, $data);
}
if (empty($goods_specifition_ids)) {
$check = pdo_get("meike_shop_goods", array("id" => $goods_id));
$goods_number = $check["goods_number"];
if ($newNum > $goods_number) {
$message = "添加失败,购物车中已有此商品,清空购物车再试";
$errno = 1;
return $this->result($errno, $message);
}
pdo_update("meike_shop_cart", array("number" => $newNum), array("goods_id" => $goods_id));
$message = "添加成功2";
$errno = 0;
return $this->result($errno, $message);
}
$check = pdo_get("meike_shop_cart", array("product_id" => $goods_specifition_ids));
if (empty($check)) {
pdo_insert("meike_shop_cart", $data);
$message = "添加成功3";
$errno = 0;
return $this->result($errno, $message);
}
$sk = pdo_get("meike_shop_goods_option", array("id" => $goods_specifition_ids));
$stock = $sk["stock"];
if ($newNum > $stock) {
$message = "添加失败,购物车中已有此商品,清空购物车再试";
$errno = 1;
return $this->result($errno, $message);
}
pdo_update("meike_shop_cart", array("number" => $newNum), array("goods_id" => $goods_id));
$message = "添加成功4";
$errno = 0;
return $this->result($errno, $message);
这个应该没问题了 |