|
|
|
@ -21,6 +21,7 @@ use app\api\service\Setting as SettingService; |
|
|
|
|
use app\common\service\GoodsCateEs; |
|
|
|
|
use app\common\service\Jd; |
|
|
|
|
use app\common\model\Tipoff as ModelTipoff; |
|
|
|
|
use app\common\model\GoodsCategoryRel; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 商品控制器 |
|
|
|
@ -559,4 +560,32 @@ class Goods extends Controller |
|
|
|
|
return $this->renderSuccess(compact('goodsList')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function JDShortLinks() |
|
|
|
|
{ |
|
|
|
|
$id = $this->request->param('id'); |
|
|
|
|
$detail = ModelTipoff::where('id',$id)->find(); |
|
|
|
|
$goodsList = GoodsModel::whereIn("goods_id",$detail['goods_id'])->field('goods_id,goods_name,goods_price_min,cost_price_min,goods_no')->select(); |
|
|
|
|
$goods_no = []; |
|
|
|
|
|
|
|
|
|
$JdModel = new jd(); |
|
|
|
|
|
|
|
|
|
$goods_no = array_column($goodsList->toArray(), 'goods_no'); |
|
|
|
|
|
|
|
|
|
$jd_url = $JdModel->getJdShortLinks($goods_no); |
|
|
|
|
$jd_url = array_column($jd_url, null, 'sku'); |
|
|
|
|
|
|
|
|
|
foreach ($goodsList as $key => &$value) { |
|
|
|
|
$cates = GoodsCategoryRel::where('goods_id', $value['goods_id'])->select()->toArray(); |
|
|
|
|
$value['jd_short_url'] = $jd_url[$value['goods_no']]['link'] ?? ""; |
|
|
|
|
//分类 |
|
|
|
|
if ($cates) { |
|
|
|
|
//会员价 |
|
|
|
|
$value['membership_price'] = \app\common\model\PriceSet::membershipPrice($value['goods_price_min'], $value['cost_price_min'], array_column($cates, 'category_id')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->renderSuccess(compact('goodsList')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|