| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\user\model;
- use think\Model;
- /**
- * 用户管理
- */
- class Userproduct extends Model
- {
- public function getProductCount($userId)
- {
- $result = $this
- ->where(['user_id' => $userId])
- ->count();
- return $result;
- }
- public function getRenewProductCount($userId)
- {
- $allData = $this
- ->field(['userProduct_maturityTime'])
- ->where(['user_id' => $userId])
- ->select();
- $count = 0;
- foreach ($allData as $key => $value) {
- $remindDate = date("Y-m-d",strtotime(15 . " day"));
- if ($value->userProduct_maturityTime <= $remindDate) {
- $count++;
- }
- }
- return $count;
- }
- public function getUserProduct($condition)
- {
- $result = $this
- ->alias('a')
- ->join('product b', 'a.product_id = b.product_id')
- ->where($condition)
- ->order('userProduct_buyTime desc')
- ->paginate(10);
- return $result;
- }
- public function findUserProduct($condition)
- {
- $result = $this
- ->where($condition)
- ->find();
- return $result;
- }
- public function updateUserProduct($condition, $data)
- {
- $result = $this
- ->where($condition)
- ->update($data);
- return $result;
- }
- }
|