Commit 2242d556 by 朱继来

调整自营下单提示信息

parent 9e736fdd
......@@ -449,20 +449,23 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'goods/detail';
$err_name = array();
$warning_arr = array();
foreach ($cart_info as $k=>$v) {
$data['id'] = $v['gid'];
$response = json_decode(curlApi($url, $data), true);
// 判断下单数量是否小于库存,若小于则弹出提示信息
if ($v['num'] < $response['data']['goods_number']) {
$err_name[] = $response['data']['goods_name'];
$temp['goods_name'] = $response['data']['goods_name']; // 型号
$temp['stock'] = $response['data']['goods_number']; // 可用库存
$warning_arr[] = $temp;
}
}
if (!empty($err_name)) {
return ['errcode' => -1, 'errmsg' => '所购商品数量小于可用库存', 'data'=>$err_name];
if (!empty($warning_arr)) {
return ['errcode' => -1, 'errmsg' => '所购商品数量小于可用库存', 'data'=>json_encode($warning_arr)];
}
return ['errcode' => 0, 'errmsg' => ''];
......
......@@ -560,11 +560,11 @@
dataType: "json",
success: function(resp){
if (resp.errcode == -1) {
var data = resp.data;
var data = eval(resp.data);
var content = '<p>确定设置以下型号为期货吗?</p>';
for (var i = 0; i < data.length; i++) {
content += '<p><span>'+(i+1)+'、</span>'+data[i]+'</p>';
content += '<p><span>'+(i+1)+'、</span>'+data[i]['goods_name']+',可用库存:'+data[i]['stock']+'</p>';
}
// 弹出提示
......
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