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
f218d094
authored
Nov 10, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
购物车
parent
9ffe949b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
app/Http/Controllers/Api/CartApiController.php
app/Http/Services/CartService.php
app/helpers.php
app/Http/Controllers/Api/CartApiController.php
View file @
f218d094
...
@@ -44,6 +44,7 @@ class CartApiController extends Controller
...
@@ -44,6 +44,7 @@ class CartApiController extends Controller
//购物车列表
//购物车列表
public
function
cartLists
(
Request
$request
){
public
function
cartLists
(
Request
$request
){
$result
=
CartService
::
cartLists
(
$request
->
user
->
id
);
$result
=
CartService
::
cartLists
(
$request
->
user
->
id
);
return
$this
->
setSuccessData
(
$result
);
}
}
...
...
app/Http/Services/CartService.php
View file @
f218d094
This diff is collapsed.
Click to expand it.
app/helpers.php
View file @
f218d094
...
@@ -61,3 +61,40 @@ function numberToHtml($number){
...
@@ -61,3 +61,40 @@ function numberToHtml($number){
return
$number
;
return
$number
;
}
}
}
}
/**
* 生成纯小写字母的字符串
*
*/
function
strRandom
(
$class
=
''
,
$len_num
=
3
){
$randstr
=
'asdwpkxmiqplmzacbmeruwulurjlauejrifkfghjklzxcvbnmqwwertyuiopkdsieurnvewjeilweiskvnx'
;
$len
=
strlen
(
$randstr
)
-
9
;
$res
=
''
;
for
(
$i
=
0
;
$i
<
$len_num
;
$i
++
){
$start
=
rand
(
0
,
$len
);
$str
=
substr
(
$randstr
,
$start
,
9
);
$res
.=
' '
.
$str
;
}
return
$res
;
}
/*
* 计算最大购买数量
*/
function
getMaxBuyStock
(
$stock
,
$multiple
,
$ladder_price
){
//todo 2022.9.27 计算最大购买数量
$max_buy_stock
=
0
;
if
(
$stock
>
0
&&
$multiple
>
0
){
$max_buy_stock1
=
intval
(
$stock
/
$multiple
)
*
$multiple
;
//库存最大购买数量
if
(
$ladder_price
){
//梯度价库存最大购买数量
$max_pur_num
=
@
$ladder_price
[
count
(
$ladder_price
)
-
1
][
"purchases"
];
$max_buy_stock2
=
intval
(
$max_pur_num
/
$multiple
)
*
$multiple
;
//库存最大购买数量
$max_buy_stock
=
$max_buy_stock1
>
$max_buy_stock2
?
$max_buy_stock2
:
$max_buy_stock1
;
}
else
{
$max_buy_stock
=
$max_buy_stock1
;
}
}
return
$max_buy_stock
;
}
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