123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace app\common\model\coupon;
- use app\common\library\helper;
- use think\facade\Db;
- use app\common\model\BaseModel;
- use app\common\model\User;
- use app\common\model\GoodsSku as GoodsSkuModel;
- use app\common\model\Goods as GoodsModel;
- /**
- * 用户优惠券使用详情模型 已废弃
- * @package app\common\model
- */
- class Usercoupondetail extends BaseModel
- {
- const COUPON_TYPE = [ 1=>'电子卡', 2=>'实体卡'];
- const COUPON_CATEGORY = [1=>'兑换卡', 2=>'储值卡'];
- protected $name = 'user_coupon_detail';
- /**
- * 兑换详细列表
- * @param string $dataType 订单类型
- * @param array $param
- * @return mixed
- */
- public function getAllList(array $param = [])
- {
- // 检索查询条件
- $filter = $this->getQueryFilter($param);
- // 获取数据列表
- $query = $this->with([])->where($filter)
- ->leftJoin('user', 'user.user_id = detail.user_id')
- ->alias('detail')
- ->field('detail.*,user.mobile,user.nick_name');
- $list = $query->order(['detail.id' => 'desc'])->paginate(15);
- foreach($list as $row){
- $row->coupon_user = User::field('mobile,nick_name')->where("user_id",$row->coupon_user_id)->find();
- $goodsku = GoodsSkuModel::where('goods_sku_id',$row->good_sku_id)->where('goods_id',$row->good_id)->find();
- $goods = GoodsModel::field('goods_name')->where("goods_id",$row->good_id)->find();
- $row->sku_name = $goodsku->goods_props[0]['value']['name']??'';
- $row->good_name = $goods->goods_name??'';
- }
- return $list;
- }
- //查询
- public function getQueryFilter($param){
- if($param['user_coupon_id']>0){
- return $param;
- }
-
- }
- /**
- * 获取兑换明细列表
- * @param int|null $limit 获取的数量
- * @param bool $onlyReceive 只显示可领取
- * @return \think\Collection
- * @throws BaseException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function getList(array $user_coupon_id_arr,int $limit = 15){
- // 查询构造器
- $query = $this->getNewQuery();
- //查询数量
- $limit > 0 && $query->limit($limit);
- $list = $query->where('user_coupon_id','in',$user_coupon_id_arr)
- ->order(['id' => 'desc'])
- ->select();
- return $list;
- }
- }
|