Storewatermark.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 数据层模型
  14. */
  15. class Storewatermark extends BaseModel {
  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. $prefix = 'storewatermark_info';
  25. $cache_info = rcache($store_id, $prefix);
  26. if (empty($cache_info)) {
  27. $wm_arr = Db::name('storewatermark')->where('store_id',$store_id)->find();
  28. $cache = array();
  29. $cache['wm_arr'] = serialize($wm_arr);
  30. wcache($store_id, $cache, $prefix, 60 * 24);
  31. }else{
  32. $wm_arr=unserialize($cache_info['wm_arr']);
  33. }
  34. return $wm_arr;
  35. }
  36. /**
  37. * 新增水印
  38. * @access public
  39. * @author csdeshang
  40. * @param array $data 参数内容
  41. * @return bool 布尔类型的返回结果
  42. */
  43. public function addStorewatermark($data) {
  44. return Db::name('storewatermark')->insertGetId($data);
  45. }
  46. /**
  47. * 更新水印
  48. * @access public
  49. * @author csdeshang
  50. * @param array $data 更新数据
  51. * @return bool 布尔类型的返回结果
  52. */
  53. public function editStorewatermark($wm_id,$data) {
  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. return Db::name('storewatermark')->where($condition)->delete();
  70. }
  71. }