2018-09-21 07:48:02 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace Service;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 资源服务层
|
|
|
|
|
|
* @author Devil
|
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
|
* @version 0.0.1
|
|
|
|
|
|
* @datetime 2016-12-01T21:51:08+0800
|
|
|
|
|
|
*/
|
|
|
|
|
|
class ResourcesService
|
|
|
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取地区名称
|
|
|
|
|
|
* @author Devil
|
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
|
* @date 2018-09-19
|
|
|
|
|
|
* @desc description
|
|
|
|
|
|
* @param [array] $params [输入参数]
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static function RegionName($params = [])
|
|
|
|
|
|
{
|
|
|
|
|
|
return M('Region')->where(['id'=>intval($params['region_id'])])->getField('name');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-08 10:17:57 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取地区名称
|
|
|
|
|
|
* @author Devil
|
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
|
* @date 2018-09-19
|
|
|
|
|
|
* @desc description
|
|
|
|
|
|
* @param [array] $params [输入参数]
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static function ExpressName($params = [])
|
|
|
|
|
|
{
|
|
|
|
|
|
return M('Express')->where(['id'=>intval($params['express_id'])])->getField('name');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-09-21 07:48:02 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 快递列表
|
|
|
|
|
|
* @author Devil
|
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
|
* @date 2018-09-19
|
|
|
|
|
|
* @desc description
|
|
|
|
|
|
* @param [array] $params [输入参数]
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static function ExpressList($params = [])
|
|
|
|
|
|
{
|
2018-10-01 17:24:40 +00:00
|
|
|
|
$where = [];
|
|
|
|
|
|
if(isset($params['is_enable']))
|
|
|
|
|
|
{
|
|
|
|
|
|
$where['is_enable'] = intval($params['is_enable']);
|
|
|
|
|
|
}
|
|
|
|
|
|
$data = M('Express')->where($where)->field('id,icon,name,sort,is_enable')->order('sort asc')->select();
|
2018-09-21 07:48:02 +00:00
|
|
|
|
if(!empty($data) && is_array($data))
|
|
|
|
|
|
{
|
|
|
|
|
|
$images_host = C('IMAGE_HOST');
|
|
|
|
|
|
foreach($data as &$v)
|
|
|
|
|
|
{
|
2018-09-26 10:41:25 +00:00
|
|
|
|
$v['icon_old'] = $v['icon'];
|
2018-09-21 07:48:02 +00:00
|
|
|
|
$v['icon'] = empty($v['icon']) ? null : $images_host.$v['icon'];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 支付方式列表
|
|
|
|
|
|
* @author Devil
|
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
|
* @date 2018-09-19
|
|
|
|
|
|
* @desc description
|
|
|
|
|
|
* @param [array] $params [输入参数]
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static function PaymentList($params = [])
|
|
|
|
|
|
{
|
2018-10-01 17:24:40 +00:00
|
|
|
|
$where = empty($params['where']) ? [] : $params['where'];
|
2018-10-04 17:46:58 +00:00
|
|
|
|
if(isset($params['is_enable']))
|
|
|
|
|
|
{
|
|
|
|
|
|
$where['is_enable'] = intval($params['is_enable']);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(isset($params['is_open_user']))
|
|
|
|
|
|
{
|
|
|
|
|
|
$where['is_open_user'] = intval($params['is_open_user']);
|
|
|
|
|
|
}
|
2018-10-01 17:24:40 +00:00
|
|
|
|
|
2018-10-04 17:46:58 +00:00
|
|
|
|
$data = M('Payment')->where($where)->field('id,logo,name,sort,payment,config,apply_terminal,apply_terminal,element,is_enable,is_open_user')->order('sort asc')->select();
|
2018-09-21 07:48:02 +00:00
|
|
|
|
if(!empty($data) && is_array($data))
|
|
|
|
|
|
{
|
|
|
|
|
|
$images_host = C('IMAGE_HOST');
|
|
|
|
|
|
foreach($data as &$v)
|
|
|
|
|
|
{
|
2018-09-26 10:41:25 +00:00
|
|
|
|
$v['logo_old'] = $v['logo'];
|
2018-09-21 07:48:02 +00:00
|
|
|
|
$v['logo'] = empty($v['logo']) ? null : $images_host.$v['logo'];
|
2018-09-27 10:30:14 +00:00
|
|
|
|
$v['element'] = empty($v['element']) ? '' : json_decode($v['element'], true);
|
|
|
|
|
|
$v['config'] = empty($v['config']) ? '' : json_decode($v['config'], true);
|
|
|
|
|
|
$v['apply_terminal'] = empty($v['apply_terminal']) ? '' : json_decode($v['apply_terminal'], true);
|
2018-09-21 07:48:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
|
|
|
|
}
|
2018-09-21 10:35:37 +00:00
|
|
|
|
|
2018-09-28 07:01:00 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取支付方式列表
|
|
|
|
|
|
* @author Devil
|
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
|
* @date 2018-09-19
|
|
|
|
|
|
* @desc 下订单根据终端自动筛选支付方式
|
|
|
|
|
|
* @param [array] $params [输入参数]
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static function BuyPaymentList($params = [])
|
|
|
|
|
|
{
|
|
|
|
|
|
$data = self::PaymentList($params);
|
|
|
|
|
|
|
|
|
|
|
|
$result = [];
|
|
|
|
|
|
if(!empty($data))
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach($data as $v)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 根据终端类型筛选
|
|
|
|
|
|
switch(APPLICATION)
|
|
|
|
|
|
{
|
|
|
|
|
|
// pc, wap
|
|
|
|
|
|
case 'web' :
|
|
|
|
|
|
if(IsMobile())
|
|
|
|
|
|
{
|
|
|
|
|
|
if(in_array('wap', $v['apply_terminal']))
|
|
|
|
|
|
{
|
|
|
|
|
|
$result[] = $v;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if(in_array('pc', $v['apply_terminal']))
|
|
|
|
|
|
{
|
|
|
|
|
|
$result[] = $v;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
// app
|
|
|
|
|
|
case 'app' :
|
|
|
|
|
|
if(in_array('app', $v['apply_terminal']))
|
|
|
|
|
|
{
|
|
|
|
|
|
$result[] = $v;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-09-21 10:35:37 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取地区节点数据
|
|
|
|
|
|
* @author Devil
|
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
|
* @date 2018-09-21
|
|
|
|
|
|
* @desc description
|
|
|
|
|
|
* @param [array] $params [输入参数]
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static function RegionNode($params = [])
|
|
|
|
|
|
{
|
|
|
|
|
|
$field = empty($params['field']) ? 'id,name,level,letters' : $params['field'];
|
|
|
|
|
|
$where = empty($params['where']) ? [] : $params['where'];
|
|
|
|
|
|
$where['is_enable'] = 1;
|
|
|
|
|
|
|
|
|
|
|
|
return M('Region')->where($where)->field($field)->order('id asc, sort asc')->select();
|
|
|
|
|
|
}
|
2018-09-30 10:13:06 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 消息添加
|
|
|
|
|
|
* @author Devil
|
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
|
* @date 2018-09-21
|
|
|
|
|
|
* @desc description
|
|
|
|
|
|
* @param [int] $user_id [用户id]
|
|
|
|
|
|
* @param [string] $title [标题]
|
|
|
|
|
|
* @param [string] $detail [内容]
|
|
|
|
|
|
* @param [int] $business_type [业务类型(0默认, 1订单, ...)]
|
|
|
|
|
|
* @param [int] $business_id [业务id]
|
|
|
|
|
|
* @param [int] $type [类型(默认0 普通消息)]
|
|
|
|
|
|
* @return [boolean] [成功true, 失败false]
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static function MessageAdd($user_id, $title, $detail, $business_type = 0, $business_id = 0, $type = 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$data = array(
|
|
|
|
|
|
'title' => $title,
|
|
|
|
|
|
'detail' => $detail,
|
|
|
|
|
|
'user_id' => intval($user_id),
|
|
|
|
|
|
'business_type' => intval($business_type),
|
|
|
|
|
|
'business_id' => intval($business_id),
|
|
|
|
|
|
'type' => intval($type),
|
|
|
|
|
|
'add_time' => time(),
|
|
|
|
|
|
);
|
|
|
|
|
|
return M('Message')->add($data) > 0;
|
|
|
|
|
|
}
|
2018-09-21 07:48:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
?>
|