AllwinGift.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\allwin\model;
  9. use think\Model;
  10. class AllwinGift extends Model{
  11. protected $pk = 'id';
  12. //赠送优惠券
  13. public function coupon(){
  14. return $this->hasOne('Coupon','id','coupon_id');
  15. }
  16. //添加或编辑
  17. public static function edit(array $param){
  18. $data = [
  19. 'types' => $param['types'],
  20. 'pay_num' => $param['pay_num'],
  21. 'pay_amount' => $param['pay_amount'],
  22. 'coupon_id' => $param['coupon_id'],
  23. 'title' => $param['title'],
  24. 'share_img' => $param['share_img'],
  25. 'share_title' => $param['share_title'],
  26. 'share_text' => $param['share_text'],
  27. 'note' => $param['note'],
  28. 'start_time' => strtotime($param['start_time']),
  29. 'end_time' => strtotime($param['end_time']),
  30. ];
  31. if(isset($param['id'])){
  32. $condition['id'] = $param['id'];
  33. $condition['member_miniapp_id'] = $param['member_miniapp_id'];
  34. return self::where($condition)->update($data);
  35. }else{
  36. $data['member_miniapp_id'] = $param['member_miniapp_id'];
  37. return self::insert($data);
  38. }
  39. }
  40. }