瀏覽代碼

修改后台呵呵商城配置

plf 4 年之前
父節點
當前提交
ab8aa06d3a
共有 21 個文件被更改,包括 751 次插入158 次删除
  1. 11 11
      src/main/java/com/caimei/modules/hehe/dao/CmHeheActivityProductDao.java
  2. 55 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheUserDao.java
  3. 0 9
      src/main/java/com/caimei/modules/hehe/entity/CmHeheActivity.java
  4. 1 1
      src/main/java/com/caimei/modules/hehe/entity/CmHeheActivityProduct.java
  5. 9 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheUser.java
  6. 57 0
      src/main/java/com/caimei/modules/hehe/entity/cmHeHeUserActivity.java
  7. 2 7
      src/main/java/com/caimei/modules/hehe/service/CmHeheActivityProductService.java
  8. 80 2
      src/main/java/com/caimei/modules/hehe/service/CmHeheUserService.java
  9. 2 3
      src/main/java/com/caimei/modules/hehe/web/CmHeheActivityController.java
  10. 3 46
      src/main/java/com/caimei/modules/hehe/web/CmHeheActivityProductController.java
  11. 93 11
      src/main/java/com/caimei/modules/hehe/web/CmHeheUserController.java
  12. 0 6
      src/main/resources/mappings/modules/hehe/CmHeheActivityMapper.xml
  13. 5 10
      src/main/resources/mappings/modules/hehe/CmHeheActivityProductMapper.xml
  14. 110 0
      src/main/resources/mappings/modules/hehe/CmHeheUserMapper.xml
  15. 0 1
      src/main/webapp/WEB-INF/views/modules/hehe/addActivityProduct.jsp
  16. 126 0
      src/main/webapp/WEB-INF/views/modules/hehe/addUserActivityProduct.jsp
  17. 2 4
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityForm.jsp
  18. 3 5
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityList.jsp
  19. 5 41
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductList.jsp
  20. 1 1
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheUserList.jsp
  21. 186 0
      src/main/webapp/WEB-INF/views/modules/hehe/userActivityProductList.jsp

+ 11 - 11
src/main/java/com/caimei/modules/hehe/dao/CmHeheActivityProductDao.java

@@ -20,10 +20,9 @@ public interface CmHeheActivityProductDao extends CrudDao<CmHeheActivityProduct>
     /**
      * 查询活动商品id
      *
-     * @param userId
      * @return
      */
-    List<Integer> findActivityProductId(Integer userId);
+    List<Integer> findActivityProductId();
 
     /**
      * 查询呵呵商城所有上架商品
@@ -33,14 +32,6 @@ public interface CmHeheActivityProductDao extends CrudDao<CmHeheActivityProduct>
      */
     List<CmHeheProduct> findAllHeHeProduct(CmHeheProduct product);
 
-    /**
-     * 修改排序值
-     *
-     * @param sort
-     * @param id
-     */
-    void updateSortById(@Param("sort") String sort, @Param("id") String id);
-
     /**
      * 查询活动阶梯
      *
@@ -59,8 +50,17 @@ public interface CmHeheActivityProductDao extends CrudDao<CmHeheActivityProduct>
 
     /**
      * 删除活动阶梯
+     *
      * @param activityId
      * @param productId
      */
-    void deleteLadder(@Param("activityId") Integer activityId,@Param("productId") Integer productId);
+    void deleteLadder(@Param("activityId") Integer activityId, @Param("productId") Integer productId);
+
+    /**
+     * 根据商品id查询活动
+     *
+     * @param productId
+     * @return
+     */
+    Integer findActivityByProductId(String productId);
 }

+ 55 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheUserDao.java

@@ -1,8 +1,15 @@
 package com.caimei.modules.hehe.dao;
 
+import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
+import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.caimei.modules.hehe.entity.cmHeHeUserActivity;
+import com.caimei.modules.user.entity.CmUser;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import com.caimei.modules.hehe.entity.CmHeheUser;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 呵呵用户DAO接口
@@ -20,4 +27,52 @@ public interface CmHeheUserDao extends CrudDao<CmHeheUser> {
      * @return
      */
     Integer findMobileOnly(CmHeheUser cmHeheUser);
+
+    /**
+     * 保存user信息
+     *
+     * @param user
+     */
+    void insertUser(CmUser user);
+
+    void updateUser(CmUser user);
+
+    /**
+     * 分销者活动商品列表
+     *
+     * @param activityProduct
+     * @return
+     */
+    List<CmHeheActivityProduct> activityProductList(CmHeheActivityProduct activityProduct);
+
+    /**
+     * 分销者下活动商品
+     *
+     * @param userId
+     * @return
+     */
+    List<Integer> findUserActivityProduct(Integer userId);
+
+    /**
+     * 查询所有参与活动的商品
+     *
+     * @param product
+     * @return
+     */
+    List<CmHeheProduct> findAllActivityProduct(CmHeheProduct product);
+
+    /**
+     * 保存活动商品到用户活动
+     *
+     * @param userActivity
+     */
+    void insertUserActivity(cmHeHeUserActivity userActivity);
+
+    /**
+     * 修改排序值
+     *
+     * @param sort
+     * @param id
+     */
+    void updateSortById(@Param("sort") String sort, @Param("id") String id);
 }

+ 0 - 9
src/main/java/com/caimei/modules/hehe/entity/CmHeheActivity.java

