作者 赵彬吉

update

@@ -10,6 +10,7 @@ use App\Models\Inquiry\InquiryForm; @@ -10,6 +10,7 @@ use App\Models\Inquiry\InquiryForm;
10 use App\Models\Inquiry\PhoneData; 10 use App\Models\Inquiry\PhoneData;
11 use App\Rules\Ids; 11 use App\Rules\Ids;
12 use App\Services\BatchExportService; 12 use App\Services\BatchExportService;
  13 +use App\Utils\LogUtils;
13 use Illuminate\Http\Request; 14 use Illuminate\Http\Request;
14 use Illuminate\Support\Facades\Storage; 15 use Illuminate\Support\Facades\Storage;
15 use Illuminate\Support\Str; 16 use Illuminate\Support\Str;
@@ -135,7 +136,7 @@ class InquiryController extends BaseController @@ -135,7 +136,7 @@ class InquiryController extends BaseController
135 { 136 {
136 if(!empty($this->param['form_id'])){ 137 if(!empty($this->param['form_id'])){
137 $data = $logic->getFormDataList(true); 138 $data = $logic->getFormDataList(true);
138 - $field = InquiryForm::getField($this->param['form_id']); 139 + $field = InquiryForm::getField($this->param['form_id'], $this->user['project_id']);
139 $map = [ 140 $map = [
140 'submit_time' => '询盘发送时间', 141 'submit_time' => '询盘发送时间',
141 ]; 142 ];
@@ -179,8 +180,12 @@ class InquiryController extends BaseController @@ -179,8 +180,12 @@ class InquiryController extends BaseController
179 if(!empty($this->param['form_id'])){ 180 if(!empty($this->param['form_id'])){
180 $item = array_merge($item, $item['data']); 181 $item = array_merge($item, $item['data']);
181 } 182 }
182 - 183 + LogUtils::info('Inquiry_export', [$map, $item]);
183 foreach ($map as $field => $name) { 184 foreach ($map as $field => $name) {
  185 + if(empty($item[$field])){
  186 + $item[$field] = '';
  187 + continue;
  188 + }
184 if(is_array($item[$field])){ 189 if(is_array($item[$field])){
185 $item[$field] = implode(',',$item[$field]); 190 $item[$field] = implode(',',$item[$field]);
186 } 191 }
@@ -89,7 +89,7 @@ class InquiryLogic extends BaseLogic @@ -89,7 +89,7 @@ class InquiryLogic extends BaseLogic
89 $page = $this->request['page'] ?: 1; 89 $page = $this->request['page'] ?: 1;
90 $form_id = $this->request['form_id'] ?? ''; 90 $form_id = $this->request['form_id'] ?? '';
91 $ids = $this->request['ids'] ?? []; 91 $ids = $this->request['ids'] ?? [];
92 - $field = InquiryForm::getField($form_id); 92 + $field = InquiryForm::getField($form_id, $this->user['project_id']);
93 $fields = ['id', 'data', 'ip', 'country', 'domain', DB::raw('referer as refer'), DB::raw('status as read_status'), DB::raw('submit_at as submit_time')]; 93 $fields = ['id', 'data', 'ip', 'country', 'domain', DB::raw('referer as refer'), DB::raw('status as read_status'), DB::raw('submit_at as submit_time')];
94 $lists = InquiryFormData::where('form_id', $form_id) 94 $lists = InquiryFormData::where('form_id', $form_id)
95 ->where(function ($query) use ($search, $field,$ids){ 95 ->where(function ($query) use ($search, $field,$ids){
@@ -50,8 +50,8 @@ class InquiryForm extends Base @@ -50,8 +50,8 @@ class InquiryForm extends Base
50 * @author zbj 50 * @author zbj
51 * @date 2023/12/5 51 * @date 2023/12/5
52 */ 52 */
53 - public static function getField($form_id){  
54 - $cache_key = 'inquiry_form_field_' . $form_id; 53 + public static function getField($form_id, $project_id){
  54 + $cache_key = 'inquiry_form_field_' . $project_id . '_' . $form_id;
55 $field = Cache::get($cache_key); 55 $field = Cache::get($cache_key);
56 if(!$field){ 56 if(!$field){
57 $field = self::where('id', $form_id)->value('field'); 57 $field = self::where('id', $form_id)->value('field');