瀏覽代碼

超级会员优惠商品

Aslee 3 年之前
父節點
當前提交
e83e4174d2

+ 24 - 0
src/main/java/com/caimei/modules/svip/dao/CmSvipProductDao.java

@@ -0,0 +1,24 @@
+package com.caimei.modules.svip.dao;
+
+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.svip.entity.CmSvipProduct;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 超级会员优惠商品DAO接口
+ * @author Aslee
+ * @version 2021-09-23
+ */
+@MyBatisDao
+public interface CmSvipProductDao extends CrudDao<CmSvipProduct> {
+
+    List<Integer> findSvipProductIds();
+
+    List<Product> findAllProduct(Product product);
+
+    void saveSort(@Param("sort") String sort, @Param("id") String id);
+}

+ 180 - 0
src/main/java/com/caimei/modules/svip/entity/CmSvipProduct.java

@@ -0,0 +1,180 @@
+package com.caimei.modules.svip.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+
+/**
+ * 超级会员优惠商品Entity
+ * @author Aslee
+ * @version 2021-09-23
+ */
+public class CmSvipProduct extends DataEntity<CmSvipProduct> {
+	
+	private static final long serialVersionUID = 1L;
+	private Integer productId;		// 商品id
+	private Integer priceType;		// 会员价类型:1折扣,2优惠价
+	private BigDecimal discount;		// 会员折扣
+	private BigDecimal discountPrice;		// 会员价
+	private Integer sort;		// 排序值
+	private Date addTime;		// 添加时间
+
+    private String productImage;   //商品图片
+    private String productName;     //商品名称
+    private String shopName;        //供应商名称
+    private BigDecimal price;       //商品机构价
+	private String includedTax;		//是否含税   0不含税,1含税
+	private String invoiceType;		//发票类型(基于是否含税基础)   1增值税票,2普通票, 3不能开票
+	private String taxPoint;		//机构开票税点(基于不含税基础) :增值税默认13%,普通票6%取值范围[0-100]
+	private String supplierTaxPoint;//供应商开票税点(基于不含税基础) :增值税默认13%,普通票6%取值范围[0-100]
+	private String costPrice;        // 成本价
+	private String costProportional;        // 比例成本百分比
+	private String costCheckFlag;        // 成本价选中标志:1固定成本 2比例成
+	
+	public CmSvipProduct() {
+		super();
+	}
+
+	public CmSvipProduct(String id){
+		super(id);
+	}
+
+	public Integer getProductId() {
+		return productId;
+	}
+
+	public void setProductId(Integer productId) {
+		this.productId = productId;
+	}
+
+	public Integer getPriceType() {
+		return priceType;
+	}
+
+	public void setPriceType(Integer priceType) {
+		this.priceType = priceType;
+	}
+
+	public BigDecimal getDiscount() {
+		return discount;
+	}
+
+	public void setDiscount(BigDecimal discount) {
+		this.discount = discount;
+	}
+
+	public BigDecimal getDiscountPrice() {
+		return discountPrice;
+	}
+
+	public void setDiscountPrice(BigDecimal discountPrice) {
+		this.discountPrice = discountPrice;
+	}
+
+	public Integer getSort() {
+		return sort;
+	}
+
+	public void setSort(Integer sort) {
+		this.sort = sort;
+	}
+
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	public Date getAddTime() {
+		return addTime;
+	}
+
+	public void setAddTime(Date addTime) {
+		this.addTime = addTime;
+	}
+
+    public String getProductImage() {
+        return productImage;
+    }
+
+    public void setProductImage(String productImage) {
+        this.productImage = productImage;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+
+    public BigDecimal getPrice() {
+        return price;
+    }
+
+    public void setPrice(BigDecimal price) {
+        this.price = price;
+    }
+
+	public String getIncludedTax() {
+		return includedTax;
+	}
+
+	public void setIncludedTax(String includedTax) {
+		this.includedTax = includedTax;
+	}
+
+	public String getInvoiceType() {
+		return invoiceType;
+	}
+
+	public void setInvoiceType(String invoiceType) {
+		this.invoiceType = invoiceType;
+	}
+
+	public String getTaxPoint() {
+		return taxPoint;
+	}
+
+	public void setTaxPoint(String taxPoint) {
+		this.taxPoint = taxPoint;
+	}
+
+	public String getSupplierTaxPoint() {
+		return supplierTaxPoint;
+	}
+
+	public void setSupplierTaxPoint(String supplierTaxPoint) {
+		this.supplierTaxPoint = supplierTaxPoint;
+	}
+
+	public String getCostPrice() {
+		return costPrice;
+	}
+
+	public void setCostPrice(String costPrice) {
+		this.costPrice = costPrice;
+	}
+
+	public String getCostProportional() {
+		return costProportional;
+	}
+
+	public void setCostProportional(String costProportional) {
+		this.costProportional = costProportional;
+	}
+
+	public String getCostCheckFlag() {
+		return costCheckFlag;
+	}
+
+	public void setCostCheckFlag(String costCheckFlag) {
+		this.costCheckFlag = costCheckFlag;
+	}
+}

+ 89 - 0
src/main/java/com/caimei/modules/svip/service/CmSvipProductService.java

@@ -0,0 +1,89 @@
+package com.caimei.modules.svip.service;
+
+import java.util.List;
+
+import com.caimei.modules.product.entity.Product;
+import com.caimei.utils.AppUtils;
+import com.caimei.utils.StringUtil;
+import com.thinkgem.jeesite.common.config.Global;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.service.CrudService;
+import com.caimei.modules.svip.entity.CmSvipProduct;
+import com.caimei.modules.svip.dao.CmSvipProductDao;
+
+import javax.annotation.Resource;
+
+/**
+ * 超级会员优惠商品Service
+ * @author Aslee
+ * @version 2021-09-23
+ */
+@Service
+@Transactional(readOnly = true)
+public class CmSvipProductService extends CrudService<CmSvipProductDao, CmSvipProduct> {
+	@Resource
+	private CmSvipProductDao cmSvipProductDao;
+
+	public CmSvipProduct get(String id) {
+		return super.get(id);
+	}
+	
+	public List<CmSvipProduct> findList(CmSvipProduct cmSvipProduct) {
+		return super.findList(cmSvipProduct);
+	}
+	
+	public Page<CmSvipProduct> findPage(Page<CmSvipProduct> page, CmSvipProduct cmSvipProduct) {
+		Page<CmSvipProduct> page1 = super.findPage(page, cmSvipProduct);
+		List<CmSvipProduct> list = page1.getList();
+		String wwwServer = Global.getConfig("wwwServer");
+		list.forEach(product->{
+			if (StringUtil.isNotBlank(product.getProductImage())) {
+				product.setProductImage(AppUtils.getImageURL("product", product.getProductImage(), 0, wwwServer));
+			}
+		});
+		return page1;
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(CmSvipProduct cmSvipProduct) {
+		if (cmSvipProduct.getIsNewRecord()) {
+			Integer priceType = null == cmSvipProduct.getDiscount() ? 2 : 1;
+			cmSvipProduct.setPriceType(priceType);
+			cmSvipProduct.setSort(1);
+		}
+		super.save(cmSvipProduct);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(CmSvipProduct cmSvipProduct) {
+		super.delete(cmSvipProduct);
+	}
+
+
+	@Transactional(readOnly = false)
+	public Page<Product> findProductPage(Page<Product> productPage, Product product) {
+		List<Integer> ids = cmSvipProductDao.findSvipProductIds();
+		product.setIds(ids);
+		product.setPage(productPage);
+		List<Product> productList = cmSvipProductDao.findAllProduct(product);
+		String wwwServer = Global.getConfig("wwwServer");
+		productList.forEach(item -> {
+			if (StringUtil.isNotBlank(item.getMainImage())) {
+				item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
+			}
+			if (ids.contains(item.getProductID())) {
+				item.setExistsFlag("1");
+			}
+		});
+		productPage.setList(productList);
+		return productPage;
+	}
+
+	@Transactional(readOnly = false)
+	public void saveSort(String sort, String id) {
+		cmSvipProductDao.saveSort(sort, id);
+	}
+}

+ 134 - 0
src/main/java/com/caimei/modules/svip/web/CmSvipProductController.java

@@ -0,0 +1,134 @@
+package com.caimei.modules.svip.web;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.caimei.modules.product.entity.Product;
+import com.google.common.collect.Maps;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+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.svip.entity.CmSvipProduct;
+import com.caimei.modules.svip.service.CmSvipProductService;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;
+
+/**
+ * 超级会员优惠商品Controller
+ * @author Aslee
+ * @version 2021-09-23
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/svip/cmSvipProduct")
+public class CmSvipProductController extends BaseController {
+
+	@Autowired
+	private CmSvipProductService cmSvipProductService;
+	
+	@ModelAttribute
+	public CmSvipProduct get(@RequestParam(required=false) String id) {
+		CmSvipProduct entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = cmSvipProductService.get(id);
+		}
+		if (entity == null){
+			entity = new CmSvipProduct();
+		}
+		return entity;
+	}
+
+	@RequestMapping(value = {"list", ""})
+	public String list(CmSvipProduct cmSvipProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<CmSvipProduct> page = cmSvipProductService.findPage(new Page<CmSvipProduct>(request, response), cmSvipProduct); 
+		model.addAttribute("page", page);
+		return "modules/svip/cmSvipProductList";
+	}
+
+	@RequestMapping(value = "form")
+	public String form(CmSvipProduct cmSvipProduct, Model model) {
+		model.addAttribute("cmSvipProduct", cmSvipProduct);
+		return "modules/svip/cmSvipProductForm";
+	}
+
+	@RequestMapping(value = "save")
+	public String save(CmSvipProduct cmSvipProduct, Model model, RedirectAttributes redirectAttributes) {
+		if (!beanValidator(model, cmSvipProduct)){
+			return form(cmSvipProduct, model);
+		}
+		cmSvipProductService.save(cmSvipProduct);
+		addMessage(redirectAttributes, "保存商品成功");
+		return "redirect:"+Global.getAdminPath()+"/svip/cmSvipProduct/?repage";
+	}
+	
+	@RequestMapping(value = "delete")
+	public String delete(CmSvipProduct cmSvipProduct, RedirectAttributes redirectAttributes) {
+		cmSvipProductService.delete(cmSvipProduct);
+		addMessage(redirectAttributes, "删除商品成功");
+		return "redirect:"+Global.getAdminPath()+"/svip/cmSvipProduct/?repage";
+	}
+
+	@RequestMapping(value = "findProductPage")
+	public String findProductPage(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
+		Page<Product> page = cmSvipProductService.findProductPage(new Page<Product>(request, response), product);
+		model.addAttribute("page", page);
+		model.addAttribute("ids", product.getIds());
+		return "modules/svip/svipAddProduct";
+	}
+
+	/**
+	 * 批量更新排序值
+	 */
+	@RequestMapping(value = "batchSaveSort")
+	@ResponseBody
+	public Map<String, Object> batchSaveSort(String sortList) {
+		Map<String, Object> map = Maps.newLinkedHashMap();
+		try {
+			String[] svipProductList = sortList.split(",");
+			for (String list : svipProductList) {
+				String[] split = list.split("-");
+				if (split.length == 1 || split.length < 1) {
+					String id = split[0];
+					String sort = null;
+					cmSvipProductService.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;
+						}
+						cmSvipProductService.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) {
+			e.printStackTrace();
+			map.put("success", false);
+			map.put("msg", "更新排序失败");
+			return map;
+		}
+	}
+}

+ 152 - 0
src/main/resources/mappings/modules/svip/CmSvipProductMapper.xml

@@ -0,0 +1,152 @@
+<?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.svip.dao.CmSvipProductDao">
+
+    <sql id="cmSvipProductColumns">
+        a.id AS "id",
+		a.productId AS "productId",
+		a.priceType AS "priceType",
+		a.discount AS "discount",
+		a.discountPrice AS "discountPrice",
+		a.sort AS "sort",
+		a.addTime AS "addTime",
+        p.mainImage as "productImage",
+        p.name as "productName",
+		s.name as "shopName",
+        p.price1 as "price",
+        p.includedTax,
+        p.invoiceType,
+        p.taxPoint,
+        p.supplierTaxPoint,
+        p.costCheckFlag,
+        p.costPrice,
+        p.costProportional
+    </sql>
+
+    <sql id="cmSvipProductJoins">
+        left join product p on a.productId = p.productID
+		left join shop s on s.shopID = p.shopID
+	</sql>
+
+    <select id="get" resultType="CmSvipProduct">
+        SELECT
+        <include refid="cmSvipProductColumns"/>
+        FROM cm_svip_product a
+        <include refid="cmSvipProductJoins"/>
+        WHERE a.id = #{id}
+    </select>
+
+    <select id="findList" resultType="CmSvipProduct">
+        SELECT
+        <include refid="cmSvipProductColumns"/>
+        FROM cm_svip_product a
+        <include refid="cmSvipProductJoins"/>
+        <where>
+            <if test="productId != null and productId != ''">
+                AND a.productId = #{productId}
+            </if>
+            <if test="productName != null and productId != ''">
+                AND p.name like concat('%',#{productName},'%')
+            </if>
+            <if test="shopName != null and productId != ''">
+                AND s.name like concat('%',#{shopName},'%')
+            </if>
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                order by -sort desc,addTime desc
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findAllList" resultType="CmSvipProduct">
+        SELECT
+        <include refid="cmSvipProductColumns"/>
+        FROM cm_svip_product a
+        <include refid="cmSvipProductJoins"/>
+        <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="findSvipProductIds" resultType="java.lang.Integer">
+        select productId
+        from cm_svip_product;
+    </select>
+    <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
+        SELECT
+        a.*,s.name AS "shopName"
+        FROM product a
+        LEFT JOIN shop s on s.shopID = a.shopID
+        <where>
+            <if test="productID != null">
+                AND a.productID = #{productID}
+            </if>
+            <if test="name != null and name != ''">
+                AND a.name LIKE
+                <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
+                <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
+                <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name LIKE
+                <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
+                <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
+                <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
+            </if>
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                order by a.productID
+            </otherwise>
+        </choose>
+    </select>
+
+    <insert id="insert" parameterType="CmSvipProduct" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO cm_svip_product(productId,
+                                    priceType,
+                                    discount,
+                                    discountPrice,
+                                    sort,
+                                    addTime)
+        VALUES (#{productId},
+                #{priceType},
+                #{discount},
+                #{discountPrice},
+                #{sort},
+                now())
+    </insert>
+
+    <update id="update">
+        UPDATE cm_svip_product
+        SET priceType     = #{priceType},
+            discount      = #{discount},
+            discountPrice = #{discountPrice},
+            sort          = #{sort}
+        WHERE id = #{id}
+    </update>
+	<update id="saveSort">
+		UPDATE cm_svip_product SET
+			sort = #{sort}
+		WHERE id = #{id}
+	</update>
+
+	<delete id="delete">
+        DELETE
+        FROM cm_svip_product
+        WHERE id = #{id}
+    </delete>
+
+</mapper>

+ 143 - 0
src/main/webapp/WEB-INF/views/modules/svip/cmSvipProductForm.jsp

@@ -0,0 +1,143 @@
+<%@ 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>
+		.showLabel{
+			margin-top:3px
+		}
+	</style>
+	<script type="text/javascript">
+		$(document).ready(function() {
+			//$("#name").focus();
+			$("#inputForm").validate({
+				submitHandler: function(form){
+					loading('正在提交,请稍等...');
+					form.submit();
+				},
+				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>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li><a href="${ctx}/svip/cmSvipProduct/">商品列表</a></li>
+		<li class="active"><a href="${ctx}/svip/cmSvipProduct/form?id=${cmSvipProduct.id}">商品<shiro:hasPermission name="svip:cmSvipProduct:edit">${not empty cmSvipProduct.id?'编辑':'添加'}</shiro:hasPermission><shiro:lacksPermission name="svip:cmSvipProduct:edit">查看</shiro:lacksPermission></a></li>
+	</ul><br/>
+	<form:form id="inputForm" modelAttribute="cmSvipProduct" action="${ctx}/svip/cmSvipProduct/save" method="post" class="form-horizontal">
+		<form:hidden path="id"/>
+		<sys:message content="${message}"/>
+		<div class="control-group">
+			<label class="control-label">商品ID:</label>
+			<div class="controls">
+				<label class="showLabel">${cmSvipProduct.productId}</label>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label">商品名称:</label>
+			<div class="controls">
+				<label class="showLabel">${cmSvipProduct.productName}</label>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label">供应商:</label>
+			<div class="controls">
+				<label class="showLabel">${cmSvipProduct.shopName}</label>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label">机构价:</label>
+			<div class="controls">
+				<label class="showLabel">¥${cmSvipProduct.price}</label>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label">是否含税:</label>
+			<div class="controls">
+				<label class="showLabel">${cmSvipProduct.includedTax == '1'?'含税':(cmSvipProduct.includedTax == '0'?'不含税':'未知')}
+                        ${cmSvipProduct.includedTax == '2'?'':(cmSvipProduct.invoiceType == '1'?'-开增值税专用发票':'-开增值税普通发票')}</label>
+			</div>
+		</div>
+		<div class="control-group" style="display: ${cmSvipProduct.includedTax == '2'?'none':''}">
+			<label class="control-label">机构税率:</label>
+			<div class="controls">
+                <label class="showLabel">${cmSvipProduct.taxPoint}%</label>
+            </div>
+		</div>
+		<div class="control-group" style="display: ${cmSvipProduct.includedTax == '2'?'none':''}">
+			<label class="control-label">供应商税率:</label>
+			<div class="controls">
+                <label class="showLabel">${cmSvipProduct.supplierTaxPoint}%</label>
+            </div>
+		</div>
+		<div class="control-group">
+			<label class="control-label">成本:</label>
+			<div class="controls">
+                <label class="showLabel">${cmSvipProduct.costCheckFlag eq '1'?'固定成本':'比例成本'}</label>
+            </div>
+		</div>
+		<div class="control-group" style="display: ${cmSvipProduct.costCheckFlag eq '1'?'none':''}">
+			<div class="controls">
+                <label class="showLabel">${cmSvipProduct.costProportional}%</label>
+            </div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>会员价:</label>
+			<div class="controls">
+                <form:radiobutton path="priceType" onchange="changePriceType(1)" value="1" label="折扣价"/>
+                <form:radiobutton path="priceType" onchange="changePriceType(2)" value="2" label="直接优惠价"/>
+			</div>
+		</div>
+		<div class="control-group discountInput" hidden>
+			<div class="controls">
+				<form:input path="discount" htmlEscape="false" class="input-medium required"/> %
+			</div>
+		</div>
+		<div class="control-group discountPriceInput" hidden>
+			<div class="controls">
+				<form:input path="discountPrice" htmlEscape="false" class="input-medium required"/>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>排序值:</label>
+			<div class="controls">
+				<form:input path="sort" htmlEscape="false" class="input-xlarge required"/>
+			</div>
+		</div>
+		<div class="form-actions">
+			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
+			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+		</div>
+	</form:form>
+<script>
+	$(function () {
+		var priceType = ${cmSvipProduct.priceType}
+		if (priceType == 1) {
+			$(".discountInput").show();
+		} else {
+			$(".discountPriceInput").show();
+		}
+	})
+	function changePriceType(priceType) {
+		if (priceType == 1) {
+			$(".discountInput").show();
+			$(".discountPriceInput").hide();
+		} else {
+			$(".discountInput").hide();
+			$(".discountPriceInput").show();
+		}
+	}
+</script>
+</body>
+</html>

+ 184 - 0
src/main/webapp/WEB-INF/views/modules/svip/cmSvipProductList.jsp

@@ -0,0 +1,184 @@
+<%@ 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 changeSort(id, sortThis) {
+			var value = sortThis.value;
+			$("#svipProduct" + id).val(id + "-" + value);
+		}
+	</script>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li class="active"><a href="${ctx}/svip/cmSvipProduct/">商品列表</a></li>
+<%--		<shiro:hasPermission name="svip:cmSvipProduct:edit"><li><a href="${ctx}/svip/cmSvipProduct/form">商品添加</a></li></shiro:hasPermission>--%>
+	</ul>
+	<form:form id="searchForm" modelAttribute="cmSvipProduct" action="${ctx}/svip/cmSvipProduct/" 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}"/>
+		<div class="ul-form">
+			 <label>商品ID:</label>
+				<form:input path="productId" htmlEscape="false" class="input-medium"/>
+			 <label>商品名称:</label>
+				<form:input path="productName" 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="查询"/>
+			&nbsp;&nbsp;<input class="btn btn-primary" style="width: 60px" onclick="batchSaveSort()" value="批量排序"/>
+			&nbsp;&nbsp;<input class="btn btn-primary" style="width: 50px" 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>商品id</th>
+				<th>商品图片</th>
+				<th>商品名称</th>
+				<th>商品供应商</th>
+				<th>机构价</th>
+				<th>会员折扣</th>
+				<th>会员价</th>
+				<th>排序值</th>
+				<th>添加时间</th>
+				<th>操作</th>
+			</tr>
+		</thead>
+		<tbody>
+		<c:forEach items="${page.list}" var="cmSvipProduct">
+			<tr>
+				<input class="check-item" type="hidden" id="svipProduct${cmSvipProduct.id}"
+					   value='${cmSvipProduct.id}-${cmSvipProduct.sort}'/>
+				<td>
+					${cmSvipProduct.productId}
+				</td>
+				<td>
+					<img src="${cmSvipProduct.productImage}" style="width:80px">
+				</td>
+				<td>
+					${cmSvipProduct.productName}
+				</td>
+				<td>
+					${cmSvipProduct.shopName}
+				</td>
+				<td>
+					${cmSvipProduct.price}
+				</td>
+				<td>
+					${cmSvipProduct.priceType eq 1? cmSvipProduct.discount:'---'}${cmSvipProduct.priceType eq 1? '%':''}
+				</td>
+				<td>
+					¥<fmt:formatNumber value="${cmSvipProduct.priceType eq 2?cmSvipProduct.discountPrice:cmSvipProduct.price * cmSvipProduct.discount * 0.01}" pattern="#0.00" />
+				</td>
+				<td>
+					<input id="sort" name="sort" style="width:50px;" value="${cmSvipProduct.sort}" onkeyup="onlynum(this)"
+						   onchange="changeSort(${cmSvipProduct.id},this)">
+				</td>
+				<td>
+					<fmt:formatDate value="${cmSvipProduct.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+    				<a href="${ctx}/svip/cmSvipProduct/form?id=${cmSvipProduct.id}">编辑</a>
+					<a href="${ctx}/svip/cmSvipProduct/delete?id=${cmSvipProduct.id}" onclick="return confirmx('确认要删除该商品吗?', this.href)">删除</a>
+				</td>
+			</tr>
+		</c:forEach>
+		</tbody>
+	</table>
+	<div class="pagination">${page}</div>
+<script>
+	//批量保存排序
+	function batchSaveSort() {
+		var items = new Array();
+		var $items = $('.check-item');
+		$items.each(function(){
+			items.push($(this).val());
+		});
+		//保存批量排序
+		$.post("${ctx}/svip/cmSvipProduct/batchSaveSort?sortList="+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() {
+		//刷新页面
+		$("#searchForm").submit();
+	}
+
+	//选择添加
+	function showSelect() {
+		var url = '';
+		var title = '';
+		url = "${ctx}/svip/cmSvipProduct/findProductPage";
+		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()) {
+				    debugger
+					var items = $jboxFrame[0].contentWindow.getCheckedItems();
+                    if (items == -1) {
+                        top.$.jBox.tip("请填写折扣和会员价(二选一)", 'error');
+                        return false;
+                    }
+					if (items.length > 0) {
+						console.log(items);
+						//添加数据
+						for (var i = 0; i < items.length; i++) {
+							var item = items[i];
+							$.post("${ctx}/svip/cmSvipProduct/save?productId=" + item.productId + "&discount=" + item.discount + "&discountPrice=" + item.discountPrice);
+						}
+					} else {
+						top.$.jBox.tip("请先勾选商品...");
+						return false;
+					}
+					$.jBox.tip('添加商品成功', 'info');
+					setInterval(g,1000);
+				}
+				return true;
+			}
+		});
+	}
+</script>
+</body>
+</html>

+ 175 - 0
src/main/webapp/WEB-INF/views/modules/svip/svipAddProduct.jsp

@@ -0,0 +1,175 @@
+<%@ 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;
+        }
+
+        .discount{
+            display: inline;
+        }
+    </style>
+
+    <script type="text/javascript">
+        $(document).ready(function () {
+            $("#searchForm").validate({
+                submitHandler: function (form) {
+                    var isSubMitFlag = true;
+                    var productID = $("#productID").val();
+                    if (isNaN(productID) || productID.indexOf('0') == 0 ) {
+                        alertx("请输入正确的商品ID");
+                        isSubMitFlag = false;
+                        return false;
+                    }
+                    if (isSubMitFlag) {
+                        form.submit();
+                    }
+                }
+            })
+        });
+    </script>
+</head>
+<body>
+<form:form id="searchForm" modelAttribute="product" action="${ctx}/svip/cmSvipProduct/findProductPage" 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}"/>
+    <form:hidden path="ids"/>
+    <div class="ul-form">
+        <label>商品ID:</label>
+        <form:input path="productID" id="productID" htmlEscape="false" maxlength="8" class="input-mini" onkeyup="onlynum(this)"/>
+        <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="clickAllSelect(this)"/> 全选</th>
+        <th>商品ID</th>
+        <th>商品图片</th>
+        <th>商品名称</th>
+        <th>供应商</th>
+        <th>机构价</th>
+        <th style="width: 140px !important;">会员折扣</th>
+        <th style="width: 140px !important;">会员价</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" ${item.existsFlag eq 1?'disabled':''} value='${item.productID}'/>
+                </th>
+                <td>${item.productID}</td>
+                <td><img class="mainImage" src="${item.mainImage}" width="50px" height="50px"></td>
+                <td class="productName">${item.name}</td>
+                <td>${item.shopName}</td>
+                <td>¥${item.price1}</td>
+                <td><input class="discount" id="discount${item.productID}" onchange="changeDiscount(${item.productID},1)" type="number" maxlength="11" style="width: 100px"> %</td>
+                <td><input class="discountPrice" id="discountPrice${item.productID}" onchange="changeDiscount(${item.productID},2)" type="number" maxlength="11" style="width: 100px"></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>
+<script type="text/javascript">
+    $(document).ready(function () {
+        //弹出框去滚动条
+        top.$('#jbox-content').css("overflow-y", "hidden");
+        show_title(30);
+    });
+
+    function page(n, s) {
+        $("#pageNo").val(n);
+        $("#pageSize").val(s);
+        $("#searchForm").submit();
+        return false;
+    }
+
+    function getCheckedItems() {
+        debugger
+        var items = new Array();
+        var $items = $('.check-item:checked');
+        var error = 0;
+        $items.each(function () {
+            let discount = $(this).parents(".itemtr").find(".discount").val();
+            let discountPrice = $(this).parents(".itemtr").find(".discountPrice").val();
+            if (discount == '' && discountPrice == '') {
+                error = -1;
+            }
+            items.push({
+                productId: $(this).val(),
+                discount: discount,
+                discountPrice: discountPrice
+            });
+        });
+        return error == -1 ? error : items;
+    }
+
+    function clickAllSelect(ckb) {
+        var isChecked = ckb.checked;
+        var $items = $('.check-item');
+        $items.each(function(){
+            var disabled = $(this).attr('disabled');
+            if (disabled != 'disabled') {
+                $(this).attr('checked', isChecked)
+            }
+        });
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+
+    /**
+     * 更改折扣/折扣价
+     */
+    function changeDiscount(productId,priceType) {
+        debugger
+        if (priceType == 1) {
+            var val = $("#discount" + productId).val();
+            if (val > 100 || val <0) {
+                $.jBox.tip("请输入0-100之间的数字", 'info');
+                val = '';
+                $("#discount" + productId).val('');
+            }else {
+                val = Number(val).toFixed(2);
+                $("#discount" + productId).val(val);
+            }
+            if (val != '' && val != undefined) {
+                $("#discountPrice"+productId).attr('readonly', 'readonly');
+            } else {
+                $("#discountPrice"+productId).removeAttr('readonly');
+            }
+        } else {
+            var val = $("#discountPrice" + productId).val();
+            if (val != '' && val != undefined) {
+                val = Number(val).toFixed(2);
+                $("#discountPrice" + productId).val(val);
+                $("#discount"+productId).attr('readonly', 'readonly');
+            } else {
+                $("#discount" + productId).removeAttr('readonly');
+            }
+        }
+    }
+</script>
+</body>
+</html>
+