Browse Source

优质供应商商品

zhijiezhao 2 tháng trước cách đây
mục cha
commit
10a8a9d35b

+ 13 - 0
src/main/java/com/caimei/modules/newhome/dao/NewPageQualitySupplierDao.java

@@ -1,9 +1,13 @@
 package com.caimei.modules.newhome.dao;
 
 import com.caimei.modules.newhome.entity.NewPageQualitySupplierImage;
+import com.caimei.modules.product.entity.Product;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import com.caimei.modules.newhome.entity.NewPageQualitySupplier;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 优质供应商DAO接口
@@ -16,4 +20,13 @@ public interface NewPageQualitySupplierDao extends CrudDao<NewPageQualitySupplie
     int updateImage(NewPageQualitySupplierImage newPageQualitySupplierImage);
     NewPageQualitySupplierImage getImage();
     int saveSort(NewPageQualitySupplier newPageQualitySupplier);
+
+    List<Product> findSupplierProducts(NewPageQualitySupplier newPageQualitySupplier);
+
+    void delProduct(@Param("id")Integer id,@Param("productId") Integer productId);
+
+    List<Product> findProductList(Product product);
+    void addProducts(@Param("id")Integer id,@Param("split") String[] split);
+
+    void updateSort(@Param("sort")String sort, @Param("id")String id);
 }

+ 19 - 0
src/main/java/com/caimei/modules/newhome/entity/NewPageQualitySupplier.java

