You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.9 KiB
90 lines
2.9 KiB
<?php
|
|
defined('IN_IA') or exit('Access Denied');
|
|
class MerchantDataEnt
|
|
{
|
|
/**
|
|
* 验证填写合法性
|
|
*/
|
|
public static function validateEntData($data,$source)
|
|
{
|
|
try {
|
|
if (!empty($data['introduction'])) {
|
|
$textRes = Filter::init($data['introduction'],$source);
|
|
if ($textRes['errno'] == 0) {
|
|
throw new Exception('企业简介'.$textRes['message']);
|
|
}
|
|
}
|
|
if (!empty($data['business'])) {
|
|
$textRes = Filter::init($data['business'],$source);
|
|
if ($textRes['errno'] == 0) {
|
|
throw new Exception('经营业务'.$textRes['message']);
|
|
}
|
|
}
|
|
if (!empty($data['advantage'])) {
|
|
$textRes = Filter::init($data['advantage'],$source);
|
|
if ($textRes['errno'] == 0) {
|
|
throw new Exception('企业优势'.$textRes['message']);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
} catch (Exception $e) {
|
|
return $e->getMessage();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 新增编辑企业信息
|
|
* @param $data
|
|
* @param $storeid
|
|
* @return bool
|
|
*/
|
|
public static function saveData($data,$storeid)
|
|
{
|
|
$save_data = ['storeid' => $storeid];
|
|
|
|
if (!empty($data['cc_id']) && is_numeric($data['cc_id'])) {
|
|
$save_data['cc_id'] = $data['cc_id'];
|
|
}
|
|
if (!empty($data['business'])) {
|
|
$save_data['business'] = htmlspecialchars_decode($data['business']);
|
|
}
|
|
if (!empty($data['advantage'])) {
|
|
$save_data['advantage'] = htmlspecialchars_decode($data['advantage']);
|
|
}
|
|
if (is_numeric($data['recommend']) && in_array($data['recommend'],[0,1])) {
|
|
$save_data['recommend'] = $data['recommend'];
|
|
}
|
|
|
|
$query = pdo_get(PDO_NAME . 'merchantdataent',['storeid' => $storeid]);
|
|
|
|
if ($query) {
|
|
$save_data['update_time'] = date("Y-m-d H:i:s",time());
|
|
|
|
pdo_update(PDO_NAME . 'merchantdataent',$save_data,['id' => $query['id']]);
|
|
} else {
|
|
$save_data['create_time'] = date("Y-m-d H:i:s",time());
|
|
|
|
pdo_insert(PDO_NAME . 'merchantdataent',$save_data);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public static function getStoreEntData($storeid)
|
|
{
|
|
return pdo_get(PDO_NAME . 'merchantdataent',['storeid' => $storeid]);
|
|
}
|
|
|
|
public static function getStoreIdArr($data)
|
|
{
|
|
if (empty($data)) return [];
|
|
$storeIdArr = [];
|
|
$where = [];
|
|
if (!empty($data['cc_id'])) $where['cc_id'] = $data['cc_id'];
|
|
if (is_numeric($data['recommend'])) $where['recommend'] = $data['recommend'];
|
|
$query = pdo_getall(PDO_NAME . 'merchantdataent',$where,['storeid']);
|
|
foreach ($query as $row) $storeIdArr[] = $row['storeid'];
|
|
return $storeIdArr;
|
|
}
|
|
}
|