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']; // 型号 if ($v['num'] > $response['data']['goods_number']) {
$temp['stock'] = $response['data']['goods_number']; // 可用库存 $temp['goods_name'] = $response['data']['goods_name']; // 型号
$warning_arr[] = $temp; $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)) { 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,80 +569,64 @@ ...@@ -568,80 +569,64 @@
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() {
var gid = $(this).find('.goods_id').text(); var gid = $(this).find('.goods_id').text();
var num = $(this).find('.goods_num').val(); var num = $(this).find('.goods_num').val();
cart_info.push({'gid':gid, 'num':num}); cart_info.push({'gid':gid, 'num':num});
}) })
$.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",
success: function(resp){ async: false,
if (resp.errcode == -1) { success: function(resp){
var data = eval(resp.data); if (resp.errcode == -1) {
var content = '<p>确定设置以下型号为期货吗?</p>'; var data = eval(resp.data);
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>';
} }
// 弹出提示
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);
}
});
}
},
})
return false; // 弹出提示
} layer.open({
} area: ['500px', '300px'],
title: '提示信息',
$.ajax({ content: content,
type: "POST", btn: [],
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); 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 { } 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