@@ -12,6 +12,9 @@ import com.thinkgem.jeesite.common.persistence.DataEntity;
 public class NewPageQualitySupplier extends DataEntity<NewPageQualitySupplier> {
 	
 	private static final long serialVersionUID = 1L;
+
+	private Integer productId;
+	private Integer shopId;
 	private String supplierName;		// 供应商名称
 	private String image;		// 供应商图片
 	private String link;		// 链接
@@ -27,6 +30,22 @@ public class NewPageQualitySupplier extends DataEntity<NewPageQualitySupplier> {
 		super(id);
 	}
 
+	public Integer getProductId() {
+		return productId;
+	}
+
+	public void setProductId(Integer productId) {
+		this.productId = productId;
+	}
+
+	public Integer getShopId() {
+		return shopId;
+	}
+
+	public void setShopId(Integer shopId) {
+		this.shopId = shopId;
+	}
+
 	@Length(min=0, max=20, message="供应商名称长度必须介于 0 和 20 之间")
 	public String getSupplierName() {
 		return supplierName;

+ 84 - 60
src/main/java/com/caimei/modules/newhome/service/NewPageQualitySupplierService.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.caimei.modules.hehe.util.UploadPicUtils;
 import com.caimei.modules.newhome.entity.NewPageQualitySupplierImage;
+import com.caimei.modules.product.entity.Product;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -18,6 +19,7 @@ import javax.servlet.http.HttpServletRequest;
 
 /**
  * 优质供应商Service
+ *
  * @author ye.qiin
  * @version 2019-03-18
  */
@@ -25,64 +27,86 @@ import javax.servlet.http.HttpServletRequest;
 @Transactional(readOnly = true)
 public class NewPageQualitySupplierService extends CrudService<NewPageQualitySupplierDao, NewPageQualitySupplier> {
 
-	@Resource
-	private NewPageQualitySupplierDao newPageQualitySupplierDao;
-
-
-	public NewPageQualitySupplier get(String id) {
-		return super.get(id);
-	}
-
-	public NewPageQualitySupplierImage getImage() {
-		return newPageQualitySupplierDao.getImage();
-	}
-
-	public List<NewPageQualitySupplier> findList(NewPageQualitySupplier newPageQualitySupplier) {
-		return super.findList(newPageQualitySupplier);
-	}
-	
-	public Page<NewPageQualitySupplier> findPage(Page<NewPageQualitySupplier> page, NewPageQualitySupplier newPageQualitySupplier) {
-		page.setOrderBy("sort");
-		return super.findPage(page, newPageQualitySupplier);
-	}
-	
-	@Transactional(readOnly = false)
-	public void save(NewPageQualitySupplier newPageQualitySupplier, HttpServletRequest request) {
-		if(null != newPageQualitySupplier.getImage() && !"".equals(newPageQualitySupplier.getImage())){
-			String img = UploadPicUtils.saveImageToServer(newPageQualitySupplier.getImage());
-			newPageQualitySupplier.setImage(img);
-		}
-		super.save(newPageQualitySupplier);
-	}
-
-	@Transactional(readOnly = false)
-	public void saveSort(NewPageQualitySupplier newPageQualitySupplier, HttpServletRequest request) {
-		newPageQualitySupplierDao.saveSort(newPageQualitySupplier);
-	}
-
-
-	@Transactional(readOnly = false)
-	public void saveImage(NewPageQualitySupplierImage newPageQualitySupplierImage, HttpServletRequest request) {
-		if(null != newPageQualitySupplierImage.getCrmImage() && !"".equals(newPageQualitySupplierImage.getCrmImage())){
-			String img = UploadPicUtils.saveImageToServer(newPageQualitySupplierImage.getCrmImage());
-			newPageQualitySupplierImage.setCrmImage(img);
-		}
-		if(null != newPageQualitySupplierImage.getWwwImage() && !"".equals(newPageQualitySupplierImage.getWwwImage())){
-			String img = UploadPicUtils.saveImageToServer(newPageQualitySupplierImage.getWwwImage());
-			newPageQualitySupplierImage.setWwwImage(img);
-		}
-		String id = newPageQualitySupplierImage.getId();
-		if(StringUtils.isNotEmpty(id)){
-			newPageQualitySupplierDao.updateImage(newPageQualitySupplierImage);
-		}else{
-			newPageQualitySupplierDao.saveImage(newPageQualitySupplierImage);
-		}
-
-	}
-	
-	@Transactional(readOnly = false)
-	public void delete(NewPageQualitySupplier newPageQualitySupplier) {
-		super.delete(newPageQualitySupplier);
-	}
-	
+    @Resource
+    private NewPageQualitySupplierDao newPageQualitySupplierDao;
+
+
+    public NewPageQualitySupplier get(String id) {
+        return super.get(id);
+    }
+
+    public NewPageQualitySupplierImage getImage() {
+        return newPageQualitySupplierDao.getImage();
+    }
+
+    public List<NewPageQualitySupplier> findList(NewPageQualitySupplier newPageQualitySupplier) {
+        return super.findList(newPageQualitySupplier);
+    }
+
+    public Page<NewPageQualitySupplier> findPage(Page<NewPageQualitySupplier> page, NewPageQualitySupplier newPageQualitySupplier) {
+        page.setOrderBy("sort");
+        return super.findPage(page, newPageQualitySupplier);
+    }
+
+    @Transactional(readOnly = false)
+    public void save(NewPageQualitySupplier newPageQualitySupplier, HttpServletRequest request) {
+        if (null != newPageQualitySupplier.getImage() && !"".equals(newPageQualitySupplier.getImage())) {
+            String img = UploadPicUtils.saveImageToServer(newPageQualitySupplier.getImage());
+            newPageQualitySupplier.setImage(img);
+        }
+        super.save(newPageQualitySupplier);
+    }
+
+    @Transactional(readOnly = false)
+    public void saveSort(NewPageQualitySupplier newPageQualitySupplier, HttpServletRequest request) {
+        newPageQualitySupplierDao.saveSort(newPageQualitySupplier);
+    }
+
+
+    @Transactional(readOnly = false)
+    public void saveImage(NewPageQualitySupplierImage newPageQualitySupplierImage, HttpServletRequest request) {
+        if (null != newPageQualitySupplierImage.getCrmImage() && !"".equals(newPageQualitySupplierImage.getCrmImage())) {
+            String img = UploadPicUtils.saveImageToServer(newPageQualitySupplierImage.getCrmImage());
+            newPageQualitySupplierImage.setCrmImage(img);
+        }
+        if (null != newPageQualitySupplierImage.getWwwImage() && !"".equals(newPageQualitySupplierImage.getWwwImage())) {
+            String img = UploadPicUtils.saveImageToServer(newPageQualitySupplierImage.getWwwImage());
+            newPageQualitySupplierImage.setWwwImage(img);
+        }
+        String id = newPageQualitySupplierImage.getId();
+        if (StringUtils.isNotEmpty(id)) {
+            newPageQualitySupplierDao.updateImage(newPageQualitySupplierImage);
+        } else {
+            newPageQualitySupplierDao.saveImage(newPageQualitySupplierImage);
+        }
+
+    }
+
+    @Transactional(readOnly = false)
+    public void delete(NewPageQualitySupplier newPageQualitySupplier) {
+        super.delete(newPageQualitySupplier);
+    }
+
+    public List<Product> findSupplierProducts(NewPageQualitySupplier newPageQualitySupplier) {
+        return newPageQualitySupplierDao.findSupplierProducts(newPageQualitySupplier);
+    }
+
+    @Transactional(readOnly = false)
+    public void productDel(Integer id, Integer productId) {
+        newPageQualitySupplierDao.delProduct(id, productId);
+    }
+
+    public List<Product> findProductList(Product product) {
+        return newPageQualitySupplierDao.findProductList(product);
+    }
+
+    @Transactional(readOnly = false)
+    public void addProducts(Integer id, String[] split) {
+        newPageQualitySupplierDao.addProducts(id, split);
+    }
+
+    @Transactional(readOnly = false)
+    public void saveBatchSort(String sort, String id) {
+        newPageQualitySupplierDao.updateSort(sort, id);
+    }
 }

+ 273 - 173
src/main/java/com/caimei/modules/newhome/web/NewPageQualitySupplierController.java

@@ -8,7 +8,10 @@ import com.caimei.constants.common.RedisKeyUtil;
 import com.caimei.modules.newhome.entity.NewPageQualitySupplierImage;
 import com.caimei.modules.opensearch.GenerateUtils;
 import com.caimei.modules.product.entity.CmBigtype;
+import com.caimei.modules.product.entity.CmProductCombination;
+import com.caimei.modules.product.entity.Product;
 import com.caimei.redis.RedisService;
+import com.caimei.utils.AppUtils;
 import com.google.common.collect.Maps;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -33,6 +36,7 @@ import java.util.regex.Pattern;
 
 /**
  * 优质供应商Controller
+ *
  * @author ye.qiin
  * @version 2019-03-18
  */
@@ -40,181 +44,277 @@ import java.util.regex.Pattern;
 @RequestMapping(value = "${adminPath}/newhome/newPageQualitySupplier")
 public class NewPageQualitySupplierController extends BaseController {
 
-	@Resource
-	private NewPageQualitySupplierService newPageQualitySupplierService;
-	@Resource
-	private RedisService redisService;
+    @Resource
+    private NewPageQualitySupplierService newPageQualitySupplierService;
+    @Resource
+    private RedisService redisService;
     @Resource
     private GenerateUtils generateUtils;
-	
-	
-	
-	@ModelAttribute
-	public NewPageQualitySupplier get(@RequestParam(required=false) String id) {
-		NewPageQualitySupplier entity = null;
-		if (StringUtils.isNotBlank(id)){
-			entity = newPageQualitySupplierService.get(id);
-		}
-		if (entity == null){
-			entity = new NewPageQualitySupplier();
-		}
-		return entity;
-	}
-
-	@RequiresPermissions("newhome:newPageQualitySupplier:view")
-	@RequestMapping(value = {"list", ""})
-	public String list(NewPageQualitySupplier newPageQualitySupplier, HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<NewPageQualitySupplier> page = newPageQualitySupplierService.findPage(new Page<NewPageQualitySupplier>(request, response), newPageQualitySupplier);
-		model.addAttribute("page", page);
-		return "modules/newhome/newPageQualitySupplierList";
-	}
-
-	@RequiresPermissions("newhome:newPageQualitySupplier:view")
-	@RequestMapping(value = "form")
-	public String form(NewPageQualitySupplier newPageQualitySupplier, Model model) {
-		model.addAttribute("newPageQualitySupplier", newPageQualitySupplier);
-		return "modules/newhome/newPageQualitySupplierForm";
-	}
-
-	@RequiresPermissions("newhome:newPageQualitySupplier:view")
-	@RequestMapping(value = "formImage")
-	public String formImage(NewPageQualitySupplierImage newPageQualitySupplierImage, Model model) {
-		NewPageQualitySupplierImage image = newPageQualitySupplierService.getImage();
-		model.addAttribute("NewPageQualitySupplierImage", image);
-		return "modules/newhome/newPageQualitySupplierImage";
-	}
-
-
-	@RequiresPermissions("newhome:newPageQualitySupplier:edit")
-	@RequestMapping(value = "saveImage")
-	public String saveImage(NewPageQualitySupplierImage newPageQualitySupplierImage,HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, newPageQualitySupplierImage)){
-			return formImage(newPageQualitySupplierImage, model);
-		}
-		if (checkValidator(model, newPageQualitySupplierImage)){
-			return formImage(newPageQualitySupplierImage, model);
-		}
-		newPageQualitySupplierService.saveImage(newPageQualitySupplierImage,request);
-		cleanRedisCache();
-		addMessage(redirectAttributes, "保存供应商广告图成功");
-		return "redirect:"+Global.getAdminPath()+"/newhome/newPageQualitySupplier/";
-	}
-
-	private boolean checkValidator(Model model, NewPageQualitySupplierImage image) {
-		if (!beanValidator(model, image)){
-			return true;
-		}
-		if (StringUtils.isEmpty(image.getWwwImage())) {
-			model.addAttribute("errorMsg", "请上传网站端图!");
-			return true;
-		}
-		if (StringUtils.isEmpty(image.getCrmImage())) {
-			model.addAttribute("errorMsg", "请上传小程序端图!");
-			return true;
-		}
-		return false;
-	}
-
-	@RequiresPermissions("newhome:newPageQualitySupplier:edit")
-	@RequestMapping(value = "batchSaveSort")
-	@ResponseBody
-	public  Map<String, Object>  batchSaveSort(String newPageList, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
-		Map<String, Object> map = Maps.newLinkedHashMap();
-		try {
-			String[]  newPageLists = newPageList.split(",");
-			for(String list:newPageLists){
-				String[] split = list.split("-");
-				String s = split[1];//判断是否是数字,或者为空
-				if(StringUtils.isNotEmpty(s)){
-			 		if( isInteger(s)){
-						NewPageQualitySupplier newPageQualitySupplier = new NewPageQualitySupplier();
-						newPageQualitySupplier.setId(split[0]);
-						newPageQualitySupplier.setSort(split[1]);
-						newPageQualitySupplierService.saveSort(newPageQualitySupplier,request);
-					}else{
-						map.put("success",false);
-						map.put("msg", "排序值只能为数字");
-						return map;
-					}
-				}else{
-					map.put("success",false);
-					map.put("msg", "排序不能为空");
-					return map;
-				}
-			}
-			cleanRedisCache();
-			map.put("success",true);
-			map.put("msg", "保存排序成功");
-			return map;
-		} catch (Exception e) {
-			map.put("success",false);
-			map.put("msg", "更新排序失败,排序不能为空");
-			return map;
-		}
-	}
-
-
-	public static boolean isInteger(String str) {
-		Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
-		return pattern.matcher(str).matches();
-	}
-
-
-	@RequiresPermissions("newhome:newPageQualitySupplier:edit")
-	@RequestMapping(value = "save")
-	public String save(NewPageQualitySupplier newPageQualitySupplier,HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, newPageQualitySupplier)){
-			return form(newPageQualitySupplier, model);
-		}
-		newPageQualitySupplierService.save(newPageQualitySupplier,request);
-		cleanRedisCache();
-		addMessage(redirectAttributes, "保存优质供应商成功");
-		return "redirect:"+Global.getAdminPath()+"/newhome/newPageQualitySupplier/?repage";
-	}
-
-	@RequiresPermissions("newhome:newPageQualitySupplier:delete")
-	@RequestMapping(value = "delete")
-	public String delete(NewPageQualitySupplier newPageQualitySupplier, RedirectAttributes redirectAttributes) {
-		newPageQualitySupplierService.delete(newPageQualitySupplier);
-		cleanRedisCache();
-		addMessage(redirectAttributes, "删除优质供应商成功");
-		return "redirect:"+Global.getAdminPath()+"/newhome/newPageQualitySupplier/?repage";
-	}
-	@RequiresPermissions("newhome:newPageHomeimage:edit")
-	@ResponseBody
-	@RequestMapping(value="updateEnabledStatus")
-	public Map<String, Object> updateEnabledStatus(String enabledStatus, String[] ids, String [] supplierIDs, HttpServletRequest request, HttpServletResponse response){
-		Map<String, Object> map = Maps.newLinkedHashMap();
-		try {
-			newPageQualitySupplierService.updateEnabledStatusByIds(enabledStatus,ids);
-			cleanRedisCache();
-			map.put("success",true);
-			map.put("msg", "修改成功");
-		} catch (Exception e) {
-			logger.debug(e.toString(),e);
-			map.put("success",false);
-			map.put("msg", "修改失败");
-		}
-		return map;
-	}
-
-	@RequiresPermissions("newhome:newPageHomeimage:edit")
-	@ResponseBody
-	@RequestMapping(value="updateCrmEnabledStatusByIds")
-	public Map<String, Object> updateCrmEnabledStatusByIds(String crmEnabledStatus, String[] ids, String [] supplierIDs, HttpServletRequest request, HttpServletResponse response){
-		Map<String, Object> map = Maps.newLinkedHashMap();
-		try {
-			newPageQualitySupplierService.updateCrmEnabledStatusByIds(crmEnabledStatus,ids);
-			cleanRedisCache();
-			map.put("success",true);
-			map.put("msg", "修改成功");
-		} catch (Exception e) {
-			logger.debug(e.toString(),e);
-			map.put("success",false);
-			map.put("msg", "修改失败");
-		}
-		return map;
-	}
+
+
+    @ModelAttribute
+    public NewPageQualitySupplier get(@RequestParam(required = false) String id) {
+        NewPageQualitySupplier entity = null;
+        if (StringUtils.isNotBlank(id)) {
+            entity = newPageQualitySupplierService.get(id);
+        }
+        if (entity == null) {
+            entity = new NewPageQualitySupplier();
+        }
+        return entity;
+    }
+
+    @RequiresPermissions("newhome:newPageQualitySupplier:view")
+    @RequestMapping(value = {"list", ""})
+    public String list(NewPageQualitySupplier newPageQualitySupplier, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<NewPageQualitySupplier> page = newPageQualitySupplierService.findPage(new Page<NewPageQualitySupplier>(request, response), newPageQualitySupplier);
+        model.addAttribute("page", page);
+        return "modules/newhome/newPageQualitySupplierList";
+    }
+
+    @RequiresPermissions("newhome:newPageQualitySupplier:view")
+    @RequestMapping(value = "form")
+    public String form(NewPageQualitySupplier newPageQualitySupplier, Model model) {
+        model.addAttribute("newPageQualitySupplier", newPageQualitySupplier);
+        return "modules/newhome/newPageQualitySupplierForm";
+    }
+
+    @RequiresPermissions("newhome:newPageQualitySupplier:view")
+    @RequestMapping(value = "product")
+    public String productList(NewPageQualitySupplier newPageQualitySupplier, Model model) {
+        List<Product> productList = newPageQualitySupplierService.findSupplierProducts(newPageQualitySupplier);
+        model.addAttribute("productList", productList);
+        model.addAttribute("newPageQualitySupplier", newPageQualitySupplier);
+        return "modules/newhome/newPageProductList";
+    }
+
+    @RequestMapping(value = "batchSaveSorts")
+    @ResponseBody
+    public Map<String, Object> batchSaveSorts(String newProducSorttList, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            String[]  newPageLists = newProducSorttList.split(",");
+            for(String list:newPageLists){
+                String[] split = list.split("-");
+                if(split.length == 1 || split.length < 1){
+                    map.put("success",false);
+                    map.put("msg", "排序值不能为空!");
+                    return map;
+                }
+                String s = split[1];
+                //判断是否是数字,或者为空
+                if(StringUtils.isNotEmpty(s)){
+                    if( isInteger(s)){
+                        String id = split[0];
+                        String sort = split[1];
+                        //保存数据,
+                        newPageQualitySupplierService.saveBatchSort(sort,id);
+                    }else{
+                        map.put("success",false);
+                        map.put("msg", "排序值只能为数字");
+                        return map;
+                    }
+                }else{
+                    map.put("success",false);
+                    map.put("msg", "排序值不能为空!");
+                    return map;
+                }
+            }
+            map.put("success",true);
+            map.put("msg", "更新排序成功");
+            return map;
+        } catch (Exception e) {
+            map.put("success",false);
+            map.put("msg", "更新排序失败");
+            return map;
+        }
+    }
+
+    @RequiresPermissions("newhome:newPageQualitySupplier:view")
+    @RequestMapping(value = "productDel")
+    public String productDel(NewPageQualitySupplier newPageQualitySupplier, RedirectAttributes redirectAttributes) {
+        newPageQualitySupplierService.productDel(Integer.valueOf(newPageQualitySupplier.getId()),newPageQualitySupplier.getProductId());
+        addMessage(redirectAttributes, "删除成功");
+        return "redirect:" + Global.getAdminPath() + "/newhome/newPageQualitySupplier/product?id=" + newPageQualitySupplier.getId();
+    }
+
+    @RequestMapping(value = "toAddProduct")
+    public String toAddProduct(Product product, Page page, Model model) {
+        //获取采美所有商品
+        if (0 == page.getPageSize() || -1 == page.getPageSize()) page.setPageSize(30);
+        if (0 == page.getPageNo()) page.setPageNo(1);
+        product.setPage(page);
+        List<Product> productList = newPageQualitySupplierService.findProductList(product);
+        if (CollectionUtils.isNotEmpty(productList)) {
+            for (Product p : productList) {
+                p.setMainImage(AppUtils.getProductImageURL(p.getMainImage(), 0, Global.getConfig("wwwServer")));
+            }
+        }
+        page.setList(productList);
+        model.addAttribute("page", page);
+        model.addAttribute("Product", product);
+        return "modules/newhome/toSelectProduct";
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "saveAddProduct")
+    public Map<String, Object> saveAddProduct(String productIds,Integer id) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            String[] split = productIds.split(",");
+            //保存商品添加的组合
+            newPageQualitySupplierService.addProducts(id,split);
+            map.put("success", true);
+            map.put("msg", "添加成功");
+        } catch (Exception e) {
+            logger.debug(e.toString(), e);
+            map.put("success", false);
+            map.put("msg", "添加失败");
+        }
+        return map;
+    }
+
+
+    @RequiresPermissions("newhome:newPageQualitySupplier:view")
+    @RequestMapping(value = "formImage")
+    public String formImage(NewPageQualitySupplierImage newPageQualitySupplierImage, Model model) {
+        NewPageQualitySupplierImage image = newPageQualitySupplierService.getImage();
+        model.addAttribute("NewPageQualitySupplierImage", image);
+        return "modules/newhome/newPageQualitySupplierImage";
+    }
+
+
+    @RequiresPermissions("newhome:newPageQualitySupplier:edit")
+    @RequestMapping(value = "saveImage")
+    public String saveImage(NewPageQualitySupplierImage newPageQualitySupplierImage, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
+        if (!beanValidator(model, newPageQualitySupplierImage)) {
+            return formImage(newPageQualitySupplierImage, model);
+        }
+        if (checkValidator(model, newPageQualitySupplierImage)) {
+            return formImage(newPageQualitySupplierImage, model);
+        }
+        newPageQualitySupplierService.saveImage(newPageQualitySupplierImage, request);
+        cleanRedisCache();
+        addMessage(redirectAttributes, "保存供应商广告图成功");
+        return "redirect:" + Global.getAdminPath() + "/newhome/newPageQualitySupplier/";
+    }
+
+    private boolean checkValidator(Model model, NewPageQualitySupplierImage image) {
+        if (!beanValidator(model, image)) {
+            return true;
+        }
+        if (StringUtils.isEmpty(image.getWwwImage())) {
+            model.addAttribute("errorMsg", "请上传网站端图!");
+            return true;
+        }
+        if (StringUtils.isEmpty(image.getCrmImage())) {
+            model.addAttribute("errorMsg", "请上传小程序端图!");
+            return true;
+        }
+        return false;
+    }
+
+    @RequiresPermissions("newhome:newPageQualitySupplier:edit")
+    @RequestMapping(value = "batchSaveSort")
+    @ResponseBody
+    public Map<String, Object> batchSaveSort(String newPageList, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            String[] newPageLists = newPageList.split(",");
+            for (String list : newPageLists) {
+                String[] split = list.split("-");
+                String s = split[1];//判断是否是数字,或者为空
+                if (StringUtils.isNotEmpty(s)) {
+                    if (isInteger(s)) {
+                        NewPageQualitySupplier newPageQualitySupplier = new NewPageQualitySupplier();
+                        newPageQualitySupplier.setId(split[0]);
+                        newPageQualitySupplier.setSort(split[1]);
+                        newPageQualitySupplierService.saveSort(newPageQualitySupplier, request);
+                    } else {
+                        map.put("success", false);
+                        map.put("msg", "排序值只能为数字");
+                        return map;
+                    }
+                } else {
+                    map.put("success", false);
+                    map.put("msg", "排序不能为空");
+                    return map;
+                }
+            }
+            cleanRedisCache();
+            map.put("success", true);
+            map.put("msg", "保存排序成功");
+            return map;
+        } catch (Exception e) {
+            map.put("success", false);
+            map.put("msg", "更新排序失败,排序不能为空");
+            return map;
+        }
+    }
+
+
+    public static boolean isInteger(String str) {
+        Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
+        return pattern.matcher(str).matches();
+    }
+
+
+    @RequiresPermissions("newhome:newPageQualitySupplier:edit")
+    @RequestMapping(value = "save")
+    public String save(NewPageQualitySupplier newPageQualitySupplier, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
+        if (!beanValidator(model, newPageQualitySupplier)) {
+            return form(newPageQualitySupplier, model);
+        }
+        newPageQualitySupplierService.save(newPageQualitySupplier, request);
+        cleanRedisCache();
+        addMessage(redirectAttributes, "保存优质供应商成功");
+        return "redirect:" + Global.getAdminPath() + "/newhome/newPageQualitySupplier/?repage";
+    }
+
+    @RequiresPermissions("newhome:newPageQualitySupplier:delete")
+    @RequestMapping(value = "delete")
+    public String delete(NewPageQualitySupplier newPageQualitySupplier, RedirectAttributes redirectAttributes) {
+        newPageQualitySupplierService.delete(newPageQualitySupplier);
+        cleanRedisCache();
+        addMessage(redirectAttributes, "删除优质供应商成功");
+        return "redirect:" + Global.getAdminPath() + "/newhome/newPageQualitySupplier/?repage";
+    }
+
+    @RequiresPermissions("newhome:newPageHomeimage:edit")
+    @ResponseBody
+    @RequestMapping(value = "updateEnabledStatus")
+    public Map<String, Object> updateEnabledStatus(String enabledStatus, String[] ids, String[] supplierIDs, HttpServletRequest request, HttpServletResponse response) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            newPageQualitySupplierService.updateEnabledStatusByIds(enabledStatus, ids);
+            cleanRedisCache();
+            map.put("success", true);
+            map.put("msg", "修改成功");
+        } catch (Exception e) {
+            logger.debug(e.toString(), e);
+            map.put("success", false);
+            map.put("msg", "修改失败");
+        }
+        return map;
+    }
+
+    @RequiresPermissions("newhome:newPageHomeimage:edit")
+    @ResponseBody
+    @RequestMapping(value = "updateCrmEnabledStatusByIds")
+    public Map<String, Object> updateCrmEnabledStatusByIds(String crmEnabledStatus, String[] ids, String[] supplierIDs, HttpServletRequest request, HttpServletResponse response) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            newPageQualitySupplierService.updateCrmEnabledStatusByIds(crmEnabledStatus, ids);
+            cleanRedisCache();
+            map.put("success", true);
+            map.put("msg", "修改成功");
+        } catch (Exception e) {
+            logger.debug(e.toString(), e);
+            map.put("success", false);
+            map.put("msg", "修改失败");
+        }
+        return map;
+    }
 
     /**
      * 有数据变动时需要清除缓存

+ 2 - 0
src/main/java/com/caimei/modules/product/entity/Product.java

@@ -14,6 +14,8 @@ import java.util.List;
 
 @Data
 public class Product extends DataEntity<Product> {
+
+    private Integer supId;
     private String name;
     private String shopName;//供应商名称
     private String validFlag; //0暂存中 1待审核 2已上架 3已下架 8 审核不通过 9已冻结

+ 2 - 1
src/main/resources/mappings/modules/coupon/CmCouponMapper.xml

@@ -374,7 +374,8 @@
 		  IFNULL(s.name, u.name) AS name,
 		  IFNULL(s.sname, u.realName) AS sname,
 		  IFNULL(s.contractMobile, u.bindMobile) AS contractMobile,
-		  IFNULL(s.linkMan, u.userName) AS linkMan
+		  IFNULL(s.linkMan, u.userName) AS linkMan,
+		  s.logo
 		FROM
 		  shop s
 		  LEFT JOIN USER u ON u.`shopID` = s.`shopID`

+ 202 - 141
src/main/resources/mappings/modules/newhome/NewPageQualitySupplierMapper.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.modules.newhome.dao.NewPageQualitySupplierDao">
-    
-	<sql id="newPageQualitySupplierColumns">
-		a.id AS "id",
+
+    <sql id="newPageQualitySupplierColumns">
+        a.id AS "id",
 		a.supplierName AS "supplierName",
 		a.image AS "image",
 		a.link AS "link",
@@ -14,154 +14,215 @@
 		a.createDate AS "createDate",
 		a.updateBy AS "updateBy.id",
 		a.updateDate AS "updateDate",
-		a.delFlag AS "delFlag"
-	</sql>
-
-	<select id="getImage" resultType="NewPageQualitySupplierImage">
-		SELECT *
-		FROM new_page_quality_supplier_image a
-		WHERE a.id = 1
-	</select>
-
-	<select id="get" resultType="NewPageQualitySupplier">
-		SELECT 
-			<include refid="newPageQualitySupplierColumns"/>
-		FROM new_page_quality_supplier a
-		WHERE a.id = #{id}
-	</select>
-	
-	<select id="findList" resultType="NewPageQualitySupplier">
-		SELECT 
-			<include refid="newPageQualitySupplierColumns"/>
-		FROM new_page_quality_supplier a
-		<where>
-			and a.delFlag = 0
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	
-	<select id="findAllList" resultType="NewPageQualitySupplier">
-		SELECT 
-			<include refid="newPageQualitySupplierColumns"/>
-		FROM new_page_quality_supplier a
-		<where>
-			
-		</where>		
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	
-	<insert id="insert" parameterType="NewPageQualitySupplier"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO new_page_quality_supplier(
-			supplierName,
-			image,
-			link,
-		<if test="sort != null and sort != ''" >
-			sort,
-		</if>
-			wwwEnabledStatus,
-			crmEnabledStatus,
-			createBy,
-			createDate,
-			updateBy,
-			updateDate,
-			delFlag
-		) VALUES (
-			#{supplierName},
-			#{image},
-			#{link},
-		<if test="sort != null and sort != ''" >
-			#{sort},
-		</if>
-			#{wwwEnabledStatus},
-			#{crmEnabledStatus},
-			#{createBy.id},
-			#{createDate},
-			#{updateBy.id},
-			#{updateDate},
-			#{delFlag}
-		)
-	</insert>
-
-
-	<insert id="saveImage" parameterType="NewPageQualitySupplierImage"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO new_page_quality_supplier_image(
-		crmImage,
-		wwwImage,
-		crmLink,
-		wwwLink
-		) VALUES (
-		#{crmImage},
-		#{imwwwImageage},
-		#{crmLink},
-		#{wwwLink}
-		)
-	</insert>
-
-
-	<update id="updateImage">
-		UPDATE new_page_quality_supplier_image SET
-		crmImage = #{crmImage},
-		wwwImage = #{wwwImage},
-		crmLink = #{crmLink},
-		wwwLink = #{wwwLink}
-		WHERE id = #{id}
-	</update>
-
-	
-	<update id="update">
-		UPDATE new_page_quality_supplier SET 	
-			supplierName = #{supplierName},
-			image = #{image},
-			link = #{link},
-			sort = #{sort},
-			wwwEnabledStatus = #{wwwEnabledStatus},
-			crmEnabledStatus = #{crmEnabledStatus},
-			createBy = #{createBy.id},
-			createDate = #{createDate},
-			updateBy = #{updateBy.id},
-			updateDate = #{updateDate},
-			delFlag = #{delFlag}
-		WHERE id = #{id}
-	</update>
-
-	<update id="saveSort">
-		UPDATE new_page_quality_supplier SET
-		sort = #{sort}
-		WHERE id = #{id}
-	</update>
-
-
-
-	<delete id="delete">
-		update new_page_quality_supplier set delFlag = 1
-		WHERE id = #{id}
-	</delete>
+		a.delFlag AS "delFlag",
+		a.shopId AS "shopId"
+    </sql>
+
+    <select id="getImage" resultType="NewPageQualitySupplierImage">
+        SELECT *
+        FROM new_page_quality_supplier_image a
+        WHERE a.id = 1
+    </select>
+
+    <select id="get" resultType="NewPageQualitySupplier">
+        SELECT
+        <include refid="newPageQualitySupplierColumns"/>
+        FROM new_page_quality_supplier a
+        WHERE a.id = #{id}
+    </select>
+
+    <select id="findList" resultType="NewPageQualitySupplier">
+        SELECT
+        <include refid="newPageQualitySupplierColumns"/>
+        FROM new_page_quality_supplier a
+        <where>
+            and a.delFlag = 0
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findAllList" resultType="NewPageQualitySupplier">
+        SELECT
+        <include refid="newPageQualitySupplierColumns"/>
+        FROM new_page_quality_supplier a
+        <where>
+
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
+    <select id="findSupplierProducts" resultType="com.caimei.modules.product.entity.Product">
+        SELECT nsp.sort as sortIndex,a.*, s.name as "shopName",nsp.supplierId as supId
+        FROM new_page_quality_supplier_product nsp
+        left join product a on a.productId = nsp.productId
+        left join shop s on a.shopId = s.shopID
+        where nsp.supplierId = #{id}
+          and a.productCategory = 1
+        group by a.productID
+        ORDER BY nsp.sort asc
+    </select>
+    <select id="findProductList" resultType="com.caimei.modules.product.entity.Product">
+        SELECT a.*,s.name as "shopName"
+        FROM product a
+        left join cm_organize_product_info copi on copi.productId = a.productID
+        left join shop s on a.shopId = s.shopID
+        left join new_page_quality_supplier_product nsp ON a.productId = nsp.productId
+        <where>
+            nsp.productId is null
+            and
+            copi.validFlag in (2,3,9)
+            <if test="productID !=null and productID !=''">
+                AND a.productID=#{productID}
+            </if>
+            <if test="name != null and name != ''">
+                AND a.name LIKE concat('%',#{name},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name LIKE concat('%',#{shopName},'%')
+            </if>
+            and a.productCategory = 1
+        </where>
+        group by a.productID
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                order by a.productID desc
+            </otherwise>
+        </choose>
+    </select>
+
+    <insert id="insert" parameterType="NewPageQualitySupplier" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO new_page_quality_supplier(
+        supplierName,
+        image,
+        link,
+        <if test="sort != null and sort != ''">
+            sort,
+        </if>
+        wwwEnabledStatus,
+        crmEnabledStatus,
+        createBy,
+        createDate,
+        updateBy,
+        updateDate,
+        delFlag,
+        shopId
+        ) VALUES (
+        #{supplierName},
+        #{image},
+        #{link},
+        <if test="sort != null and sort != ''">
+            #{sort},
+        </if>
+        #{wwwEnabledStatus},
+        #{crmEnabledStatus},
+        #{createBy.id},
+        #{createDate},
+        #{updateBy.id},
+        #{updateDate},
+        #{delFlag},
+        #{shopId}
+        )
+    </insert>
+
+
+    <insert id="saveImage" parameterType="NewPageQualitySupplierImage" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO new_page_quality_supplier_image(crmImage,
+                                                    wwwImage,
+                                                    crmLink,
+                                                    wwwLink)
+        VALUES (#{crmImage},
+                #{imwwwImageage},
+                #{crmLink},
+                #{wwwLink})
+    </insert>
+
+    <insert id="addProducts">
+        insert into new_page_quality_supplier_product(productId,supplierId,shopId)
+            values
+        <foreach collection="split" item="item" index="index" separator=",">
+            (#{item},#{id},(select shopId from product where productId = #{item}))
+        </foreach>
+    </insert>
+
+
+    <update id="updateImage">
+        UPDATE new_page_quality_supplier_image
+        SET crmImage = #{crmImage},
+            wwwImage = #{wwwImage},
+            crmLink  = #{crmLink},
+            wwwLink  = #{wwwLink}
+        WHERE id = #{id}
+    </update>
+
+
+    <update id="update">
+        UPDATE new_page_quality_supplier
+        SET supplierName     = #{supplierName},
+            image            = #{image},
+            link             = #{link},
+            sort             = #{sort},
+            wwwEnabledStatus = #{wwwEnabledStatus},
+            crmEnabledStatus = #{crmEnabledStatus},
+            createBy         = #{createBy.id},
+            createDate       = #{createDate},
+            updateBy         = #{updateBy.id},
+            updateDate       = #{updateDate},
+            delFlag          = #{delFlag},
+            shopId           = #{shopId}
+        WHERE id = #{id}
+    </update>
+
+    <update id="saveSort">
+        UPDATE new_page_quality_supplier
+        SET sort = #{sort}
+        WHERE id = #{id}
+    </update>
+
+    <delete id="delete">
+        update new_page_quality_supplier
+        set delFlag = 1
+        WHERE id = #{id}
+    </delete>
+
+    <delete id="delProduct">
+        DELETE
+        FROM new_page_quality_supplier_product
+        WHERE supplierId = #{id}
+          and productId = #{productId}
+    </delete>
 
     <update id="updateEnabledStatusByIds">
         UPDATE new_page_quality_supplier a SET a.wwwEnabledStatus = #{param1}
-        WHERE  a.id IN
-        <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
+        WHERE a.id IN
+        <foreach collection="param2" item="id" index="index" open="(" separator="," close=")">
             #{id}
         </foreach>
     </update>
 
     <update id="updateCrmEnabledStatusByIds">
         UPDATE new_page_quality_supplier a SET a.crmEnabledStatus = #{param1}
-        WHERE  a.id IN
-        <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
+        WHERE a.id IN
+        <foreach collection="param2" item="id" index="index" open="(" separator="," close=")">
             #{id}
         </foreach>
     </update>
+    <update id="updateSort">
+        update new_page_quality_supplier_product
+        set sort = #{sort}
+        where productId = #{id}
+    </update>
 </mapper>

+ 3 - 1
src/main/webapp/WEB-INF/views/modules/coupon/toAddShop.jsp

@@ -28,7 +28,8 @@
                 "name": shop.name,
                 "sname": shop.sname,
                 "linkMan": shop.linkMan,
-                "contractMobile": shop.contractMobile
+                "contractMobile": shop.contractMobile,
+                "logo":shop.logo
             };
             return items;
         }
@@ -94,6 +95,7 @@
                 <td>${item.sname}</td>
                 <td>${item.linkMan}</td>
                 <td>${item.contractMobile}</td>
+                <td hidden>${item.logo}</td>
             </tr>
         </c:forEach>
     </c:if>

+ 185 - 0
src/main/webapp/WEB-INF/views/modules/newhome/newPageProductList.jsp

@@ -0,0 +1,185 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>优质供应商商品列表</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th {
+            text-align: center;
+        }
+
+        .table td {
+            text-align: center;
+        }
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+
+        });
+
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+
+
+        //选择添加商品
+        function showSelect() {
+            //获取选中的组合
+            var id = $(".supId").val();
+            top.$.jBox("iframe:${ctx}/newhome/newPageQualitySupplier/toAddProduct?supId=" + id, {
+                iframeScrolling: 'yes',
+                width: $(top.document).width() - 400,
+                height: $(top.document).height() - 160,
+                persistent: true,
+                title: "选择商品",
+                buttons: {"确定": '1', "关闭": '-1'},
+                submit: function (v, h, f) {
+                    //确定
+                    var $jboxFrame = top.$('#jbox-iframe');
+                    var $mainFrame = top.$('#mainFrame');
+                    if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                        var items = $jboxFrame[0].contentWindow.getCheckedItems();//获取到的数据格式:(含有参数序号拼接,使用数组传入)1o,2e,3t,4y,5u,6p
+                        if (items.length > 0) {
+                            //添加数据
+                            $.post("${ctx}/newhome/newPageQualitySupplier/saveAddProduct",
+                                {"productIds": items, "id": id},
+                                function (data) {
+                                    if (true == data.success) {
+                                        window.location.href = "${ctx}/newhome/newPageQualitySupplier/product?id=" + id;
+                                        $.jBox.tip(data.msg, 'info');
+                                    } else {
+                                        $.jBox.tip(data.msg, 'error');
+                                    }
+                                }, "JSON");//这里返回的类型有:json,html,xml,text
+                            return true;
+                        } else {
+                            top.$.jBox.tip("请先勾选商品...");
+                            return false;
+                        }
+                    }
+                    return true;
+                }
+            });
+        }
+
+        //批量保存排序
+        function batchSaveSort() {
+            var items = new Array();
+            var $items = $('.check-item');
+            $items.each(function () {
+                items.push($(this).val());
+            });
+            //保存批量排序
+            $.post("${ctx}/newhome/newPageQualitySupplier/batchSaveSorts?newProducSorttList=" + items, function (data) {
+                if (true == data.success) {
+                    $.jBox.tip(data.msg, 'info');
+                    setInterval(g, 1000);
+                } else {
+                    $.jBox.tip(data.msg, 'error');
+                }
+            }, "JSON");//这里返回的类型有:json,html,xml,text
+        }
+
+        function g() {
+            window.location.href = "${ctx}/newhome/newPageQualitySupplier/product?id=${newPageQualitySupplier.id}";//刷新页面
+        }
+
+        //修改排序值
+        function changeSort(id,sortThis) {
+            var value = sortThis.value;
+            $("#sort"+id).val(id+"-"+value);
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/newhome/newPageQualitySupplier/">优质供应商列表</a></li>
+    <li class="active"><a
+            href="${ctx}/newhome/newPageQualitySupplier/product?id=${newPageQualitySupplier.id}">优质供应商商品列表</a></li>
+</ul>
+<div class="ul-form">
+    <input type="button" class="btn btn-primary" value="添加商品" onclick="showSelect()"/>&nbsp&nbsp&nbsp
+    <c:if test="${not empty productList}">
+        <input type="button" class="btn btn-primary" value="保存排序" onclick="batchSaveSort()"/>
+    </c:if>
+    <br><font color="#a9a9a9">&nbsp;&nbsp;&nbsp;排序规则:按照排序数值升序排列,数值越小排序越靠前,排序值允许重复。</font>
+    <div class="clearfix"></div>
+</div>
+<input type="hidden" class="supId" value="${newPageQualitySupplier.id}">
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>商品ID</th>
+        <th>商品图片</th>
+        <th>商品名称</th>
+        <th>供应商</th>
+        <th>排序值</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <c:if test="${not empty productList}">
+        <c:forEach items="${productList}" var="product">
+            <tbody>
+            <tr>
+                <input class="check-item" type="hidden" id="sort${product.productID}"
+                       value='${product.productID}-${product.sortIndex}'/>
+                <td>
+                        ${product.productID}
+                </td>
+                <td><img src="${product.mainImage}" width="50px" height="50px"></td>
+                <td>
+                    <a href="https://www.caimei365.com/product-${product.productID}.html"
+                       target="_blank">${product.name}</a>
+                    <font color="red">
+                        <c:if test="${product.validFlag eq 9}">
+                            (已隐身)
+                        </c:if>
+                        <c:if test="${product.validFlag eq 3}">
+                            (已下架)
+                        </c:if>
+                        <c:if test="${product.validFlag eq 0}">
+                            (已删除)
+                        </c:if>
+                        <c:if test="${product.validFlag eq 1}">
+                            (待审核)
+                        </c:if>
+                        <c:if test="${product.validFlag eq 8}">
+                            (审核未通过)
+                        </c:if>
+                    </font>
+                </td>
+                <td>
+                        ${product.shopName}
+                </td>
+                <td>
+                    <input id="sort" name="sort" style="width:50px;" value="${product.sortIndex}"
+                           onkeyup="onlynum(this)"  onchange="changeSort(${product.productID},this)">
+                </td>
+                <td>
+                    <a href="${ctx}/newhome/newPageQualitySupplier/productDel?id=${newPageQualitySupplier.id}&productId=${product.productID}"
+                       onclick="return confirmx('确认删除吗?', this.href)">删除</a>
+                </td>
+            </tr>
+            </tbody>
+        </c:forEach>
+    </c:if>
+</table>
+<c:if test="${empty productList}">
+    <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+</body>
+</html>

+ 139 - 82
src/main/webapp/WEB-INF/views/modules/newhome/newPageQualitySupplierForm.jsp

@@ -1,93 +1,150 @@
 <%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
 <html>
 <head>
-	<title>优质供应商管理</title>
-	<meta name="decorator" content="default"/>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			//$("#name").focus();
-			$("#inputForm").validate({
-				submitHandler: function(form){
+    <title>优质供应商管理</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //$("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+                    var shopId = $("#shopId").val();
+                    if (shopId != undefined && shopId.trim() != "" && shopId != 0) {
+                        console.log(shopId);
+                    } else {
+                        alertx("请选择供应商!");
+                    }
                     var image = $("#image").val();
-                    if(image != undefined && image.trim() != ""){
+                    if (image != undefined && image.trim() != "") {
                         loading('正在提交,请稍等...');
                         form.submit();
-					}else{
-                     	alertx("请先选择图片!");
-					}
-				},
-				errorContainer: "#messageBox",
-				errorPlacement: function(error, element) {
-					$("#messageBox").text("输入有误,请先更正。");
-					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
-						error.appendTo(element.parent().parent());
-					} else {
-						error.insertAfter(element);
-					}
-				}
-			});
-		});
-	</script>
+                    } else {
+                        alertx("请先选择图片!");
+                    }
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function (error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+
+        //点击添加
+        function showSelect() {
+            var url = "${ctx}/coupon/cmCoupon/toAddShop";
+            var title = '';
+            title = "选择供应商";
+            top.$.jBox("iframe:" + url, {
+                iframeScrolling: 'yes',
+                width: $(top.document).width() - 400,
+                height: $(top.document).height() - 160,
+                persistent: true,
+                title: title,
+                buttons: {"确定": '1', "取消": '-1'},
+                submit: function (v, h, f) {
+                    //确定
+                    var $jboxFrame = top.$('#jbox-iframe');
+                    var $mainFrame = top.$('#mainFrame');
+                    if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                        var items = $jboxFrame[0].contentWindow.getCheckedItems();
+                        console.log(items);
+                        appendShopOrderHead(items);
+                    }
+                    return true;
+                }
+            });
+        }
+
+        function appendShopOrderHead(data) {
+            $("#shopId").val(data.shopId);
+            $("#supplierName").val(data.name);
+            $("#image").val(data.logo);
+            var link = "https://www.caimei365.com/supplier-" + data.shopId + ".html";
+            $("#link").val(link);
+        }
+    </script>
 </head>
 <body>
-	<ul class="nav nav-tabs">
-		<li><a href="${ctx}/newhome/newPageQualitySupplier/">优质供应商列表</a></li>
-		<li class="active"><a href="${ctx}/newhome/newPageQualitySupplier/form?id=${newPageQualitySupplier.id}">优质供应商<shiro:hasPermission name="newhome:newPageQualitySupplier:edit">${not empty newPageQualitySupplier.id?'编辑':'添加'}</shiro:hasPermission><shiro:lacksPermission name="newhome:newPageQualitySupplier:edit">查看</shiro:lacksPermission></a></li>
-		<shiro:hasPermission name="newhome:newPageQualitySupplier:edit"><li><a href="${ctx}/newhome/newPageQualitySupplier/formImage?id=1">供应商广告图添加</a></li></shiro:hasPermission>
-	</ul><br/>
-	<form:form id="inputForm" modelAttribute="newPageQualitySupplier" action="${ctx}/newhome/newPageQualitySupplier/save" method="post" class="form-horizontal">
-		<form:hidden path="id"/>
-		<sys:message content="${message}"/>
-		<div class="control-group">
-			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>供应商名称:</label>
-			<div class="controls">
-				<form:input path="supplierName" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>供应商图片:</label>
-			<div class="controls">
-				<form:hidden  id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
-				<sys:ckfinder input="image" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
-			</div>
-			<div class="controls" style="padding-top: 20px;">
-                <p style="color:#D0D0D0 ;">建议尺寸:134px*134px</p>
-			</div>
-		</div>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/newhome/newPageQualitySupplier/">优质供应商列表</a></li>
+    <li class="active"><a
+            href="${ctx}/newhome/newPageQualitySupplier/form?id=${newPageQualitySupplier.id}">优质供应商<shiro:hasPermission
+            name="newhome:newPageQualitySupplier:edit">${not empty newPageQualitySupplier.id?'编辑':'添加'}</shiro:hasPermission><shiro:lacksPermission
+            name="newhome:newPageQualitySupplier:edit">查看</shiro:lacksPermission></a></li>
+    <shiro:hasPermission name="newhome:newPageQualitySupplier:edit">
+        <li><a href="${ctx}/newhome/newPageQualitySupplier/formImage?id=1">供应商广告图添加</a></li>
+    </shiro:hasPermission>
+</ul>
+<br/>
+<form:form id="inputForm" modelAttribute="newPageQualitySupplier" action="${ctx}/newhome/newPageQualitySupplier/save"
+           method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <form:hidden path="shopId"/>
+    <sys:message content="${message}"/>
+    <%--关联供应商--%>
+    <div class="control-group">
+        <label class="control-label"><a href="JavaScript:;" onclick="showSelect()">请选择供应商</a></label>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>供应商名称:</label>
+        <div class="controls">
+            <form:input path="supplierName" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>供应商图片:</label>
+        <div class="controls">
+            <form:hidden id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
+            <sys:ckfinder input="image" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
+                          maxHeight="100"/>
+        </div>
+        <div class="controls" style="padding-top: 20px;">
+            <p style="color:#D0D0D0 ;">建议尺寸:134px*134px</p>
+        </div>
+    </div>
 
-		<div class="control-group">
-			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>链接:</label>
-			<div class="controls">
-				<form:input path="link" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>排序:</label>
-			<div class="controls">
-				<form:input path="sort" htmlEscape="false" maxlength="11" class="input-xlarge required"/>
-			</div>
-		</div>
-		<div class="control-group crmstatus" style="" >
-			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>小程序端状态:</label>
-			<div class="controls">
-				<form:select path="crmEnabledStatus" class="input-xlarge ">
-					<form:options items="${fns:getDictList('enabled_status')}" itemLabel="label" itemValue="value" htmlEscape="false" />
-				</form:select>
-			</div>
-		</div>
-		<div class="control-group crmstatus" style="" >
-			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>PC端状态:</label>
-			<div class="controls">
-				<form:select path="wwwEnabledStatus" class="input-xlarge ">
-					<form:options items="${fns:getDictList('enabled_status')}" itemLabel="label" itemValue="value" htmlEscape="false" />
-				</form:select>
-			</div>
-		</div>
-		<div class="form-actions">
-			<shiro:hasPermission name="newhome:newPageQualitySupplier:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
-			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
-		</div>
-	</form:form>
+    <div class="control-group">
+        <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>链接:</label>
+        <div class="controls">
+            <form:input path="link" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>排序:</label>
+        <div class="controls">
+            <form:input path="sort" htmlEscape="false" maxlength="11" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group crmstatus" style="">
+        <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>小程序端状态:</label>
+        <div class="controls">
+            <form:select path="crmEnabledStatus" class="input-xlarge ">
+                <form:options items="${fns:getDictList('enabled_status')}" itemLabel="label" itemValue="value"
+                              htmlEscape="false"/>
+            </form:select>
+        </div>
+    </div>
+    <div class="control-group crmstatus" style="">
+        <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>PC端状态:</label>
+        <div class="controls">
+            <form:select path="wwwEnabledStatus" class="input-xlarge ">
+                <form:options items="${fns:getDictList('enabled_status')}" itemLabel="label" itemValue="value"
+                              htmlEscape="false"/>
+            </form:select>
+        </div>
+    </div>
+    <div class="form-actions">
+        <shiro:hasPermission name="newhome:newPageQualitySupplier:edit"><input id="btnSubmit" class="btn btn-primary"
+                                                                               type="submit"
+                                                                               value="保 存"/>&nbsp;</shiro:hasPermission>
+        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+    </div>
+</form:form>
 </body>
 </html>

+ 1 - 0
src/main/webapp/WEB-INF/views/modules/newhome/newPageQualitySupplierList.jsp

@@ -154,6 +154,7 @@
 
 				<shiro:hasPermission name="newhome:newPageQualitySupplier:edit"><td>
     				<a href="${ctx}/newhome/newPageQualitySupplier/form?id=${newPageQualitySupplier.id}">编辑</a>
+    				<a href="${ctx}/newhome/newPageQualitySupplier/product?id=${newPageQualitySupplier.id}">商品编辑</a>
     				<shiro:hasPermission name="newhome:newPageQualitySupplier:delete">
 					<a href="${ctx}/newhome/newPageQualitySupplier/delete?id=${newPageQualitySupplier.id}" onclick="return confirmx('确定删除吗?删除后不可恢复!', this.href)">删除</a>
 					</shiro:hasPermission>

+ 127 - 0
src/main/webapp/WEB-INF/views/modules/newhome/toSelectProduct.jsp

@@ -0,0 +1,127 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>选择商品</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table td i {
+            margin: 0 2px;
+        }
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //弹出框去滚动条
+            top.$('#jbox-content').css("overflow-y", "hidden");
+            show_title(30);
+
+//			反选
+            $('body').on('click', 'input[name="info"]', function () {
+                var allInputLength = $('input[name="info"]').length - $('input[name="info"]:disabled').length,
+                    allInputCheckedLength = $('input[name="info"]:checked').length,
+                    checkAllEle = $('.check-all');
+//			    判断选中长度和总长度,如果相等就是全选否则取消全选
+                if (allInputLength === allInputCheckedLength) {
+                    checkAllEle.attr('checked', true);
+                } else {
+                    checkAllEle.attr('checked', false);
+                }
+            })
+        });
+
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+
+        function getCheckedItems() {
+            var items = "";
+            var $items = $('.check-item:checked');
+            $items.each(function () {
+                //通过拿到的商品ID串(逗号隔开)
+                var productID = $(this).val();
+                items = items + productID + ","
+            });
+            items = items.substring(0, items.length - 1);
+            return items;
+        }
+
+        function allCkbfun(ckb) {
+            var isChecked = ckb.checked;
+            $(".check-item").attr('checked', isChecked);
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字和两位小数(金额)
+         */
+        function num(obj) {
+            obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+            obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
+            obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
+            obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+        }
+
+    </script>
+</head>
+<body>
+<form:form id="searchForm" modelAttribute="product"
+           action="${ctx}/newhome/newPageQualitySupplier/toAddProduct?supId=${product.supId}" method="post"
+           class="breadcrumb form-search">
+    <input id="supId" name="supId" type="hidden" value="${product.supId}"/>
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>商品ID:</label>
+        <form:input path="productID" htmlEscape="false" maxlength="10" class="input-mini" onchange="onlynum(this)"/>
+        <label>商品名称:</label>
+        <form:input path="productName" htmlEscape="false" class="input-medium" maxlength="20"/>
+        <label>供应商:</label>
+        <form:input path="shopName" htmlEscape="false" class="input-medium" maxlength="20"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table class="table table-striped table-bordered table-condensed table-hover">
+    <tr>
+        <th style="width:20px;"><input class="check-all" type="checkbox" onclick="allCkbfun(this);"/></th>
+        <th>商品ID</th>
+        <th>商品图片</th>
+        <th>商品名称</th>
+        <th>供应商</th>
+    </tr>
+    <tbody>
+    <c:if test="${not empty page.list}">
+        <c:forEach items="${page.list}" var="item">
+            <tr id="${item.productID}" class="itemtr">
+                    <%--已过滤添加过的商品和未上架的商品--%>
+                <th>
+                    <input class="check-item" type="checkbox" name="info" value='${item.productID}'/>
+                </th>
+                <td>${item.productID}</td>
+                <td><img src="${item.mainImage}" width="50px" height="50px"></td>
+                <td>${item.name}</td>
+                <td>${item.shopName}</td>
+            </tr>
+        </c:forEach>
+    </c:if>
+    </tbody>
+</table>
+<c:if test="${empty page.list}">
+    <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+</body>
+</html>