Commit d04fa0d3 authored by zhaobiyan's avatar zhaobiyan

兑换信息导入

parents 7f1f5617 d0780bc5
......@@ -32,4 +32,5 @@ public interface DictDataFrameworkService {
*/
List<DictDataRespDTO> listDictDatasFromCache(String type);
DictDataRespDTO parseDictDataFromCacheWithMultiLang(String type, String multiLangLabel);
}
......@@ -25,4 +25,8 @@ public class DictFrameworkUtils {
return service.parseDictDataFromCache(type, label);
}
public static DictDataRespDTO parseDictDataFromCacheWithMultiLang(String type, String multiLangLabel) {
return service.parseDictDataFromCacheWithMultiLang(type, multiLangLabel);
}
}
......@@ -42,6 +42,21 @@ public class I18nMessage {
}
}
/**
* 获取一条语言配置信息
*
* @param message 配置信息属性名,eg: api.response.code.user.signUp
* @return
*/
public static String getMessage(String message, Object... arg) {
Locale locale = LocaleContextHolder.getLocale();
try {
return accessor.getMessage(message, arg, locale);
} catch (Exception e) {
return message;
}
}
/**
* 获取一条语言配置信息
* TODO 此方法暂时只支持中英文国际化,如需更多,待优化
......
......@@ -6,6 +6,7 @@ import java.math.BigDecimal;
@Data
public class CurrencyRespDTO {
private Integer id;
/**
* 中文名称
*/
......
package cn.iocoder.yudao.module.ecw.api.express;
import cn.iocoder.yudao.module.ecw.api.express.dto.ExpressRespDTO;
import java.util.List;
public interface ExpressApi {
List<ExpressRespDTO> getAllExpress();
}
package cn.iocoder.yudao.module.ecw.api.express.dto;
import lombok.Data;
@Data
public class ExpressRespDTO {
private Long id;
/**
* 快递公司名称
*/
private String companyName;
}
......@@ -4,6 +4,7 @@ import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.ecw.api.express.dto.ExpressRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.ecw.controller.admin.express.vo.*;
......@@ -31,4 +32,5 @@ public interface ExpressConvert {
List<ExpressExcelVO> convertList02(List<ExpressDO> list);
List<ExpressRespDTO> convert2DTO(List<ExpressDO> list);
}
package cn.iocoder.yudao.module.ecw.service.api;
import cn.iocoder.yudao.module.ecw.api.express.ExpressApi;
import cn.iocoder.yudao.module.ecw.api.express.dto.ExpressRespDTO;
import cn.iocoder.yudao.module.ecw.convert.express.ExpressConvert;
import cn.iocoder.yudao.module.ecw.dal.dataobject.express.ExpressDO;
import cn.iocoder.yudao.module.ecw.service.express.ExpressService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
public class ExpressApiImpl implements ExpressApi {
@Resource
private ExpressService expressService;
@Override
public List<ExpressRespDTO> getAllExpress() {
List<ExpressDO> list = expressService.list();
return ExpressConvert.INSTANCE.convert2DTO(list);
}
}
......@@ -67,4 +67,5 @@ public interface ExpressService {
*/
List<ExpressDO> getExpressList(ExpressExportReqVO exportReqVO);
List<ExpressDO> list();
}
package cn.iocoder.yudao.module.ecw.service.express;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
......@@ -79,4 +81,11 @@ public class ExpressServiceImpl implements ExpressService {
return expressMapper.selectList(exportReqVO);
}
@Override
public List<ExpressDO> list() {
LambdaQueryWrapper<ExpressDO> wrapper = Wrappers.lambdaQuery();
wrapper.eq(ExpressDO::getDeleted, 0);
return expressMapper.selectList(wrapper);
}
}
......@@ -27,6 +27,7 @@ public interface ErrorCodeConstants {
ErrorCode REWARD_REDEEM_STATUS_ERROR = new ErrorCode(1001011019, "reward.redeem.status.error");
ErrorCode REWARD_REDEEM_VERIFY_NO_PARAM = new ErrorCode(1001011020, "reward.redeem.verify.no.param");
ErrorCode REWARD_REDEEM_BATCH_VERIFY_ERROR = new ErrorCode(1001011021, "reward.redeem.batch.verify.error");
ErrorCode REWARD_REDEEM_VERIFY_BACK_STATUS = new ErrorCode(1001011021, "reward.redeem.verify.back.status");
ErrorCode REWARD_REDEEM_VERIFY_BACK_STATUS = new ErrorCode(1001011022, "reward.redeem.verify.back.status");
ErrorCode REDEEM_IMPORT_MAX_COUNT = new ErrorCode(1001011023, "redeem.import.max.count");
}
......@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.reward.controller.admin.redeem;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.module.reward.api.reward.RedeemRewardApi;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO;
......@@ -10,16 +11,21 @@ import cn.iocoder.yudao.module.reward.vo.reward.*;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageReqVO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
......@@ -78,6 +84,31 @@ public class RedeemRewardController {
return success(rewardRedeemService.export(reqVO));
}
@PostMapping("record/import/template")
@ApiOperation("导入模板下载")
public void importTemplate(HttpServletResponse response) throws IOException {
// 手动创建导出 demo
List<RedeemInfoImportExcelVO> list = Arrays.asList(
RedeemInfoImportExcelVO.builder().id(String.valueOf(11111)).redeemType("上门领取").courierCompany("顺丰空运").expenses(BigDecimal.valueOf(11.11))
.currency("人民币").expressDate("2024-01-01 11:22:33").expressNo("SDSD212212").remark("备注备注").expressSender("系统管理员")
.build(),
RedeemInfoImportExcelVO.builder().id(String.valueOf(11111)).redeemType("包邮到家").courierCompany("顺丰空运").expenses(BigDecimal.valueOf(11.11))
.currency("美元").expressDate("2024-01-01 11:22:33").expressNo("SDSD212212").remark("备注备注").expressSender("系统管理员")
.build());
// 输出
ExcelUtils.write(response, "兑换信息导入模板.xls", "兑换信息", RedeemInfoImportExcelVO.class, list);
}
@PostMapping(value = "record/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation("兑换信息导入")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "Excel 文件", required = true, dataTypeClass = MultipartFile.class)
})
public CommonResult<RecordInfoImportRespVO> recordImport(@RequestParam("file") MultipartFile file) throws IOException {
List<RedeemInfoImportExcelVO> list = ExcelUtils.read(file, RedeemInfoImportExcelVO.class);
return success(rewardRedeemService.recordImport(list));
}
@PostMapping("/single")
@ApiOperation("兑换礼品")
......
......@@ -76,7 +76,7 @@ public class RewardRedeemDO extends BaseDO {
/**
* 快递公司
*/
private Integer courierCompany;
private Long courierCompany;
/**
* 快递单号
*/
......
package cn.iocoder.yudao.module.reward.dto;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author zhaobiyan
*/
@Data
public class RedeemRecordImportDTO {
private Long id;
private Integer redeemType;
private BigDecimal expenses;
private Integer currency;
private Integer courierCompany;
private String expressNo;
private Date expressDate;
private String expressSender;
private String remark;
}
......@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.reward.dto;
import lombok.Builder;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
......@@ -15,7 +16,11 @@ public class RewardRedeemVerifyDTO {
private Integer redeemType;
private Integer courierCompany;
private BigDecimal expense;
private Integer currency;
private Long courierCompany;
/**
* 收件人地址
*/
......
......@@ -31,4 +31,6 @@ public interface RewardRedeemService extends IService<RewardRedeemDO> {
List<RewardRedeemPageRespVO> exportList(RewardRedeemPageReqVO request);
Integer exportCount(RewardRedeemPageReqVO request);
RecordInfoImportRespVO recordImport(List<RedeemInfoImportExcelVO> dataList);
}
package cn.iocoder.yudao.module.reward.vo.reward;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import java.util.Map;
@Data
@Builder
public class RecordInfoImportRespVO {
@ApiModelProperty(value = "导入失败的信息集合", required = true, notes = "key 为兑换id,value 为失败原因")
private Map<String, String> redeemIdFailedMap;
public RecordInfoImportRespVO() {
}
public RecordInfoImportRespVO(Map<String, String> redeemIdFailedMap) {
this.redeemIdFailedMap = redeemIdFailedMap;
}
}
package cn.iocoder.yudao.module.reward.vo.reward;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false)
public class RedeemInfoImportExcelVO {
@ExcelProperty("兑换记录ID/Redeem ID")
private String id;
@ExcelProperty("兑换方式/Redeem Method")
private String redeemType;
@ExcelProperty("费用/fee")
private BigDecimal expenses;
@ExcelProperty("币种/Currency")
private String currency;
@ExcelProperty("快递公司/Express")
private String courierCompany;
@ExcelProperty("快递单号/Express NO")
private String expressNo;
@ExcelProperty(value = "快递日期/Delivery Date")
private String expressDate;
@ExcelProperty("快递寄出人/Sender")
private String expressSender;
@ExcelProperty("备注/Remark")
private String remark;
}
......@@ -25,7 +25,7 @@ public class RewardRedeemVerifyReqVO {
private String recipientPhoneNum;
@ApiModelProperty(value = "快递公司")
private Integer courierCompany;
private Long courierCompany;
/**
* 收件人地址
*/
......
......@@ -70,6 +70,9 @@ public class DictDataServiceImpl implements DictDataService {
* key2:字典标签 label
*/
private ImmutableTable<String, String, DictDataDO> labelDictDataCache;
private ImmutableTable<String, String, DictDataDO> labelEnDictDataCache;
/**
* 字典数据缓存,第二个 key 使用 value
*
......@@ -93,13 +96,16 @@ public class DictDataServiceImpl implements DictDataService {
// 构建缓存
ImmutableTable.Builder<String, String, DictDataDO> labelDictDataBuilder = ImmutableTable.builder();
ImmutableTable.Builder<String, String, DictDataDO> labelEnDictDataBuilder = ImmutableTable.builder();
ImmutableTable.Builder<String, String, DictDataDO> valueDictDataBuilder = ImmutableTable.builder();
dataList.forEach(dictData -> {
labelDictDataBuilder.put(dictData.getDictType(), dictData.getLabel(), dictData);
valueDictDataBuilder.put(dictData.getDictType(), dictData.getValue(), dictData);
labelEnDictDataBuilder.put(dictData.getDictType(), dictData.getLabelEn(), dictData);
});
labelDictDataCache = labelDictDataBuilder.build();
valueDictDataCache = valueDictDataBuilder.build();
labelEnDictDataCache = labelEnDictDataBuilder.build();
maxUpdateTime = CollectionUtils.getMaxValue(dataList, DictDataDO::getUpdateTime);
log.info("[initLocalCache][缓存字典数据,数量为:{}]", dataList.size());
}
......@@ -174,6 +180,15 @@ public class DictDataServiceImpl implements DictDataService {
return DictDataConvert.INSTANCE.convertList03(labelDictDataCache.row(type).values());
}
@Override
public DictDataRespDTO parseDictDataFromCacheWithMultiLang(String type, String multiLangLabel) {
DictDataDO dictDataDO = labelDictDataCache.get(type, multiLangLabel);
if (dictDataDO == null) {
dictDataDO = labelEnDictDataCache.get(type, multiLangLabel);
}
return DictDataConvert.INSTANCE.convert02(dictDataDO);
}
@Override
public Long createDictData(DictDataCreateReqVO reqVO) {
// 校验正确性
......
......@@ -1013,6 +1013,11 @@ reward.time.not.allow=The reward time is not allow
get.lock.failed = The service is busy, please try again later
reward.redeem.not.exist = reward redeem record does not exist
reward.redeem.status.error = reward redeem record that is redeeming can edit or verify
reward.redeem.verify.no.param = In addition to collect at home, the delivery company/delivery number/delivery time/delivery sender/recipient address must be filled in
reward.redeem.verify.no.param = Fee/Currency/Express/Express NO/Delivery Date/Sender/Recipient Address must be filled in
reward.redeem.batch.verify.error = reward redeem record verify failed, please check record data : {}
reward.redeem.verify.back.status = record status must be redeemed
\ No newline at end of file
reward.redeem.verify.back.status = record status must be redeemed
redeem.import.max.count = allow maximum number of imports is {}
dict.unknown.error = Not in dict {0}: {1}
express.not.exist = express not exist
currency.not.exist = currency not exist
date.format.error = date format error, for example : 2024-01-01 12:11:11
\ No newline at end of file
......@@ -1017,6 +1017,11 @@ reward.time.not.allow=\u6D3B\u52A8\u65F6\u95F4\u4E0D\u5408\u6CD5
get.lock.failed = \u670D\u52A1\u7E41\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5
reward.redeem.not.exist = \u793C\u54C1\u5151\u6362\u8BB0\u5F55\u4E0D\u5B58\u5728
reward.redeem.status.error = \u53EA\u6709\u5151\u6362\u4E2D\u72B6\u6001\u7684\u8BB0\u5F55\u624D\u5141\u8BB8\u7F16\u8F91\u6216\u6838\u9500
reward.redeem.verify.no.param = \u9664\u4E0A\u95E8\u9886\u53D6\u5916\uFF0C\u5FEB\u9012\u516C\u53F8/\u5FEB\u9012\u5355\u53F7/\u5FEB\u9012\u65F6\u95F4/\u5FEB\u9012\u53D1\u9001\u4EBA/\u6536\u4EF6\u4EBA\u5730\u5740\uFF0C\u5FC5\u987B\u586B\u5199
reward.redeem.verify.no.param = \u8D27\u503C/\u5E01\u79CD/\u5FEB\u9012\u516C\u53F8/\u5FEB\u9012\u5355\u53F7/\u5FEB\u9012\u65F6\u95F4/\u5FEB\u9012\u53D1\u9001\u4EBA/\u6536\u4EF6\u4EBA\u5730\u5740\uFF0C\u5FC5\u987B\u586B\u5199
reward.redeem.batch.verify.error = \u793C\u54C1\u8BB0\u5F55\u6279\u91CF\u6838\u9500\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u6570\u636E\u662F\u5426\u6B63\u786E:{}
reward.redeem.verify.back.status = \u56DE\u9000\u8BB0\u5F55\u72B6\u6001\u5FC5\u987B\u4E3A\u5DF2\u5151\u6362
\ No newline at end of file
reward.redeem.verify.back.status = \u56DE\u9000\u8BB0\u5F55\u72B6\u6001\u5FC5\u987B\u4E3A\u5DF2\u5151\u6362
redeem.import.max.count = \u5141\u8BB8\u7684\u6700\u5927\u5BFC\u5165\u6761\u6570\u4E3A{}
dict.unknown.error = \u4E0D\u5728{0}\u5B57\u5178\u4E2D: {1}
express.not.exist = \u5FEB\u9012\u516C\u53F8\u4E0D\u5B58\u5728
currency.not.exist = \u5E01\u79CD\u4E0D\u5B58\u5728
date.format.error = \u65E5\u671F\u683C\u5F0F\u4E0D\u6B63\u786E, \u6B63\u786E\u683C\u5F0F\u53C2\u8003: 2024-01-01 12:11:11
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment