|
|
|
@ -124,9 +124,7 @@ class Goods extends Controller |
|
|
|
|
case 'jd': |
|
|
|
|
case 'jd1': |
|
|
|
|
case 'jd2': |
|
|
|
|
case 'zy': |
|
|
|
|
$province = Region::withoutGlobalScope()->where('name', $params['province'])->where('level', 1)->find(); |
|
|
|
|
//$city = Region::withoutGlobalScope()->where('name', $params['city'])->where('level', 2)->find(); |
|
|
|
|
$district = Region::withoutGlobalScope()->where('name', $params['district'])->where('level', 3)->find(); |
|
|
|
|
$jd = new \app\common\service\Jd(); |
|
|
|
|
$arr = []; |
|
|
|
@ -152,16 +150,43 @@ class Goods extends Controller |
|
|
|
|
]; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
if ($goods->stock_total >= ($value['num'] ?? 1)) { |
|
|
|
|
$res = "有货"; |
|
|
|
|
if ($goods->is_use_jd_stock) {//是否使用京东库存 |
|
|
|
|
$province = Region::withoutGlobalScope()->where('name', $params['province'])->where('level', 1)->find(); |
|
|
|
|
$district = Region::withoutGlobalScope()->where('name', $params['district'])->where('level', 3)->find(); |
|
|
|
|
$jd = new \app\common\service\Jd(); |
|
|
|
|
$arr = []; |
|
|
|
|
|
|
|
|
|
$ret = $jd->getGoodsStock($province->jd_code, $city->jd_code, $district->jd_code, $goods['goods_no'], $value['num'] ?? 1); |
|
|
|
|
// echo "<pre>"; |
|
|
|
|
// print_r($ret); |
|
|
|
|
//var_dump($ret); |
|
|
|
|
if ($ret) { |
|
|
|
|
$res = $ret['stockResp']['desc'] ?? "无货"; |
|
|
|
|
if (strpos($res, "无货") !== false) { |
|
|
|
|
$res = "无货"; |
|
|
|
|
} elseif (strpos($res, "有货") == false) { |
|
|
|
|
$res = "有货"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$data = [ |
|
|
|
|
'state' => $res, |
|
|
|
|
'goods_name' => $goods['goods_name'], |
|
|
|
|
'goods_id' => $goods['goods_id'], |
|
|
|
|
//'promise_info' => $ret['promiseInfo'] ?? "预计72小时内发货", |
|
|
|
|
'promise_info' => "预计48小时内发货", |
|
|
|
|
]; |
|
|
|
|
} else { |
|
|
|
|
if ($goods->stock_total >= ($value['num'] ?? 1)) { |
|
|
|
|
$res = "有货"; |
|
|
|
|
} |
|
|
|
|
$data = [ |
|
|
|
|
'state' => $res, |
|
|
|
|
'goods_name' => $goods['goods_name'], |
|
|
|
|
'goods_id' => $goods['goods_id'], |
|
|
|
|
'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']]['name'] ?? "72小时")."内发货", |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
$data = [ |
|
|
|
|
'state' => $res, |
|
|
|
|
'goods_name' => $goods['goods_name'], |
|
|
|
|
'goods_id' => $goods['goods_id'], |
|
|
|
|
'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']]['name'] ?? "72小时")."内发货", |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|