购物

parent 13fea70d
...@@ -67,14 +67,14 @@ class CartService ...@@ -67,14 +67,14 @@ class CartService
if ($checkHas){ //存在累计库存 if ($checkHas){ //存在累计库存
$temp["buy_number"] = $skuInfo["stock"] > ($v['buy_number']+$checkHas["buy_number"]) ? $v['buy_number']+$checkHas["buy_number"] : $skuInfo["stock"]; $temp["buy_number"] = $skuInfo["stock"] > ($v['buy_number']+$checkHas["buy_number"]) ? $v['buy_number']+$checkHas["buy_number"] : $skuInfo["stock"];
$temp["update_time"] = time(); $temp["update_time"] = time();
$temp["status"] = $v["buy_number"] > 0 ? CartModel::STATUS_YES:CartModel::STATUS_NO; $temp["status"] = $v["buy_number"] > 0 ? CartModel::status_yes:CartModel::status_no;
$flag = CartModel::where(["cart_id"=>$checkHas["cart_id"]])->update($temp); $flag = CartModel::where(["cart_id"=>$checkHas["cart_id"]])->update($temp);
if (!$flag){ if (!$flag){
return false; return false;
} }
}else{ //不存在插入购物车 }else{ //不存在插入购物车
$temp["buy_number"] = $skuInfo["stock"] > $v['buy_number'] ? $v['buy_number'] : $skuInfo["stock"]; $temp["buy_number"] = $skuInfo["stock"] > $v['buy_number'] ? $v['buy_number'] : $skuInfo["stock"];
$temp["status"] = $v["buy_number"] > 0 ? CartModel::STATUS_YES:CartModel::STATUS_NO; $temp["status"] = $v["buy_number"] > 0 ? CartModel::status_yes:CartModel::status_no;
$temp["create_time"] = time(); $temp["create_time"] = time();
$temp["update_time"] = time(); $temp["update_time"] = time();
......
...@@ -10,18 +10,8 @@ class CartModel extends Model ...@@ -10,18 +10,8 @@ class CartModel extends Model
protected $table = 'cart'; protected $table = 'cart';
public $timestamps = false; public $timestamps = false;
const STATUS_NO = -1; //状态禁用 const status_no = -1; //状态禁用
const STATUS_YES = 1; //状态启动 const status_yes = 1; //状态启动
//查询购物车数据
public static function getCartInfo($user_id)
{
$map = [
"user_id" => $user_id
];
$res = self::where($map)->first();
return ($res) ? $res->toArray() : [];
}
} }
...@@ -10,21 +10,35 @@ class OrderModel extends Model ...@@ -10,21 +10,35 @@ class OrderModel extends Model
protected $primaryKey = 'order_id'; protected $primaryKey = 'order_id';
public $timestamps = false; public $timestamps = false;
//添加购物车 //已取消 -1 Cancelled
public static function addCart() //待审核 1 Waiting for approval
{ //待付款 2 Waiting for payment
//待付尾款 3
//待发货 4 Waiting for dispatch
} //部分发货 7
//待收货 8 Waiting for delivery
//查询购物车数据 //已完成 10 Transaction Complete
public static function getOrderInfoByrderSn($order_sn) const status_cancel = -1;
{ const status_waiting_approval = 1;
$map = [ const status_waiting_pay =2 ;
"order_sn" => $order_sn const status_waiting_end_pay =3 ;
]; const status_waiting_send =4 ;
$res = self::where($map)->first(); const status_waiting_half_send =7 ;
return ($res) ? $res->toArray() : []; const status_waiting_delivery =8 ;
} const status_complete =10 ;
static $status = [
self::status_cancel => "Cancelled",
self::status_waiting_approval => "Waiting for approval",
self::status_waiting_pay => "Waiting for payment",
self::status_waiting_end_pay => "",
self::status_waiting_send => " Waiting for dispatch",
self::status_waiting_half_send => "",
self::status_waiting_delivery => "Waiting for delivery",
self::status_complete => "Transaction Complete",
];
} }
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