作者 lyh

gx

... ... @@ -552,10 +552,31 @@ class ProductController extends BaseController
public function sendAiProduct(){
$this->request->validate([
'keyword'=>'required',
'product_id'=>'required'
],[
'keyword.required' => 'keyword不能为空',
'product_id.required' => 'product_id不能为空',
]);
$data = curl_c('http://title.globalso.com/ajax_data_for_web.php?keyword='.$this->param['keyword'],false);
$this->response('success',Code::SUCCESS,$data);
$productInfo = $this->model->read(['id' => $this->param['product_id']]);
if (!empty($productInfo)) {
$this->fail('请选择有效产品信息!');
}
$productInfo = $this->handleParam($productInfo);
$keyword = generateRoute($this->param['keyword']);
$pre_suf = file_get_contents("http://www.quanqiusou.cn/get_prefix_suffix_api.php");
$pre_suf_array = json_decode($pre_suf,JSON_OBJECT_AS_ARRAY);
$search_info = file_get_contents("http://title.globalso.com/ajax_data_for_web.php?keyword=".$keyword);
if ($search_info) {
$new_info = explode(" - ",trim($search_info));
$new_title = str_replace(' ',' ',$pre_suf_array['prefix_title'][0].' '.$new_info[0]);
$tm_ky = explode(',',$new_info[1]);
$contents = $pre_suf_array['prefix'][0].' '.$new_title.', '.$pre_suf_array['suffix_s'][0]."\r\n";
$contents .= $pre_suf_array['prefix_title'][0].' '.implode(', ',$tm_ky).', '.$pre_suf_array['suffix_l'][0]."\r\n";
$new_content = htmlentities($contents);
}
if (FALSE == empty($data['new_content'])){
$productInfo['describe'] = $new_content . $productInfo['$data'];
}
$this->response('success',Code::SUCCESS,$productInfo);
}
}
... ...