Storewatermark.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 数据层模型
  13. */
  14. class Storewatermark extends BaseModel
  15. {
  16. /**
  17. * 根据店铺id获取水印
  18. * @access public
  19. * @author csdeshang
  20. * @param int $store_id 店铺ID
  21. * @return type
  22. */
  23. public function getOneStorewatermarkByStoreId($store_id)
  24. {
  25. $prefix = 'storewatermark_info';
  26. $cache_info = rcache($store_id, $prefix);
  27. if (empty($cache_info)) {
  28. $wm_arr = Db::name('storewatermark')->where('store_id', $store_id)->find();
  29. $cache = array();
  30. $cache['wm_arr'] = serialize($wm_arr);
  31. wcache($store_id, $cache, $prefix, 60 * 24);
  32. } else {
  33. $wm_arr = unserialize($cache_info['wm_arr']);
  34. }
  35. return $wm_arr;
  36. }
  37. /**
  38. * 新增水印
  39. * @access public
  40. * @author csdeshang
  41. * @param array $data 参数内容
  42. * @return bool 布尔类型的返回结果
  43. */
  44. public function addStorewatermark($data)
  45. {
  46. return Db::name('storewatermark')->insertGetId($data);
  47. }
  48. /**
  49. * 更新水印
  50. * @access public
  51. * @author csdeshang
  52. * @param array $data 更新数据
  53. * @return bool 布尔类型的返回结果
  54. */
  55. public function editStorewatermark($wm_id, $data)
  56. {
  57. $storewatermark_info = Db::name('storewatermark')->where('swm_id', $wm_id)->find();
  58. if ($storewatermark_info) {
  59. //清空缓存
  60. dcache($storewatermark_info['store_id'], 'storewatermark_info');
  61. }
  62. return Db::name('storewatermark')->where('swm_id', $wm_id)->update($data);
  63. }
  64. /**
  65. * 删除水印
  66. * @access public
  67. * @author csdeshang
  68. * @param int $id 记录ID
  69. * @return bool 布尔类型的返回结果
  70. */
  71. public function delStorewatermark($condition)
  72. {
  73. return Db::name('storewatermark')->where($condition)->delete();
  74. }
  75. }