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

144 行
5.7 KiB
PHP
可执行文件

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

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

<?php
namespace Common\Model;
//[1.5.46]
/**
* 会员余额记录表
* Class RetailRechargeOrderModel
* @package Common\Model
*/
class RetailRechargeOrderModel extends BaseModel
{
protected $tableName = 'recharge_order';
const ID = 'id'; //int(11) NOT NULL AUTO_INCREMENT COMMENT '充值的id',
const MERCHANT_ID = 'merchant_id'; //int(11) DEFAULT '0' COMMENT '商户id'
const STORE_ID = 'store_id'; //int(11) DEFAULT '0' COMMENT '门店id。',
const VID = 'vid'; //int(11) DEFAULT '0' COMMENT '会员id。',
const STATUS = 'status'; //smallint(1) DEFAULT '1' COMMENT '是否成功 1.支付成功 0.未支付',
const PAY_ORDER_ID = 'pay_order_id'; //int(11) DEFAULT '0' COMMENT '关联pay_order表的id 用于支付回调时更新充值状态',
const MONEY = 'money'; //decimal(10,2) DEFAULT '0.00' COMMENT '实际充值的金额(支付金额)',
const ALL_MONEY = 'all_money'; //decimal(10,2) DEFAULT '0.00' COMMENT '充值获得的总金额',
const GIVE_MONEY = 'give_money'; //decimal(10,2) DEFAULT '0.00' COMMENT '充值获得的赠送金额',
const USER_TYPE = 'user_type'; //tinyint(1) NOT NULL DEFAULT '0' COMMENT '充值人员类型:1,商家管理员,2,店长,3,收银员。',
const CASHIER_ID = 'cashier_id'; //int(11) DEFAULT '0' COMMENT '收银员id。',
const BILL_ID = 'bill_id'; //int(11) DEFAULT '0' COMMENT '会员支付时 关联 retail_bill 表id 。',
const VIP_RECHARGE_ID = 'vip_recharge_id'; //int(11) DEFAULT '0' COMMENT '充值档次id:仅充值时有效;',
const REMARK = 'remark'; //varchar(255) DEFAULT '' COMMENT '备注',
const SCENE_TYPE = 'scene_type'; //tinyint(2) NOT NULL DEFAULT '0' COMMENT '变动场景 1收银机 2商户后台 3门店后台 4小程序 5公众号',
const TYPE = 'type'; //tinyint(2) NOT NULL DEFAULT '0' COMMENT '变动类型 1充值 2消费 3编辑增加 4编辑减少 5退款增加 6红包充值 7大转盘充值 8礼品卡充值 9充值退款
const ADD_TIME = 'add_time'; //varchar(12) DEFAULT NULL,
const STATE = 'state'; // tinyint(1) DEFAULT '1' COMMENT '1正常 0删除',
const PAY_TYPE = 'pay_type';//tinyint(1) DEFAULT '0' COMMENT '1现金 2微信 3支付宝',
const REFUND_STATUS = 'refund_status';//tinyint(1) DEFAULT '1' COMMENT '1:未退款 2:已退款',
const RECHARGE_ORDER_ID = 'recharge_order_id';//充值:0 退款:原recharge_order)id
const REPAY_NAME = 'repay_name';//int(1) DEFAULT 0 NULL COMMENT '到账方式 0:直接到账 1:分期到账';
public function getRechargeType($where, $key)
{
$res = $this->alias('r')
->join('ls_retail_pay_order as p on r.' . $this::PAY_ORDER_ID . '=p.id')
->where($where)
->sum($key);
return $res;
}
/**
* 获取余额记录+分页
*/
public function getBalanceRecord($map, $field, $order, $page)
{
$res = $this->alias('r')
->join('ls_retail_store as s on r.' . $this::STORE_ID . '=s.id', 'LEFT')
->where($map)
->field($field)
->order($order)
->page($page)
->select();
return $res;
}
public function getVipRechargeList($map, $fields, $page, $limit)
{
if (!$map) {
return false;
}
if (!$page || !$limit || $page == '' || $limit == '') {
$data = $this->alias('r')->join('ls_retail_vip as v on r.vid=v.id')->field($fields)->where($map)->order('r.id desc')->select();
} else {
$data = $this->alias('r')->join('ls_retail_vip as v on r.vid=v.id')->field($fields)->where($map)->page($page, $limit)->order('r.id desc')->select();
}
return $data;
}
public function getVipRechargeCount($map)
{
if (!$map) {
return false;
}
$count = $this->alias('r')->join('ls_retail_vip as v on r.vid=v.id')->where($map)->count();
return $count;
}
/**
* 获取联Vip表查询的sum值
* @param $map 条件
* @param $sum_field sum字段
* @param string $alias 别名
* @return int
*/
public function getLinkVipSum($map, $sum_field, $alias = 'r')
{
$sum = $this->alias($alias)
->join('ls_retail_vip as v on r.vid=v.id')
->where($map)->sum($sum_field);
$sum = $sum ? $sum : 0;
return $sum;
}
public function getRefundSum($map, $sum_field)
{
$sum = $this->alias('r1')
->join('ls_recharge as v on r.vid=v.id')
->where($map)->sum($sum_field);
}
/**
* 会员充值记录列表
* @param $fields
* @param $where
* @param int $page
* @param int $limit
* @param string $order
* @return mixed
*/
public function getVipRechargeRecordList($fields, $where, $page = 1, $limit = 10, $order = 'r.id desc')
{
$fields = $fields ? $fields : 'r.*';
$list = $this->alias('r')
->join('ls_retail_vip as v on v.id = r.vid')
->join('ls_retail_store as s on s.id=r.store_id', 'LEFT')
->field($fields)
->where($where)
->page($page, $limit)
->order($order)
->select();
return $list;
}
/**
* 会员充值记录列表总条数
* @param $where
* @return mixed
*/
public function getVipRechargeRecordCount($where)
{
$count = $this->alias('r')
->join('ls_retail_vip as v on v.id = r.vid')
->join('ls_retail_store as s on s.id=r.store_id', 'LEFT')
->where($where)
->count();
return $count;
}
}