Userproduct.php 846 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\user\model;
  3. use think\Model;
  4. /**
  5. * 用户管理
  6. */
  7. class Userproduct extends Model
  8. {
  9. public function getProductCount($userId)
  10. {
  11. $result = $this
  12. ->where(['user_id' => $userId])
  13. ->count();
  14. return $result;
  15. }
  16. public function getRenewProductCount($userId)
  17. {
  18. $allData = $this
  19. ->field(['userProduct_dayNumber', 'userProduct_buyTime'])
  20. ->where(['user_id' => $userId])
  21. ->select();
  22. $count = 0;
  23. foreach ($allData as $key => $value) {
  24. $numberDay = $value->userProduct_dayNumber - 15;
  25. $remindDate = date("Y-m-d",strtotime($numberDay . " day"));
  26. if ($value->userProduct_buyTime >= $remindDate) {
  27. $count++;
  28. }
  29. }
  30. return $count;
  31. }
  32. }