VipCard.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. * 判断是否VIP
  7. */
  8. namespace app\allwin\model;
  9. use think\Model;
  10. class VipCard extends Model{
  11. protected $pk = 'id';
  12. protected $table = 'ai_allwin_vipcard';
  13. protected $autoWriteTimestamp = true;
  14. protected $createTime = false;
  15. //添加或编辑
  16. public static function edit($param,int $id = 0){
  17. if($id){
  18. return self::where(['id' => $id])->update($param);
  19. }else{
  20. $param['update_time'] = time();
  21. return self::insert($param);
  22. }
  23. }
  24. //编辑创客的关联的优惠券
  25. public static function editCoupon(int $vip_id,$coupon_ids){
  26. $info = self::where(['id' => $vip_id])->find();
  27. if(empty($info->coupon_ids)){
  28. $info->coupon_ids = implode(',',$coupon_ids);
  29. }else{
  30. $coupon_ida = explode(',',$info->coupon_ids);
  31. $ida = array_merge($coupon_ida,$coupon_ids);
  32. $info->coupon_ids = implode(',',$ida);
  33. }
  34. return $info->save();
  35. }
  36. }