Commit 4b7ef484 by 吕明尚

券码查询获取适用门店增加经纬度和距离

parent 53338875
......@@ -2,13 +2,15 @@ package share.web.controller.system;
import com.dianping.openapi.sdk.api.tuangou.entity.*;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.core.domain.R;
import share.common.enums.ConsumerCouponStatusEnum;
import share.system.domain.SStore;
import share.system.domain.vo.SStoreDto;
import share.system.domain.vo.SStoreVo;
import share.system.service.QPService;
import share.system.service.TiktokService;
......@@ -79,13 +81,16 @@ public class QPController {
//查询当前优惠券适用门店
@GetMapping("/queryshop")
public R<List<SStore>> queryshop(String code) {
if (code.length() == 10) {
return R.ok(qpService.queryshop(code));
} else if (code.startsWith("https://v.douyin.com/") | code.length() == 15 | code.length() == 12) {
return R.ok(tiktokService.queryshop(code));
public R<List<SStoreVo>> queryshop(SStoreDto dto) {
if (StringUtils.isEmpty(dto.getCode())) {
throw new RuntimeException("券码缺失");
}
if (dto.getCode().length() == 10) {
return R.ok(qpService.queryshop(dto));
} else if (dto.getCode().startsWith("https://v.douyin.com/") | dto.getCode().length() == 15 | dto.getCode().length() == 12) {
return R.ok(tiktokService.queryshop(dto));
} else {
return R.fail("请输入正确的券码");
throw new RuntimeException("请输入正确的券码");
}
}
}
package share.system.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import share.common.core.domain.BaseEntity;
@Data
public class SStoreDto extends BaseEntity {
/**
* 经度
*/
@ApiModelProperty(value = "经度")
private String longitude;
/**
* 纬度
*/
@ApiModelProperty(value = "纬度")
private String latitude;
private String code;
}
package share.system.service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SStore;
import share.system.domain.SStoreConsumer;
import share.system.domain.vo.SStoreConsumerVo;
import share.system.domain.vo.SStoreVo;
import share.system.request.SStoreRequest;
import share.system.domain.SStoreConsumer;
import java.util.List;
import java.util.Map;
/**
* 门店Service接口
......@@ -101,4 +101,8 @@ public interface ISStoreService extends IService<SStore>
List<SStoreVo> storeList();
List<SStoreVo> convertDosToVos(List<SStore> storeList);
List<SStoreVo> convertDosToVosSortByDst(List<SStore> storeList, SStoreRequest request);
}
......@@ -5,6 +5,8 @@ import com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse;
import com.dianping.openapi.sdk.api.tuangou.entity.*;
import share.system.domain.SCoupon;
import share.system.domain.SStore;
import share.system.domain.vo.SStoreDto;
import share.system.domain.vo.SStoreVo;
import share.system.domain.vo.SessionVo;
import java.util.List;
......@@ -32,7 +34,7 @@ public interface QPService {
List<CustomerKeyShopScopeResponseEntity> scope();
List<SStore> queryshop(String code);
List<SStoreVo> queryshop(SStoreDto dto);
List<SStore> getsStores(List<SStore> sStoreList, SCoupon sCoupon);
List<SStoreVo> getsStores(List<SStore> sStoreList, SCoupon sCoupon, SStoreDto dto);
}
package share.system.service;
import cn.hutool.json.JSONObject;
import share.system.domain.SStore;
import share.system.domain.tiktok.TiktokCouponDto;
import share.system.domain.tiktok.TiktokPoi;
import share.system.domain.vo.OnlineQueryDto;
import share.system.domain.vo.SStoreDto;
import share.system.domain.vo.SStoreVo;
import java.util.List;
......@@ -29,5 +30,5 @@ public interface TiktokService {
List<TiktokPoi> poiList();
List<SStore> queryshop(String code);
List<SStoreVo> queryshop(SStoreDto dto);
}
......@@ -35,7 +35,10 @@ import share.system.domain.SConsumerCoupon;
import share.system.domain.SCoupon;
import share.system.domain.SStore;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SStoreDto;
import share.system.domain.vo.SStoreVo;
import share.system.domain.vo.SessionVo;
import share.system.request.SStoreRequest;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISCouponService;
import share.system.service.ISStoreService;
......@@ -420,7 +423,11 @@ public class QPServiceImpl implements QPService {
}
@Override
public List<SStore> queryshop(String code) {
public List<SStoreVo> queryshop(SStoreDto dto) {
String code = dto.getCode();
if (StringUtils.isEmpty(dto.getLatitude()) || StringUtils.isEmpty(dto.getLongitude())) {
throw new RuntimeException("经纬度不能为空");
}
LambdaQueryWrapper<SStore> sStoreLambdaQueryWrapper = new LambdaQueryWrapper<>(SStore.class);
sStoreLambdaQueryWrapper.eq(SStore::getStoreType, StoreType.HOTEL.getCode());
List<SStore> sStoreList = storeService.list(sStoreLambdaQueryWrapper);
......@@ -433,7 +440,7 @@ public class QPServiceImpl implements QPService {
eq(SCoupon::getPlatformType, PlatformTypeEnum.MEITUAN.getCode()));
if (!ObjectUtils.isEmpty(sCoupon)) {
//过滤不存在sCoupon.getstoreIds()的门店
return getsStores(sStoreList, sCoupon);
return getsStores(sStoreList, sCoupon, dto);
} else {
List<SCoupon> coupons = isCouponService.queryShopDeal();
SCoupon scoupon = coupons.stream().filter(o -> o.getDealgroupId().equals(prepare.getDealgroup_id())).findFirst().get();
......@@ -442,12 +449,12 @@ public class QPServiceImpl implements QPService {
}
isCouponService.save(scoupon);
//过滤不存在sCoupon.getstoreIds()的门店
return getsStores(sStoreList, scoupon);
return getsStores(sStoreList, scoupon, dto);
}
}
@Override
public List<SStore> getsStores(List<SStore> sStoreList, SCoupon sCoupon) {
public List<SStoreVo> getsStores(List<SStore> sStoreList, SCoupon sCoupon, SStoreDto dto) {
List<SStore> collect = sStoreList.stream().filter(o -> {
String storeIds = sCoupon.getStoreIds();
if (StringUtils.isEmpty(storeIds)) {
......@@ -462,8 +469,11 @@ public class QPServiceImpl implements QPService {
return false;
}).collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)) {
return sStoreList;
return storeService.convertDosToVos(sStoreList);
}
return collect;
SStoreRequest request = new SStoreRequest();
request.setNowLatitude(dto.getLatitude());
request.setNowLongitude(dto.getLongitude());
return storeService.convertDosToVosSortByDst(collect, request);
}
}
......@@ -301,7 +301,8 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
* @param request
* @return
*/
private List<SStoreVo> convertDosToVosSortByDst(List<SStore> storeList, SStoreRequest request) {
@Override
public List<SStoreVo> convertDosToVosSortByDst(List<SStore> storeList, SStoreRequest request) {
List<SStoreVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(storeList)) {
// 查询每一个房间最后一条预定订单下单时间
......@@ -350,7 +351,8 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
* @param storeList
* @return
*/
private List<SStoreVo> convertDosToVos(List<SStore> storeList) {
@Override
public List<SStoreVo> convertDosToVos(List<SStore> storeList) {
List<SStoreVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(storeList)) {
// 查询每一个房间最后一条预定订单下单时间
......
......@@ -27,6 +27,8 @@ import share.system.domain.tiktok.TiktokCouponDto;
import share.system.domain.tiktok.TiktokPoi;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.OnlineQueryDto;
import share.system.domain.vo.SStoreDto;
import share.system.domain.vo.SStoreVo;
import share.system.service.*;
import java.io.UnsupportedEncodingException;
......@@ -468,7 +470,11 @@ public class TiktokServiceImpl implements TiktokService {
}
@Override
public List<SStore> queryshop(String code) {
public List<SStoreVo> queryshop(SStoreDto dto) {
String code = dto.getCode();
if (StringUtils.isEmpty(dto.getLatitude()) || StringUtils.isEmpty(dto.getLongitude())) {
throw new RuntimeException("经纬度不能为空");
}
LambdaQueryWrapper<SStore> sStoreLambdaQueryWrapper = new LambdaQueryWrapper<>(SStore.class);
sStoreLambdaQueryWrapper.eq(SStore::getStoreType, StoreType.HOTEL.getCode());
List<SStore> sStoreList = storeService.list(sStoreLambdaQueryWrapper);
......@@ -492,7 +498,7 @@ public class TiktokServiceImpl implements TiktokService {
eq(SCoupon::getPlatformType, PlatformTypeEnum.TIKTOK.getCode()));
sStoreList = storeService.list(new LambdaQueryWrapper<>(SStore.class).isNotNull(SStore::getTiktokPoiId));
if (!ObjectUtils.isEmpty(sCoupon)) {
return qpService.getsStores(sStoreList, sCoupon);
return qpService.getsStores(sStoreList, sCoupon, dto);
} else {
List<SCoupon> coupons = isCouponService.querySkuPoiList();
SCoupon scoupon = coupons.stream().filter(s -> s.getTiktokSkuId().equals(sku.getStr("sku_id"))).findFirst().get();
......@@ -500,7 +506,7 @@ public class TiktokServiceImpl implements TiktokService {
throw new RuntimeException("当前优惠券异常,请联系客服");
}
isCouponService.save(scoupon);
return qpService.getsStores(sStoreList, scoupon);
return qpService.getsStores(sStoreList, scoupon, dto);
}
} catch (RuntimeException e) {
throw new RuntimeException(e);
......
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