Authored by chenjian

Merge branch 'dev_available_channel' into test6.8.4

... ... @@ -4,21 +4,21 @@
module.exports = function (app) {
/*************************************优惠券管理--庞洁*************************************/
//列表页
app.get("/market/couponList/index", "marketing.CouponList.Index",function(){
this.$extend={
moduleName:'营销管理',
pageName:'优惠券管理',
app.get("/market/couponList/index", "marketing.CouponList.Index", function () {
this.$extend = {
moduleName: '营销管理',
pageName: '优惠券管理',
}
});
//优惠券列表
app.post("/coupon/queryCouponList", "CouponList_queryCouponList");
//添加页
app.get("/market/couponList/add", "marketing.CouponList.AddOrUpdate",function(){
this.$extend={
moduleName:'营销管理',
pageName:'新增优惠券',
//添加页
app.get("/market/couponList/add", "marketing.CouponList.AddOrUpdate", function () {
this.$extend = {
moduleName: '营销管理',
pageName: '新增优惠券',
title: "新增优惠券",
type: "add",
action: "/coupon/add"
... ... @@ -26,10 +26,10 @@ module.exports = function (app) {
});
//编辑页
app.get("/market/couponList/update/:id", "marketing.CouponList.AddOrUpdate",function(){
this.$extend={
moduleName:'营销管理',
pageName:'修改优惠券',
app.get("/market/couponList/update/:id", "marketing.CouponList.AddOrUpdate", function () {
this.$extend = {
moduleName: '营销管理',
pageName: '修改优惠券',
title: "修改优惠券",
type: "update",
action: "/coupon/update"
... ... @@ -67,10 +67,10 @@ module.exports = function (app) {
//清除指定商品
app.post("/coupon/cleanPrdLimit", "CouponList_cleanPrdLimit");
app.get("/market/department/index", "marketing.CouponList.DepartmentIndex",function(){
this.$extend={
moduleName:'营销管理',
pageName:'费用承担部门管理',
app.get("/market/department/index", "marketing.CouponList.DepartmentIndex", function () {
this.$extend = {
moduleName: '营销管理',
pageName: '费用承担部门管理',
}
});
//新增部门
... ... @@ -79,7 +79,10 @@ module.exports = function (app) {
//修改部门
app.post("/coupon/updateDepartment", "Department_update");
app.post("/coupon/queryDepartmentList","Department_list");
app.post("/coupon/queryDepartmentList", "Department_list");
app.post("/coupon/queryDepartmentById","Department_queryById");
app.post("/coupon/queryDepartmentById", "Department_queryById");
//查询券可用渠道
app.post("/coupon/queryChannelGroups", "CouponList_queryChannelGroups");
};
\ No newline at end of file
... ...
/**
*
* Created by yoho on 2016/6/21.
... ... @@ -17,14 +16,14 @@ module.exports = {
department: {type: Number},
couponName: {type: String},
status: {type: Number},
couponType:{type:Number},
feeSharingType:{type:Number},
startTimeStr: {type:String},
endTimeStr: {type:String}
couponType: {type: Number},
feeSharingType: {type: Number},
startTimeStr: {type: String},
endTimeStr: {type: String}
}
},
getCouponDetailById:{
getCouponDetailById: {
title: "单张详情",
url: "/coupon/getCouponDetailById",
params: {
... ... @@ -55,15 +54,16 @@ module.exports = {
multipleNum: {type: Number},
shopPriceLimits: {type: String},
sknExclude: {type: String},
shopLimit:{type:String},
feeSharingType:{type:Number},
feeSharingRatio:{type:Number},
productLimit:{type:String},
isNew : {type:Number},
isUseLimitRule:{type:String},
prdPoolLimit : {type:String},
cusPublicCouponName:{type:String},
publicCouponType:{type:Number}
shopLimit: {type: String},
feeSharingType: {type: Number},
feeSharingRatio: {type: Number},
productLimit: {type: String},
isNew: {type: Number},
isUseLimitRule: {type: String},
prdPoolLimit: {type: String},
cusPublicCouponName: {type: String},
publicCouponType: {type: Number},
channel: {type: String}
}
},
reject: {
... ... @@ -116,12 +116,16 @@ module.exports = {
publicNumberCode: {type: Number}
}
},
cleanPrdLimit : {
cleanPrdLimit: {
title: "清除指定商品",
url: "/coupon/cleanPrdLimit",
params: {
param : {type: Number}
param: {type: Number}
}
},
queryChannelGroups: {
title: "券可用渠道",
url: "/channel/queryChannelGroups"
}
}
};
... ...
... ... @@ -228,13 +228,13 @@
<select id="useRange" class="form-control input-form" value="[[useRange]]">
<option value="">请选择</option>
[[if couponType!=6]]
<option value="0">分类</option>
<option value="0">分类</option>
[[/if]]
[[if couponType!=6]]
<option value="2">店铺</option>
[[/if]]
[[if couponType > 0 && couponType != 6]]
<option value="3">商品</option>
<option value="3">商品</option>
[[/if]]
[[if couponType==6]]
<option value="2">店铺(SKN除外)</option>
... ... @@ -337,6 +337,63 @@
[[/if]]
</div>
</div>
<!---------------- 可用渠道配置 开始 ---------------->
<div class="panel-heading">
<h4 class="panel-title">渠道限制</h4>
</div>
<div class="panel-body">
<div class="row">
[[each couponAvailableChannels as Available_Channels i]]
<div class="form-group">
<div class="col-sm-8">
<label class="col-sm-2 control-label">可用渠道 [[i]]</label>
<!-- 渠道 -->
<div class="col-sm-2">
<label class="checkbox-inline">
<!-- 判断是否选中 -->
<input type="checkbox" class="couponAvailableChannels"
[[each channel as Available_Channels_status j]]
[[if Available_Channels_status.groupId==Available_Channels.groupId]]
checked
[[/if]]
[[/each]]
value="[[Available_Channels.groupId]]"> [[Available_Channels.groupName]]
</label>
</div>
<!-- 子门店 -->
[[if Available_Channels.storeList]]
<div class="col-sm-8">
[[each Available_Channels.storeList as Available_storeList index]]
<label class="checkbox-inline">
<!-- 判断是否选中 -->
<input type="checkbox" class="couponAvailableChannelStoreList couponAvailableChannelStoreList_[[Available_Channels.groupId]]"
[[each channel as Available_Channels_status j]]
[[if Available_Channels_status.groupId==Available_Channels.groupId]]
[[each Available_Channels_status.storeList as Available_Channels_storeList_status k]]
[[if Available_Channels_storeList_status==Available_storeList.storeId]]
checked
[[/if]]
[[/each]]
[[/if]]
[[/each]]
value="[[Available_storeList.storeId]]"> [[Available_storeList.storeName]] [[Available_Channels_storeList_status]]
</label>
[[/each]]
</div>
[[/if]]
</div>
</div>
[[/each]]
</div>
</div>
<!---------------- 可用渠道配置 结束 ---------------->
<div>
</div>
... ... @@ -557,7 +614,7 @@
</div>
</script>
<script type="text/template" id="template_prdPoolLimit">
<script type="text/template" id="template_prdPoolLimit">
<div class="panel">
<div class="panel-body nopadding">
... ... @@ -571,7 +628,7 @@
<option value="[[id||-1]]">[[text||"选择商品池"]]</option>
</select>
</div>
</div>
</div>
</div>
... ...
... ... @@ -277,6 +277,64 @@
[[/if]]
</div>
</div>
<!-------------- 使用渠道 start -------------->
<div class="panel-heading">
<h4 class="panel-title">渠道限制</h4>
</div>
<div class="panel-body">
<div class="row">
[[each couponAvailableChannels as Available_Channels i]]
<div class="form-group">
<div class="col-sm-8">
<label class="col-sm-2 control-label">可用渠道 [[i]]</label>
<!-- 渠道 -->
<div class="col-sm-2">
<label class="checkbox-inline">
<!-- 判断是否选中 -->
<input type="checkbox" class="couponAvailableChannels" disabled
[[each channel as Available_Channels_status j]]
[[if Available_Channels_status.groupId==Available_Channels.groupId]]
checked
[[/if]]
[[/each]]
value="[[Available_Channels.groupId]]"> [[Available_Channels.groupName]]
</label>
</div>
<!-- 子门店 -->
[[if Available_Channels.storeList]]
<div class="col-sm-8">
[[each Available_Channels.storeList as Available_storeList index]]
<label class="checkbox-inline">
<!-- 判断是否选中 -->
<input type="checkbox" class="couponAvailableChannelStoreList couponAvailableChannelStoreList_[[Available_Channels.groupId]]" disabled
[[each channel as Available_Channels_status j]]
[[if Available_Channels_status.groupId==Available_Channels.groupId]]
[[each Available_Channels_status.storeList as Available_Channels_storeList_status k]]
[[if Available_Channels_storeList_status==Available_storeList.storeId]]
checked
[[/if]]
[[/each]]
[[/if]]
[[/each]]
value="[[Available_storeList.storeId]]"> [[Available_storeList.storeName]] [[Available_Channels_storeList_status]]
</label>
[[/each]]
</div>
[[/if]]
</div>
</div>
[[/each]]
</div>
</div>
<!-------------- 使用渠道 end -------------->
<div class="panel-heading">
<h4 class="panel-title">领券条件</h4>
</div>
... ... @@ -361,7 +419,7 @@
</select>
</div>
</div>
<div class="form-group">
<div class="form-group">/couponList/index
<label class="col-sm-2 control-label">第三方 ID</label>
<div class="col-sm-8">
<input id="thirdId" class="form-control panel-input" value="{{thirdId}}" {{if thirdType == 1}}readonly{{/if}} type="text" placeholder="第三方 ID">
... ...
... ... @@ -11,8 +11,8 @@ var startTimeObj;
var endTimeObj;
var customType = [];
var shopPriceLimits=[];
var isNew ;
var shopPriceLimits = [];
var isNew;
var publicCouponType;
/**
* 监听输入值的变化
... ... @@ -30,10 +30,10 @@ $(document).on("change", ".observe", function () {
var Bll = {
Brands: [],//品牌数据
selectSorts: [],//分类数据
selectShops:[],//店铺数据
selectShopIds:[],
selectShops: [],//店铺数据
selectShopIds: [],
selectBrandsName: [],
selectPrdPool:{},
selectPrdPool: {},
getBrands: function () {//获取品牌数据
var Brand = {};
$.get("/ajax/yohosearch", function (res) {
... ... @@ -80,7 +80,7 @@ var Bll = {
e.init();
$("#limitStartTime").datetimepicker({
timeFormat: 'HH:mm:ss',
showSecond: true
showSecond: true
}).data("datepicker");
// startTimeObj = $("#startTime").datetimepicker({
// timeFormat: 'HH:mm:ss',
... ... @@ -90,9 +90,10 @@ var Bll = {
// timeFormat: 'HH:mm:ss',
// showSecond: true
// }).data("datepicker");
$.timepicker.datetimeRange($("#startTime"), $("#endTime"),{
$.timepicker.datetimeRange($("#startTime"), $("#endTime"), {
start: {timeFormat: 'HH:mm:ss'},
end: {timeFormat: 'HH:mm:ss'} } );
end: {timeFormat: 'HH:mm:ss'}
});
new common.dropDown({el: '#filter-couponType'});
... ... @@ -145,40 +146,40 @@ var Bll = {
}
}
//delete product limit
if(couponBean.productLimit){
$("#cleanPrdLimit").on("click",function(){
if (couponBean.productLimit) {
$("#cleanPrdLimit").on("click", function () {
var _cleanPrdLimit = $(this);
common.dialog.confirm("清除商品", "确认清除商品?",function(){
common.dialog.confirm("清除商品", "确认清除商品?", function () {
common.util.__ajax({
url: "/coupon/cleanPrdLimit",//获取所有部门
data: {param: couponBean.id}
}, function (res) {
if(res.code == 200){
if (res.code == 200) {
couponBean.productLimit = null;
$("textarea[name=\"productLimit\"]").val('');
_cleanPrdLimit.attr("disabled",true);
_cleanPrdLimit.attr("disabled", true);
common.util.__tip(res.message, 'success');
}else{
} else {
common.util.__tip(res.message, 'warning');
}
},true);
}, true);
});
});
}
//isNew
if(couponBean.isNew){
if (couponBean.isNew) {
isNew = couponBean.isNew;
}
if(couponBean.couponType=='3'){
$("input[name='publicCouponType']").attr("disabled",true);
if(couponBean.publicCouponType=='1'){
$("input[name='cusPublicCouponName']").attr("disabled",true);
$("input[name='couponNum']").attr("disabled",true);
$("#filter-couponType").attr("disabled",true);
if (couponBean.couponType == '3') {
$("input[name='publicCouponType']").attr("disabled", true);
if (couponBean.publicCouponType == '1') {
$("input[name='cusPublicCouponName']").attr("disabled", true);
$("input[name='couponNum']").attr("disabled", true);
$("#filter-couponType").attr("disabled", true);
}
}
}
... ... @@ -227,12 +228,19 @@ var Bll = {
}
};
/**
* 根据type判断界面
*/
console.log("type====="+type);
console.log("type=====" + type);
if (type == 'add') {
//TODO: 2018.12.17 新增时,去动态获得渠道限制信息
common.util.__ajax({
async: false,
url: "/coupon/queryChannelGroups"
}, function (res) {
// console.log(res.data)
couponBean.couponAvailableChannels = res.data
}, true)
Bll.__render(couponBean, type);
} else {
var id = location.href.substring(location.href.lastIndexOf("/") + 1);
... ... @@ -241,8 +249,16 @@ if (type == 'add') {
data: {couponsId: id}
}, function (res) {
couponBean = res.data;
$.extend(window.ViewModel,res.data);
couponBean.limitStartTime=Bll.getTime(couponBean.limitStartTime);
//TODO: 2018.12.17 编辑时,去动态获得渠道限制信息以及勾选状态
common.util.__ajax({
async: false,
url: "/coupon/queryChannelGroups"
}, function (res) {
couponBean.couponAvailableChannels = res.data
}, true)
$.extend(window.ViewModel, res.data);
couponBean.limitStartTime = Bll.getTime(couponBean.limitStartTime);
couponBean.startTime = Bll.getTime(couponBean.startTime);
couponBean.endTime = Bll.getTime(couponBean.endTime);
Bll.selectSorts = couponBean.sortList || [];
... ... @@ -268,8 +284,8 @@ if (type == 'add') {
couponBean.brandList = Bll.selectBrandsName.join(";");
couponBean.useRange = 1;
}
if(couponBean.shopsIdName&&couponBean.shopsIdName.length>0){
for(var i=0;i<couponBean.shopsIdName.length;i++){
if (couponBean.shopsIdName && couponBean.shopsIdName.length > 0) {
for (var i = 0; i < couponBean.shopsIdName.length; i++) {
Bll.selectShops.push(couponBean.shopsIdName[i].text);
Bll.selectShopIds.push(couponBean.shopsIdName[i].id);
}
... ... @@ -277,12 +293,12 @@ if (type == 'add') {
couponBean.useRange = 2;
}
//指定商品
if(couponBean.productLimit){
if (couponBean.productLimit) {
couponBean.useRange = 3;
}
if(couponBean.prdPoolLimit){
if (couponBean.prdPoolLimit) {
couponBean.useRange = 4;
Bll.selectPrdPool = {id : couponBean.prdPoolLimit, name : couponBean.prdPoolLimitName}
Bll.selectPrdPool = {id: couponBean.prdPoolLimit, name: couponBean.prdPoolLimitName}
}
Bll.__render(couponBean, type)
}, true);
... ... @@ -300,23 +316,23 @@ $(document).on("change", "#useLimitType", function () {
$(document).on("change", "#useRange", function () {
couponBean.useRange = $(this).val();
var _useRange = couponBean.useRange;
if(_useRange){
if(_useRange== 2|| _useRange == 3){
if (_useRange) {
if (_useRange == 2 || _useRange == 3) {
PrdPoolService.dropPrdPool();
}
}
Bll.__render(couponBean, type);
});
$(document).on("change","#filter-couponType",function(){
$(document).on("change", "#filter-couponType", function () {
var couponTypeVal = $(this).val();
couponBean.couponType = $(this).val();
if(couponTypeVal==4||couponTypeVal==5||couponTypeVal==7||couponTypeVal==8){
if (couponTypeVal == 4 || couponTypeVal == 5 || couponTypeVal == 7 || couponTypeVal == 8) {
couponBean.feeSharingType = 1;
}else if(couponTypeVal==6){
} else if (couponTypeVal == 6) {
couponBean.feeSharingType = 2;
}
$.extend(window.ViewModel,couponBean);
$.extend(window.ViewModel, couponBean);
Bll.__render(couponBean, type);
});
/**
... ... @@ -337,16 +353,17 @@ $(document).on("click", "input[name='customType']", function () {
$(document).on("click", "input[name='publicCouponType']", function () {
publicCouponType = $(this).val();
console.log("publicCouponType",publicCouponType);
if(publicCouponType=='1'){
console.log("publicCouponType", publicCouponType);
if (publicCouponType == '1') {
couponBean.couponNum = 1;
$("input[name='couponNum']").attr("disabled",true);
$("input[name='couponNum']").attr("disabled", true);
}
couponBean.publicCouponType = publicCouponType
Bll.__render(couponBean, type);;
if(publicCouponType=='1'){
$("input[name='couponNum']").attr("disabled",true);
Bll.__render(couponBean, type);
;
if (publicCouponType == '1') {
$("input[name='couponNum']").attr("disabled", true);
}
});
/**
... ... @@ -384,42 +401,115 @@ $(document).on("keyup", ".number", function () {
/**
* 渠道限制事件
*/
$(document).on("click", 'input:checkbox[class="couponAvailableChannels"]', function () {
// console.log($(this).is(':checked'),$(this).val())
var mark = $(this).is(':checked')
var className = "couponAvailableChannelStoreList_" + $(this).val()
// console.log(className)
$("." + className).each(function () {
// console.log($(this).val())
$(this).prop("checked", mark)
})
});
/**
* 多选框联动
*/
$(document).on("click", '.couponAvailableChannelStoreList', function () {
if ($(this).is(':checked')) {
// console.log($(this).is(':checked'))
var localNode = $(this).parents("div")[1]
// 门店勾选 对应的渠道也勾选
$(localNode).find('.couponAvailableChannels').prop("checked", true)
}
// 如果门店都没勾选 去除渠道的勾选
if (!$(this).is(':checked')) {
var locNode = $(this).parents("div")[0]
// 门店勾选 对应的渠道也勾选
var mark = true
const len = $(locNode).find('.couponAvailableChannelStoreList').length
const data = $(locNode).find('.couponAvailableChannelStoreList')
for (var i = 0; i < len; i++) {
if ($(data[i]).is(':checked')) {
mark = false
break
}
}
if (mark) {
var localN = $(this).parents("div")[1]
$(localN).find('.couponAvailableChannels').prop("checked", false)
}
}
});
/**
* 保存
*/
$(document).on("click", "#save_brand", function () {
//TODO: 2018.12.17 保存时,获得渠道限制信息,重新组装
var localSimilarDataJson
var jsonDataChannel = []
common.util.__ajax({
async: false,
url: "/coupon/queryChannelGroups"
}, function (res) {
localSimilarDataJson = res.data
}, true)
$('input:checkbox[class="couponAvailableChannels"]:checked').each(function () {
for (var i = 0; i < localSimilarDataJson.length; i++) {
if (localSimilarDataJson[i].groupId == $(this).val()) {
var channelObject = {}
channelObject.storeList = []
channelObject.groupId = $(this).val()
var className = "couponAvailableChannelStoreList_" + $(this).val()
$("." + className).each(function () {
if ($(this).is(':checked'))
channelObject.storeList.push($(this).val())
})
jsonDataChannel.push(channelObject)
}
}
});
// console.log(JSON.stringify(jsonDataChannel))
couponBean.channel = JSON.stringify(jsonDataChannel)
//新增时如果,如果没有选定,赋予1(我司承担)
if(type=='add'&&$("#feeSharingType").val()=='0'){
if (type == 'add' && $("#feeSharingType").val() == '0') {
couponBean.feeSharingType = 1;
}else{
} else {
couponBean.feeSharingType = $("#feeSharingType").val();
}
couponBean.feeSharingRatio = $("#feeSharingRatio").val();
if(couponBean.couponType=='6'){
if(couponBean.shopList==''){
if (couponBean.couponType == '6') {
if (couponBean.shopList == '') {
common.util.__tip('店铺券需要设置店铺限制!', 'warning');
return false;
}
if(couponBean.shopLimit && couponBean.shopLimit.indexOf(",")>0){
if (couponBean.shopLimit && couponBean.shopLimit.indexOf(",") > 0) {
common.util.__tip('店铺券最多设置一个店铺限制!', 'warning');
return false;
}
}
if(couponBean.couponType=='3'){
if(couponBean.publicCouponType=='0'){
if (couponBean.couponType == '3') {
if (couponBean.publicCouponType == '0') {
couponBean.cusPublicCouponName = '';
}
if(couponBean.publicCouponType=='1'){
var cusPublicCouponName = couponBean.cusPublicCouponName;
if(cusPublicCouponName==''){
if (couponBean.publicCouponType == '1') {
var cusPublicCouponName = couponBean.cusPublicCouponName;
if (cusPublicCouponName == '') {
common.util.__tip('码值不能为空!', 'warning');
return false;
}
//名称不能包含特殊字符
if(!cusPublicCouponName.startsWith("#")||/[~^$@%&!*]/gi.test(cusPublicCouponName)){
if (!cusPublicCouponName.startsWith("#") || /[~^$@%&!*]/gi.test(cusPublicCouponName)) {
common.util.__tip('码值格式输入错误', 'warning');
return false;
}
if(cusPublicCouponName.length>20){
if (cusPublicCouponName.length > 20) {
common.util.__tip('码值不可超出20个汉字', 'warning');
return false;
}
... ... @@ -428,14 +518,14 @@ $(document).on("click", "#save_brand", function () {
var productLimit = $("textarea[name=\"productLimit\"]").val();
var explains = couponBean.explains;
if(explains==''){
if (explains == '') {
common.util.__tip('优惠券说明不能为空!', 'warning');
return false;
}
if(productLimit){
if (productLimit) {
couponBean.productLimit = productLimit;
if(productLimit.indexOf(",")>-1){
if (productLimit.indexOf(",") > -1) {
common.util.__tip('指定商品请使用英文逗号', 'warning');
return false;
}
... ... @@ -468,12 +558,12 @@ var initSort = function () {//初始化分类弹框
if (tabTreeArr.length > 0) {
for (var i = 0; i < tabTreeArr.length; i++) {
Bll.selectSorts.push(tabTreeArr[i].selected);
ids.push(tabTreeArr[i].selected[tabTreeArr[i].selected.length-1].id);
ids.push(tabTreeArr[i].selected[tabTreeArr[i].selected.length - 1].id);
}
couponBean.sortLimit = ids.join(',');
}else{
couponBean.sortLimit="";
} else {
couponBean.sortLimit = "";
}
if (Bll.selectSorts.length > 0) {
var sorts = [], sortList = [];
... ... @@ -489,7 +579,7 @@ var initSort = function () {//初始化分类弹框
couponBean.sortsList = sortList.join(";");
Bll.__render(couponBean, type);
}else{
} else {
couponBean.sortsList = "";
Bll.__render(couponBean, type);
}
... ... @@ -630,15 +720,15 @@ var initShop = function () {//初始化店铺弹框
Bll.selectShops = [];
if ($(".shop").length > 0) {
$(".shop").each(function(index){
Bll.selectShops.push($(this).text().replace("选择店铺","").trim());
Bll.selectShopIds.push($(this).val());
});
$(".shop").each(function (index) {
Bll.selectShops.push($(this).text().replace("选择店铺", "").trim());
Bll.selectShopIds.push($(this).val());
});
couponBean.shopLimit = Bll.selectShopIds.join(',');
couponBean.shopList = Bll.selectShops.join(";");
PrdPoolService.dropPrdPool();
Bll.__render(couponBean, type);
}else{
} else {
couponBean.shopList = "";
couponBean.shopLimit = "";
Bll.__render(couponBean, type);
... ... @@ -662,8 +752,10 @@ $(document).on('click', "#addShop", function () {
$.each(Bll.selectShops, function (i, item) {
var shopName = Bll.selectShops[i];
var shopId = Bll.selectShopIds[i];
var Template = {shopId:shopId,
shopName:shopName};
var Template = {
shopId: shopId,
shopName: shopName
};
var $shopGroup = $(common.util.__template2($("#shopWrap").html(), Template));
$shopGroup.appendTo($('.shop-wrap'));
shopDropDown();
... ... @@ -679,8 +771,10 @@ $(document).on('click', "#addShop", function () {
//添加一个店铺
$(document).on('click', '.add-shop-btn', function () {
var Template = {shopId:"",
shopName:""};
var Template = {
shopId: "",
shopName: ""
};
var $shopGroup = $(common.util.__template2($("#shopWrap").html(), Template));
$shopGroup.appendTo($('.shop-wrap'));
shopDropDown();
... ... @@ -692,20 +786,22 @@ $(document).on('click', '.del-shop-btn', function () {
Bll.selectShops.splice(shopIndex, 1);
//Bll.checkSortNum();
});
//店铺券使用couponShops下拉,其他的使用queryShop下拉
function shopDropDown(){
if(couponBean.couponType==6){
function shopDropDown() {
if (couponBean.couponType == 6) {
new common.dropDown({
el: '.shop',
ajax: 'couponShops'
});
}else{
} else {
new common.dropDown({
el: '.shop',
ajax: 'queryShopPass'
});
}
}
//********************* 店铺end****************************************
$(document).on("change", "input[name='isUseLimitRule']", function () {
... ... @@ -730,21 +826,21 @@ var PrdPoolService = {
callback: function () {
//myself
//myselfEnd
Bll.selectPrdPool = {};
Bll.selectPrdPool = {};
if ($(".prdPoolLimit").length > 0) {
var _pass = true;
$(".prdPoolLimit").each(function(index){
$(".prdPoolLimit").each(function (index) {
var _id = $(this).val();
if(_id <= 0){
if (_id <= 0) {
_pass = false;
return false;
}else{
Bll.selectPrdPool.name = $(this).text().replace("选择商品池","").trim()
} else {
Bll.selectPrdPool.name = $(this).text().replace("选择商品池", "").trim()
Bll.selectPrdPool.id = _id;
}
});
if (!_pass) {
common.util.__tip("请选择商品池", 'warning');
... ... @@ -754,8 +850,8 @@ var PrdPoolService = {
couponBean.prdPoolLimitName = Bll.selectPrdPool.name;
dropShop();
Bll.__render(couponBean, type);
}else{
couponBean.prdPoolLimit = "";
} else {
couponBean.prdPoolLimit = "";
Bll.__render(couponBean, type);
}
},
... ... @@ -767,7 +863,7 @@ var PrdPoolService = {
__self.buildPrdPoolDropDown();
},
//选择商品池
clickHandle : function(){
clickHandle: function () {
var __self = this;
if (Bll.selectShops && Bll.selectShops.length > 0) {
//渲染店铺
... ... @@ -787,26 +883,25 @@ var PrdPoolService = {
}
__self.buildPrdPoolDropDown();
},
buildPrdPoolDropDown : function(){
buildPrdPoolDropDown: function () {
return new common.dropDown({
el: '.prdPoolLimit',
ajax: 'productPool',
params : {diffType : 3}
params: {diffType: 3}
});
},
dropPrdPool : function(){
dropPrdPool: function () {
couponBean.prdPoolLimit = "";
Bll.selectPrdPool = {};
Bll.selectPrdPool = {};
}
}
$(document).on('click', "#addPrdPool", function () {
PrdPoolService.clickHandle();
});
var dropShop = function(){
var dropShop = function () {
Bll.selectShopIds = [];
Bll.selectShops = [];
couponBean.shopLimit = "";
... ...
... ... @@ -18,12 +18,12 @@ new common.dropDown({el: '#filter-couponType'});
//下拉框
new common.dropDown({el: '#filter-feeSharingType'});
var couponTypes = ["活动券", "B券", "券码", "生日券", "免邮券","店铺券","分享券","会员营销券"];
var couponTypes = ["活动券", "B券", "券码", "生日券", "免邮券", "店铺券", "分享券", "会员营销券"];
var useLimitTypes = ["无限制", "货物件数限制", "订单金额限制"];
// var customTypes = ["新客户", "银卡会员", "金卡会员", "白金卡会员", "普通用户(不含新客)"];
var customTypes={1:"新客户",2:"银卡会员", 3:"金卡会员", 4:"白金卡会员", 5:"普通用户(不含新客)",9:"学生"};
var shopPriceLimitsTable={1:"成交价低于吊牌价三折",2:"限量商品"};
var thirdTypeEnum={1:"微信", 2:"支付宝", 3: "微薄"};
var customTypes = {1: "新客户", 2: "银卡会员", 3: "金卡会员", 4: "白金卡会员", 5: "普通用户(不含新客)", 9: "学生"};
var shopPriceLimitsTable = {1: "成交价低于吊牌价三折", 2: "限量商品"};
var thirdTypeEnum = {1: "微信", 2: "支付宝", 3: "微薄"};
var ENUM = {
status: {0: '待审核', 1: '审核通过', 2: '驳回', '-1': '过期', 3: '作废'},//全部
... ... @@ -35,20 +35,19 @@ common.util.__ajax({
url: "/coupon/getAllDepartment",//获取所有部门
data: {size: 1000}
}, function (res) {
var data=res.data;
var newData=data.filter(function(v,i){
if(v.status==1){
var data = res.data;
var newData = data.filter(function (v, i) {
if (v.status == 1) {
return v;
}
});
res.data=newData;
res.data = newData;
console.log(res);
$("#departments").html(common.util.__template2($("#search-department").html(), res));
new common.dropDown({el: "#choose-department"});
}, true);
/**
* tab分页
*/
... ... @@ -59,25 +58,21 @@ var t = new common.tab({
g.options.columns[6].hidden = true;
g.options.columns[7].hidden = true;
switch (columnname) {
case "1":
{
case "1": {
g.options.columns[8].hidden = true;
}
break;
case "2":
{
case "2": {
g.options.columns[6].hidden = false;
g.options.columns[8].hidden = true;
}
break;
case "3":
{
case "3": {
g.options.columns[7].hidden = false;
g.options.columns[8].hidden = true;
}
break;
case "all":
{
case "all": {
g.options.columns[8].hidden = false;
}
break;
... ... @@ -104,8 +99,8 @@ var g = new common.grid({
couponId: common.util.__input("filter-coupon"),
couponName: common.util.__input("filter-couponName"),
department: common.util.__input("choose-department"),
couponType:common.util.__input("filter-couponType"),
feeSharingType:common.util.__input("filter-feeSharingType"),
couponType: common.util.__input("filter-couponType"),
feeSharingType: common.util.__input("filter-feeSharingType"),
status: t.active,
startTimeStr: common.util.__input("startTimeStr"),
endTimeStr: common.util.__input("endTimeStr")
... ... @@ -115,86 +110,88 @@ var g = new common.grid({
{display: "优惠券ID", name: "id"},
{
display: "基本信息", render: function (item) {
var arr = [];
arr.push("<p>名称:" + item.couponName + "</p>");
arr.push("<p>类型:" + couponTypes[item.couponType - 1] + "</p>");
arr.push("<p>优惠结果:" + item.couponAmount + "</p>");
arr.push("<p>数量:" + item.couponNum + "</p>");
arr.push("<p>部门:" + item.departmentName + "</p>");
if (item.couponsUseRuleVo && item.couponsUseRuleVo.thirdType) {
arr.push("<p>第三方(" + thirdTypeEnum[item.couponsUseRuleVo.thirdType] + "): " + item.couponsUseRuleVo.thirdId+ "</p>");
var arr = [];
arr.push("<p>名称:" + item.couponName + "</p>");
arr.push("<p>类型:" + couponTypes[item.couponType - 1] + "</p>");
arr.push("<p>优惠结果:" + item.couponAmount + "</p>");
arr.push("<p>数量:" + item.couponNum + "</p>");
arr.push("<p>部门:" + item.departmentName + "</p>");
if (item.couponsUseRuleVo && item.couponsUseRuleVo.thirdType) {
arr.push("<p>第三方(" + thirdTypeEnum[item.couponsUseRuleVo.thirdType] + "): " + item.couponsUseRuleVo.thirdId + "</p>");
}
return arr.join('');
}
return arr.join('');
}
},
{
display: "使用期限", render: function (item) {
var startTime = Bll.getTime(item.startTime);
var endTime = Bll.getTime(item.endTime);
return startTime + "</br> 至 " + endTime;
}
var startTime = Bll.getTime(item.startTime);
var endTime = Bll.getTime(item.endTime);
return startTime + "</br> 至 " + endTime;
}
},
{
display: "使用条件", render: function (item) {
var str = "无限制";
if (item.useLimitType == 1) {
str = "件数满:" + item.useLimit;
} else if (item.useLimitType == 2) {
str = "金额满:" + item.useLimit;
var str = "无限制";
if (item.useLimitType == 1) {
str = "件数满:" + item.useLimit;
} else if (item.useLimitType == 2) {
str = "金额满:" + item.useLimit;
}
return '<p style="max-width: 200px;word-wrap: break-word;">' + str + '</p>';
}
return '<p style="max-width: 200px;word-wrap: break-word;">' + str + '</p>';
}
},
{display: "优惠券说明", name: "explains"},
{display: "费用承担", render:function(item){
var feeType;
if(item.feeSharingType == 1){
feeType = "我司承担";
}else if(item.feeSharingType ==2){
feeType = "供应商承担"
}else if(item.feeSharingType ==3){
feeType = "分摊(合同结算)";
}else if(item.feeSharingType ==4){
feeType = "分摊-我司承担比例:"+item.feeSharingRatio;
}else if(item.feeSharingType ==5){
feeType = "优惠券分摊条款";
{
display: "费用承担", render: function (item) {
var feeType;
if (item.feeSharingType == 1) {
feeType = "我司承担";
} else if (item.feeSharingType == 2) {
feeType = "供应商承担"
} else if (item.feeSharingType == 3) {
feeType = "分摊(合同结算)";
} else if (item.feeSharingType == 4) {
feeType = "分摊-我司承担比例:" + item.feeSharingRatio;
} else if (item.feeSharingType == 5) {
feeType = "优惠券分摊条款";
}
return feeType;
}
return feeType;
}},
},
{
display: "驳回理由", hidden: true, name: "rejectReason", render: function (item) {
return "<p style='color: red'>" + item.rejectReason + "</p>"
}
return "<p style='color: red'>" + item.rejectReason + "</p>"
}
},
{
display: "作废理由", hidden: true, name: "invalidReason", render: function (item) {
return "<p style='color: red'>" + item.invalidReason + "</p>"
}
return "<p style='color: red'>" + item.invalidReason + "</p>"
}
},
{
display: '状态', render: function (item) {
var html = ENUM.status[item.status] || '全部';
if (item.status == 2) {
if (item.rejectReason.length > 10) {
item.rejectReason = item.rejectReason.substring(0, 10) + "......";
var html = ENUM.status[item.status] || '全部';
if (item.status == 2) {
if (item.rejectReason.length > 10) {
item.rejectReason = item.rejectReason.substring(0, 10) + "......";
}
html += '<p style="color:red;word-wrap: break-word;">(' + item.rejectReason + ')</p>';
}
html += '<p style="color:red;word-wrap: break-word;">(' + item.rejectReason + ')</p>';
}
if (item.status == 3) {
if (item.invalidReason.length > 10) {
item.invalidReason = item.invalidReason.substring(0, 10) + "......";
if (item.status == 3) {
if (item.invalidReason.length > 10) {
item.invalidReason = item.invalidReason.substring(0, 10) + "......";
}
html += '<p style="color:red;word-wrap: break-word;">(' + item.invalidReason + ')</p>';
}
html += '<p style="color:red;word-wrap: break-word;">(' + item.invalidReason + ')</p>';
return html;
}
return html;
}
},
{
display: "操作", render: function (item) {
var HtmArr = [];
HtmArr = Bll.getButtons(item.__index, item.id, item.options);
return HtmArr.join('');
}
var HtmArr = [];
HtmArr = Bll.getButtons(item.__index, item.id, item.options);
return HtmArr.join('');
}
}
]
});
... ... @@ -321,6 +318,17 @@ $(document).on('click', '.coupon-info', function () {
}, function (res) {
item1 = res.data;
}, true);
// 获取可用渠道
common.util.__ajax({
async: false,
url: "/coupon/queryChannelGroups"
}, function (res) {
item1.couponAvailableChannels = res.data
}, true)
item1.createTime = Bll.getTime(item1.createTime);
item1.limitStartTime = Bll.getTime(item1.limitStartTime);
item1.startTime = Bll.getTime(item1.startTime);
... ... @@ -334,9 +342,9 @@ $(document).on('click', '.coupon-info', function () {
});
item1.brandsList = brands.join(";")
}
if(item1.shopsIdName){
if (item1.shopsIdName) {
var shops = [];
item1.shopsIdName.forEach(function(x){
item1.shopsIdName.forEach(function (x) {
shops.push(x.text);
});
item1.shopList = shops.join(";");
... ... @@ -380,14 +388,14 @@ $(document).on('click', '.coupon-info', function () {
limits.push(shopPriceLimitsTable[item1.shopPriceLimits[i]]);
}
item1.shopPriceLimits = limits.join(",");
}else {
} else {
item1.shopPriceLimits = "无";
}
Bll.toastInfo(item1, '优惠券详情');
});
// 绑定第三方
$(document).on('click', '.operation-third', function() {
$(document).on('click', '.operation-third', function () {
var item = g.rows[$(this).data("index")];
var obj = {};
... ... @@ -400,20 +408,21 @@ $(document).on('click', '.operation-third', function() {
var url = "/coupon/updateCouponsUseRule";
var dialog = common.dialog.confirm("绑定第三方 ID", artTemplate("third-template", obj), function() {
var dialog = common.dialog.confirm("绑定第三方 ID", artTemplate("third-template", obj), function () {
e.submit(url, function (option) {
e.submit(url, function (option) {
console.log(option.data);
console.log(option.data);
option.success=function() {
dialog.close();
g.reload();
};
option.error=function(){};
});
option.success = function () {
dialog.close();
g.reload();
};
option.error = function () {
};
});
return false;
return false;
});
// e.on("validate", function() {
... ... @@ -424,18 +433,17 @@ $(document).on('click', '.operation-third', function() {
// });
e.init();
new common.dropDown({ el: "#thirdType" });
if (item.couponsUseRuleVo.thirdType == '1'){
new common.dropDown({el: "#thirdType"});
if (item.couponsUseRuleVo.thirdType == '1') {
$("#weixin").show();
}else{
} else {
$("#weixin").hide();
}
});
// 更新微信卡券h5链接
$(document).on('click', '#updateh5-btn', function() {
$(document).on('click', '#updateh5-btn', function () {
var obj = {};
... ... @@ -443,14 +451,14 @@ $(document).on('click', '#updateh5-btn', function() {
var url = "/coupon/updateH5Link";
var dialog = common.dialog.confirm("更新微信卡券h5链接", artTemplate("h5Link-template", obj), function() {
var dialog = common.dialog.confirm("更新微信卡券h5链接", artTemplate("h5Link-template", obj), function () {
e.submit(url, function (option) {
console.log(option.data);
option.success=function(res) {
if(res.code == 200) {
option.success = function (res) {
if (res.code == 200) {
common.util.__tip('更新微信卡券h5链接成功!', 'success');
dialog.close();
} else {
... ... @@ -460,7 +468,7 @@ $(document).on('click', '#updateh5-btn', function() {
return false;
};
option.error=function(){
option.error = function () {
common.util.__tip('提交失败!', 'fail');
};
});
... ... @@ -472,24 +480,24 @@ $(document).on('click', '#updateh5-btn', function() {
});
// 查看操作记录
$(document).on('click', '.operation-records', function() {
$(document).on('click', '.operation-records', function () {
var couponId = $(this).data('coupon-id');
var option = {
title:'操作记录详情',
content:"<div class='historyDetail'>加载操作记录...</div>",
width:'70%',
button:[{value:"关闭", css:"btn-primary"}]
title: '操作记录详情',
content: "<div class='historyDetail'>加载操作记录...</div>",
width: '70%',
button: [{value: "关闭", css: "btn-primary"}]
};
new common.dialog(option);
getOperationRecords(couponId);
});
$(document).on('change','#thirdType', function () {
$(document).on('change', '#thirdType', function () {
var title = $(this).val();
if (title == '1'){
if (title == '1') {
$("#weixin").show();
}else{
} else {
$("#weixin").hide();
}
});
... ... @@ -500,8 +508,8 @@ function getOperationRecords(couponId) {
data: {
couponsId: couponId
}
}, function(resp) {
if(resp.code == 200) {
}, function (resp) {
if (resp.code == 200) {
var data = resp.data;
covertOperationRecord(data)
$('.historyDetail').html(common.util.__template2($('#operation-record-template').html(), {list: data}));
... ... @@ -514,8 +522,8 @@ function getOperationRecords(couponId) {
// 转化操作类型,操作时间
function covertOperationRecord(data) {
var TYPE = {0: "新增", 1: "修改", 2: "作废"}
if(data && data.length > 0) {
$.each(data, function(index, item) {
if (data && data.length > 0) {
$.each(data, function (index, item) {
item.operationType = TYPE[item.operationType];
item.createTime = Bll.getTime(item.createTime);
})
... ... @@ -523,20 +531,20 @@ function covertOperationRecord(data) {
}
/**
*导出指定时间范围的券
*/
$("#exportByTimeRange-btn").click(function () {
*导出指定时间范围的券
*/
$("#exportByTimeRange-btn").click(function () {
var queryConf = {
couponId: common.util.__input("filter-coupon"),
couponName: common.util.__input("filter-couponName"),
department: common.util.__input("choose-department"),
couponType:common.util.__input("filter-couponType"),
feeSharingType:common.util.__input("filter-feeSharingType"),
couponType: common.util.__input("filter-couponType"),
feeSharingType: common.util.__input("filter-feeSharingType"),
status: t.active,
startTimeStr: common.util.__input("startTimeStr"),
endTimeStr: common.util.__input("endTimeStr")
};
if(!queryConf.startTimeStr || !queryConf.endTimeStr){
if (!queryConf.startTimeStr || !queryConf.endTimeStr) {
common.util.__tip('请选择开始时间和结束时间', 'warning');
return;
}
... ...
... ... @@ -2,35 +2,36 @@
* Created by ty on 2016/5/24.
*/
var couponBean = {
id:"",
couponType:"",
couponName:"",
couponNum:"",
useNum:1,
department:"",
startTime:"",
endTime:"",
explains:"特例商品不支持使用优惠券",
useLimitType:0,
useLimit:"",
couponAmount:"",
brandLimit:"",
brandList:"",
sortList:"",
sortLimit:"",
customType:"",
multipleNum:1,
shopPriceLimits:"",
sknExclude:"",
useRange:0,
shopList:"",
shopIds:"",
feeSharingType:"0",
feeSharingRatio:"",
isUseLimitRule:"",
cusPublicCouponName:"",
publicCouponType:""
id: "",
couponType: "",
couponName: "",
couponNum: "",
useNum: 1,
department: "",
startTime: "",
endTime: "",
explains: "特例商品不支持使用优惠券",
useLimitType: 0,
useLimit: "",
couponAmount: "",
brandLimit: "",
brandList: "",
sortList: "",
sortLimit: "",
customType: "",
multipleNum: 1,
shopPriceLimits: "",
sknExclude: "",
useRange: 0,
shopList: "",
shopIds: "",
feeSharingType: "0",
feeSharingRatio: "",
isUseLimitRule: "",
cusPublicCouponName: "",
publicCouponType: "",
couponAvailableChannels: "", // 可用渠道
channel: "" // 可用渠道勾选状态
};
module.exports = couponBean;
\ No newline at end of file
... ...