OrderCount.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class OrderCount extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'order_count';
  9. public static function createuserdata($orderInfo)
  10. {
  11. if (!empty($orderInfo['order_status_id'])) {
  12. $data = ['ptype' => 'user', 'uid' => $orderInfo['uid'], 'order_id' => $orderInfo['id'], 'order_status_id' => $orderInfo['order_status_id']];
  13. if (empty(self::where($data)->find())) {
  14. self::where(['ptype' => 'user', 'uid' => $orderInfo['uid'], 'order_id' => $orderInfo['id']])->update(['is_read' => 1]);
  15. $data['is_read'] = 0;
  16. self::create($data);
  17. }
  18. }
  19. return $data;
  20. }
  21. public static function getUserCount($uid, $order_status_id)
  22. {
  23. return self::where('uid', $uid)->where('ptype', 'user')->where('is_read', 0)->where('order_status_id', $order_status_id)->count();
  24. }
  25. public static function upread($uid, $order_status_id)
  26. {
  27. $where['uid'] = $uid;
  28. $where['ptype'] = 'user';
  29. $where['is_read'] = 0;
  30. if (!empty($order_status_id)) {
  31. $where['order_status_id'] = $order_status_id;
  32. }
  33. //var_dump($where);
  34. return self::where($where)->update(['is_read' => 1]);
  35. }
  36. }