|
|
@@ -16,7 +16,9 @@
|
|
|
*/
|
|
|
package org.springblade.sing.active.controller;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -27,8 +29,10 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springblade.common.utils.BeanPropertyUtil;
|
|
|
+import org.springblade.common.utils.ExcelWriteUtil;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
@@ -44,8 +48,10 @@ import org.springblade.sing.active.wrapper.ActiveProductRecordWrapper;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
@@ -60,6 +66,7 @@ import java.util.Optional;
|
|
|
@AllArgsConstructor
|
|
|
@RequestMapping("sing_active/activeproductrecord")
|
|
|
@Api(value = "活动作品", tags = "活动作品接口")
|
|
|
+@Slf4j
|
|
|
public class ActiveProductRecordController extends BladeController {
|
|
|
|
|
|
private final IActiveProductRecordService activeProductRecordService;
|
|
|
@@ -76,18 +83,18 @@ public class ActiveProductRecordController extends BladeController {
|
|
|
|
|
|
ActiveProductRecord detail = activeProductRecordService.getOne(Condition.getQueryWrapper(activeProductRecord));
|
|
|
|
|
|
- if (detail != null){
|
|
|
+ if (detail != null) {
|
|
|
//获取排名
|
|
|
String key = ActiveProductConstant.PRODUCT_SORT_CACHE_KEY.concat(":").concat(detail.getActiveId().toString());
|
|
|
Long revrank = bladeRedis.zRevrank(key, detail.getId());
|
|
|
|
|
|
ActiveProductRecordVO activeProductRecordVO = ActiveProductRecordWrapper.build().entityVO(detail);
|
|
|
- if (revrank != null){
|
|
|
+ if (revrank != null) {
|
|
|
activeProductRecordVO.setRank(revrank + 1);
|
|
|
}
|
|
|
return R.data(activeProductRecordVO);
|
|
|
}
|
|
|
- return R.data(null);
|
|
|
+ return R.data(null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -96,21 +103,55 @@ public class ActiveProductRecordController extends BladeController {
|
|
|
@GetMapping("/list")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
@ApiOperation(value = "分页", notes = "传入activeProductRecord")
|
|
|
- public R<IPage<ActiveProductRecordVO>> list(ActiveProductRecord activeProductRecord, Query query) {
|
|
|
+ public R<IPage<ActiveProductRecordVO>> list(ActiveProductRecord activeProductRecord, Query query,
|
|
|
+ Date createTimeStart, Date createTimeEnd, String key) {
|
|
|
LambdaQueryWrapper<ActiveProductRecord> activeProductRecordLambdaQueryWrapper = Condition.getQueryWrapper(activeProductRecord).lambda();
|
|
|
- if(StringUtils.isNotBlank(activeProductRecord.getTitle())){
|
|
|
- activeProductRecordLambdaQueryWrapper.like(ActiveProductRecord::getTitle,
|
|
|
- new StringBuilder("%").append(activeProductRecord.getTitle()).append("%").toString());
|
|
|
+ //添加创建时间条件
|
|
|
+ if (createTimeStart != null && createTimeEnd != null) {
|
|
|
+ activeProductRecordLambdaQueryWrapper.between(ActiveProductRecord::getCreateTime, createTimeStart, createTimeEnd);
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(activeProductRecord.getPhone())){
|
|
|
- activeProductRecordLambdaQueryWrapper.like(ActiveProductRecord::getPhone,
|
|
|
- new StringBuilder("%").append(activeProductRecord.getPhone()).append("%").toString());
|
|
|
+ //添加关键字key查询条件
|
|
|
+ if (StringUtils.isNotBlank(key)) {
|
|
|
+ activeProductRecordLambdaQueryWrapper.and(wq -> {
|
|
|
+ wq.eq(ActiveProductRecord::getTitle, new StringBuilder("%").append(key).append("%").toString()).
|
|
|
+ or().eq(ActiveProductRecord::getProductNo,key);
|
|
|
+ });
|
|
|
}
|
|
|
activeProductRecordLambdaQueryWrapper.orderByAsc(ActiveProductRecord::getProductNo);
|
|
|
- IPage<ActiveProductRecord> pages = activeProductRecordService.page(Condition.getPage(query),activeProductRecordLambdaQueryWrapper);
|
|
|
+ IPage<ActiveProductRecord> pages = activeProductRecordService.page(Condition.getPage(query), activeProductRecordLambdaQueryWrapper);
|
|
|
return R.data(ActiveProductRecordWrapper.build(bladeRedis).pageVO(pages));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成列表
|
|
|
+ */
|
|
|
+ @PostMapping("/generateList")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "生成列表", notes = "传入balanceBills")
|
|
|
+ public void generateList(ActiveProductRecord activeProductRecord,
|
|
|
+ Query query,
|
|
|
+ Date createTimeStart,
|
|
|
+ Date createTimeEnd,
|
|
|
+ String key,
|
|
|
+ @RequestParam String keyValue,
|
|
|
+ HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ R<IPage<ActiveProductRecordVO>> page = this.list(activeProductRecord, query, createTimeStart, createTimeEnd, key);
|
|
|
+ //判断是否为空
|
|
|
+ if (ObjectUtils.isNotEmpty(page) && ObjectUtils.isNotEmpty(page.getData()) && ObjectUtils.isNotEmpty(page.getData().getRecords())) {
|
|
|
+ //键值对
|
|
|
+ Map<String, String> titleMap = JSONObject.parseObject(keyValue, Map.class);
|
|
|
+ if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(titleMap)) {
|
|
|
+ //写入到Excel
|
|
|
+ ExcelWriteUtil.writeToResponse(response, DateUtil.now(), "提现记录表", titleMap, page.getData().getRecords(), ActiveProductRecordVO.class);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/getMyTotalHeat")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
@ApiOperation(value = "获取我获取的总热力值", notes = "传入activeProductRecord")
|
|
|
@@ -167,16 +208,17 @@ public class ActiveProductRecordController extends BladeController {
|
|
|
|
|
|
/**
|
|
|
* 设置活动作品编号
|
|
|
+ *
|
|
|
* @param activeProductRecord
|
|
|
* @return
|
|
|
*/
|
|
|
private ActiveProductRecord setProductNo(ActiveProductRecord activeProductRecord) {
|
|
|
- if(ObjectUtils.isEmpty(activeProductRecord.getProductNo())){
|
|
|
+ if (ObjectUtils.isEmpty(activeProductRecord.getProductNo())) {
|
|
|
//查询最大值
|
|
|
Map<String, Object> map = activeProductRecordService.getMap(Wrappers.<ActiveProductRecord>query().select(new StringBuilder("IFNULL(max(")
|
|
|
.append(BeanPropertyUtil.getFieldNameToUnder(ActiveProductRecord::getProductNo)).append("),0) as NO").toString())
|
|
|
.eq(BeanPropertyUtil.getFieldNameToUnder(ActiveProductRecord::getActiveId), activeProductRecord.getActiveId()));
|
|
|
- activeProductRecord.setProductNo(Long.valueOf(MapUtil.getInt(map, "NO")+1));
|
|
|
+ activeProductRecord.setProductNo(Long.valueOf(MapUtil.getInt(map, "NO") + 1));
|
|
|
}
|
|
|
return activeProductRecord;
|
|
|
}
|