Browse Source

套餐核销码

zhangxiaobin 1 year ago
parent
commit
86757b9648
2 changed files with 53 additions and 1 deletions
  1. 0 1
      application/api/controller/Order.php
  2. 53 0
      application/common/model/UserCoupons.php

+ 0 - 1
application/api/controller/Order.php

@@ -175,7 +175,6 @@ class Order extends Api
             $where['id'] = $id;
             $where['company_id'] = $companyId;
             $where['user_id'] = $userId;
-            $where['status'] = 2;
             $modelData = $this->model->where($where)->find();
             if (empty($modelData)) {
                 throw new Exception('未找到相关信息');

+ 53 - 0
application/common/model/UserCoupons.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+
+class UserCoupons extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'user_coupons';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'integer';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'endtime_text'
+    ];
+
+
+
+    public function getEndtimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['endtime']) ? $data['endtime'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+    protected function setEndtimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    public function user()
+    {
+        return $this->belongsTo('User', 'user_id', 'id',[],'LEFT')->setEagerlyType(0);
+    }
+
+    public function company()
+    {
+        return $this->belongsTo('Company', 'company_id', 'id',[],'LEFT')->setEagerlyType(0);
+    }
+}