Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3b56a1ac
authored
Nov 10, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
购物
parent
13fea70d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
27 deletions
app/Http/Services/CartService.php
app/Http/Services/OrderService.php
app/Models/CartModel.php
app/Models/OrderModel.php
app/Http/Services/CartService.php
View file @
3b56a1ac
...
...
@@ -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
();
...
...
app/Http/Services/OrderService.php
0 → 100644
View file @
3b56a1ac
This diff is collapsed.
Click to expand it.
app/Models/CartModel.php
View file @
3b56a1ac
...
...
@@ -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
;
//状态启动
}
app/Models/OrderModel.php
View file @
3b56a1ac
...
...
@@ -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
()
:
[];
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment