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

188 行
6.8 KiB
PHP
可执行文件

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

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

<?php
namespace Common\Model;
use Think\Model;
//[1.7.90]
class MerchantModel extends Model
{
protected $tableName = 'retail_merchant';
protected $fields = array(
'id', //int(11) NOT NULL AUTO_INCREMENT,
'mobile', //varchar(11) DEFAULT NULL COMMENT '商户手机号(登录账号)',
'password', //varchar(255) DEFAULT NULL COMMENT '商户登录密码',
'begin_time', //varchar(11) DEFAULT NULL COMMENT '商户账号启用时间',
'end_time', //varchar(11) DEFAULT NULL COMMENT '商户账号过期时间',
'province', //int(11) DEFAULT NULL COMMENT '商户所在省份(地址id)',
'city', //int(11) DEFAULT NULL COMMENT '商户所在市(市区id)',
'area', //int(11) DEFAULT NULL COMMENT '商户所在县区(县区id)',
'addtime', //varchar(11) DEFAULT NULL COMMENT '创建时间',
'status', //varchar(2) DEFAULT '1' COMMENT '1:正常使用 2:被禁用 3:被删除',
'name', //varchar(30) DEFAULT NULL COMMENT '商户的名称',
'address', //text,
'headimg', //text COMMENT '头像',
'partnerid', //int(11) DEFAULT '1' COMMENT '合伙人id',
'agentid', //int(11) DEFAULT NULL COMMENT '代理商id',
'mealid', //int(11) DEFAULT NULL COMMENT '套餐id',
'juris', //varchar(1) DEFAULT '1' COMMENT '1禁用 2开启 小程序功能',
'storenum', //int(11) DEFAULT '1' COMMENT '门店数量',
'merchant_rate', //decimal(10,6) DEFAULT NULL COMMENT '新大陆进件商家费率',
'toshopcode', //varchar(100) DEFAULT NULL,
'nearby_status', //tinyint(1) DEFAULT '2' COMMENT '是否直接跳转附近门店 1.开启 2.关闭',
'inputrecharge', //tinyint(1) DEFAULT '1' COMMENT '自定义充值金额:1,开启,2,关闭。',
'show_all_vip', //tinyint(1) DEFAULT '2' COMMENT '门店是否显示所有会员 1.显示 2.不显示',
'operation_vip', //tinyint(1) DEFAULT '2' COMMENT '门店是否操作所有会员1.可以2.不可以',
'auto_read_recharge_grade',//tinyint(1) DEFAULT '1' COMMENT '自定义充值时,是否自动读取充值档次,1,自动读取(默认设置),2,不读取。',
'openid', //varchar(50) DEFAULT NULL COMMENT '微信用户openid',
'openid_type', //tinyint(3) DEFAULT '0' COMMENT '是否绑定微信 0 未绑定 1 已绑定',
'cost_type', //tinyint(1) DEFAULT '1' COMMENT '1成本价算法 移动加权法 2加权法',
'headimg_id', //varchar(255) DEFAULT '0',
'new_continent_status',//tinyint(1) DEFAULT '0' COMMENT '商户新大陆配置权限0 关闭 1开启',
'express_search', //tinyint(1) DEFAULT '2' COMMENT '1开启 2关闭',
'ali_rate', //decimal(10,6) DEFAULT NULL COMMENT '支付宝商家费率',
'wx_rate', //decimal(10,6) DEFAULT NULL COMMENT '微信商家费率',
'union_pay_rate', //decimal(10,6) DEFAULT NULL COMMENT '商户云闪付费率',
);
/**
* 判断商户是否能正常使用
* @param $id
* @return mixed
*/
public function getFindNormalMerchant($id)
{
$merchant = $this->where(array('id' => $id, 'status' => array('in', '1,2')))->find();
if (!empty($merchant)) {
if ($merchant['status'] == 1) {
$time = time();
//判断代理商是否过期
if ($merchant['begin_time'] < $time && $merchant['end_time'] > $time) {
$res['status'] = 1;
$res['data'] = $merchant;
} else {
$res['status'] = 0;
$res['msg'] = '未在商户有效期内';
}
} else {
$res['status'] = 0;
$res['msg'] = '商户异常';
}
} else {
$res['status'] = 0;
$res['msg'] = '商户不存在';
}
return $res;
}
/**
* @param $map
* @return mixed
*/
public function Mer_del($map)
{
$re = $this->where($map)->delete();
return $re;
}
/**
* @param $map
* @param string $filed
* @return mixed
*/
public function getFind($map, $filed = '*')
{
if (!isset($map['status'])) {
$map['status'] = 1;
}
$cache = $this->where($map)->field($filed)->find();
return $cache;
}
/**
* 获取某字段
* @param $map
* @param string $fields
* @param $bol
* @return mixed
*/
public function getFindField($map, $fields = 'id', $bol = false)
{
$res = $this->where($map)->getField($fields, $bol);
return $res;
}
/**
* @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)
{
$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)
->select();
return $cache;
}
public function getListLimit($map, $limit)
{
$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($limit)
->where($map)
->select();
return $cache;
}
/**
* 添加商户信息
*/
public function addMerchant($data)
{
$re = $this->add($data);
return $re;
}
/**
* 修改用户信息
*/
public function UpdateMerchant($map, $data)
{
$res = $this->where($map)->save($data);
return $res;
}
/* 商户获取代理商id
* @param
* $merchantid
* @return int
* */
public function get_agent_id($merchantid)
{
$agent_id = $this->where(array('id' => $merchantid))->getfield('agentid');
if ($agent_id) {
return $agent_id;
} else {
return false;
}
}
}