Authored by mali

Merge branch 'master' of http://git.yoho.cn/ufo/ufo-platform

... ... @@ -70,4 +70,11 @@ public interface UfoSizeMapper {
* @return
*/
List<Size> selectByIdList(@Param("list")List<Integer> idList);
/**
* 根据二级分类id获取尺码数据
* @param sortId
* @return
*/
List<Size> getOrderBySortLevel2Id(Integer sortId);
}
... ...
... ... @@ -92,4 +92,8 @@
#{item}
</foreach>
</select>
<select id="getOrderBySortLevel2Id" resultMap="sizeMap">
select id, sort_id, order_by from size where sort_id = #{sortId}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.ufo.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.error.exception.ServiceException;
import com.yoho.ufo.dal.UfoSizeMapper;
import com.yoho.ufo.model.brand.BrandSeries;
import com.yoho.ufo.model.commoditybasicrole.size.Size;
... ... @@ -18,6 +19,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author kun.wang
... ... @@ -36,11 +38,26 @@ public class SizeServiceImpl implements ISizeService {
LOGGER.info("saveOrUpdateSize param = {}", sizeRequestBo);
Size size = OrikaUtils.map(sizeRequestBo, Size.class);
if (size.getId() == null || size.getId() == 0) {
// 判断排序值是否已存在
List<Size> sizeList = ufoSizeMapper.getOrderBySortLevel2Id(size.getSortId());
List<Integer> orderBys = sizeList.stream().map(size1 -> size1.getOrderBy()).collect(Collectors.toList());
if (orderBys.contains(size.getOrderBy())) {
throw new ServiceException(201, "排序值" + size.getOrderBy() + "已存在!");
}
size.setCreateTime(DateUtil.currentTimeSeconds());
size.setUpdateTime(size.getCreateTime());
// 新增
return ufoSizeMapper.insertSize(size);
} else {
List<Size> sizeList = ufoSizeMapper.getOrderBySortLevel2Id(size.getSortId());
for (Size size1 : sizeList) {
if (!size1.getId().equals(size.getId())) {
if (size1.getOrderBy().equals(size.getOrderBy())) {
throw new ServiceException(201, "排序值" + size.getOrderBy() + "已存在!");
}
}
}
// 更新
size.setUpdateTime(DateUtil.currentTimeSeconds());
return ufoSizeMapper.updateSize(size);
... ...
... ... @@ -75,7 +75,7 @@
}, function (data) {
$("#sizeEditForm").form("load", data.data);
$("#sizeEditForm #sortId").myCombobox('select', data.data.sortId);
$("#sizeEditForm #sortId").myCombobox('disable');
$("#sizeEditForm #sortId").myCombobox('readonly');
});
}
});
... ...
... ... @@ -61,7 +61,7 @@
contentType: "application/json",
dataType: "json",
type: "GET",
url: contextPath + '/productSort/getProductSortIdAndName',
url: contextPath + '/productSort/getLevel2SortIdAndName',
success: function (data) {
if (data.code != 200 || !data.data || data.data.length == 0) {
return;
... ...
... ... @@ -12,11 +12,8 @@
</tr>
<tr style="height: 60px">
<td width="10%">上传</td>
<td width="10%"><span style="color:red">*</span><label>上传</label></td>
<td width="50%">
<!--<input id="file" name="file" class="easyui-filebox" style="margin-left: 20px" data-options="buttonText: '请选择文件',width:300,onChange:function(){$('#importBtn').click()},onClickButton: function(){$('#uploadXlsx').filebox('reset')}"/> -->
<!--<a id="importBtn" class="btn-success" style="display:none"></a>-->
<input id="file" name="file" class="easyui-filebox" style="margin-left: 20px" data-options="buttonText: '请选择文件',width:300,onClickButton: function(){$('#file').filebox('reset')}"/> 
</td>
</tr>
... ... @@ -35,14 +32,6 @@
$(function () {
/*$("#downLoadFileModel").linkbutton({
text : "2.下载样例.xlsx",
iconCls : "icon-more",
onClick : function() {
window.open(contextPath + '/common/productId.xlsx');
}
});*/
// 隐藏域赋值
$('#productPoolEditForm #id').val(productPoolId);
... ... @@ -51,69 +40,6 @@
missingMessage: "商品池名称不能为空",
prompt: "请输入"
});
/*$("#importBtn").linkbutton({
text : "上传文件",
iconCls : "icon-more",
onClick : function() {
var input = window.self.$('input[name="uploadXlsx"]')[0];
if(!input){
return;
}
var files = input.files;
if(files.length == 0){
return;
}
var filename = files[0].name;
//文件的后缀名
var extension = filename.substr(filename.lastIndexOf(".")).toLowerCase();
if(extension != ".xlsx"){
window.self.$.messager.alert("提示消息","请选择xlsx类型文件!");
return;
}
//创建formdata
var form = new FormData();
form.append("file",input.files[0]);
//发送请求
$.ajax({
type: "POST",
url: contextPath + '/GoodsShelvesInfoController/uploadShelves.do',
data: form,
async: false,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(result) {
if(result.code == 200){
$("#shelvesListTable").datagrid("reload");
var msg = "添加成功"+result.data+"条,";
var errorMsg = result.message;
if(errorMsg != null && errorMsg != ""){
msg += "<br>";
msg += errorMsg;
}
$.messager.alert("提示消息",msg);
}else{
var msg = '<span style="color: red;font-weight: bold;">导入失败。请检查如下内容并重新导入:</span><br>'
msg += result.message;
$.messager.alert("导入失败提示",msg);
}
}
});
}
});*/
/*if (productPoolId > 0) {
$.post(contextPath + "/productPool/getProductPoolById", {
id: productPoolId
}, function (data) {
$("#productPoolEditForm").form("load", data.data);
});
}*/
});
</script>
\ No newline at end of file
... ...