PosterTemplate.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\postertemplate\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' => 'goods',
  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' => 30,
  37. 'headimg_height' => 30,
  38. 'headimg_top' => 30,
  39. 'headimg_left' => 20,
  40. //昵称
  41. 'nickname_is_show' => 1,
  42. 'nickname_color' => '#000000',
  43. 'nickname_font_size' => 14,
  44. 'nickname_width' => 150,
  45. 'nickname_height' => 14,
  46. 'nickname_top' => 36,
  47. 'nickname_left' => 60,
  48. //商品图片
  49. 'goods_img_is_show' => 1,
  50. 'goods_img_top' => 233,
  51. 'goods_img_left' => 19,
  52. 'goods_img_width' => 300,
  53. 'goods_img_height' => 300,
  54. //商品名称
  55. 'goods_name_is_show' => 1,
  56. 'goods_name_color' => '#000000',
  57. 'goods_name_font_size' => 14,
  58. 'goods_name_top' => 174,
  59. 'goods_name_left' => 40,
  60. 'goods_name_width' => 200,
  61. 'goods_name_height' => 30,
  62. //商品销售价
  63. 'goods_price_is_show' => 1,
  64. 'goods_price_color' => '#FF4544',
  65. 'goods_price_font_size' => 18,
  66. 'goods_price_width' => 100,
  67. 'goods_price_height' => 14,
  68. 'goods_price_top' => 568,
  69. 'goods_price_left' => 28,
  70. //商品划线价
  71. 'goods_market_price_is_show' => 1,
  72. 'goods_market_price_color' => '#000000',
  73. 'goods_market_price_font_size' => 14,
  74. 'goods_market_price_width' => 100,
  75. 'goods_market_price_height' => 14,
  76. 'goods_market_price_top' => 572,
  77. 'goods_market_price_left' => 108,
  78. //店铺名称
  79. 'store_name_is_show' => 1,
  80. 'store_name_color' => '#000000',
  81. 'store_name_font_size' => 14,
  82. 'store_name_width' => 80,
  83. 'store_name_height' => 20,
  84. 'store_name_top' => 44,
  85. 'store_name_left' => 270,
  86. //店铺logo
  87. 'store_logo_is_show' => 1,
  88. 'store_logo_width' => 60,
  89. 'store_logo_height' => 25,
  90. 'store_logo_top' => 21,
  91. 'store_logo_left' => 270,
  92. ]
  93. ];
  94. /**
  95. * 添加海报模板
  96. * @param array $condition
  97. * @param int $page
  98. * @param int $page_size
  99. * @param string $field
  100. * @param string $order
  101. * @return array
  102. */
  103. public function addPosterTemplate($data)
  104. {
  105. $res = model('poster_template')->add($data);
  106. if ($res === false) {
  107. return $this->error('', 'RESULT_ERROR');
  108. }
  109. return $this->success($res);
  110. }
  111. /**
  112. * 编辑海报模板
  113. * @param $data
  114. * @param $condition
  115. * @return array
  116. */
  117. public function editPosterTemplate($data, $condition)
  118. {
  119. $res = model('poster_template')->update($data, $condition);
  120. if ($res === false) {
  121. return $this->error('', 'SAVE_FAIL');
  122. }
  123. return $this->success($res);
  124. }
  125. /**
  126. * 删除海报模板
  127. * @param array $condition
  128. * @param int $page
  129. * @param int $page_size
  130. * @param string $field
  131. * @param string $order
  132. * @return array
  133. */
  134. public function deletePosterTemplate($condition)
  135. {
  136. $res = model('poster_template')->delete($condition);
  137. if ($res === false) {
  138. return $this->error('', 'RESULT_ERROR');
  139. }
  140. return $this->success($res);
  141. }
  142. /**
  143. * 获取海报模板信息
  144. * @param array $condition
  145. * @param string $field
  146. * @return array
  147. */
  148. public function getPosterTemplateInfo($condition = [], $field = '*')
  149. {
  150. $info = model('poster_template')->getInfo($condition, $field);
  151. return $this->success($info);
  152. }
  153. /**
  154. * 获取海报模板列表
  155. * @param array $condition
  156. * @param string $field
  157. * @param string $order
  158. * @param null $limit
  159. * @return array
  160. */
  161. public function getPosterTemplateList($condition = [], $field = '*', $order = 'create_time desc')
  162. {
  163. $list = model('poster_template')->getList($condition, $field, $order);
  164. return $this->success($list);
  165. }
  166. /**
  167. * 获取海报模板分页列表
  168. * @param array $condition
  169. * @param int $page
  170. * @param int $page_size
  171. * @param string $field
  172. * @param string $order
  173. * @return array
  174. */
  175. public function getPosterTemplatePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $field = '*', $order = 'create_time desc')
  176. {
  177. $list = model('poster_template')->pageList($condition, $field, $order, $page, $page_size);
  178. return $this->success($list);
  179. }
  180. /*************************** 模板默认数据 ********************************/
  181. public function getMubanInfo($condition = [], $field = '*', $alias = 'a', $join = [])
  182. {
  183. $list = model('poster_muban')->getInfo($condition, $field, $alias, $join);
  184. return $this->success($list);
  185. }
  186. public function getMubanList($condition = [], $field = '*')
  187. {
  188. $list = model('poster_muban')->getList($condition, $field);
  189. return $this->success($list);
  190. }
  191. }