Storewatermark.php 2.1 KB

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