config.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. class Model9{
  3. public function filterData($post){
  4. $data=array(
  5. 'back_color'=>$post['back_color'],
  6. 'padding_top'=>$post['padding_top'],
  7. 'padding_bottom'=>$post['padding_bottom'],
  8. 'back_image'=>$post['back_image'],
  9. 'title_big'=>$post['title_big'],
  10. 'title_small'=>$post['title_small'],
  11. 'goods_class_1'=>$post['goods_class_1'],
  12. 'gc_id'=>isset($post['gc_id'])?$post['gc_id']:array(),
  13. 'adv_center'=>$post['adv_center'],
  14. 'adv_right'=>$post['adv_right'],
  15. 'if_fixed_goods'=>$post['if_fixed_goods'],
  16. 'goods_id'=>isset($post['goods_id'])?$post['goods_id']:array(),
  17. 'goods_class_2'=>$post['goods_class_2'],
  18. 'goods_sort'=>$post['goods_sort'],
  19. 'if_fixed_brand'=>$post['if_fixed_brand'],
  20. 'brand_id'=>isset($post['brand_id'])?$post['brand_id']:array(),
  21. 'goods_class_3'=>$post['goods_class_3'],
  22. );
  23. return ds_callback(true,'',$data);
  24. }
  25. public function formatData($config,$store_id=0){
  26. $config=json_decode($config,true);
  27. $goodsclass_model=model('goodsclass');
  28. $cate_list=array();
  29. if(isset($config['gc_id'])){
  30. $i=0;
  31. foreach($config['gc_id'] as $gc_id => $val){
  32. $temp=$goodsclass_model->getGoodsclassInfoById($gc_id);
  33. if($temp){
  34. $temp['children']=$goodsclass_model->getGoodsclassListByParentId($gc_id);
  35. foreach($temp['children'] as $k => $child){
  36. $temp['children'][$k]['children']=$goodsclass_model->getGoodsclassListByParentId($child['gc_id']);
  37. }
  38. $cate_list[intval($val['sort'])*10+$i]=$temp;
  39. }
  40. $i++;
  41. }
  42. }
  43. ksort($cate_list);
  44. $config['gc_list']=array_values($cate_list);
  45. $goods_model=model('goods');
  46. $goods_list=array();
  47. if($config['if_fixed_goods']==1){
  48. if(!empty($config['goods_id'])){
  49. $where=array();
  50. if($store_id){
  51. $where[] = array('store_id','=',$store_id);
  52. }
  53. $where[]=array('goods_id','in',array_keys($config['goods_id']));
  54. $goods_list=$goods_model->getGoodsOnlineList($where, '*', 0, 'goods_id desc');
  55. $sorted_goods=array();
  56. foreach($goods_list as $v1){
  57. if(empty($sorted_goods)){
  58. $sorted_goods[]=array_merge($v1,array('sort'=>intval($config['goods_id'][$v1['goods_id']]['sort'])));
  59. }else{
  60. $c=count($sorted_goods);
  61. foreach($sorted_goods as $k2 => $v2){
  62. if($v2['sort']>intval($config['goods_id'][$v1['goods_id']]['sort'])){
  63. array_splice($sorted_goods,$k2,0,array(array_merge($v1,array('sort'=>intval($config['goods_id'][$v1['goods_id']]['sort'])))));
  64. break;
  65. }
  66. }
  67. if($c==count($sorted_goods)){
  68. $sorted_goods[]=array_merge($v1,array('sort'=>intval($config['goods_id'][$v1['goods_id']]['sort'])));
  69. }
  70. }
  71. }
  72. $goods_list=$sorted_goods;
  73. }
  74. }else{
  75. $order='goods_id desc';
  76. switch(intval($config['goods_sort'])){
  77. case 2:
  78. $order='goods_salenum desc';
  79. break;
  80. case 3:
  81. $order='evaluation_good_star desc';
  82. break;
  83. }
  84. $where = array();
  85. if($store_id){
  86. $where[] = array('goodscommon.store_id','=',$store_id);
  87. }
  88. if ($config['goods_class_2']) {
  89. $where[]=array('goodscommon.gc_id_1|goodscommon.gc_id_2|goodscommon.gc_id_3|goodscommon.gc_id','=',intval($config['goods_class_2']));
  90. }
  91. //所需字段
  92. $fieldstr = "goods.goods_id,goods.goods_storage,goodscommon.goods_commonid,goodscommon.store_id,goodscommon.goods_name,goodscommon.goods_advword,goodscommon.goods_price,goods.goods_promotion_price,goods.goods_promotion_type,goodscommon.goods_marketprice,goodscommon.goods_image,goods.goods_salenum,goods.evaluation_good_star,goods.evaluation_count";
  93. $fieldstr .= ',goodscommon.is_virtual,goodscommon.is_goodsfcode,goods.is_have_gift,goodscommon.store_name,goodscommon.is_platform_store';
  94. $goods_list = $goods_model->getGoodsUnionList($where,$fieldstr , $order,'goodscommon.goods_commonid', 10);
  95. }
  96. $config['goods_list']=$goods_list;
  97. $brand_model = model('brand');
  98. $brand_list = array();
  99. if ($config['if_fixed_brand']) {
  100. if (!empty($config['brand_id'])) {
  101. $condition = array();
  102. $condition[] = array('brand_id','in',array_keys($config['brand_id']));
  103. $brand_list = $brand_model->getBrandPassedList($condition, '*', 10,Db::raw('FIELD(brand_id, '.implode(',',array_keys($config['brand_id'])).')'));
  104. }
  105. } else {
  106. $where = array();
  107. if ($config['goods_class_3']) {
  108. $where[] = array('gc_id','=',$config['goods_class_3']);
  109. }
  110. $brand_list = $brand_model->getBrandPassedList($where, '*', 10);
  111. }
  112. $config['brand_list']=$brand_list;
  113. return ds_callback(true,'',$config);
  114. }
  115. }