config.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. class Model6{
  3. public function filterData($post){
  4. $data=array(
  5. 'back_color'=>$post['back_color'],
  6. 'show_format'=>$post['show_format'],
  7. 'goods_count'=>$post['goods_count'],
  8. 'goods_class'=>$post['goods_class'],
  9. 'goods_sort'=>$post['goods_sort'],
  10. 'if_show_goods_icon'=>$post['if_show_goods_icon'],
  11. 'goods_icon'=>$post['goods_icon'],
  12. 'if_fixed_goods'=>$post['if_fixed_goods'],
  13. 'goods_id'=>isset($post['goods_id'])?$post['goods_id']:array(),
  14. );
  15. return ds_callback(true,'',$data);
  16. }
  17. public function formatData($config,$store_id=0){
  18. $config=json_decode($config,true);
  19. $goods_model=model('goods');
  20. $goods_list=array();
  21. if($config['if_fixed_goods']==1){
  22. if(!empty($config['goods_id'])){
  23. $where=array();
  24. if($store_id){
  25. $where[] = array('store_id','=',$store_id);
  26. }
  27. $where[]=array('goods_id','in',array_keys($config['goods_id']));
  28. $goods_list=$goods_model->getGoodsOnlineList($where, '*', 0, 'goods_id desc');
  29. $sorted_goods=array();
  30. foreach($goods_list as $v1){
  31. $v1['goods_image']=goods_thumb($v1);
  32. if(empty($sorted_goods)){
  33. $sorted_goods[]=array_merge($v1,array('sort'=>intval($config['goods_id'][$v1['goods_id']]['sort'])));
  34. }else{
  35. $c=count($sorted_goods);
  36. foreach($sorted_goods as $k2 => $v2){
  37. if($v2['sort']>intval($config['goods_id'][$v1['goods_id']]['sort'])){
  38. array_splice($sorted_goods,$k2,0,array(array_merge($v1,array('sort'=>intval($config['goods_id'][$v1['goods_id']]['sort'])))));
  39. break;
  40. }
  41. }
  42. if($c==count($sorted_goods)){
  43. $sorted_goods[]=array_merge($v1,array('sort'=>intval($config['goods_id'][$v1['goods_id']]['sort'])));
  44. }
  45. }
  46. }
  47. $goods_list=$sorted_goods;
  48. }
  49. }else{
  50. $order='goods_id desc';
  51. switch(intval($config['goods_sort'])){
  52. case 2:
  53. $order='goods_salenum desc';
  54. break;
  55. case 3:
  56. $order='evaluation_good_star desc';
  57. break;
  58. }
  59. $where = array();
  60. if($store_id){
  61. $where[] = array('goodscommon.store_id','=',$store_id);
  62. }
  63. if ($config['goods_class']) {
  64. $where[]=array('goodscommon.gc_id_1|goodscommon.gc_id_2|goodscommon.gc_id_3|goodscommon.gc_id','=',intval($config['goods_class']));
  65. }
  66. //所需字段
  67. $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";
  68. $fieldstr .= ',goodscommon.is_virtual,goodscommon.is_goodsfcode,goods.is_have_gift,goodscommon.store_name,goodscommon.is_platform_store';
  69. $goods_list = $goods_model->getGoodsUnionList($where,$fieldstr , $order,'goodscommon.goods_commonid', intval($config['goods_count']));
  70. foreach($goods_list as $key => $val){
  71. $goods_list[$key]['goods_image']=goods_thumb($val);
  72. }
  73. }
  74. $config['goods_list']=$goods_list;
  75. return ds_callback(true,'',$config);
  76. }
  77. }