| @@ -19,17 +19,17 @@ public class TtMerchantPoi extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value=" merchant_id",name="supplierExtId") | |||
| private String supplierExtId; | |||
| @io.swagger.annotations.ApiModelProperty(value="poi名称 商户名",name="poiName") | |||
| private String poiName; | |||
| @io.swagger.annotations.ApiModelProperty(value="商户名",name="merchantName") | |||
| private String merchantName; | |||
| @io.swagger.annotations.ApiModelProperty(value="省",name="province") | |||
| private String province; | |||
| @io.swagger.annotations.ApiModelProperty(value="商户省",name="merchantProvince") | |||
| private String merchantProvince; | |||
| @io.swagger.annotations.ApiModelProperty(value="市",name="city") | |||
| private String city; | |||
| @io.swagger.annotations.ApiModelProperty(value="商户市",name="merchantCity") | |||
| private String merchantCity; | |||
| @io.swagger.annotations.ApiModelProperty(value="地址",name="address") | |||
| private String address; | |||
| @io.swagger.annotations.ApiModelProperty(value="商户地址",name="merchantAddr") | |||
| private String merchantAddr; | |||
| @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") | |||
| private Float longitude; | |||
| @@ -46,10 +46,22 @@ public class TtMerchantPoi extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="高德POI ID/抖音POIID",name="poiId") | |||
| private String poiId; | |||
| @io.swagger.annotations.ApiModelProperty(value="poi名称 ",name="poiName") | |||
| private String poiName; | |||
| @io.swagger.annotations.ApiModelProperty(value="省",name="province") | |||
| private String province; | |||
| @io.swagger.annotations.ApiModelProperty(value="市",name="city") | |||
| private String city; | |||
| @io.swagger.annotations.ApiModelProperty(value="地址",name="address") | |||
| private String address; | |||
| @io.swagger.annotations.ApiModelProperty(value="抖音平台任务ID",name="taskId") | |||
| private String taskId; | |||
| @io.swagger.annotations.ApiModelProperty(value="匹配状态,0-等待匹配,1-正在匹配,2-匹配成功,3-匹配失败",name="matchStatus") | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumSupplierMathStatus 匹配状态,0-等待匹配,1-正在匹配,2-匹配成功,3-匹配失败",name="matchStatus") | |||
| private Integer matchStatus; | |||
| @io.swagger.annotations.ApiModelProperty(value="匹配状态描述",name="mismatchStatusDesc") | |||
| @@ -60,4 +72,13 @@ public class TtMerchantPoi extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="抖音平台商户ID",name="supplierId") | |||
| private String supplierId; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumSupplierSyncStatus 最近一次同步状态, 0 - 未处理; 1 - 通过; 2 - 未通过",name="lastSyncStatus") | |||
| private Integer lastSyncStatus; | |||
| @io.swagger.annotations.ApiModelProperty(value="同步失败原因,抖音风控政策问题,该字段无法提供太多信息,目前审核不通过联系抖音运营做进一步处理",name="failReason") | |||
| private String failReason; | |||
| } | |||
| @@ -82,7 +82,7 @@ public class TtSupplierSync implements Serializable { | |||
| * 1101 JsonArray 酒店服务 | |||
| * ************* | |||
| */ | |||
| private JsonObject attributes;//店铺属性字段,编号规则:垂直行业 1xxx-酒店民宿 2xxx-餐饮 3xxx-景区 通用属性-9yxxx | |||
| private JsonObject attributes = new JsonObject();//店铺属性字段,编号规则:垂直行业 1xxx-酒店民宿 2xxx-餐饮 3xxx-景区 通用属性-9yxxx | |||
| private String longitude;//经度 | |||
| private List<String> openTime;//营业时间, 从周一到周日,list长度为7,不营业则为空字符串 | |||
| @@ -7,20 +7,22 @@ import java.util.Map; | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumBusiness { | |||
| //抖音poi同步店铺类型 | |||
| //店铺类型 1 - 酒店民宿 2 - 餐饮 3 - 景区 4 - 电商 5 - 教育 6 - 丽人 7 - 爱车 8 - 亲子 9 - 宠物 10 - 家装 11 - 娱乐场所 12 - 图文快印 | |||
| // 0:无, 1:餐饮, 2:娱乐, 3:服饰, 4:亲子, 5:超市, 6:其他 | |||
| BUSINESS_NULL(0, "无"), | |||
| BUSINESS_ID1(1, "餐饮"), | |||
| BUSINESS_ID2(2, "娱乐"), | |||
| BUSINESS_ID3(3, "服饰"), | |||
| BUSINESS_ID4(4, "亲子"), | |||
| BUSINESS_ID5(5, "超市"), | |||
| BUSINESS_ID6(6, "其它"), | |||
| BUSINESS_ID7(7, "美妆"), | |||
| BUSINESS_ID8(8, "珠宝"), | |||
| BUSINESS_ID9(9, "服务"), | |||
| BUSINESS_ID10(10, "家居"), | |||
| BUSINESS_ID11(11, "数码家电"), | |||
| BUSINESS_NULL(0, "无", null), | |||
| BUSINESS_ID1(1, "餐饮", 2), | |||
| BUSINESS_ID2(2, "娱乐", 11), | |||
| BUSINESS_ID3(3, "服饰", 6), | |||
| BUSINESS_ID4(4, "亲子", 8), | |||
| BUSINESS_ID5(5, "超市", null), | |||
| BUSINESS_ID6(6, "其它", null), | |||
| BUSINESS_ID7(7, "美妆",6), | |||
| BUSINESS_ID8(8, "珠宝",null), | |||
| BUSINESS_ID9(9, "服务",11), | |||
| BUSINESS_ID10(10, "家居",10), | |||
| BUSINESS_ID11(11, "数码家电",null), | |||
| ; | |||
| private static Map<Integer,EnumBusiness> map = new HashMap<Integer,EnumBusiness>(); | |||
| @@ -44,11 +46,13 @@ public enum EnumBusiness { | |||
| private Integer code; | |||
| private String message; | |||
| private Integer ttType; | |||
| EnumBusiness(Integer code, String message) { | |||
| EnumBusiness(Integer code, String message,Integer ttType) { | |||
| this.code = code; | |||
| this.message = message; | |||
| this.ttType = ttType; | |||
| } | |||
| public Integer getCode() { | |||
| @@ -58,4 +62,8 @@ public enum EnumBusiness { | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| public Integer getTtType() { | |||
| return ttType; | |||
| } | |||
| } | |||
| @@ -0,0 +1,38 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumSupplierSyncStatus { | |||
| // 最近一次同步状态, 0 - 未处理; 1 - 通过; 2 - 未通过 | |||
| // match_update(-1, "等待重新同步"), | |||
| match_wait(0, " 未处理"), | |||
| match_success(1, "通过"), | |||
| match_fail(2, "未通过"), | |||
| ; | |||
| public static EnumSupplierSyncStatus getEnum(Integer code) { | |||
| for (EnumSupplierSyncStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumSupplierSyncStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -3,16 +3,19 @@ package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.google.gson.JsonArray; | |||
| import com.google.gson.JsonObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.douyin.web.api.TtWebService; | |||
| import com.iformall.douyin.web.bean.TtSupplierMatch; | |||
| import com.iformall.douyin.web.bean.TtSupplierMatchList; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumSupplierMathStatus; | |||
| import com.iformall.douyin.web.bean.TtSupplierSync; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.Constant; | |||
| @@ -93,10 +96,10 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| poi.setId(merchant.getId()); | |||
| poi.updateTenantInfo(mall); | |||
| poi.setSupplierExtId(merchant.getId().toString()); | |||
| poi.setPoiName(merchant.getName()); | |||
| poi.setProvince(mall.getProvince()); | |||
| poi.setCity(mall.getCity()); | |||
| poi.setAddress(mall.getAddr()); | |||
| poi.setMerchantName(merchant.getName()); | |||
| poi.setMerchantProvince(mall.getProvince()); | |||
| poi.setMerchantCity(mall.getCity()); | |||
| poi.setMerchantAddr(mall.getAddr()); | |||
| poi.setLongitude(mall.getLongitude() == null?null:mall.getLongitude().floatValue()); | |||
| poi.setLatitude(mall.getLatitude() == null?null:mall.getLatitude().floatValue()); | |||
| poi.setMatchStatus(EnumSupplierMathStatus.match_update.getCode()); | |||
| @@ -189,20 +192,69 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| if(!EnumSupplierMathStatus.match_success.getCode().equals(merchantPoi.getMatchStatus())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该店铺未匹配成功,暂不能同步"); | |||
| } | |||
| WxMerchant merchant = wxMerchantMapper.selectById(id); | |||
| String supplierId = supplierSync(tenantInfo, merchantPoi, merchant); | |||
| if(StringUtils.isBlank(supplierId)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败"); | |||
| } | |||
| TtMerchantPoi updPoi = new TtMerchantPoi(); | |||
| updPoi.setId(id); | |||
| updPoi.setSupplierId(supplierId); | |||
| updPoi.setLastSyncStatus(EnumSupplierSyncStatus.match_wait.getCode()); | |||
| updPoi.setUpdateDate(new Date()); | |||
| ttMerchantPoiMapper.updateById(merchantPoi); | |||
| return new ResultData(); | |||
| } | |||
| private String supplierSync(TenantEntity tenantInfo,TtMerchantPoi merchantPoi,WxMerchant merchant){ | |||
| TtSupplierSync supplierSync = new TtSupplierSync(); | |||
| supplierSync.setContactPhone(merchant.getLinkPhone()); | |||
| List<String> images = new ArrayList<>(); | |||
| images.add(merchant.getImgUrl()); | |||
| supplierSync.setImages(images); | |||
| // supplierSync.setMerchantUid();//如果开启分账并且已进件 | |||
| // supplierSync.setServiceProvider();//营业执照等 | |||
| supplierSync.setSupplierExtId(merchant.getId().toString()); | |||
| supplierSync.setStatus(EnumMerchantStatus.VALID.getCode().equals(merchant.getStatus())?1:2); | |||
| supplierSync.setAddress(merchantPoi.getAddress()); | |||
| // supplierSync.setAvgCost();//人均消费(单位分) | |||
| // supplierSync.setCustomerInfo();//商家资质 | |||
| supplierSync.setDescription(merchant.getIntroduction()); | |||
| supplierSync.setName(merchant.getName()); | |||
| // supplierSync.setRecommends();//推荐 | |||
| supplierSync.setServices(getServices()); | |||
| // supplierSync.setLongitude();//经度 | |||
| // supplierSync.setLatitude();//纬度 | |||
| // supplierSync.setOpenTime();// 营业时间, 从周一到周日,list长度为7, | |||
| supplierSync.setPoiId(merchantPoi.getPoiId()); | |||
| return null; | |||
| //如果抖音没有这个类型怎么办 | |||
| Integer ttType = EnumBusiness.getEnum(merchant.getBusinessId()).getTtType(); | |||
| if(ttType == null){ | |||
| logger.error("未找到对应的店铺类型"); | |||
| throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),"未找到对应的店铺类型"); | |||
| } | |||
| supplierSync.setType(ttType); | |||
| String supplierId = null; | |||
| try { | |||
| supplierId = getTtWebService(tenantInfo).getProductService().supplierSync(supplierSync); | |||
| } catch (WxErrorException e) { | |||
| logger.error("发起店铺同步error"+e.getMessage()); | |||
| throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| return supplierId; | |||
| } | |||
| private String supplierMatch(TenantEntity tenantInfo, List<TtMerchantPoi> merchantPoiList){ | |||
| private String supplierMatch(TenantEntity tenantInfo, List<TtMerchantPoi> merchantPoiList) throws MallinkException{ | |||
| TtSupplierMatchList matchList = new TtSupplierMatchList(); | |||
| for (TtMerchantPoi poi:merchantPoiList) { | |||
| TtSupplierMatch match = new TtSupplierMatch(); | |||
| match.setSupplierExtId(poi.getSupplierExtId()); | |||
| match.setPoiName(poi.getPoiName()); | |||
| match.setProvince(poi.getProvince()); | |||
| match.setCity(poi.getCity()); | |||
| match.setAddress(poi.getAddress()); | |||
| match.setPoiName(poi.getMerchantName()); | |||
| match.setProvince(poi.getMerchantProvince()); | |||
| match.setCity(poi.getMerchantCity()); | |||
| match.setAddress(poi.getMerchantAddr()); | |||
| match.setLongitude(poi.getLongitude()); | |||
| match.setLatitude(poi.getLatitude()); | |||
| match.setAmapId(poi.getAmapId()); | |||
| @@ -214,6 +266,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| taskId = getTtWebService(tenantInfo).getShopMatchService().supplierMatch(matchList); | |||
| } catch (WxErrorException e) { | |||
| logger.error("发起店铺匹配POI同步任务error"+e.getMessage()); | |||
| throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| return taskId; | |||
| } | |||
| @@ -261,4 +314,15 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| } | |||
| } | |||
| //__________________________________店铺同步_______________________________________________ | |||
| //团购券类型 services 中的 service_type 必须包含 9101,门票类型 services 中的 service_type 必须包含 9001 | |||
| private JsonArray getServices(){ | |||
| JsonArray jsonArray = new JsonArray(); | |||
| JsonObject jsonObject = new JsonObject(); | |||
| jsonObject.addProperty("enable",1); | |||
| jsonObject.addProperty("service_type",9101); | |||
| jsonArray.add(jsonObject); | |||
| return jsonArray; | |||
| } | |||
| } | |||
| @@ -6,26 +6,43 @@ | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="supplier_ext_id" jdbcType="VARCHAR" property="supplierExtId"/> | |||
| <result column="poi_name" jdbcType="VARCHAR" property="poiName"/> | |||
| <result column="province" jdbcType="VARCHAR" property="province"/> | |||
| <result column="city" jdbcType="VARCHAR" property="city"/> | |||
| <result column="address" jdbcType="VARCHAR" property="address"/> | |||
| <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | |||
| <result column="merchant_province" jdbcType="VARCHAR" property="merchantProvince"/> | |||
| <result column="merchant_city" jdbcType="VARCHAR" property="merchantCity"/> | |||
| <result column="merchant_addr" jdbcType="VARCHAR" property="merchantAddr"/> | |||
| <result column="longitude" jdbcType="FLOAT" property="longitude"/> | |||
| <result column="latitude" jdbcType="FLOAT" property="latitude"/> | |||
| <result column="amap_id" jdbcType="VARCHAR" property="amapId"/> | |||
| <result column="extra" jdbcType="VARCHAR" property="extra"/> | |||
| <result column="poi_id" jdbcType="VARCHAR" property="poiId"/> | |||
| <result column="poi_name" jdbcType="VARCHAR" property="poiName"/> | |||
| <result column="province" jdbcType="VARCHAR" property="province"/> | |||
| <result column="city" jdbcType="VARCHAR" property="city"/> | |||
| <result column="address" jdbcType="VARCHAR" property="address"/> | |||
| <result column="task_id" jdbcType="VARCHAR" property="taskId"/> | |||
| <result column="match_status" jdbcType="INTEGER" property="matchStatus"/> | |||
| <result column="mismatch_status_desc" jdbcType="VARCHAR" property="mismatchStatusDesc"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="supplier_id" jdbcType="VARCHAR" property="supplierId"/> | |||
| <result column="last_sync_status" jdbcType="INTEGER" property="lastSyncStatus"/> | |||
| <result column="fail_reason" jdbcType="VARCHAR" property="failReason"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`supplier_ext_id`,`poi_name`,`province`,`city`,`address`, | |||
| `longitude`,`latitude`,`amap_id`,`extra`,`poi_id`,`task_id`,`match_status`,`mismatch_status_desc`, | |||
| `create_date`,`update_date` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`supplier_ext_id`, | |||
| `merchant_name`,`merchant_province`,`merchant_city`,`merchant_addr`,`longitude`,`latitude`, | |||
| `amap_id`,`extra`, | |||
| `poi_id`,`poi_name`,`province`,`city`,`address`, | |||
| `task_id`,`match_status`,`mismatch_status_desc`, | |||
| `create_date`,`update_date`, | |||
| `supplier_id`,`last_sync_status`,`fail_reason` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -50,8 +67,8 @@ | |||
| and `poi_id` = #{poiId} | |||
| </if> | |||
| <if test=" null != poiName and ''!= poiName "> | |||
| and `poi_name` like concat('%', #{poiName},'%') | |||
| <if test=" null != merchantName and ''!= merchantName "> | |||
| and `merchant_name` like concat('%', #{merchantName},'%') | |||
| </if> | |||
| <if test=" null != taskId and ''!= taskId "> | |||
| @@ -62,6 +79,14 @@ | |||
| and `match_status` = #{matchStatus} | |||
| </if> | |||
| <if test=" null != supplierId and '' != supplierId"> | |||
| and `supplier_id` = #{supplierId} | |||
| </if> | |||
| <if test=" null != lastSynStatus"> | |||
| and `last_sync_status` = #{lastSynStatus} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and `id` in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||