更新购物车

parent 3a60cc79
......@@ -10,6 +10,7 @@ use App\Models\InquiryModel;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Models\CartModel;
use Mockery\Exception;
//购物车服务器层
class CartService
......@@ -48,7 +49,6 @@ class CartService
$temp["raw_brand_name"]= $digikeyArr["raw_brand_name"];
}
//购买时价格
$buy_price = 0;
$ladder_price = data_get($skuInfo,"ladder_price");
......@@ -65,7 +65,7 @@ class CartService
$temp["buy_price"] = $buy_price;
if ($buy_number < \Arr::get($skuInfo,"moq") || $buy_number > $skuInfo["stock"] ){
return false;
throw new Exception("error moq",1001);
}
$temp["buy_number"] = $buy_number;
......@@ -77,18 +77,18 @@ class CartService
$flag = CartModel::where(["cart_id"=>$checkHas["cart_id"]])->update($temp);
if (!$flag){
return false;
throw new Exception("error update",1002);
}
}else{ //不存在插入购物车
$temp["user_id"] = $user_id;
$temp["gid"] = $gid;
$temp["gid"] = $user_id > 0 ? "":$gid;
$temp["status"] = $buy_number > 0 ? CartModel::status_yes:CartModel::status_no;
$temp["create_time"] = time();
$temp["update_time"] = time();
$cart_id = CartModel::insertGetId($temp);
if (!$cart_id){
return false;
throw new Exception("error add",1003);
}
}
......@@ -112,7 +112,8 @@ class CartService
return $te;
}catch (\Exception $e){
$con->rollback();
throw new InvalidRequestException($e->getMessage().$e->getLine());
# throw new InvalidRequestException($e->getMessage().$e->getLine());
return false;
}
}
......@@ -174,7 +175,7 @@ class CartService
$temp["status"] = $v["buy_number"] > 0 ? CartModel::status_yes:CartModel::status_no;
$flag = CartModel::where(["cart_id"=>$checkHas["cart_id"]])->update($temp);
if (!$flag){
return false;
throw new Exception("error update",1003);
}
}else{ //不存在插入购物车
$temp["buy_number"] = $skuInfo["stock"] > $v['buy_number'] ? $v['buy_number'] : $skuInfo["stock"];
......@@ -184,7 +185,7 @@ class CartService
$flag = CartModel::insertGetId($temp);
if (!$flag){
return false;
throw new Exception("error add",1003);
}
}
}
......@@ -194,7 +195,8 @@ class CartService
return true;
}catch (\Exception $e){
$con->rollback();
throw new InvalidRequestException($e->getMessage().$e->getLine());
#throw new InvalidRequestException($e->getMessage().$e->getLine());
return false;
}
}
......
......@@ -354,7 +354,7 @@ class OrderService
$where["order_id"] = $order_id;
if ($user_id >0){
$where["user_id"] = $user_id;
// $where["user_id"] = $user_id;
}
$orderInfo = OrderModel::getOrderInfo($where);
if (!$orderInfo){
......
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 sign in to comment