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
fcb9b58d
authored
Nov 11, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
订单添加
parent
64fa34fc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
2 deletions
app/Http/Services/OrderService.php
app/Models/OrderModel.php
app/Models/UserModel.php
app/helpers.php
app/Http/Services/OrderService.php
View file @
fcb9b58d
...
@@ -8,6 +8,7 @@ use App\Models\Inquiry;
...
@@ -8,6 +8,7 @@ use App\Models\Inquiry;
use
App\Models\InquiryItems
;
use
App\Models\InquiryItems
;
use
App\Models\InquiryItemsModel
;
use
App\Models\InquiryItemsModel
;
use
App\Models\InquiryModel
;
use
App\Models\InquiryModel
;
use
App\Models\UserModel
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Redis
;
use
Illuminate\Support\Facades\Redis
;
use
App\Models\CartModel
;
use
App\Models\CartModel
;
...
@@ -19,6 +20,9 @@ class OrderService
...
@@ -19,6 +20,9 @@ class OrderService
public
static
function
addOrder
(
$data
,
$user_id
)
public
static
function
addOrder
(
$data
,
$user_id
)
{
{
$vs
=
json_decode
(
\Arr
::
get
(
$data
,
'items'
,
[]),
true
);
$vs
=
json_decode
(
\Arr
::
get
(
$data
,
'items'
,
[]),
true
);
//查询用户详情
$userInfo
=
UserModel
::
getUserInfo
(
$user_id
);
try
{
try
{
$con
=
DB
::
connection
();
$con
=
DB
::
connection
();
$redis
=
Redis
::
connection
();
$redis
=
Redis
::
connection
();
...
@@ -28,7 +32,14 @@ class OrderService
...
@@ -28,7 +32,14 @@ class OrderService
#订单主表
#订单主表
$mainData
=
[
$mainData
=
[
"order_sn"
=>
11
,
"order_sn"
=>
11
,
""
=>
""
,
"sem_order"
=>
self
::
createOrderSn
(),
"user_id"
=>
$user_id
,
"company_name"
=>
$userInfo
[
"company_name"
],
"exchange_rate"
=>
getRate
(),
"currency"
=>
2
,
"order_remark"
=>
data_get
(
$data
,
"order_remark"
),
"create_time"
=>
time
(),
"update_time"
=>
time
(),
];
];
$order_id
=
OrderModel
::
insertGetId
(
$mainData
);
$order_id
=
OrderModel
::
insertGetId
(
$mainData
);
...
@@ -94,7 +105,17 @@ class OrderService
...
@@ -94,7 +105,17 @@ class OrderService
}
}
}
}
//刷新购物车并且返回列表
//生成订单单号
public
static
function
createOrderSn
(
$pre
=
"SE"
){
$order_sn
=
$pre
.
date
(
"Y-m-d"
)
.
rand
(
1000
,
9999
);
$check
=
OrderModel
::
getOrderInfo
([
"order_sn"
=>
$order_sn
]);
if
(
$check
){
self
::
createOrderSn
();
}
return
$order_sn
;
}
//订单列表
public
static
function
orderLists
(
$user_id
){
public
static
function
orderLists
(
$user_id
){
//当前用户所有可用的购物车数据
//当前用户所有可用的购物车数据
...
...
app/Models/OrderModel.php
View file @
fcb9b58d
...
@@ -37,6 +37,12 @@ class OrderModel extends Model
...
@@ -37,6 +37,12 @@ class OrderModel extends Model
self
::
status_complete
=>
"Transaction Complete"
,
self
::
status_complete
=>
"Transaction Complete"
,
];
];
//获取订单详情
public
static
function
getOrderInfo
(
$where
)
{
$res
=
self
::
where
(
$where
)
->
first
();
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
...
...
app/Models/UserModel.php
View file @
fcb9b58d
...
@@ -53,4 +53,14 @@ class UserModel extends Authenticatable implements MustVerifyEmail
...
@@ -53,4 +53,14 @@ class UserModel extends Authenticatable implements MustVerifyEmail
'password'
=>
Hash
::
make
(
$data
[
'password'
]),
'password'
=>
Hash
::
make
(
$data
[
'password'
]),
]);
]);
}
}
//获取用户详情
public
static
function
getUserInfo
(
$user_id
)
{
$map
=
[
"id"
=>
$user_id
];
$res
=
self
::
where
(
$map
)
->
first
();
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
}
}
app/helpers.php
View file @
fcb9b58d
<?php
<?php
use
Illuminate\Support\Facades\Redis
;
function
test_helper
()
function
test_helper
()
{
{
return
'OK'
;
return
'OK'
;
...
@@ -98,3 +100,12 @@ function getMaxBuyStock($stock,$multiple,$ladder_price){
...
@@ -98,3 +100,12 @@ function getMaxBuyStock($stock,$multiple,$ladder_price){
}
}
return
$max_buy_stock
;
return
$max_buy_stock
;
}
}
/*
* 获取汇率,兑换人民币汇率
*/
public
function
getRate
(
$k
=
"美元"
)
{
$redis
=
Redis
::
connection
();
return
$redis
->
hget
(
'erp_rate'
,
$k
);
}
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