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

广告投放页优化

上级 af1db774
...@@ -76,9 +76,9 @@ public class AdvertisementItemController { ...@@ -76,9 +76,9 @@ public class AdvertisementItemController {
public R saveBatch(@RequestParam("aId") String aId, @RequestParam("itemIds") String itemIds) { public R saveBatch(@RequestParam("aId") String aId, @RequestParam("itemIds") String itemIds) {
String itemIdArr[] = itemIds.split(","); String itemIdArr[] = itemIds.split(",");
for (int i = 0; i < itemIdArr.length; i++) { for (int i = 0; i < itemIdArr.length; i++) {
Map map=new HashMap(); Map map = new HashMap();
map.put("adId",aId); map.put("adId", aId);
map.put("itemId",itemIdArr[i]); map.put("itemId", itemIdArr[i]);
int count = advertisementItemService.getAdItemCount(map); int count = advertisementItemService.getAdItemCount(map);
if (count > 0) if (count > 0)
continue; continue;
...@@ -129,11 +129,25 @@ public class AdvertisementItemController { ...@@ -129,11 +129,25 @@ public class AdvertisementItemController {
@RequestMapping("/deleteByItem") @RequestMapping("/deleteByItem")
@ResponseBody @ResponseBody
public R deleteByItem(@RequestParam("itemId") String itemId) { public R deleteByItem(@RequestParam("itemId") String itemId, @RequestParam("adId") String adId) {
int res = advertisementItemService.deleteByItem(itemId); int res = advertisementItemService.deleteByItem(itemId, adId);
if (res > 0) { if (res > 0) {
return R.ok(); return R.ok();
} }
return R.error("操作失败"); return R.error("操作失败");
} }
@RequestMapping("/setItemTop")
@ResponseBody
public R setItemTop(@RequestParam("itemId") String itemId,
@RequestParam("adId") String adId) {
int res = advertisementItemService.setItemTop(itemId, adId);
if (res > 0) {
return R.ok();
} else if (res == -1) {
return R.error("最多置顶60个商品");
}
return R.error("操作失败");
}
} }
...@@ -15,5 +15,13 @@ public interface AdvertisementItemDao extends BaseDao<AdvertisementItemEntity> { ...@@ -15,5 +15,13 @@ public interface AdvertisementItemDao extends BaseDao<AdvertisementItemEntity> {
int getAdItemCount(Map<String, Object> map); int getAdItemCount(Map<String, Object> map);
int deleteByItem(String itemId); int deleteByItem(@Param("itemId") String itemId, @Param("adId") String adId);
int getMaxSort();
int setItemTop(@Param("top") Integer top, @Param("itemId") String itemId, @Param("adId") String adId);
AdvertisementItemEntity getAdItemById(@Param("itemId") String itemId, @Param("adId") String adId);
int updateAdItem(AdvertisementItemEntity advertisementItemEntity);
} }
...@@ -8,7 +8,7 @@ import java.util.Date; ...@@ -8,7 +8,7 @@ import java.util.Date;
* 表名 advertisement_item * 表名 advertisement_item
* *
* @author lipengjun * @author lipengjun
* @date 2020-09-25 14:48:21 * @date 2020-10-07 15:50:04
*/ */
public class AdvertisementItemEntity implements Serializable { public class AdvertisementItemEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -21,6 +21,14 @@ public class AdvertisementItemEntity implements Serializable { ...@@ -21,6 +21,14 @@ public class AdvertisementItemEntity implements Serializable {
* 商品ID * 商品ID
*/ */
private String itemId; private String itemId;
/**
* 置顶
*/
private Integer isTop;
/**
* 排序
*/
private Integer sort;
/** /**
* 设置:广告投放ID * 设置:广告投放ID
...@@ -48,6 +56,30 @@ public class AdvertisementItemEntity implements Serializable { ...@@ -48,6 +56,30 @@ public class AdvertisementItemEntity implements Serializable {
public String getItemId() { public String getItemId() {
return itemId; return itemId;
} }
/**
* 设置:置顶
*/
public void setIsTop(Integer isTop) {
this.isTop = isTop;
}
/**
* 获取:置顶
*/
public Integer getIsTop() {
return isTop;
}
/**
* 设置:排序
*/
public void setSort(Integer sort) {
this.sort = sort;
}
/**
* 获取:排序
*/
public Integer getSort() {
return sort;
}
} }
...@@ -12,6 +12,8 @@ public class TbCfStationItemEntityExtends extends TbCfStationItemEntity implemen ...@@ -12,6 +12,8 @@ public class TbCfStationItemEntityExtends extends TbCfStationItemEntity implemen
private String itemDesc; private String itemDesc;
private BigDecimal discountPrice; private BigDecimal discountPrice;
private String uname; private String uname;
private Integer isTop;
private Integer sort;
public String getUname() { public String getUname() {
return uname; return uname;
...@@ -62,4 +64,22 @@ public class TbCfStationItemEntityExtends extends TbCfStationItemEntity implemen ...@@ -62,4 +64,22 @@ public class TbCfStationItemEntityExtends extends TbCfStationItemEntity implemen
public void setGoodtype(String goodtype) { public void setGoodtype(String goodtype) {
this.goodtype = goodtype; this.goodtype = goodtype;
} }
public Integer getIsTop() {
return isTop;
}
public void setIsTop(Integer isTop) {
this.isTop = isTop;
}
@Override
public Integer getSort() {
return sort;
}
@Override
public void setSort(Integer sort) {
this.sort = sort;
}
} }
package com.platform.service; package com.platform.service;
import com.platform.entity.AdvertisementItemEntity; import com.platform.entity.AdvertisementItemEntity;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -71,5 +72,7 @@ public interface AdvertisementItemService { ...@@ -71,5 +72,7 @@ public interface AdvertisementItemService {
int getAdItemCount(Map<String, Object> map); int getAdItemCount(Map<String, Object> map);
int deleteByItem(String itemId); int deleteByItem(String itemId, String adId);
int setItemTop(String itemId, String adId);
} }
...@@ -4,9 +4,11 @@ import com.platform.dao.AdvertisementItemDao; ...@@ -4,9 +4,11 @@ import com.platform.dao.AdvertisementItemDao;
import com.platform.entity.AdvertisementItemEntity; import com.platform.entity.AdvertisementItemEntity;
import com.platform.service.AdvertisementItemService; import com.platform.service.AdvertisementItemService;
import com.platform.utils.IdUtil; import com.platform.utils.IdUtil;
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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -62,7 +64,38 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService { ...@@ -62,7 +64,38 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService {
} }
@Override @Override
public int deleteByItem(String itemId) { public int deleteByItem(String itemId, String adId) {
return advertisementItemDao.deleteByItem(itemId); return advertisementItemDao.deleteByItem(itemId, adId);
}
@Override
public int setItemTop(String itemId, String adId) {
if (StringUtils.isBlank(itemId) || StringUtils.isBlank(adId)) {
return 0;
}
AdvertisementItemEntity byId = advertisementItemDao.getAdItemById(itemId, adId);
if (byId == null) {
return 0;
}
String top = byId.getIsTop().toString();
//置顶
if ("0".equals(top)) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("adId", adId);
paramMap.put("itemId", itemId);
int count = advertisementItemDao.getAdItemCount(paramMap);
//最多置顶60个
if (count >= 60) {
return -1;
}
int maxSort = advertisementItemDao.getMaxSort();
byId.setSort(++maxSort);
byId.setIsTop(1);
} else {
//取消置顶
byId.setSort(0);
byId.setIsTop(0);
}
return advertisementItemDao.updateAdItem(byId);
} }
} }
...@@ -6,16 +6,31 @@ ...@@ -6,16 +6,31 @@
<resultMap type="com.platform.entity.AdvertisementItemEntity" id="advertisementItemMap"> <resultMap type="com.platform.entity.AdvertisementItemEntity" id="advertisementItemMap">
<result property="adId" column="ad_id"/> <result property="adId" column="ad_id"/>
<result property="itemId" column="item_id"/> <result property="itemId" column="item_id"/>
<result property="isTop" column="is_top"/>
<result property="sort" column="sort"/>
</resultMap> </resultMap>
<select id="queryObject" resultType="com.platform.entity.AdvertisementItemEntity"> <select id="queryObject" resultType="com.platform.entity.AdvertisementItemEntity">
select select
`ad_id`, `ad_id`,
`item_id` `item_id`,
`is_top`,
`sort`
from advertisement_item from advertisement_item
where ad_id = #{id} where ad_id = #{id}
</select> </select>
<select id="getAdItemById" resultType="com.platform.entity.AdvertisementItemEntity">
select
`ad_id`,
`item_id`,
`is_top`,
`sort`
from advertisement_item
where ad_id = #{adId}
and item_id=#{itemId}
</select>
<select id="getAdItemCount" resultType="int"> <select id="getAdItemCount" resultType="int">
select count(1) from advertisement_item where ad_id = #{adId} select count(1) from advertisement_item where ad_id = #{adId}
<if test="itemId != null and itemId.trim() != ''"> <if test="itemId != null and itemId.trim() != ''">
...@@ -23,15 +38,24 @@ ...@@ -23,15 +38,24 @@
</if> </if>
</select> </select>
<update id="setItemTop">
update advertisement_item set is_top=#{top} where item_id=#{itemId} and ad_id=#{adId}
</update>
<select id="getMaxSort" resultType="int">
select max(sort) from advertisement_item
</select>
<delete id="deleteByItem"> <delete id="deleteByItem">
delete from advertisement_item where item_id=#{itemId} delete from advertisement_item where item_id=#{itemId} and ad_id=#{adId}
</delete> </delete>
<select id="queryList" resultType="com.platform.entity.AdvertisementItemEntity"> <select id="queryList" resultType="com.platform.entity.AdvertisementItemEntity">
select select
`ad_id`, `ad_id`,
`item_id` `item_id`,
`is_top`,
`sort`
from advertisement_item from advertisement_item
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
...@@ -61,20 +85,35 @@ ...@@ -61,20 +85,35 @@
<insert id="save" parameterType="com.platform.entity.AdvertisementItemEntity"> <insert id="save" parameterType="com.platform.entity.AdvertisementItemEntity">
insert into advertisement_item( insert into advertisement_item(
`ad_id`, `ad_id`,
`item_id`) `item_id`,
`is_top`,
`sort`)
values( values(
#{adId}, #{adId},
#{itemId}) #{itemId},
#{isTop},
#{sort})
</insert> </insert>
<update id="update" parameterType="com.platform.entity.AdvertisementItemEntity"> <update id="update" parameterType="com.platform.entity.AdvertisementItemEntity">
update advertisement_item update advertisement_item
<set> <set>
<if test="itemId != null">`item_id` = #{itemId}</if> <if test="itemId != null">`item_id` = #{itemId},</if>
<if test="isTop != null">`is_top` = #{isTop},</if>
<if test="sort != null">`sort` = #{sort}</if>
</set> </set>
where ad_id = #{adId} where ad_id = #{adId}
</update> </update>
<update id="updateAdItem" parameterType="com.platform.entity.AdvertisementItemEntity">
update advertisement_item
<set>
<if test="isTop != null">`is_top` = #{isTop},</if>
<if test="sort != null">`sort` = #{sort}</if>
</set>
where ad_id = #{adId} and item_id = #{itemId}
</update>
<delete id="delete"> <delete id="delete">
delete from advertisement_item where ad_id = #{value} delete from advertisement_item where ad_id = #{value}
</delete> </delete>
......
...@@ -93,13 +93,16 @@ ...@@ -93,13 +93,16 @@
i.`creator`, i.`creator`,
d.descripition_name dname, d.descripition_name dname,
t.goodstwotype_title title, t.goodstwotype_title title,
o.goodstype_title goodtype o.goodstype_title goodtype,
a.is_top,
a.sort
from advertisement_item a from advertisement_item a
left join tb_cf_station_item i on i.item_id=a.item_id left join tb_cf_station_item i on i.item_id=a.item_id
left JOIN tb_cf_goodstype o ON o.goodstype_id = i.item_category left JOIN tb_cf_goodstype o ON o.goodstype_id = i.item_category
left JOIN tb_cf_goodstwotype t ON i.item_categorytwo=t.goodstwotype_id left JOIN tb_cf_goodstwotype t ON i.item_categorytwo=t.goodstwotype_id
left JOIN tb_cf_descripiton d ON i.item_descrition_id=d.descripition_id left JOIN tb_cf_descripiton d ON i.item_descrition_id=d.descripition_id
where a.ad_id=#{adId} and i.enable_flag!=0 where a.ad_id=#{adId} and i.enable_flag!=0
order by a.is_top desc,a.sort desc,i.create_time desc
<if test="offset != null and limit != null"> <if test="offset != null and limit != null">
limit #{offset}, #{limit} limit #{offset}, #{limit}
</if> </if>
......
...@@ -130,18 +130,16 @@ let vm = new Vue({ ...@@ -130,18 +130,16 @@ let vm = new Vue({
} }
}, },
methods: { methods: {
delItem(id) { delItem(itemId) {
let id = getSelectedRow("#jqGrid");
confirm('确定要删除选中的记录?', function () { confirm('确定要删除选中的记录?', function () {
Ajax.request({ Ajax.request({
url: "../advertisementitem/deleteByItem?itemId=" + id, url: "../advertisementitem/deleteByItem?itemId=" + itemId + '&adId=' + id,
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
successCallback: function () { successCallback: function () {
alert('操作成功', function (index) { alert('操作成功', function (index) {
let page = $("#adItemjqGrid").jqGrid('getGridParam', 'page'); vm.btn_Search(id);
$("#adItemjqGrid").jqGrid('setGridParam', {
page: page
}).trigger("reloadGrid");
}); });
} }
}); });
...@@ -273,7 +271,12 @@ let vm = new Vue({ ...@@ -273,7 +271,12 @@ let vm = new Vue({
{ {
label: '操作', index: 'operate', width: 120, formatter: function (value, grid, rows) { label: '操作', index: 'operate', width: 120, formatter: function (value, grid, rows) {
return '<span class="label label-info pointer" onclick="vm.delItem(\'' + rows.itemId + '\')">移除</span>&nbsp;&nbsp;' if (rows.isTop == 1) {
return '<span class="label label-danger pointer" onclick="vm.itemTop(\'' + rows.itemId + '\')">取消置顶</span>&nbsp;&nbsp;' +
'<span class="label label-info pointer" onclick="vm.delItem(\'' + rows.itemId + '\')">移除</span>&nbsp;&nbsp;'
}
return '<span class="label label-info pointer" onclick="vm.itemTop(\'' + rows.itemId + '\')">置顶</span>&nbsp;&nbsp;' +
'<span class="label label-info pointer" onclick="vm.delItem(\'' + rows.itemId + '\')">移除</span>&nbsp;&nbsp;'
} }
} }
], ],
...@@ -283,6 +286,19 @@ let vm = new Vue({ ...@@ -283,6 +286,19 @@ let vm = new Vue({
vm.btn_Search(id); vm.btn_Search(id);
vm.getInfo(id); vm.getInfo(id);
}, },
itemTop(itemId) {
let id = getSelectedRow("#jqGrid");
let url = '../advertisementitem/setItemTop?itemId=' + itemId + '&adId=' + id;
Ajax.request({
url: url,
type: "GET",
contentType: "application/json",
successCallback: function (resultData) {
vm.btn_Search(id);
!notShowMessage ? iview.Message.success(resultData.success) : null;
}
});
},
saveOrUpdate: function (event) { saveOrUpdate: function (event) {
if (vm.advertisement.adName == null || vm.advertisement.adName == '') { if (vm.advertisement.adName == null || vm.advertisement.adName == '') {
alert("广告名称不能为空") alert("广告名称不能为空")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论