| @@ -9,9 +9,11 @@ import java.util.Map; | |||
| import java.util.concurrent.TimeUnit; | |||
| import java.util.stream.Collectors; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMiniappThemeValue; | |||
| import com.iformall.enums.EnumCouponType; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import org.apache.commons.beanutils.BeanUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| @@ -227,6 +229,10 @@ public class WxCouponController extends BaseController { | |||
| } | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> objectCommonRedisTemplate; | |||
| @ApiOperation("根据id(couponChannel)查询接口") | |||
| @GetMapping("/detail") | |||
| @ApiImplicitParams({ | |||
| @@ -372,6 +378,32 @@ public class WxCouponController extends BaseController { | |||
| 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) { | |||
| WxCouponChannel cc = wxCouponChannelService.getById(couponChannelIdL,tenantId); | |||
| @@ -346,6 +346,10 @@ public class WxMerchant extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private String addr; | |||
| @io.swagger.annotations.ApiModelProperty(value="ttPoi",name="ttPoi") | |||
| @TableField(exist = false) | |||
| private String ttPoi; | |||
| @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") | |||
| @TableField(exist = false) | |||
| private BigDecimal longitude; | |||
| @@ -101,6 +101,10 @@ public class WxMerchantVo extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "置顶时间", name = "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") | |||
| @TableField(exist = false) | |||
| private BigDecimal longitude; | |||
| @@ -128,6 +132,7 @@ public class WxMerchantVo extends TenantEntity { | |||
| this.linkLinePhone = m.getLinkLinePhone(); | |||
| this.topTime = m.getTopTime(); | |||
| this.addr = m.getAddr(); | |||
| this.ttPoi = m.getTtPoi(); | |||
| this.longitude = m.getLongitude(); | |||
| 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 result = this.service.execute(executor, apiUrl, spuStockSync.toJson()); | |||
| 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; | |||
| } | |||
| // String spuExtId = jsonObject.getString("spu_ext_id"); | |||
| // if(spuStockSync.getSpuExtId().equals(spuExtId)){ | |||
| // return true; | |||
| // } | |||
| return false; | |||
| } | |||
| } | |||
| @@ -11,6 +11,7 @@ import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCouponCVo; | |||
| import com.iformall.domain.vo.WxCouponStatisVo; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| public interface WxCouponService { | |||
| @@ -265,4 +266,6 @@ public interface WxCouponService { | |||
| Map<Long,String> getCouponMerchantMap(List<Long> couponIds,TenantEntity tenantEntity,boolean onlyOneMerchantCoupons); | |||
| 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()); | |||
| List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); | |||
| 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)){ | |||
| 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.HttpServletResponse; | |||
| import static java.util.stream.Collectors.toList; | |||
| @Service | |||
| public class WxCouponServiceImpl implements WxCouponService { | |||
| @@ -154,7 +156,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| 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.updateTenantInfo(wxCoupon); | |||
| wxCouponChannel.setCouponIds(ids); | |||
| @@ -259,7 +261,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| if (merchantList != null) { | |||
| merchantList = merchantList.stream().filter( | |||
| m->m.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())) | |||
| .collect(Collectors.toList()); | |||
| .collect(toList()); | |||
| } | |||
| wxCouponCVo.setMerchantVoList(merchantList); | |||
| if(EnumCouponType.COUPON_GIFT.getCode().equals(wxCouponCVo.getType())){ | |||
| @@ -1111,5 +1113,23 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| 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; | |||
| } | |||
| } | |||
| @@ -1011,7 +1011,11 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| Long floor = record.getFloor(); | |||
| List<Long> floorMerchantIds = getFloorBuildMerchantIds(record, floorRule, building, floor, 0, 0); | |||
| if (null != floorMerchantIds) { | |||
| merchantIds.retainAll(floorMerchantIds); | |||
| if(merchantIds.size() > 0){ | |||
| merchantIds.retainAll(floorMerchantIds); | |||
| }else{ | |||
| merchantIds.addAll(floorMerchantIds); | |||
| } | |||
| } | |||
| if (merchantIds.size() > 0 ) { | |||
| record.setIds(merchantIds); | |||
| @@ -1065,6 +1069,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| floorMerchantIds.add(-999L); | |||
| return floorMerchantIds; | |||
| } | |||
| return floorMerchantIds; | |||
| } | |||
| return null; | |||
| } | |||
| @@ -1251,6 +1256,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| TtMerchantPoi poi = poiMap.get(m.getId()); | |||
| if(null != poi){ | |||
| m.setAddr(poi.getAddress()); | |||
| m.setTtPoi(poi.getPoiId()); | |||
| m.setLongitude(poi.getLongitude()); | |||
| m.setLatitude(poi.getLatitude()); | |||
| } | |||
| @@ -1318,6 +1324,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| vo.setShopVoList(merchantShopVoList.get(vo.getId())); | |||
| } | |||
| vo.setAddr(m.getAddr()); | |||
| vo.setTtPoi(m.getTtPoi()); | |||
| vo.setLongitude(m.getLongitude()); | |||
| vo.setLatitude(m.getLatitude()); | |||
| return vo; | |||
| @@ -1630,6 +1637,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| TtMerchantPoi poi = poiMap.get(m.getId()); | |||
| if(null != poi){ | |||
| m.setAddr(poi.getAddress()); | |||
| m.setTtPoi(poi.getPoiId()); | |||
| m.setLongitude(poi.getLongitude()); | |||
| m.setLatitude(poi.getLatitude()); | |||
| } | |||
| @@ -1654,6 +1662,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| vo.setId(m.getId()); | |||
| vo.setAddr(m.getAddr()); | |||
| vo.setTtPoi(m.getTtPoi()); | |||
| vo.setLongitude(m.getLongitude()); | |||
| vo.setLatitude(m.getLatitude()); | |||
| vo.setMerchantImgUrl(m.getImgUrl()); | |||
| @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||
| import com.iformall.douyin.miniapp.api.TtMaService; | |||
| import com.iformall.douyin.pay.DouYinPayHelper; | |||
| @@ -29,6 +30,8 @@ import org.springframework.stereotype.Service; | |||
| import java.io.File; | |||
| import java.util.*; | |||
| import static java.util.stream.Collectors.toList; | |||
| @Slf4j | |||
| @Service | |||
| public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implements CDrivingPayService{ | |||
| @@ -117,6 +120,7 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| } | |||
| //目前订单都是一笔一笔同步,暂不支持购物车 | |||
| WxOrderCouponVo wxOrderCouponVo = batchOrder.getOrders().get(0); | |||
| List<WxMerchantVo> merchantList = wxOrderCouponVo.getMerchantVoList().stream().sorted(Comparator.comparing(m -> m.getTtPoi(), Comparator.nullsLast(String::compareTo))).collect(toList()); | |||
| TtMaService ttappService = maUtil.getTtMaService(appInfo); | |||
| // map.put("access_token",appInfo.getAccessToken());//后面会自动加上 | |||
| @@ -126,7 +130,7 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| map.put("payment_order_no", payOrder.getTransactionId()); | |||
| if(isPoiOrder){ | |||
| map.put("client_key",clientKey);//第三方在开放平台申请的 ClientKey(生活服务订单必传) | |||
| map.put("ext_shop_id",wxOrderCouponVo.getMerchantVoList().get(0).getId());//生活服务外部商户 id,购买店铺 id (生活服务订单必传) | |||
| map.put("ext_shop_id",merchantList.get(0).getId().toString());//生活服务外部商户 id,购买店铺 id (生活服务订单必传) | |||
| map.put("order_type",9101); | |||
| }else{ | |||
| map.put("order_type",0); | |||
| @@ -142,7 +146,7 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| if(isPoiOrder){ | |||
| orderDetail.put("ext_order_id",payOrder.getPayOrderNo()); | |||
| orderDetail.put("status", getTtPoiOrderStatus(wxOrderCouponVo.getOrderStatus(),wxOrderCouponVo.getCouponOrderStatus()).getCode()); | |||
| orderDetail.put("shop_name",wxOrderCouponVo.getMerchantVoList().get(0).getMerchantName()); | |||
| orderDetail.put("shop_name",merchantList.get(0).getMerchantName()); | |||
| orderDetail.put("entry_type",2); | |||
| orderDetail.put("entry_schema",getOrderEntrySchema(appInfo.getAppId(),batchOrder.getId())); | |||
| orderDetail.put("create_order_time",batchOrder.getCreateDate().getTime()); | |||
| @@ -153,13 +157,13 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| } | |||
| if(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode().equals(wxOrderCouponVo.getCouponOrderStatus()) | |||
| && wxOrderCouponVo.getBMerchantId() != null){ | |||
| orderDetail.put("ext_valid_shop_id",wxOrderCouponVo.getBMerchantId()); | |||
| orderDetail.put("ext_valid_shop_id",wxOrderCouponVo.getBMerchantId().toString()); | |||
| TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(wxOrderCouponVo.getBMerchantId()); | |||
| if(merchantPoi != null){ | |||
| orderDetail.put("valid_poi_id_str",merchantPoi.getPoiId()); | |||
| } | |||
| } | |||
| orderDetail.put("ext_goods_id",wxOrderCouponVo.getCouponChannelId()); | |||
| orderDetail.put("ext_goods_id",wxOrderCouponVo.getCouponChannelId().toString()); | |||
| orderDetail.put("goods_name",wxOrderCouponVo.getTitle()); | |||
| // orderDetail.put("goods_info","");//商品描述信息。向用户介绍商品,最多120字。 | |||
| orderDetail.put("goods_cover_image",wxOrderCouponVo.getCoverImg()); | |||
| @@ -85,6 +85,9 @@ public class Constant { | |||
| public static final String importMemPrev = "importmem:"; | |||
| 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:"; | |||