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

164 行
4.9 KiB
PHP
可执行文件

<?php
namespace Common\Model;
use Think\Model;
//[1.7.90]
class AgentModel extends Model
{
protected $tableName = 'retail_agent';
protected $fields = array(
'id',// int(11) NOT NULL AUTO_INCREMENT,
'name', //varchar(100) DEFAULT NULL COMMENT '超管名称',
'addtime', //varchar(12) DEFAULT NULL COMMENT '添加时间',
'status',// smallint(1) DEFAULT '1' COMMENT '是否启用 1启用 2禁用',
'last_time',// varchar(11) DEFAULT NULL COMMENT '最后一次登陆的时间',
'password',// varchar(32) DEFAULT NULL,
'type',// smallint(1) DEFAULT '2' COMMENT '1:超级管理员 2合伙人',
'begin_time',// varchar(13) DEFAULT NULL COMMENT '开始时间',
'end_time',// varchar(13) DEFAULT NULL COMMENT '结束时间',
'image',// varchar(255) DEFAULT NULL COMMENT '代理商头像',
'phone',// varchar(13) DEFAULT NULL COMMENT '合伙人手机号',
'address',// varchar(255) DEFAULT NULL COMMENT '地址',
'province',// varchar(32) DEFAULT NULL COMMENT '省',
'city',// varchar(64) DEFAULT NULL COMMENT '市',
'area',// varchar(64) DEFAULT NULL COMMENT '区或县',
'partnerid',//合伙人id
'discountid',//折扣id
'money',//余额
'agent_rate', //代理商费率
'ali_rate', //支付宝费率
'wx_rate', //微信费率
'bank_id', //开户银行
'bank_card', //银行卡号
'union_pay_rate', //代理商云闪付费率
);
/**
* @param $map
* @return mixed
*/
/**
* 添加商户信息
*/
public function addAgent($data)
{
$re = $this->add($data);
return $re;
}
//编辑代理商信息
public function UpdateUser($map, $data)
{
$re = $this->where($map)->save($data);
return $this->_sql();
}
public function agent_del($map)
{
$re = $this->where($map)->delete();
return $re;
}
/**
* @param $map
* @return mixed
*/
public function getFind($map)
{
$cache = $this->where($map)->find();
return $cache;
}
/**
* @param $map
* @return mixed
*/
public function getCount($map)
{
$count = $this->alias('m')
->where($map)
->count();
return $count;
}
/**
* @param $map
* @return mixed
*/
public function getList($map, $page)
{
$cache = $this->alias('m')
->field('m.*,p.city_name as pname,c.city_name as cname,a.city_name as aname')
->join('ls_citys as p on p.cityid = m.province')
->join('ls_citys as c on c.cityid = m.city')
->join('ls_citys as a on a.cityid = m.area')
->where($map)
->page($page)
->select();
return $cache;
}
public function getListLimit($map, $page)
{
$cache = $this->alias('m')
->field('m.*,p.city_name as pname,c.city_name as cname,a.city_name as aname')
->join('ls_citys as p on p.cityid = m.province')
->join('ls_citys as c on c.cityid = m.city')
->join('ls_citys as a on a.cityid = m.area')
->limit($page)
->where($map)
->select();
return $cache;
}
public function getListLimits($map, $page)
{
$cache = $this->alias('m')
->field('m.*,p.city_name as pname,c.city_name as cname,a.city_name as aname')
->join('ls_citys as p on p.cityid = m.province')
->join('ls_citys as c on c.cityid = m.city')
->join('ls_citys as a on a.cityid = m.area')
->page($page)
->where($map)
->select();
return $cache;
}
/**
* 修改用户信息
*/
public function UpdateMerchant($map, $data)
{
$res = $this->where($map)->save($data);
return $res;
}
/**
* 判断代理商是否有效
* @param $id 代理商id
* @return mixed
*/
public function getFindNormalAgent($id){
$agent = $this->where(array('id' => $id, 'status' => 1))->find();
if(!empty($agent)){
if($agent['status'] == 1){
$time = time();
//判断代理商是否过期
if ($agent['begin_time'] < $time && $agent['end_time'] > $time) {
$res['status'] = 1;
}else{
$res['status'] = 0;
$res['msg'] = '代理商未在有效期内';
}
}else{
$res['status'] = 0;
$res['msg'] = '代理商异常';
}
}else{
$res['status'] = 0;
$res['msg'] = '代理商不存在';
}
return $res;
}
}