作者 lyh

gx

@@ -552,10 +552,31 @@ class ProductController extends BaseController @@ -552,10 +552,31 @@ class ProductController extends BaseController
552 public function sendAiProduct(){ 552 public function sendAiProduct(){
553 $this->request->validate([ 553 $this->request->validate([
554 'keyword'=>'required', 554 'keyword'=>'required',
  555 + 'product_id'=>'required'
555 ],[ 556 ],[
556 'keyword.required' => 'keyword不能为空', 557 'keyword.required' => 'keyword不能为空',
  558 + 'product_id.required' => 'product_id不能为空',
557 ]); 559 ]);
558 - $data = curl_c('http://title.globalso.com/ajax_data_for_web.php?keyword='.$this->param['keyword'],false);  
559 - $this->response('success',Code::SUCCESS,$data); 560 + $productInfo = $this->model->read(['id' => $this->param['product_id']]);
  561 + if (!empty($productInfo)) {
  562 + $this->fail('请选择有效产品信息!');
  563 + }
  564 + $productInfo = $this->handleParam($productInfo);
  565 + $keyword = generateRoute($this->param['keyword']);
  566 + $pre_suf = file_get_contents("http://www.quanqiusou.cn/get_prefix_suffix_api.php");
  567 + $pre_suf_array = json_decode($pre_suf,JSON_OBJECT_AS_ARRAY);
  568 + $search_info = file_get_contents("http://title.globalso.com/ajax_data_for_web.php?keyword=".$keyword);
  569 + if ($search_info) {
  570 + $new_info = explode(" - ",trim($search_info));
  571 + $new_title = str_replace(' ',' ',$pre_suf_array['prefix_title'][0].' '.$new_info[0]);
  572 + $tm_ky = explode(',',$new_info[1]);
  573 + $contents = $pre_suf_array['prefix'][0].' '.$new_title.', '.$pre_suf_array['suffix_s'][0]."\r\n";
  574 + $contents .= $pre_suf_array['prefix_title'][0].' '.implode(', ',$tm_ky).', '.$pre_suf_array['suffix_l'][0]."\r\n";
  575 + $new_content = htmlentities($contents);
  576 + }
  577 + if (FALSE == empty($data['new_content'])){
  578 + $productInfo['describe'] = $new_content . $productInfo['$data'];
  579 + }
  580 + $this->response('success',Code::SUCCESS,$productInfo);
560 } 581 }
561 } 582 }