提交 e0cc9a85 authored 作者: 吴德鹏's avatar 吴德鹏

运费管理

上级 1984b7c3
...@@ -106,4 +106,16 @@ public class TbCfExpressTemplateController { ...@@ -106,4 +106,16 @@ public class TbCfExpressTemplateController {
return R.ok().put("list", list); return R.ok().put("list", list);
} }
@RequestMapping("/placedTop/{id}")
@ResponseBody
public R placedTop(@PathVariable("id") String id) {
int i = tbCfExpressTemplateService.placedTop(id);
if (i > 0) {
return R.ok();
} else if (i == -1) {
return R.error("最多只有一个默认模板");
}
return R.error("操作失败");
}
} }
...@@ -10,4 +10,5 @@ import com.platform.entity.TbCfExpressTemplateEntity; ...@@ -10,4 +10,5 @@ import com.platform.entity.TbCfExpressTemplateEntity;
*/ */
public interface TbCfExpressTemplateDao extends BaseDao<TbCfExpressTemplateEntity> { public interface TbCfExpressTemplateDao extends BaseDao<TbCfExpressTemplateEntity> {
int getDefaultCount();
} }
package com.platform.service; package com.platform.service;
import com.platform.entity.TbCfExpressTemplateEntity; import com.platform.entity.TbCfExpressTemplateEntity;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -68,4 +69,6 @@ public interface TbCfExpressTemplateService { ...@@ -68,4 +69,6 @@ public interface TbCfExpressTemplateService {
* @return 删除条数 * @return 删除条数
*/ */
int deleteBatch(String[] templateIds); int deleteBatch(String[] templateIds);
int placedTop(String id);
} }
...@@ -4,9 +4,12 @@ import com.platform.dao.TbCfExpressTemplateDao; ...@@ -4,9 +4,12 @@ import com.platform.dao.TbCfExpressTemplateDao;
import com.platform.entity.TbCfExpressTemplateEntity; import com.platform.entity.TbCfExpressTemplateEntity;
import com.platform.service.TbCfExpressTemplateService; import com.platform.service.TbCfExpressTemplateService;
import com.platform.utils.IdUtil; import com.platform.utils.IdUtil;
import com.platform.utils.util.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -38,12 +41,17 @@ public class TbCfExpressTemplateServiceImpl implements TbCfExpressTemplateServic ...@@ -38,12 +41,17 @@ public class TbCfExpressTemplateServiceImpl implements TbCfExpressTemplateServic
@Override @Override
public int save(TbCfExpressTemplateEntity tbCfExpressTemplate) { public int save(TbCfExpressTemplateEntity tbCfExpressTemplate) {
tbCfExpressTemplate.setTemplateId(tbCfExpressTemplate.getTemplateId()); tbCfExpressTemplate.setTemplateId(IdUtil.createIdbyUUID());
tbCfExpressTemplate.setIsDefault(0);
tbCfExpressTemplate.setStatus(1);
tbCfExpressTemplate.setCreateTime(new Date());
tbCfExpressTemplate.setUpdateTime(new Date());
return tbCfExpressTemplateDao.save(tbCfExpressTemplate); return tbCfExpressTemplateDao.save(tbCfExpressTemplate);
} }
@Override @Override
public int update(TbCfExpressTemplateEntity tbCfExpressTemplate) { public int update(TbCfExpressTemplateEntity tbCfExpressTemplate) {
tbCfExpressTemplate.setUpdateTime(new Date());
return tbCfExpressTemplateDao.update(tbCfExpressTemplate); return tbCfExpressTemplateDao.update(tbCfExpressTemplate);
} }
...@@ -56,4 +64,26 @@ public class TbCfExpressTemplateServiceImpl implements TbCfExpressTemplateServic ...@@ -56,4 +64,26 @@ public class TbCfExpressTemplateServiceImpl implements TbCfExpressTemplateServic
public int deleteBatch(String[] templateIds) { public int deleteBatch(String[] templateIds) {
return tbCfExpressTemplateDao.deleteBatch(templateIds); return tbCfExpressTemplateDao.deleteBatch(templateIds);
} }
@Override
public int placedTop(String id) {
int res = 0;
if (StringUtils.isBlank(id)) {
return res;
}
TbCfExpressTemplateEntity express = tbCfExpressTemplateDao.queryObject(id);
System.err.println(express.getIsDefault().toString());
if ("0".equals(express.getIsDefault().toString())) {
int count = tbCfExpressTemplateDao.getDefaultCount();
if (count >= 1) {
res = -1;
return res;
}
express.setIsDefault(1);
} else {
express.setIsDefault(0);
}
res = tbCfExpressTemplateDao.update(express);
return res;
}
} }
...@@ -41,7 +41,9 @@ ...@@ -41,7 +41,9 @@
from tb_cf_express_template from tb_cf_express_template
where template_id = #{id} where template_id = #{id}
</select> </select>
<select id="getDefaultCount" resultType="int">
select count(*) from tb_cf_express_template where is_default=1 and status=1
</select>
<select id="queryList" resultType="com.platform.entity.TbCfExpressTemplateEntity"> <select id="queryList" resultType="com.platform.entity.TbCfExpressTemplateEntity">
select select
`template_id`, `template_id`,
...@@ -62,14 +64,14 @@ ...@@ -62,14 +64,14 @@
from tb_cf_express_template from tb_cf_express_template
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%') AND template_title LIKE concat('%',#{name},'%')
</if> </if>
<choose> <choose>
<when test="sidx != null and sidx.trim() != ''"> <when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order} order by ${sidx} ${order}
</when> </when>
<otherwise> <otherwise>
order by is_default order by is_default desc
</otherwise> </otherwise>
</choose> </choose>
<if test="offset != null and limit != null"> <if test="offset != null and limit != null">
...@@ -81,7 +83,7 @@ ...@@ -81,7 +83,7 @@
select count(*) from tb_cf_express_template select count(*) from tb_cf_express_template
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%') AND template_title LIKE concat('%',#{name},'%')
</if> </if>
</select> </select>
......
...@@ -36,11 +36,12 @@ ...@@ -36,11 +36,12 @@
<Form-item label="模板标题" prop="templateTitle"> <Form-item label="模板标题" prop="templateTitle">
<i-input v-model="tbCfExpressTemplate.templateTitle" placeholder="模板标题" style="width:300px"/> <i-input v-model="tbCfExpressTemplate.templateTitle" placeholder="模板标题" style="width:300px"/>
</Form-item> </Form-item>
<Form-item label="计费方式" prop="tbCfExpressTemplate.type"> <Form-item label="计费方式" prop="type">
<!--<i-input v-model="tbCfExpressTemplate.type" placeholder="计费方式" style="width:300px"/>--> <i-select placeholder="请选择" v-model="tbCfExpressTemplate.type" style="width:300px">
<Radio-group v-model="type"> <i-option v-for=" e in typeList"
<Radio v-for="e in typeList" :label="e.label" :value="e.value"></Radio> :value="e.value">{{e.label}}
</Radio-group> </i-option>
</i-select>
</Form-item> </Form-item>
<Form-item label="起始数量" prop="startNum"> <Form-item label="起始数量" prop="startNum">
<i-input v-model="tbCfExpressTemplate.startNum" placeholder="起始数量" style="width:300px"/> <i-input v-model="tbCfExpressTemplate.startNum" placeholder="起始数量" style="width:300px"/>
......
...@@ -44,13 +44,14 @@ $(function () { ...@@ -44,13 +44,14 @@ $(function () {
{label: '续件运费(美金)', name: 'continuationFee', index: 'continuation_fee', width: 80}, {label: '续件运费(美金)', name: 'continuationFee', index: 'continuation_fee', width: 80},
{label: '免邮价格', name: 'postageFreePrice', index: 'postage_free_price', width: 80}, {label: '免邮价格', name: 'postageFreePrice', index: 'postage_free_price', width: 80},
{label: '创建日期', name: 'createTime', index: 'create_time', width: 80}, {label: '创建日期', name: 'createTime', index: 'create_time', width: 80},
{label: '最后编辑时间', name: 'updateTime', index: 'update_time', width: 80}, // {label: '最后编辑时间', name: 'updateTime', index: 'update_time', width: 80},
{ {
label: '操作', index: 'operate', width: 80, formatter: function (value, grid, rows) { label: '操作', index: 'operate', width: 80, formatter: function (value, grid, rows) {
if (rows.type === 0) { if (rows.isDefault === 1) {
return '<span class="label label-danger pointer" ">默认</span>&nbsp;&nbsp;'; return '<span class="label label-danger pointer" ">默认</span>&nbsp;&nbsp;' +
'<span class="label label-primary pointer" onclick="vm.placedTop(\'' + rows.templateId + '\')">取消默认</span>';
} }
return '<span class="label label-info pointer" ">设置默认</span>&nbsp;&nbsp;'; return '<span class="label label-info pointer" onclick="vm.placedTop(\'' + rows.templateId + '\')">设置默认</span>&nbsp;&nbsp;';
} }
}] }]
}); });
...@@ -59,14 +60,14 @@ $(function () { ...@@ -59,14 +60,14 @@ $(function () {
let vm = new Vue({ let vm = new Vue({
el: '#rrapp', el: '#rrapp',
data: { data: {
type: null, type: '',
typeList: [{ typeList: [{
label: '计件', value: '0',
value: '0' label: '计件'
}, },
{ {
label: '计重', value: '1',
value: '1' label: '计重'
}], }],
showList: true, showList: true,
title: null, title: null,
...@@ -81,6 +82,19 @@ let vm = new Vue({ ...@@ -81,6 +82,19 @@ let vm = new Vue({
} }
}, },
methods: { methods: {
placedTop: function (id) {
let url = '../tbcfexpresstemplate/placedTop/' + id;
Ajax.request({
url: url,
type: "GET",
contentType: "application/json",
successCallback: function () {
alert('操作成功', function (index) {
vm.reload();
});
}
})
},
query: function () { query: function () {
vm.reload(); vm.reload();
}, },
...@@ -146,6 +160,11 @@ let vm = new Vue({ ...@@ -146,6 +160,11 @@ let vm = new Vue({
async: true, async: true,
successCallback: function (r) { successCallback: function (r) {
vm.tbCfExpressTemplate = r.tbCfExpressTemplate; vm.tbCfExpressTemplate = r.tbCfExpressTemplate;
// let type = vm.tbCfExpressTemplate.type;
// this.typeList.map(res=>{
// res.value
// })
} }
}); });
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论