Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
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
47b47c2a
authored
Nov 07, 2018
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整自营下单(现货/期货)
parent
3e5ffe84
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
78 deletions
app/Http/Controllers/AddOrderController.php
public/js/add_order.js
app/Http/Controllers/AddOrderController.php
View file @
47b47c2a
...
...
@@ -446,6 +446,7 @@ Class AddOrderController extends Controller
{
if
(
$request
->
isMethod
(
'post'
))
{
$cart_info
=
json_decode
(
$request
->
input
(
'cart_info'
,
''
),
true
);
$sale_type
=
$request
->
input
(
'sale_type'
,
1
);
$data
[
'k1'
]
=
time
();
$data
[
'k2'
]
=
md5
(
md5
(
$data
[
'k1'
])
.
'fh6y5t4rr351d2c3bryi'
);
...
...
@@ -459,16 +460,27 @@ Class AddOrderController extends Controller
$response
=
json_decode
(
curlApi
(
$url
,
$data
),
true
);
// 判断下单数量是否小于库存,若小于则弹出提示信息
if
(
$v
[
'num'
]
<
$response
[
'data'
][
'goods_number'
])
{
$temp
[
'goods_name'
]
=
$response
[
'data'
][
'goods_name'
];
// 型号
$temp
[
'stock'
]
=
$response
[
'data'
][
'goods_number'
];
// 可用库存
$warning_arr
[]
=
$temp
;
if
(
$sale_type
==
1
)
{
// 现货订单--判断下单数量是否大于库存,若大于则弹出提示信息
if
(
$v
[
'num'
]
>
$response
[
'data'
][
'goods_number'
])
{
$temp
[
'goods_name'
]
=
$response
[
'data'
][
'goods_name'
];
// 型号
$temp
[
'stock'
]
=
$response
[
'data'
][
'goods_number'
];
// 可用库存
$warning_arr
[]
=
$temp
;
$errmsg
=
'库存不足,建议设置为期货类型'
;
}
}
else
{
// 期货订单--判断下单数量是否小于库存,若小于则弹出提示信息
if
(
$v
[
'num'
]
<
$response
[
'data'
][
'goods_number'
])
{
$temp
[
'goods_name'
]
=
$response
[
'data'
][
'goods_name'
];
// 型号
$temp
[
'stock'
]
=
$response
[
'data'
][
'goods_number'
];
// 可用库存
$warning_arr
[]
=
$temp
;
$errmsg
=
'您提交的数量有实际库存,建议直接购买现货'
;
}
}
}
if
(
!
empty
(
$warning_arr
))
{
return
[
'errcode'
=>
-
1
,
'errmsg'
=>
'所购商品数量小于可用库存'
,
'data'
=>
json_encode
(
$warning_arr
)];
return
[
'errcode'
=>
-
1
,
'errmsg'
=>
$errmsg
,
'data'
=>
json_encode
(
$warning_arr
)];
}
return
[
'errcode'
=>
0
,
'errmsg'
=>
''
];
...
...
@@ -496,14 +508,11 @@ Class AddOrderController extends Controller
$data
[
'sale_type'
]
=
$request
->
input
(
'sale_type'
,
''
);
// 自营线上选择销售类型
$data
[
'k1'
]
=
time
();
$data
[
'k2'
]
=
md5
(
md5
(
$data
[
'k1'
])
.
'fh6y5t4rr351d2c3bryi'
);
$url
=
Config
(
'website.api_domain'
)
.
'order/create'
;
// echo '<pre>';
// print_r(curlApi($url, $data));die;
$response
=
json_decode
(
curlApi
(
$url
,
$data
),
true
);
if
(
$response
[
'err_code'
]
==
0
)
{
...
...
public/js/add_order.js
View file @
47b47c2a
...
...
@@ -533,6 +533,7 @@
})
if
(
cart_ids
.
length
>
0
)
{
var
submit
=
true
;
var
datax
=
{
uid
:
user_id
,
sale_id
:
sale_id
,
...
...
@@ -568,80 +569,64 @@
if
(
type
==
2
)
{
var
sale_type
=
$
(
'#sale_type'
).
val
();
if
(
sale_type
==
2
)
{
// 选择期货
var
cart_info
=
[];
var
cart_info
=
[];
$
(
'.shop-table tbody tr'
).
each
(
function
()
{
var
gid
=
$
(
this
).
find
(
'.goods_id'
).
text
();
var
num
=
$
(
this
).
find
(
'.goods_num'
).
val
();
$
(
'.shop-table tbody tr'
).
each
(
function
()
{
var
gid
=
$
(
this
).
find
(
'.goods_id'
).
text
();
var
num
=
$
(
this
).
find
(
'.goods_num'
).
val
();
cart_info
.
push
({
'gid'
:
gid
,
'num'
:
num
});
})
cart_info
.
push
({
'gid'
:
gid
,
'num'
:
num
});
})
$
.
ajax
({
type
:
"POST"
,
url
:
'/ajax/checkStock'
,
data
:
{
cart_info
:
JSON
.
stringify
(
cart_info
),
num
:
11
},
dataType
:
"json"
,
success
:
function
(
resp
){
if
(
resp
.
errcode
==
-
1
)
{
var
data
=
eval
(
resp
.
data
);
var
content
=
'<p>确定设置以下型号为期货吗?</p>'
;
$
.
ajax
({
type
:
"POST"
,
url
:
'/ajax/checkStock'
,
data
:
{
cart_info
:
JSON
.
stringify
(
cart_info
),
sale_type
:
sale_type
},
dataType
:
"json"
,
async
:
false
,
success
:
function
(
resp
){
if
(
resp
.
errcode
==
-
1
)
{
var
data
=
eval
(
resp
.
data
);
var
content
=
'<p>'
+
resp
.
errmsg
+
'</p>'
;
submit
=
false
;
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
content
+=
'<p><span>'
+
(
i
+
1
)
+
'、</span>'
+
data
[
i
][
'goods_name'
]
+
',可用库存:'
+
data
[
i
][
'stock'
]
+
'</p>'
;
}
// 弹出提示
layer
.
open
({
area
:
[
'500px'
,
'300px'
],
title
:
'提示信息'
,
content
:
content
,
btn
:[
'确定'
,
'取消'
],
yes
:
function
(
index
,
layero
){
$
.
ajax
({
type
:
"POST"
,
url
:
'/ajax/create'
,
data
:
datax
,
dataType
:
"json"
,
success
:
function
(
resp
){
if
(
resp
.
errcode
==
0
)
{
layer
.
msg
(
resp
.
errmsg
);
location
.
href
=
'/addorder/success?order_id='
+
resp
.
data
.
order_id
+
'&type='
+
resp
.
data
.
type
;
}
layer
.
msg
(
resp
.
errmsg
);
},
})
},
btn2
:
function
(
index
,
layero
){
layer
.
close
(
index
);
}
});
}
},
})
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
content
+=
'<p><span>'
+
(
i
+
1
)
+
'、</span>'
+
data
[
i
][
'goods_name'
]
+
',可用库存:'
+
data
[
i
][
'stock'
]
+
'</p>'
;
}
return
false
;
}
}
$
.
ajax
({
type
:
"POST"
,
url
:
'/ajax/create'
,
data
:
datax
,
dataType
:
"json"
,
success
:
function
(
resp
){
if
(
resp
.
errcode
==
0
)
{
layer
.
msg
(
resp
.
errmsg
);
location
.
href
=
'/addorder/success?order_id='
+
resp
.
data
.
order_id
+
'&type='
+
resp
.
data
.
type
;
return
false
;
}
// 弹出提示
layer
.
open
({
area
:
[
'500px'
,
'300px'
],
title
:
'提示信息'
,
content
:
content
,
btn
:
[],
});
layer
.
alert
(
resp
.
errmsg
);
},
})
return
false
;
}
},
})
}
if
(
submit
)
{
$
.
ajax
({
type
:
"POST"
,
url
:
'/ajax/create'
,
data
:
datax
,
dataType
:
"json"
,
success
:
function
(
resp
){
if
(
resp
.
errcode
==
0
)
{
layer
.
msg
(
resp
.
errmsg
);
location
.
href
=
'/addorder/success?order_id='
+
resp
.
data
.
order_id
+
'&type='
+
resp
.
data
.
type
;
return
false
;
}
layer
.
alert
(
resp
.
errmsg
);
},
})
}
}
else
{
layer
.
msg
(
'请先添加商品'
);
}
...
...
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