购物

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