AllwinInfoShare.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. use think\helper\Time;
  11. use filter\Filter;
  12. class AllwinInfoShare extends Model{
  13. protected $pk = 'id';
  14. /**
  15. * 判断分享记录如果合规发红包
  16. * @return void
  17. */
  18. public function redRocket(array $param,$ucode = null){
  19. if(empty($ucode)){
  20. return;
  21. }
  22. if ($param['is_pay'] <= 0 || $param['task_money'] <= 0) {
  23. return;
  24. }
  25. $uid = model('SystemUser')->isInvite(Filter::filter_escape($ucode));
  26. if(empty($uid)){
  27. return;
  28. }
  29. list($start,$end) = Time::today();
  30. $condition[] = ['info_id','=',$param['id']];
  31. $condition[] = ['times','>',$start];
  32. $condition[] = ['uid','=',$uid];
  33. $rel = self::where($condition)->find();
  34. if($rel){
  35. return self::where(['info_id'=> $param['id']])->setInc('views',1);
  36. }else{
  37. $data['uid'] = $uid;
  38. $data['info_id'] = $param['id'];
  39. $data['views'] = 1;
  40. $data['times'] = time();
  41. return self::insert($data);
  42. }
  43. }
  44. /**
  45. * 发红包
  46. * @return void
  47. */
  48. public function postRedRocket(array $param,$ucode = null){
  49. }
  50. }