营销系统--优惠券补偿记录
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了营销系统--优惠券补偿记录相关的知识,希望对你有一定的参考价值。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="ctx" value="${pageContext.request.contextPath}" /> <jsp:include page="/jsp/common/header.jsp"></jsp:include> <script src="${ctx }/js/promote/compensatingLog.js"></script> <table class="queryTable"> <tr> <td class="queryTitle" width="80px">操作人</td> <td class="queryContent" ><input class="inputText" type="text" id="userName" /></td> <td class="queryTitle" width="80px">补偿时间</td> <td class="queryContent" > <input class="inputText easyui-datebox" type="text" id="editTimeBg" style="width: 100px" editable="false" /> 到 <input class="inputText easyui-datebox" type="text" id="editTimeEd" style="width: 100px" editable="false" /> </td> <td class="queryTitle" width="80px">补偿会员</td> <td class="queryContent" ><input class="inputText" type="text" id="loginName" /></td> </tr> <tr> <td class="queryTitle" width="80px">补偿理由</td> <td class="queryContent" ><input class="inputText" type="text" id="giveExcuse" /></td> <td class="queryTitle" width="80px">补偿形式</td> <td class="queryContent" > <select id="compensatingForm" style="width: 100px" panelHeight="auto" onchange="couponOrIntegralShow(this)"> <option value>请选择</option> <option value="coupon">优惠券</option> <option value="integral">积分</option> </select> <label id="type" > <input class="inputText" type="text" id="compensatingContent" /></label> </td> <td class="queryBtnTd" colspan="2"><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="doQuery()">查 询</a></td> </tr> </table> <table id="deliveryGrid"></table>
$(function(){ $("#opreateHtml").window("close"); $("#compensatingContent").combobox({ url:appPath+"/page/compensationtypeAct/ecCouponTypeSelect", valueField:"id", textField:"text", panelHeight:"auto", editable:false }); $("#type").hide(); $("#deliveryGrid").datagrid({ url:appPath+"/page/compensatingLogAct/getPage", height:"full", striped:true, remoteSort:false, pagination:true, rownumbers:true, singleSelect:false, queryParams:getQueryParam(), columns:[[ {field:‘addTime‘,title:‘补偿时间‘,width:130,align:‘center‘,sortable:true}, {field:‘userName‘,title:‘操作人‘,width:100,align:‘center‘,sortable:true}, {field:‘loginName‘,title:‘补偿会员‘,width:100,align:‘center‘,sortable:true}, {field:‘giveExcuse‘,title:‘补偿理由‘,width:100,align:‘center‘,sortable:true}, {field:‘compensatingForm‘,title:‘补偿形式‘,width:100,align:‘center‘,sortable:true, formatter:function(value){ if(value=="coupon"){ return "优惠券"; }else if(value=="integral"){ return "积分"; }else{ return value; } } }, {field:‘compensatingContent‘,title:‘补偿内容‘,width:100,align:‘center‘,sortable:true} ]], }); }); function getQueryParam(){ var compensatingLog =new Object(); compensatingLog.userName=$.trim($("#userName").val()); compensatingLog.editTimeBg=$.trim($("#editTimeBg").datebox(‘getValue‘)); compensatingLog.editTimeEd=$.trim($("#editTimeEd").datebox(‘getValue‘)); compensatingLog.loginName=$.trim($("#loginName").val()); compensatingLog.giveExcuse=$.trim($("#giveExcuse").val()); compensatingLog.compensatingForm=$.trim($("#compensatingForm").val()); if($.trim($("#compensatingForm").val())=="coupon"){ compensatingLog.compensatingContent=$.trim($("#compensatingContent").combobox(‘getValue‘)); } return compensatingLog; } function doQuery(){ $("#deliveryGrid").datagrid(‘load‘,getQueryParam()); } function couponOrIntegralShow(o){ if(o.value==‘coupon‘){ $("#type").show(); }else{ $("#type").hide(); } }
package com.founder.ec.promote.action; import java.util.*; import javax.servlet.http.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.founder.ec.base.action.BaseClassAction; import com.founder.ec.common.utils.StringUtil; import com.founder.ec.promote.model.Compensationtype; import com.founder.ec.promote.model.EcCouponType; import com.founder.ec.promote.service.CompensationtypeService; import com.founder.ec.promote.service.EcCouponTypeService; import com.j1.base.dto.ServiceMessage; import com.j1.base.type.MsgStatus; import com.j1.member.mysql.model.MemberRoleRepModel; /** * * @author liuyuandi 2015年9月15日 下午1:21:11 * @since 1.0.0 */ @Controller @RequestMapping(value="/compensationtypeAct") public class CompensationtypeAction extends BaseClassAction<Compensationtype>{ @Autowired private CompensationtypeService compensationtypeService; /** *@description 查询补偿列表 */ @RequestMapping(value="/getPage") @ResponseBody public Map<String,Object> getPage(HttpServletRequest request,Compensationtype compensationtype) { int pageSize=10,pageNo=1; pageNo = Integer.parseInt(request.getParameter("page")); pageSize= Integer.parseInt(request.getParameter("rows")); return compensationtypeService.getPage(compensationtype, pageNo, pageSize); } /** *@description 查询单个补偿对象 */ @RequestMapping(value="/getBean/{getId}") public void getBean(HttpServletRequest request,HttpServletResponse response,@PathVariable Object getId) { if(getId!=null && getId.toString().length()>0){ Compensationtype compensationtype=new Compensationtype(); compensationtype.setId(Long.parseLong(getId.toString())); compensationtype=compensationtypeService.getT(compensationtype); super.writeClient(response, super.ObjectChangJSONObject(compensationtype).toString(), "");} } /** *@description添加或是更新 */ @RequestMapping(value="/saveOrUpdate") public void updateOrSave(HttpServletRequest request,HttpServletResponse response,Compensationtype compensationtype) { String userId=request.getSession().getAttribute("userId").toString(); if(compensationtype.getId()!=null) { compensationtype.setEditTime(StringUtil.returnDateFormat(new Date(),"yyyy-MM-dd HH:mm:ss")); compensationtype.setEditUserId(Integer.parseInt(userId)); compensationtypeService.update(compensationtype); } else { super.bindingProperty(compensationtype, userId); compensationtypeService.save(compensationtype); } } /** *@description删除补偿数据 */ @RequestMapping(value="/deleteIdsLogic") public void deleteIdsLogic(HttpServletRequest request,HttpServletResponse response) { String userId=request.getSession().getAttribute("userId").toString(); String ids=null; if(request.getParameter("ids")!=null) { ids=request.getParameter("ids").trim(); if(ids.indexOf(",")>0) { String[] idArr=ids.split(","); for(int i=0;i<idArr.length;i++) { Compensationtype bean=new Compensationtype(); bean.setId(Long.parseLong(idArr[i])); bean.setIsDelete("Y"); bean.setEditTime(StringUtil.returnDateFormat(new Date(),"yyyy-MM-dd HH:mm:ss")); bean.setEditUserId(Integer.parseInt(userId)); compensationtypeService.update(bean); } } } } /** * @author liuyuandi 2015-6-26 14:36:10 * @param request * @param Response * @return */ @RequestMapping("/ecCouponTypeSelect") @ResponseBody public List<Object> ecCouponTypeSelect(HttpServletRequest request,HttpServletResponse Response){ List<Object> linkageRes =new ArrayList<Object>(); HashMap<String,Object> param = new HashMap<String, Object>(); param.put("useType","3"); List<EcCouponType> typeList = compensationtypeService.queryCouponTypeByIdList(param); Map<String,Object> defaultValue = new HashMap<String,Object>(); defaultValue.put("id", ""); defaultValue.put("text", "请选择优惠券类型"); defaultValue.put("selected", true); linkageRes.add(defaultValue); if(typeList.size()>0){ List<EcCouponType> typeList1 =typeList; if(null!=typeList && !typeList.isEmpty()){ for(EcCouponType nt : typeList1){ Map<String,Object> typeMap = new HashMap<String,Object>(); typeMap.put("id", nt.getCouponTypeId()); typeMap.put("text", nt.getCouponTypeName()); typeMap.put("attributes", nt); linkageRes.add(typeMap); } } } return linkageRes; } }
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" > <sqlMap namespace="Compensationtype"> <typeAlias alias="Compensationtype" type="com.founder.ec.promote.model.Compensationtype"/> <resultMap id="CompensationtypeMap" class="Compensationtype"> <result column="ID" property="id" /> <result column="GIVE_EXCUSE" property="giveExcuse" /> <result column="COMPENSATING_FORM" property="compensatingForm" /> <result column="COMPENSATING_CONTENT" property="compensatingContent" /> <result column="STANDBY2" property="standby2" /> <result column="STANDBY1" property="standby1" /> <result column="ADD_USER_ID" property="addUserId" /> <result column="ADD_TIME" property="addTime" /> <result column="EDIT_USER_ID" property="editUserId" /> <result column="EDIT_TIME" property="editTime" /> <result column="IS_DELETE" property="isDelete" /> </resultMap> <sql id="be_fy"> select * from (select row_.*, rownum rownum_ from ( </sql> <sql id="ed_fy"> ) row_ where 1=1 <isNotEmpty prepend="and" property="endRow"> <![CDATA[ rownum <= #endRow# ]]> </isNotEmpty> )where 1=1 <isNotEmpty prepend="and" property="startRow"> <![CDATA[ rownum_ >= #startRow# ]]> </isNotEmpty> </sql> <select id="getCompensationtypePage" resultMap="CompensationtypeMap" parameterClass="Compensationtype"> <include refid="be_fy"/> select cc.id, cc.give_excuse, cc.compensating_form, (case when cc.compensating_form=‘coupon‘ then (select pe.coupon_type_name from ec_coupon_type pe where pe.coupon_type_id=cc.compensating_content and pe.is_delete=‘N‘) else cc.compensating_content end) compensating_content, cc.standby1, cc.standby2, cc.is_delete, cc.add_time, cc.add_user_id, cc.edit_time, cc.edit_user_id from compensationType cc where cc.IS_DELETE=‘N‘ <isNotEmpty prepend="and" property="giveExcuse"> <![CDATA[ cc.GIVE_EXCUSE like ‘%$giveExcuse$%‘ ]]> </isNotEmpty> <isNotEmpty prepend="and" property="compensatingForm"> <![CDATA[ cc.COMPENSATING_FORM =#compensatingForm# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="compensatingContent"> <![CDATA[ cc.COMPENSATING_CONTENT=#compensatingContent# ]]> </isNotEmpty> order by cc.id desc <include refid="ed_fy"/> </select> <select id="getCompensationtypeCount" resultClass="Integer" parameterClass="Compensationtype"> select count(cc.id) from compensationType cc where cc.IS_DELETE=‘N‘ <isNotEmpty prepend="and" property="giveExcuse"> <![CDATA[ cc.GIVE_EXCUSE like ‘%$giveExcuse$%‘ ]]> </isNotEmpty> <isNotEmpty prepend="and" property="compensatingForm"> <![CDATA[ cc.COMPENSATING_FORM =#compensatingForm# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="compensatingContent"> <![CDATA[ cc.COMPENSATING_CONTENT=#compensatingContent# ]]> </isNotEmpty> </select> <insert id="save" parameterClass="Compensationtype"> <selectKey resultClass="Long" keyProperty="id" > SELECT compensationType_SEQ.nextval AS id from dual </selectKey> insert into compensationType ( EDIT_USER_ID,GIVE_EXCUSE,COMPENSATING_CONTENT,STANDBY2,STANDBY1,ADD_USER_ID,EDIT_TIME,ID,IS_DELETE,ADD_TIME,COMPENSATING_FORM) values ( #editUserId#,#giveExcuse#,#compensatingContent#,#standby2#,#standby1#,#addUserId#,#editTime#,#id#,#isDelete#,#addTime#,#compensatingForm#) </insert> <update id="update" parameterClass="Compensationtype"> update compensationType <dynamic prepend="set"> <isNotEmpty prepend="," property="editUserId"> <![CDATA[ EDIT_USER_ID=#editUserId# ]]> </isNotEmpty> <isNotEmpty prepend="," property="giveExcuse"> <![CDATA[ GIVE_EXCUSE=#giveExcuse# ]]> </isNotEmpty> <isNotEmpty prepend="," property="compensatingContent"> <![CDATA[ COMPENSATING_CONTENT=#compensatingContent# ]]> </isNotEmpty> <isNotEmpty prepend="," property="standby2"> <![CDATA[ STANDBY2=#standby2# ]]> </isNotEmpty> <isNotEmpty prepend="," property="standby1"> <![CDATA[ STANDBY1=#standby1# ]]> </isNotEmpty> <isNotEmpty prepend="," property="addUserId"> <![CDATA[ ADD_USER_ID=#addUserId# ]]> </isNotEmpty> <isNotEmpty prepend="," property="editTime"> <![CDATA[ EDIT_TIME=#editTime# ]]> </isNotEmpty> <isNotEmpty prepend="," property="isDelete"> <![CDATA[ IS_DELETE=#isDelete# ]]> </isNotEmpty> <isNotEmpty prepend="," property="addTime"> <![CDATA[ ADD_TIME=#addTime# ]]> </isNotEmpty> <isNotEmpty prepend="," property="compensatingForm"> <![CDATA[ COMPENSATING_FORM=#compensatingForm# ]]> </isNotEmpty> </dynamic> where ID=#id# </update> <select id="getCompensationtype" parameterClass="Compensationtype" resultMap="CompensationtypeMap"> select id, give_excuse, compensating_form, compensating_content, standby1, standby2, is_delete, add_time, add_user_id, edit_time, edit_user_id from compensationType where ID=#id# </select> <select id="getSimilarCompensationtype" parameterClass="Compensationtype" resultMap="CompensationtypeMap"> select id, give_excuse, compensating_form, compensating_content, standby1, standby2, is_delete, add_time, add_user_id, edit_time, edit_user_id from compensationType where is_delete=‘N‘ <isNotEmpty prepend="and" property="giveExcuse"> <![CDATA[ cc.GIVE_EXCUSE like ‘%$giveExcuse$%‘ ]]> </isNotEmpty> <isNotEmpty prepend="and" property="compensatingForm"> <![CDATA[ cc.COMPENSATING_FORM =#compensatingForm# ]]> </isNotEmpty> <isNotEmpty prepend="and" property="compensatingContent"> <![CDATA[ cc.COMPENSATING_CONTENT=#compensatingContent# ]]> </isNotEmpty> </select> </sqlMap>
===============================知识点分析===============================================
主要知识点在查询条件中的补偿形式,
如果我选择的是"请选择"或者是"积分",后面没有联动,当我选择的是优惠券,后面会有个下拉框的列表.这是怎么实现的呢?
其实说白了就是一个二级联动,有某个主键进行关联查询.
先来看如何展示与隐藏的.
<td class="queryTitle" width="80px">补偿形式</td> <td class="queryContent" > <select id="compensatingForm" style="width: 100px" panelHeight="auto" onchange="couponOrIntegralShow(this)"> <option value>请选择</option> <option value="coupon">优惠券</option> <option value="integral">积分</option> </select> <label id="type" > <input class="inputText" type="text" id="compensatingContent" /></label> </td> <td class="queryBtnTd" colspan="2"><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="doQuery()">查 询</a></td> </tr> </table>
有一个
onchange="couponOrIntegralShow(this)",接着看对应的js:
function couponOrIntegralShow(o){
if(o.value==‘coupon‘){
$("#type").show();
}else{
$("#type").hide();
}
}
这样就可以看出展示,隐藏了.
那又是怎么进行联动的呢?
<label id="type" > <input class="inputText" type="text" id="compensatingContent" /></label> <!--看这个label标签的id --> $("#compensatingContent").combobox({ url:appPath+"/page/compensationtypeAct/ecCouponTypeSelect", valueField:"id", textField:"text", panelHeight:"auto", editable:false }); <!-- 这个id,去后台查询了,展示这些列表 -->
@RequestMapping("/ecCouponTypeSelect") @ResponseBody public List<Object> ecCouponTypeSelect(HttpServletRequest request,HttpServletResponse Response){ List<Object> linkageRes =new ArrayList<Object>(); HashMap<String,Object> param = new HashMap<String, Object>(); param.put("useType","3"); List<EcCouponType> typeList = compensationtypeService.queryCouponTypeByIdList(param); Map<String,Object> defaultValue = new HashMap<String,Object>(); defaultValue.put("id", "");
defaultValue.put("text", "请选择优惠券类型"); defaultValue.put("selected", true); linkageRes.add(defaultValue); if(typeList.size()>0){ List<EcCouponType> typeList1 =typeList; if(null!=typeList && !typeList.isEmpty()){ for(EcCouponType nt : typeList1){ Map<String,Object> typeMap = new HashMap<String,Object>(); typeMap.put("id", nt.getCouponTypeId()); typeMap.put("text", nt.getCouponTypeName()); typeMap.put("attributes", nt); linkageRes.add(typeMap); } } } return linkageRes; }
<!-- 根据ID查询优惠券类型,或是根据券的类型去查找优惠券 --> <select id="getCouponTypeById" parameterClass="java.util.Map" resultMap="ecCouponTypeResult"> select <include refid="Base_sql"/> from EC_COUPON_TYPE r where r.is_delete=‘N‘ <isNotEmpty prepend="and" property="couponTypeId"> r.COUPON_TYPE_ID = #couponTypeId# </isNotEmpty> <isNotEmpty prepend="and" property="couponTypeName"> r.COUPON_TYPE_NAME like ‘%$couponTypeName$%‘ </isNotEmpty> <isNotEmpty prepend="and" property="couponFee"> r.COUPON_FEE = #couponFee# </isNotEmpty> <isNotEmpty prepend="and" property="useType"> r.USE_TYPE = #useType# </isNotEmpty> </select>
注意一下查询条件取值:
function getQueryParam(){ var compensatingLog =new Object(); compensatingLog.userName=$.trim($("#userName").val()); compensatingLog.editTimeBg=$.trim($("#editTimeBg").datebox(‘getValue‘)); compensatingLog.editTimeEd=$.trim($("#editTimeEd").datebox(‘getValue‘)); compensatingLog.loginName=$.trim($("#loginName").val()); compensatingLog.giveExcuse=$.trim($("#giveExcuse").val()); compensatingLog.compensatingForm=$.trim($("#compensatingForm").val()); if($.trim($("#compensatingForm").val())=="coupon"){ compensatingLog.compensatingContent=$.trim($("#compensatingContent").combobox(‘getValue‘)); } return compensatingLog; }
以上是关于营销系统--优惠券补偿记录的主要内容,如果未能解决你的问题,请参考以下文章