config.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. class Model10{
  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_l'=>$post['back_image_l'],
  9. 'title_big_l'=>$post['title_big_l'],
  10. 'title_small_l'=>$post['title_small_l'],
  11. 'goods_class_1_l'=>$post['goods_class_1_l'],
  12. 'gc_id_l'=>isset($post['gc_id_l'])?$post['gc_id_l']:array(),
  13. 'adv_right_l'=>$post['adv_right_l'],
  14. 'if_fixed_goods_l'=>$post['if_fixed_goods_l'],
  15. 'goods_id_l'=>isset($post['goods_id_l'])?$post['goods_id_l']:array(),
  16. 'goods_class_2_l'=>$post['goods_class_2_l'],
  17. 'goods_sort_l'=>$post['goods_sort_l'],
  18. 'if_fixed_brand_l'=>$post['if_fixed_brand_l'],
  19. 'brand_id_l'=>isset($post['brand_id_l'])?$post['brand_id_l']:array(),
  20. 'goods_class_3_l'=>$post['goods_class_3_l'],
  21. 'back_image_r'=>$post['back_image_r'],
  22. 'title_big_r'=>$post['title_big_r'],
  23. 'title_small_r'=>$post['title_small_r'],
  24. 'goods_class_1_r'=>$post['goods_class_1_r'],
  25. 'gc_id_r'=>isset($post['gc_id_r'])?$post['gc_id_r']:array(),
  26. 'adv_right_r'=>$post['adv_right_r'],
  27. 'if_fixed_goods_r'=>$post['if_fixed_goods_r'],
  28. 'goods_id_r'=>isset($post['goods_id_r'])?$post['goods_id_r']:array(),
  29. 'goods_class_2_r'=>$post['goods_class_2_r'],
  30. 'goods_sort_r'=>$post['goods_sort_r'],
  31. 'if_fixed_brand_r'=>$post['if_fixed_brand_r'],
  32. 'brand_id_r'=>isset($post['brand_id_r'])?$post['brand_id_r']:array(),
  33. 'goods_class_3_r'=>$post['goods_class_3_r'],
  34. );
  35. return ds_callback(true,'',$data);
  36. }
  37. public function formatData($config,$store_id=0){
  38. $config=json_decode($config,true);
  39. $goodsclass_model=model('goodsclass');
  40. $cate_list=array();
  41. if(isset($config['gc_id_l'])){
  42. $temp=$goodsclass_model->getGoodsclassInfoById($config['gc_id_l']);
  43. if($temp){
  44. $temp['children']=$goodsclass_model->getGoodsclassListByParentId($config['gc_id_l']);
  45. foreach($temp['children'] as $k => $child){
  46. $temp['children'][$k]['children']=$goodsclass_model->getGoodsclassListByParentId($child['gc_id']);
  47. }
  48. $cate_list[]=$temp;
  49. }
  50. }
  51. $config['gc_list_l']=$cate_list;
  52. $cate_list=array();
  53. if(isset($config['gc_id_r'])){
  54. $temp=$goodsclass_model->getGoodsclassInfoById($config['gc_id_r']);
  55. if($temp){
  56. $temp['children']=$goodsclass_model->getGoodsclassListByParentId($config['gc_id_r']);
  57. foreach($temp['children'] as $k => $child){
  58. $temp['children'][$k]['children']=$goodsclass_model->getGoodsclassListByParentId($child['gc_id']);
  59. }
  60. $cate_list[]=$temp;
  61. }
  62. }
  63. $config['gc_list_r']=$cate_list;
  64. $goods_model=model('goods');
  65. $goods_list=array();
  66. if($config['if_fixed_goods_l']==1){
  67. if(!empty($config['goods_id_l'])){
  68. $where=array();
  69. if($store_id){
  70. $where[] = array('store_id','=',$store_id);
  71. }
  72. $where[]=array('goods_id','in',array_keys($config['goods_id_l']));
  73. $goods_list=$goods_model->getGoodsOnlineList($where, '*', 0, 'goods_id desc');
  74. $sorted_goods=array();
  75. foreach($goods_list as $v1){
  76. if(empty($sorted_goods)){
  77. $sorted_goods[]=array_merge($v1,array('sort'=>intval($config['goods_id_l'][$v1['goods_id']]['sort'])));
  78. }else{
  79. $c=count($sorted_goods);
  80. foreach($sorted_goods as $k2 => $v2){
  81. if($v2['sort']>intval($config['goods_id_l'][$v1['goods_id']]['sort'])){
  82. array_splice($sorted_goods,$k2,0,array(array_merge($v1,array('sort'=>intval($config['goods_id_l'][$v1['goods_id']]['sort'])))));
  83. break;
  84. }
  85. }
  86. if($c==count($sorted_goods)){
  87. $sorted_goods[]=array_merge($v1,array('sort'=>intval($config['goods_id_l'][$v1['goods_id']]['sort'])));
  88. }
  89. }
  90. }
  91. $goods_list=$sorted_goods;
  92. }
  93. }else{
  94. $order='goods_id desc';
  95. switch(intval($config['goods_sort_l'])){
  96. case 2:
  97. $order='goods_salenum desc';
  98. break;
  99. case 3:
  100. $order='evaluation_good_star desc';
  101. break;
  102. }
  103. $where = array();
  104. if($store_id){
  105. $where[] = array('goodscommon.store_id','=',$store_id);
  106. }
  107. if ($config['goods_class_2_l']) {
  108. $where[]=array('goodscommon.gc_id_1|goodscommon.gc_id_2|goodscommon.gc_id_3|goodscommon.gc_id','=',intval($config['goods_class_2_l']));
  109. }
  110. //所需字段
  111. $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";
  112. $fieldstr .= ',goodscommon.is_virtual,goodscommon.is_goodsfcode,goods.is_have_gift,goodscommon.store_name,goodscommon.is_platform_store';
  113. $goods_list = $goods_model->getGoodsUnionList($where,$fieldstr , $order,'goodscommon.goods_commonid', 10);
  114. }
  115. $config['goods_list_l']=$goods_list;
  116. $goods_list=array();
  117. if($config['if_fixed_goods_r']==1){
  118. if(!empty($config['goods_id_r'])){
  119. $where=array();
  120. if($store_id){
  121. $where[] = array('store_id','=',$store_id);
  122. }
  123. $where[]=array('goods_id','in',array_keys($config['goods_id_r']));
  124. $goods_list=$goods_model->getGoodsOnlineList($where, '*', 0, 'goods_id desc');
  125. $sorted_goods=array();
  126. foreach($goods_list as $v1){
  127. if(empty($sorted_goods)){
  128. $sorted_goods[]=array_merge($v1,array('sort'=>intval($config['goods_id_r'][$v1['goods_id']]['sort'])));
  129. }else{
  130. $c=count($sorted_goods);
  131. foreach($sorted_goods as $k2 => $v2){
  132. if($v2['sort']>intval($config['goods_id_r'][$v1['goods_id']]['sort'])){
  133. array_splice($sorted_goods,$k2,0,array(array_merge($v1,array('sort'=>intval($config['goods_id_r'][$v1['goods_id']]['sort'])))));
  134. break;
  135. }
  136. }
  137. if($c==count($sorted_goods)){
  138. $sorted_goods[]=array_merge($v1,array('sort'=>intval($config['goods_id_r'][$v1['goods_id']]['sort'])));
  139. }
  140. }
  141. }
  142. $goods_list=$sorted_goods;
  143. }
  144. }else{
  145. $order='goods_id desc';
  146. switch(intval($config['goods_sort_r'])){
  147. case 2:
  148. $order='goods_salenum desc';
  149. break;
  150. case 3:
  151. $order='evaluation_good_star desc';
  152. break;
  153. }
  154. $where = array();
  155. if($store_id){
  156. $where[] = array('goodscommon.store_id','=',$store_id);
  157. }
  158. if ($config['goods_class_2_r']) {
  159. $where[]=array('goodscommon.gc_id_1|goodscommon.gc_id_2|goodscommon.gc_id_3|goodscommon.gc_id','=',intval($config['goods_class_2_r']));
  160. }
  161. //所需字段
  162. $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";
  163. $fieldstr .= ',goodscommon.is_virtual,goodscommon.is_goodsfcode,goods.is_have_gift,goodscommon.store_name,goodscommon.is_platform_store';
  164. $goods_list = $goods_model->getGoodsUnionList($where,$fieldstr , $order,'goodscommon.goods_commonid', 10);
  165. }
  166. $config['goods_list_r']=$goods_list;
  167. $brand_model = model('brand');
  168. $brand_list = array();
  169. if ($config['if_fixed_brand_l']) {
  170. if (!empty($config['brand_id_l'])) {
  171. $condition = array();
  172. $condition[] = array('brand_id','in',array_keys($config['brand_id_l']));
  173. $brand_list = $brand_model->getBrandPassedList($condition, '*', 10,Db::raw('FIELD(brand_id, '.implode(',',array_keys($config['brand_id_l'])).')'));
  174. }
  175. } else {
  176. $where = array();
  177. if ($config['goods_class_3_l']) {
  178. $where[] = array('gc_id','=',$config['goods_class_3_l']);
  179. }
  180. $brand_list = $brand_model->getBrandPassedList($where, '*', 10);
  181. }
  182. $config['brand_list_l']=$brand_list;
  183. $brand_list = array();
  184. if ($config['if_fixed_brand_r']) {
  185. if (!empty($config['brand_id_r'])) {
  186. $condition = array();
  187. $condition[] = array('brand_id','in',array_keys($config['brand_id_r']));
  188. $brand_list = $brand_model->getBrandPassedList($condition, '*', 10,Db::raw('FIELD(brand_id, '.implode(',',array_keys($config['brand_id_r'])).')'));
  189. }
  190. } else {
  191. $where = array();
  192. if ($config['goods_class_3_r']) {
  193. $where[] = array('gc_id','=',$config['goods_class_3_r']);
  194. }
  195. $brand_list = $brand_model->getBrandPassedList($where, '*', 10);
  196. }
  197. $config['brand_list_r']=$brand_list;
  198. return ds_callback(true,'',$config);
  199. }
  200. }