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. * ============================================================================
  12. * 数据层模型
  13. */
  14. class Storesnstracelog extends BaseModel
  15. {
  16. public $page_info;
  17. /**
  18. * 店铺动态列表
  19. * @access public
  20. * @author csdeshang
  21. * @param array $condition 条件
  22. * @param string $field 字段
  23. * @param string $order 排序
  24. * @param int $limit 限制
  25. * @param int $pagesize 分页
  26. * @return array
  27. */
  28. public function getStoresnstracelogList($condition, $field = '*', $order = 'stracelog_id desc', $limit = 0, $pagesize = 0)
  29. {
  30. if ($pagesize) {
  31. $res = Db::name('storesnstracelog')->where($condition)->field($field)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  32. $this->page_info = $res;
  33. return $res->items();
  34. } else {
  35. return Db::name('storesnstracelog')->where($condition)->field($field)->order($order)->limit($limit)->select()->toArray();
  36. }
  37. }
  38. /**
  39. * 获得店铺动态总数
  40. * @access public
  41. * @author csdeshang
  42. * @param array $condition 条件
  43. * @return int
  44. */
  45. public function getStoresnstracelogCount($condition)
  46. {
  47. return Db::name('storesnstracelog')->where($condition)->count();
  48. }
  49. /**
  50. * 获取单条店铺动态
  51. * @access public
  52. * @author csdeshang
  53. * @param array $condition 条件
  54. * @return array
  55. */
  56. public function getStoresnstracelogInfo($condition)
  57. {
  58. return Db::name('storesnstracelog')->where($condition)->find();
  59. }
  60. /**
  61. * 保存店铺动态
  62. * @access public
  63. * @author csdeshang
  64. * @param array $data 数据
  65. * @return boolean
  66. */
  67. public function addStoresnstracelog($data)
  68. {
  69. return Db::name('storesnstracelog')->insertGetId($data);
  70. }
  71. /**
  72. * 保存店铺动态
  73. * @access public
  74. * @author csdeshang
  75. * @param array $data 数据
  76. * @return boolean
  77. */
  78. public function addStoresnstracelogAll($data)
  79. {
  80. return Db::name('storesnstracelog')->insertAll($data);
  81. }
  82. /**
  83. * 更新店铺动态
  84. * @access public
  85. * @author csdeshang
  86. * @param array $update 更新数据
  87. * @param array $condition 条件
  88. * @return boolean
  89. */
  90. public function editStoresnstracelog($update, $condition)
  91. {
  92. return Db::name('storesnstracelog')->where($condition)->update($update);
  93. }
  94. /**
  95. * 删除店铺动态
  96. * @access public
  97. * @author csdeshang
  98. * @param array $condition 条件
  99. * @return boolean
  100. */
  101. public function delStoresnstracelog($condition)
  102. {
  103. return Db::name('storesnstracelog')->where($condition)->delete();
  104. }
  105. /**
  106. * 拼写个类型样式
  107. * @param type $type 动态类型
  108. * @param type $data 相关数据
  109. * @return string
  110. */
  111. public function spellingStyle($type, $data)
  112. {
  113. //1'relay',2'normal',3'new',4'coupon',5'xianshi',6'mansong',7'bundling',8'groupbuy',9'recommend',10'hotsell'
  114. $rs = '';
  115. switch ($type) {
  116. case '2':
  117. break;
  118. case '3':
  119. $rs = "<div class=\"fd-media\">
  120. <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>
  121. <div class=\"goodsinfo\">
  122. <dl>
  123. <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>
  124. <dd>" . lang('sns_sharegoods_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  125. <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>
  126. <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>
  127. </dl>
  128. </div>
  129. </div>";
  130. break;
  131. case '4':
  132. $rs = "<div class=\"fd-media\">
  133. <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>
  134. <div class=\"goodsinfo\">
  135. <dl>
  136. <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>
  137. <dd>" . lang('store_sns_coupon_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['coupon_price']) . "</dd>
  138. <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>
  139. </dl>
  140. </div>
  141. </div>";
  142. break;
  143. case '5':
  144. $rs = "<div class=\"fd-media\">
  145. <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>
  146. <div class=\"goodsinfo\">
  147. <dl>
  148. <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>
  149. <dd>" . lang('sns_sharegoods_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  150. <dd>" . lang('store_sns_formerprice') . lang('ds_colon') . lang('currency') . ds_price_format($data['xianshigoods_price']) . "</dd>
  151. <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>
  152. </dl>
  153. </div>
  154. </div>";
  155. break;
  156. case '6':
  157. $rs = "<div class=\"fd-media\">
  158. <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>
  159. <div class=\"goodsinfo\">
  160. <dl>
  161. <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>
  162. <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>
  163. </dl>
  164. </div>
  165. </div>";
  166. break;
  167. case '7':
  168. $rs = "<div class=\"fd-media\">
  169. <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>
  170. <div class=\"goodsinfo\">
  171. <dl>
  172. <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>
  173. <dd>" . lang('store_sns_bundling_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['bl_discount_price']) . "</dd>
  174. <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>
  175. </dl>
  176. </div>
  177. </div>";
  178. break;
  179. case '8':
  180. $rs = "<div class=\"fd-media\">
  181. <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>
  182. <div class=\"goodsinfo\">
  183. <dl>
  184. <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>
  185. <dd>" . lang('store_sns_goodsprice') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  186. <dd>" . lang('store_sns_groupprice') . lang('ds_colon') . lang('currency') . ds_price_format($data['groupbuy_price']) . "</dd>
  187. <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>
  188. </dl>
  189. </div>
  190. </div>";
  191. break;
  192. case '9':
  193. $rs = "<div class=\"fd-media\">
  194. <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>
  195. <div class=\"goodsinfo\">
  196. <dl>
  197. <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>
  198. <dd>" . lang('sns_sharegoods_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  199. <dd>" . lang('sns_sharegoods_freight') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_freight']) . "</dd>
  200. <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>
  201. </dl>
  202. </div>
  203. </div>";
  204. break;
  205. case '10':
  206. $rs = "<div class=\"fd-media\">
  207. <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>
  208. <div class=\"goodsinfo\">
  209. <dl>
  210. <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>
  211. <dd>" . lang('sns_sharegoods_price') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_price']) . "</dd>
  212. <dd>" . lang('sns_sharegoods_freight') . lang('ds_colon') . lang('currency') . ds_price_format($data['goods_freight']) . "</dd>
  213. <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>
  214. </dl>
  215. </div>
  216. </div>";
  217. break;
  218. }
  219. return $rs;
  220. }
  221. }