fanli/src/main/java/com/yeshi/fanli/controller/DouYinCallBackController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/dao/ad/DouYinClickEventDao.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/entity/ad/DouYinClickEvent.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/service/impl/ad/DouYinClickEventServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/service/inter/ad/DouYinClickEventService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeOrderApiUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
fanli/src/main/java/com/yeshi/fanli/controller/DouYinCallBackController.java
@@ -2,16 +2,19 @@ import java.io.PrintWriter; import javax.annotation.Resource; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.google.gson.Gson; import com.yeshi.fanli.entity.ad.DouYinClickEvent; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.ad.DouYinClickEventService; @Controller @RequestMapping("ad/callback/douyin") public class DouYinCallBackController { @Resource private DouYinClickEventService douYinClickEventService; /** * 抖音下载回调 @@ -20,7 +23,7 @@ */ @RequestMapping("monitor") public void download(DouYinClickEvent event, PrintWriter out) { LogHelper.test(new Gson().toJson(event)); douYinClickEventService.save(event); out.print("success"); } fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserMsgController.java
@@ -594,7 +594,9 @@ // 创建时间在28号后的才有新人欢迎 if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) { UserHomeMsgVO vo = new UserHomeMsgVO(); vo.setContent(String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!",Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()))); vo.setContent(String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!", Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()), Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()))); vo.setTitle("新人欢迎"); vo.setCreateTime(getTimeDesc(now, new Date(time))); vo.setType(UserHomeMsgVO.TYPE_WELCOME); @@ -745,8 +747,9 @@ // 1、活动区域 int platformCode = Constant.getPlatformCode(acceptData.getPlatform()); List<Special> listSpecial = specialService.listByPlaceKey("msg_activities", platformCode, Integer.parseInt(acceptData.getVersion())); List<Special> listSpecial = specialService.listByPlaceKey("msg_activities", platformCode, Integer.parseInt(acceptData.getVersion())); if (listSpecial != null && listSpecial.size() > 0) { for (Special special : listSpecial) { @@ -844,7 +847,10 @@ if ((time > TimeUtil.convertToTimeTemp("2019-01-28", "yyyy-MM-dd") || uid == null)) { Map<String, Object> map = new HashMap<String, Object>(); map.put("title", "新人欢迎"); map.put("content",String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!",Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()),Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()))); map.put("content", String.format("恭喜你,成为%s的用户\n独家优惠券帮你省钱;\n参与奖金活动帮你赚钱;\n让%s成为你的省钱助手吧!", Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()), Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()))); map.put("createTime", new Date(time)); UserMsgCenter msgCenternre = new UserMsgCenter(); msgCenternre.setWelcomeMsg(map); @@ -873,26 +879,27 @@ /** * 提醒大图 */ MsgCommonDTO notify = msgConfigService.getNotifyMsg(); if (!"douyin".equalsIgnoreCase(acceptData.getChannel())) { MsgCommonDTO notify = msgConfigService.getNotifyMsg(); if (notify != null && notify.getShow() == true) { boolean read = false; MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType( UserCommonMsgVO.TYPE_NOTIFY, acceptData.getDevice(), acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2); if (state != null && state.getReadTime() != null && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime()) read = true; if (notify.getJumpDetail() == null) read = true; // 查询是否已读 UserCommonMsgVO vo = new UserCommonMsgVO(notify.getIcon(), notify.getTitle(), notify.getUpdateTime(), UserCommonMsgVO.TYPE_NOTIFY, notify.getContent(), read, notify.getJumpDetail(), notify.getParams(), 0); vo.setPicture(notify.getPicture()); root.put("notifyMsg", builder.create().toJson(vo)); if (notify != null && notify.getShow() == true) { boolean read = false; MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType( UserCommonMsgVO.TYPE_NOTIFY, acceptData.getDevice(), acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2); if (state != null && state.getReadTime() != null && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime()) read = true; if (notify.getJumpDetail() == null) read = true; // 查询是否已读 UserCommonMsgVO vo = new UserCommonMsgVO(notify.getIcon(), notify.getTitle(), notify.getUpdateTime(), UserCommonMsgVO.TYPE_NOTIFY, notify.getContent(), read, notify.getJumpDetail(), notify.getParams(), 0); vo.setPicture(notify.getPicture()); root.put("notifyMsg", builder.create().toJson(vo)); } } root.put("list", builder.create().toJson(listCenter)); root.put("commonList", builder.create().toJson(commonMsgList)); root.put("count", listCenter.size()); fanli/src/main/java/com/yeshi/fanli/dao/ad/DouYinClickEventDao.java
New file @@ -0,0 +1,17 @@ package com.yeshi.fanli.dao.ad; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import com.yeshi.fanli.dao.MongodbBaseDao; import com.yeshi.fanli.entity.ad.DouYinClickEvent; public class DouYinClickEventDao extends MongodbBaseDao<DouYinClickEvent> { public DouYinClickEvent selectByAid(String aid) { Query query = new Query(); query.addCriteria(Criteria.where("aid").is(aid)); return findOne(query); } } fanli/src/main/java/com/yeshi/fanli/entity/ad/DouYinClickEvent.java
@@ -1,5 +1,6 @@ package com.yeshi.fanli.entity.ad; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Field; @@ -14,6 +15,7 @@ public final static String MONITOR__LINK__PARAMS = "aid=__AID__&aidName=__AID__NAME__&campaignId=__CAMPAIGN__ID__&cid=__CID__&csite=__CSITE__&ctype=__CTYPE__&mac=__MAC__&mac1=__MAC1__&ua=__UA__&idfa=__IDFA__&imei=__IMEI__&uuid=__UUID__&androidId=__ANDROIDID__&openUDID=__OPENUDID__&os=__OS__&ip=__IP__&ts=__TS__&convertId=__CONVERT__ID __&callback=__CALLBACK__PARAM __";// 监测链接 @Id @Field private String aid; // 广告计划id 原值 @Field fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateTBRelationAndSpecialOrderJob.java
@@ -44,16 +44,10 @@ * 结束页码(每页100条数据) */ public void updateRelationAndSpecialOrder(long startTime, long endTime) { List<TaoBaoOrder> list = TaoKeOrderApiUtil.getSpecialOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_ALL); List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getThirdSpecialOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_ALL); List<TaoBaoOrder> list2 = TaoKeOrderApiUtil.getRelationOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_ALL); List<TaoBaoOrder> list3 = TaoKeOrderApiUtil.getThirdRelationOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_ALL); List<TaoBaoOrder> list =TaoKeOrderApiUtil.getTaoBaoSpecialOrderList (startTime, endTime,1); List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList (startTime, endTime,1); if (list1 != null && list1.size() > 0) list.addAll(list1); if (list2 != null && list2.size() > 0) list.addAll(list2); if (list3 != null && list3.size() > 0) list.addAll(list3); // 爬取到的订单号 if (list != null) for (TaoBaoOrder order : list) { @@ -64,22 +58,15 @@ } public void updateRelationAndSpecialSettleOrder(long startTime, long endTime) { List<TaoBaoOrder> list = TaoKeOrderApiUtil.getSpecialOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_SETTLEMENT); List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getThirdSpecialOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_SETTLEMENT); List<TaoBaoOrder> list2 = TaoKeOrderApiUtil.getRelationOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_SETTLEMENT); List<TaoBaoOrder> list3 = TaoKeOrderApiUtil.getThirdRelationOrder(startTime, endTime,TaoKeOrderApiUtil.TK_STATUS_SETTLEMENT); List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoSpecialOrderList (startTime, endTime,3); List<TaoBaoOrder> list1 = TaoKeOrderApiUtil.getTaoBaoRelationOrderList (startTime, endTime,3); if (list1 != null && list1.size() > 0) list.addAll(list1); if (list2 != null && list2.size() > 0) list.addAll(list2); if (list3 != null && list3.size() > 0) list.addAll(list3); // 爬取到的订单号 if (list != null) for (TaoBaoOrder order : list) { LogHelper.orderInfo("爬取到的订单号:" + order.getOrderId()); } addRelationAndSpecialOrder(list); } fanli/src/main/java/com/yeshi/fanli/service/impl/ad/DouYinClickEventServiceImpl.java
New file @@ -0,0 +1,25 @@ package com.yeshi.fanli.service.impl.ad; import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.yeshi.fanli.dao.ad.DouYinClickEventDao; import com.yeshi.fanli.entity.ad.DouYinClickEvent; import com.yeshi.fanli.service.inter.ad.DouYinClickEventService; @Service public class DouYinClickEventServiceImpl implements DouYinClickEventService { @Resource private DouYinClickEventDao douYinClickEventDao; @Override public void save(DouYinClickEvent event) { // 查询 DouYinClickEvent old = douYinClickEventDao.selectByAid(event.getAid()); if (old == null) douYinClickEventDao.save(event); } } fanli/src/main/java/com/yeshi/fanli/service/inter/ad/DouYinClickEventService.java
New file @@ -0,0 +1,11 @@ package com.yeshi.fanli.service.inter.ad; import com.yeshi.fanli.entity.ad.DouYinClickEvent; public interface DouYinClickEventService { public void save(DouYinClickEvent event); } fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeOrderApiUtil.java
@@ -292,6 +292,12 @@ e.printStackTrace(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } return null; } @@ -390,6 +396,101 @@ } } } return orderList; } private static List<TaoBaoOrder> parseTaoBaoOrderNew(String response) { List<TaoBaoOrder> orderList = new ArrayList<>(); JSONArray array = null; JSONObject data = JSONObject.fromObject(response); try { array = data.optJSONObject("tbk_order_details_get_response").optJSONObject("data").optJSONObject("results") .optJSONArray("publisher_order_dto"); } catch (Exception e) { return orderList; } if (array != null) for (int i = 0; i < array.size(); i++) { JSONObject item = array.optJSONObject(i); try { TaoBaoOrder taoBaoOrder = new TaoBaoOrder(); taoBaoOrder.setAdPositionId(item.optString("adzone_id")); taoBaoOrder.setAdPositionName(item.optString("adzone_name")); taoBaoOrder.setAuctionId(item.optLong("item_id")); taoBaoOrder.setClassName(item.optString("item_category_name")); taoBaoOrder.setClickTime(item.optString("click_time")); taoBaoOrder.setCount(item.optInt("item_num")); taoBaoOrder.setCreateTime(item.optString("tk_create_time")); if (!StringUtil.isNullOrEmpty(item.optString("total_commission_fee"))) taoBaoOrder.seteIncome(new BigDecimal(item.optString("total_commission_fee"))); else taoBaoOrder.seteIncome(new BigDecimal(0)); if (!StringUtil.isNullOrEmpty(item.optString("pub_share_pre_fee"))) taoBaoOrder.setEstimate(new BigDecimal(item.optString("pub_share_pre_fee"))); else taoBaoOrder.setEstimate(new BigDecimal(0)); taoBaoOrder.setiRatio(new BigDecimal(item.optString("income_rate"))); taoBaoOrder.setLatestUpdateTime(null); taoBaoOrder.setManagerWangWang(null); taoBaoOrder.setOrderBy(null); taoBaoOrder.setOrderId(item.optString("trade_parent_id")); if (item.optInt("tk_status") == 12) taoBaoOrder.setOrderState("订单付款"); else if (item.optInt("tk_status") == 3) taoBaoOrder.setOrderState("订单结算"); else if (item.optInt("tk_status") == 13) taoBaoOrder.setOrderState("订单失效"); else if (item.optInt("tk_status") == 14) taoBaoOrder.setOrderState("订单成功"); taoBaoOrder.setOrderType(item.optString("order_type")); if (!StringUtil.isNullOrEmpty(item.optString("alipay_total_price"))) taoBaoOrder.setPayment(new BigDecimal(item.optString("alipay_total_price"))); else taoBaoOrder.setPayment(new BigDecimal(0)); taoBaoOrder.setPrice(new BigDecimal(item.optString("item_price"))); if (!StringUtil.isNullOrEmpty(item.optString("pay_price"))) taoBaoOrder.setSettlement(new BigDecimal(item.optString("pay_price"))); else taoBaoOrder.setSettlement(new BigDecimal(0)); taoBaoOrder.setSettlementTime(item.optString("tk_earning_time")); taoBaoOrder.setShop(item.optString("seller_shop_title")); taoBaoOrder.setSourceMediaId(item.optString("site_id")); taoBaoOrder.setSourceMediaName(item.optString("site_name")); taoBaoOrder.setsRatio(null); if (!StringUtil.isNullOrEmpty(item.optString("subsidy_fee")))// 补贴金额 taoBaoOrder.setSubsidy(new BigDecimal(item.optString("subsidy_fee"))); if (!StringUtil.isNullOrEmpty(item.optString("subsidy_rate"))) taoBaoOrder.setSubsidyRatio(new BigDecimal(item.optString("subsidy_rate"))); taoBaoOrder.setSubsidyType(item.optString("subsidy_type")); taoBaoOrder.setTechnologySupportPercent(null); taoBaoOrder.setThirdService(null); taoBaoOrder.setTitle(item.optString("item_title")); if (!StringUtil.isNullOrEmpty(item.optString("total_commission_fee"))) taoBaoOrder.setTkMoney(new BigDecimal(item.optString("total_commission_fee"))); else taoBaoOrder.setTkMoney(new BigDecimal(0)); if (!StringUtil.isNullOrEmpty(item.optString("commission_rate"))) taoBaoOrder.setTkRate(new BigDecimal(item.optString("commission_rate"))); else if (!StringUtil.isNullOrEmpty(item.optString("total_commission_rate"))) taoBaoOrder.setTkRate(new BigDecimal(item.optString("total_commission_rate"))); taoBaoOrder.setTransactionPlatform(item.optString("terminal_type")); taoBaoOrder.setRelationId(item.optString("relation_id")); taoBaoOrder.setSpecialId(item.optString("special_id")); taoBaoOrder.setTradeId(item.optString("trade_id")); orderList.add(taoBaoOrder); } catch (Exception e) { try { LogHelper.errorDetailInfo(e, "订单号信息:" + item.toString(), "订单解析出错"); } catch (Exception e1) { } } } return orderList; } @@ -579,7 +680,7 @@ orderQuery.orderQueryType = "settle_time"; orderQuery.orderScene = 1; orderQuery.pageSize = 100; orderQuery.tkStatus=TK_STATUS_SETTLEMENT; orderQuery.tkStatus = TK_STATUS_SETTLEMENT; int page = 1; orderQuery.pageNo = page; if (third) @@ -732,4 +833,73 @@ return finalResult; } /** * 获取淘宝会员运营订单 * * @param startTime * @param endTime * @return */ public static List<TaoBaoOrder> getTaoBaoSpecialOrderList(long startTime, long endTime, int queryType) { List<TaoBaoOrder> orderList = new ArrayList<>(); // 间隔3小时 long jianGe = endTime - startTime; long page = jianGe / (1000 * 60 * 60 * 3L); if (page == 0) page = 1; for (int i = 1; i <= page; i++) { long start = startTime + (i - 1) * (1000 * 60 * 60 * 3L); long end = start + (1000 * 60 * 60 * 3L); if (end > endTime) end = endTime; List<TaoBaoOrder> tempOrderList = queryNewOrder(TimeUtil.getGernalTime(start, "yyyy-MM-dd HH:mm:ss"), TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"), queryType, 3); if (tempOrderList != null) orderList.addAll(tempOrderList); } return orderList; } public static List<TaoBaoOrder> getTaoBaoRelationOrderList(long startTime, long endTime, int queryType) { List<TaoBaoOrder> orderList = new ArrayList<>(); // 间隔3小时 long jianGe = endTime - startTime; long page = jianGe / (1000 * 60 * 60 * 3L); if (page == 0) page = 1; for (int i = 1; i <= page; i++) { long start = startTime + (i - 1) * (1000 * 60 * 60 * 3L); long end = start + (1000 * 60 * 60 * 3L); if (end > endTime) end = endTime; List<TaoBaoOrder> tempOrderList = queryNewOrder(TimeUtil.getGernalTime(start, "yyyy-MM-dd HH:mm:ss"), TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"), queryType, 2); if (tempOrderList != null) orderList.addAll(tempOrderList); } return orderList; } public static List<TaoBaoOrder> queryNewOrder(String startTime, String endTime, int queryType, int orderScene) { Map<String, String> params = new HashMap<>(); params.put("query_type", queryType + ""); params.put("page_size", "100"); params.put("start_time", startTime); params.put("end_time", endTime); params.put("page_no", "1"); params.put("order_scene", orderScene + ""); params.put("method", "taobao.tbk.order.details.get"); TaoKeAppInfo app = new TaoKeAppInfo(); app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); try { JSONObject json = TaoKeBaseUtil.baseRequest(params, app); List<TaoBaoOrder> orderList = parseTaoBaoOrderNew(json.toString()); return orderList; } catch (TaoKeApiException e) { e.printStackTrace(); } return new ArrayList<>(); } }