修改后台导入线索和订单图片上传

This commit is contained in:
lcc
2024-06-18 14:34:13 +08:00
parent 07cdc59630
commit 9e08ed68d1
3 changed files with 57 additions and 43 deletions
+32 -10
View File
@@ -101,9 +101,9 @@ class Clues extends HD_Controller
}
}
if(strlen($params['status'])){
if (strlen($params['status'])) {
$where["status"] = $params['status'];
}else{
} else {
$where["status > "] = '-1';
}
@@ -473,7 +473,12 @@ class Clues extends HD_Controller
$data[] = array(
'name' => $objWorksheet->getCell('A' . $_row)->getValue(),
'mobile' => $objWorksheet->getCell('B' . $_row)->getValue(),
'cfrom' => $objWorksheet->getCell('C' . $_row)->getValue(),
'cfrom1' => $objWorksheet->getCell('C' . $_row)->getValue(),
'cfrom2' => $objWorksheet->getCell('D' . $_row)->getValue(),
'province_name' => $objWorksheet->getCell('E' . $_row)->getValue(),
'city_name' => $objWorksheet->getCell('F' . $_row)->getValue(),
'county_name' => $objWorksheet->getCell('G' . $_row)->getValue(),
'biz_name' => $objWorksheet->getCell('H' . $_row)->getValue(),
);
}
$done = $this->add_batch($data);
@@ -937,11 +942,22 @@ class Clues extends HD_Controller
private function add_batch($lists)
{
$done = 0;
$adds = array();
$adds = $map_province = $map_city = $map_county = $map_biz = [];
$where = array('status' => 1);
$select = 'id, title';
$map_cfrom = $this->clues_cfrom_model->map('title', 'id', $where, '', 0, 0, $select);
$biz_strings = implode("','", array_unique(array_column($lists, 'biz_name')));
if ($biz_strings) $where = ["biz_name in ('{$biz_strings}')" => null];
$biz_strings && $map_biz = $this->biz_model->map('biz_name', 'id', $where, '', 0, 0, 'id,biz_name');
$province_strings = implode("','", array_unique(array_column($lists, 'province_name')));
if ($province_strings) $where = ["province_name in ('{$province_strings}')" => null];
$province_strings && $map_province = $this->area_model->map('province_name', 'province_id', $where, '', 0, 0, 'DISTINCT(province_id),province_name');
$city_strings = implode("','", array_unique(array_column($lists, 'city_name')));
if ($city_strings) $where = ["city_name in ('{$city_strings}')" => null];
$city_strings && $map_city = $this->area_model->map('city_name', 'city_id', $where, '', 0, 0, 'DISTINCT(city_id),city_name');
$county_strings = implode("','", array_unique(array_column($lists, 'county_name')));
if ($county_strings) $where = ["county_name in ('{$county_strings}')" => null];
$county_strings && $map_county = $this->area_model->map('county_name', 'county_id', $where, '', 0, 0, 'DISTINCT(county_id),county_name');
$fails = array();
foreach ($lists as $k => $v) {
if (!$v['name']) {
@@ -956,18 +972,24 @@ class Clues extends HD_Controller
$fails[] = array('data' => $v, 'msg' => '手机号已存在');
continue;
}
$cf_id = $map_cfrom[$v['cfrom']];
$adds[] = array(
$cf_id = $map_cfrom[$v['cfrom1']];
$cf2_id = $map_cfrom[$v['cfrom2']];
$temp = array(
'name' => $v['name'],
'mobile' => $v['mobile'],
'cf_id' => $cf_id ? $cf_id : 0,
'cf_id' => $cf_id ?: 0,
'cf2_id' => $cf2_id ?: 0,
'c_time' => time(),
'province_id' => $map_province[$v['province_name']] ?: 0,
'city_id' => $map_city[$v['city_name']] ?: 0,
'county_id' => $map_county[$v['county_name']] ?: 0,
'biz_id' => $map_biz[$v['biz_name']] ?: 0,
);
$adds[] = $temp;
$done++;
}
$fails && debug_log('[warning]# fails=' . json_encode($fails), __FUNCTION__, $this->log_dir);
if ($adds) {
$ret = $this->clues_model->add_batch($adds);
if (!$ret) {
+8 -10
View File
@@ -460,7 +460,8 @@ class Orders extends HD_Controller
} else {
$re_data_id = $re_data['id'];
}
if ($field == 'ins_img' || $field == 'other_img') {
$field == 'contract_img' && $save_value = $re_data[$field] ? $re_data[$field] . ',' . $value : $value;
if ($field == 'ins_img') {
$val_arr = json_decode($re_data[$field], true);
$val_arr[] = $value;
$save_value = json_encode($val_arr, JSON_UNESCAPED_UNICODE);
@@ -535,17 +536,14 @@ class Orders extends HD_Controller
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
if ($info['field'] == 'ins_img' || $info['field'] == 'other_img') {
$jsondata = json_decode($row[$info['field']], true);
$new_jsondata = [];
foreach ($jsondata as $item) {
if (strpos($info['value'], $item) !== false) {
} else {
$new_jsondata[] = $item;
}
if ($info['field'] == 'contract_img') {
$img_array = explode(',', $row[$info['field']]);
$new_imgs = [];
foreach ($img_array as $item) {
strpos($info['value'], $item) === false && $new_imgs[] = $item;
}
$update = [
$info['field'] => json_encode($new_jsondata, JSON_UNESCAPED_UNICODE)
$info['field'] => implode(',', $new_imgs)
];
} elseif ($info['field'] == 'insurance_img' || $info['field'] == 'business_img' || $info['field'] == 'accident_img' || $info['field'] == 'bill_ck_img') {
$update = [
+17 -23
View File
@@ -81,6 +81,7 @@
</li>
</ul>
</div>
<!--
<div class="am-form-group clearfix">
<p class="am-text-default mb10 ml30 pt15 pb10">
订单合同:
@@ -105,30 +106,27 @@
</li>
</ul>
</div>
-->
<div class="am-form-group clearfix">
<div class="">
<p class="am-text-default mb10 ml30 pt15 pb10">
订单合同:
</p>
<ul id="viewer-other_img" class="photopic-list ml30 clearfix">
<? if ($info['imgs_status']['other_img']['imgs']) { ?>
<? foreach ($info['imgs_status']['other_img']['imgs'] as $key => $val) { ?>
<li style="position:relative;">
<div style="position:absolute;top:5px;right:0;padding:0 8px 2px 8px;line-height:22px; background-color:rgba(0,0,0,.5);font-size:14px;color:#fff;"
onclick="del_img('data','other_img','<?= $val ?>')">x
</div>
<a target="_blank" class="pic">
<img alt="交车合照<?= $key + 1 ?>" onclick="showViewer('viewer-other_img')"
src="<?= $val ?>"/>
</a>
</li>
<? } ?>
<? } ?>
<li>
<ul id="contract_img" class="photopic-list ml30 clearfix">
<li style="position:relative;" v-for="(item,index) in info.img_data.contract_img" :key="index">
<div style="position:absolute;top:5px;right:0;padding:0 8px 2px 8px;line-height:22px; background-color:rgba(0,0,0,.5);font-size:14px;color:#fff;"
:onclick="'del_img(\'data\',\'contract_img\',\''+item+'\')'">x
</div>
<a target="_blank" class="pic">
<img alt="订单合同" onclick="showViewer('contract_img')"
:src="item"/>
</a>
</li>
<li v-if="info.img_data.contract_img.length<5">
<a href="javascript:void(0);" class="pic" data-file="1" data-type="jpg,png,gif,png,jpeg"
data-uptype="qiniu" data-field="other_img" data-mark="compalbum">
<input type="hidden" class="other_img" name="other_img" data-type="1" value=""
onchange="upImg('other_img',this)">
data-uptype="qiniu" data-field="contract_img" data-mark="compalbum">
<input type="hidden" class="contract_img" name="contract_img" data-type="1" value=""
onchange="upImg('contract_img',this)">
<div></div>
</a>
</li>
@@ -340,11 +338,7 @@
<script>
function upImg(field, obj) {
var value;
if (field == 'ins_img' || field == 'other_img') {
value = $(obj).val();
} else {
value = $(obj).val();
}
value = $(obj).val();
var loading = layer.msg('图片上传中..', {
icon: 16
, shade: 0.3