فهرست منبع

投票记录恢复/废弃

xiaoqiang 4 سال پیش
والد
کامیت
9fe55c8030

+ 21 - 2
src/main/java/org/springblade/sing/active/controller/ActiveHelpRecordController.java

@@ -39,6 +39,7 @@ import org.springblade.sing.goods.service.IHelpGoodsService;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import java.util.List;
 
 /**
  * 活动助力记录 控制器
@@ -93,8 +94,6 @@ public class ActiveHelpRecordController extends BladeController {
 	@ApiOperationSupport(order = 3)
 	@ApiOperation(value = "分页", notes = "传入activeHelpRecord")
 	public R<IPage<ActiveHelpRecordVO>> page(ActiveHelpRecordVO activeHelpRecord, Query query) {
-		System.out.println(activeHelpRecord.getBeginTime());
-		System.out.println(activeHelpRecord.getLastTime());
 		IPage<ActiveHelpRecordVO> pages = activeHelpRecordService.selectActiveHelpRecordPage(Condition.getPage(query), activeHelpRecord);
 		return R.data(pages);
 	}
@@ -148,4 +147,24 @@ public class ActiveHelpRecordController extends BladeController {
 		return R.data(activeHelpRecordService.productVote(productId));
 	}
 
+	@PostMapping("/recordHide")
+	public R recordHide(@RequestParam List<Long> recordIds){
+		return R.status(activeHelpRecordService.recordHide(recordIds));
+	}
+
+	@PostMapping("/recordShow")
+	public R recordShow(@RequestParam List<Long> recordIds){
+		return R.status(activeHelpRecordService.recordShow(recordIds));
+	}
+
+	@PostMapping("/recordHideByIp")
+	public R recordHideByIp(@RequestParam List<String> ips){
+		return R.status(activeHelpRecordService.recordHideByIp(ips));
+	}
+
+	@PostMapping("/recordShowByIp")
+	public R recordShowByIp(@RequestParam List<String> ips){
+		return R.status(activeHelpRecordService.recordShowByIp(ips));
+	}
+
 }

+ 3 - 0
src/main/java/org/springblade/sing/active/entity/ProductVote.java

@@ -54,4 +54,7 @@ public class ProductVote extends BaseEntity {
 
 		@ApiModelProperty(value = "投票次数")
 		private String count;
+
+		@ApiModelProperty(value = "投票次数")
+		private Integer status;
 }

+ 6 - 5
src/main/java/org/springblade/sing/active/mapper/ActiveHelpRecordMapper.xml

@@ -23,10 +23,11 @@
     </resultMap>
 
     <resultMap id="productVoteResultMap" type="org.springblade.sing.active.entity.ProductVote">
-        <result column="productName" property="productName"/>
+        <result column="product_name" property="productName"/>
         <result column="ip" property="ip"/>
-        <result column="productNo" property="productNo"/>
-        <result column="count" property="count"/>
+        <result column="product_no" property="productNo"/>
+        <result column="t_count" property="count"/>
+        <result column="t_status" property="status"/>
     </resultMap>
 
 
@@ -53,10 +54,10 @@
 
 
     <select id="selectVote" resultMap="productVoteResultMap">
-        SELECT p.title productName,p.product_no productNo,ip,count(*) count FROM `sing_active_help_record` h
+        SELECT p.product_no product_no,p.title product_name,h.ip,count(0) t_count,h.status t_status FROM sing_active_help_record h
         left join sing_active_product_record p on h.product_id = p.id
         WHERE product_id = #{productId}
-        group by ip order by count desc
+        group by h.ip,h.status order by t_count desc
     </select>
 
 </mapper>

+ 23 - 0
src/main/java/org/springblade/sing/active/service/IActiveHelpRecordService.java

@@ -47,4 +47,27 @@ public interface IActiveHelpRecordService extends BaseService<ActiveHelpRecord>
 	 * @return
 	 */
 	List<ProductVote> productVote(Long productId);
+
+	/**
+	 * 投票记录废弃
+	 * @param recordIds
+	 * @return
+	 */
+    boolean recordHide(List<Long> recordIds);
+
+	/**
+	 * 投票记录恢复
+	 * @param recordIds
+	 * @return
+	 */
+	boolean recordShow(List<Long> recordIds);
+
+	/**
+	 * 投票记录废弃
+	 * @param ips
+	 * @return
+	 */
+	boolean recordHideByIp(List<String> ips);
+
+	boolean recordShowByIp(List<String> ips);
 }

+ 82 - 0
src/main/java/org/springblade/sing/active/service/impl/ActiveHelpRecordServiceImpl.java

@@ -16,15 +16,24 @@
  */
 package org.springblade.sing.active.service.impl;
 
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import io.jsonwebtoken.lang.Assert;
 import org.springblade.sing.active.entity.ActiveHelpRecord;
