store_msg.model.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * 店铺消息模板模型
  4. *
  5. */
  6. defined('InShopNC') or exit('Access Invalid!');
  7. class store_msgModel extends Model{
  8. public function __construct() {
  9. parent::__construct('store_msg');
  10. }
  11. /**
  12. * 新增店铺消息
  13. * @param unknown $insert
  14. */
  15. public function addStoreMsg($insert) {
  16. $time = time();
  17. $insert['sm_addtime'] = $time;
  18. $sm_id = $this->insert($insert);
  19. if (C('node_chat')) {
  20. @file_get_contents(NODE_SITE_URL.'/store_msg/?id='.$sm_id.'&time='.$time);
  21. }
  22. return $sm_id;
  23. }
  24. /**
  25. * 更新店铺消息表
  26. * @param unknown $condition
  27. * @param unknown $update
  28. */
  29. public function editStoreMsg($condition, $update) {
  30. return $this->where($condition)->update($update);
  31. }
  32. /**
  33. * 查看店铺消息详细
  34. * @param unknown $condition
  35. * @param string $field
  36. */
  37. public function getStoreMsgInfo($condition, $field = '*') {
  38. return $this->field($field)->where($condition)->find();
  39. }
  40. /**
  41. * 店铺消息列表
  42. * @param unknown $condition
  43. * @param string $field
  44. * @param string $page
  45. * @param string $order
  46. */
  47. public function getStoreMsgList($condition, $field = '*', $page = '0', $order = 'sm_id desc') {
  48. return $this->field($field)->where($condition)->order($order)->page($page)->select();
  49. }
  50. /**
  51. * 计算消息数量
  52. * @param unknown $condition
  53. */
  54. public function getStoreMsgCount($condition) {
  55. return $this->where($condition)->count();
  56. }
  57. /**
  58. * 删除店铺消息
  59. * @param unknown $condition
  60. */
  61. public function delStoreMsg($condition) {
  62. $this->where($condition)->delete();
  63. }
  64. }