| @@ -7,7 +7,10 @@ import java.util.List; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxMiniappThemeValue; | |||||
| import com.iformall.enums.EnumCouponType; | import com.iformall.enums.EnumCouponType; | ||||
| import com.iformall.utils.RedisCacheUtils; | |||||
| import org.apache.commons.beanutils.BeanUtils; | import org.apache.commons.beanutils.BeanUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -56,6 +59,10 @@ public class WxCouponController extends BaseController { | |||||
| @Qualifier("couponDetailRedisTemplate") | @Qualifier("couponDetailRedisTemplate") | ||||
| RedisTemplate<String, WxCouponCVo> cdRedisTemplate; | RedisTemplate<String, WxCouponCVo> cdRedisTemplate; | ||||
| @Autowired | |||||
| @Qualifier("objectCommonRedisTemplate") | |||||
| RedisTemplate<String, Object> objectCommonRedisTemplate; | |||||
| @ApiOperation("根据id(couponChannel)查询接口") | @ApiOperation("根据id(couponChannel)查询接口") | ||||
| @GetMapping("/detail") | @GetMapping("/detail") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -201,6 +208,32 @@ public class WxCouponController extends BaseController { | |||||
| return new ResultData(wxCouponCVo); | return new ResultData(wxCouponCVo); | ||||
| } | } | ||||
| // @ApiOperation("根据id(couponId)查询接口") | |||||
| // @GetMapping("/getMerchantList") | |||||
| // @ApiImplicitParams({ | |||||
| // @ApiImplicitParam(name = "couponId", value = "couponId", dataType = "String", paramType = "query", required = true) | |||||
| // }) | |||||
| // public ResultData getMerchantList(Long couponId) { | |||||
| // | |||||
| // if (couponId == null) { | |||||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| // } | |||||
| // | |||||
| // String key = Constant.coupon_merchants_key+getTenantInfo().getTenantId()+":"+couponId; | |||||
| // | |||||
| // List<WxMerchantVo> valueList = RedisCacheUtils.getCacheListObject(objectCommonRedisTemplate, key, WxMerchantVo.class); | |||||
| // if(valueList != null && valueList.size() > 0){ | |||||
| // return new ResultData(valueList); | |||||
| // } | |||||
| // valueList = couponService.getCouponMerchantList(getTenantInfo(),couponId); | |||||
| // if(valueList == null || valueList.size() == 0){ | |||||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| // } | |||||
| // | |||||
| // RedisCacheUtils.cache(objectCommonRedisTemplate,key,valueList,3600l); | |||||
| // return new ResultData(valueList); | |||||
| // } | |||||
| private WxCouponCVo generateWxCouponCVo(Long couponChannelIdL,String tenantId) { | private WxCouponCVo generateWxCouponCVo(Long couponChannelIdL,String tenantId) { | ||||
| WxCouponChannel cc = wxCouponChannelService.getById(couponChannelIdL,tenantId); | WxCouponChannel cc = wxCouponChannelService.getById(couponChannelIdL,tenantId); | ||||
| @@ -346,6 +346,10 @@ public class WxMerchant extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String addr; | private String addr; | ||||
| @io.swagger.annotations.ApiModelProperty(value="ttPoi",name="ttPoi") | |||||
| @TableField(exist = false) | |||||
| private String ttPoi; | |||||
| @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") | @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private BigDecimal longitude; | private BigDecimal longitude; | ||||
| @@ -101,6 +101,10 @@ public class WxMerchantVo extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "置顶时间", name = "topTime") | @io.swagger.annotations.ApiModelProperty(value = "置顶时间", name = "topTime") | ||||
| private Date topTime; | private Date topTime; | ||||
| @io.swagger.annotations.ApiModelProperty(value="ttPoi",name="ttPoi") | |||||
| @TableField(exist = false) | |||||
| private String ttPoi; | |||||
| @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") | @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private BigDecimal longitude; | private BigDecimal longitude; | ||||
| @@ -128,6 +132,7 @@ public class WxMerchantVo extends TenantEntity { | |||||
| this.linkLinePhone = m.getLinkLinePhone(); | this.linkLinePhone = m.getLinkLinePhone(); | ||||
| this.topTime = m.getTopTime(); | this.topTime = m.getTopTime(); | ||||
| this.addr = m.getAddr(); | this.addr = m.getAddr(); | ||||
| this.ttPoi = m.getTtPoi(); | |||||
| this.longitude = m.getLongitude(); | this.longitude = m.getLongitude(); | ||||
| this.latitude = m.getLatitude(); | this.latitude = m.getLatitude(); | ||||
| } | } | ||||
| @@ -76,10 +76,15 @@ public class TtWebProductServiceImpl implements TtWebProductService { | |||||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.POST_SPU_STOCK_UPDATE; | String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.POST_SPU_STOCK_UPDATE; | ||||
| String result = this.service.execute(executor, apiUrl, spuStockSync.toJson()); | String result = this.service.execute(executor, apiUrl, spuStockSync.toJson()); | ||||
| JSONObject jsonObject = JSONObject.parseObject(result); | JSONObject jsonObject = JSONObject.parseObject(result); | ||||
| String spuExtId = jsonObject.getString("spu_ext_id"); | |||||
| if(spuStockSync.getSpuExtId().equals(spuExtId)){ | |||||
| Integer error_code = jsonObject.getInteger("error_code"); | |||||
| if(error_code.intValue() == 0){ | |||||
| return true; | return true; | ||||
| } | } | ||||
| // String spuExtId = jsonObject.getString("spu_ext_id"); | |||||
| // if(spuStockSync.getSpuExtId().equals(spuExtId)){ | |||||
| // return true; | |||||
| // } | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| @@ -11,6 +11,7 @@ import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponStatisVo; | import com.iformall.domain.vo.WxCouponStatisVo; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | |||||
| public interface WxCouponService { | public interface WxCouponService { | ||||
| @@ -261,4 +262,6 @@ public interface WxCouponService { | |||||
| Map<Long,String> getCouponMerchantMap(List<Long> couponIds,TenantEntity tenantEntity,boolean onlyOneMerchantCoupons); | Map<Long,String> getCouponMerchantMap(List<Long> couponIds,TenantEntity tenantEntity,boolean onlyOneMerchantCoupons); | ||||
| Map<Long, WxCoupon> getCouponMap(List<Long> couponIds, TenantEntity tenantEntity); | Map<Long, WxCoupon> getCouponMap(List<Long> couponIds, TenantEntity tenantEntity); | ||||
| List<WxMerchantVo> getCouponMerchantList(TenantEntity tenantInfo, Long couponId); | |||||
| } | } | ||||
| @@ -593,11 +593,11 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||||
| poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); | poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); | ||||
| List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); | List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); | ||||
| if(poiList == null || poiList.isEmpty()){ | if(poiList == null || poiList.isEmpty()){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到可用poi"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到匹配的poi"); | |||||
| } | } | ||||
| List<Long> collect = poiList.stream().map(p -> p.getId()).collect(Collectors.toList()); | |||||
| // List<Long> collect = poiList.stream().map(p -> p.getId()).collect(Collectors.toList()); | |||||
| String spuId = spuSync(coupon,couponChannel,collect); | |||||
| String spuId = spuSync(coupon,couponChannel,couponMerchantIds); | |||||
| if(StringUtils.isBlank(spuId)){ | if(StringUtils.isBlank(spuId)){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败"); | ||||
| } | } | ||||
| @@ -48,6 +48,8 @@ import java.util.stream.Collectors; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import static java.util.stream.Collectors.toList; | |||||
| @Service | @Service | ||||
| public class WxCouponServiceImpl implements WxCouponService { | public class WxCouponServiceImpl implements WxCouponService { | ||||
| @@ -154,7 +156,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| List<Long> ids = wxCouponList.stream().map(p -> p.getId()).collect(Collectors.toList()); | |||||
| List<Long> ids = wxCouponList.stream().map(p -> p.getId()).collect(toList()); | |||||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | WxCouponChannel wxCouponChannel = new WxCouponChannel(); | ||||
| wxCouponChannel.updateTenantInfo(wxCoupon); | wxCouponChannel.updateTenantInfo(wxCoupon); | ||||
| wxCouponChannel.setCouponIds(ids); | wxCouponChannel.setCouponIds(ids); | ||||
| @@ -249,7 +251,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| if (merchantList != null) { | if (merchantList != null) { | ||||
| merchantList = merchantList.stream().filter( | merchantList = merchantList.stream().filter( | ||||
| m->m.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())) | m->m.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())) | ||||
| .collect(Collectors.toList()); | |||||
| .collect(toList()); | |||||
| } | } | ||||
| wxCouponCVo.setMerchantVoList(merchantList); | wxCouponCVo.setMerchantVoList(merchantList); | ||||
| if(EnumCouponType.COUPON_GIFT.getCode().equals(wxCouponCVo.getType())){ | if(EnumCouponType.COUPON_GIFT.getCode().equals(wxCouponCVo.getType())){ | ||||
| @@ -1101,5 +1103,23 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return couponMap; | return couponMap; | ||||
| } | } | ||||
| @Override | |||||
| public List<WxMerchantVo> getCouponMerchantList(TenantEntity tenantInfo, Long couponId) { | |||||
| List<Long> couponIdList = new ArrayList<Long>(); | |||||
| couponIdList.add(couponId); | |||||
| Map<Long, List<WxMerchantVo>> couponMerchantVoMap = wxMerchantService.findCouponMerchantVoList(couponIdList, tenantInfo,true); | |||||
| List<WxMerchantVo> merchantList = couponMerchantVoMap.get(couponId); | |||||
| if (merchantList != null) { | |||||
| merchantList = merchantList.stream().sorted(Comparator.comparing(m -> m.getTtPoi(), Comparator.nullsLast(String::compareTo))).collect(toList()); | |||||
| merchantList = merchantList.stream().filter( | |||||
| m->m.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())) | |||||
| .collect(toList()); | |||||
| } | |||||
| return merchantList; | |||||
| } | |||||
| } | } | ||||
| @@ -1251,6 +1251,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| TtMerchantPoi poi = poiMap.get(m.getId()); | TtMerchantPoi poi = poiMap.get(m.getId()); | ||||
| if(null != poi){ | if(null != poi){ | ||||
| m.setAddr(poi.getAddress()); | m.setAddr(poi.getAddress()); | ||||
| m.setTtPoi(poi.getPoiId()); | |||||
| m.setLongitude(poi.getLongitude()); | m.setLongitude(poi.getLongitude()); | ||||
| m.setLatitude(poi.getLatitude()); | m.setLatitude(poi.getLatitude()); | ||||
| } | } | ||||
| @@ -1318,6 +1319,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| vo.setShopVoList(merchantShopVoList.get(vo.getId())); | vo.setShopVoList(merchantShopVoList.get(vo.getId())); | ||||
| } | } | ||||
| vo.setAddr(m.getAddr()); | vo.setAddr(m.getAddr()); | ||||
| vo.setTtPoi(m.getTtPoi()); | |||||
| vo.setLongitude(m.getLongitude()); | vo.setLongitude(m.getLongitude()); | ||||
| vo.setLatitude(m.getLatitude()); | vo.setLatitude(m.getLatitude()); | ||||
| return vo; | return vo; | ||||
| @@ -1630,6 +1632,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| TtMerchantPoi poi = poiMap.get(m.getId()); | TtMerchantPoi poi = poiMap.get(m.getId()); | ||||
| if(null != poi){ | if(null != poi){ | ||||
| m.setAddr(poi.getAddress()); | m.setAddr(poi.getAddress()); | ||||
| m.setTtPoi(poi.getPoiId()); | |||||
| m.setLongitude(poi.getLongitude()); | m.setLongitude(poi.getLongitude()); | ||||
| m.setLatitude(poi.getLatitude()); | m.setLatitude(poi.getLatitude()); | ||||
| } | } | ||||
| @@ -1654,6 +1657,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| vo.setId(m.getId()); | vo.setId(m.getId()); | ||||
| vo.setAddr(m.getAddr()); | vo.setAddr(m.getAddr()); | ||||
| vo.setTtPoi(m.getTtPoi()); | |||||
| vo.setLongitude(m.getLongitude()); | vo.setLongitude(m.getLongitude()); | ||||
| vo.setLatitude(m.getLatitude()); | vo.setLatitude(m.getLatitude()); | ||||
| vo.setMerchantImgUrl(m.getImgUrl()); | vo.setMerchantImgUrl(m.getImgUrl()); | ||||
| @@ -120,8 +120,8 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| } | } | ||||
| //目前订单都是一笔一笔同步,暂不支持购物车 | //目前订单都是一笔一笔同步,暂不支持购物车 | ||||
| WxOrderCouponVo wxOrderCouponVo = batchOrder.getOrders().get(0); | WxOrderCouponVo wxOrderCouponVo = batchOrder.getOrders().get(0); | ||||
| // List<WxMerchantVo> merchantList = wxOrderCouponVo.getMerchantVoList().stream().sorted(Comparator.comparing(m -> m.getTtPoi(), Comparator.nullsLast(String::compareTo))).collect(toList()); | |||||
| List<WxMerchantVo> merchantList = wxOrderCouponVo.getMerchantVoList(); | |||||
| List<WxMerchantVo> merchantList = wxOrderCouponVo.getMerchantVoList().stream().sorted(Comparator.comparing(m -> m.getTtPoi(), Comparator.nullsLast(String::compareTo))).collect(toList()); | |||||
| TtMaService ttappService = maUtil.getTtMaService(appInfo); | TtMaService ttappService = maUtil.getTtMaService(appInfo); | ||||
| // map.put("access_token",appInfo.getAccessToken());//后面会自动加上 | // map.put("access_token",appInfo.getAccessToken());//后面会自动加上 | ||||
| Map<String,Object> map = new HashMap<>(); | Map<String,Object> map = new HashMap<>(); | ||||
| @@ -85,6 +85,9 @@ public class Constant { | |||||
| public static final String importMemPrev = "importmem:"; | public static final String importMemPrev = "importmem:"; | ||||
| public static final String importInvestCustomerPrev = "importinvestcustomer:"; | public static final String importInvestCustomerPrev = "importinvestcustomer:"; | ||||
| //商品门店 | |||||
| public static final String coupon_merchants_key = "coupon:merchants:"; | |||||
| //限制接口访问次数 | //限制接口访问次数 | ||||
| public static final String INTERFACE_VISIT_LIMIT_KEY = "INTERFACE:LIMIT:"; | public static final String INTERFACE_VISIT_LIMIT_KEY = "INTERFACE:LIMIT:"; | ||||