Storesnstracelog.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Storesnstracelog extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 店铺动态列表
  16. * @access public
  17. * @author csdeshang
  18. * @param array $condition 条件
  19. * @param string $field 字段
  20. * @param string $order 排序
  21. * @param int $limit 限制
  22. * @param int $pagesize 分页
  23. * @return array
  24. */
  25. public function getStoresnstracelogList($condition, $field = '*', $order = 'stracelog_id desc', $limit = 0, $pagesize = 0)
  26. {
  27. if ($pagesize) {
  28. $res = Db::name('storesnstracelog')->where($condition)->field($field)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  29. $this->page_info = $res;
  30. return $res->items();
  31. } else {
  32. return Db::name('storesnstracelog')->where($condition)->field($field)->order($order)->limit($limit)->select()->toArray();
  33. }
  34. }
  35. /**
  36. * 获得店铺动态总数
  37. * @access public
  38. * @author csdeshang
  39. * @param array $condition 条件
  40. * @return int
  41. */
  42. public function getStoresnstracelogCount($condition)
  43. {
  44. return Db::name('storesnstracelog')->where($condition)->count();
  45. }
  46. /**
  47. * 获取单条店铺动态
  48. * @access public
  49. * @author csdeshang
  50. * @param array $condition 条件
  51. * @return array
  52. */
  53. public function getStoresnstracelogInfo($condition)
  54. {
  55. return Db::name('storesnstracelog')->where($condition)->find();
  56. }
  57. /**
  58. * 保存店铺动态
  59. * @access public
  60. * @author csdeshang
  61. * @param array $data 数据
  62. * @return boolean
  63. */
  64. public function addStoresnstracelog($data)
  65. {
  66. return Db::name('storesnstracelog')->insertGetId($data);
  67. }
  68. /**
  69. * 保存店铺动态
  70. * @access public
  71. * @author csdeshang
  72. * @param array $data 数据
  73. * @return boolean
  74. */
  75. public function addStoresnstracelogAll($data)
  76. {
  77. return Db::name('storesnstracelog')->insertAll($data);
  78. }
  79. /**
  80. * 更新店铺动态
  81. * @access public
  82. * @author csdeshang
  83. * @param array $update 更新数据
  84. * @param array $condition 条件
  85. * @return boolean
  86. */
  87. public function editStoresnstracelog($update, $condition)
  88. {
  89. return Db::name('storesnstracelog')->where($condition)->update($update);
  90. }
  91. /**
  92. * 删除店铺动态
  93. * @access public
  94. * @author csdeshang
  95. * @param array $condition 条件
  96. * @return boolean
  97. */
  98. public function delStoresnstracelog($condition)
  99. {
  100. return Db::name('storesnstracelog')->where($condition)->delete();
  101. }
  102. /**
  103. * 拼写个类型样式
  104. * @param type $type 动态类型
  105. * @param type $data 相关数据
  106. * @return string
  107. */
  108. public function spellingStyle($type, $data)
  109. {
  110. //1'relay',2'normal',3'new',4'coupon',5'xianshi',6'mansong',7'bundling',8'groupbuy',9'recommend',10'hotsell'
  111. $rs = '';
  112. switch ($type) {
  113. case '2':
  114. break;
  115. case '3':
  116. $rs = "<div class=\"fd-media\">
  117. <div class=\"goodsimg\"><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\"><img src=\"" . goods_cthumb($data['goods_image'], 240, $data['store_id']) . "\" onload=\"javascript:ResizeImage(this,120,120);\" alt=\"" . $data['goods_name'] . "\"></a></div>
  118. <div class=\"goodsinfo\">
  119. <dl>
  120. <dt><i class=\"desc-type desc-type-new\">" . lang('store_sns_new_selease') . "</i><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\">" . $data['goods_name'] . "</a></dt>
  121. <dd>" . lang('sns_sharegoods_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  122. <dd>" . ((isset($data['goods_transfee_charge']) && $data['goods_transfee_charge'] == '1') ? lang('store_sns_free_shipping') : lang('sns_sharegoods_freight') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_freight'])) . "</dd>
  123. <dd dstype=\"collectbtn_" . $data['goods_id'] . "\"><a href=\"javascript:void(0);\" onclick=\"javascript:collect_goods('" . $data['goods_id'] . "','succ','collectbtn_" . $data['goods_id'] . "');\">" . lang('sns_sharegoods_collect') . "</a></dd>
  124. </dl>
  125. </div>
  126. </div>";
  127. break;
  128. case '4':
  129. $rs = "<div class=\"fd-media\">
  130. <div class=\"goodsimg\"><a target=\"_blank\" href=\"" . (string)url('Coupon_store/detail', array('coupon_id' => $data['coupon_id'], 'id' => $data['store_id'])) . "\"><img src=\"" . $data['coupon_pic'] . "\" onerror=\"this.src='" . HOME_SITE_ROOT . "/images/default_coupon_image.png'\" onload=\"javascript:ResizeImage(this,120,120);\" alt=\"" . $data['coupon_title'] . "\"></a></div>
  131. <div class=\"goodsinfo\">
  132. <dl>
  133. <dt><i class=\"desc-type desc-type-coupon\">" . lang('store_sns_coupon') . "</i><a target=\"_blank\" href=\"" . (string)url('Coupon_store/detail', array('coupon_id' => $data['coupon_id'], 'id' => $data['store_id'])) . "\">" . $data['coupon_title'] . "</a></dt>
  134. <dd>" . lang('store_sns_coupon_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['coupon_price']) . "</dd>
  135. <dd>" . lang('store_sns_start-stop_time') . lang('ds_colon') . date('Y-m-d H:i', $data['coupon_start_date']) . "~" . date('Y-m-d H:i', $data['coupon_end_date']) . "</dd>
  136. </dl>
  137. </div>
  138. </div>";
  139. break;
  140. case '5':
  141. $rs = "<div class=\"fd-media\">
  142. <div class=\"goodsimg\"><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\"><img src=\"" . goods_cthumb($data['goods_image'], 240, $data['store_id']) . "\" onload=\"javascript:ResizeImage(this,120,120);\" alt=\"" . $data['goods_name'] . "\"></a></div>
  143. <div class=\"goodsinfo\">
  144. <dl>
  145. <dt><i class=\"desc-type desc-type-xianshi\">" . lang('store_sns_xianshi') . "</i><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\">" . $data['goods_name'] . "</a></dt>
  146. <dd>" . lang('sns_sharegoods_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  147. <dd>" . lang('store_sns_formerprice') . lang('ds_colon') . lang('currency') . ds_price_format($data['xianshigoods_price']) . "</dd>
  148. <dd dstype=\"collectbtn_" . $data['goods_id'] . "\"><a href=\"javascript:void(0);\" onclick=\"javascript:collect_goods('" . $data['goods_id'] . "','succ','collectbtn_" . $data['goods_id'] . "');\">" . lang('sns_sharegoods_collect') . "</a></dd>
  149. </dl>
  150. </div>
  151. </div>";
  152. break;
  153. case '6':
  154. $rs = "<div class=\"fd-media\">
  155. <div class=\"goodsimg\"><a target=\"_blank\" href=\"" . (string)url('Store/index', array('store_id' => $data['store_id'])) . "\"><img src=\"" . HOME_SITE_ROOT . "/images/mjs-pic.gif\" onload=\"javascript:ResizeImage(this,120,120);\" alt=\"" . $data['mansong_name'] . "\"></a></div>
  156. <div class=\"goodsinfo\">
  157. <dl>
  158. <dt><i class=\"desc-type desc-type-mansong\">" . lang('store_sns_mansong') . "</i><a target=\"_blank\" href=\"" . (string)url('Store/index', array('store_id' => $data['store_id'])) . "\">" . $data['mansong_name'] . "</a></dt>
  159. <dd>" . lang('store_sns_start-stop_time') . lang('ds_colon') . date('Y-m-d H:i', $data['mansong_starttime']) . "~" . date('Y-m-d H:i', $data['mansong_endtime']) . "</dd>
  160. </dl>
  161. </div>
  162. </div>";
  163. break;
  164. case '7':
  165. $rs = "<div class=\"fd-media\">
  166. <div class=\"goodsimg\"><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\"><img src=\"" . goods_cthumb($data['bl_img'], 240, $data['store_id']) . "\" onload=\"javascript:ResizeImage(this,120,120);\" alt=\"" . $data['bl_name'] . "\"></a></div>
  167. <div class=\"goodsinfo\">
  168. <dl>
  169. <dt><i class=\"desc-type desc-type-bundling\">" . lang('store_sns_bundling') . "</i><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\">" . $data['bl_name'] . "</a></dt>
  170. <dd>" . lang('store_sns_bundling_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['bl_discount_price']) . "</dd>
  171. <dd>" . (($data['bl_freight_choose'] == 1) ? lang('store_sns_free_shipping') : lang('sns_sharegoods_freight') . lang('ds_colon') . lang('currency') . ds_price_format($data['bl_freight'])) . "</dd>
  172. </dl>
  173. </div>
  174. </div>";
  175. break;
  176. case '8':
  177. $rs = "<div class=\"fd-media\">
  178. <div class=\"goodsimg\"><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\"><img src=\"" . groupbuy_thumb($data['group_pic'], 'small', $data['store_id']) . "\" onload=\"javascript:ResizeImage(this,120,120);\" alt=\"" . $data['group_name'] . "\"></a></div>
  179. <div class=\"goodsinfo\">
  180. <dl>
  181. <dt><i class=\"desc-type desc-type-groupbuy\">" . lang('store_sns_groupbuy') . "</i><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\">" . $data['group_name'] . "</a></dt>
  182. <dd>" . lang('store_sns_goodsprice') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  183. <dd>" . lang('store_sns_groupprice') . lang('ds_colon') . lang('currency') . ds_price_format($data['groupbuy_price']) . "</dd>
  184. <dd>" . lang('store_sns_start-stop_time') . lang('ds_colon') . date('Y-m-d H:i', $data['start_time']) . "~" . date('Y-m-d H:i', $data['end_time']) . "</dd>
  185. </dl>
  186. </div>
  187. </div>";
  188. break;
  189. case '9':
  190. $rs = "<div class=\"fd-media\">
  191. <div class=\"goodsimg\"><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\"><img src=\"" . goods_thumb($data, 240) . "\" onload=\"javascript:ResizeImage(this,120,120);\" alt=\"" . $data['goods_name'] . "\"></a></div>
  192. <div class=\"goodsinfo\">
  193. <dl>
  194. <dt><i class=\"desc-type desc-type-recommend\">" . lang('store_sns_store_recommend') . "</i><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\">" . $data['goods_name'] . "</a></dt>
  195. <dd>" . lang('sns_sharegoods_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  196. <dd>" . lang('sns_sharegoods_freight') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_freight']) . "</dd>
  197. <dd dstype=\"collectbtn_" . $data['goods_id'] . "\"><a href=\"javascript:void(0);\" onclick=\"javascript:collect_goods('" . $data['goods_id'] . "','succ','collectbtn_" . $data['goods_id'] . "');\">" . lang('sns_sharegoods_collect') . "</a></dd>
  198. </dl>
  199. </div>
  200. </div>";
  201. break;
  202. case '10':
  203. $rs = "<div class=\"fd-media\">
  204. <div class=\"goodsimg\"><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\"><img src=\"" . goods_thumb($data, 240) . "\" onload=\"javascript:ResizeImage(this,120,120);\" alt=\"" . $data['goods_name'] . "\"></a></div>
  205. <div class=\"goodsinfo\">
  206. <dl>
  207. <dt><i class=\"desc-type desc-type-hotsell\">" . lang('store_sns_hotsell') . "</i><a target=\"_blank\" href=\"" . (string)url('home/Goods/index', array('goods_id' => $data['goods_id'])) . "\">" . $data['goods_name'] . "</a></dt>
  208. <dd>" . lang('sns_sharegoods_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  209. <dd>" . lang('sns_sharegoods_freight') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_freight']) . "</dd>
  210. <dd dstype=\"collectbtn_" . $data['goods_id'] . "\"><a href=\"javascript:void(0);\" onclick=\"javascript:collect_goods('" . $data['goods_id'] . "','succ','collectbtn_" . $data['goods_id'] . "');\">" . lang('sns_sharegoods_collect') . "</a></dd>
  211. </dl>
  212. </div>
  213. </div>";
  214. break;
  215. }
  216. return $rs;
  217. }
  218. }