257 lines
10 KiB
PHP
257 lines
10 KiB
PHP
<?php
|
|
|
|
class AutoProductEntity
|
|
{
|
|
public $id;
|
|
public $title;
|
|
public $imgs;
|
|
public $brandId;
|
|
public $seriesId;
|
|
public $provinceId;
|
|
public $cityId;
|
|
public $countyId;
|
|
public $timeStart;
|
|
public $timeEnd;
|
|
public $timeLaunch;
|
|
public $crowdProfiling;
|
|
public $status;
|
|
public $cluesCommission;
|
|
public $orderCommission;
|
|
public $updateTime;
|
|
public $createTime;
|
|
public $cpsMoney;
|
|
|
|
//扩展信息
|
|
public $guide_price; //指导价
|
|
public $discounts; //优惠信息
|
|
public $discounts2; //优惠信息
|
|
public $discounts3; //优惠信息
|
|
public $promotion_text; //推广文案
|
|
public $posterBg; //海报背景图
|
|
public $banner; //banner图
|
|
|
|
public function __construct()
|
|
{
|
|
$ci = &get_instance();
|
|
$ci->load->model('area_model');
|
|
$ci->load->model('agent/auto_product_city_model', 'autoProductCity');
|
|
$ci->load->model('agent/auto_product_model', 'autoProduct');
|
|
$ci->load->model('agent/auto_product_setting_model', 'autoProductSetting');
|
|
$ci->load->model('auto/auto_brand_model', 'mdAutoBrand');
|
|
$ci->mdAutoBrand->set_db('ssdb');
|
|
$ci->load->model('auto/auto_series_model', 'mdAutoSeries');
|
|
$ci->mdAutoSeries->set_db('ssdb');
|
|
$autoProduct = new Auto_product_model();
|
|
foreach ($autoProduct::EXTEND_FIELDS as $key => $val) {
|
|
$value = $ci->autoProductSetting->getValue($this->id, $key);
|
|
|
|
$this->$key = $value ?: $val;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getBrandName()
|
|
{
|
|
$ci = &get_instance();
|
|
$brand = $ci->mdAutoBrand->get(['id' => $this->brandId]);
|
|
return $brand ? $brand['name'] : '';
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getSeriesName()
|
|
{
|
|
$ci = &get_instance();
|
|
$series = $ci->mdAutoSeries->get(['id' => $this->seriesId]);
|
|
return $series ? $series['name'] : '';
|
|
}
|
|
|
|
/**
|
|
* 获取标签
|
|
* @return array
|
|
*/
|
|
public function getLabel()
|
|
{
|
|
$ci = &get_instance();
|
|
$ci->load->model('agent/auto_product_label_model', 'autoProductLabel');
|
|
$rows = $ci->autoProductLabel->select(['product_id' => $this->id], '', '', '', 'label_id');
|
|
$result = [];
|
|
if (!empty($rows)) {
|
|
foreach ($rows as $row) {
|
|
$result[] = intval($row['label_id']);
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* 获取标签中文名称
|
|
* @return array
|
|
*/
|
|
public function getLabelName()
|
|
{
|
|
$ci = &get_instance();
|
|
$ci->load->model('agent/auto_product_label_model', 'autoProductLabel');
|
|
$rows = $ci->autoProductLabel->select(['product_id' => $this->id], '', '', '', 'label_id');
|
|
$result = [];
|
|
if (!empty($rows)) {
|
|
foreach ($rows as $row) {
|
|
$ids[] = intval($row['label_id']);
|
|
}
|
|
$idsString = implode(',', $ids);
|
|
if ($idsString) {
|
|
$ci->load->model('agent/admin/Market_sys_dictionary_data_model', 'mdSysDictionaryData');
|
|
$where = [
|
|
"dictDataId in ({$idsString})" => null,
|
|
"dictId in (select dictId from lc_market_sys_dictionary where dictCode in ('carProductLabel','productLevel'))" => null
|
|
];
|
|
$rows = $ci->mdSysDictionaryData->select($where, '', '', '', 'dictDataId,dictDataName');
|
|
foreach ($rows as $item) {
|
|
$result[] = $item['dictDataName'];
|
|
}
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* 获取第一张banner图
|
|
* @return string
|
|
*/
|
|
public function getFirstBanner()
|
|
{
|
|
$banner = $this->banner ? explode(',', $this->banner) : [];
|
|
return $banner ? build_qiniu_image_url($banner[0]) : '';
|
|
}
|
|
|
|
/**
|
|
* 获取图片列表
|
|
* @return array
|
|
*/
|
|
public function getImagesList()
|
|
{
|
|
$imgs = $this->imgs ? explode(',', $this->imgs) : [];
|
|
$result = [];
|
|
if (!empty($imgs)) {
|
|
foreach ($imgs as $item) {
|
|
$result[] = build_qiniu_image_url($item);
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* 获取一个优惠券信息
|
|
* @return array
|
|
*/
|
|
public function getOneCoupons($userId = '')
|
|
{
|
|
$ci = &get_instance();
|
|
$ci->load->model('agent/auto_product_coupon_model', 'autoProductCoupon');
|
|
$ci->load->model('agent/auto_user_coupon_model', 'autoUserCoupon');
|
|
$where = [
|
|
'product_id' => $this->id,
|
|
'status' => 1
|
|
];
|
|
/** @var AutoProductCouponEntity[] $rows */
|
|
$rows = $ci->autoProductCoupon->select($where, 'id desc', 1, 1, '', 'AutoProductCouponEntity');
|
|
$result = ['show' => 0];
|
|
if (!empty($rows)) {
|
|
$row = $rows[0];
|
|
$text = '立即领取';
|
|
$status = 1;
|
|
$count_down = 0;
|
|
if (strtotime($row->timeStart) < time() && strtotime($row->timeEnd) > time()) {
|
|
$count_down = strtotime($row->timeEnd) - time();
|
|
} else {
|
|
if (strtotime($row->timeStart) > time()) {
|
|
$text = '未开始';
|
|
$status = 2;
|
|
} else {
|
|
$text = '已结束';
|
|
$status = 3;
|
|
}
|
|
};
|
|
if ($userId && $ci->autoUserCoupon->count(['couponId' => $row->id, 'userId' => $userId])) {
|
|
$text = '领取成功';
|
|
$status = 4;
|
|
}
|
|
$result = [
|
|
'show' => 1,
|
|
'coupon_id' => $row->id,
|
|
'title' => $row->title,
|
|
'price' => intval($row->price),
|
|
'rule' => $row->rule,
|
|
'typeCn' => '好车补专项补贴',
|
|
'timeStart' => date('Y-m-d', strtotime($row->timeStart)),
|
|
'timeEnd' => date('Y-m-d', strtotime($row->timeEnd)),
|
|
'activityProcess' => '<p><img src="https://img.liche.cn/space/agent/admin/202506/p_20c14cf6c986f702ed414a5f96699a54.jpg?v=1" alt=""/></p>',
|
|
'checkStandard' => '<p>① 返现权益仅限购车人本人领取;</p>
|
|
<p>② 须在权益有效期内提交申请,购车发票开具经销商、购车发票车系/车型应在权益指定范围内;</p>
|
|
<p>③ 订单创建日期须早于购车发票开票日期</p>
|
|
<p>④ 购车合同/发票上的姓名、证件号须与实名信息一致</p>
|
|
<p>⑤ 购车发票应为发票联原件或扫描件,不能为复印件、发票其他联或扫描件。发票照片须 清楚完整,字迹清晰,无修改</p>',
|
|
'FAQ' => '<p>问:购车人与实名认证账户人不一致可以领取补贴吗?</p>
|
|
<p>答:仅限购车人本人领取补贴。</p>
|
|
<p> </p>
|
|
<p>问:如何领权益?先买车还是先领券?</p>
|
|
<p>答:领取补贴流程为:在线上领取补贴券,线下4S店交付定金、到店提车—上传凭证—审 核通过,领取补贴返现。如您已在4S店内交付定金,或已提车,再领补贴券是无法享 受补贴的。</p>
|
|
<p> </p>
|
|
<p>问:我申请的购车补贴什么时候审核?</p>
|
|
<p>答:补贴审核时效一般为自上传凭证起15个工作日内完成审核,因公平起见参与活动的订单依据上传凭证时间顺序进行审核,无法做加急处理,请您耐心等待,如遇特殊情况将会顺延审核时效。具体届时请参考实际页面的审核结果为准。</p>
|
|
<p> </p>
|
|
<p>问:同一天下单同一天购车可以吗?</p>
|
|
<p>答:下单日期必须早于在4S店缴纳定金或者购车日期,(部分品牌有特殊规则要求,明细 规则以商品详情页说明为准)。</p>
|
|
<p> </p>
|
|
<p>问:我到店了,4S店说不知道有这个活动怎么办?</p>
|
|
<p>答:本次活动为平安车主专项补贴权益(活动权益与4S店无关,无须询问4S店)。不影响 您正常到店自由议价和享受其他优惠。</p>
|
|
<p> </p>
|
|
<p>问:下单后在哪里查看订单?如何上传凭证?</p>
|
|
<p>答:通过活动页面进入【我的】-【我的订单】,可查看订单进度。【我的】-【我的补贴】, 可根据提示上传相关凭证进行审核。</p>',
|
|
'getNun' => $ci->autoUserCoupon->count(['couponId' => $row->id]),
|
|
'bizTip' => $row->getBizTip(),
|
|
'count_down' => $count_down * 1000,
|
|
'btn_info' => [
|
|
'text' => $text,
|
|
'status' => $status,
|
|
],
|
|
'bizList' => $row->getBizList(1, 1),
|
|
'hasMoreBiz' => $row
|
|
];
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* 获取推广城市
|
|
* @return array
|
|
*/
|
|
public function getProvinceCity()
|
|
{
|
|
$ci = &get_instance();
|
|
$cityList = $ci->autoProductCity->select(['productId' => $this->id]);
|
|
$provinceCityIds = [];
|
|
$cityNames = [];
|
|
if ($cityList) {
|
|
$cityIds = implode(',', array_column($cityList, 'cityId'));
|
|
if ($cityIds) {
|
|
$where = [
|
|
"city_id in ($cityIds)" => null
|
|
];
|
|
$citys = $ci->area_model->map('city_id', '', $where, '', '', '', 'DISTINCT city_id,city_name');
|
|
}
|
|
foreach ($cityList as $item) {
|
|
$provinceCityIds[] = [$item['provinceId'], $item['cityId']];
|
|
$city = $citys[$item['cityId']] ? $citys[$item['cityId']][0] : [];
|
|
if ($city) {
|
|
$cityNames[] = $city['city_name'];
|
|
}
|
|
}
|
|
}
|
|
$result = ['provinceCityIds' => $provinceCityIds, 'cityNames' => $cityNames];
|
|
return $result;
|
|
}
|
|
} |