文件
mashangyoujiu/Application/ShopCoupon/Model/ShopCouponRecordModel.class.php

144 行
4.2 KiB
PHP
可执行文件

<?php
namespace ShopCoupon\Model;
use Common\Model\BaseModel;
class ShopCouponRecordModel extends BaseModel
{
protected $tableName = 'shop_coupon_record';
protected $fields = [
'id',
'merchant_id',
'coupon_id', //商家券主键id
'xcx_id', //领取的小程序用户id
'stock_id', //发券批次号
'receive_stock_id', //领券批次号
'openid', //用户在公众号的唯一标识
'coupon_code', //券码
'use_time', //请求核销时间
'wechatpay_use_time', //核销时间
'use_request_no', //核销请求单据号
'operator_id', //核销人id 0为小程序用户购买核销
'verification_store_id', //核销的门店
'verification_available_type', //核销场景 1小程序 2收银机 3公众号
'verification_type', //核销状态1未核销 2已核销
'used_type', //使用状态1未使用 2已使用
'add_time', //领取时间
'bill_id', //订单id
'store_id' //门店id
];
/**
* 商家券信息
* @param $fields
* @param $where
* @return mixed
*/
public function verificationCouponInfo($fields, $where)
{
$info = $this->alias('r')
->join('ls_shop_coupon as s on r.coupon_id=s.id')
->field($fields)
->where($where)
->find();
return $info;
}
/**
* 发放记录
* @param $fields
* @param $where
* @param $page
* @param $limit
* @return mixed
*/
public function recordList($fields, $where, $page, $limit)
{
$list = $this->alias('r')
->join('ls_shop_coupon as c on r.coupon_id=c.id')
->join('ls_retail_xcxvip as x on r.xcx_id=x.id')
->join('ls_retail_vip as v on x.vid=v.id', 'LEFT')
->join('ls_retail_store as s on r.store_id = s.id', 'LEFT')
->join('ls_retail_cashier as j on r.operator_id=j.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_shop_coupon as c on r.coupon_id=c.id')
->join('ls_retail_xcxvip as x on r.xcx_id=x.id')
->join('ls_retail_vip as v on x.vid=v.id', 'LEFT')
->join('ls_retail_store as s on r.verification_store_id = s.id', 'LEFT')
->join('ls_jurisdiction_user as j on r.operator_id=j.id', 'LEFT')
->where($where)
->count();
return $count;
}
/**
* 用户的商家券列表分页
* @param $fields
* @param $where
* @param $page
* @param $limit
* @return mixed
*/
public function userCouponList($fields, $where, $page, $limit)
{
$list = $this->alias('s')
->join('ls_shop_coupon as c on s.coupon_id=c.id')
->field($fields)
->where($where)
->page($page, $limit)
->order('s.id desc')
->select();
return $list;
}
/**
* 用户的商家券列表无分页
* @param $fields
* @param $where
* @return mixed
*/
public function PlaceOrderCouponList($fields, $where)
{
$info = $this->alias('r')
->join('ls_shop_coupon as s on r.coupon_id=s.id')
->field($fields)
->where($where)
->order('r.id desc')
->select();
return $info;
}
/**
* 根据的用户商家券的id获取服务商下的openid
* @param $fields
* @param $where
* @return mixed
*/
public function basisIdGetOpenid($fields='x.service_openid,x.openid',$where)
{
$xcx_info = $this->alias('s')
->join('ls_retail_xcxvip as x on s.xcx_id=x.id')
->field($fields)
->where($where)
->find();
return $xcx_info;
}
}