106 行
3.0 KiB
PHP
可执行文件
106 行
3.0 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace PayCoupon\Model;
|
|
|
|
use Common\Model\BaseModel;
|
|
|
|
class PayCouponRecordModel extends BaseModel
|
|
{
|
|
protected $tableName = 'pay_coupon_record';
|
|
protected $fields = [
|
|
'id',
|
|
'openid', //用户openid
|
|
'merchant_id', //商户id
|
|
'coupon_id', //代金券表主键id
|
|
'vip_id', //会员id
|
|
'add_time', //发放时间
|
|
'operator_id', //操作人id
|
|
'user_coupon_id', //用户领导代金券的id
|
|
'stock_id', //发放的微信代金券id
|
|
'stock_name', //代金券名称
|
|
'stock_type', //批次类型 1为NORMAL固定面额满减券,2为DISCOUNT折扣券使用规则,3为EXCHANGE换购券使用规则
|
|
'use_status', //1未使用 2已使用
|
|
'user_type', //1普通模式 2服务商模式
|
|
'type', //1小程序 2公众号
|
|
'uid', //小程序用户id
|
|
'order_id', //订单id
|
|
'receive_store_id', //领取门店
|
|
'use_store_id', //核销门店
|
|
'use_time', //核销时间
|
|
'use_scene', //核销场景 1小程序 2收银机 3公众号
|
|
'use_type', //1购买商品 2充值
|
|
'coupon_fee', //优惠的金额元
|
|
];
|
|
|
|
/**
|
|
* 小程序用户领取记录
|
|
* @param $fields
|
|
* @param $where
|
|
* @param $page
|
|
* @param $limit
|
|
* @return mixed
|
|
*/
|
|
public function userRecordList($fields, $where, $page, $limit)
|
|
{
|
|
$list = $this->alias('r')
|
|
->join('ls_pay_coupon as p on r.coupon_id = p.id')
|
|
->field($fields)
|
|
->where($where)
|
|
->page($page . ',' . $limit)
|
|
->order('r.id desc')
|
|
->select();
|
|
return $list;
|
|
}
|
|
|
|
|
|
/**
|
|
* 发放记录
|
|
* @param $fields
|
|
* @param $where
|
|
* @param $page
|
|
* @param $limit
|
|
* @return mixed
|
|
*/
|
|
public function record($fields, $where, $page, $limit)
|
|
{
|
|
$list = $this->alias('r')
|
|
->join('ls_retail_vip as v on r.vip_id=v.id', 'LEFT')
|
|
->join('ls_retail_store as s on r.receive_store_id = s.id', 'LEFT')
|
|
->field($fields)
|
|
->where($where)
|
|
->page($page, $limit)
|
|
->order('r.id desc')
|
|
->select();
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* 记录总数
|
|
* @param $where
|
|
* @return mixed
|
|
*/
|
|
public function recordCount($where)
|
|
{
|
|
$count = $this->alias('r')
|
|
->join('ls_pay_coupon as p on r.coupon_id = p.id')
|
|
->join('ls_retail_vip as v on r.vip_id=v.id', 'LEFT')
|
|
->join('ls_retail_store as s on v.storeid = s.id', 'LEFT')
|
|
->where($where)
|
|
->count();
|
|
return $count;
|
|
}
|
|
|
|
|
|
//查询用户的代金券详情
|
|
public function couponInfo($where, $field='*')
|
|
{
|
|
$info = $this->alias('r')
|
|
->join('ls_pay_coupon as p on r.coupon_id = p.id')
|
|
->field($field)
|
|
->where($where)
|
|
->find();
|
|
return $info;
|
|
}
|
|
|
|
|
|
} |