Commit 0caacc9c authored by hezhen's avatar hezhen

修改加入购物车

parent b5b01f5a
......@@ -9,6 +9,9 @@ $uniacid = $_W['uniacid'];
$uid = $_GPC['user_id'];
$goods_id = $_GPC['goods_id'];
$spe_price_id = $_GPC['spe_price_id'];
$trip_time = strtotime($_GPC['trip_time']);
$company_id = $_GPC['company_id'];
$company_name = $_GPC['company_name'];
$number = $_GPC['number'];
$number = intval($number);
$goods = pdo_get('longbing_company_goods', array('id' => $goods_id), array('id', 'name', 'cover', 'price', 'freight'));
......@@ -49,12 +52,12 @@ $result = false;
$price = sprintf('%.2f', $number * $spe_price['price']);
if (!$check) {
$insertData = array('goods_id' => $goods_id, 'user_id' => $uid, 'name' => $goods['name'], 'cover' => $goods['cover'], 'spe_price_id' => $spe_price_id, 'content' => $titles, 'number' => $number, 'uniacid' => $uniacid, 'price' => $price, 'freight' => $goods['freight'], 'create_time' => $time, 'update_time' => $time);
$insertData = array('goods_id' => $goods_id, 'user_id' => $uid, 'name' => $goods['name'], 'cover' => $goods['cover'], 'spe_price_id' => $spe_price_id, 'content' => $titles, 'number' => $number, 'uniacid' => $uniacid, 'price' => $price, 'freight' => $goods['freight'], 'create_time' => $time, 'update_time' => $time, 'trip_time' => $trip_time, 'company_id' => $company_id, 'company_name' => $company_name);
$result = pdo_insert('longbing_company_shop_trolley', $insertData);
$insert_id = pdo_insertid();
}
else {
$updateData = array('name' => $goods['name'], 'cover' => $goods['cover'], 'spe_price_id' => $spe_price_id, 'content' => $titles, 'price' => sprintf('%.2f', $check['price'] + $price), 'number' => sprintf('%.2f', $check['number'] + $number), 'freight' => $goods['freight'], 'update_time' => $time);
$updateData = array('name' => $goods['name'], 'cover' => $goods['cover'], 'spe_price_id' => $spe_price_id, 'content' => $titles, 'price' => sprintf('%.2f', $check['price'] + $price), 'number' => sprintf('%.2f', $check['number'] + $number), 'freight' => $goods['freight'], 'update_time' => $time, 'trip_time' => $trip_time, 'company_id' => $company_id, 'company_name' => $company_name);
$insert_id = $check['id'];
$result = pdo_update('longbing_company_shop_trolley', $updateData, array('id' => $check['id']));
}
......
......@@ -30,10 +30,10 @@ if (empty($address)) {
$trolley_in = '(' . $trolley_ids . ')';
if (1 < count($trolley_arr)) {
$sql = 'SELECT a.id,a.spe_price_id,a.number,a.goods_id,b.name,b.cover,b.freight FROM ' . tablename('longbing_company_shop_trolley') . ' a LEFT JOIN ' . tablename('longbing_company_goods') . (' b ON a.goods_id = b.id WHERE a.user_id = ' . $uid . ' && a.status = 1 && a.id in ' . $trolley_in);
$sql = 'SELECT a.id,a.spe_price_id,a.number,a.trip_time,a.company_id,a.company_name,a.goods_id,b.name,b.cover,b.freight FROM ' . tablename('longbing_company_shop_trolley') . ' a LEFT JOIN ' . tablename('longbing_company_goods') . (' b ON a.goods_id = b.id WHERE a.user_id = ' . $uid . ' && a.status = 1 && a.id in ' . $trolley_in);
}
else {
$sql = 'SELECT a.id,a.spe_price_id,a.number,a.goods_id,b.name,b.cover,b.freight FROM ' . tablename('longbing_company_shop_trolley') . ' a LEFT JOIN ' . tablename('longbing_company_goods') . (' b ON a.goods_id = b.id WHERE a.user_id = ' . $uid . ' && a.status = 1 && a.id = ' . $trolley_ids);
$sql = 'SELECT a.id,a.spe_price_id,a.number,a.trip_time,a.company_id,a.company_name,a.goods_id,b.name,b.cover,b.freight FROM ' . tablename('longbing_company_shop_trolley') . ' a LEFT JOIN ' . tablename('longbing_company_goods') . (' b ON a.goods_id = b.id WHERE a.user_id = ' . $uid . ' && a.status = 1 && a.id = ' . $trolley_ids);
}
$list = pdo_fetchall($sql);
......@@ -124,7 +124,7 @@ if (!empty($result)) {
$order_id = pdo_insertid();
foreach ($list as $k => $v) {
$insertItem = array('order_id' => $order_id, 'goods_id' => $v['goods_id'], 'name' => $v['name'], 'cover' => $v['cover'], 'spe_price_id' => $v['spe_price_id'], 'content' => $v['spe'], 'number' => $v['number'], 'price' => $v['price'], 'uniacid' => $uniacid, 'create_time' => $time, 'update_time' => $time);
$insertItem = array('order_id' => $order_id, 'goods_id' => $v['goods_id'], 'name' => $v['name'], 'cover' => $v['cover'], 'spe_price_id' => $v['spe_price_id'], 'content' => $v['spe'], 'number' => $v['number'], 'price' => $v['price'], 'uniacid' => $uniacid, 'create_time' => $time, 'update_time' => $time,'company_id' => $v['company_id'],'trip_time' => $v['trip_time'],'company_name' => $v['company_name']);
$result = pdo_insert('longbing_company_shop_order_item', $insertItem);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment