EditablePageConfig.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 数据层模型
  15. */
  16. class EditablePageConfig extends BaseModel {
  17. public $page_info;
  18. public $store_id=0;
  19. /**
  20. * 新增可编辑页面配置
  21. * @author csdeshang
  22. * @param array $data 参数内容
  23. * @return bool 布尔类型的返回结果
  24. */
  25. public function addEditablePageConfig($data) {
  26. return Db::name('editable_page_config')->insertGetId($data);
  27. }
  28. /**
  29. * 删除一个可编辑页面配置
  30. * @author csdeshang
  31. * @param array $condition 条件
  32. * @return bool 布尔类型的返回结果
  33. */
  34. public function delEditablePageConfig($condition) {
  35. //删除图片
  36. $editable_page_config_id_list=Db::name('editable_page_config')->where($condition)->column('editable_page_config_id');
  37. if($editable_page_config_id_list){
  38. $upload_condition = array();
  39. $upload_condition[] = array('upload_type','=',7);
  40. $upload_condition[] = array('item_id','in',$editable_page_config_id_list);
  41. $file_name_list=Db::name('upload')->where($upload_condition)->column('file_name');
  42. foreach($file_name_list as $file_name){
  43. @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_EDITABLE_PAGE. DIRECTORY_SEPARATOR .$file_name);
  44. }
  45. model('upload')->delUpload($upload_condition);
  46. }
  47. return Db::name('editable_page_config')->where($condition)->delete();
  48. }
  49. /**
  50. * 获取可编辑页面配置列表
  51. * @author csdeshang
  52. * @param array $condition 查询条件
  53. * @param obj $pagesize 分页页数
  54. * @param str $orderby 排序
  55. * @return array 二维数组
  56. */
  57. public function getEditablePageConfigList($condition = array(), $pagesize = '', $orderby = 'editable_page_config_sort_order asc') {
  58. if ($pagesize) {
  59. $result = Db::name('editable_page_config')->where($condition)->order($orderby)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  60. $this->page_info = $result;
  61. return $result->items();
  62. } else {
  63. return Db::name('editable_page_config')->where($condition)->order($orderby)->select()->toArray();
  64. }
  65. }
  66. public function getOneEditablePageConfig($condition = array()) {
  67. return Db::name('editable_page_config')->where($condition)->find();
  68. }
  69. /**
  70. * 更新可编辑页面配置记录
  71. * @author csdeshang
  72. * @param array $data 更新内容
  73. * @return bool
  74. */
  75. public function editEditablePageConfig($condition, $data) {
  76. return Db::name('editable_page_config')->where($condition)->update($data);
  77. }
  78. public function getEditablePageConfigGoods($goods_info) {
  79. //所需字段
  80. $fieldstr = "goods_id,goods_commonid,store_id,goods_name,goods_advword,goods_price,goods_promotion_price,goods_promotion_type,goods_marketprice,goods_image,goods_salenum,evaluation_good_star,evaluation_count";
  81. $fieldstr .= ',is_virtual,is_goodsfcode,is_have_gift,goods_advword,store_id,store_name,is_platform_store';
  82. $goods_model = model('goods');
  83. $goods_list = array();
  84. $order = 'goods_id desc';
  85. switch ($goods_info['sort']) {
  86. case 'hot':
  87. $order = 'goods_salenum desc';
  88. break;
  89. case 'good':
  90. $order = 'evaluation_good_star desc';
  91. break;
  92. }
  93. if ($goods_info['if_fix']) {
  94. if (!empty($goods_info['goods_id'])) {
  95. $condition = array();
  96. $condition[] = array('goods_id','in',array_keys($goods_info['goods_id']));
  97. $goods_list = $goods_model->getGoodsOnlineList($condition, $fieldstr, $goods_info['count'], Db::raw('FIELD(goods_id, '.implode(',',array_keys($goods_info['goods_id'])).')'));
  98. }
  99. } else {
  100. $where = array();
  101. if($this->store_id){
  102. $where[] = array('store_id','=',$this->store_id);
  103. }
  104. if ($goods_info['gc_id']) {
  105. if($this->store_id){
  106. $where[] = array('goods_stcids','like', '%,' . $goods_info['gc_id'] . ',%');
  107. }else{
  108. //$where[] = array('gc_id','=',$goods_info['gc_id']);
  109. $where=$goods_model->_getRecursiveClass($where,$goods_info['gc_id']);
  110. }
  111. }
  112. $goods_list = $goods_model->getGoodsListByColorDistinct($where, $fieldstr, $order, $goods_info['count']);
  113. }
  114. return $goods_list;
  115. }
  116. public function getEditablePageConfigBrand($brand_info) {
  117. //所需字段
  118. $fieldstr = "*";
  119. $brand_model = model('brand');
  120. $brand_list = array();
  121. if ($brand_info['if_fix']) {
  122. if (!empty($brand_info['brand_id'])) {
  123. $condition = array();
  124. $condition[] = array('brand_id','in',array_keys($brand_info['brand_id']));
  125. $brand_list = $brand_model->getBrandPassedList($condition, $fieldstr, $brand_info['count'],Db::raw('FIELD(brand_id, '.implode(',',array_keys($brand_info['brand_id'])).')'));
  126. }
  127. } else {
  128. $where = array();
  129. if ($brand_info['gc_id']) {
  130. $where[] = array('gc_id','=',$brand_info['gc_id']);
  131. }
  132. $brand_list = $brand_model->getBrandPassedList($where, $fieldstr, $brand_info['count']);
  133. }
  134. return $brand_list;
  135. }
  136. public function getEditablePageConfigCate($cate_info,$model_id) {
  137. $cate_list=array();
  138. foreach($cate_info['list'] as $j => $cate){
  139. if(isset($cate['gc_id'])){
  140. $temp=model('goodsclass')->getGoodsclassInfoById($cate['gc_id']);
  141. if($temp){
  142. if($model_id==8){
  143. $temp['children']=model('goodsclass')->getGoodsclassListByParentId($cate['gc_id']);
  144. foreach($temp['children'] as $k => $child){
  145. $temp['children'][$k]['children']=model('goodsclass')->getGoodsclassListByParentId($child['gc_id']);
  146. }
  147. }
  148. $cate_list[]=$temp;
  149. }
  150. }
  151. }
  152. return $cate_list;
  153. }
  154. }
  155. ?>