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.

124 lines
2.9 KiB

<?php
namespace app\integral\logic;
use app\integral\model\IntegralConfig;
use app\integral\model\IntegralConfigAdvertise;
use app\integral\model\IntegralConfigCarousel;
class Config extends Base
{
/**
* 获取积分攻略
* @date 2022-11-09
*/
public function getIntegralNotice()
{
$config_model = new IntegralConfig();
// 获取积分攻略
$config = $config_model->getOneData([
['uid', '=', $this->mid]
], 'id,integral_notice');
return sendSuccessArray([
// 积分攻略
'integral_notice' => $config['integral_notice']
]);
}
/**
* 获取配送方式
* @date 2022-11-17
*/
public function getDeliveryType()
{
$config_model = new IntegralConfig();
// 获取配送方式
$config = $config_model->getOneData([
['uid', '=', $this->mid]
], 'id,delivery_type');
$config['delivery_type'] = explode(',', $config['delivery_type']);
// 到货方式
$delivery_type = [];
if (in_array(1, $config['delivery_type'])) {
$delivery_type[] = [
'id' => 1,
'name' => '邮寄'
];
}
if (in_array(2, $config['delivery_type'])) {
$delivery_type[] = [
'id' => 2,
'name' => '自提'
];
}
return sendSuccessArray([
// 配送方式
'delivery_type' => $delivery_type
]);
}
/**
* 获取积分商城轮播图
* @date 2022-11-09
*/
public function getCarousel()
{
$config_carousel_model = new IntegralConfigCarousel();
// 获取商城轮播图
$carousel = $config_carousel_model->getAllData([
['uid', '=', $this->mid]
], 'image,link_url', 'sort desc');
$carousel = empty($carousel) ? [] : $carousel->toArray();
return sendSuccessArray([
// 轮播图
'carousel' => $carousel
]);
}
/**
* 获取积分商城广告图
* @date 2022-11-09
*/
public function getAdvertise()
{
$config_advertise_model = new IntegralConfigAdvertise();
// 获取商城广告图
$advertise_data = $config_advertise_model->getAllData([
['uid', '=', $this->mid]
], 'type,image,link_url', 'id asc');
$advertise_data = empty($advertise_data) ? [] : $advertise_data->toArray();
// 初始化数据
$advertise = [
'top' => [],
'bottom' => []
];
// 赋值
foreach ($advertise_data as $k => $v) {
if ($v['type'] == 1) {
$advertise['top'][] = $v;
} else {
$advertise['bottom'][] = $v;
}
}
return sendSuccessArray([
// 广告图
'advertise' => $advertise
]);
}
}