@ -77,48 +77,63 @@ class Goods extends Controller
{
{
// wmc商品详情
// wmc商品详情
$params = $this->request->param();
$params = $this->request->param();
$goods = GoodsModel::where('goods_id', $params['goods_id'])->find();
if (!$params['list'] || !$params['province'] || !$params['city'] || !$params['district']) {
if (!$goods) {
return $this->renderError('参数错误!');
return $this->renderError('商品不存在');
}
}
$return = [];
$res = "无货";
foreach ($params['list'] as $value) {
switch ($goods->channel) {
$res = "无货";
case 'sn':
$goods = GoodsModel::where('goods_id', $value['goods_id'])->find();
$city = Region::where('name',$params['city'])->where('level',2)->find();
switch ($goods->channel) {
$district = Region::where('name',$params['district'])->where('level',3)->find();
case 'sn':
$suning = new \app\common\service\Suning();
$city = Region::where('name',$params['city'])->where('level',2)->find();
$goods->num = $param['num'] ?? 1;
$district = Region::where('name',$params['district'])->where('level',3)->find();
$ret = $suning->shoppingCartPrice([$goods->toArray()], $city->sn_code, $district->sn_code);
// var_dump($city);
if ($ret & & $ret[0]['state'] == 1) {
// var_dump($district);
$res = "有货";
$suning = new \app\common\service\Suning();
}
$goods->num = $param['num'] ?? 1;
break;
$data = $suning->shoppingCartPrice([$goods->toArray()], $city->sn_code, $district->sn_code);
case 'jd':
$data['goods_name'] = $goods['goods_name'];
$province = Region::where('name',$params['province'])->where('level',1)->find();
$data['goods_id'] = $goods['goods_id'];
$city = Region::where('name',$params['city'])->where('level',2)->find();
break;
$district = Region::where('name',$params['district'])->where('level',3)->find();
case 'jd':
$jd = new \app\common\service\Jd();
$province = Region::where('name',$params['province'])->where('level',1)->find();
$goods->num = $params['num'] ?? 1;
$city = Region::where('name',$params['city'])->where('level',2)->find();
$ret = $jd->getGoodsStock($province->jd_code, $city->jd_code, $district->jd_code, $goods['goods_no'], $params['num'] ?? 1);
$district = Region::where('name',$params['district'])->where('level',3)->find();
$res = $ret['stockResp']['desc'];
$jd = new \app\common\service\Jd();
if (strpos($res, "无货") == true) {
$arr = [];
$res = "无货";
} elseif (strpos($res, "有货") == true) {
$ret = $jd->getGoodsStock($province->jd_code, $city->jd_code, $district->jd_code, $goods['goods_no'], $value['num'] ?? 1);
$res = "有货";
if ($ret) {
}
$res = $ret['stockResp']['desc'];
// echo "< pre > ";
if (strpos($res, "无货") !== false) {
// print_r($ret);
$res = "无货";
// exit;
} elseif (strpos($res, "有货") == false) {
$res = "有货";
break;
}
default:
}
if ($goods->stock_total > ($params['num'] ?? 1)) {
$data = [
$res = "有货";
'state'=> $res,
}
'goods_name'=> $goods['goods_name'],
break;
'goods_id'=> $goods['goods_id'],
];
break;
default:
if ($goods->stock_total > ($value['num'] ?? 1)) {
$res = "有货";
}
$data = [
'state'=> $res,
'goods_name'=> $goods['goods_name'],
'goods_id'=> $goods['goods_id'],
];
break;
}
$return[] = $data;
}
}
return $this->renderSuccess(['stock' => $res]);
return $this->renderSuccess($return);
}
}
public function browseLog(): Json
public function browseLog(): Json
{
{