CouponModel.php 743 字节
<?php
/**
 * Created by PhpStorm.
 * User: yhbr
 * Date: 2018/9/5
 * Time: 15:03
 */
namespace app\coupons\model;
use think\Model;
use think\Db;

class CouponModel extends Model
{
    public function getAllDiscountCouponByUniqueIdAndByStatus($status = null, $user_id)
    {
        if ($status == null) {
            $status = 1;
        }
        $map['status'] = array('eq', $status);
        $map['user_id'] = array('eq', $user_id);
        $res = Db::name('discount_coupon')->field('id,reduce,discount_coupon_name,deadline')->where($map)->select()->toArray();
        foreach ($res as $key => $item) {
            $item['deadline'] = date('Y-m-d', $item['deadline']);
            $res[$key] = $item;
        }
        return $res;
    }

}