Commit 73677bf6 by 杨树贤

Merge branch 'dev/ver/1.0.0' of http://git.ichunt.net/semour/semour_web into dev/ver/1.0.0

parents 430e09f8 e270b244
......@@ -60,7 +60,7 @@ class CartApiController extends Controller
//购物车列表
public function cartLists(Request $request){
$result = CartService::cartLists($request->user->id,$request->user->gid);
$result = CartService::cartLists($request->user->id,$request->user->gid,$request->input("cart_ids",0));
return $this->setSuccessData($result);
}
......
......@@ -62,17 +62,21 @@ class CartService
$temp["buy_price"] = $buy_price;
$checkHas = CartModel::where(["user_id"=>$user_id,"goods_id"=>$goods_id,"status"=>1])->first();
$temp["buy_number"] = $skuInfo["stock"] > $buy_number ? $buy_number : $skuInfo["stock"];
if ($checkHas){
$buy_number = $buy_number+$checkHas["buy_number"];
$cart_id = $checkHas["cart_id"];
$temp["update_time"] = time();
$temp["status"] = $buy_number > 0 ? CartModel::status_yes:CartModel::status_no;
$temp["buy_number"] = $skuInfo["stock"] > $buy_number ? $buy_number : $skuInfo["stock"];
$flag = CartModel::where(["cart_id"=>$checkHas["cart_id"]])->update($temp);
if (!$flag){
return false;
}
}else{ //不存在插入购物车
$temp["buy_number"] = $skuInfo["stock"] > $buy_number ? $buy_number : $skuInfo["stock"];
$temp["status"] = $buy_number > 0 ? CartModel::status_yes:CartModel::status_no;
$temp["create_time"] = time();
$temp["update_time"] = time();
......@@ -187,8 +191,7 @@ class CartService
/*
* 刷新购物车并且返回列表
*/
public static function cartLists($user_id,$gid="",$page_size=400,$page=1){
public static function cartLists($user_id,$gid="",$cart_ids=0,$page_size=400,$page=1){
//当前用户所有可用的购物车数据
if (!$user_id && !$gid){
return [];
......@@ -201,6 +204,9 @@ class CartService
}
$query = CartModel::where($where)->wherein("status",[CartModel::status_no,CartModel::status_yes])->orderBy('status', 'desc');
if($cart_ids){
$query = $query->wherein("cart_id",explode(",",$cart_ids));
}
$res = $query->paginate($page_size, ['*'], 'page', $page)->toArray();
$result = $res["data"];
......
......@@ -44,6 +44,7 @@ class OrderService
$billing_address_id = $data["billing_address_id"]; //账单地址
$items = json_decode(\Arr::get($data, 'items', []),true);
//查询用户详情
$userInfo = UserModel::getUserInfo($user_id);
$order_sn = self::createOrderSn();
......
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