135 行
5.0 KiB
PHP
可执行文件
135 行
5.0 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Common\Model;
|
||
|
||
use Think\Model;
|
||
|
||
//[1.4.70]
|
||
|
||
/**
|
||
* 商户会员余额记录表
|
||
* Class RechargeOrderModel
|
||
* @package Common\Model
|
||
*/
|
||
class RechargeOrderModel extends BaseModel
|
||
{
|
||
protected $tableName = 'recharge_order';
|
||
protected $fields = array(
|
||
'id', //int(11) NOT NULL AUTO_INCREMENT COMMENT '充值的id',
|
||
'vid', //int(11) DEFAULT '0' COMMENT '会员id。',
|
||
'status', //smallint(1) DEFAULT '1' COMMENT '是否成功 1.支付成功 0.未支付',
|
||
'pay_order_id', //int(11) DEFAULT '0' COMMENT '关联pay_order表的id 用于支付回调时更新充值状态',
|
||
'money', //decimal(10,2) DEFAULT '0.00' COMMENT '实际充值的金额(支付金额)',
|
||
'all_money', //decimal(10,2) DEFAULT '0.00' COMMENT '充值获得的总金额',
|
||
'store_id', //int(11) DEFAULT '0' COMMENT '门店id。',
|
||
'add_time', //varchar(12) DEFAULT NULL,
|
||
'remark', //varchar(255) DEFAULT '' COMMENT '备注',
|
||
'state', //tinyint(1) DEFAULT '1' COMMENT '1正常 0删除',
|
||
'merchant_id', //int(11) DEFAULT '0' COMMENT '商户id',
|
||
'cashier_id', //int(11) DEFAULT '0' COMMENT '收银员id。',
|
||
'user_type', //tinyint(1) NOT NULL DEFAULT '0' COMMENT '充值人员类型:1.商家2.店长3.收银员。',
|
||
'bill_id', //int(11) DEFAULT '0' COMMENT '会员支付时 关联 retail_bill 表id 。',
|
||
'vip_recharge_id',//int(11) DEFAULT '0' COMMENT '充值档次id:仅充值时有效;',
|
||
'scene_type', //tinyint(2) NOT NULL COMMENT '变动场景 1收银机 2商户后台 3门店后台 4小程序 5公众号 6小助手 ',
|
||
'type', //tinyint(2) NOT NULL DEFAULT '0' COMMENT '变动类型 1充值 2消费 3编辑增加 4编辑减少 5退款增加 6红包充值 7大转盘充值 8礼品卡充值 9充值退款',
|
||
'pay_type', //tinyint(1) DEFAULT '0' COMMENT '1现金 2微信 3支付宝',
|
||
'recharge_order_id',//int(11) DEFAULT '0' COMMENT '充值:0 退款:原recharge_order_id',
|
||
'refund_status',//int(1) DEFAULT '1' COMMENT '1:正常 2:退款',
|
||
'repay_name',//int(1) DEFAULT 0 NULL COMMENT '到账方式 0:直接到账 1:分期到账';
|
||
);
|
||
|
||
public function getSelect_v1($map, $field, $order, $page, $limit)
|
||
{
|
||
if (!$field) {
|
||
$field = '*';
|
||
}
|
||
if (!$order) {
|
||
$order = 'id asc';
|
||
}
|
||
$res = $this->where($map)->field($field)->page($page, $limit)->order($order)->select();
|
||
return $res;
|
||
}
|
||
|
||
public function getSelectAndStore($map, $field, $order, $page)
|
||
{
|
||
if (!$field) {
|
||
$field = 'v.*,s.*';
|
||
}
|
||
if (!$order) {
|
||
$order = 'id asc';
|
||
}
|
||
$res = $this->alias('r')
|
||
->join('ls_retail_store as s on r.storeid=s.id', 'LEFT')
|
||
->where($map)
|
||
->field($field)
|
||
->order($order)
|
||
->page($page)
|
||
->select();
|
||
return $res;
|
||
}
|
||
|
||
|
||
public function getSelectList($map, $limit)
|
||
{
|
||
$res = $this->alias('v')
|
||
->join('ls_retail_vip_grade as g on g.id=v.gradeid')
|
||
->join('ls_retail_store as s on s.id=v.storeid')
|
||
->where($map)
|
||
->page($limit)
|
||
->field('v.mobile_phone,v.name,v.integral,v.addtime,v.overtime,g.grade_name,s.storetag as storename')
|
||
->select();
|
||
return $res;
|
||
}
|
||
|
||
/**
|
||
* 余额记录查询
|
||
* @param [array] $map 条件
|
||
* @param [int] $page 分页
|
||
* @param [int] $limit 数量
|
||
* @field [string] $field 字段 default '*'
|
||
* @return [array|bool] $data|false
|
||
*/
|
||
public function getVipRechargeList($map, $page = '', $limit = '', $field = '*')
|
||
{
|
||
if (!$map) {
|
||
return false;
|
||
}
|
||
// var_dump($map);
|
||
if (!$page || !$limit || $page == '' || $limit == '') {
|
||
$data = $this->alias('r')->join('ls_retail_vip as v on r.vid=v.id')->field($field)->where($map)->select();
|
||
} else {
|
||
$data = $this->alias('r')->join('ls_retail_vip as v on r.vid=v.id')->field($field)->where($map)->page($page, $limit)->select();
|
||
}
|
||
return $data;
|
||
|
||
}
|
||
|
||
/**
|
||
* 统计余额记录(count)
|
||
* @param [array] $map 条件
|
||
* @return [int|bool] $total|false
|
||
*/
|
||
public function total($map)
|
||
{
|
||
if (!$map) {
|
||
return false;
|
||
}
|
||
$total = $this->alias('r')->join('ls_retail_vip as v on r.vid=v.id')->where($map)->count();
|
||
return $total;
|
||
}
|
||
|
||
/**
|
||
* 统计单个字段总和(sum)
|
||
* @param [array] $map 条件
|
||
* @param [string] $field 字段
|
||
* @return [int|bool] $sum|false
|
||
*/
|
||
public function toSum($map, $field)
|
||
{
|
||
if (!$map || !$field) {
|
||
return false;
|
||
}
|
||
$sum = $this->alias('r')->join('ls_retail_vip as v on r.vid=v.id')->where($map)->sum($field);
|
||
return $sum;
|
||
}
|
||
} |