| | |
| | | |
| | | </exclusions> |
| | | </dependency> |
| | | <!-- rabbitmq --> |
| | | <dependency> |
| | | <groupId>org.springframework.amqp</groupId> |
| | | <artifactId>spring-rabbit</artifactId> |
| | | <version>2.3.10</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.springframework</groupId> |
| | | <artifactId>spring-tx</artifactId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <groupId>org.springframework</groupId> |
| | | <artifactId>spring-core</artifactId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <groupId>org.springframework</groupId> |
| | | <artifactId>spring-context</artifactId> |
| | | </exclusion> |
| | | |
| | | <exclusion> |
| | | <groupId>org.springframework</groupId> |
| | | <artifactId>spring-beans</artifactId> |
| | | </exclusion> |
| | | |
| | | |
| | | </exclusions> |
| | | </dependency> |
| | | </dependencies> |
| | | <build> |
| | | <plugins> |
| | |
| | | import org.quartz.SchedulerException; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageProperties; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.cache.ehcache.EhCacheCacheManager; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | |
| | | @Controller |
| | |
| | | |
| | | @Resource |
| | | private TaoBaoCouponCacheService taoBaoCouponCacheService; |
| | | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @RequestMapping(value = "kefu") |
| | | public void kefu(HttpServletRequest request, PrintWriter out) { |
| | |
| | | out.print("success"); |
| | | } |
| | | |
| | | @RequestMapping("testRabbit") |
| | | public void testRabbit(){ |
| | | String msg = "你好:"+TimeUtil.getGernalTime(System.currentTimeMillis(),"yyyy-MM-dd HH:mm:ss"); |
| | | // 向队列发送消息 |
| | | // rabbitTemplate.convertAndSend("order-all-fanli",msg); |
| | | // 向exchange发送消息 |
| | | // rabbitTemplate.convertAndSend("topic_place_order", "*", msg); |
| | | |
| | | // Message message = MessageBuilder.withBody(msg.getBytes()).setDeliveryMode(MessageDeliveryMode.PERSISTENT).setExpiration("10000").build(); |
| | | rabbitTemplate.convertAndSend("test_queue",msg); |
| | | } |
| | | @RequestMapping("testRabbitDelay") |
| | | public void testRabbitDelay(){ |
| | | String msg = "这是测试的一条延时消息"; |
| | | int time = 5; |
| | | MessageProperties messageProperties = new MessageProperties(); |
| | | messageProperties.setHeader("x-delay", 1000 * time);//延迟5秒被删除 |
| | | Message message = new Message(msg.getBytes(StandardCharsets.UTF_8), messageProperties); |
| | | rabbitTemplate.convertAndSend("delay_exchange", "delay", message);//交换机和路由键必须和配置文件类中保持一致 |
| | | System.out.println(TimeUtil.getGernalTime(System.currentTimeMillis(),"yyyy-MM-dd HH:mm:ss") + " 发送一条消息"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong( commonGoods.getGoodsId())); |
| | | goodsDetail = GoodsDetailVOFactory.convertJDGoods(goodsInfo, params); |
| | | } else if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(commonGoods.getGoodsId())); |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(commonGoods.getGoodsId()); |
| | | goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, params); |
| | | } |
| | | |
| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.accept.AdminAcceptData; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqManager; |
| | | import org.springframework.core.task.TaskExecutor; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private RabbitmqManager rabbitmqManager; |
| | | |
| | | // private static final String PAYSUCCESS = "支付成功"; |
| | | // private static final String ORDERCLOSE="订单关闭"; |
| | |
| | | } |
| | | } |
| | | |
| | | CMQManager.getInstance().addTaoBaoOrderMsg(key); |
| | | rabbitmqManager.addTaoBaoOrderMsg(key); |
| | | try { |
| | | // 6小时内不再处理 |
| | | if (Constant.IS_OUTNET) { |
| | |
| | | |
| | | case Constant |
| | | .SOURCE_TYPE_PDD: |
| | | PDDGoodsDetail pddGoodsDetail = getPDDGoods(acceptData.getSystem(), Long.parseLong(goodsId), uid); |
| | | PDDGoodsDetail pddGoodsDetail = getPDDGoods(acceptData.getSystem(), goodsId, uid); |
| | | goodsDetailVO.setGoods(GoodsDetailVOLijinFactory.convertPDDGoods(pddGoodsDetail, paramsDTO)); |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + goodsId); |
| | | ThreadUtil.run(new Runnable() { |
| | |
| | | return jdGoods; |
| | | } |
| | | |
| | | private PDDGoodsDetail getPDDGoods(SystemEnum system, Long id, Long uid) { |
| | | private PDDGoodsDetail getPDDGoods(SystemEnum system, String id, Long uid) { |
| | | String pid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.fanli); |
| | | PDDGoodsDetail pddGoods = null; |
| | | try { |
| | |
| | | return false; |
| | | } |
| | | |
| | | private boolean checkCanUsedPDD(Long goodsId, BigDecimal priceLimit) { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) |
| | | return false; |
| | | BigDecimal quanPrice = PinDuoDuoUtil.getCouponPrice(goods); |
| | | if (quanPrice.compareTo(priceLimit) <= 0) |
| | | return true; |
| | | |
| | | return false; |
| | | } |
| | | |
| | | } |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqManager; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | |
| | | |
| | | @Resource |
| | | private TeamDividentsSourceOrderService teamDividentsSourceOrderService; |
| | | |
| | | @Resource |
| | | private RabbitmqManager rabbitmqManager; |
| | | |
| | | /** |
| | | * 订单列表 |
| | |
| | | try { |
| | | isS = orderService.addOrder(or); |
| | | if (isS) { |
| | | CMQManager.getInstance().addTaoBaoOrderMsg(order); |
| | | rabbitmqManager.addTaoBaoOrderMsg(order); |
| | | // 加入到LostOrder |
| | | LostOrder lo = new LostOrder(); |
| | | lo.setCreateTime(System.currentTimeMillis()); |
| | |
| | | } |
| | | collectionGoodsV2Service.addJDCollection(uid, jdGoods); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | PDDGoodsDetail pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (pddGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品已下架")); |
| | | return; |
| | |
| | | String customParams = pddAuthService.getFanliCustomParams(uid); |
| | | PDDConvertLinkResultVO convertLinkResult = null; |
| | | try { |
| | | convertLinkResult = pddConvertLinkManager.convertGoods(Long.parseLong(pddGoodsId), acceptData.getSystem(), customParams, uid == null ? SystemPIDInfo.PidType.coupon : SystemPIDInfo.PidType.fanli); |
| | | convertLinkResult = pddConvertLinkManager.convertGoods(pddGoodsId, acceptData.getSystem(), customParams, uid == null ? SystemPIDInfo.PidType.coupon : SystemPIDInfo.PidType.fanli); |
| | | convertLinkJumpVO = new ConvertLinkJumpVO(GoodsJumpUtil.getPDDJumpInfo(convertLinkResult), Constant.SOURCE_TYPE_PDD); |
| | | outPrintConvertResult(convertLinkJumpVO, out); |
| | | return; |
| | |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s",materialId,couponUrl), e); |
| | | } |
| | | } else if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail pddGoodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsVO.getGoodsId())); |
| | | PDDGoodsDetail pddGoodsDetail = PinDuoDuoApiUtil.getGoodsDetail(goodsVO.getGoodsId()); |
| | | if (pddGoodsDetail == null) { |
| | | return null; |
| | | } |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getDetailPDD", method = RequestMethod.POST) |
| | | public void getDetialPDD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { |
| | | public void getDetialPDD(AcceptData acceptData, String id, Long uid, String from, PrintWriter out) { |
| | | // 系统验证 |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getPDDLink") |
| | | public void getPDDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) { |
| | | public void getPDDLink(AcceptData acceptData, Long uid, String id, String source, PrintWriter out) { |
| | | |
| | | if (id == null || id <= 0) { |
| | | if (id == null ) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空")); |
| | | return; |
| | | } |
| | |
| | | data.put("extend", true); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId)); |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(goodsId); |
| | | if (goods == null) { |
| | | data.put("extend", false); |
| | | data.put("url", String.format("https://mobile.yangkeduo.com/goods.html?goods_id=%s", goodsId)); |
| | |
| | | //是否包含淘宝链接/口令 |
| | | if (page == 1) { |
| | | List<String> linkList = HttpUtil.getUrlListFromText(key); |
| | | if ((linkList != null && linkList.size() > 0) || TaoBaoUtil.isHaveNewVersionTaoBaoToken(key)) { |
| | | |
| | | if (((linkList != null && linkList.size() > 0) || TaoBaoUtil.isHaveNewVersionTaoBaoToken(key))&&false) { |
| | | // 暂时不通过链接搜索 |
| | | String id = DaTaoKeApiUtil.parseGoodsIdFromToken(key); |
| | | if (id != null) { |
| | | goodsId = id; |
| | |
| | | } |
| | | if (goodsId == null) { |
| | | //解析链接 |
| | | if (linkList != null && linkList.size() > 0) { |
| | | String tempGoodsId = clipboardAnalysisManager.parseTBAuctionIdFromLink(linkList.get(0)); |
| | | if (!StringUtil.isNullOrEmpty(tempGoodsId)) { |
| | | goodsId = tempGoodsId; |
| | | } |
| | | } |
| | | // if (linkList != null && linkList.size() > 0) { |
| | | // String tempGoodsId = clipboardAnalysisManager.parseTBAuctionIdFromLink(linkList.get(0)); |
| | | // if (!StringUtil.isNullOrEmpty(tempGoodsId)) { |
| | | // goodsId = tempGoodsId; |
| | | // } |
| | | // } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (goodsId != null) { |
| | | try { |
| | | PDDGoodsDetail pddGoodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId), PinDuoDuoApiUtil.PID_DEFAULT, customParams); |
| | | PDDGoodsDetail pddGoodsDetail = PinDuoDuoApiUtil.getGoodsDetail(goodsId, PinDuoDuoApiUtil.PID_DEFAULT, customParams); |
| | | if (pddGoodsDetail != null) { |
| | | count = 1; |
| | | goodsList.add(pddGoodsDetail); |
| | |
| | | e.printStackTrace(); |
| | | if (e.getCode() == PDDApiException.CODE_NOT_AUTH) { |
| | | try { |
| | | PDDGoodsDetail pddGoodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId), PinDuoDuoApiUtil.PID_DEFAULT, Constant.PDD_SEARCH_CUSTOMER_PARAMS); |
| | | PDDGoodsDetail pddGoodsDetail = PinDuoDuoApiUtil.getGoodsDetail(goodsId, PinDuoDuoApiUtil.PID_DEFAULT, Constant.PDD_SEARCH_CUSTOMER_PARAMS); |
| | | if (pddGoodsDetail != null) { |
| | | count = 1; |
| | | goodsList.add(pddGoodsDetail); |
| | |
| | | |
| | | // 拼多多 |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | createPDDShare(acceptData, uid, Long.parseLong(goodsId), source, needGoods, out); |
| | | createPDDShare(acceptData, uid, goodsId, source, needGoods, out); |
| | | return; |
| | | } |
| | | |
| | |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, |
| | | public void createPDDShare(AcceptData acceptData, Long uid, String goodsId, String source, boolean needGoods, |
| | | PrintWriter out) { |
| | | |
| | | //查询当前用户是否授权 |
| | |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | createPDDViewText(acceptData.getSystem(), goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); |
| | | createPDDViewText(acceptData.getSystem(), goodsType, uid, template, goodsId, hasCoupon, out); |
| | | return; |
| | | } |
| | | |
| | |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | private void createPDDViewText(SystemEnum system, Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, |
| | | private void createPDDViewText(SystemEnum system, Integer goodsType, Long uid, String template, String goodsId, Boolean hasCoupon, |
| | | PrintWriter out) { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) { |
| | |
| | | goodsDetail = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO); |
| | | } |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getImageList", method = RequestMethod.GET) |
| | | public void getCouponList(AcceptData acceptData, String callback, Long id, PrintWriter out) { |
| | | if (id == null || id == 0) { |
| | | public void getCouponList(AcceptData acceptData, String callback, String id, PrintWriter out) { |
| | | if (id == null ) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请上传商品ID"))); |
| | | return; |
| | | } |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getPDDGoodsDetail") |
| | | public void getPDDGoodsDetail(final AcceptData acceptData, final Long id, String uid, String callback, |
| | | public void getPDDGoodsDetail(final AcceptData acceptData, final String id, String uid, String callback, |
| | | PrintWriter out) { |
| | | if (id == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | |
| | | } |
| | | collectionGoodsV2Service.addJDCollection(uid, jdGoods); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | PDDGoodsDetail pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (pddGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品已下架")); |
| | | return; |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getBuyLink", method = RequestMethod.POST) |
| | | public void getBuyLink(WXMPAcceptData acceptData, Long goodsId, Integer goodsType, String from, String couponUrl, |
| | | public void getBuyLink(WXMPAcceptData acceptData, String goodsId, Integer goodsType, String from, String couponUrl, |
| | | Long uid, String inviteCode, PrintWriter out) { |
| | | if (goodsId == null || goodsType == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品信息传递错误")); |
| | |
| | | |
| | | String jumpLink = null; |
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) { // 京东 |
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId); |
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "sharePoster", method = RequestMethod.POST) |
| | | public void sharePoster(WXMPAcceptData acceptData, Long goodsId, Integer goodsType, String from, Integer type, |
| | | public void sharePoster(WXMPAcceptData acceptData, String goodsId, Integer goodsType, String from, Integer type, |
| | | Long uid, PrintWriter out) { |
| | | if (uid == null || uid < 1) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | |
| | | } |
| | | |
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) { // 京东 |
| | | createPosterJD(acceptData, goodsId, goodsType, from, type, user, inviteCode, out); |
| | | createPosterJD(acceptData, Long.parseLong(goodsId), goodsType, from, type, user, inviteCode, out); |
| | | } else if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) { // 拼多多 |
| | | createPosterPDD(acceptData, goodsId, goodsType, from, type, user, inviteCode, out); |
| | | } else { |
| | |
| | | /** |
| | | * 创建拼多多分享海报 |
| | | */ |
| | | private void createPosterPDD(WXMPAcceptData acceptData, Long goodsId, Integer goodsType, String from, Integer type, |
| | | private void createPosterPDD(WXMPAcceptData acceptData, String goodsId, Integer goodsType, String from, Integer type, |
| | | UserInfo user, String inviteCode, PrintWriter out) { |
| | | PDDGoodsDetail pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (pddGoods == null) { |
| | |
| | | } else { |
| | | String pddId = PinDuoDuoUtil.getPDDGoodsId(text); |
| | | if (!StringUtil.isNullOrEmpty(pddId)) { |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(pddId)); |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(pddId); |
| | | if (goods != null) { |
| | | commonGoods = CommonGoodsFactory.create(goods); |
| | | } else { |
| | |
| | | List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>(); |
| | | if (listExist != null && listExist.size() > 0) { |
| | | for (FreeGoodsCoupon freeGood : listExist) { |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(freeGood.getGoodsId())); |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(freeGood.getGoodsId()); |
| | | if (goodsInfo == null) { |
| | | listdel.add(freeGood); |
| | | } else { |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqManager; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | |
| | | |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | |
| | | @Resource |
| | | private RabbitmqManager rabbitmqManager; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | } |
| | | |
| | | CMQManager.getInstance().addTaoBaoOrderMsg(key); |
| | | rabbitmqManager.addTaoBaoOrderMsg(key); |
| | | |
| | | try { |
| | | // 6小时内不再处理 |
| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqManager; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private RabbitmqManager rabbitmqManager; |
| | | |
| | | /** |
| | | * 更新渠道订单 |
| | |
| | | if (orders != null && orders.size() > 0 && System.currentTimeMillis() |
| | | - TimeUtil.convertToTimeTemp(orders.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss") < 1000 |
| | | * 60 * 10L)// 10分钟内产生的单作为新订单处理 |
| | | CMQManager.getInstance().addTaoBaoNewOrderMsg(key); |
| | | rabbitmqManager.addTaoBaoNewOrderMsg(key); |
| | | else |
| | | CMQManager.getInstance().addTaoBaoOrderMsg(key); |
| | | rabbitmqManager.addTaoBaoOrderMsg(key); |
| | | |
| | | try { |
| | | // 20分钟内不再处理 |
| | |
| | | // @Reference(version = "1.0", check = false,url="dubbo://193.112.35.168:20902/com.ks.vip.service.VipOrederPayService") |
| | | @Reference(version = "1.0", check = false) |
| | | private LijinBalanceService lijinBalanceService; |
| | | |
| | | @Reference(version = "1.0", check = false) |
| | | private LijinRecordService lijinRecordService; |
| | | |
| | |
| | | |
| | | boolean addShop = true; |
| | | for (int i = 0; i < 2; i++) { |
| | | if ("1".equals(way)) { |
| | | if ("1".equals(way)&&false) { |
| | | // 京东搜索不能过度消耗 |
| | | JDFilter filterAPI = new JDFilter(); |
| | | filterAPI.setKeyword(SearchFilterUtil.filterSearchContent(searchKey)); |
| | | filterAPI.setPageIndex(1); |
| | |
| | | jdGoods = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(jdGoods, params); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(pddGoods, params); |
| | | } |
| | | |
| | |
| | | commentText = template.replace("[链接]", jumpLink); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | String sharePid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share); |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId), sharePid, "1"); |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(goodsId, sharePid, "1"); |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetail.getGoodsSign(), sharePid, "1"); |
| | | if (jumpLink == null) { |
| | | throw new GoodsEvaluateException(1, "该商品转链失败"); |
| | |
| | | |
| | | String sharePid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share); |
| | | |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsDetailVO.getGoodsId()), |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(goodsDetailVO.getGoodsId(), |
| | | sharePid, "1"); |
| | | |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetail.getGoodsSign(), |
| | |
| | | JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | goodsDetail = GoodsDetailVOFactory.convertJDGoods(goodsInfo, params); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, params); |
| | | } |
| | | if (goodsDetail != null) |
| | |
| | | vo = GoodsDetailVOFactory.convertJDGoods(goodsInfo, paramsDTO); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goodsInfo != null) |
| | | vo = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, paramsDTO); |
| | | } |
| | |
| | | } |
| | | break; |
| | | case "拼多多": { |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(id)); |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(id); |
| | | if (goodsDetail != null && goodsDetail.getGoodsGalleryUrls() != null) { |
| | | GoodsMoneyConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system); |
| | | goods = GoodsDetailVOFactory.convertPDDGoods(goodsDetail, params); |
| | |
| | | if (commonGoodsList.size() <= 0)// 不存在就插入商品 |
| | | { |
| | | PDDGoodsDetail pddGoods = null; |
| | | pddGoods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(cog.getGoodsId())); |
| | | pddGoods = PinDuoDuoApiUtil.getGoodsDetail(cog.getGoodsId()); |
| | | if (pddGoods != null) { |
| | | cog = CommonOrderGoodsFactory.create(pddGoods); |
| | | } |
| | |
| | | return; |
| | | //如果在偿还里面就先偿还,然后再失效 |
| | | TeamRewardDebt debt = teamRewardDebtService.selectBySourceId(hongBaoV2.getId()); |
| | | if (debt != null && debt.getLeftMoney().compareTo(hongBaoV2.getMoney()) <= 0) { |
| | | if (debt != null &&debt.getLeftMoney().compareTo(new BigDecimal(0))>0 && debt.getLeftMoney().compareTo(hongBaoV2.getMoney()) <= 0) { |
| | | teamRewardDebtService.repayDebt(debt.getId(), hongBaoV2.getMoney(), "封禁失效,先偿还再失效"); |
| | | } |
| | | |
| | |
| | | try { |
| | | invalidHongBaoForbidden(item); |
| | | } catch (TeamRewardDebtException e) { |
| | | e.printStackTrace(); |
| | | throw new OrderMoneySettleException(10, "偿还出错"); |
| | | } |
| | | hongBaoList.remove(i); |
| | |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.service.manger.order.TeamRewardManager; |
| | | import com.yeshi.fanli.util.goods.douyin.DYUtil; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqManager; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | |
| | | |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | @Resource |
| | | private RabbitmqManager rabbitmqManager; |
| | | |
| | | /** |
| | | * 是否是分享订单 |
| | |
| | | update.setLatestUpdateTime(new Date()); |
| | | update.setOrderState("订单失效"); |
| | | taoBaoOrderService.updateSelectiveByPrimaryKey(update); |
| | | CMQManager.getInstance().addTaoBaoOrderMsg(taoBaoOrder.getOrderId()); |
| | | rabbitmqManager.addTaoBaoOrderMsg(taoBaoOrder.getOrderId()); |
| | | } |
| | | } |
| | | |
| | |
| | | @Resource |
| | | private AppVersionService appVersionService; |
| | | |
| | | @Reference(version = "1.0", check = false) |
| | | //TODO 测试 |
| | | // @Reference(version = "1.0", check = false) |
| | | private BPushTaskService bPushTaskService; |
| | | |
| | | @Resource |
| | |
| | | |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | // 拼多多 |
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(auctionId)); |
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(auctionId); |
| | | if (pddGoods == null) { |
| | | throw new UserGoodsStorageException(1, auctionId + "商品已下架"); |
| | | } |
| | |
| | | } |
| | | convertGoods = CommonGoodsFactory.create(jdGoods); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail pddGoods = redisManager.getPDDGoodsDetail(Long.parseLong( goodsId)); |
| | | PDDGoodsDetail pddGoods = redisManager.getPDDGoodsDetail(goodsId); |
| | | if (pddGoods == null) { |
| | | throw new UserShareGoodsRecordException(1, "商品已下架"); |
| | | } |
| | |
| | | throw new UserCloudGoodsException(1, goodsId + "未找到商品信息"); |
| | | commonGoods = CommonGoodsFactory.create(goods); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { // 拼多多 |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) |
| | | throw new UserCloudGoodsException(1, goodsId + "未找到商品信息"); |
| | | commonGoods = CommonGoodsFactory.create(goods); |
| | |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | sendJDGoods(user, robotId, wxId, Long.parseLong(goodsId), relationId, listOpen, result.getId()); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | sendPDDGoods(user, robotId, wxId, Long.parseLong(goodsId), relationId, listOpen, result.getId()); |
| | | sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_VIP) { |
| | | sendVIPGoods(user, robotId, wxId, Long.parseLong(goodsId), relationId, listOpen, result.getId()); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | |
| | | * @param listOpen |
| | | * @throws UserCloudException |
| | | */ |
| | | private void sendPDDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId, |
| | | private void sendPDDGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId, |
| | | List<UserCloudGroup> listOpen, String pid) throws UserCloudException { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) |
| | |
| | | } |
| | | } |
| | | } else if (simpleGoods.getGoodsType() == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(simpleGoods.getGoodsId())); |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(simpleGoods.getGoodsId()); |
| | | if (goods != null) { |
| | | commonGoods = CommonGoodsFactory.create(goods); |
| | | } else { |
| | |
| | | */ |
| | | public void start() { |
| | | doExtractResult();// 处理提现结果 |
| | | doTaoBaoOrders();// 处理淘宝订单 |
| | | doTaoBaoNewOrders();// 处理淘宝订单(刚刚产生的) |
| | | doOrderFanLiNew();// 新版返利 |
| | | doOrderShareFanLi(); |
| | | doWeiQuanOrder();// 处理维权订单 |
| | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 处理淘宝订单 |
| | | */ |
| | | public void doTaoBaoOrders() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | // 同时开启3个线程处理 |
| | | for (int i = 0; i < 3; i++) { |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | try { |
| | | // 取16个订单 |
| | | List<String> orderIds = CMQManager.getInstance().consumeTaoBaoOrderMsg(16); |
| | | if (orderIds != null) { |
| | | for (String orderId : orderIds) { |
| | | if (NumberUtil.isNumeric(orderId.trim())) { |
| | | Map<String, List<TaoBaoOrder>> map = new HashMap<>(); |
| | | List<TaoBaoOrder> orderList = taoBaoOrderService |
| | | .getTaoBaoOrderByOrderId(orderId); |
| | | map.put(orderId, orderList); |
| | | LogHelper.orderInfo("开始处理订单:" + orderId); |
| | | orderProcessService.processOrder(map); |
| | | LogHelper.orderInfo("结束处理订单:" + orderId); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 刚刚产生的订单 |
| | | */ |
| | | public void doTaoBaoNewOrders() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | // 同时开启3个线程处理 |
| | | for (int i = 0; i < 1; i++) { |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | try { |
| | | // 取16个订单 |
| | | List<String> orderIds = CMQManager.getInstance().consumeTaoBaoNewOrderMsg(16); |
| | | Map<String, List<TaoBaoOrder>> map = new HashMap<>(); |
| | | if (orderIds != null) { |
| | | for (String orderId : orderIds) { |
| | | List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId); |
| | | map.put(orderId, orderList); |
| | | |
| | | LogHelper.orderInfo("新订单-开始处理订单:" + orderId); |
| | | long startTime = System.currentTimeMillis(); |
| | | orderProcessService.processOrder(map); |
| | | LogHelper.orderInfo("新订单-结束处理订单:" + orderId + "- 处理时间:" |
| | | + (System.currentTimeMillis() - startTime)); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | for (String shortLink : linkSet) { |
| | | String goodsId = PinDuoDuoUtil.getPDDGoodsId(shortLink); |
| | | if (!StringUtil.isNullOrEmpty(goodsId)) { |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId)); |
| | | PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(goodsId); |
| | | if (goodsDetail == null) |
| | | throw new Exception("拼多多转链失败"); |
| | | PDDConvertLinkResultVO pddUrl = PinDuoDuoApiUtil.convert(goodsDetail.getGoodsSign(), |
| | |
| | | * @throws PDDGoodsException |
| | | * @throws PDDAuthException |
| | | */ |
| | | public PDDConvertLinkResultVO convertGoods(Long goodsId, SystemEnum system, String customParams, SystemPIDInfo.PidType pidType) throws PDDGoodsException, PDDAuthException { |
| | | public PDDConvertLinkResultVO convertGoods(String goodsId, SystemEnum system, String customParams, SystemPIDInfo.PidType pidType) throws PDDGoodsException, PDDAuthException { |
| | | |
| | | String pid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, pidType); |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | |
| | | return cmqManager; |
| | | } |
| | | |
| | | /** |
| | | * 发送订单消息 |
| | | * |
| | | * @param orderId |
| | | */ |
| | | public void addTaoBaoOrderMsg(String orderId) { |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | tdmqUtil.sendMsg(QUEUENAME_ORDER, orderId); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 消费淘宝订单消息 |
| | | * |
| | | * @param count |
| | | */ |
| | | public List<String> consumeTaoBaoOrderMsg(int count) { |
| | | List<String> resultList = new ArrayList<>(); |
| | | List<Message> list = tdmqUtil.recieveMsg(count, QUEUENAME_ORDER); |
| | | |
| | | if (list != null) |
| | | for (Message msg : list) { |
| | | String result = msg.msgBody; |
| | | resultList.add(result); |
| | | // 删除消息 |
| | | tdmqUtil.deleteMsg(QUEUENAME_ORDER, msg.receiptHandle); |
| | | } |
| | | return resultList; |
| | | } |
| | | |
| | | /** |
| | | * 删除淘宝订单消息 |
| | | * |
| | | * @param receiptHandle |
| | | */ |
| | | public void deleteTaoBaoOrderMsg(String receiptHandle) { |
| | | |
| | | tdmqUtil.deleteMsg(QUEUENAME_ORDER, receiptHandle); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 发送订单消息(刚刚产生的订单) |
| | | * |
| | | * @param orderId |
| | | */ |
| | | public void addTaoBaoNewOrderMsg(String orderId) { |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | tdmqUtil.sendMsg(QUEUENAME_NEW_ORDER, orderId); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 消费淘宝订单消息(刚刚产生的订单) |
| | | * |
| | | * @param count |
| | | */ |
| | | public List<String> consumeTaoBaoNewOrderMsg(int count) { |
| | | List<String> resultList = new ArrayList<>(); |
| | | List<Message> list = tdmqUtil.recieveMsg(count, QUEUENAME_NEW_ORDER); |
| | | |
| | | if (list != null) |
| | | for (Message msg : list) { |
| | | String result = msg.msgBody; |
| | | resultList.add(result); |
| | | // 删除消息 |
| | | tdmqUtil.deleteMsg(QUEUENAME_NEW_ORDER, msg.receiptHandle); |
| | | } |
| | | return resultList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除淘宝订单消息(刚刚产生的订单) |
| | | * |
| | | * @param receiptHandle |
| | | */ |
| | | public void deleteTaoBaoNewOrderMsg(String receiptHandle) { |
| | | |
| | | tdmqUtil.deleteMsg(QUEUENAME_NEW_ORDER, receiptHandle); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 添加提现结果消息 |
| | |
| | | } |
| | | } |
| | | |
| | | public PDDGoodsDetail getPDDGoodsDetail(long goodsId) { |
| | | public PDDGoodsDetail getPDDGoodsDetail(String goodsId) { |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.pinDuoDuoGoods, goodsId + ""); |
| | | |
| | | String value = getCommonString(key); |
| | |
| | | * @param goodsId |
| | | * @return |
| | | */ |
| | | public PDDGoodsDetail getGoodsInfo(long goodsId){ |
| | | public PDDGoodsDetail getGoodsInfo(String goodsId){ |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.PDDGoods, goodsId + ""); |
| | | String value = redisManager.getCommonString(key); |
| | | if (!StringUtil.isNullOrEmpty(value)) { |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String fromEmail="ohaicao@163.com"; |
| | | String fromEmailPwd="admin123456"; |
| | | String fromEmail="app_yzm_zc@163.com"; |
| | | String fromEmailPwd="KZKSRTEMDWEQRAQR"; |
| | | String title="测试标题"; |
| | | String content="测试内容"; |
| | | sendEmail("liuhongrui@banliapp.com",fromEmail,fromEmailPwd,title,content); |
| | | sendEmail("hexiaohui@banliapp.com",fromEmail,fromEmailPwd,title,content); |
| | | } |
| | | } |
| | |
| | | GoodsDetailVO goodsInfo = new GoodsDetailVO(); |
| | | goodsInfo.setBaoyou(true); |
| | | goodsInfo.setGoodsType(Constant.SOURCE_TYPE_PDD); |
| | | goodsInfo.setGoodsId(goods.getGoodsId() + ""); |
| | | goodsInfo.setGoodsId(goods.getGoodsSign()+ ""); |
| | | goodsInfo.setTitle(goods.getGoodsName()); |
| | | goodsInfo.setSalesType(4); // 总销量 |
| | | goodsInfo.setPriceName("拼团价"); |
| | |
| | | } |
| | | |
| | | return goodsInfo; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | public static String APP_ID = "1864778416"; |
| | | public static String APP_KEY = "388f5133d13a5ea290aa5c44f3ebcc00"; |
| | | public static String SECRET_KEY = "85e7e72110564efab6e13d302a4419da"; |
| | | public static String SECRET_KEY = "270eefea04d44e33b5c21511aa857458"; |
| | | private static String SERVER_URL = "https://router.jd.com/api"; |
| | | |
| | | // 订单查询类型 |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // JDFilter filter=new JDFilter(); |
| | | // filter.setKeyword("花卉"); |
| | | // filter.setPageIndex(1); |
| | | // filter.setPageSize(20); |
| | | // queryByKey(filter); |
| | | JDFilter filter=new JDFilter(); |
| | | filter.setKeyword("花卉"); |
| | | filter.setPageIndex(1); |
| | | filter.setPageSize(20); |
| | | queryByKey(filter); |
| | | getGoodsDetail(100007520546L); |
| | | |
| | | long now = System.currentTimeMillis(); |
| | | |
| | | JDOrderResult result = JDApiUtil.getOrderList(1, 200, new Date(now), JDApiUtil.ORDER_TYPE_CREATETIME); |
| | | System.out.printf(result.toString()); |
| | | |
| | | // long now = System.currentTimeMillis(); |
| | | // |
| | | // JDOrderResult result = JDApiUtil.getOrderList(1, 200, new Date(now), JDApiUtil.ORDER_TYPE_CREATETIME); |
| | | // System.out.printf(result.toString()); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: DelayMsgInfo |
| | | * @description: 延迟消息的数据 |
| | | * @date 2024/10/12 13:31 |
| | | */ |
| | | public class DelayMsgInfo { |
| | | |
| | | private String queueName; // 队列名称 |
| | | private String exchangeName; // 交换机名称 |
| | | private String routingKey; |
| | | private int delayMs; // 延迟的时间 |
| | | private int sendCount;// 发送次数 |
| | | private String msg;// 消息内容 |
| | | |
| | | public String getRoutingKey() { |
| | | return routingKey; |
| | | } |
| | | |
| | | public void setRoutingKey(String routingKey) { |
| | | this.routingKey = routingKey; |
| | | } |
| | | |
| | | public String getQueueName() { |
| | | return queueName; |
| | | } |
| | | |
| | | public void setQueueName(String queueName) { |
| | | this.queueName = queueName; |
| | | } |
| | | |
| | | public String getExchangeName() { |
| | | return exchangeName; |
| | | } |
| | | |
| | | public void setExchangeName(String exchangeName) { |
| | | this.exchangeName = exchangeName; |
| | | } |
| | | |
| | | public int getDelayMs() { |
| | | return delayMs; |
| | | } |
| | | |
| | | public void setDelayMs(int delayMs) { |
| | | this.delayMs = delayMs; |
| | | } |
| | | |
| | | public int getSendCount() { |
| | | return sendCount; |
| | | } |
| | | |
| | | public void setSendCount(int sendCount) { |
| | | this.sendCount = sendCount; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public void setMsg(String msg) { |
| | | this.msg = msg; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit; |
| | | |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: 测试消息 |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | public class QueueHelloWorldListener implements MessageListener { |
| | | @Override |
| | | public void onMessage(Message message) { |
| | | try { |
| | | System.out.println("收到消息:"+ new String(message.getBody(),"UTF-8")); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: RabbitDelayConsumer |
| | | * @description: TODO |
| | | * @date 2024/10/12 11:21 |
| | | */ |
| | | @Component |
| | | public class RabbitDelayConsumeFailConsumer { |
| | | private Logger logger = LoggerFactory.getLogger("infoLog"); |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @RabbitListener(queues = RabbitmqSenderUtil.CONSUME_FAIL_QUEUE_NAME, ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | String msg = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | logger.info("RabbitDelayConsumeFailConsumer-{}", msg); |
| | | DelayMsgInfo msgInfo = new Gson().fromJson(msg, DelayMsgInfo.class); |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("retry_count", (msgInfo.getSendCount() + 1) + ""); |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, msgInfo.getQueueName(), msgInfo.getMsg(), headers); |
| | | channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: RabbitDelayConsumer |
| | | * @description: |
| | | * @date 2024/10/12 11:21 |
| | | */ |
| | | @Component |
| | | public class RabbitDelayConsumer { |
| | | |
| | | private Logger logger = LoggerFactory.getLogger("infoLog"); |
| | | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | |
| | | @RabbitListener(queues = RabbitmqSenderUtil.DELAY_QUEUE_NAME, ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | String msg = new String( message.getBody(), StandardCharsets.UTF_8); |
| | | logger.info("RabbitDelayConsumer-{}",msg); |
| | | DelayMsgInfo msgInfo = new Gson().fromJson(msg, DelayMsgInfo.class); |
| | | if(!StringUtil.isNullOrEmpty(msgInfo.getQueueName())){ |
| | | // 队列消息 |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, msgInfo.getQueueName(), msgInfo.getMsg()); |
| | | }else{ |
| | | // 交换机消息 |
| | | RabbitmqSenderUtil.sendExchangeMsg(rabbitTemplate, msgInfo.getExchangeName(), msgInfo.getRoutingKey(), msgInfo.getMsg()); |
| | | } |
| | | channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit; |
| | | |
| | | import org.springframework.amqp.core.Binding; |
| | | import org.springframework.amqp.core.BindingBuilder; |
| | | import org.springframework.amqp.core.CustomExchange; |
| | | import org.springframework.amqp.core.Queue; |
| | | import org.springframework.amqp.rabbit.annotation.EnableRabbit; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: RabbitmqConfig |
| | | * @description: TODO |
| | | * @date 2024/10/12 11:10 |
| | | */ |
| | | @Configuration |
| | | @EnableRabbit |
| | | public class RabbitmqConfig { |
| | | @Bean("pluginDelayExchange") |
| | | public CustomExchange pluginDelayExchange() { |
| | | Map<String, Object> argMap = new HashMap<>(); |
| | | argMap.put("x-delayed-type", "direct");//必须要配置这个类型,可以是direct,topic和fanout |
| | | //第二个参数必须为x-delayed-message |
| | | return new CustomExchange(RabbitmqSenderUtil.DELAY_EXCHANGE_NAME, "x-delayed-message", false, false, argMap); |
| | | } |
| | | |
| | | |
| | | @Bean("pluginDelayQueue") |
| | | public Queue pluginDelayQueue() { |
| | | Map<String, Object> headers=new HashMap<>(); |
| | | headers.put("x-message-ttl", 24*60*60*1000); |
| | | return new Queue(RabbitmqSenderUtil.DELAY_QUEUE_NAME,true, false, false, headers); |
| | | } |
| | | |
| | | @Bean("pluginDelayConsumeFailQueue") |
| | | public Queue pluginDelayConsumeFailQueue() { |
| | | Map<String, Object> headers=new HashMap<>(); |
| | | headers.put("x-message-ttl", 24*60*60*1000); |
| | | return new Queue(RabbitmqSenderUtil.CONSUME_FAIL_QUEUE_NAME,true, false, false, headers); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding pluginDelayBinding(@Qualifier("pluginDelayQueue") Queue queue, @Qualifier("pluginDelayExchange") CustomExchange customExchange) { |
| | | return BindingBuilder.bind(queue).to(customExchange).with(RabbitmqSenderUtil.ROUTING_KEY_COMMON_DELAY).noargs(); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding pluginDelayConsumeFailBinding(@Qualifier("pluginDelayConsumeFailQueue") Queue queue, @Qualifier("pluginDelayExchange") CustomExchange customExchange) { |
| | | return BindingBuilder.bind(queue).to(customExchange).with(RabbitmqSenderUtil.ROUTING_KEY_CONSUME_FAIL_DELAY).noargs(); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit; |
| | | |
| | | import com.alipay.api.response.AlipayFundTransUniTransferResponse; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.fanli.dto.HongBao; |
| | | import com.yeshi.fanli.dto.mq.UidDateDTO; |
| | | import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo; |
| | | import com.yeshi.fanli.entity.bus.user.Extract; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | import com.yeshi.fanli.entity.common.AdminUser; |
| | | import com.yeshi.fanli.entity.push.PushQueueRecord; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: RabbitmqManager |
| | | * @description: 消息管理 |
| | | * @date 2024/10/14 10:19 |
| | | */ |
| | | @Component |
| | | public class RabbitmqManager { |
| | | // 订单处理队列 |
| | | public static String QUEUENAME_ORDER = "fanli-orders"; |
| | | |
| | | // 刚刚产生的订单处理队列 |
| | | public static String QUEUENAME_NEW_ORDER = "fanli-new-orders"; |
| | | |
| | | // 提现结果处理队列 |
| | | public static String EXTRACT_RESULT = "extract-result"; |
| | | // IOS推送队列 |
| | | public static String PUSH_IOS = "push-ios"; |
| | | |
| | | // 返利队列 |
| | | public static String FANLI_ORDER = "fanli-order"; |
| | | |
| | | // 返利队列 |
| | | public static String FANLI_ORDER_NEW = "fanli-order-new"; |
| | | |
| | | |
| | | // 分享订单收益 |
| | | public static String FANLI_SHARE_ORDER = "fanli-share-order"; |
| | | |
| | | // 维权订单 |
| | | public static String ORDER_WEIQUAN = "weiquan-order"; |
| | | |
| | | public static String GOODS_UPDATE = "goods_update_queue"; |
| | | // 重要数据更新 |
| | | public static String IMPORTANT_GOODS_UPDATE = "imp_goods_update_queue"; |
| | | |
| | | //特价会员开通 |
| | | public static String TEJIA_VIP = "tejia_vip"; |
| | | |
| | | |
| | | static { |
| | | QUEUENAME_ORDER += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | QUEUENAME_NEW_ORDER += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | EXTRACT_RESULT += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | PUSH_IOS += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | FANLI_ORDER += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | FANLI_ORDER_NEW += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | ORDER_WEIQUAN += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | IMPORTANT_GOODS_UPDATE += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | FANLI_SHARE_ORDER += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | TEJIA_VIP += "-" + Constant.systemCommonConfig.getProjectName(); |
| | | } |
| | | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | |
| | | /** |
| | | * 发送订单消息 |
| | | * |
| | | * @param orderId |
| | | */ |
| | | public void addTaoBaoOrderMsg(String orderId) { |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, QUEUENAME_ORDER, orderId); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送订单消息(刚刚产生的订单) |
| | | * |
| | | * @param orderId |
| | | */ |
| | | public void addTaoBaoNewOrderMsg(String orderId) { |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, QUEUENAME_NEW_ORDER, orderId); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加提现结果消息 |
| | | * |
| | | * @param extract |
| | | * @param response |
| | | */ |
| | | public void addExtractResultMsg(Extract extract, AlipayFundTransUniTransferResponse response, |
| | | AdminUser adminUser) { |
| | | String content = new Gson().toJson(new AlipayTransferResultInfo(extract, response, adminUser)); |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, EXTRACT_RESULT, content); |
| | | } |
| | | |
| | | // 订单返利 |
| | | public void addFanLiMsg(HongBao hongBao) { |
| | | String content = new Gson().toJson(hongBao); |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, FANLI_ORDER, content); |
| | | } |
| | | |
| | | |
| | | // 新版订单返利 |
| | | public void addFanLiMsgNew(HongBaoV2 hongBao) { |
| | | String content = new Gson().toJson(hongBao); |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, FANLI_ORDER_NEW, content); |
| | | } |
| | | |
| | | // 分享订单收益 |
| | | public void addFanLiShareMsg(UidDateDTO dto) { |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, FANLI_SHARE_ORDER, new Gson().toJson(dto)); |
| | | } |
| | | |
| | | |
| | | // 维权订单 |
| | | public void addWeiQuanOrderMsg(TaoBaoWeiQuanOrder order) { |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, ORDER_WEIQUAN, new Gson().toJson(order)); |
| | | } |
| | | |
| | | /** |
| | | * 添加IOS推送消息 |
| | | * |
| | | * @param pushQueueRecord |
| | | */ |
| | | public void addIOSPushMsg(PushQueueRecord pushQueueRecord) { |
| | | |
| | | String content = new GsonBuilder().create().toJson(pushQueueRecord); |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, PUSH_IOS, content); |
| | | } |
| | | |
| | | /** |
| | | * 添加需要更新的商品ID |
| | | * |
| | | * @param goodsId |
| | | */ |
| | | public void addNeedUpdateTaoBaoGoodsId(String goodsId) { |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, GOODS_UPDATE, goodsId + ""); |
| | | } |
| | | |
| | | /** |
| | | * 添加淘宝重要商品更新 |
| | | * |
| | | * @param actionId |
| | | */ |
| | | public void addTBImpGoodsUpdate(String actionId) { |
| | | RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, IMPORTANT_GOODS_UPDATE, actionId + ""); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: RabbitmqMsgConsumeUtil |
| | | * @description: 消息消费工具 |
| | | * @date 2024/10/12 14:43 |
| | | */ |
| | | public class RabbitmqMsgConsumeUtil { |
| | | |
| | | public interface IMessageProcess{ |
| | | public void onProcess() throws Exception; |
| | | } |
| | | |
| | | public static void processMessage(Message message, Channel channel, RabbitTemplate rabbitTemplate,IMessageProcess messageProcessor) throws IOException { |
| | | try { |
| | | messageProcessor.onProcess(); |
| | | channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); |
| | | }catch(Exception e){ |
| | | if(RabbitmqSenderUtil.retryConsume(rabbitTemplate, message)){ |
| | | channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); |
| | | }else{ |
| | | channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit; |
| | | |
| | | import com.google.gson.Gson; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageProperties; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: RabbitmqUtil |
| | | * @description: mq消息发送工具 |
| | | * @date 2024/10/12 13:04 |
| | | */ |
| | | public class RabbitmqSenderUtil { |
| | | |
| | | // 延迟交换机 |
| | | public static final String DELAY_EXCHANGE_NAME = "delay_exchange"; |
| | | // 延迟队列 |
| | | public static final String DELAY_QUEUE_NAME = "delay_queue"; |
| | | |
| | | //常规延迟队列的routingKey |
| | | public static final String ROUTING_KEY_COMMON_DELAY = "delay"; |
| | | // 消费失败的延迟消息 |
| | | public static final String ROUTING_KEY_CONSUME_FAIL_DELAY = "consume_fail_delay"; |
| | | // 消费失败处理队列 |
| | | public static final String CONSUME_FAIL_QUEUE_NAME = "consume_fail_queue"; |
| | | |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 发送队列消息 |
| | | * @date 13:06 2024/10/12 |
| | | * @param: rabbitTemplate |
| | | * @param: queueName |
| | | * @param: message |
| | | **/ |
| | | public static void sendQueueMsg(RabbitTemplate rabbitTemplate, String queueName, String message) { |
| | | rabbitTemplate.convertAndSend(queueName, message); |
| | | } |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 发送带头部的消息 |
| | | * @date 13:54 2024/10/12 |
| | | * @param: rabbitTemplate |
| | | * @param: queueName |
| | | * @param: msg |
| | | * @param: headers |
| | | **/ |
| | | public static void sendQueueMsg(RabbitTemplate rabbitTemplate, String queueName, String msg, Map<String, String> headers) { |
| | | MessageProperties messageProperties = new MessageProperties(); |
| | | if (headers != null) { |
| | | for (String key : headers.keySet()) { |
| | | messageProperties.setHeader(key, headers.get(key));//延迟5秒被删除 |
| | | } |
| | | } |
| | | Message message = new Message(msg.getBytes(StandardCharsets.UTF_8), messageProperties); |
| | | rabbitTemplate.convertAndSend(queueName, message);//交换机和路由键必须和配置文件类中保持一致 |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 发送队列延迟消息 |
| | | * @date 13:07 2024/10/12 |
| | | * @param: rabbitTemplate |
| | | * @param: queueName |
| | | * @param: msg |
| | | * @param: delayMS |
| | | **/ |
| | | public static void sendQueueMsg(RabbitTemplate rabbitTemplate, String queueName, String msg, int delayMS) { |
| | | DelayMsgInfo msgInfo = new DelayMsgInfo(); |
| | | msgInfo.setDelayMs(delayMS); |
| | | msgInfo.setQueueName(queueName); |
| | | msgInfo.setMsg(msg); |
| | | MessageProperties messageProperties = new MessageProperties(); |
| | | messageProperties.setHeader("x-delay", delayMS);//延迟5秒被删除 |
| | | Message message = new Message(new Gson().toJson(msgInfo).getBytes(StandardCharsets.UTF_8), messageProperties); |
| | | rabbitTemplate.convertAndSend(DELAY_EXCHANGE_NAME, ROUTING_KEY_COMMON_DELAY, message);//交换机和路由键必须和配置文件类中保持一致 |
| | | } |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 发送交换机消息 |
| | | * @date 13:13 2024/10/12 |
| | | * @param: rabbitTemplate |
| | | * @param: exchangeName |
| | | * @param: routingKey |
| | | * @param: message |
| | | **/ |
| | | public static void sendExchangeMsg(RabbitTemplate rabbitTemplate, String exchangeName, String routingKey, String message) { |
| | | rabbitTemplate.convertAndSend(exchangeName, routingKey, message); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 发送延迟交换机消息 |
| | | * @date 13:39 2024/10/12 |
| | | * @param: rabbitTemplate |
| | | * @param: exchangeName |
| | | * @param: routingKey |
| | | * @param: msg |
| | | * @param: delayMs |
| | | **/ |
| | | public static void sendExchangeMsg(RabbitTemplate rabbitTemplate, String exchangeName, String routingKey, String msg, int delayMs) { |
| | | DelayMsgInfo msgInfo = new DelayMsgInfo(); |
| | | msgInfo.setDelayMs(delayMs); |
| | | msgInfo.setExchangeName(exchangeName); |
| | | msgInfo.setMsg(msg); |
| | | msgInfo.setRoutingKey(routingKey); |
| | | MessageProperties messageProperties = new MessageProperties(); |
| | | messageProperties.setHeader("x-delay", delayMs); |
| | | Message message = new Message(new Gson().toJson(msgInfo).getBytes(StandardCharsets.UTF_8), messageProperties); |
| | | rabbitTemplate.convertAndSend(DELAY_EXCHANGE_NAME, ROUTING_KEY_COMMON_DELAY, message); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @description 添加消息到重新消费队列 |
| | | * @date 14:10 2024/10/12 |
| | | * @param: rabbitTemplate |
| | | * @param: message |
| | | * @return boolean 加入重新消费队列 |
| | | **/ |
| | | public static boolean retryConsume(RabbitTemplate rabbitTemplate, Message message) { |
| | | Map<String, Object> messageHeaders = message.getMessageProperties().getHeaders(); |
| | | int retryCount = 0; |
| | | if (messageHeaders.containsKey("retry_count")) { |
| | | retryCount = Integer.parseInt(messageHeaders.get("retry_count") + ""); |
| | | } |
| | | // 重试5次 |
| | | if (retryCount >= 5) { |
| | | return false; |
| | | } |
| | | |
| | | // 发送延迟消息 |
| | | DelayMsgInfo msgInfo = new DelayMsgInfo(); |
| | | msgInfo.setQueueName(message.getMessageProperties().getConsumerQueue()); |
| | | msgInfo.setMsg(new String(message.getBody(), StandardCharsets.UTF_8)); |
| | | msgInfo.setRoutingKey(message.getMessageProperties().getReceivedRoutingKey()); |
| | | msgInfo.setSendCount(retryCount); |
| | | MessageProperties messageProperties = new MessageProperties(); |
| | | messageProperties.setHeader("x-delay", 5*60*1000); |
| | | // messageProperties.setHeader("x-delay", 5*1000);// 测试为5s |
| | | Message messageNew = new Message(new Gson().toJson(msgInfo).getBytes(StandardCharsets.UTF_8), messageProperties); |
| | | rabbitTemplate.convertAndSend(DELAY_EXCHANGE_NAME, ROUTING_KEY_CONSUME_FAIL_DELAY, messageNew); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.money.extract.ExtractService; |
| | | import com.yeshi.fanli.util.CMQManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class ExtractResultListener { |
| | | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private ExtractService extractService; |
| | | |
| | | @RabbitListener(queues = "extract-result-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | if (!StringUtil.isNullOrEmpty(result)) { |
| | | AlipayTransferResultInfo alipayTransferResultInfo = new Gson().fromJson(result, |
| | | AlipayTransferResultInfo.class); |
| | | try { |
| | | extractService.processExtractResult(alipayTransferResultInfo); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class FanliNewOrdersListener { |
| | | |
| | | @Resource |
| | | private TaoBaoOrderService taoBaoOrderService; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @RabbitListener(queues = "fanli-new-orders-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String orderId = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | Map<String, List<TaoBaoOrder>> map = new HashMap<>(); |
| | | List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId); |
| | | map.put(orderId, orderList); |
| | | LogHelper.orderInfo("新订单-开始处理订单:" + orderId); |
| | | long startTime = System.currentTimeMillis(); |
| | | orderProcessService.processOrder(map); |
| | | LogHelper.orderInfo("新订单-结束处理订单:" + orderId + "- 处理时间:" |
| | | + (System.currentTimeMillis() - startTime)); |
| | | }); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; |
| | | import com.yeshi.fanli.util.CMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.NumberUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class FanliOrderListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private TaoBaoOrderService taoBaoOrderService; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @RabbitListener(queues = "fanli-order-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String orderId = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | if (NumberUtil.isNumeric(orderId.trim())) { |
| | | Map<String, List<TaoBaoOrder>> map = new HashMap<>(); |
| | | List<TaoBaoOrder> orderList = taoBaoOrderService |
| | | .getTaoBaoOrderByOrderId(orderId); |
| | | map.put(orderId, orderList); |
| | | LogHelper.orderInfo("开始处理订单:" + orderId); |
| | | orderProcessService.processOrder(map); |
| | | LogHelper.orderInfo("结束处理订单:" + orderId); |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.util.CMQManager; |
| | | import com.yeshi.fanli.util.RedisKeyEnum; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class FanliOrderNewListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | |
| | | @RabbitListener(queues = "fanli-order-new-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | if (!StringUtil.isNullOrEmpty(result)) { |
| | | HongBaoV2 hongbao = new Gson().fromJson(result, HongBaoV2.class); |
| | | try { |
| | | if (hongbao != null) { |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.hongBaoFanLi, |
| | | hongbao.getId() + ""); |
| | | if (StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) { |
| | | // 处理之后要隔2小时再次进行处理 |
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 2); |
| | | orderProcessService.fanli(hongbao); |
| | | } |
| | | } |
| | | } catch (TaoBaoWeiQuanException e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, "HongBaoV2-ID:" + hongbao.getId(), ""); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.NumberUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class FanliOrdersListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private TaoBaoOrderService taoBaoOrderService; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @RabbitListener(queues = "fanli-orders-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String orderId = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | if (NumberUtil.isNumeric(orderId.trim())) { |
| | | Map<String, List<TaoBaoOrder>> map = new HashMap<>(); |
| | | List<TaoBaoOrder> orderList = taoBaoOrderService |
| | | .getTaoBaoOrderByOrderId(orderId); |
| | | map.put(orderId, orderList); |
| | | LogHelper.orderInfo("开始处理订单:" + orderId); |
| | | orderProcessService.processOrder(map); |
| | | LogHelper.orderInfo("结束处理订单:" + orderId); |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.dto.mq.UidDateDTO; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.util.CMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class FanliShareOrderListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @RabbitListener(queues = "fanli-share-order-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | UidDateDTO dto = new Gson().fromJson(result, UidDateDTO.class); |
| | | try { |
| | | orderProcessService.fanliShare(dto.getUid(), dto.getDate()); |
| | | |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, result, ""); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | |
| | | |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.dto.mq.UidDateDTO; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.manger.money.TeamEincomeManager; |
| | | import com.yeshi.fanli.util.mq.cmq.order.TeamOrderCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class FanliTeamIncomeOrderListener { |
| | | Logger orderMoneyLog = LoggerFactory.getLogger("orderMoneyLog"); |
| | | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private TeamEincomeManager teamEincomeManager; |
| | | |
| | | @RabbitListener(queues = "fanli-team-income-order-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | UidDateDTO dto = new Gson().fromJson(result, UidDateDTO.class); |
| | | try { |
| | | orderMoneyLog.info("团队收益结算开始处理:日期-{} Uid-{}", TimeUtil.getGernalTime(dto.getDate().getTime(), "yyyy-MM-dd"), dto.getUid()); |
| | | teamEincomeManager.addTeamRewardTOUserAccount(dto.getDate(), dto.getUid()); |
| | | orderMoneyLog.info("团队收益结算处理成功:日期-{} Uid-{}", TimeUtil.getGernalTime(dto.getDate().getTime(), "yyyy-MM-dd"), dto.getUid()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, result, ""); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.dto.mq.UidDateDTO; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.util.mq.cmq.order.TeamOrderCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class FanliTeamIncomeOrderPreListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @RabbitListener(queues = "fanli-team-income-order-pre-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | UidDateDTO dto = new Gson().fromJson(result, UidDateDTO.class); |
| | | try { |
| | | orderProcessService.fanliPreInvaite(dto.getUid(), dto.getDate()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(dto).toString(), ""); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class ImpGoodsUpdateListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; |
| | | |
| | | @RabbitListener(queues = "imp_goods_update_queue-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String goodsId= new String(message.getBody(), StandardCharsets.UTF_8); |
| | | try { |
| | | long startTime = System.currentTimeMillis(); |
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(goodsId); |
| | | // 更新一条数据需要的时间 |
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(goods); |
| | | long time = System.currentTimeMillis() - startTime; |
| | | LogHelper.test("淘宝重要商品库更新时间:" + time); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.dto.mq.order.body.CommonOrderMQMsg; |
| | | import com.yeshi.fanli.entity.dy.DYOrder; |
| | | import com.yeshi.fanli.entity.jd.JDOrder; |
| | | import com.yeshi.fanli.entity.pdd.PDDOrder; |
| | | import com.yeshi.fanli.entity.suning.SuningOrderInfo; |
| | | import com.yeshi.fanli.entity.vipshop.VipShopOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.dy.DYOrderService; |
| | | import com.yeshi.fanli.service.inter.order.jd.JDOrderService; |
| | | import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService; |
| | | import com.yeshi.fanli.service.inter.order.suning.SuningOrderService; |
| | | import com.yeshi.fanli.service.inter.order.vipshop.VipShopOrderService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class OrderAllListener { |
| | | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | |
| | | @Resource |
| | | private JDOrderService jdOrderService; |
| | | |
| | | @Resource |
| | | private PDDOrderService pddOrderService; |
| | | |
| | | @Resource |
| | | private VipShopOrderService vipShopOrderService; |
| | | |
| | | @Resource |
| | | private SuningOrderService suningOrderService; |
| | | |
| | | |
| | | @Resource |
| | | private DYOrderService dyOrderService; |
| | | |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | |
| | | @RabbitListener(queues = "order-all-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | CommonOrderMQMsg orderMQMsg = JsonUtil.getSimpleGson().fromJson(result, CommonOrderMQMsg.class); |
| | | try { |
| | | LogHelper.test("订单消费:" + new Gson().toJson(orderMQMsg)); |
| | | if (orderMQMsg != null) { |
| | | String orderId = orderMQMsg.getOrderId(); |
| | | switch (orderMQMsg.getSourceType()) { |
| | | case Constant |
| | | .SOURCE_TYPE_JD: { |
| | | JDOrder order = jdOrderService.selectDetailByOrderId(Long.parseLong(orderId)); |
| | | orderProcessService.processJDOrder(order); |
| | | } |
| | | break; |
| | | case Constant |
| | | .SOURCE_TYPE_PDD: { |
| | | List<PDDOrder> orderList = pddOrderService.selectByOrderSn(orderId); |
| | | if (orderList != null) |
| | | for (PDDOrder order : orderList) |
| | | orderProcessService.processPDDOrder(order); |
| | | } |
| | | break; |
| | | case Constant |
| | | .SOURCE_TYPE_VIP: { |
| | | List<VipShopOrder> orderList = vipShopOrderService.listDetailByOrderSn(orderId); |
| | | if (orderList != null) |
| | | for (VipShopOrder order : orderList) |
| | | orderProcessService.processVipShopOrder(order); |
| | | } |
| | | break; |
| | | case Constant |
| | | .SOURCE_TYPE_SUNING: { |
| | | List<SuningOrderInfo> orderList = suningOrderService.listByOrderCode(orderId); |
| | | if (orderList != null) |
| | | for (SuningOrderInfo order : orderList) |
| | | orderProcessService.processSuningOrder(order); |
| | | } |
| | | break; |
| | | case Constant |
| | | .SOURCE_TYPE_DY: { |
| | | List<DYOrder> orderList = dyOrderService.listByOrderId(orderId); |
| | | if (orderList != null) |
| | | for (DYOrder order : orderList) |
| | | orderProcessService.processDYOrder(order); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | throw e; |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.jd.JDOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.jd.JDOrderService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.cmq.order.JDOrderCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class OrderJDListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private JDOrderService jdOrderService; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @RabbitListener(queues = "order-jd-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String orderId = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | try { |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | JDOrder order = jdOrderService.selectDetailByOrderId(Long.parseLong(orderId)); |
| | | orderProcessService.processJDOrder(order); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.pdd.PDDOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.cmq.order.PDDOrderCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class OrderPDDListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private PDDOrderService pddOrderService; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @RabbitListener(queues = "order-pdd-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String orderId = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | try { |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | List<PDDOrder> orderList = pddOrderService.selectByOrderSn(orderId); |
| | | if (orderList != null) |
| | | for (PDDOrder order : orderList) |
| | | orderProcessService.processPDDOrder(order); |
| | | } |
| | | LogHelper.test("拼多多订单处理成功:" + orderId); |
| | | } catch (Exception e) { |
| | | LogHelper.test("拼多多订单处理失败:" + orderId); |
| | | LogHelper.errorDetailInfo(e); |
| | | throw e; |
| | | } |
| | | |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.suning.SuningOrderInfo; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.suning.SuningOrderService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class OrderSuningListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private SuningOrderService suningOrderService; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @RabbitListener(queues = "order-suning-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String orderId = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | try { |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | List<SuningOrderInfo> orderList = suningOrderService.listByOrderCode(orderId); |
| | | if (orderList != null) |
| | | for (SuningOrderInfo order : orderList) |
| | | orderProcessService.processSuningOrder(order); |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | throw e; |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.vipshop.VipShopOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.vipshop.VipShopOrderService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.cmq.order.VipShopOrderCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class OrderVIPShopListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private VipShopOrderService vipShopOrderService; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @RabbitListener(queues = "order-vipshop-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String orderId = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | try { |
| | | LogHelper.test("唯品会订单消费:" + orderId); |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | List<VipShopOrder> orderList = vipShopOrderService.listDetailByOrderSn(orderId); |
| | | if (orderList != null) |
| | | for (VipShopOrder order : orderList) |
| | | orderProcessService.processVipShopOrder(order); |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | throw e; |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.dto.push.PushContentDetailDTO; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.push.HWPushService; |
| | | import com.yeshi.fanli.util.mq.cmq.PushCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class PushHWListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private HWPushService hwPushService; |
| | | |
| | | @RabbitListener(queues = "push-hw-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | PushContentDetailDTO dto = new Gson().fromJson(result, PushContentDetailDTO.class); |
| | | LogHelper.pushHW("接受到消息:" + new Gson().toJson(dto)); |
| | | try { |
| | | hwPushService.push(dto); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.push.PushQueueRecord; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.push.IOSPushService; |
| | | import com.yeshi.fanli.util.CMQManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class PushIosListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private IOSPushService iosPushService; |
| | | |
| | | @RabbitListener(queues = "push-ios-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | try { |
| | | |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | if (!StringUtil.isNullOrEmpty(result)) { |
| | | PushQueueRecord pushQueueRecord = new Gson().fromJson(result, PushQueueRecord.class); |
| | | iosPushService.readyPushIOS(pushQueueRecord); |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | throw e; |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.dto.mq.UidDateDTO; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.manger.money.TeamEincomeManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.cmq.order.TeamOrderCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class TeamDividentsListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private TeamEincomeManager teamEincomeManager; |
| | | |
| | | @RabbitListener(queues = "team_dividents-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | if (!StringUtil.isNullOrEmpty(result)) { |
| | | UidDateDTO dto = new Gson().fromJson(result, UidDateDTO.class); |
| | | try { |
| | | teamEincomeManager.addTeamDividentsTOUserAccount(dto.getDate(), dto.getUid()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.dto.mq.UidDateDTO; |
| | | import com.yeshi.fanli.exception.order.dividents.TeamDividentsRecordException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.manger.order.TeamDividentsManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.cmq.order.TeamOrderCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class TeamDividentsPreListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private TeamDividentsManager teamDividentsManager; |
| | | |
| | | @RabbitListener(queues = "team_dividents_pre-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | if (!StringUtil.isNullOrEmpty(result)) { |
| | | UidDateDTO dto = new Gson().fromJson(result, UidDateDTO.class); |
| | | try { |
| | | teamDividentsManager.addToTeamEincome(dto.getUid(), dto.getDate()); |
| | | } catch (TeamDividentsRecordException e1) { |
| | | if (e1.getCode() == TeamDividentsRecordException.CODE_EXIST) { |
| | | |
| | | } else { |
| | | try { |
| | | LogHelper.errorDetailInfo(e1); |
| | | } catch (Exception e2) { |
| | | e2.printStackTrace(); |
| | | } |
| | | throw e1; |
| | | } |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.dto.mq.order.body.CommonOrderMQMsg; |
| | | import com.yeshi.fanli.entity.dy.DYOrder; |
| | | import com.yeshi.fanli.entity.jd.JDOrder; |
| | | import com.yeshi.fanli.entity.pdd.PDDOrder; |
| | | import com.yeshi.fanli.entity.suning.SuningOrderInfo; |
| | | import com.yeshi.fanli.entity.vipshop.VipShopOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.dy.DYOrderService; |
| | | import com.yeshi.fanli.service.inter.order.jd.JDOrderService; |
| | | import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService; |
| | | import com.yeshi.fanli.service.inter.order.suning.SuningOrderService; |
| | | import com.yeshi.fanli.service.inter.order.vipshop.VipShopOrderService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class TestListener { |
| | | |
| | | private Logger logger = LoggerFactory.getLogger("infoLog"); |
| | | |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @RabbitListener(queues = "test_queue", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | logger.info("接受到测试数据:{}", result); |
| | | // throw new Exception("测试"); |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.entity.order.HongBaoOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralGetService; |
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService; |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; |
| | | import com.yeshi.fanli.util.mq.cmq.HongBaoRecieveCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class TopicHongbaoIntegralListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private HongBaoV2Service hongBaoV2Service; |
| | | |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | |
| | | @Resource |
| | | private HongBaoOrderService hongBaoOrderService; |
| | | |
| | | @Resource |
| | | private ThreeSaleSerivce threeSaleSerivce; |
| | | |
| | | @Resource |
| | | private IntegralGetService integralGetService; |
| | | |
| | | @Resource |
| | | private IntegralTaskRecordService integralTaskRecordService; |
| | | |
| | | private void fanliGetIntegral(HongBaoV2 hongBaoV2) { |
| | | |
| | | if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU |
| | | && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) { |
| | | // 查询对应的订单号 |
| | | Long mainHongBaoId = hongBaoV2.getId(); |
| | | if (hongBaoV2.getParent() != null && hongBaoV2.getParent().getId() != null) |
| | | mainHongBaoId = hongBaoV2.getParent().getId(); |
| | | |
| | | HongBaoOrder hongbaoOrder = hongBaoOrderService.selectDetailByHongBaoId(mainHongBaoId); |
| | | if (hongbaoOrder == null || hongbaoOrder.getCommonOrder() == null) |
| | | return; |
| | | CommonOrder commonOrder = hongbaoOrder.getCommonOrder(); |
| | | |
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购订单 |
| | | integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(), |
| | | commonOrder.getSourceType()); |
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享订单 |
| | | integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(), |
| | | commonOrder.getSourceType()); |
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级邀请 |
| | | integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(), |
| | | commonOrder.getSourceType()); |
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级邀请 |
| | | integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(), |
| | | commonOrder.getSourceType()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @RabbitListener(queues = "topic_hongbao_integral", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | |
| | | |
| | | Long hongBaoId = Long.parseLong(result); |
| | | try { |
| | | HongBaoV2 hongBaoV2 = hongBaoV2Service.selectByPrimaryKey(hongBaoId); |
| | | if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU |
| | | && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) { |
| | | // 到账送金币 |
| | | fanliGetIntegral(hongBaoV2); |
| | | // 返利不足0.01元送金币 |
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购 |
| | | // 判断是否为该用户的首笔红包 |
| | | List<Integer> typeList = new ArrayList<>(); |
| | | typeList.add(HongBaoV2.TYPE_ZIGOU); |
| | | HongBaoV2 firstHongBao = hongBaoV2Service.getFirstValidHongBaoByTypeAndUid( |
| | | typeList, hongBaoV2.getUserInfo().getId()); |
| | | if (firstHongBao != null |
| | | && firstHongBao.getId().longValue() == hongBaoV2.getId()) {// 自购首单到账 |
| | | // 查询下级红包 |
| | | BigDecimal firstLevelMoney = new BigDecimal(0); |
| | | BigDecimal secondLevelMoney = new BigDecimal(0); |
| | | // 获取改单下面的红包 |
| | | List<HongBaoV2> hongBaoList = new ArrayList<>(); |
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService |
| | | .selectDetailByHongBaoId(hongBaoV2.getId()); |
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {// 计算改订单号下面的所有返利金额 |
| | | CommonOrder commonOrder = hongBaoOrder.getCommonOrder(); |
| | | List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId( |
| | | commonOrder.getSourceType(), commonOrder.getOrderNo()); |
| | | for (CommonOrder co : list) { |
| | | HongBaoOrder hbo = hongBaoOrderService |
| | | .selectDetailByCommonOrderId(co.getId()); |
| | | if (hbo != null && hbo.getHongBaoV2() != null) |
| | | hongBaoList.add(hbo.getHongBaoV2()); |
| | | } |
| | | } |
| | | |
| | | for (HongBaoV2 hb : hongBaoList) { |
| | | List<HongBaoV2> children = hongBaoV2Service |
| | | .listChildrenById(hb.getId()); |
| | | if (children != null) |
| | | for (HongBaoV2 child : children) |
| | | if (child.getType() == HongBaoV2.TYPE_YIJI) { |
| | | firstLevelMoney = firstLevelMoney.add(child.getMoney()); |
| | | } else if (child.getType() == HongBaoV2.TYPE_ERJI) { |
| | | secondLevelMoney = secondLevelMoney.add(child.getMoney()); |
| | | } |
| | | } |
| | | |
| | | // 查询下级的生效时间 |
| | | ThreeSale threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState( |
| | | hongBaoV2.getUserInfo().getId(), ThreeSale.STATE_SUCCESS); |
| | | if (threeSale != null && threeSale.getSucceedTime() != null && threeSale |
| | | .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前 |
| | | // 成功时间要大于20190910日才开始送金币 |
| | | if (threeSale.getSucceedTime() > TimeUtil.convertToTimeTemp("20190901", |
| | | "yyyyMMdd")) { |
| | | if (firstLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 一级返利小于0.01 |
| | | integralTaskRecordService.firstRebateOrderRewardBoss( |
| | | threeSale.getBoss().getId(), |
| | | hongBaoV2.getUserInfo().getId(), null); |
| | | LogHelper.test("自购-一级用户-" + threeSale.getBoss().getId() |
| | | + "-hongBaoId:" + hongBaoV2.getId()); |
| | | } |
| | | } |
| | | } |
| | | // 查询下下级生效时间 |
| | | if (threeSale != null) { |
| | | threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState( |
| | | threeSale.getBoss().getId(), ThreeSale.STATE_SUCCESS); |
| | | if (threeSale != null && threeSale.getSucceedTime() != null && threeSale |
| | | .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前 |
| | | // 成功时间要大于20190910日才开始送金币 |
| | | if (threeSale.getSucceedTime() > TimeUtil |
| | | .convertToTimeTemp("20190901", "yyyyMMdd")) { |
| | | if (secondLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 二级返利小于0.01 |
| | | integralTaskRecordService.firstRebateOrderRewardBossSuper( |
| | | threeSale.getBoss().getId(), |
| | | hongBaoV2.getUserInfo().getId(), null); |
| | | LogHelper.test("自购-二级用户-" + threeSale.getBoss().getId() |
| | | + "-hongBaoId:" + hongBaoV2.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享赚 |
| | | // 判断是否为该用户的首笔红包 |
| | | List<Integer> typeList = new ArrayList<>(); |
| | | typeList.add(HongBaoV2.TYPE_SHARE_GOODS); |
| | | HongBaoV2 firstHongBao = hongBaoV2Service.getFirstValidHongBaoByTypeAndUid( |
| | | typeList, hongBaoV2.getUserInfo().getId()); |
| | | if (firstHongBao != null |
| | | && firstHongBao.getId().longValue() == hongBaoV2.getId()) // 分享首笔到账 |
| | | { |
| | | |
| | | // 查询下级红包 |
| | | BigDecimal firstLevelMoney = new BigDecimal(0); |
| | | // 获取改单下面的红包 |
| | | List<HongBaoV2> hongBaoList = new ArrayList<>(); |
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService |
| | | .selectDetailByHongBaoId(hongBaoV2.getId()); |
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {// 计算改订单号下面的所有返利金额 |
| | | CommonOrder commonOrder = hongBaoOrder.getCommonOrder(); |
| | | List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId( |
| | | commonOrder.getSourceType(), commonOrder.getOrderNo()); |
| | | for (CommonOrder co : list) { |
| | | HongBaoOrder hbo = hongBaoOrderService |
| | | .selectDetailByCommonOrderId(co.getId()); |
| | | if (hbo != null && hbo.getHongBaoV2() != null) |
| | | hongBaoList.add(hbo.getHongBaoV2()); |
| | | } |
| | | } |
| | | |
| | | for (HongBaoV2 hb : hongBaoList) { |
| | | List<HongBaoV2> children = hongBaoV2Service |
| | | .listChildrenById(hb.getId()); |
| | | if (children != null) |
| | | for (HongBaoV2 child : children) |
| | | if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) { |
| | | firstLevelMoney = firstLevelMoney.add(child.getMoney()); |
| | | } |
| | | } |
| | | |
| | | ThreeSale threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState( |
| | | hongBaoV2.getUserInfo().getId(), ThreeSale.STATE_SUCCESS); |
| | | if (threeSale != null && threeSale.getSucceedTime() != null && threeSale |
| | | .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前 |
| | | // 成功时间要大于20190910日才开始送金币 |
| | | if (threeSale.getSucceedTime() > TimeUtil.convertToTimeTemp("20190901", |
| | | "yyyyMMdd")) { |
| | | if (firstLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 一级返利小于0.01 |
| | | integralTaskRecordService.firstSharerOrderRewardBoss( |
| | | threeSale.getBoss().getId(), |
| | | hongBaoV2.getUserInfo().getId(), null); |
| | | LogHelper.test("分享-一级用户-" + threeSale.getBoss().getId() |
| | | + "-hongBaoId:" + hongBaoV2.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | // 金币不重要无需重复处理 |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.bus.user.Order; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService; |
| | | import com.yeshi.fanli.util.mq.cmq.order.PlaceOrderCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class TopicPlaceOrderAdListener { |
| | | private Logger logger = LoggerFactory.getLogger("infoLog"); |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | |
| | | |
| | | |
| | | private boolean isFirstValidOrder(String orderId, int sourceType, Long uid) { |
| | | CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid); |
| | | if (commonOrder != null && commonOrder.getOrderNo().equalsIgnoreCase(orderId) |
| | | && sourceType == commonOrder.getSourceType()) |
| | | return true; |
| | | else |
| | | return false; |
| | | } |
| | | |
| | | @RabbitListener(queues = "topic_place_order_ad", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | Order order = new Gson().fromJson(result, Order.class); |
| | | if (isFirstValidOrder(order.getOrderId(), order.getOrderType(), |
| | | order.getUserInfo().getId())) {// 有效的首单 |
| | | // TODO 抖音的数据回调 |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | import com.yeshi.fanli.entity.bus.user.Order; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.entity.order.HongBaoOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service; |
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService; |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; |
| | | import com.yeshi.fanli.util.mq.cmq.order.PlaceOrderCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.amqp.core.AcknowledgeMode; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class TopicPlaceOrderIntegralListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | |
| | | @Resource |
| | | private HongBaoOrderService hongBaoOrderService; |
| | | |
| | | @Resource |
| | | private HongBaoV2Service hongBaoV2Service; |
| | | |
| | | @Resource |
| | | private IntegralTaskRecordService integralTaskRecordService; |
| | | |
| | | @Resource |
| | | private ThreeSaleSerivce threeSaleSerivce; |
| | | |
| | | |
| | | private boolean isFirstValidOrder(String orderId, int sourceType, Long uid) { |
| | | CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid); |
| | | if (commonOrder != null && commonOrder.getOrderNo().equalsIgnoreCase(orderId) |
| | | && sourceType == commonOrder.getSourceType()) |
| | | return true; |
| | | else |
| | | return false; |
| | | } |
| | | |
| | | @RabbitListener(queues = "topic_place_order_integral", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | Order order = new Gson().fromJson(result, Order.class); |
| | | try { |
| | | // 是否是首单 |
| | | if (isFirstValidOrder(order.getOrderId(), order.getOrderType(), |
| | | order.getUserInfo().getId())) { |
| | | // 统计订单下的用户所获得的返利金额 |
| | | List<CommonOrder> list = commonOrderService |
| | | .listBySourceTypeAndOrderId(order.getOrderType(), order.getOrderId()); |
| | | Map<Long, BigDecimal> hongBaoMoney = new HashMap<>(); |
| | | if (list != null) { |
| | | for (CommonOrder commonOrder : list) { |
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService |
| | | .selectDetailByCommonOrderId(commonOrder.getId()); |
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) { |
| | | Long mainUid = hongBaoOrder.getHongBaoV2().getUserInfo().getId(); |
| | | if (hongBaoMoney.get(mainUid) == null) |
| | | hongBaoMoney.put(mainUid, new BigDecimal(0)); |
| | | hongBaoMoney.put(mainUid, hongBaoMoney.get(mainUid) |
| | | .add(hongBaoOrder.getHongBaoV2().getMoney())); |
| | | // 查询上级 |
| | | List<HongBaoV2> children = hongBaoV2Service |
| | | .listChildrenById(hongBaoOrder.getHongBaoV2().getId()); |
| | | if (children != null) { |
| | | for (HongBaoV2 hongBao : children) { |
| | | Long uid = hongBao.getUserInfo().getId(); |
| | | if (hongBaoMoney.get(uid) == null) |
| | | hongBaoMoney.put(uid, new BigDecimal(0)); |
| | | hongBaoMoney.put(uid, |
| | | hongBaoMoney.get(uid).add(hongBao.getMoney())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (isFirstValidOrder(order.getOrderId(), order.getOrderType(), |
| | | order.getUserInfo().getId())) {// 有效的首单 |
| | | if (hongBaoMoney.get(order.getUserInfo().getId()) == null || hongBaoMoney |
| | | .get(order.getUserInfo().getId()).compareTo(new BigDecimal("0")) <= 0) { |
| | | // 分享奖金是0 |
| | | integralTaskRecordService.firstShareOrderReward(order.getUserInfo().getId(), |
| | | null); |
| | | } |
| | | |
| | | // 获取上两级数据 |
| | | UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId()); |
| | | if (boss != null) {// 判断上级的红包 |
| | | if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId()) |
| | | .compareTo(new BigDecimal("0")) <= 0) { |
| | | // 补偿金币 |
| | | integralTaskRecordService.firstSharerOrderRewardBoss(boss.getId(), |
| | | order.getUserInfo().getId(), null); |
| | | } |
| | | } |
| | | |
| | | } else {// 自购订单 |
| | | UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId()); |
| | | if (boss != null) {// 判断上级的红包 |
| | | if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId()) |
| | | .compareTo(new BigDecimal("0")) <= 0) { |
| | | // 补偿金币1级 |
| | | integralTaskRecordService.firstRebateOrderRewardBoss(boss.getId(), |
| | | order.getUserInfo().getId(), null); |
| | | } |
| | | |
| | | boss = threeSaleSerivce.getBoss(boss.getId()); |
| | | if (boss != null) {// 判断上级的红包 |
| | | if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney |
| | | .get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) { |
| | | // 补偿金币2级 |
| | | integralTaskRecordService.firstRebateOrderRewardBossSuper( |
| | | boss.getId(), order.getUserInfo().getId(), null); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | throw e; |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.dto.money.UserMoneyChangeDTO; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService; |
| | | import com.yeshi.fanli.util.mq.cmq.UserMoneyChangeCMQManager; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class TopicUserMoneyDebtListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private UserMoneyDebtService userMoneyDebtService; |
| | | |
| | | @RabbitListener(queues = "topic_user_money_debt", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | UserMoneyChangeDTO dto = new Gson().fromJson(result, UserMoneyChangeDTO.class); |
| | | try { |
| | | if (dto != null && dto.getChangeMoney().compareTo(new BigDecimal(0)) > 0) { |
| | | userMoneyDebtService.repayDebt(dto.getUid()); |
| | | } |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | throw e; |
| | | } |
| | | |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.util.mq.rabbit.consumer; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.util.CMQManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqMsgConsumeUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageListener; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: QueueHelloWorldListener |
| | | * @description: |
| | | * @date 2024/9/26 13:47 |
| | | */ |
| | | @Component |
| | | public class WeiquanOrderListener { |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @RabbitListener(queues = "weiquan-order-fanli", ackMode = "MANUAL") |
| | | public void onMessage(Message message, Channel channel) throws Exception { |
| | | RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> { |
| | | String result = new String(message.getBody(), StandardCharsets.UTF_8); |
| | | if (!StringUtil.isNullOrEmpty(result)) { |
| | | TaoBaoWeiQuanOrder taoBaoWeiQuanOrder = new Gson().fromJson(result, TaoBaoWeiQuanOrder.class); |
| | | |
| | | try { |
| | | orderProcessService.weiQuanOrder(taoBaoWeiQuanOrder); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | |
| | | throw e; |
| | | |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |
| | |
| | | * 微信小程序转链 @Title: convertWXMP @Description: @param goodsId @param |
| | | * pid @param customParams @return PDDPromotionUrl 返回类型 @throws |
| | | */ |
| | | public static String convertWXMP(Long goodsId, String pid, String customParams) { |
| | | public static String convertWXMP(String goodsId, String pid, String customParams) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("type", "pdd.ddk.goods.promotion.url.generate"); |
| | | map.put("p_id", pid); |
| | |
| | | /** |
| | | * 获取商品详情 |
| | | * |
| | | * @param goodsId |
| | | * @param goodsSign |
| | | */ |
| | | public static PDDGoodsDetail getGoodsDetail(Long goodsId) { |
| | | public static PDDGoodsDetail getGoodsDetail(String goodsSign) { |
| | | try { |
| | | return getGoodsDetail(goodsId, PID_DEFAULT, "437031"); |
| | | return getGoodsDetail(goodsSign, PID_DEFAULT, "437031"); |
| | | } catch (PDDApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static PDDGoodsDetail getGoodsDetail(Long goodsId, String pid, String customParameters) throws PDDApiException { |
| | | public static PDDGoodsDetail getGoodsDetail(String goodsSign, String pid, String customParameters) throws PDDApiException { |
| | | |
| | | PDDSearchFilter sf = new PDDSearchFilter(); |
| | | sf.setKw(goodsId + ""); |
| | | PDDGoodsResult goodsResult = searchGoods(sf, customParameters); |
| | | if (goodsResult == null) |
| | | return null; |
| | | |
| | | if (goodsResult.getGoodsList() == null || goodsResult.getGoodsList().size() <= 0) { |
| | | return null; |
| | | } |
| | | |
| | | String goodsSign = goodsResult.getGoodsList().get(0).getGoodsSign(); |
| | | // String goodsSign = goodsResult.getGoodsList().get(0).getGoodsSign(); |
| | | |
| | | |
| | | JSONArray array = new JSONArray(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | public static void main(String[] args) throws Exception{ |
| | | |
| | | // PDDConvertLinkResultVO vo = getAuthLink("8590899_72067894", 437031+""); |
| | | boolean isAuthed = isAuth(PID_DEFAULT, 437031+""); |
| | | System.out.println("是否授权:"+isAuthed); |
| | | // boolean isAuthed = isAuth(PID_DEFAULT, 437031+""); |
| | | // System.out.println("是否授权:"+isAuthed); |
| | | // |
| | | // System.out.println(vo); |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(419563711836L); |
| | | PDDSearchFilter searchFilter=new PDDSearchFilter(); |
| | | searchFilter.setKw("鞋"); |
| | | searchFilter.setPage(1); |
| | | searchFilter.setPageSize(20); |
| | | PinDuoDuoApiUtil.searchGoods(searchFilter,Constant.PDD_SEARCH_CUSTOMER_PARAMS); |
| | | // PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(364476396740L); |
| | | |
| | | // PDDConvertLinkResultVO vo = convertChannel("0", PID_DEFAULT, null); |
| | | |
| | | // System.out.println(vo); |
| | | PDDConvertLinkResultVO goodsc = PinDuoDuoApiUtil.convert(goods.getGoodsSign(), PID_DEFAULT + "", "437031", false); |
| | | // PDDConvertLinkResultVO goodsc = PinDuoDuoApiUtil.convert(goods.getGoodsSign(), PID_DEFAULT + "", "437031", false); |
| | | |
| | | System.out.println(""); |
| | | // System.out.println(""); |
| | | } |
| | | } |
| | |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | |
| | | import org.apache.commons.httpclient.Header; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.HttpException; |
| | | import org.apache.commons.httpclient.methods.GetMethod; |
| | | import org.apache.commons.httpclient.methods.PostMethod; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | |
| | | if (url == null) |
| | | return null; |
| | | String link = url; |
| | | |
| | | if (isPDDShortLink(link)) {// 拼多多的短链 |
| | | HttpClient client = new HttpClient(); |
| | | client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String pddId = getPDDGoodsId("https://yangkeduo.com/goods.html?goods_id=239627857864&_oak_rem_ar_id=999&page_from=35&refer_page_name=index&refer_page_id=10002_1624604559079_5bp5ba3dv6&refer_page_sn=10002"); |
| | | String link = "https://mobile.yangkeduo.com/goods.html?ps=Xy6iPwbIKZ"; |
| | | HttpClient client = new HttpClient(); |
| | | client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); |
| | | GetMethod pm = new GetMethod(link); |
| | | pm.setRequestHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"); |
| | | //pm.setRequestHeader("Sec-Fetch-Site","same-origin"); |
| | | pm.setRequestHeader("Upgrade-Insecure-Requests","1"); |
| | | pm.setRequestHeader("Referer","https://mobile.yangkeduo.com/goods.html?ps=Xy6iPwbIKZ"); |
| | | //pm.setRequestHeader("Priority","u=0, i"); |
| | | pm.setRequestHeader(":authority","mobile.yangkeduo.com"); |
| | | //pm.setRequestHeader("Cookie","api_uid=CkilZ2ZPIkIbkQBWBOpQAg==; _nano_fp=Xpman5TjX5gYX5XyX9_~Ae2Gbs0pL8h6jt_96NPO; webp=1; jrpl=KlZOYnFydoAazGlzTaZsZppQwiLSz3OM; njrpl=KlZOYnFydoAazGlzTaZsZppQwiLSz3OM; dilx=C2L6L~2oOr3ElrZKZ4_YW; pdd_vds=gaeAuFISuzLSnVdWuVbgspGgwjOXGqdpNMuzbXyFeJOXypsMOMlkLJnMGpOH"); |
| | | pm.setRequestHeader("Sec-Ch-Ua","\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\", \"Not-A.Brand\";v=\"99\""); |
| | | pm.setRequestHeader("Sec-Ch-Ua-Mobile","?0"); |
| | | pm.setRequestHeader("Sec-Ch-Ua-Platform","\"Windows\""); |
| | | pm.setRequestHeader("Sec-Fetch-Dest","document"); |
| | | pm.setRequestHeader("Sec-Fetch-Mode","navigate"); |
| | | // pm.setRequestHeader("",""); |
| | | // pm.setRequestHeader("",""); |
| | | |
| | | System.out.println(pddId); |
| | | try { |
| | | client.executeMethod(pm); |
| | | Header[] headers = pm.getRequestHeaders(); |
| | | for(Header header:headers ){ |
| | | |
| | | System.out.println(header.toString()); |
| | | } |
| | | Header location = pm.getResponseHeader("Location"); |
| | | if (location != null) { |
| | | link = location.getValue(); |
| | | System.out.println(link); |
| | | } |
| | | System.out.println(pm.getResponseBodyAsString()); |
| | | } catch (HttpException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | // String result = getAcessTokenInfo("576a51ae7b9b4db1bbfc921cf381ac0c", "1234"); |
| | | // System.out.println(result); |
| | | // VipShopOrder order = getOrderDetail("23090254293903"); |
| | | System.out.println(parseGoodsIdFromLink("https://t.vip.com/8F39raFxwN7")); |
| | | VipShopOrder order = getOrderDetail("24092976176343"); |
| | | // convertLink("6920342191507923649","437032"); |
| | | // System.out.println(parseGoodsIdFromLink("https://t.vip.com/8F39raFxwN7")); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | <dubbo:annotation package="com.yeshi.fanli"></dubbo:annotation> |
| | | |
| | | <dubbo:registry address="zookeeper://172.16.16.46:2181"/> |
| | | <!--<dubbo:registry address="zookeeper://193.112.35.168:2182"/>--> |
| | | <!--<dubbo:registry address="zookeeper://172.16.16.46:2181"/>--> |
| | | <dubbo:registry address="zookeeper://193.112.35.168:2182"/> |
| | | |
| | | <!-- url=dubbo://192.168.3.122:20882/com.yeshi.goods.facade.service.TaoBaoCouponCacheService --> |
| | | |
New file |
| | |
| | | rabbitmq.host=134.175.68.214 |
| | | rabbitmq.port=5672 |
| | | rabbitmq.username=root |
| | | rabbitmq.password=yeshi2014 |
| | | rabbitmq.virtual-host=/fanli |
| | | rabbitmq.x-message-ttl=21600000 |
| | | |
New file |
| | |
| | | rabbitmq.host=172.16.16.38 |
| | | rabbitmq.port=5672 |
| | | rabbitmq.username=root |
| | | rabbitmq.password=yeshi2014 |
| | | rabbitmq.virtual-host=/fanli |
| | | rabbitmq.x-message-ttl=21600000 |
| | | |
| | | |
| | | |
| | |
| | | </appender> |
| | | |
| | | |
| | | <appender name="JD_API_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.filePath}/api/jdapi.log</file> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
| | | <fileNamePattern>${log.filePath}/api/jdapi.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> |
| | | <maxHistory>${log.maxHistory}</maxHistory> |
| | | <maxFileSize>${log.maxSize}</maxFileSize> |
| | | </rollingPolicy> |
| | | <appender name="JD_API_APPENDER" class="com.tencentcloudapi.cls.LoghubAppender"> |
| | | |
| | | <layout class="ch.qos.logback.classic.PatternLayout"> |
| | | <pattern> |
| | | ${log.pattern} |
| | | </pattern> |
| | | </layout> |
| | | <!--必选项--> |
| | | <endpoint>${tencent.log.endpoint}</endpoint> |
| | | <accessKeyId>${tencent.log.accesskey}</accessKeyId> |
| | | <accessKeySecret>${tencent.log.accessKeySecret}</accessKeySecret> |
| | | <topicId>a2ca13da-6f4f-4352-a74f-e15ef639a43c</topicId> |
| | | |
| | | <!-- 可选项 设置时间格式 --> |
| | | <timeFormat>yyyy-MM-dd'T'HH:mm:ssZ</timeFormat> |
| | | <timeZone>Asia/Shanghai</timeZone> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | <mdcFields>THREAD_ID,MDC_KEY</mdcFields> |
| | | |
| | | </appender> |
| | | |
| | | <appender name="USER_ORDER" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | |
| | | debug日志会输出到debugAppender指定的文件中 |
| | | info日志会输出到infoAppender指定的文件中 |
| | | error日志会输出到errorAppender指定的文件中--> |
| | | <logger name="infoLog" level="INFO" additivity="false"> |
| | | <appender-ref ref="STDOUT"></appender-ref> |
| | | </logger> |
| | | |
| | | <logger name="userInfoLog" level="INFO" additivity="false"> |
| | | <appender-ref ref="USER_INFO"></appender-ref> |
| | | </logger> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <beans xmlns="http://www.springframework.org/schema/beans" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xmlns:rabbit="http://www.springframework.org/schema/rabbit" |
| | | xmlns:context="http://www.springframework.org/schema/context" |
| | | xsi:schemaLocation="http://www.springframework.org/schema/beans |
| | | http://www.springframework.org/schema/beans/spring-beans.xsd |
| | | http://www.springframework.org/schema/rabbit |
| | | http://www.springframework.org/schema/rabbit/spring-rabbit.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> |
| | | |
| | | <context:annotation-config /> |
| | | <rabbit:connection-factory id="connectionFactory" |
| | | host="${rabbitmq.host}" |
| | | port="${rabbitmq.port}" |
| | | username="${rabbitmq.username}" |
| | | password="${rabbitmq.password}" |
| | | virtual-host="${rabbitmq.virtual-host}" /> |
| | | |
| | | <context:component-scan base-package="com.yeshi.fanli.util.mq.rabbit" /> |
| | | |
| | | <bean id="rabbitListenerContainerFactory" |
| | | class="org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory"> |
| | | <property name="connectionFactory" ref="connectionFactory"/> |
| | | <!-- 可以根据需要配置其他属性 --> |
| | | </bean> |
| | | |
| | | |
| | | |
| | | |
| | | </beans> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <beans xmlns="http://www.springframework.org/schema/beans" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xmlns:rabbit="http://www.springframework.org/schema/rabbit" |
| | | xsi:schemaLocation="http://www.springframework.org/schema/beans |
| | | http://www.springframework.org/schema/beans/spring-beans.xsd |
| | | |
| | | |
| | | http://www.springframework.org/schema/rabbit |
| | | http://www.springframework.org/schema/rabbit/spring-rabbit.xsd"> |
| | | |
| | | <rabbit:connection-factory id="connectionFactory" |
| | | host="${rabbitmq.host}" |
| | | port="${rabbitmq.port}" |
| | | username="${rabbitmq.username}" |
| | | password="${rabbitmq.password}" |
| | | virtual-host="${rabbitmq.virtual-host}" /> |
| | | <!--定义管理交换机、队列--> |
| | | <rabbit:admin connection-factory="connectionFactory"/> |
| | | |
| | | <rabbit:queue id="deadLetterQueue" name="deadLetterQueue" auto-declare="true"> |
| | | <rabbit:queue-arguments> |
| | | <entry key="x-message-ttl" value="172800000" value-type="java.lang.Integer"/> <!-- 设置消息 TTL 为 2天 --> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <!-- 定义死信交换机和队列 --> |
| | | <rabbit:fanout-exchange id="deadLetterExchange" name="dead.letter.exchange" > |
| | | <rabbit:bindings> |
| | | <rabbit:binding queue="deadLetterQueue"/> |
| | | </rabbit:bindings> |
| | | </rabbit:fanout-exchange> |
| | | |
| | | |
| | | <!--定义持久化队列,不存在则自动创建;不绑定到交换机则绑定到默认交换机. 默认交换机类型为direct,名字为:"",路由键为队列的名称--> |
| | | <!-- |
| | | id:bean的名称 |
| | | name:queue的名称 |
| | | auto-declare:自动创建 |
| | | auto-delete:自动删除。 最后一个消费者和该队列断开连接后,自动删除队列 |
| | | durable:是否持久化 |
| | | --> |
| | | |
| | | |
| | | |
| | | <!-- 简单模式 --> |
| | | <!-- ignore-declaration-exceptions: 忽略队列已存在且声明时属性不一致的报错 --> |
| | | <rabbit:queue id="order-all-fanli" name="order-all-fanli" auto-declare="true"> |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="order-vipshop-fanli" name="order-vipshop-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="order-suning-fanli" name="order-suning-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="push-hw-fanli" name="push-hw-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="order-jd-fanli" name="order-jd-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="order-pdd-fanli" name="order-pdd-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="tejia_vip-fanli" name="tejia_vip-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="fanli-share-order-fanli" name="fanli-share-order-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="imp_goods_update_queue-fanli" name="imp_goods_update_queue-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="fanli-order-new-fanli" name="fanli-order-new-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="weiquan-order-fanli" name="weiquan-order-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="fanli-order-fanli" name="fanli-order-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="push-ios-fanli" name="push-ios-fanli" auto-declare="true"> |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="extract-result-fanli" name="extract-result-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="fanli-team-income-order-fanli" name="fanli-team-income-order-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="fanli-new-orders-fanli" name="fanli-new-orders-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="team_dividents-fanli" name="team_dividents-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="fanli-orders-fanli" name="fanli-orders-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="fanli-team-income-order-pre-fanli" name="fanli-team-income-order-pre-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="team_dividents_pre-fanli" name="team_dividents_pre-fanli" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | |
| | | <!-- 发布订阅模式 --> |
| | | <!-- fanout: 广播, 所有绑定到交换机的队列都能收到消息 --> |
| | | |
| | | <!-- 用户资金变化订阅 --> |
| | | <rabbit:queue id="topic_user_money_debt" name="topic_user_money_debt" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:fanout-exchange id="topic_user_money" name="topic_user_money" auto-declare="true" > |
| | | <rabbit:bindings> |
| | | <rabbit:binding queue="topic_user_money_debt" /> |
| | | </rabbit:bindings> |
| | | </rabbit:fanout-exchange> |
| | | |
| | | <!-- 下单订阅 --> |
| | | <rabbit:queue id="topic_place_order_integral" name="topic_place_order_integral" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:queue id="topic_place_order_ad" name="topic_place_order_ad" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:fanout-exchange id="topic_place_order" name="topic_place_order" auto-declare="true" > |
| | | <rabbit:bindings> |
| | | <rabbit:binding queue="topic_place_order_integral" /> |
| | | <rabbit:binding queue="topic_place_order_ad" /> |
| | | </rabbit:bindings> |
| | | </rabbit:fanout-exchange> |
| | | |
| | | <!-- 下单红包订阅 --> |
| | | <rabbit:queue id="topic_hongbao_integral" name="topic_hongbao_integral" auto-declare="true" > |
| | | <rabbit:queue-arguments> |
| | | <!-- 配置死信队列 --> |
| | | <entry key="x-dead-letter-exchange" value="dead.letter.exchange" /> |
| | | <entry key="x-message-ttl" value="${rabbitmq.x-message-ttl}" value-type="java.lang.Integer"/> |
| | | </rabbit:queue-arguments> |
| | | </rabbit:queue> |
| | | <rabbit:fanout-exchange id="topic_hongbao" name="topic_hongbao" auto-declare="true" > |
| | | <rabbit:bindings> |
| | | <rabbit:binding queue="topic_hongbao_integral" /> |
| | | </rabbit:bindings> |
| | | </rabbit:fanout-exchange> |
| | | |
| | | <!-- rabbitTemplate--> |
| | | <rabbit:template id="rabbitTemplate" connection-factory="connectionFactory" retry-template="retryTemplate" /> |
| | | |
| | | <!-- Retry Template --> |
| | | <bean id="retryTemplate" class="org.springframework.retry.support.RetryTemplate"> |
| | | <property name="backOffPolicy"> |
| | | <bean class="org.springframework.retry.backoff.ExponentialBackOffPolicy"> |
| | | <property name="initialInterval" value="1000"/> <!-- 初始间隔 --> |
| | | <property name="multiplier" value="3"/> <!-- 乘数 --> |
| | | <property name="maxInterval" value="30000"/> <!-- 最大间隔 --> |
| | | </bean> |
| | | </property> |
| | | <property name="retryPolicy"> |
| | | <bean class="org.springframework.retry.policy.SimpleRetryPolicy"> |
| | | <property name="maxAttempts" value="5"></property> |
| | | </bean> |
| | | </property> |
| | | </bean> |
| | | |
| | | </beans> |
| | |
| | | <value>classpath:xxl-job-executor.properties</value> |
| | | <value>classpath:elasticsearch.properties</value> |
| | | <value>classpath:kafka_log.properties</value> |
| | | <value>classpath:rabbitmq.properties</value> |
| | | </array> |
| | | </property> |
| | | </bean> |
| | |
| | | <import resource="classpath:xxl-job.xml"/> |
| | | <import resource="classpath:elasticsearch.xml"/> |
| | | <import resource="classpath:dubbo/consumer.xml"/> |
| | | <import resource="classpath:rabbitmq/spring-rabbitmq-producer.xml"/> |
| | | <import resource="classpath:rabbitmq/spring-rabbitmq-consumer.xml"/> |
| | | |
| | | |
| | | |
| | | <!--异步定义推荐方式 <task:executor id="executor" pool-size="15" /> <task:scheduler |
| | |
| | | |
| | | <properties> |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | <org.springframework-version>4.3.14.RELEASE</org.springframework-version> |
| | | <org.springframework-version>5.2.0.RELEASE</org.springframework-version> |
| | | <mybatis.version>3.4.1</mybatis.version> |
| | | <!-- <spring.mongodb.version>1.9.8.RELEASE</spring.mongodb.version> --> |
| | | <spring.mongodb.version>1.10.10.RELEASE</spring.mongodb.version> |