+import org.springblade.sing.active.entity.ActiveProductRecord;
 import org.springblade.sing.active.entity.ProductVote;
+import org.springblade.sing.active.service.IActiveProductRecordService;
 import org.springblade.sing.active.vo.ActiveHelpRecordVO;
 import org.springblade.sing.active.mapper.ActiveHelpRecordMapper;
 import org.springblade.sing.active.service.IActiveHelpRecordService;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -36,6 +45,9 @@ import java.util.List;
 @Service
 public class ActiveHelpRecordServiceImpl extends BaseServiceImpl<ActiveHelpRecordMapper, ActiveHelpRecord> implements IActiveHelpRecordService {
 
+	@Autowired
+	private IActiveProductRecordService activeProductRecordService;
+
 	@Override
 	public IPage<ActiveHelpRecordVO> selectActiveHelpRecordPage(IPage<ActiveHelpRecordVO> page, ActiveHelpRecordVO activeHelpRecord) {
 		return page.setRecords(baseMapper.selectActiveHelpRecordPage(page, activeHelpRecord));
@@ -46,4 +58,74 @@ public class ActiveHelpRecordServiceImpl extends BaseServiceImpl<ActiveHelpRecor
 		return baseMapper.selectVote(productId);
     }
 
+    @Override
+    public boolean recordHide(List<Long> recordIds) {
+		Assert.notNull(recordIds,"请选择助力记录");
+		List<ActiveHelpRecord> activeHelpRecords = super.listByIds(recordIds);
+		Assert.notNull(activeHelpRecords,"此助力记录已失效");
+
+		statusHide(activeHelpRecords);
+		return super.updateBatchById(activeHelpRecords);
+	}
+
+	@Override
+	public boolean recordShow(List<Long> recordIds) {
+		Assert.notNull(recordIds,"请选择助力记录");
+		List<ActiveHelpRecord> activeHelpRecords = super.listByIds(recordIds);
+		Assert.notNull(activeHelpRecords,"此助力记录已失效");
+
+		statusShow(activeHelpRecords);
+		return super.updateBatchById(activeHelpRecords);
+	}
+
+	@Override
+	public boolean recordHideByIp(List<String> ips) {
+		List<ActiveHelpRecord> activeHelpRecords = new ArrayList<>();
+		for (String ip : ips) {
+			List<ActiveHelpRecord> list = super.list(new LambdaQueryWrapper<ActiveHelpRecord>().eq(ActiveHelpRecord::getIp, ip));
+			statusHide(list);
+			activeHelpRecords.addAll(list);
+		}
+
+		return super.updateBatchById(activeHelpRecords);
+	}
+
+	@Override
+	public boolean recordShowByIp(List<String> ips) {
+		List<ActiveHelpRecord> activeHelpRecords = new ArrayList<>();
+		for (String ip : ips) {
+			List<ActiveHelpRecord> list = super.list(new LambdaQueryWrapper<ActiveHelpRecord>().eq(ActiveHelpRecord::getIp, ip));
+			statusShow(list);
+			activeHelpRecords.addAll(list);
+		}
+		return super.updateBatchById(activeHelpRecords);
+	}
+
+	//恢复票数
+	private void statusShow(List<ActiveHelpRecord> list) {
+		for (ActiveHelpRecord activeHelpRecord : list) {
+			if (activeHelpRecord.getStatus() == 0){
+				activeHelpRecord.setStatus(1);
+				//更新作品票数
+				ActiveProductRecord productRecord = activeProductRecordService.getById(activeHelpRecord.getProductId());
+				productRecord.setVoteCount(productRecord.getVoteCount() + activeHelpRecord.getVoteCount());
+				activeProductRecordService.updateById(productRecord);
+			}
+		}
+	}
+
+	//减去票数
+	private void statusHide(List<ActiveHelpRecord> list) {
+		for (ActiveHelpRecord activeHelpRecord : list) {
+			if (activeHelpRecord.getStatus() == 1){
+				activeHelpRecord.setStatus(0);
+				//更新作品票数
+				ActiveProductRecord productRecord = activeProductRecordService.getById(activeHelpRecord.getProductId());
+				productRecord.setVoteCount(productRecord.getVoteCount() - activeHelpRecord.getVoteCount());
+				activeProductRecordService.updateById(productRecord);
+			}
+		}
+	}
+
+
 }

+ 0 - 1
src/main/java/org/springblade/sing/goods/controller/PointGoodsController.java

@@ -96,7 +96,6 @@ public class PointGoodsController extends BladeController {
 		IPage<PointGoodsVO> pages = pointGoodsService.selectPointGoodsPage(Condition.getPage(query), pointGoods);
 		return R.data(pages);
 	}
-
 	/**
 	 * 新增 积分商城
 	 */