Commit 724cc73f by 朱继来

Merge branch 'zjl_qihuo_20181015' into development

parents 92350303 47b47c2a
...@@ -446,6 +446,7 @@ Class AddOrderController extends Controller ...@@ -446,6 +446,7 @@ Class AddOrderController extends Controller
{ {
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
$cart_info = json_decode($request->input('cart_info', ''), true); $cart_info = json_decode($request->input('cart_info', ''), true);
$sale_type = $request->input('sale_type', 1);
$data['k1'] = time(); $data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi'); $data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
...@@ -459,16 +460,27 @@ Class AddOrderController extends Controller ...@@ -459,16 +460,27 @@ Class AddOrderController extends Controller
$response = json_decode(curlApi($url, $data), true); $response = json_decode(curlApi($url, $data), true);
// 判断下单数量是否小于库存,若小于则弹出提示信息 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']) { if ($v['num'] < $response['data']['goods_number']) {
$temp['goods_name'] = $response['data']['goods_name']; // 型号 $temp['goods_name'] = $response['data']['goods_name']; // 型号
$temp['stock'] = $response['data']['goods_number']; // 可用库存 $temp['stock'] = $response['data']['goods_number']; // 可用库存
$warning_arr[] = $temp; $warning_arr[] = $temp;
$errmsg = '您提交的数量有实际库存,建议直接购买现货';
}
} }
} }
if (!empty($warning_arr)) { 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' => '']; return ['errcode' => 0, 'errmsg' => ''];
...@@ -496,14 +508,11 @@ Class AddOrderController extends Controller ...@@ -496,14 +508,11 @@ Class AddOrderController extends Controller
$data['sale_type'] = $request->input('sale_type', ''); // 自营线上选择销售类型 $data['sale_type'] = $request->input('sale_type', ''); // 自营线上选择销售类型
$data['k1'] = time(); $data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi'); $data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$url = Config('website.api_domain').'order/create'; $url = Config('website.api_domain').'order/create';
// echo '<pre>';
// print_r(curlApi($url, $data));die;
$response = json_decode(curlApi($url, $data), true); $response = json_decode(curlApi($url, $data), true);
if ($response['err_code'] == 0) { if ($response['err_code'] == 0) {
......
...@@ -533,6 +533,7 @@ ...@@ -533,6 +533,7 @@
}) })
if (cart_ids.length > 0) { if (cart_ids.length > 0) {
var submit = true;
var datax = { var datax = {
uid: user_id, uid: user_id,
sale_id: sale_id, sale_id: sale_id,
...@@ -568,7 +569,7 @@ ...@@ -568,7 +569,7 @@
if (type == 2) { if (type == 2) {
var sale_type = $('#sale_type').val(); var sale_type = $('#sale_type').val();
if (sale_type == 2) { // 选择期货
var cart_info = []; var cart_info = [];
$('.shop-table tbody tr').each(function() { $('.shop-table tbody tr').each(function() {
...@@ -581,12 +582,14 @@ ...@@ -581,12 +582,14 @@
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '/ajax/checkStock', url: '/ajax/checkStock',
data: {cart_info: JSON.stringify(cart_info), num: 11}, data: {cart_info: JSON.stringify(cart_info), sale_type: sale_type},
dataType: "json", dataType: "json",
async: false,
success: function(resp){ success: function(resp){
if (resp.errcode == -1) { if (resp.errcode == -1) {
var data = eval(resp.data); var data = eval(resp.data);
var content = '<p>确定设置以下型号为期货吗?</p>'; var content = '<p>'+resp.errmsg+'</p>';
submit = false;
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
content += '<p><span>'+(i+1)+'、</span>'+data[i]['goods_name']+',可用库存:'+data[i]['stock']+'</p>'; content += '<p><span>'+(i+1)+'、</span>'+data[i]['goods_name']+',可用库存:'+data[i]['stock']+'</p>';
...@@ -597,35 +600,16 @@ ...@@ -597,35 +600,16 @@
area: ['500px', '300px'], area: ['500px', '300px'],
title: '提示信息', title: '提示信息',
content: content, content: content,
btn:['确定', '取消'], 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);
}
}); });
}
},
})
return false; return false;
} }
},
})
} }
if (submit) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '/ajax/create', url: '/ajax/create',
...@@ -642,6 +626,7 @@ ...@@ -642,6 +626,7 @@
layer.alert(resp.errmsg); layer.alert(resp.errmsg);
}, },
}) })
}
} else { } else {
layer.msg('请先添加商品'); layer.msg('请先添加商品');
} }
......
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