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

商品置顶

上级 aa02bcd0
...@@ -225,4 +225,73 @@ public class TbCfStationItemController extends ApiBaseAction { ...@@ -225,4 +225,73 @@ public class TbCfStationItemController extends ApiBaseAction {
List<SysUserEntity> userList = tbCfStationItemService.queryCreator(); List<SysUserEntity> userList = tbCfStationItemService.queryCreator();
return R.ok().put("list", userList); return R.ok().put("list", userList);
} }
/**
* 商品置顶:
* 1)设置itemTop 为 1
* 2)设置sort 为 置顶总数+1
*
* @return R
*/
@RequestMapping("/itemTop")
@ResponseBody
public R itemTop(@RequestParam("itemId") String itemId) {
int res = tbCfStationItemService.itemTop(itemId);
if (res > 0) {
return R.ok();
} else if (res == -1) {
return R.error("该商品已下架,不能置顶");
}
return R.error("置顶失败");
}
/**
* 取消置顶
*/
@RequestMapping("/cancelTop")
@ResponseBody
public R cancelTop(@RequestParam("itemId") String itemId) {
int res = tbCfStationItemService.cancelTop(itemId);
if (res > 0) {
return R.ok();
}
return R.error("取消置顶失败");
}
/**
* 商品向上
*
* @param itemId
* @return R
*/
@RequestMapping("/itemUpward")
@ResponseBody
public R itemUpward(@RequestParam("itemId") String itemId) {
int res = tbCfStationItemService.itemUpward(itemId);
if (res > 0) {
return R.ok();
} else if (res == -1) {
return R.error("商品已在顶部");
}
return R.error("交换失败");
}
/**
* 商品向下
*
* @param itemId
* @return R
*/
@RequestMapping("/itemDownward")
@ResponseBody
public R itemDownward(@RequestParam("itemId") String itemId) {
int res = tbCfStationItemService.itemDownward(itemId);
if (res > 0) {
return R.ok();
} else if (res == -1) {
return R.error("商品已在底部");
}
return R.error("交换失败");
}
} }
...@@ -26,4 +26,8 @@ public interface TbCfStationItemDao extends BaseDao<TbCfStationItemEntity> { ...@@ -26,4 +26,8 @@ public interface TbCfStationItemDao extends BaseDao<TbCfStationItemEntity> {
List<TbCfStationItemEntity> queryByCodeList(String code); List<TbCfStationItemEntity> queryByCodeList(String code);
List<TbCfStationItemEntity> getItemByIds(String[] ids); List<TbCfStationItemEntity> getItemByIds(String[] ids);
int queryTopCount();
TbCfStationItemEntity queryItemBySort(Integer sort);
} }
...@@ -97,5 +97,14 @@ public interface TbCfStationItemService { ...@@ -97,5 +97,14 @@ public interface TbCfStationItemService {
void importExcel(MultipartFile multipartFile); void importExcel(MultipartFile multipartFile);
R importShopifyProducts(MultipartFile multipartFile); R importShopifyProducts(MultipartFile multipartFile);
List<SysUserEntity> queryCreator(); List<SysUserEntity> queryCreator();
int itemTop(String itemId);
int cancelTop(String itemId);
int itemUpward(String itemId);
int itemDownward(String itemId);
} }
...@@ -476,5 +476,64 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService { ...@@ -476,5 +476,64 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
public List<SysUserEntity> queryCreator() { public List<SysUserEntity> queryCreator() {
return sysUserDao.queryList(null); return sysUserDao.queryList(null);
} }
@Override
public int itemTop(String itemId) {
TbCfStationItemEntity item = tbCfStationItemDao.queryObject(itemId);
if ("2".equals(item.getEnableFlag().toString())) {
return -1;
}
item.setItemTop(1);
int count = tbCfStationItemDao.queryTopCount();
item.setSort(++count);
return tbCfStationItemDao.update(item);
}
@Override
public int cancelTop(String itemId) {
TbCfStationItemEntity item = tbCfStationItemDao.queryObject(itemId);
item.setItemTop(0);
item.setSort(0);
return tbCfStationItemDao.update(item);
}
@Override
public int itemUpward(String itemId) {
int res = 0;
TbCfStationItemEntity item = tbCfStationItemDao.queryObject(itemId);
Integer sort = item.getSort();
if ("1".equals(sort.toString())) {
return -1;
}
TbCfStationItemEntity upItem = tbCfStationItemDao.queryItemBySort(sort - 1);
upItem.setSort(sort);
int res1 = tbCfStationItemDao.update(upItem);
item.setSort(sort - 1);
int res2 = tbCfStationItemDao.update(item);
if (res1 > 0 && res2 > 0) {
res = 1;
}
return res;
}
@Override
public int itemDownward(String itemId) {
int res = 0;
TbCfStationItemEntity item = tbCfStationItemDao.queryObject(itemId);
Integer sort = item.getSort();
int count = tbCfStationItemDao.queryTopCount();
if (String.valueOf(count).equals(sort.toString())) {
return -1;
}
TbCfStationItemEntity downItem = tbCfStationItemDao.queryItemBySort(sort + 1);
downItem.setSort(sort);
int res1 = tbCfStationItemDao.update(downItem);
item.setSort(sort + 1);
int res2 = tbCfStationItemDao.update(item);
if (res1 > 0 && res2 > 0) {
res = 1;
}
return res;
}
} }
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
order by ${sidx} ${order} order by ${sidx} ${order}
</when> </when>
<otherwise> <otherwise>
order by i.item_top desc,i.sort asc order by i.item_top desc,i.sort asc,i.create_time desc
</otherwise> </otherwise>
</choose> </choose>
<if test="offset != null and limit != null"> <if test="offset != null and limit != null">
...@@ -205,6 +205,14 @@ ...@@ -205,6 +205,14 @@
i.item_id = #{itemId} i.item_id = #{itemId}
</select> </select>
<select id="queryTopCount" resultType="int">
select count(1) from tb_cf_station_item where item_top=1
</select>
<select id="queryItemBySort" resultType="com.platform.entity.ItemDescSkus">
select * from tb_cf_station_item where sort =#{sort} limit 1
</select>
<select id="queryTotal" resultType="int"> <select id="queryTotal" resultType="int">
select count(*) from tb_cf_station_item select count(*) from tb_cf_station_item
WHERE 1=1 and enable_flag!=0 WHERE 1=1 and enable_flag!=0
......
...@@ -15,7 +15,7 @@ $(function () { ...@@ -15,7 +15,7 @@ $(function () {
/*{label: '所属平台', name: 'platformCode', index: 'platform_code', width: 80}, /*{label: '所属平台', name: 'platformCode', index: 'platform_code', width: 80},
{label: '平台名', name: 'platformName', index: 'platform_name', width: 80},*/ {label: '平台名', name: 'platformName', index: 'platform_name', width: 80},*/
{label: '供应商', name: 'supplier', index: 'supplier', width: 80}, {label: '供应商', name: 'supplier', index: 'supplier', width: 80},
{label: '置顶', name: 'itemTop', index: 'item_top', width: 80,hidden: true}, {label: '置顶', name: 'itemTop', index: 'item_top', width: 80, hidden: true},
{label: '商品一级分类', name: 'goodtype', index: 'goodtype', width: 80}, {label: '商品一级分类', name: 'goodtype', index: 'goodtype', width: 80},
{label: '商品二级分类', name: 'title', index: 'title', width: 80}, {label: '商品二级分类', name: 'title', index: 'title', width: 80},
{label: '商品三级分类', name: 'dname', index: 'itemDescritionId', width: 80}, {label: '商品三级分类', name: 'dname', index: 'itemDescritionId', width: 80},
...@@ -25,14 +25,11 @@ $(function () { ...@@ -25,14 +25,11 @@ $(function () {
{ {
label: '操作', index: 'operate', width: 120, formatter: function (value, grid, rows) { label: '操作', index: 'operate', width: 120, formatter: function (value, grid, rows) {
if (rows.itemTop === 1) { if (rows.itemTop === 1) {
return '<span class="label label-danger pointer" onclick="vm.placedTop(\'' + rows.id + '\')">置顶</span>&nbsp;&nbsp;' + return '<span class="label label-primary pointer" onclick="vm.itemUpward(\'' + rows.itemId + '\')" ">up</span>&nbsp;&nbsp;' +
'<span class="label label-warning pointer" onclick="vm.off(\'' + rows.id + '\')" ">取消</span>&nbsp;&nbsp;' + '<span class="label label-success pointer" onclick="vm.itemDownward(\'' + rows.itemId + '\')" ">down</span>&nbsp;&nbsp' +
'<span class="label label-success pointer" onclick="vm.activate(\'' + rows.id + '\')" ">up</span>'+ '<span class="label label-danger pointer" onclick="vm.cancelTop(\'' + rows.itemId + '\')" ">取消置顶</span>&nbsp;&nbsp;';
'<span class="label label-warning pointer" onclick="vm.off(\'' + rows.id + '\')" ">down</span>&nbsp;&nbsp;';
} }
return '<span class="label label-info pointer" onclick="vm.placedTop(\'' + rows.id + '\')">置顶</span>&nbsp;&nbsp;' + return '<span class="label label-info pointer" onclick="vm.itemTop(\'' + rows.itemId + '\')">置顶</span>&nbsp;&nbsp;'
'<span class="label label-warning pointer" onclick="vm.off(\'' + rows.id + '\')" ">up</span>&nbsp;&nbsp;' +
'<span class="label label-success pointer" onclick="vm.activate(\'' + rows.id + '\')" ">down</span>';
} }
} }
] ]
...@@ -118,6 +115,58 @@ let vm = new Vue({ ...@@ -118,6 +115,58 @@ let vm = new Vue({
handleProductAttr_Batch: [], handleProductAttr_Batch: [],
}, },
methods: { methods: {
//商品置顶
itemTop(id) {
Ajax.request({
url: "../tbcfstationitem/itemTop?itemId=" + id,
type: "GET",
contentType: "application/json",
successCallback: function (resultData) {
vm.reload();
// console.log(resultData);
!notShowMessage ? iview.Message.success(resultData.success) : null;
}
});
},
//商品取消置顶
cancelTop(id) {
Ajax.request({
url: "../tbcfstationitem/cancelTop?itemId=" + id,
type: "GET",
contentType: "application/json",
successCallback: function (resultData) {
vm.reload();
// console.log(resultData);
!notShowMessage ? iview.Message.success(resultData.success) : null;
}
});
},
//商品向上
itemUpward(id) {
Ajax.request({
url: "../tbcfstationitem/itemUpward?itemId=" + id,
type: "GET",
contentType: "application/json",
successCallback: function (resultData) {
vm.reload();
// console.log(resultData);
!notShowMessage ? iview.Message.success(resultData.success) : null;
}
});
},
//商品向下
itemDownward(id) {
Ajax.request({
url: "../tbcfstationitem/itemDownward?itemId=" + id,
type: "GET",
contentType: "application/json",
successCallback: function (resultData) {
vm.reload();
// console.log(resultData);
!notShowMessage ? iview.Message.success(resultData.success) : null;
}
});
},
//保存批量操作价格的数据 //保存批量操作价格的数据
saveBatchDataPrice(e) { saveBatchDataPrice(e) {
if (this.batchAmount && this.batchCount) { if (this.batchAmount && this.batchCount) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论