AisInfoShare.php 1.5 KB

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