@@ -15,7 +15,6 @@ public class CmHeheActivity extends DataEntity<CmHeheActivity> {
 	
 	private static final long serialVersionUID = 1L;
 	private String name;		// 活动名称
-	private String userId;		// 分销者用户id
 	private String status;		// 小程序状态:1启用,2停用
 	private String listImage;		// 小程序列表缩略图
 	private String detailsImage;		// 小程序详情主题图
@@ -41,14 +40,6 @@ public class CmHeheActivity extends DataEntity<CmHeheActivity> {
 		this.name = name;
 	}
 	
-	public String getUserId() {
-		return userId;
-	}
-
-	public void setUserId(String userId) {
-		this.userId = userId;
-	}
-	
 	@Length(min=0, max=1, message="小程序状态长度必须介于 0 和 1 之间")
 	public String getStatus() {
 		return status;

+ 1 - 1
src/main/java/com/caimei/modules/hehe/entity/CmHeheActivityProduct.java

@@ -25,7 +25,7 @@ public class CmHeheActivityProduct extends DataEntity<CmHeheActivityProduct> {
     private String shopName;        //供应商名称
     private BigDecimal price;        // 售价
     private String unit;        //包装规格
-    private Integer userId;         //分销者id
+    private Integer userId;         //用户id
     private List<CmHeHeActivityLadder> activityLadderList;  //活动阶梯
 
     public CmHeheActivityProduct() {

+ 9 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheUser.java

@@ -14,6 +14,7 @@ import com.thinkgem.jeesite.common.persistence.DataEntity;
 public class CmHeheUser extends DataEntity<CmHeheUser> {
 	
 	private static final long serialVersionUID = 1L;
+	private Integer userId;		//对应user表用户id
 	private String name;		// 姓名
 	private String mobile;		// 手机号
 	private String userIdentity;		// 用户身份:1普通用户,2分销者
@@ -29,6 +30,14 @@ public class CmHeheUser extends DataEntity<CmHeheUser> {
 		super(id);
 	}
 
+	public Integer getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Integer userId) {
+		this.userId = userId;
+	}
+
 	@Length(min=0, max=30, message="姓名长度必须介于 0 和 30 之间")
 	public String getName() {
 		return name;

+ 57 - 0
src/main/java/com/caimei/modules/hehe/entity/cmHeHeUserActivity.java

@@ -0,0 +1,57 @@
+package com.caimei.modules.hehe.entity;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/23
+ */
+public class cmHeHeUserActivity implements Serializable {
+    private Integer id;
+    private Integer userId; //用户id
+    private Integer activityId; //活动id
+    private Integer productId;  //商品id
+    private Integer sort;       //排序值
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getActivityId() {
+        return activityId;
+    }
+
+    public void setActivityId(Integer activityId) {
+        this.activityId = activityId;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+}

+ 2 - 7
src/main/java/com/caimei/modules/hehe/service/CmHeheActivityProductService.java

@@ -58,8 +58,8 @@ public class CmHeheActivityProductService extends CrudService<CmHeheActivityProd
         super.delete(cmHeheActivityProduct);
     }
 
-    public Page<CmHeheProduct> findProductPage(Page<CmHeheProduct> productPage, CmHeheProduct product, Integer userId) {
-        List<Integer> productIds = activityProductDao.findActivityProductId(userId);
+    public Page<CmHeheProduct> findProductPage(Page<CmHeheProduct> productPage, CmHeheProduct product) {
+        List<Integer> productIds = activityProductDao.findActivityProductId();
         product.setIds(productIds);
         product.setPage(productPage);
         List<CmHeheProduct> productList = activityProductDao.findAllHeHeProduct(product);
@@ -88,11 +88,6 @@ public class CmHeheActivityProductService extends CrudService<CmHeheActivityProd
         }
     }
 
-    @Transactional(readOnly = false)
-    public void saveSort(String sort, String id) {
-        activityProductDao.updateSortById(sort, id);
-    }
-
     @Transactional(readOnly = false)
     public void saveActivityLadder(String params, String id) {
         CmHeheActivityProduct activityProduct = activityProductDao.get(id);

+ 80 - 2
src/main/java/com/caimei/modules/hehe/service/CmHeheUserService.java

@@ -1,7 +1,12 @@
 package com.caimei.modules.hehe.service;
 
+import com.caimei.modules.hehe.dao.CmHeheActivityProductDao;
 import com.caimei.modules.hehe.dao.CmHeheUserDao;
-import com.caimei.modules.hehe.entity.CmHeheUser;
+import com.caimei.modules.hehe.entity.*;
+import com.caimei.modules.user.entity.CmUser;
+import com.caimei.utils.AppUtils;
+import com.caimei.utils.StringUtil;
+import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
 import com.thinkgem.jeesite.common.utils.StringUtils;
@@ -9,7 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
@@ -24,6 +29,8 @@ import java.util.List;
 public class CmHeheUserService extends CrudService<CmHeheUserDao, CmHeheUser> {
     @Autowired
     private CmHeheUserDao cmHeheUserDao;
+    @Autowired
+    private CmHeheActivityProductDao activityProductDao;
 
     public CmHeheUser get(String id) {
         return super.get(id);
@@ -39,9 +46,27 @@ public class CmHeheUserService extends CrudService<CmHeheUserDao, CmHeheUser> {
 
     @Transactional(readOnly = false)
     public void save(CmHeheUser cmHeheUser) {
+        CmUser user = new CmUser();
+        user.setBindMobile("H" + cmHeheUser.getMobile());
+        user.setUserName(cmHeheUser.getName());
+        user.setName(cmHeheUser.getName());
         if (StringUtils.isBlank(cmHeheUser.getId())) {
             cmHeheUser.setUserIdentity("2");
             cmHeheUser.setAddTime(new Date());
+            //保存user表
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String currentTime = simpleDateFormat.format(new Date());
+            user.setPassword("HeHe");
+            //6:呵呵商城用户
+            user.setUserPermission(6);
+            user.setUserIdentity(6);
+            user.setRegisterTime(currentTime);
+            user.setValidFlag("1");
+            cmHeheUserDao.insertUser(user);
+            cmHeheUser.setUserId(user.getUserID());
+        } else {
+            user.setUserID(cmHeheUser.getUserId());
+            cmHeheUserDao.updateUser(user);
         }
         super.save(cmHeheUser);
     }
@@ -49,4 +74,57 @@ public class CmHeheUserService extends CrudService<CmHeheUserDao, CmHeheUser> {
     public Integer findMobileOnly(CmHeheUser cmHeheUser) {
         return cmHeheUserDao.findMobileOnly(cmHeheUser);
     }
+
+    public Page<CmHeheActivityProduct> activityProductList(Page<CmHeheActivityProduct> productPage, CmHeheActivityProduct activityProduct) {
+        activityProduct.setPage(productPage);
+        List<CmHeheActivityProduct> productList = cmHeheUserDao.activityProductList(activityProduct);
+        String wwwServer = Global.getConfig("wwwServer");
+        productList.forEach(item -> {
+            List<CmHeHeActivityLadder> activityLadderList = activityProductDao.findActivityLadder(item.getActivityId(), item.getProductId());
+            if (StringUtil.isNotBlank(item.getMainImage())) {
+                item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
+            }
+            item.setActivityLadderList(activityLadderList);
+        });
+        productPage.setList(productList);
+        return productPage;
+    }
+
+    public Page<CmHeheProduct> findProductPage(Page<CmHeheProduct> productPage, CmHeheProduct product, Integer userId) {
+        List<Integer> productIds = cmHeheUserDao.findUserActivityProduct(userId);
+        product.setIds(productIds);
+        product.setPage(productPage);
+        List<CmHeheProduct> productList = cmHeheUserDao.findAllActivityProduct(product);
+        String wwwServer = Global.getConfig("wwwServer");
+        productList.forEach(item -> {
+            if (StringUtil.isNotBlank(item.getMainImage())) {
+                item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
+            }
+        });
+        productPage.setList(productList);
+        return productPage;
+    }
+
+    @Transactional(readOnly = false)
+    public void addActivityProducts(Integer userId, String productIds) {
+        if (StringUtil.isNotBlank(productIds)) {
+            String[] strings = productIds.split(",");
+            cmHeHeUserActivity userActivity = new cmHeHeUserActivity();
+            userActivity.setUserId(userId);
+            for (String productId : strings) {
+                if (StringUtil.isNotBlank(productId)) {
+                    userActivity.setProductId(Integer.valueOf(productId));
+                    Integer activityId = activityProductDao.findActivityByProductId(productId);
+                    userActivity.setActivityId(activityId);
+                    cmHeheUserDao.insertUserActivity(userActivity);
+                }
+            }
+
+        }
+    }
+
+    @Transactional(readOnly = false)
+    public void saveSort(String sort, String id) {
+        cmHeheUserDao.updateSortById(sort, id);
+    }
 }

+ 2 - 3
src/main/java/com/caimei/modules/hehe/web/CmHeheActivityController.java

@@ -49,7 +49,6 @@ public class CmHeheActivityController extends BaseController {
     public String list(CmHeheActivity cmHeheActivity, HttpServletRequest request, HttpServletResponse response, Model model) {
         Page<CmHeheActivity> page = cmHeheActivityService.findPage(new Page<CmHeheActivity>(request, response), cmHeheActivity);
         model.addAttribute("page", page);
-        model.addAttribute("userId", cmHeheActivity.getUserId());
         return "modules/hehe/cmHeheActivityList";
     }
 
@@ -66,14 +65,14 @@ public class CmHeheActivityController extends BaseController {
         }
         cmHeheActivityService.save(cmHeheActivity);
         addMessage(redirectAttributes, "保存活动成功");
-        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheActivity/?userId=" + cmHeheActivity.getUserId();
+        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheActivity/";
     }
 
     @RequestMapping(value = "delete")
     public String delete(CmHeheActivity cmHeheActivity, RedirectAttributes redirectAttributes) {
         cmHeheActivityService.delete(cmHeheActivity);
         addMessage(redirectAttributes, "删除活动成功");
-        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheActivity/?userId=" + cmHeheActivity.getUserId();
+        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheActivity/";
     }
 
     /**

+ 3 - 46
src/main/java/com/caimei/modules/hehe/web/CmHeheActivityProductController.java

@@ -67,17 +67,16 @@ public class CmHeheActivityProductController extends BaseController {
     public String delete(CmHeheActivityProduct cmHeheActivityProduct, RedirectAttributes redirectAttributes) {
         cmHeheActivityProductService.delete(cmHeheActivityProduct);
         addMessage(redirectAttributes, "删除活动商品成功");
-        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheActivityProduct/list?activityId=" + cmHeheActivityProduct.getActivityId() + "&userId=" + cmHeheActivityProduct.getUserId();
+        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheActivityProduct/list?activityId=" + cmHeheActivityProduct.getActivityId();
     }
 
     /**
      * 添加商品,商品数据
      */
     @RequestMapping(value = "findProductPage")
-    public String findProductPage(CmHeheProduct product, Integer userId, Model model, HttpServletRequest request, HttpServletResponse response) {
-        Page<CmHeheProduct> page = cmHeheActivityProductService.findProductPage(new Page<CmHeheProduct>(request, response), product, userId);
+    public String findProductPage(CmHeheProduct product, Model model, HttpServletRequest request, HttpServletResponse response) {
+        Page<CmHeheProduct> page = cmHeheActivityProductService.findProductPage(new Page<CmHeheProduct>(request, response), product);
         model.addAttribute("page", page);
-        model.addAttribute("userId", userId);
         return "modules/hehe/addActivityProduct";
     }
 
@@ -96,48 +95,6 @@ public class CmHeheActivityProductController extends BaseController {
         return map;
     }
 
-    /**
-     * 批量更新排序值
-     */
-    @RequestMapping(value = "batchSaveSort")
-    @ResponseBody
-    public Map<String, Object> batchSaveSort(String sortList) {
-        Map<String, Object> map = Maps.newLinkedHashMap();
-        try {
-            String[] newPageLists = sortList.split(",");
-            for (String list : newPageLists) {
-                String[] split = list.split("-");
-                if (split.length == 1 || split.length < 1) {
-                    String id = split[0];
-                    String sort = null;
-                    cmHeheActivityProductService.saveSort(sort, id);
-                } else {
-                    String id = split[0];
-                    String sort = split[1];
-                    if (isInteger(sort)) {
-                        if (StringUtils.equals("0", sort)) {
-                            map.put("success", false);
-                            map.put("msg", "排序值只能填写大于等于1的整数");
-                            return map;
-                        }
-                        cmHeheActivityProductService.saveSort(sort, id);
-                    } 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;
-        }
-    }
-
     /**
      * 保存活动阶梯
      */

+ 93 - 11
src/main/java/com/caimei/modules/hehe/web/CmHeheUserController.java

@@ -1,23 +1,29 @@
 package com.caimei.modules.hehe.web;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.shiro.authz.annotation.RequiresPermissions;
+import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
+import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.caimei.modules.hehe.entity.CmHeheUser;
+import com.caimei.modules.hehe.service.CmHeheUserService;
+import com.google.common.collect.Maps;
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.thinkgem.jeesite.common.web.BaseController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
-import com.thinkgem.jeesite.common.config.Global;
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.web.BaseController;
-import com.thinkgem.jeesite.common.utils.StringUtils;
-import com.caimei.modules.hehe.entity.CmHeheUser;
-import com.caimei.modules.hehe.service.CmHeheUserService;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;
 
 /**
  * 呵呵用户Controller
@@ -77,10 +83,86 @@ public class CmHeheUserController extends BaseController {
      * 呵呵商城所有用户列表
      */
     @RequestMapping("/userList")
-    public String userList(CmHeheUser cmHeheUser, HttpServletRequest request, HttpServletResponse response, Model model){
+    public String userList(CmHeheUser cmHeheUser, HttpServletRequest request, HttpServletResponse response, Model model) {
         Page<CmHeheUser> page = cmHeheUserService.findPage(new Page<CmHeheUser>(request, response), cmHeheUser);
         model.addAttribute("page", page);
         return "modules/hehe/cmHeheUserAllList";
     }
 
+    /**
+     * 分销者活动商品数据
+     */
+    @RequestMapping(value = "activityProductList")
+    public String activityProductList(CmHeheActivityProduct activityProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<CmHeheActivityProduct> page = cmHeheUserService.activityProductList(new Page<CmHeheActivityProduct>(request, response), activityProduct);
+        model.addAttribute("page", page);
+        model.addAttribute("activityProduct", activityProduct);
+        return "modules/hehe/userActivityProductList";
+    }
+
+    /**
+     * 添加活动商品,商品数据
+     */
+    @RequestMapping(value = "findProductPage")
+    public String findProductPage(CmHeheProduct product, Integer userId, Model model, HttpServletRequest request, HttpServletResponse response) {
+        Page<CmHeheProduct> page = cmHeheUserService.findProductPage(new Page<CmHeheProduct>(request, response), product, userId);
+        model.addAttribute("page", page);
+        model.addAttribute("userId", userId);
+        return "modules/hehe/addUserActivityProduct";
+    }
+
+    /**
+     * 添加商品
+     */
+    @RequestMapping(value = "addActivityProducts")
+    @ResponseBody
+    public Map<String, Object> addActivityProducts(Integer userId, String productIds) {
+        cmHeheUserService.addActivityProducts(userId, productIds);
+        HashMap<String, Object> map = new HashMap<>(2);
+        map.put("success", true);
+        map.put("info", "添加活动商品成功");
+        return map;
+    }
+
+    /**
+     * 批量更新排序值
+     */
+    @RequestMapping(value = "batchSaveSort")
+    @ResponseBody
+    public Map<String, Object> batchSaveSort(String sortList) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            String[] newPageLists = sortList.split(",");
+            for (String list : newPageLists) {
+                String[] split = list.split("-");
+                if (split.length == 1 || split.length < 1) {
+                    String id = split[0];
+                    String sort = null;
+                    cmHeheUserService.saveSort(sort, id);
+                } else {
+                    String id = split[0];
+                    String sort = split[1];
+                    if (isInteger(sort)) {
+                        if (StringUtils.equals("0", sort)) {
+                            map.put("success", false);
+                            map.put("msg", "排序值只能填写大于等于1的整数");
+                            return map;
+                        }
+                        cmHeheUserService.saveSort(sort, id);
+                    } 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;
+        }
+    }
 }

+ 0 - 6
src/main/resources/mappings/modules/hehe/CmHeheActivityMapper.xml

@@ -5,7 +5,6 @@
 	<sql id="cmHeheActivityColumns">
 		a.id AS "id",
 		a.name AS "name",
-		a.userId AS "userId",
 		a.status AS "status",
 		a.listImage AS "listImage",
 		a.detailsImage AS "detailsImage",
@@ -39,9 +38,6 @@
 			<if test="status != null and status != ''">
 				AND a.status = #{status}
 			</if>
-			<if test="userId != null">
-				AND a.userId = #{userId}
-			</if>
 			<if test="activityStatus == 1">
 				AND a.beginTime <![CDATA[ > ]]> NOW()
 			</if>
@@ -82,7 +78,6 @@
 	<insert id="insert" parameterType="CmHeheActivity"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_hehe_activity(
 			name,
-			userId,
 			status,
 			listImage,
 			detailsImage,
@@ -92,7 +87,6 @@
 			delFlag
 		) VALUES (
 			#{name},
-			#{userId},
 			#{status},
 			#{listImage},
 			#{detailsImage},

+ 5 - 10
src/main/resources/mappings/modules/hehe/CmHeheActivityProductMapper.xml

@@ -6,7 +6,6 @@
 		a.id AS "id",
 		a.activityId AS "activityId",
 		a.productId AS "productId",
-		a.sort AS "sort",
 		a.addTime AS "addTime",
 		a.delFlag AS "delFlag",
 		chp.price AS "price",
@@ -50,7 +49,7 @@
 				ORDER BY ${page.orderBy}
 			</when>
 			<otherwise>
-				ORDER BY -a.sort DESC
+				ORDER BY a.addTime DESC
 			</otherwise>
 		</choose>
 	</select>
@@ -76,13 +75,11 @@
 		INSERT INTO cm_hehe_activity_product(
 			activityId,
 			productId,
-			sort,
 			addTime,
 			delFlag
 		) VALUES (
 			#{activityId},
 			#{productId},
-			#{sort},
 			NOW(),
 			0
 		)
@@ -92,7 +89,6 @@
 		UPDATE cm_hehe_activity_product SET 	
 			activityId = #{activityId},
 			productId = #{productId},
-			sort = #{sort},
 			addTime = #{addTime}
 		WHERE id = #{id}
 	</update>
@@ -110,7 +106,6 @@
 		WHERE
 		  a.delFlag = 0
 		  AND cha.delFlag = 0
-		  AND cha.userId = #{userId}
 	</select>
 
 	<select id="findAllHeHeProduct" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
@@ -144,10 +139,6 @@
 		</if>
 	</select>
 
-	<update id="updateSortById">
-		UPDATE cm_hehe_activity_product SET sort = #{sort} WHERE id =#{id}
-	</update>
-
 	<select id="findActivityLadder" resultType="com.caimei.modules.hehe.entity.CmHeHeActivityLadder">
 		SELECT
 		  id,
@@ -180,5 +171,9 @@
 	<delete id="deleteLadder">
 		DELETE FROM cm_hehe_activity_ladder WHERE activityId = #{activityId} AND productId =#{productId}
 	</delete>
+
+	<select id="findActivityByProductId" resultType="integer">
+		SELECT activityId FROM cm_hehe_activity_product WHERE productId = #{productId}
+	</select>
 	
 </mapper>

+ 110 - 0
src/main/resources/mappings/modules/hehe/CmHeheUserMapper.xml

@@ -4,6 +4,7 @@
     
 	<sql id="cmHeheUserColumns">
 		a.id AS "id",
+		a.userId AS "userId",
 		a.name AS "name",
 		a.mobile AS "mobile",
 		a.userIdentity AS "userIdentity",
@@ -74,6 +75,7 @@
 	
 	<insert id="insert" parameterType="CmHeheUser"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_hehe_user(
+			userId,
 			name,
 			mobile,
 			userIdentity,
@@ -81,6 +83,7 @@
 			openId,
 			addTime
 		) VALUES (
+			#{userId},
 			#{name},
 			#{mobile},
 			#{userIdentity},
@@ -112,5 +115,112 @@
 			  AND id != #{id}
 		  </if>
 	</select>
+
+	<insert id="insertUser" parameterType="com.caimei.modules.user.entity.CmUser" keyColumn="userID" keyProperty="userID" useGeneratedKeys="true">
+		INSERT INTO USER (
+		  bindMobile, userPermission, userIdentity,
+		  userName, password, name, registerTime,
+		  validFlag
+		)
+		VALUES
+		  (
+			#{bindMobile}, #{userPermission}, #{userIdentity},
+			#{userName}, #{password}, #{name}, #{registerTime},
+			#{validFlag}
+		  )
+	</insert>
+
+	<update id="updateUser">
+		UPDATE
+		  user
+		SET
+		  bindMobile = #{bindMobile},
+		  userName = #{userName},
+		  name = #{name}
+		WHERE
+		  userID = #{userID}
+	</update>
+
+	<select id="activityProductList" resultType="com.caimei.modules.hehe.entity.CmHeheActivityProduct">
+		SELECT
+		a.id AS "id",
+		a.userId AS "userId",
+		a.activityId AS "activityId",
+		a.productId AS "productId",
+		a.sort AS "sort",
+		chp.price AS "price",
+		p.name AS "name",
+		p.mainImage AS "mainImage",
+		p.unit AS "unit",
+		s.name AS "shopName"
+		FROM
+		cm_hehe_user_activity a
+		LEFT JOIN cm_hehe_product chp ON chp.productId = a.productID
+		LEFT JOIN product p ON a.productId = p.productID
+		LEFT JOIN shop s ON s.shopID = p.shopID
+		WHERE
+		a.userId = #{userId}
+		<if test="name != null and name != ''">
+			AND p.name LIKE CONCAT('%',#{name},'%')
+		</if>
+		<if test="shopName != null and shopName != ''">
+			AND s.name LIKE CONCAT('%',#{shopName},'%')
+		</if>
+		ORDER BY
+		- a.sort DESC
+	</select>
+
+	<select id="findUserActivityProduct" resultType="integer">
+		SELECT productId FROM cm_hehe_user_activity  WHERE userId = #{userId}
+	</select>
+	
+	<select id="findAllActivityProduct" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
+		SELECT
+		  a.id AS "id",
+		  a.productId AS "productId",
+		  chp.price AS "price",
+		  p.name AS "name",
+		  p.mainImage AS "mainImage",
+		  s.name AS "shopName"
+		FROM
+		  cm_hehe_activity_product a
+		  LEFT JOIN cm_hehe_product chp ON a.productId = chp.productId
+		  LEFT JOIN product p ON a.productId = p.productID
+		  LEFT JOIN shop s ON s.shopID = p.shopID
+		WHERE
+		  a.delFlag = 0
+		<if test="ids != null and ids.size() > 0 ">
+			AND a.productId NOT IN
+			<foreach collection="ids" open="(" close=")" item="id" separator=",">
+				#{id}
+			</foreach>
+		</if>
+		<if test="productId != null">
+			AND a.productId = #{productId}
+		</if>
+		<if test="name != null and name != ''">
+			AND p.name LIKE CONCAT('%',#{name},'%')
+		</if>
+		<if test="shopName != null and shopName != ''">
+			AND s.name LIKE CONCAT('%',#{shopName},'%')
+		</if>
+		ORDER BY productId DESC
+	</select>
+
+	<insert id="insertUserActivity">
+		INSERT INTO `cm_hehe_user_activity` (
+		  `userId`, `activityId`, `productId`,
+		  addTime
+		)
+		VALUES
+		  (
+			#{userId}, #{activityId}, #{productId},
+			NOW()
+		  )
+	</insert>
+
+	<update id="updateSortById">
+		UPDATE cm_hehe_user_activity SET sort = #{sort} WHERE id =#{id}
+	</update>
 	
 </mapper>

+ 0 - 1
src/main/webapp/WEB-INF/views/modules/hehe/addActivityProduct.jsp

@@ -76,7 +76,6 @@
 </head>
 <body>
 <form:form id="searchForm" modelAttribute="cmHeheProduct" action="${ctx}/hehe/cmHeheActivityProduct/findProductPage" method="post" class="breadcrumb form-search">
-    <input name="userId" type="hidden" value="${userId}"/>
     <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
     <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
     <div class="ul-form">

+ 126 - 0
src/main/webapp/WEB-INF/views/modules/hehe/addUserActivityProduct.jsp

@@ -0,0 +1,126 @@
+<%@ 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 = new Array();
+            var $items = $('.check-item:checked');
+            $items.each(function () {
+                //通过拿到的商品ID组合键获取其它值
+                var productId = $(this).val();
+                items.push(productId);
+            });
+            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="cmHeheProduct" action="${ctx}/hehe/cmHeheUser/findProductPage" method="post"
+           class="breadcrumb form-search">
+    <input name="userId" type="hidden" value="${userId}"/>
+    <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" onkeyup="onlynum(this)" maxlength="9" class="input-mini"/>
+        <label>商品名称:</label>
+        <form:input path="name" 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>
+        <th>售价</th>
+    </tr>
+    <tbody>
+    <c:if test="${not empty page.list}">
+        <c:forEach items="${page.list}" var="item">
+            <tr id="${item.id}" 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>
+                <td>${item.price}</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>

+ 2 - 4
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityForm.jsp

@@ -85,13 +85,11 @@
 </head>
 <body>
 	<ul class="nav nav-tabs">
-		<li><a href="${ctx}/hehe/cmHeheUser/">分销者列表</a></li>
-		<li><a href="${ctx}/hehe/cmHeheActivity/list?userId=${cmHeheActivity.userId}">活动列表</a></li>
-		<li class="active"><a href="${ctx}/hehe/cmHeheActivity/form?id=${cmHeheActivity.id}&userId=${cmHeheActivity.userId}">${not empty cmHeheActivity.id?'编辑':'添加'}活动</a></li>
+		<li><a href="${ctx}/hehe/cmHeheActivity/list">活动列表</a></li>
+		<li class="active"><a href="${ctx}/hehe/cmHeheActivity/form?id=${cmHeheActivity.id}">${not empty cmHeheActivity.id?'编辑':'添加'}活动</a></li>
 	</ul><br/>
 	<form:form id="inputForm" modelAttribute="cmHeheActivity" action="${ctx}/hehe/cmHeheActivity/save" method="post" class="form-horizontal">
 		<form:hidden path="id"/>
-		<form:hidden path="userId"/>
 		<sys:message content="${message}"/>
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>活动名称:</label>

+ 3 - 5
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityList.jsp

@@ -22,13 +22,11 @@
 </head>
 <body>
 	<ul class="nav nav-tabs">
-		<li><a href="${ctx}/hehe/cmHeheUser/">分销者列表</a></li>
-		<li class="active"><a href="${ctx}/hehe/cmHeheActivity/list?userId=${userId}">活动列表</a></li>
+		<li class="active"><a href="${ctx}/hehe/cmHeheActivity/list">活动列表</a></li>
 	</ul>
 	<form:form id="searchForm" modelAttribute="cmHeheActivity" action="${ctx}/hehe/cmHeheActivity/" method="post" class="breadcrumb form-search">
 		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
 		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-		<input name="userId" type="hidden" value="${userId}"/>
 		<div class="ul-form">
 			 <label>活动名称:</label>
 				<form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
@@ -46,7 +44,7 @@
 				<form:option value="3" label="已结束"/>
 			</form:select>
 			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
-			&nbsp;&nbsp;<input class="btn btn-primary" style="width: 80px" onclick="window.location='${ctx}/hehe/cmHeheActivity/form?userId=${userId}'" value="添加活动"/>
+			&nbsp;&nbsp;<input class="btn btn-primary" style="width: 80px" onclick="window.location='${ctx}/hehe/cmHeheActivity/form'" value="添加活动"/>
 			<div class="clearfix"></div>
 		</div>
 	</form:form>
@@ -94,7 +92,7 @@
 					<fmt:formatDate value="${cmHeheActivity.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
 				</td>
 				<td>
-					<a href="${ctx}/hehe/cmHeheActivityProduct/list?activityId=${cmHeheActivity.id}&userId=${userId}">商品列表</a>
+					<a href="${ctx}/hehe/cmHeheActivityProduct/list?activityId=${cmHeheActivity.id}">商品列表</a>
     				<a href="${ctx}/hehe/cmHeheActivity/form?id=${cmHeheActivity.id}">编辑</a>
 					<a href="${ctx}/hehe/cmHeheActivity/delete?id=${cmHeheActivity.id}" onclick="return confirmx('确认要删除该呵呵商城活动吗?', this.href)">删除</a>
 				</td>

+ 5 - 41
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductList.jsp

@@ -28,16 +28,12 @@
 </head>
 <body>
 <ul class="nav nav-tabs">
-    <li><a href="${ctx}/hehe/cmHeheUser/">分销者列表</a></li>
-    <li><a href="${ctx}/hehe/cmHeheActivity/list?userId=${activityProduct.userId}">活动列表</a></li>
-    <li class="active"><a
-            href="${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}&userId=${activityProduct.userId}">活动商品列表</a>
-    </li>
+    <li><a href="${ctx}/hehe/cmHeheActivity/list">活动列表</a></li>
+    <li class="active"><a href="${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}">活动商品列表</a></li>
 </ul>
 <form:form id="searchForm" modelAttribute="cmHeheActivityProduct" action="${ctx}/hehe/cmHeheActivityProduct/"
            method="post" class="breadcrumb form-search">
     <input type="hidden" name="activityId" value="${activityProduct.activityId}"/>
-    <input type="hidden" name="userId" value="${activityProduct.userId}"/>
     <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
     <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
     <div class="ul-form">
@@ -46,7 +42,6 @@
         <label>供应商名称:</label>
         <form:input path="shopName" htmlEscape="false" class="input-medium"/>
         &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
-        <input class="btn btn-primary" type="button" value="一键排序" onclick="batchSaveSort()" style="margin-left: 15px"/>
         &nbsp;&nbsp;<input class="btn btn-primary" style="width: 80px" onclick="showSelect()" value="添加商品"/>
         <div class="clearfix"></div>
     </div>
@@ -60,15 +55,12 @@
         <th>供应商</th>
         <th>售价</th>
         <th>活动价</th>
-        <th>排序</th>
         <th>操作</th>
     </tr>
     </thead>
     <tbody>
     <c:forEach items="${page.list}" var="cmHeheActivityProduct">
         <tr>
-            <input class="check-item" type="hidden" id="preferredProductSort${cmHeheActivityProduct.id}"
-                   value='${cmHeheActivityProduct.id}-${cmHeheActivityProduct.sort}'/>
             <td>
                 <img class="mainImage" src="${cmHeheActivityProduct.mainImage}" width="50px" height="50px">
             </td>
@@ -95,10 +87,6 @@
                     <label>¥${cmHeheActivityProduct.activityLadderList[2].buyPrice}(购买数≥${cmHeheActivityProduct.activityLadderList[2].buyNum})</label><br>
                 </c:if>
             </td>
-            <td>
-                <input id="sort" name="sort" style="width:50px;" value="${cmHeheActivityProduct.sort}"
-                       onkeyup="onlynum(this)" onchange="changeSort(${cmHeheActivityProduct.id},this)">
-            </td>
             <td>
                 <a href="javascript:void(0);" onclick="showLadder(${cmHeheActivityProduct.id})">编辑</a>
                 <a href="${ctx}/hehe/cmHeheActivityProduct/delete?id=${cmHeheActivityProduct.id}"
@@ -117,7 +105,7 @@
         var title = '';
         url = "${ctx}/hehe/cmHeheActivityProduct/findProductPage";
         title = "添加商品";
-        top.$.jBox("iframe:" + url + "?userId=${activityProduct.userId}", {
+        top.$.jBox("iframe:" + url, {
             iframeScrolling: 'yes',
             width: $(top.document).width() - 600,
             height: $(top.document).height() - 160,
@@ -137,7 +125,7 @@
                             if (true == data.success) {
                                 $.jBox.tip(data.info, 'info');
                                 setTimeout(function () {
-                                    window.location.href = "${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}&userId=${activityProduct.userId}"
+                                    window.location.href = "${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}"
                                 }, 1300);
                             } else {
                                 $.jBox.tip(data.info, 'error');
@@ -154,30 +142,6 @@
         });
     }
 
-    //修改排序值
-    function changeSort(id, sortThis) {
-        var value = sortThis.value;
-        $("#preferredProductSort" + id).val(id + "-" + value);
-    }
-
-    //批量保存排序
-    function batchSaveSort() {
-        var items = new Array();
-        var $items = $('.check-item');
-        $items.each(function () {
-            items.push($(this).val());
-        });
-        //保存批量排序
-        $.post("${ctx}/hehe/cmHeheActivityProduct/batchSaveSort?sortList=" + items, function (data) {
-            if (true == data.success) {
-                $.jBox.tip(data.msg, 'info');
-                window.location.href = "${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}&userId=${activityProduct.userId}";
-            } else {
-                $.jBox.tip(data.msg, 'error');
-            }
-        }, "JSON");//这里返回的类型有:json,html,xml,text
-    }
-
     /**
      * @param obj
      * jquery控制input只能输入数字
@@ -209,7 +173,7 @@
                         if (true == data.success) {
                             $.jBox.tip(data.info, 'info');
                             setTimeout(function () {
-                                window.location.href = "${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}&userId=${activityProduct.userId}"
+                                window.location.href = "${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}"
                             }, 1300);
                         } else {
                             $.jBox.tip(data.info, 'error');

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheUserList.jsp

@@ -69,7 +69,7 @@
 				</td>
 				<td>
     				<a href="${ctx}/hehe/cmHeheUser/form?id=${cmHeheUser.id}">编辑</a>
-					<a href="${ctx}/hehe/cmHeheActivity/list?userId=${cmHeheUser.id}">活动列表</a>
+					<a href="${ctx}/hehe/cmHeheUser/activityProductList?userId=${cmHeheUser.userId}">活动商品</a>
 				</td>
 			</tr>
 		</c:forEach>

+ 186 - 0
src/main/webapp/WEB-INF/views/modules/hehe/userActivityProductList.jsp

@@ -0,0 +1,186 @@
+<%@ 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;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/hehe/cmHeheUser/">分销者列表</a></li>
+    <li class="active"><a href="${ctx}/hehe/cmHeheUser/activityProductList?userId=${activityProduct.userId}">活动商品</a>
+    </li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmHeheActivityProduct" action="${ctx}/hehe/cmHeheUser/activityProductList"
+           method="post" class="breadcrumb form-search">
+    <input type="hidden" name="userId" value="${activityProduct.userId}"/>
+    <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>商品名称:</label>
+        <form:input path="name" htmlEscape="false" class="input-medium"/>
+        <label>供应商名称:</label>
+        <form:input path="shopName" htmlEscape="false" class="input-medium"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <input class="btn btn-primary" type="button" value="一键排序" onclick="batchSaveSort()" style="margin-left: 15px"/>
+        &nbsp;&nbsp;<input class="btn btn-primary" style="width: 80px" onclick="showSelect()" value="添加商品"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>图片</th>
+        <th>名称</th>
+        <th>供应商</th>
+        <th>售价</th>
+        <th>活动价</th>
+        <th>排序</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="cmHeheActivityProduct">
+        <tr>
+            <input class="check-item" type="hidden" id="preferredProductSort${cmHeheActivityProduct.id}"
+                   value='${cmHeheActivityProduct.id}-${cmHeheActivityProduct.sort}'/>
+            <td>
+                <img class="mainImage" src="${cmHeheActivityProduct.mainImage}" width="50px" height="50px">
+            </td>
+            <td>
+                    ${cmHeheActivityProduct.name}
+            </td>
+            <td>
+                    ${cmHeheActivityProduct.shopName}
+            </td>
+            <td>
+                    ${cmHeheActivityProduct.price}
+            </td>
+            <td>
+                <c:if test="${cmHeheActivityProduct.activityLadderList.size() eq 1}">
+                    <label>¥${cmHeheActivityProduct.activityLadderList[0].buyPrice}(购买数≥${cmHeheActivityProduct.activityLadderList[0].buyNum})</label><br>
+                </c:if>
+                <c:if test="${cmHeheActivityProduct.activityLadderList.size() eq 2}">
+                    <label>¥${cmHeheActivityProduct.activityLadderList[0].buyPrice}(购买数${cmHeheActivityProduct.activityLadderList[0].buyNum}-${cmHeheActivityProduct.activityLadderList[1].buyNum})</label><br>
+                    <label>¥${cmHeheActivityProduct.activityLadderList[1].buyPrice}(购买数≥${cmHeheActivityProduct.activityLadderList[1].buyNum})</label><br>
+                </c:if>
+                <c:if test="${cmHeheActivityProduct.activityLadderList.size() eq 3}">
+                    <label>¥${cmHeheActivityProduct.activityLadderList[0].buyPrice}(购买数${cmHeheActivityProduct.activityLadderList[0].buyNum}-${cmHeheActivityProduct.activityLadderList[1].buyNum})</label><br>
+                    <label>¥${cmHeheActivityProduct.activityLadderList[1].buyPrice}(购买数${cmHeheActivityProduct.activityLadderList[1].buyNum}-${cmHeheActivityProduct.activityLadderList[2].buyNum})</label><br>
+                    <label>¥${cmHeheActivityProduct.activityLadderList[2].buyPrice}(购买数≥${cmHeheActivityProduct.activityLadderList[2].buyNum})</label><br>
+                </c:if>
+            </td>
+            <td>
+                <input id="sort" name="sort" style="width:50px;" value="${cmHeheActivityProduct.sort}"
+                       onkeyup="onlynum(this)" onchange="changeSort(${cmHeheActivityProduct.id},this)">
+            </td>
+            <td>
+                <a href="${ctx}/hehe/cmHeheActivityProduct/delete?id=${cmHeheActivityProduct.id}"
+                   onclick="return confirmx('确认要删除该商品吗?', this.href)">删除</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+
+<script>
+    //选择添加
+    function showSelect() {
+        var url = '';
+        var title = '';
+        url = "${ctx}/hehe/cmHeheUser/findProductPage";
+        title = "添加商品";
+        top.$.jBox("iframe:" + url + "?userId=${activityProduct.userId}", {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 600,
+            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();
+                    if (items.length > 0) {
+                        console.log(items);
+                        //添加数据
+                        $.post("${ctx}/hehe/cmHeheUser/addActivityProducts?userId=${activityProduct.userId}&productIds=" + items, function (data) {
+                            if (true == data.success) {
+                                $.jBox.tip(data.info, 'info');
+                                setTimeout(function () {
+                                    window.location.href = "${ctx}/hehe/cmHeheUser/activityProductList?userId=${activityProduct.userId}"
+                                }, 1300);
+                            } else {
+                                $.jBox.tip(data.info, 'error');
+                            }
+                        }, "JSON");//这里返回的类型有:json,html,xml,text
+                        return true;
+                    } else {
+                        top.$.jBox.tip("请先勾选商品...");
+                        return false;
+                    }
+                }
+                return true;
+            }
+        });
+    }
+
+    //修改排序值
+    function changeSort(id, sortThis) {
+        var value = sortThis.value;
+        $("#preferredProductSort" + id).val(id + "-" + value);
+    }
+
+    //批量保存排序
+    function batchSaveSort() {
+        var items = new Array();
+        var $items = $('.check-item');
+        $items.each(function () {
+            items.push($(this).val());
+        });
+        //保存批量排序
+        $.post("${ctx}/hehe/cmHeheUser/batchSaveSort?sortList=" + items, function (data) {
+            if (true == data.success) {
+                $.jBox.tip(data.msg, 'info');
+                window.location.href = "${ctx}/hehe/cmHeheUser/activityProductList?userId=${activityProduct.userId}";
+            } else {
+                $.jBox.tip(data.msg, 'error');
+            }
+        }, "JSON");//这里返回的类型有:json,html,xml,text
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+</script>
+</body>
+</html>