AisCoupon.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 优惠券管理
  7. */
  8. namespace app\ais\model;
  9. use think\Model;
  10. class AisCoupon extends Model{
  11. protected $pk = 'id';
  12. public function getTypesnameAttr($value,$data){
  13. $status = [0 =>'代金券',1 =>'折扣券',2 =>'兑换券',3 =>'储值券'];
  14. return $status[$data['types']];
  15. }
  16. public function getDegreeAttr($value,$data){
  17. $status = [0 =>'¥'.$data['price'],1 => $data['discount'].' 折',2 => $data['price'].' 次',3 => '¥'.$data['amount']];
  18. return $status[$data['types']];
  19. }
  20. /**
  21. * 好店信息
  22. * @return void
  23. */
  24. public function store(){
  25. return $this->hasOne('AisStore','id','store_id');
  26. }
  27. /**
  28. * 用户已领油
  29. * @return void
  30. */
  31. public function couponuser(){
  32. return $this->hasOne('AisCouponUser','coupon_id','id');
  33. }
  34. //搜索好店名称
  35. public function searchNameAttr($query,$value){
  36. if(!empty($value)){
  37. $query->where('name','like', '%'.$value .'%');
  38. }
  39. }
  40. }