config.php 3.7 KB

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