作者 lyh
@@ -66,6 +66,7 @@ class AdsController extends BaseController @@ -66,6 +66,7 @@ class AdsController extends BaseController
66 } 66 }
67 $result = $result->toArray(); 67 $result = $result->toArray();
68 $result['relay_site_total'] = $relay_site_total; 68 $result['relay_site_total'] = $relay_site_total;
  69 + $result['default_ai_param'] = ReInquiryTask::DEFAULT_AI_PARAM;
69 70
70 return $this->response('success', Code::SUCCESS, $result); 71 return $this->response('success', Code::SUCCESS, $result);
71 } 72 }
@@ -86,10 +87,26 @@ class AdsController extends BaseController @@ -86,10 +87,26 @@ class AdsController extends BaseController
86 $num = intval($request->input('num')); 87 $num = intval($request->input('num'));
87 $status = intval($request->input('status')); 88 $status = intval($request->input('status'));
88 $is_replace_text = intval($request->input('is_replace_text')); 89 $is_replace_text = intval($request->input('is_replace_text'));
  90 + $ai_param = $request->input('ai_param');
89 if (empty($title) || empty($ad_id)) 91 if (empty($title) || empty($ad_id))
90 return $this->response('请填写完整信息!', Code::USER_ERROR, []); 92 return $this->response('请填写完整信息!', Code::USER_ERROR, []);
91 93
92 - ReInquiryTask::createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status, $is_replace_text); 94 + //AI生成
  95 + if($is_replace_text == 2){
  96 + if(empty($ai_param['mkeywords'])){
  97 + return $this->response('工厂关键词不能为空!', Code::USER_ERROR, []);
  98 + }
  99 + if(empty($ai_param['characters'])){
  100 + return $this->response('随机字符数不能为空!', Code::USER_ERROR, []);
  101 + }
  102 + if(empty($ai_param['inkeywords'])){
  103 + return $this->response('询盘内容关键词不能为空!', Code::USER_ERROR, []);
  104 + }
  105 + if(empty($ai_param['suoxie'])){
  106 + return $this->response('英文缩写参考不能为空!', Code::USER_ERROR, []);
  107 + }
  108 + }
  109 + ReInquiryTask::createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status, $is_replace_text, $ai_param);
93 return $this->response('success', Code::SUCCESS, []); 110 return $this->response('success', Code::SUCCESS, []);
94 } 111 }
95 112
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 */ 7 */
8 namespace App\Models\Inquiry; 8 namespace App\Models\Inquiry;
9 9
  10 +use App\Helper\Arr;
10 use App\Models\Base; 11 use App\Models\Base;
11 use Illuminate\Database\Eloquent\Model; 12 use Illuminate\Database\Eloquent\Model;
12 13
@@ -28,6 +29,36 @@ class ReInquiryTask extends Base @@ -28,6 +29,36 @@ class ReInquiryTask extends Base
28 const STATUS_OPEN = 1; 29 const STATUS_OPEN = 1;
29 const STATUS_CLOSE = 0; 30 const STATUS_CLOSE = 0;
30 31
  32 + const DEFAULT_AI_PARAM = [
  33 + 'mkeywords' => '',
  34 + 'characters' => '30
  35 +40
  36 +50
  37 +60
  38 +70
  39 +80
  40 +90
  41 +100
  42 +120
  43 +150',
  44 + 'inkeywords' => 'OEM/ODM价格
  45 +FOB价格多少
  46 +最小起订量
  47 +批发价格多少
  48 +批发价格及价格梯度
  49 +本地是否招商
  50 +支持的支付方式
  51 +产品画册及类别
  52 +公司详细资质
  53 +能否WhatsApp直接联系
  54 +是否需求本地合作伙伴',
  55 + 'suoxie' => 'Thanks 写成 Tks
  56 +Please 写成 Pls
  57 +As Soon As Possible 写成 ASAP
  58 +For Your Information 写成 FYI
  59 +How Much 写成 HM',
  60 + ];
  61 +
31 /** 62 /**
32 * 创建询盘任务 63 * 创建询盘任务
33 * @param $id 64 * @param $id
@@ -40,7 +71,7 @@ class ReInquiryTask extends Base @@ -40,7 +71,7 @@ class ReInquiryTask extends Base
40 * @param int $status 71 * @param int $status
41 * @return ReInquiryTask 72 * @return ReInquiryTask
42 */ 73 */
43 - public static function createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status = self::STATUS_OPEN, $is_replace_text = 1) 74 + public static function createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status, $is_replace_text, $ai_param)
44 { 75 {
45 $self = self::where(['id' => $id])->first(); 76 $self = self::where(['id' => $id])->first();
46 if (empty($self)) 77 if (empty($self))
@@ -53,6 +84,7 @@ class ReInquiryTask extends Base @@ -53,6 +84,7 @@ class ReInquiryTask extends Base
53 $self->num = $num; 84 $self->num = $num;
54 $self->status = $status; 85 $self->status = $status;
55 $self->is_replace_text = $is_replace_text; 86 $self->is_replace_text = $is_replace_text;
  87 + $self->ai_param = $ai_param;
56 $self->save(); 88 $self->save();
57 return $self; 89 return $self;
58 } 90 }
@@ -72,4 +104,14 @@ class ReInquiryTask extends Base @@ -72,4 +104,14 @@ class ReInquiryTask extends Base
72 } 104 }
73 return $value; 105 return $value;
74 } 106 }
  107 +
  108 + public function setAiParamAttribute($value)
  109 + {
  110 + $this->attributes['ai_param'] = Arr::a2s($value);
  111 + }
  112 +
  113 + public function getAiParamAttribute($value)
  114 + {
  115 + return Arr::s2a($value) ?: self::DEFAULT_AI_PARAM;
  116 + }
75 } 117 }