Qrcode.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\wechat\model;
  11. use app\model\BaseModel;
  12. use think\facade\Cache;
  13. /**
  14. * 微信二维码
  15. */
  16. class Qrcode extends BaseModel
  17. {
  18. /***************************************************************** 微信二维码 start ***************************************************************************/
  19. /**
  20. * 添加微信二维码
  21. * @param $data
  22. * @return array
  23. */
  24. public function addQrcode($data)
  25. {
  26. $data[ "update_time" ] = time();
  27. Cache::tag("wechat_qrcode")->clear();
  28. $result = model("wechat_qrcode")->add($data);
  29. return $this->success($result);
  30. }
  31. /**
  32. * 编辑微信二维码
  33. * @param $data
  34. * @param $condition
  35. */
  36. public function editQrcode($data, $condition)
  37. {
  38. $data[ "update_time" ] = time();
  39. Cache::tag("wechat_qrcode")->clear();
  40. $result = model("wechat_qrcode")->update($data, $condition);
  41. return $this->success($result);
  42. }
  43. /**
  44. * 删除微信二维码
  45. * @param $condition
  46. */
  47. public function deleteQrcode($condition)
  48. {
  49. Cache::tag("wechat_qrcode")->clear();
  50. $result = model("wechat_qrcode")->delete($condition);
  51. return $this->success($result);
  52. }
  53. /**
  54. * 设置默认二维码模板
  55. * @param $condition
  56. * @param $is_default
  57. */
  58. public function modifyQrcodeDefault($condition)
  59. {
  60. //将全部模板设置为非默认
  61. Cache::tag("wechat_qrcode")->clear();
  62. model("wechat_qrcode")->update([ "is_default" => 0 ], [ 'is_default' => 1 ]);
  63. $res = model("wechat_qrcode")->update([ "is_default" => 1 ], $condition);
  64. return $this->success($res);
  65. }
  66. /**
  67. * 获取二维码模板详情
  68. * @param $condition
  69. */
  70. public function getQrcodeInfo($condition, $field = "*")
  71. {
  72. $data = json_encode([ $condition, $field ]);
  73. $cache = Cache::get("wechat_qrcode_getQrcodeInfo_" . $data);
  74. if (!empty($cache)) {
  75. return $this->success($cache);
  76. }
  77. $info = model('wechat_qrcode')->getInfo($condition, $field);
  78. Cache::tag("wechat_qrcode")->set("wechat_qrcode_getQrcodeInfo_" . $data, $info);
  79. return $this->success($info);
  80. }
  81. /**
  82. * 获取微信二维码列表
  83. * @param array $condition
  84. * @param number $page
  85. * @param string $page_size
  86. * @param string $order
  87. * @param string $field
  88. */
  89. public function getQrcodePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
  90. {
  91. $data = json_encode([ $condition, $page, $page_size, $order, $field ]);
  92. $cache = Cache::get("wechat_qrcode_getQrcodePageList_" . $data);
  93. if (!empty($cache)) {
  94. return $this->success($cache);
  95. }
  96. $list = model('wechat_qrcode')->pageList($condition, $field, $order, $page, $page_size);
  97. Cache::tag("wechat_qrcode")->set("wechat_qrcode_getQrcodePageList_" . $data, $list);
  98. return $this->success($list);
  99. }
  100. /***************************************************************** 微信粉丝 end ***************************************************************************/
  101. }