From 9b51a95fa8bc9b3a86108c6900e17fc55f8db467 Mon Sep 17 00:00:00 2001 From: Administrator <15274802129@163.com> Date: Mon, 19 May 2025 17:02:07 +0800 Subject: [PATCH] refactor(vip): 优化积分和返佣计算逻辑 --- src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html | 454 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 386 insertions(+), 68 deletions(-) diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html index 18b2c15..36a817c 100644 --- a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html +++ b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html @@ -28,14 +28,26 @@ </div> </div> </div> - <div class="layui-row layui-col-space10 layui-form-item"> + <div class="layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">商品分类:</label> <div class="layui-input-block"> -<!-- <select name="categoryId" class="categary-addPeoduct" >--> -<!-- <option value="">请选择</option>--> -<!-- </select>--> <div id="goods-category"></div> + </div> + </div> + + <div class="layui-col-lg3"> + <label class="layui-form-label">是否主推:</label> + <div class="layui-input-block"> + <input type="radio" name="isHot" value="1" title="是" /> + <input type="radio" name="isHot" value="2" title="否" checked /> + </div> + </div> + + <div class="layui-col-lg3"> + <label class="layui-form-label febs-form-item-require">序号:</label> + <div class="layui-input-block"> + <input type="number" name="orderNumber" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> </div> </div> </div> @@ -45,6 +57,14 @@ <label class="layui-form-label febs-form-item-require">单位:</label> <div class="layui-input-block"> <input type="text" name="unit" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> + </div> + </div> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">重量:</label> + <div class="layui-input-block"> + <input type="text" name="goodsWeight" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> + + <div class="layui-form-mid layui-word-aux">默认单位:克。请填写数字。如:1千克,则填入1000。</div> </div> </div> </div> @@ -78,26 +98,27 @@ <div class="layui-input-block"> <select name="isNormal" class="goods-type" lay-filter="goods-type-select"> <option value="1">普通商品区</option> - <option value="2">套餐区</option> +<!-- <option value="2">套餐区</option>--> </select> </div> </div> - <div class="layui-form-item febs-hide tc-set"> - <label class="layui-form-label">静态倍数</label> - <div class="layui-input-block"> - <input type="text" name="staticMulti" placeholder="请输入静态倍数" autocomplete="off" class="layui-input"> - <div class="layui-form-mid layui-word-aux">支付后,赠送(购买金额*静态倍数)的赠送积分</div> - </div> - </div> +<!-- <div class="layui-form-item">--> +<!-- <label class="layui-form-label">推销员返积分比例(%)</label>--> +<!-- <div class="layui-input-block">--> +<!-- <input type="text" name="staticMulti" placeholder="请输入推销员返积分比例" autocomplete="off" class="layui-input">--> +<!-- </div>--> +<!-- </div>--> - <div class="layui-form-item febs-hide tc-set"> - <label class="layui-form-label">静态占比(%)</label> - <div class="layui-input-block"> - <input type="text" name="staticProp" placeholder="请输入静态占比" autocomplete="off" class="layui-input"> - <div class="layui-form-mid layui-word-aux">所有套餐静态占比相加应等于100%</div> - </div> - </div> +<!-- <div class="layui-form-item febs-hide tc-set">--> +<!-- <label class="layui-form-label">积分折扣(%)</label>--> +<!-- <div class="layui-input-block">--> +<!-- <input type="text" name="staticProp" placeholder="请输入积分折扣" autocomplete="off" class="layui-input">--> +<!-- <div class="layui-form-mid layui-word-aux">折扣积分=售价*积分折扣(%)*积分换算比例</div>--> +<!-- <div class="layui-form-mid layui-word-aux">不允许使用积分设置成:0%</div>--> +<!-- <div class="layui-form-mid layui-word-aux">全部使用积分设置成:大于等于100%</div>--> +<!-- </div>--> +<!-- </div>--> </div> <div class="layui-tab-item"> @@ -109,6 +130,7 @@ <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> <div class="layui-upload-list" id="demo2"></div> </blockquote> + <div class="layui-word-aux">双击图片删除</div> </div> </div> </div> @@ -128,6 +150,7 @@ <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> <div class="layui-upload-list" id="thumbsBanners"></div> </blockquote> + <div class="layui-word-aux">双击图片删除</div> </div> </div> </div> @@ -140,9 +163,33 @@ </div> <div class="layui-form-item"> + <label class="layui-form-label">商品参数:</label> + <div class="layui-input-block"> + <label> + <textarea name="goodsParameter" rows="5" autocomplete="off" class="layui-textarea" ></textarea> + </label> + </div> + </div> + +<!-- <div class="layui-form-item">--> +<!-- <label class="layui-form-label febs-form-item-require">商品详情:</label>--> +<!-- <div class="layui-input-block">--> +<!-- <textarea id="goodsDetailEditAdd" lay-verify="content" name = "goodsDetails" class="layui-textarea"></textarea>--> +<!--<!– <div style="border: 1px solid #ccc;">–>--> +<!--<!– <div id="toolbar-container-good-add" style="border-bottom: 1px solid #ccc;"></div>–>--> +<!--<!– <div id="editor-container-good-add" style="height: 450px;"></div>–>--> +<!--<!– </div>–>--> +<!-- </div>--> +<!-- </div>--> + + <div class="layui-form-item"> <label class="layui-form-label febs-form-item-require">商品详情:</label> <div class="layui-input-block"> - <textarea id="goodsDetailEdit" lay-verify="goodsDetails" name = "goodsDetails" class="layui-textarea"></textarea> +<!-- <textarea id="goodsDetailEditAdd" lay-verify="content" name = "goodsDetails" class="layui-textarea"></textarea>--> + <div style="border: 1px solid #ccc;"> + <div id="toolbar-container" class="toolbar"></div> + <div id="text-container" class="text" style="height: 450px;"></div> + </div> </div> </div> </div> @@ -162,11 +209,83 @@ </div> </div> </div> +<!-- <blockquote class="layui-elem-quote blue-border">代理价格</blockquote>--> +<!-- <div class="layui-row layui-col-space10 layui-form-item">--> +<!-- <div class="layui-col-lg6">--> +<!-- <label class="layui-form-label febs-form-item-require">一级价格:</label>--> +<!-- <div class="layui-input-block">--> +<!-- <input type="text" name="levelOnePrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">--> +<!-- </div>--> +<!-- </div>--> +<!-- <div class="layui-col-lg6">--> +<!-- <label class="layui-form-label febs-form-item-require">二级价格:</label>--> +<!-- <div class="layui-input-block">--> +<!-- <input type="text" name="levelTwoPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">--> +<!-- </div>--> +<!-- </div>--> +<!-- </div>--> +<!-- <div class="layui-row layui-col-space10 layui-form-item">--> +<!-- <div class="layui-col-lg6">--> +<!-- <label class="layui-form-label febs-form-item-require">三级价格:</label>--> +<!-- <div class="layui-input-block">--> +<!-- <input type="text" name="levelThreePrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">--> +<!-- </div>--> +<!-- </div>--> +<!-- </div>--> <div class="layui-form-item"> - <label class="layui-form-label febs-form-item-require">成本价:</label> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">成本价:</label> + <div class="layui-input-block"> + <input type="text" name="costPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> + </div> + </div> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">积分折扣(%)</label> + <div class="layui-input-block"> + <input type="text" name="staticProp" lay-verify="required" placeholder="请输入积分折扣" lay-reqText="请输入积分折扣" autocomplete="off" class="layui-input"> + <div class="layui-form-mid layui-word-aux">折扣积分=原价 * 积分折扣(%)* 积分换算比例</div> + <div class="layui-form-mid layui-word-aux">不允许使用积分设置成:0%</div> + <div class="layui-form-mid layui-word-aux">全部使用积分设置成:大于等于100%</div> + </div> + </div> + + </div> + <blockquote class="layui-elem-quote blue-border">运费设置</blockquote> + <div class="layui-form-item"> + <label class="layui-form-label">运费:</label> <div class="layui-input-block"> - <input type="text" name="costPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> + <input type="radio" name="carriageType" value="1" title="固定运费" lay-filter="hasCarriage" /> + <input type="radio" name="carriageType" value="2" title="使用邮费模板" lay-filter="hasCarriage" checked/> + </div> + </div> + + <div class="layui-form-item carriage-input febs-hide"> + <div class="layui-col-lg6"> + <label class="layui-form-label">固定运费:</label> + <div class="layui-input-block"> + <input id="carriageAmountDefault" type="text" name="carriageAmount" placeholder="" autocomplete="off" class="layui-input"> + <div class="layui-form-mid layui-word-aux">远费设置为0元,商品将显示为免运费。</div> + </div> + </div> + </div> + + <div class="layui-form-item carriage-rule"> + <div class="layui-col-lg6"> + <label class="layui-form-label febs-form-item-require">邮费模板:</label> + <div class="layui-input-block"> + <div id="carriage-rule"></div> + </div> + </div> + </div> + + <blockquote class="layui-elem-quote blue-border">优惠卷设置</blockquote> + <div class="layui-form-item coupon-rule"> + <div class="layui-col-lg6"> + <label class="layui-form-label">优惠卷:</label> + <div class="layui-input-block"> + <div id="coupon-rule"></div> + </div> </div> </div> @@ -186,9 +305,18 @@ <input type="text" name="addMallGoodsSkuDtos" autocomplete="off" class="layui-input" id="attrName"> </div> </div> - <div class="layui-col-lg6"> - <button type="button" class="layui-btn layui-btn-normal layui-btn" id="test3" >添加</button> + <div class="layui-col-lg1"> + <button type="button" + class="layui-btn layui-btn-normal layui-btn" id="test3"> + 添加 + </button> </div> +<!-- <div class="layui-col-lg1">--> +<!-- <button type="button"--> +<!-- class="layui-btn layui-btn-normal layui-btn" id="test4">--> +<!-- 新增样品--> +<!-- </button>--> +<!-- </div>--> </div> <div class="layui-form-item"> @@ -222,6 +350,12 @@ .layui-table-cell { height:auto; } + .layui-upload-list { + margin: 0 !important; + } + .multi-images { + margin: 0 5px !important; + } </style> <script type="text/html" id="toolbar"> <div class="layui-btn-container"> @@ -252,10 +386,75 @@ upload = layui.upload, validate = layui.validate, element = layui.element; - + // form.verify(validate); form.render(); + const E = window.wangEditor; + const editor = new E('#toolbar-container', '#text-container'); // 传入两个元素 + editor.config.showLinkImg = false; + editor.config.uploadFileName = 'file'; + editor.config.customUploadImg = function (files, insertImgFn) { + // files 是 input 中选中的文件列表 + // insertImgFn 是获取图片 url 后,插入到编辑器的方法 + // 上传图片,返回结果,将图片插入到编辑器中 + for (let i = 0; i < files.length; i++){ + var form = new FormData(); + form.append("file", files[0]); + $.ajax({ + url:'/admin/goods/uploadFileBase64', + type: "post", + processData: false, + contentType: false, + data: form, + dataType: 'json', + success(res) { + // 上传代码返回结果之后,将图片插入到编辑器中 + insertImgFn(res.data.src, res.data.title, '') + } + }) + } + }; + editor.create(); + + // var E = window.wangEditor; + // const editorConfig = { MENU_CONF: {} }; + // editorConfig.MENU_CONF['uploadImage'] = { + // server: '/admin/goods/uploadFileBase64', + // fieldName : "file", + // customInsert(res, insertFn) { + // insertFn(res.data.src, res.data.title, '') + // }, + // } + // + // const editor = E.createEditor({ + // selector: '#editor-container-good-add', + // config : editorConfig, + // mode: 'default' + // }); + // + // const toolbar = E.createToolbar({ + // editor, + // selector: '#toolbar-container-good-add', + // mode: 'default' + // }); + laydate.render({ elem: '#febs-form-group-date' + }); + layedit.set({ //设置图片接口 + uploadImage: { + url: 'admin/goods/uploadFileBase64', //接口url + type: 'post', + } + }); + //创建一个编辑器 + var indexAdd = layedit.build('goodsDetailEditAdd',{ + height: 300 + }); + form.verify({ + //content富文本域中的lay-verify值 + content: function(value) { + return layedit.sync(indexAdd); + } }); formSelects.render(); @@ -267,6 +466,11 @@ value : 'id', children : 'child' }, + iconfont: { + parent: 'hidden', + }, + tips: '请选择', + filterable: true, radio: true, clickClose: true, tree: { @@ -284,6 +488,60 @@ }); }) + var carriageRule = xmSelect.render({ + el: '#carriage-rule', + language: 'zn', + prop : { + value : 'id', + children : 'child' + }, + iconfont: { + parent: 'hidden', + }, + radio: true, + clickClose: true, + tree: { + show: true, + //非严格模式 + strict: false, + }, + data: [] + }) + + febs.get(ctx + 'admin/goods/carriageRuleTree', null, function(res) { + carriageRule.update({ + data : res.data, + autoRow: true, + }); + }) + + var couponRule = xmSelect.render({ + el: '#coupon-rule', + language: 'zn', + prop : { + value : 'id', + children : 'child' + }, + iconfont: { + parent: 'hidden', + }, + // radio: true, + clickClose: true, + tree: { + show: true, + //非严格模式 + strict: false, + }, + data: [] + }) + + febs.get(ctx + 'admin/goods/couponTreeSet', null, function(res) { + couponRule.update({ + data : res.data, + autoRow: true, + }); + }) + var tableSkuData=[]; var tableIns = table.render({ elem: '#multiSku' @@ -293,14 +551,19 @@ ,cols: [[ //表头 {type: 'checkbox'} ,{field: 'index', title: '序号', width:70} - ,{field: 'styleName', title: '样式', edit:'text'} - ,{field: 'skuName', title: '规格', edit:'text'} - ,{field: 'presentPrice', title: '现价', edit:'text'} - ,{field: 'originalPrice', title: '原价', edit:'text'} - ,{field: 'costPrice', title: '成本价', edit:'text'} + ,{field: 'styleName', title: '样式', edit:'text', width:200} + ,{field: 'skuName', title: '规格', edit:'text', width:200} + // ,{field: 'sample', title:'样品', width:100} + ,{field: 'goodsWeight', title: '重量', edit:'text', width:100} + // ,{field: 'levelOnePrice', title: '一级价格', edit:'text', width:100} + // ,{field: 'levelTwoPrice', title: '二级价格', edit:'text', width:100} + // ,{field: 'levelThreePrice', title: '三级价格', edit:'text', width:100} + ,{field: 'originalPrice', title: '原价', edit:'text', width:100} + ,{field: 'presentPrice', title: '现价', edit:'text', width:100} + ,{field: 'costPrice', title: '成本价', edit:'text', width:100} ,{templet: '#tableImgUpload', title: '缩略图', width:150} - ,{field: 'stock', title: '库存', edit:'text'} - ,{field: 'skuVolume', title: '销量', edit:'text'} + ,{field: 'stock', title: '库存', edit:'text', width:100} + ,{field: 'skuVolume', title: '销量', edit:'text', width:100} ,{field: 'skuImage', title: '缩略图地址', hide:true} ]] ,data: [] @@ -342,6 +605,18 @@ $('.multi-sku-table').hide(); } else { $('.multi-sku-table').show(); + } + }); + + form.on('radio(hasCarriage)', function(data){ + if (data.value == 2) { + $('.carriage-input').hide(); + $('.carriage-rule').show(); + // document.getElementById('carriageAmountDefault').value = 0; + } else { + $('.carriage-input').show(); + $('.carriage-rule').hide(); + // document.getElementById('carriageAmountDefault').value = 0; } }); @@ -393,6 +668,12 @@ addTableDate(data); }); + $('#test4').on('click', function () { + var data = {}; + data.sample = "样品"; + addTableDate(data); + }); + function bindUpload(index) { // 普通图片上传 upload.render({ @@ -437,7 +718,7 @@ ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ - $('#thumbsBanners').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img" style="width: 100px">') + $('#thumbsBanners').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img multi-images" style="width: 130px">') }); } ,done: function(res){ @@ -447,8 +728,38 @@ }else{ $("#thumbs").val(thumbs + ',' + res.data.src); } + + imgUnBind(".multi-images"); + imgMultiBind(); } }); + + function imgUnBind(className) { + $(className).each(function() { + $(this).unbind('dblclick'); + }) + } + + function imgMultiBind() { + $(".multi-images").each(function(index, element) { + $(this).on("dblclick", function() { + var imgThumb = $(".multi-images")[index]; + $(imgThumb).remove(); + + var images = $("#thumbs").val(); + var imagesArr; + if (images) { + imagesArr = images.split(","); + imagesArr.splice(index, 1); + images = imagesArr.join(","); + } + $("#thumbs").val(images); + + imgUnBind(".multi-images"); + imgMultiBind(); + }); + }) + } //图片上传 upload.render({ @@ -458,45 +769,52 @@ ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ - $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img" style="width: 100px">') + if ($("#thumb").val()) { + $('#demo2').html('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img single-image" style="width: 130px">') + } else { + $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img single-image" style="width: 130px">') + } + }); } ,done: function(res){ $("#thumb").val(res.data.src); + + imgUnBind(".single-image"); + imgSingleBind(); } }); - layedit.set({ //设置图片接口 - uploadImage: { - url: 'admin/goods/uploadFileBase64', //接口url - type: 'post', - } - }); - //创建一个编辑器 - var index = layedit.build('goodsDetailEdit', { height: '300px', }); - //提交时把值同步到文本域中 - form.verify({ - //content富文本域中的lay-verify值 - goodsDetails: function(value) { - return layedit.sync(index); - } - }); + function imgSingleBind() { + $(".single-image").each(function(index, element) { + $(this).on("dblclick", function() { + var imgThumb = $(".single-image")[index]; + $(imgThumb).remove(); + $("#thumb").val(""); - - upload.render({ - elem: '#skuImg'+index - ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 - ,done: function(res){ - febs.alert.success(res.data.src); - $('#imageUrls' + index).attr('src', res.data.src); - $('#skuImage'+ index).val(res.data.src); - } - }); + imgUnBind(".single-image"); + imgSingleBind(); + }); + }) + } form.on('submit(goods-add-form-submit)', function (data) { data.field.goodsType = 1; + let couponRuleList = couponRule.getValue(); + if (couponRuleList.length > 0) { + var couponIds = []; + layui.each(couponRuleList, function (key, item) { + couponIds.push(item.id) + }); + data.field.couponIds=couponIds; + } data.field.addMallGoodsSkuDtos = tableSkuData; data.field.categoryId = category.getValue('valueStr'); + data.field.carriageRuleId = carriageRule.getValue('valueStr'); + // let content = layedit.getContent(); + // alert(content); + // data.field.goodsDetails = content; + data.field.goodsDetails = editor.txt.html(); $.ajax({ 'url':ctx + 'admin/goods/addMallGoods', 'type':'post', @@ -520,14 +838,14 @@ return false; }); - form.on('select(goods-type-select)', function(data){ - $('.tc-set').each(function() { - if (data.value == 2) { - $(this).show(); - } else { - $(this).hide(); - } - }) - }); + // form.on('select(goods-type-select)', function(data){ + // $('.tc-set').each(function() { + // if (data.value == 2) { + // $(this).show(); + // } else { + // $(this).hide(); + // } + // }) + // }); }); </script> \ No newline at end of file -- Gitblit v1.9.1