Commit 1e3311ac by 吕明尚

修改美团绑定门店查询

parent 033e1b72
......@@ -392,34 +392,29 @@ public class QPServiceImpl implements QPService {
*/
@Override
public List<CustomerKeyShopScopeResponseEntity> scope() {
Boolean b = redisUtil.exists(ReceiptRdeisEnum.MT_SESSION_KEY.getValue());
if (Boolean.FALSE.equals(b)) {
Boolean exists = redisUtil.exists(ReceiptRdeisEnum.MT_SESSION_KEY.getValue());
if (Boolean.FALSE.equals(exists)) {
throw new RuntimeException("请联系管理员");
}
DefaultOpenAPIClient openAPIClient = new DefaultOpenAPIClient();
String o = redisUtil.get(ReceiptRdeisEnum.MT_SESSION_KEY.getValue());
JSONObject sessionKey = new JSONObject(o);
String session = (String) sessionKey.get("access_token");
String bid = (String) sessionKey.get("bid");
String sessionKeyJson = redisUtil.get(ReceiptRdeisEnum.MT_SESSION_KEY.getValue());
JSONObject sessionKeyObject = new JSONObject(sessionKeyJson);
String session = (String) sessionKeyObject.get("access_token");
String bid = (String) sessionKeyObject.get("bid");
CustomerKeyShopScopeRequest request = new CustomerKeyShopScopeRequest(APP_KEY, APP_SECRET, session, bid);
CustomerKeyShopScopeQuery shopScopeQuery = new CustomerKeyShopScopeQuery(request);
DefaultOpenAPIClient openAPIClient = new DefaultOpenAPIClient();
CustomerKeyShopScopeResponse response = openAPIClient.invoke(shopScopeQuery);
if (response.getCode() != 200) {
logger.error("适用店铺查询接口:{}", response.getMsg());
logger.error("适用店铺查询接口失败: code={}, msg={}", response.getCode(), response.getMsg());
throw new RuntimeException(response.getMsg());
}
//查询所有门店
List<SStore> list = storeService.list();
//过滤以增加的门店 根据open_shop_uuid
List<SStore> stores = storeService.list();
Map<String, SStore> storeMap = stores.stream()
.collect(Collectors.toMap(SStore::getOpenShopUuid, s -> s));
List<CustomerKeyShopScopeResponseEntity> data = response.getData();
List<CustomerKeyShopScopeResponseEntity> collect = data.stream().filter(o1 -> {
Optional<SStore> first = list.stream().filter(o2 -> o2.getOpenShopUuid().equals(o1.getOpen_shop_uuid())).findFirst();
if (first.isPresent()) {
return false;
}
return true;
}).collect(java.util.stream.Collectors.toList());
return collect;
return data.stream()
.filter(entity -> !storeMap.containsKey(entity.getOpen_shop_uuid()))
.collect(Collectors.toList());
}
@Override
......
......@@ -104,14 +104,11 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
SConsumerCouponVo vo = new SConsumerCouponVo();
BeanUtils.copyProperties(item, vo);
if (!ObjectUtils.isEmpty(item.getStoreId())) {
Optional<SStore> matchingObj = list.stream()
.filter(obj -> obj.getId().equals(item.getStoreId()))
.findAny();
if (matchingObj.isPresent()) {
vo.setStoreName(matchingObj.get().getName());
} else {
vo.setStoreName("");
}
vo.setStoreName(list.stream()
.filter(store -> store.getId().equals(item.getStoreId()))
.map(SStore::getName)
.findFirst()
.orElse(""));
}
if (item.getCouponType().equals(CouponTypeEnum.CASH.getCode()) && StringUtils.isEmpty(item.getStoreIds())) {
item.setStoreIds(list.stream().map(SStore::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.joining(",")));
......@@ -435,9 +432,9 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
newSConsumerCoupon.setMinPrice(new BigDecimal(0.00));
newSConsumerCoupon.setSubPrice(sCoupon.getSubPrice());
newSConsumerCoupon.setWeeks(sCoupon.getWeeks());
// newSConsumerCoupon.setStoreIds(sCoupon.getStoreIds());
// newSConsumerCoupon.setSubPrice(sCoupon.getSubPrice());
// newSConsumerCoupon.setCouponPayPrice(sCoupon.getCouponPayPrice());
newSConsumerCoupon.setStoreIds(sCoupon.getStoreIds());
newSConsumerCoupon.setSubPrice(sCoupon.getSubPrice());
newSConsumerCoupon.setCouponPayPrice(sCoupon.getCouponPayPrice());
newSConsumerCoupon.setMinDuration(sCoupon.getMinDuration());
newSConsumerCoupon.setMaxDuration(sCoupon.getMaxDuration());
newSConsumerCoupon.setDuration(sCoupon.getDuration());
......
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