文件
mashangyoujiu/Application/Common/Model/PlugModel.class.php

161 行
5.6 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
/**
* 插件模型 - 数据对象模型
* @author zaiyuliya
* @version LV1.0
*/
namespace Common\Model;
use Think\Model;
class PlugModel extends Model
{
protected $tableName = 'plug';
protected $fields = array(
'id', //int(11) NOT NULL AUTO_INCREMENT,
'plug_name', //varchar(100) DEFAULT NULL COMMENT '插件名称',
'plug_url', //text COMMENT '管理路径',
'use_url', //text COMMENT '使用路径',
'icon_url', //text COMMENT '图标路径',
'status', //smallint(1) DEFAULT NULL COMMENT '是否启用 0:未启用 1:已启用',
'addtime', //varchar(12) DEFAULT NULL COMMENT '添加时间',
'information', //text COMMENT '描述信息',
'class_id', //int(11) DEFAULT NULL COMMENT '类别id',
'type', //tinyint(1) DEFAULT '0' COMMENT '1会员卡插件 2其他插件',
'smclass_id', // int(11) NOT NULL DEFAULT '7' COMMENT '小分类id 以下字段未新增的',
'detailinfomation',// text NOT NULL COMMENT '详细描述',
'type', // tinyint(1) DEFAULT '2' COMMENT '1会员卡插件 2其他插件 tip:以下字段未新增的',
'label', // tinyint(1) NOT NULL DEFAULT '0' COMMENT '标签:0,普通,1,上新,2,推荐,3,最热',
'title', // varchar(255) NOT NULL DEFAULT '' COMMENT '一句话描述。',
'position', // int(8) NOT NULL DEFAULT '0' COMMENT '排序:小的靠前。',
'price', // decimal(10,0) DEFAULT '0' COMMENT '价格',
'templatetype',// tinyint(1) NOT NULL DEFAULT '0' COMMENT '模板类型:0,插件(不是模板),1,会员卡模板,2,商城模板,3,收银模板',
'installpackage',// varchar(255) NOT NULL DEFAULT '' COMMENT '安装包',
'needpackage',// tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否需要安装包:1,不需要,2,需要。',
'template_theme',
);
/*
* 添加一个新的板块
* @itme 添加的数据信息
* @return bool
*/
public function getPlug($map)
{
$res = $this->where($map)->find();
return $res;
}
public function addPlug($item)
{
$re = $this->add($item);
return $re;
}
public function getSelect($map)
{
$res = $this->where($map)->select();
return $res;
}
public function delPlug($map)
{
$res = $this->where($map)->delete();
return $res;
}
/*
* 修改一个新的板块
*/
public function updatePlug($map, $item)
{
$res = $this->where($map)->save($item);
return $res;
}
/*
* 获取所有的插件信息
*/
public function getAllPlug()
{
$info = $this->alias('p')
->join('ls_plug_class as c on p.class_id=c.id')
->field('p.*,c.class_name')
->select();
if (!empty($info)) {
return $info;
} else {
return false;
}
}
/**
* 验证商户的红包插件是否可用
* $merhcantid 商户id
*/
public function getRewardAccess($merchantid)
{
$plug = M('plug')->where(array('plug_name' => '红包', 'status' => 1))->find();
if ($plug) {
// 有该插件
$map['plug_id'] = $plug['id']; //
$map['merchant_id'] = $merchantid; // 主店id
$map['m_status'] = 1;
$merchant_plug = M('plug_merchant')->where($map)->find();
if ($merchant_plug) {
return $plug;
} else {
return false;
}
} else {
return false;
}
}
public function getActivityAccess($merchantid)
{
$map['pm.merchant_id'] = $merchantid;
$map['pm.m_status'] = 1;
$reward_plug = M('plug_merchant as pm')->join("ls_plug as p on p.id=pm.plug_id AND p.plug_name='红包'")->where($map)->find();
$reward = M('reward')->where(array('merchantid' => $merchantid, 'status' => 1, 'type' => 2))->find();
if (!empty($reward_plug) && !empty($reward)) {
$reward['plug_name'] = '红包';
return $reward;
} else {
$turntable_plug = M('plug_merchant as pm')->join("ls_plug as p on p.id=pm.plug_id AND p.plug_name='大转盘'")->where($map)->find();
$turntable = M('turntable')->where(array('merchantid' => $merchantid, 'status' => 1, 'type' => 2))->find();
if (!empty($turntable_plug) && !empty($turntable)) {
$turntable['plug_name'] = '大转盘';
return $turntable;
} else {
return false;
}
}
}
public function closeAgentPlug($id, $agent_id)
{
$map['plug_id'] = $id;
$map['a_status'] = 1;
$map['agent_id'] = $agent_id;
$updatePartner = M('plug_agent')->where($map)->save(array('a_status' => 2));
$merchant_list = M('retail_merchant')->where(array('agentid' => $agent_id))->select();
if (!empty($merchant_list)) {
$merchant_ids = '';
foreach ($merchant_list as $val) {
if ($merchant_ids == '') {
$merchant_ids = $val['id'];
} else {
$merchant_ids .= ',' . $val['id'];
}
}
$map2['merchant_id'] = array('in', $merchant_ids);
$map2['m_status'] = 1;
$map2['plug_id'] = $id;
$updateAgent = M('plug_merchant')->where($map2)->save(array('m_status' => 2));
}
}
}