PosterTemplate.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\fenxiao\model;
  13. use app\model\BaseModel;
  14. /**
  15. * 海报模板
  16. */
  17. class PosterTemplate extends BaseModel
  18. {
  19. //默认模板数据
  20. const DEFAULT_TEMPLATE = [
  21. 'template_id' => 0,
  22. 'template_type' => 'fenxiao',
  23. 'poster_name' => '',
  24. 'background' => '',
  25. //二维码
  26. 'qrcode_type' => '',
  27. 'qrcode_width' => 80,
  28. 'qrcode_height' => 80,
  29. 'qrcode_top' => 540,
  30. 'qrcode_left' => 260,
  31. //json数据
  32. 'template_json' => [
  33. //头像
  34. 'headimg_is_show' => 1,
  35. 'headimg_shape' => 'circle',
  36. 'headimg_width' => 56,
  37. 'headimg_height' => 56,
  38. 'headimg_top' => 426,
  39. 'headimg_left' => 41,
  40. //昵称
  41. 'nickname_is_show' => 1,
  42. 'nickname_font_size' => 22,
  43. 'nickname_color' => '#faa87a',
  44. 'nickname_width' => 150,
  45. 'nickname_height' => 30,
  46. 'nickname_top' => 515,
  47. 'nickname_left' => 20,
  48. //分享语
  49. 'share_content' => '邀您一起分享赚佣金',
  50. 'share_content_is_show' => 1,
  51. 'share_content_font_size' => 14,
  52. 'share_content_color' => '#8D8D8D',
  53. 'share_content_width' => 130,
  54. 'share_content_height' => 30,
  55. 'share_content_top' => 550,
  56. 'share_content_left' => 20,
  57. ]
  58. ];
  59. /**
  60. * 添加海报模板
  61. * @param array $condition
  62. * @param int $page
  63. * @param int $page_size
  64. * @param string $field
  65. * @param string $order
  66. * @return array
  67. */
  68. public function addPosterTemplate($data)
  69. {
  70. $res = model('poster_template')->add($data);
  71. if ($res === false) {
  72. return $this->error('', 'RESULT_ERROR');
  73. }
  74. return $this->success($res);
  75. }
  76. /**
  77. * 编辑海报模板
  78. * @param $data
  79. * @param $condition
  80. * @return array
  81. */
  82. public function editPosterTemplate($data, $condition)
  83. {
  84. $res = model('poster_template')->update($data, $condition);
  85. if ($res === false) {
  86. return $this->error('', 'SAVE_FAIL');
  87. }
  88. return $this->success($res);
  89. }
  90. /**
  91. * 删除海报模板
  92. * @param array $condition
  93. * @param int $page
  94. * @param int $page_size
  95. * @param string $field
  96. * @param string $order
  97. * @return array
  98. */
  99. public function deletePosterTemplate($condition)
  100. {
  101. $res = model('poster_template')->delete($condition);
  102. if ($res === false) {
  103. return $this->error('', 'RESULT_ERROR');
  104. }
  105. return $this->success($res);
  106. }
  107. /**
  108. * 获取海报模板信息
  109. * @param array $condition
  110. * @param string $field
  111. * @return array
  112. */
  113. public function getPosterTemplateInfo($condition = [], $field = '*')
  114. {
  115. $info = model('poster_template')->getInfo($condition, $field);
  116. return $this->success($info);
  117. }
  118. /**
  119. * 获取海报模板列表
  120. * @param array $condition
  121. * @param string $field
  122. * @param string $order
  123. * @param null $limit
  124. * @return array
  125. */
  126. public function getPosterTemplateList($condition = [], $field = '*', $order = 'create_time desc')
  127. {
  128. $list = model('poster_template')->getList($condition, $field, $order);
  129. return $this->success($list);
  130. }
  131. /**
  132. * 获取海报模板分页列表
  133. * @param array $condition
  134. * @param int $page
  135. * @param int $page_size
  136. * @param string $field
  137. * @param string $order
  138. * @return array
  139. */
  140. public function getPosterTemplatePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $field = '*', $order = 'create_time desc')
  141. {
  142. $list = model('poster_template')->pageList($condition, $field, $order, $page, $page_size);
  143. return $this->success($list);
  144. }
  145. /**
  146. * 对之前的数据做兼容处理
  147. * @param $template_json
  148. */
  149. public function correctTemplateJsonData($template_json)
  150. {
  151. //兼容处理
  152. if (!isset($template_json[ 'share_content_is_show' ])) $template_json[ 'share_content_is_show' ] = 1;
  153. if (!isset($template_json[ 'share_content_font_size' ])) $template_json[ 'share_content_font_size' ] = 14;
  154. if (!isset($template_json[ 'share_content_color' ])) $template_json[ 'share_content_color' ] = '#8D8D8D';
  155. return $this->success($template_json);
  156. }
  157. /*************************** 模板默认数据 ********************************/
  158. public function getMubanInfo($condition = [], $field = '*', $alias = 'a', $join = [])
  159. {
  160. $list = model('poster_muban')->getInfo($condition, $field, $alias, $join);
  161. return $this->success($list);
  162. }
  163. public function getMubanList($condition = [], $field = '*')
  164. {
  165. $list = model('poster_muban')->getList($condition, $field);
  166. return $this->success($list);
  167. }
  168. }