REAPI/app/channel/service/ProductBaseService.php

84 lines
1.8 KiB
PHP
Raw Normal View History

2024-09-29 15:43:18 +08:00
<?php
namespace app\channel\service;
use app\core\Service;
/**
* 商品基本信息服务
* Class ChannelService
* @package app\channel\service
*/
class ProductBaseService extends Service
{
/**
* 设置默认操作表
* @var string
*/
public $table = 'service_product';
# 商品类型
public $type = array
(
1 => '加油卡',
2 => '话费',
3 => '权益卡',
4 => '卡密类',
5 => 'API业务类'
2024-09-29 15:43:18 +08:00
);
public function getType()
{
return $this->type;
}
# 根据产品id获取产品
public function getOne($id)
{
$where['id'] = $id;
$where['status'] = 1;
$data = $this->db()->where($where)->find();
if ($data) {
$data['service'] = $this->getService($data['service_id']);
if ($data['service']) {
$data['key'] = $data['service']['key'];
} else {
return false;
}
}
return $data;
}
# 获取业务
public function getService($id)
{
$where['id'] = $id;
$where['status'] = 1;
return $this->app->db->name('service_info')->where($where)->find();
}
# 获取所有业务
public function getServiceAll()
{
$where['status'] = 1;
return $this->app->db->name('service_info')->where($where)->select();
}
# 获取渠道id
public function getProductId($id)
{
$where['service_id'] = $id;
$where['status'] = 1;
return $this->app->db->name('channel_product')->where($where)->find();
}
# 获取所有产品
public function getAll()
{
$where['status'] = 1;
$data = $this->db()->where($where)->select();
return $data;
}
}