提交 5006fb36 authored 作者: 李秋林's avatar 李秋林

出售记录redis到db库逻辑

上级 8b5f9c8c
...@@ -56,17 +56,25 @@ public class TemporaryActivityCoreController { ...@@ -56,17 +56,25 @@ public class TemporaryActivityCoreController {
} }
/** /**
* 删除促销员[今日活动 - (出售列表中添加)出售单元]数据 * 修改/删除促销员[今日活动 - (出售列表中添加)出售单元]某一条数据
*/
@PutMapping("/today/reported/market_cell/one")
public R todayUpdateMarketCellOne(@RequestBody TemporaryActivityMarketCellVo marketcellVo) {
marketcellVo.updateDataVerify();
tempActivityCoreService.todayUpdateMarketCellOne(marketcellVo);
return R.success();
}
/**
* 删除促销员[今日活动 - (出售列表中添加)出售单元]在缓存中的全部数据
* 当促销员取消保存活动记录时,数据进行删除 * 当促销员取消保存活动记录时,数据进行删除
*/ */
@DeleteMapping("/today/reported/del_market_cell") @DeleteMapping("/today/reported/market_cell/del")
public R todayActivityMarketCellReported(Integer temporaryId) { public R todayDeleteMarketCellReported(Integer temporaryId) {
tempActivityCoreService.todayActivityDeleteMarketCellReported(temporaryId); tempActivityCoreService.todayActivityDeleteMarketCellReported(temporaryId);
return R.success(); return R.success();
} }
/** /**
* 促销员[今日活动]数据提交审批 * 促销员[今日活动]数据提交审批
* 修改审批状态 * 修改审批状态
......
...@@ -22,7 +22,7 @@ import javax.validation.constraints.NotNull; ...@@ -22,7 +22,7 @@ import javax.validation.constraints.NotNull;
public class TemporaryActivityQueryController { public class TemporaryActivityQueryController {
@Autowired @Autowired
TemporaryActivityQueryService temporaryActivityQueryService; private TemporaryActivityQueryService temporaryActivityQueryService;
/** /**
* 根据促销员id查询所有任务 * 根据促销员id查询所有任务
...@@ -53,8 +53,6 @@ public class TemporaryActivityQueryController { ...@@ -53,8 +53,6 @@ public class TemporaryActivityQueryController {
return R.success(dto); return R.success(dto);
} }
/** /**
* 促销员[今日活动 - (出售列表中添加)出售单元]数据 * 促销员[今日活动 - (出售列表中添加)出售单元]数据
* 数据暂存到redis中,当调用保存接口时再添加到数据库中 * 数据暂存到redis中,当调用保存接口时再添加到数据库中
...@@ -64,4 +62,16 @@ public class TemporaryActivityQueryController { ...@@ -64,4 +62,16 @@ public class TemporaryActivityQueryController {
public R todayActivityMarketCell(Integer temporaryId) { public R todayActivityMarketCell(Integer temporaryId) {
return R.success(temporaryActivityQueryService.findActivityMarketCell(temporaryId)); return R.success(temporaryActivityQueryService.findActivityMarketCell(temporaryId));
} }
/**
* 促销员[今日活动 - (出售列表中添加)出售单元]数据
* 返回保存在数据库中的数据
*/
@GetMapping("/today/reported/market_cell/{id}")
public R findActivityMarketCellByDb(@PathVariable("id") Long activityId) {
if (activityId <= 0){
return R.success();
}
return R.success(temporaryActivityQueryService.findActivityMarketCellByDb(activityId));
}
} }
package com.wangxiaolu.promotion.domain.activity.dao;
import com.alibaba.fastjson.JSONArray;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityMarketCellDto;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-06-21 15
* @describe :
*/
public interface TemporaryActivityMarketCellDao {
void saveList(Long activityReportedId,JSONArray jsonArray);
List<TemporaryActivityMarketCellDto> selectList(Long activityId);
void updateById(TemporaryActivityMarketCellDto dto);
void deleteById(Long id);
}
package com.wangxiaolu.promotion.domain.activity.dao.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityMarketCellDao;
import com.wangxiaolu.promotion.domain.activity.mapper.TemporaryActivityMarketCellMapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityMarketCellDO;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityMarketCellDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author : liqiulin
* @date : 2024-06-21 15
* @describe :
*/
@Service
public class TemporaryActivityMarketCellDaoImpl implements TemporaryActivityMarketCellDao {
@Autowired
TemporaryActivityMarketCellMapper temporaryActivityMarketCellMapper;
@Override
public void saveList(Long activityReportedId, JSONArray jsonArray) {
if (CollectionUtils.isEmpty(jsonArray)) {
return;
}
List<TemporaryActivityMarketCellDO> dos = new ArrayList<>(jsonArray.size() * 2);
jsonArray.forEach(jri -> {
JSONObject jo = (JSONObject) jri;
TemporaryActivityMarketCellDO marketCellDO = JSONObject.parseObject(jo.toString(), TemporaryActivityMarketCellDO.class);
marketCellDO.setActivityReportedId(activityReportedId);
marketCellDO.setClassName(jo.getString("prdName"));
marketCellDO.setCreateDate(DateUtil.today());
dos.add(marketCellDO);
});
temporaryActivityMarketCellMapper.saveList(dos);
}
@Override
public List<TemporaryActivityMarketCellDto> selectList(Long activityId) {
LambdaQueryWrapper<TemporaryActivityMarketCellDO> qw = new LambdaQueryWrapper<>();
qw.eq(TemporaryActivityMarketCellDO::getActivityReportedId, activityId)
.eq(TemporaryActivityMarketCellDO::getIsDelete,1);
List<TemporaryActivityMarketCellDO> marketCellDOS = temporaryActivityMarketCellMapper.selectList(qw);
return transitionDtos(marketCellDOS);
}
@Override
public void updateById(TemporaryActivityMarketCellDto dto) {
TemporaryActivityMarketCellDO updateDos = new TemporaryActivityMarketCellDO();
updateDos.setId(dto.getId());
updateDos.setBox(dto.getBox());
updateDos.setBag(dto.getBag());
temporaryActivityMarketCellMapper.updateById(updateDos);
}
@Override
public void deleteById(Long id) {
TemporaryActivityMarketCellDO updateDos = new TemporaryActivityMarketCellDO();
updateDos.setId(id);
updateDos.setIsDelete(0);
temporaryActivityMarketCellMapper.updateById(updateDos);
}
/**
* DO to DTO (单个对象)
*
* @param temDos DO对象List
* @return DTO对象
*/
private List<TemporaryActivityMarketCellDto> transitionDtos(List<TemporaryActivityMarketCellDO> temDos) {
if (CollectionUtils.isEmpty(temDos)) {
return new ArrayList<>();
}
List<TemporaryActivityMarketCellDto> dtos = new ArrayList<>(temDos.size() * 2);
for (TemporaryActivityMarketCellDO temDo : temDos) {
dtos.add(transitionDto(temDo));
}
return dtos;
}
/**
* DO to DTO (单个对象)
*
* @param temDo DO对象
* @return DTO对象
*/
private TemporaryActivityMarketCellDto transitionDto(TemporaryActivityMarketCellDO temDo) {
TemporaryActivityMarketCellDto temporaryDto = null;
if (Objects.isNull(temDo)) {
return temporaryDto;
}
temporaryDto = new TemporaryActivityMarketCellDto();
BeanUtils.copyProperties(temDo, temporaryDto);
return temporaryDto;
}
}
package com.wangxiaolu.promotion.domain.activity.mapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityMarketCellDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author a02200059
* @description 针对表【temporary_activity_market_cell】的数据库操作Mapper
* @createDate 2024-06-21 15:30:32
* @Entity com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityMarketCellDO
*/
@Mapper
@Repository
public interface TemporaryActivityMarketCellMapper extends BaseMapper<TemporaryActivityMarketCellDO> {
void saveList(@Param("list") List<TemporaryActivityMarketCellDO> dos);
}
package com.wangxiaolu.promotion.domain.activity.mapper.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
* @TableName temporary_activity_market_cell
*/
@TableName(value ="temporary_activity_market_cell")
@Data
public class TemporaryActivityMarketCellDO implements Serializable {
/**
* 主键id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 关联—temporary_info表id
*/
private Integer temporaryId;
private Long activityReportedId;
/**
* 商品类型名称
*/
private String className;
/**
* 商品唯一标识,来源第三方系统的唯一ID(ERP)
*/
private String prdId;
/**
* 商品名称
*/
private String prdName;
/**
* 卖出-袋
*/
private Integer bag;
/**
* 卖出-箱
*/
private Integer box;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建日期YYYY-MM-DD
*/
private String createDate;
/**
* 修改时间
*/
private Date modifyTime;
/**
* 1:使用中;0:删除;
*/
private Integer isDelete;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
...@@ -84,16 +84,6 @@ public class TemporaryActivityReportedDO implements Serializable { ...@@ -84,16 +84,6 @@ public class TemporaryActivityReportedDO implements Serializable {
* 退回原因 * 退回原因
*/ */
private String approveReason; private String approveReason;
private Integer sellXiangA;
private Integer sellXiangB;
private Integer sellXiangC;
private Integer sellXiangD;
private Integer sellDaiA;
private Integer sellDaiB;
private Integer sellDaiC;
private Integer sellDaiD;
/** /**
* 创建时间 * 创建时间
*/ */
......
package com.wangxiaolu.promotion.pojo.activity.temporary.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @author : liqiulin
* @date : 2024-06-21 16
* @describe :
*/
@Data
@Accessors(chain = true)
public class TemporaryActivityMarketCellDto {
/**
* 主键id
*/
private Long id;
/**
* 关联—temporary_info表id
*/
private Integer temporaryId;
private Long activityReportedId;
/**
* 商品类型名称
*/
private String className;
/**
* 商品唯一标识,来源第三方系统的唯一ID(ERP)
*/
private String prdId;
/**
* 商品名称
*/
private String prdName;
/**
* 卖出-袋
*/
private Integer bag;
/**
* 卖出-箱
*/
private Integer box;
/**
* 创建日期YYYY-MM-DD
*/
private String createDate;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
...@@ -112,15 +112,6 @@ public class TemporaryActivityReportedDto { ...@@ -112,15 +112,6 @@ public class TemporaryActivityReportedDto {
private List<String> psvPhotoUrls; private List<String> psvPhotoUrls;
private List<String> psvChangePhotoUrls; private List<String> psvChangePhotoUrls;
private Integer sellXiangA;
private Integer sellXiangB;
private Integer sellXiangC;
private Integer sellXiangD;
private Integer sellDaiA;
private Integer sellDaiB;
private Integer sellDaiC;
private Integer sellDaiD;
/** /**
* 创建时间 * 创建时间
*/ */
......
...@@ -66,15 +66,4 @@ public class TemporaryActivityDataVo { ...@@ -66,15 +66,4 @@ public class TemporaryActivityDataVo {
*/ */
private List<String> psvPhotoUrls; private List<String> psvPhotoUrls;
private List<String> psvChangePhotoUrls; private List<String> psvChangePhotoUrls;
private Integer ax;
private Integer sellXiangA;
private Integer sellXiangB;
private Integer sellXiangC;
private Integer sellXiangD;
private Integer sellDaiA;
private Integer sellDaiB;
private Integer sellDaiC;
private Integer sellDaiD;
} }
\ No newline at end of file
...@@ -58,26 +58,47 @@ public class TemporaryActivityMarketCellVo { ...@@ -58,26 +58,47 @@ public class TemporaryActivityMarketCellVo {
/** /**
* 卖出数据 - 袋 * 卖出数据 - 袋
*/ */
private Integer bag; private int bag;
/** /**
* 卖出数据 - 箱 * 卖出数据 - 箱
*/ */
private Integer box; private int box;
public void saveDataVerify() { /**
// if (Objects.isNull(this.marketCellId) && StringUtils.isBlank(this.uuid)){ * 当前数据操作类型
// throw new ParamException(RCode.DATA_NOT_HAVE_ERROR, null); * 0:删除;
// } * 2:修改;
*/
private Integer operate;
if (StringUtils.isBlank(this.prdClassName) || StringUtils.isBlank(this.prdId)){ public void saveDataVerify() {
if (StringUtils.isBlank(this.prdClassName) || StringUtils.isBlank(this.prdId)) {
throw new ParamException(RCode.PRODUCT_CLASS_NOT_ERROR, null); throw new ParamException(RCode.PRODUCT_CLASS_NOT_ERROR, null);
} }
if ((Objects.isNull(this.bag) && Objects.isNull(this.box)) || (this.bag + this.box <= 0)) { if (this.bag + this.box <= 0) {
throw new ParamException(RCode.MARKET_NUMBER_NOT_ERROR, null);
}
}
public void updateDataVerify() {
if (Objects.isNull(this.marketCellId) && StringUtils.isBlank(this.uuid)) {
throw new ParamException(RCode.DATA_NOT_HAVE_ERROR, null);
}
if ((this.bag + this.box <= 0) && (0 != operate)) {
throw new ParamException(RCode.MARKET_NUMBER_NOT_ERROR, null); throw new ParamException(RCode.MARKET_NUMBER_NOT_ERROR, null);
} }
}
public boolean operateIsUpdate() {
return 2 == operate;
}
public boolean operateIsDelete() {
return 0 == operate;
} }
......
...@@ -40,7 +40,18 @@ public interface TemporaryActivityCoreService { ...@@ -40,7 +40,18 @@ public interface TemporaryActivityCoreService {
*/ */
void clockStoreCalDistance(String storeQcId, Long id, String clockCoordinates); void clockStoreCalDistance(String storeQcId, Long id, String clockCoordinates);
/**
* 保存销售上报-出售单元 - 缓存
*/
void todayActivityMarketCellReported(TemporaryActivityMarketCellVo marketcellVo); void todayActivityMarketCellReported(TemporaryActivityMarketCellVo marketcellVo);
/**
* 删除销售上报-出售单元 - 缓存
*/
void todayActivityDeleteMarketCellReported(Integer temporaryId); void todayActivityDeleteMarketCellReported(Integer temporaryId);
/**
* 修改/删除 单一出售单元
*/
void todayUpdateMarketCellOne(TemporaryActivityMarketCellVo marketcellVo);
} }
...@@ -2,6 +2,7 @@ package com.wangxiaolu.promotion.service.activity.temporary; ...@@ -2,6 +2,7 @@ package com.wangxiaolu.promotion.service.activity.temporary;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.wangxiaolu.promotion.pojo.PageInfo; import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityMarketCellDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import java.util.List; import java.util.List;
...@@ -26,4 +27,6 @@ public interface TemporaryActivityQueryService { ...@@ -26,4 +27,6 @@ public interface TemporaryActivityQueryService {
TemporaryActivityReportedDto findTemporaryActivityById(Long activityId); TemporaryActivityReportedDto findTemporaryActivityById(Long activityId);
JSONArray findActivityMarketCell(Integer temporaryId); JSONArray findActivityMarketCell(Integer temporaryId);
List<TemporaryActivityMarketCellDto> findActivityMarketCellByDb(Long activityId);
} }
...@@ -18,6 +18,7 @@ import com.wangxiaolu.promotion.exception.DataException; ...@@ -18,6 +18,7 @@ import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.exception.FlowException; import com.wangxiaolu.promotion.exception.FlowException;
import com.wangxiaolu.promotion.exception.ParamException; import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.PromotionStoreDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.PromotionStoreDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityMarketCellDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.vo.TemporaryActivityMarketCellVo; import com.wangxiaolu.promotion.pojo.activity.temporary.vo.TemporaryActivityMarketCellVo;
...@@ -66,6 +67,8 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -66,6 +67,8 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
@Autowired @Autowired
private TemporaryInfoDao temporaryInfoDao; private TemporaryInfoDao temporaryInfoDao;
@Autowired
private TemporaryActivityMarketCellDao temporaryActivityMarketCellDao;
/** /**
...@@ -82,14 +85,11 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -82,14 +85,11 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
throw new FlowException(RCode.DATA_HAVE_ERROR, null); throw new FlowException(RCode.DATA_HAVE_ERROR, null);
} }
// 查询上报人负责人 // 查询上报人负责人;初始化任务状态:已保存
WxTemporaryInfoDto wxTemporaryInfoDto = temporaryInfoDao.selectOneById(temActDto.getTemporaryId()); WxTemporaryInfoDto wxTemporaryInfoDto = temporaryInfoDao.selectOneById(temActDto.getTemporaryId());
temActDto.setApproveStatus(TemActApproveStatus.SUBMITTED);
// 初始化任务状态:已保存
temActDto.setApproveStatus(TemActApproveStatus.APPROVED);
temActDto.setApproverId(wxTemporaryInfoDto.getChargerQcId()); temActDto.setApproverId(wxTemporaryInfoDto.getChargerQcId());
temActDto.setApproveName(wxTemporaryInfoDto.getChargerName()); temActDto.setApproveName(wxTemporaryInfoDto.getChargerName());
temActDto.setApproveTime(new Date());
// 根据storeQcId查询店铺信息,进行店铺信息补充 // 根据storeQcId查询店铺信息,进行店铺信息补充
PromotionStoreDto promotionStoreDto = promotionStoreDao.selectOneById(temActDto.getStoreId()); PromotionStoreDto promotionStoreDto = promotionStoreDao.selectOneById(temActDto.getStoreId());
...@@ -98,15 +98,20 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -98,15 +98,20 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
.setProvince(promotionStoreDto.getProvince()) .setProvince(promotionStoreDto.getProvince())
.setCity(promotionStoreDto.getCity()); .setCity(promotionStoreDto.getCity());
// 保存活动数据 temporary_activity_reported
long reportedId = temporaryActivityReportedDao.activityDataSave(temActDto); long reportedId = temporaryActivityReportedDao.activityDataSave(temActDto);
temActDto.setId(reportedId); temActDto.setId(reportedId);
// 保存图片 // 保存图片
saveActivityPhoto(temActDto); saveActivityPhoto(temActDto);
// 售卖单元新增保存
String key = temMarketCellRedisKey(temActDto.getTemporaryId());
temporaryActivityMarketCellDao.saveList(reportedId,redisCache.getToJsonArray(key));
// 日志保存 // 日志保存
tempActivityLogDao.save(temActDto.getTemporaryId(), temActDto.getTemporaryName(), LogType.t_2, temActDto.getId(), temActDto); tempActivityLogDao.save(temActDto.getTemporaryId(), temActDto.getTemporaryName(), LogType.t_2, temActDto.getId(), temActDto);
redisCache.removeKey(key);
return reportedId; return reportedId;
} }
...@@ -120,6 +125,12 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -120,6 +125,12 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
// 图片增量保存 // 图片增量保存
saveActivityPhoto(temActDto); saveActivityPhoto(temActDto);
temporaryActivityReportedDao.updateById(temActDto); temporaryActivityReportedDao.updateById(temActDto);
// 售卖单元新增保存
String key = temMarketCellRedisKey(temActDto.getTemporaryId());
temporaryActivityMarketCellDao.saveList(temActDto.getId(),redisCache.getToJsonArray(key));
redisCache.removeKey(key);
// 日志保存 // 日志保存
tempActivityLogDao.save(temActDto.getTemporaryId(), temActDto.getTemporaryName(), LogType.t_2, temActDto.getId(), temActDto); tempActivityLogDao.save(temActDto.getTemporaryId(), temActDto.getTemporaryName(), LogType.t_2, temActDto.getId(), temActDto);
} }
...@@ -155,6 +166,7 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -155,6 +166,7 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
if (Objects.isNull(reportedDto)) { if (Objects.isNull(reportedDto)) {
throw new ParamException(RCode.DATA_NOT_HAVE_ERROR, null); throw new ParamException(RCode.DATA_NOT_HAVE_ERROR, null);
} }
// TemActApproveStatus approveStatus = reportedDto.getApproveStatus(); // TemActApproveStatus approveStatus = reportedDto.getApproveStatus();
// if (!TemActApproveStatus.SUBMITTED.name().equals(approveStatus.name()) && !TemActApproveStatus.SEND_BACK.name().equals(approveStatus.name())) { // if (!TemActApproveStatus.SUBMITTED.name().equals(approveStatus.name()) && !TemActApproveStatus.SEND_BACK.name().equals(approveStatus.name())) {
// throw new FlowException(RCode.STATUS_UPDATE_ERROR, null); // throw new FlowException(RCode.STATUS_UPDATE_ERROR, null);
...@@ -165,7 +177,8 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -165,7 +177,8 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
TemporaryActivityReportedDto updateDto = new TemporaryActivityReportedDto() TemporaryActivityReportedDto updateDto = new TemporaryActivityReportedDto()
.setId(id) .setId(id)
.setApproveName(wxTemporaryInfoDto.getChargerName()) .setApproveName(wxTemporaryInfoDto.getChargerName())
.setApproveStatus(TemActApproveStatus.IN_APPROVAL); .setApproveStatus(TemActApproveStatus.APPROVED)
.setApproveTime(new Date());
// 修改审批 // 修改审批
temporaryActivityReportedDao.updateById(updateDto); temporaryActivityReportedDao.updateById(updateDto);
...@@ -178,13 +191,13 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -178,13 +191,13 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
public void todayActivityMarketCellReported(TemporaryActivityMarketCellVo marketcellVo) { public void todayActivityMarketCellReported(TemporaryActivityMarketCellVo marketcellVo) {
String key = temMarketCellRedisKey(marketcellVo.getTemporaryId()); String key = temMarketCellRedisKey(marketcellVo.getTemporaryId());
JSONArray marketCells = redisCache.getToJsonArray(key); JSONArray marketCells = redisCache.getToJsonArray(key);
if (Objects.isNull(marketCells)){ if (Objects.isNull(marketCells)) {
marketCells = new JSONArray(); marketCells = new JSONArray();
}else { } else {
// 判断prdId是否已存在 // 判断prdId是否已存在
List<String> prdIdList = marketCells.stream().map(o -> ((JSONObject) o).getString("prdId")).collect(Collectors.toList()); List<String> prdIdList = marketCells.stream().map(o -> ((JSONObject) o).getString("prdId")).collect(Collectors.toList());
if (prdIdList.contains(marketcellVo.getPrdId())){ if (prdIdList.contains(marketcellVo.getPrdId())) {
throw new ParamException(RCode.PRODUCT_CLASS_HAS_ERROR,null); throw new ParamException(RCode.PRODUCT_CLASS_HAS_ERROR, null);
} }
} }
...@@ -199,6 +212,72 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -199,6 +212,72 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
redisCache.removeKey(key); redisCache.removeKey(key);
} }
@Override
public void todayUpdateMarketCellOne(TemporaryActivityMarketCellVo marketcellVo) {
// 修改/删除 缓存中的数据
if (StringUtils.isNotBlank(marketcellVo.getUuid())) {
todayUpdateMarketCellOneToRedis(marketcellVo);
}
// 修改/删除 DB库中的数据
if (Objects.nonNull(marketcellVo.getMarketCellId())){
todayUpdateMarketCellOneToDb(marketcellVo);
}
}
private void todayUpdateMarketCellOneToDb(TemporaryActivityMarketCellVo marketcellVo) {
if (marketcellVo.operateIsDelete()){
temporaryActivityMarketCellDao.deleteById(marketcellVo.getMarketCellId());
}
if (marketcellVo.operateIsUpdate()){
TemporaryActivityMarketCellDto dto = new TemporaryActivityMarketCellDto()
.setId(marketcellVo.getMarketCellId())
.setBag(marketcellVo.getBag())
.setBox(marketcellVo.getBox());
temporaryActivityMarketCellDao.updateById(dto);
}
}
private void todayUpdateMarketCellOneToRedis(TemporaryActivityMarketCellVo marketcellVo) {
String key = temMarketCellRedisKey(marketcellVo.getTemporaryId());
JSONArray marketCells = redisCache.getToJsonArray(key);
if (Objects.isNull(marketCells)) {
throw new ParamException(RCode.DATA_NOT_HAVE_ERROR, null);
}
String uuid = marketcellVo.getUuid();
if (marketcellVo.operateIsUpdate()) {
marketCells.stream().forEach(jo -> {
JSONObject mj = (JSONObject) jo;
String uuidR = mj.getString("uuid");
if (uuidR.equals(uuid)) {
mj.put("box", marketcellVo.getBox());
mj.put("bag", marketcellVo.getBag());
}
});
}
if (marketcellVo.operateIsDelete()) {
for (int i = 0; i < marketCells.size(); i++) {
JSONObject mj = (JSONObject) marketCells.get(i);
String uuidR = mj.getString("uuid");
if (uuidR.equals(uuid)) {
marketCells.remove(i);
break;
}
}
}
redisCache.removeKey(key);
if (!CollectionUtils.isEmpty(marketCells)) {
redisCache.addToJsonToMinute(key, marketCells, 30);
}
}
/** /**
* 根据店铺或打卡记录中的店铺,判断打卡距离 * 根据店铺或打卡记录中的店铺,判断打卡距离
* 经度,范围为 -180~180,负数表示西经;纬度,范围为 -90~90,负数表示南纬 * 经度,范围为 -180~180,负数表示西经;纬度,范围为 -90~90,负数表示南纬
...@@ -236,7 +315,7 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -236,7 +315,7 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
// } // }
} }
private String temMarketCellRedisKey(Integer temporaryId){ private String temMarketCellRedisKey(Integer temporaryId) {
return RedisKeys.TemporaryKeys.TEMPORARY_ACTIVITY_MARKET_CELL.getKey() + temporaryId + "_" + DateUtil.today(); return RedisKeys.TemporaryKeys.TEMPORARY_ACTIVITY_MARKET_CELL.getKey() + temporaryId + "_" + DateUtil.today();
} }
......
...@@ -5,10 +5,12 @@ import com.alibaba.fastjson.JSONArray; ...@@ -5,10 +5,12 @@ import com.alibaba.fastjson.JSONArray;
import com.fasterxml.uuid.Generators; import com.fasterxml.uuid.Generators;
import com.wangxiaolu.promotion.common.redis.RedisKeys; import com.wangxiaolu.promotion.common.redis.RedisKeys;
import com.wangxiaolu.promotion.common.redis.service.RedisCache; import com.wangxiaolu.promotion.common.redis.service.RedisCache;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityMarketCellDao;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityPhotoDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityPhotoDao;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao;
import com.wangxiaolu.promotion.enums.activity.ActivityPhotoType; import com.wangxiaolu.promotion.enums.activity.ActivityPhotoType;
import com.wangxiaolu.promotion.pojo.PageInfo; import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityMarketCellDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityQueryService; import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityQueryService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -35,6 +37,8 @@ public class TemporaryActivityQueryServiceImpl implements TemporaryActivityQuery ...@@ -35,6 +37,8 @@ public class TemporaryActivityQueryServiceImpl implements TemporaryActivityQuery
TemporaryActivityReportedDao temporaryActivityReportedDao; TemporaryActivityReportedDao temporaryActivityReportedDao;
@Autowired @Autowired
TemporaryActivityPhotoDao temporaryActivityPhotoDao; TemporaryActivityPhotoDao temporaryActivityPhotoDao;
@Autowired
TemporaryActivityMarketCellDao temporaryActivityMarketCellDao;
/** /**
* 根据促销员id查询所有任务 * 根据促销员id查询所有任务
...@@ -71,6 +75,12 @@ public class TemporaryActivityQueryServiceImpl implements TemporaryActivityQuery ...@@ -71,6 +75,12 @@ public class TemporaryActivityQueryServiceImpl implements TemporaryActivityQuery
return redisCache.getToJsonArray(key); return redisCache.getToJsonArray(key);
} }
@Override
public List<TemporaryActivityMarketCellDto> findActivityMarketCellByDb(Long activityId) {
List<TemporaryActivityMarketCellDto> dtos = temporaryActivityMarketCellDao.selectList(activityId);
return dtos;
}
private void findActivityReportedPhoto(TemporaryActivityReportedDto dto) { private void findActivityReportedPhoto(TemporaryActivityReportedDto dto) {
if (Objects.isNull(dto)) { if (Objects.isNull(dto)) {
return; return;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wangxiaolu.promotion.domain.activity.mapper.TemporaryActivityMarketCellMapper">
<resultMap id="BaseResultMap" type="com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityMarketCellDO">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="temporaryId" column="temporary_id" jdbcType="INTEGER"/>
<result property="className" column="class_name" jdbcType="VARCHAR"/>
<result property="prdId" column="prd_id" jdbcType="VARCHAR"/>
<result property="prdName" column="prd_name" jdbcType="VARCHAR"/>
<result property="bag" column="bag" jdbcType="INTEGER"/>
<result property="box" column="box" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createDate" column="create_date" jdbcType="CHAR"/>
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,temporary_id,class_name,
prd_id,prd_name,bag,
box,create_time,create_date,
modify_time
</sql>
<insert id="saveList" parameterType="java.util.List">
INSERT INTO temporary_activity_market_cell (activity_reported_id, temporary_id, class_name, prd_id, prd_name, bag, box, create_date)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.activityReportedId},#{item.temporaryId},#{item.className},#{item.prdId},#{item.prdName},#{item.bag},#{item.box},#{item.createDate})
</foreach>
</insert>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论