*/
@Service
public class SourceTypeServiceImpl implements SourceTypeService {
- private final SourceTypeDao paytypeDao;
- private final SourceTypeConfigDao paytypeConfigDao;
+ private final SourceTypeDao sourceTypeDao;
+ private final SourceTypeConfigDao sourceTypeConfigDao;
private final ShopSourceTypeDao shopSourceTypeDao;
private final ShopSourceTypeConfigDao shopSourceTypeConfigDao;
@Autowired
- public SourceTypeServiceImpl(SourceTypeDao paytypeDao, SourceTypeConfigDao paytypeConfigDao, ShopSourceTypeDao shopSourceTypeDao, ShopSourceTypeConfigDao shopSourceTypeConfigDao) {
- this.paytypeDao = paytypeDao;
- this.paytypeConfigDao = paytypeConfigDao;
+ public SourceTypeServiceImpl(SourceTypeDao sourceTypeDao, SourceTypeConfigDao sourceTypeConfigDao, ShopSourceTypeDao shopSourceTypeDao, ShopSourceTypeConfigDao shopSourceTypeConfigDao) {
+ this.sourceTypeDao = sourceTypeDao;
+ this.sourceTypeConfigDao = sourceTypeConfigDao;
this.shopSourceTypeDao = shopSourceTypeDao;
this.shopSourceTypeConfigDao = shopSourceTypeConfigDao;
}
@Override
@Cacheable(cacheNames = "dictionary_cache", keyGenerator = "tenantCacheKey")
public TSourceType getBySourceType(String paytype) {
- return paytypeDao.getOne(paytype);
+ return sourceTypeDao.getOne(paytype);
}
@Override
@Cacheable(cacheNames = "dictionary_cache", keyGenerator = "tenantCacheKey")
public Map<String, String> getSourceTypeConfigBySourceType(String pattype) {
- List<TSourceTypeConfig> list = paytypeConfigDao.getBySourceType(pattype);
+ List<TSourceTypeConfig> list = sourceTypeConfigDao.getBySourceType(pattype);
Map<String, String> map = new HashMap<>(list.size());
for (TSourceTypeConfig paytypeConfig : list) {
map.put(paytypeConfig.getConfigid(), paytypeConfig.getConfigValue());
@Override
public boolean checkRechargeSourcetype(String sourcetype) throws Exception {
- TSourceType tSourceType = paytypeDao.getBySourceType(sourcetype);
+ TSourceType tSourceType = sourceTypeDao.getBySourceType(sourcetype);
if (null == tSourceType) {
throw new TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统不支持支付方式[" + sourcetype + "]");
} else if (!tSourceType.getEnable() || !tSourceType.getChargeEnable()) {
@Override
public boolean checkShopSourceType(String shopaccno, String sourceType, boolean anonymousflag) throws Exception {
//step1: 判断系统支付能力是否启用
- TSourceType tSourceType = paytypeDao.getBySourceType(sourceType);
+ TSourceType tSourceType = sourceTypeDao.getBySourceType(sourceType);
if (null == tSourceType) {
throw new TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统不支持支付方式[" + sourceType + "]");
} else {
@Override
public Map<String, String> getChargePaytypeConfig(String paytype, boolean ignoreStatus) throws Exception {
- TSourceType tSourceType = paytypeDao.getBySourceType(paytype);
+ TSourceType tSourceType = sourceTypeDao.getBySourceType(paytype);
if (null == tSourceType) {
throw new TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统不支持支付方式[" + paytype + "]");
} else if (!ignoreStatus && (!tSourceType.getEnable() || !tSourceType.getChargeEnable())) {
}
Map<String, String> result = new HashMap<>(0);
- List<TSourceTypeConfig> list = paytypeConfigDao.getBySourceType(paytype);
+ List<TSourceTypeConfig> list = sourceTypeConfigDao.getBySourceType(paytype);
if (!StringUtil.isEmpty(list)) {
for (TSourceTypeConfig config : list) {
result.put(config.getConfigid(), config.getConfigValue());
@Override
public Map<String, String> getConsumePaytypeConfig(String paytype, String shopaccno, boolean anonymousflag, boolean ignoreStatus) throws Exception {
//step1: 判断系统支付能力是否启用
- TSourceType tSourceType = paytypeDao.getBySourceType(paytype);
+ TSourceType tSourceType = sourceTypeDao.getBySourceType(paytype);
if (null == tSourceType) {
throw new TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统不支持支付方式[" + paytype + "]");
} else {
}
Map<String, String> result = new HashMap<>(0);
- List<TSourceTypeConfig> list = paytypeConfigDao.getBySourceType(paytype);
+ List<TSourceTypeConfig> list = sourceTypeConfigDao.getBySourceType(paytype);
if (!StringUtil.isEmpty(list)) {
for (TSourceTypeConfig config : list) {
if (config.getGlobalflag()) {
}
+ private TDictionary findExistsOrNew(List<TDictionary> list, TDictionary item) {
+ for (TDictionary i : list) {
+ if (item.getDicttype().equals(i.getDicttype()) && item.getDictval().equals(i.getDictval())) {
+ i.setDicttypename(item.getDicttypename());
+ i.setDictcaption(item.getDictcaption());
+ return i;
+ }
+ }
+ TDictionary newDict = new TDictionary();
+ newDict.setDicttype(item.getDicttype());
+ newDict.setDictval(item.getDictval());
+ newDict.setDictcaption(item.getDictcaption());
+ newDict.setDicttypename(item.getDicttypename());
+ return newDict;
+ }
+
@Override
@CacheEvict(cacheNames = "dictionary_cache", key = "@tenantHolder.genKey(#dicttype)")
public void updateDictionaryByDictType(String dicttype, List<TDictionary> list) {
throw new IllegalArgumentException("TDictionary dicttype mismatch");
}
}
+ List<TDictionary> exists = dictionaryDao.findAllByDicttype(dicttype);
+ List<TDictionary> newItems = new ArrayList<>();
dictionaryDao.deleteByDicttype(dicttype);
for (TDictionary item : list) {
- dictionaryDao.save(item);
+ newItems.add(findExistsOrNew(exists, item));
}
+ exists.removeAll(newItems);
+ dictionaryDao.deleteAll(exists);
+ dictionaryDao.saveAll(newItems);
}
@Override