use of com.tony.billing.entity.CostRecord in project BillingDubbo by TonyJiangWJ.
the class CostRecordController method backUp.
@RequestMapping("/record/backup/csv/get")
public void backUp(HttpServletResponse response, @ModelAttribute("request") BaseRequest request) {
CostRecord requestParam = new CostRecord();
requestParam.setUserId(request.getUserId());
List<CostRecord> records = costRecordService.find(requestParam);
List<String> result = alipayBillCsvUtil.convertPOJO2String(records);
OutputStreamWriter outputStreamWriter = null;
BufferedWriter bufferedWriter = null;
try {
response.reset();
response.setContentType("application/octet-stream; charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename=" + "backup" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + ".csv");
OutputStream outputStream = response.getOutputStream();
outputStreamWriter = new OutputStreamWriter(outputStream, "GBK");
bufferedWriter = new BufferedWriter(outputStreamWriter);
for (String rs : result) {
bufferedWriter.write(rs);
bufferedWriter.newLine();
}
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
} catch (IOException e) {
logger.error("创建备份文件失败", e);
}
}
use of com.tony.billing.entity.CostRecord in project BillingDubbo by TonyJiangWJ.
the class CostRecordController method formatModelList.
private List<CostRecordDTO> formatModelList(List<CostRecord> list, boolean showTags) {
if (!CollectionUtils.isEmpty(list)) {
List<CostRecordDTO> models = new ArrayList<>();
CostRecordDTO model;
List<TagInfo> tagInfos;
for (CostRecord entity : list) {
model = new CostRecordDTO();
model.setId(entity.getId());
model.setCreateTime(entity.getCostCreateTime());
model.setGoodsName(entity.getGoodsName());
model.setInOutType(entity.getInOutType());
model.setIsDeleted(entity.getIsDeleted());
model.setMoney(MoneyUtil.fen2Yuan(entity.getMoney()));
model.setLocation(entity.getLocation());
model.setOrderStatus(entity.getOrderStatus());
model.setOrderType(entity.getOrderType());
model.setTradeNo(entity.getTradeNo());
model.setTarget(entity.getTarget());
model.setMemo(entity.getMemo());
model.setIsHidden(entity.getIsHidden());
if (showTags) {
tagInfos = tagInfoService.listTagInfoByTradeNo(entity.getTradeNo());
if (!CollectionUtils.isEmpty(tagInfos)) {
model.setTags(tagInfos.stream().map(TagInfo::getTagName).collect(Collectors.toList()));
}
}
models.add(model);
}
return models;
} else {
return null;
}
}
use of com.tony.billing.entity.CostRecord in project BillingDubbo by TonyJiangWJ.
the class CostRecordController method updateRecord.
/**
* 修改消费记录
*
* @param request
* @return
*/
@RequestMapping(value = "/record/update")
public BaseResponse updateRecord(@ModelAttribute("request") @Validated CostRecordUpdateRequest request) {
BaseResponse response = new BaseResponse();
CostRecord record = new CostRecord();
record.setLocation(request.getLocation());
record.setGoodsName(request.getGoodsName());
record.setMemo(request.getMemo());
record.setTradeNo(request.getTradeNo());
record.setUserId(request.getUserId());
record.setOrderType(request.getOrderType());
record.setVersion(request.getVersion());
if (costRecordService.updateByTradeNo(record) > 0) {
return ResponseUtil.success(response);
}
return ResponseUtil.error(response);
}
use of com.tony.billing.entity.CostRecord in project BillingDubbo by TonyJiangWJ.
the class AlipayBillCsvConvertServiceImpl method convertToDoForInsert.
private CostRecord convertToDoForInsert(Record entity, Long userId) {
if (entity == null) {
return null;
}
CostRecord record = new CostRecord();
record.setIsDeleted(0);
record.setCostCreateTime(entity.getCreateTime());
record.setGoodsName(entity.getGoodsName());
record.setInOutType(entity.getInOutType());
record.setLocation(entity.getLocation());
record.setMemo(entity.getMemo());
record.setCostModifyTime(entity.getModifyTime());
record.setMoney(MoneyUtil.yuan2fen(entity.getMoney()));
record.setOrderNo(entity.getOrderNo());
record.setOrderStatus(entity.getOrderStatus());
record.setOrderType(entity.getOrderType());
record.setPaidTime(entity.getPaidTime());
record.setRefundMoney(MoneyUtil.yuan2fen(entity.getRefundMoney()));
record.setServiceCost(MoneyUtil.yuan2fen(entity.getServiceCost()));
record.setTarget(entity.getTarget());
record.setTradeNo(entity.getTradeNo());
record.setTradeStatus(entity.getTradeStatus());
record.setUserId(userId);
record.setVersion(0);
record.setIsHidden(EnumHidden.NOT_HIDDEN.val());
record.setIsDeleted(EnumDeleted.NOT_DELETED.val());
record.setCreateTime(new Date());
record.setModifyTime(new Date());
return record;
}
use of com.tony.billing.entity.CostRecord in project BillingDubbo by TonyJiangWJ.
the class TagInfoController method delCostTag.
/**
* 删除账单标签
*
* @param request
* @return
*/
@RequestMapping(value = "/cost/tag/delete")
public BaseResponse delCostTag(@ModelAttribute("request") @Validated CostTagDelRequest request) {
BaseResponse response = new BaseResponse();
try {
CostRecord costRecord = costRecordService.findByTradeNo(request.getTradeNo(), request.getUserId());
TagInfo tagInfo = tagInfoService.getTagInfoById(request.getTagId());
if (costRecord != null && tagInfo != null) {
if (tagInfoService.deleteCostTag(costRecord.getId(), tagInfo.getId())) {
ResponseUtil.success(response);
} else {
ResponseUtil.error(response);
}
} else {
ResponseUtil.paramError(response);
}
} catch (Exception e) {
logger.error("/cost/tag/delete error", e);
ResponseUtil.sysError(response);
}
return response;
}
Aggregations