fanli/src/main/java/com/yeshi/fanli/aspect/RequestSerializableAspect.java
@@ -92,6 +92,7 @@ if (!StringUtil.isNullOrEmpty(cacheKey)) { cacheKey = joinPoint.getTarget().getClass().getName() + "." + targetMethod.getName() + "-" + cacheKey; String cacheAlias = cacheKey; cacheKey = "rs-" + StringUtil.Md5(cacheKey); // jiedis原子性做拦截 Jedis jedis = jedisPool.getResource(); @@ -102,6 +103,8 @@ // 等待响应 while (result <= 0) { result = jedis.setnx(cacheKey, "1"); LogHelper.error("触发并发锁:" + cacheAlias); LogHelper.error("redis键:" + cacheKey); if (result <= 0) { try { Thread.sleep(50); fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java
@@ -86,11 +86,9 @@ @Resource private TLJBuyGoodsService tljBuyGoodsService; @Resource private IntegralGetService integralGetService; private void doTaoLiJinBuy(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) { JSONObject data = new JSONObject(); @@ -99,6 +97,10 @@ // 根据日期与商品ID查询 TLJBuyGoods tljBuyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(auctionId, TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); if (tljBuyGoods == null) { out.print(JsonUtil.loadFalseResult(1, "商品不存在")); return; } String appKey = tljBuyGoods.getAppKey(); TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppKeyCache(appKey); if (config == null) { @@ -121,7 +123,7 @@ data.put("type", 1); data.put("link", link); out.print(JsonUtil.loadTrueResult(data)); integralGetService.addTaoLiJinBuy(uid, auctionId); } @@ -289,7 +291,7 @@ // 获得金币 integralGetService.addCouponRebate(uid); } catch (Exception e) { LogHelper.errorDetailInfo(e); @@ -421,7 +423,7 @@ history.setGoodsId(goodsId); recommendGoodsDeleteHistoryService.addRecommendGoodsDeleteHistory(history); out.print(JsonUtil.loadTrueResult("")); // 获得金币 integralGetService.addCloseRecommendGoods(uid); } fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5TaoLiJinController.java
New file @@ -0,0 +1,145 @@ package com.yeshi.fanli.controller.client.v1.h5; import java.io.PrintWriter; import java.math.BigDecimal; import java.util.Date; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.JsonUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.taobao.ShareHotGoods; import com.yeshi.fanli.entity.taobao.TLJBuyGoods; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService; import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService; import com.yeshi.fanli.util.TaoBaoConstant; import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoLiJinUtil; import com.yeshi.fanli.vo.goods.GoodsDetailVO; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @Controller @RequestMapping("api/apph5/v1/tlj") public class AppH5TaoLiJinController { @Resource private TLJBuyGoodsService tljBuyGoodsService; @Resource private ShareHotGoodsService shareHotGoodsService; @Resource private HongBaoManageService hongBaoManageService; @Resource private ConfigTaoLiJinService configTaoLiJinService; @RequestMapping("getTLJBuyGoods") public void getTLJBuyGoods(AcceptData acceptData, PrintWriter out, String callback) { // List<TLJBuyGoods> goodsList = tljBuyGoodsService .listByDay(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); int count = goodsList.size(); JSONObject data = new JSONObject(); JSONArray goodsArray = new JSONArray(); goodsList = goodsList.size() > 10 ? goodsList.subList(0, 10) : goodsList; BigDecimal proportion = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE; Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); for (TLJBuyGoods goods : goodsList) { TaoBaoGoodsBrief taoBaoGoodsBrief = goods.getGoods(); if (taoBaoGoodsBrief == null) { continue; } // 计算推广红包 BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion); // 推广红包 不能小于1 if (spreadMoney.compareTo(new BigDecimal(1.0)) < 0) { continue; } GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, proportion, proportion); // 大于1.6.5的才会显示福利价 if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) { if (detailVO.getCouponPrice() != null && detailVO.getCouponPrice().compareTo(new BigDecimal(0)) > 0) detailVO.setCouponPrice(detailVO.getCouponPrice().subtract(spreadMoney)); else detailVO.setZkPrice(detailVO.getZkPrice().subtract(spreadMoney)); } goodsArray.add(gson.toJson(detailVO)); } data.put("goodsList", goodsArray); data.put("count", count); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } /** * 分享爆款商品 * * @param acceptData * @param out * @param callback */ @RequestMapping("getShareHotGoods") public void getShareHotGoods(AcceptData acceptData, PrintWriter out, String callback) { List<ShareHotGoods> goodsList = shareHotGoodsService .listByDay(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); int count = goodsList.size(); JSONObject data = new JSONObject(); JSONArray goodsArray = new JSONArray(); goodsList = goodsList.size() > 10 ? goodsList.subList(0, 10) : goodsList; Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); BigDecimal fanLiRate = hongBaoManageService.getTLJShareRate(System.currentTimeMillis()); BigDecimal shareRate = hongBaoManageService.getTLJShareRate(System.currentTimeMillis()); for (ShareHotGoods hotGoods : goodsList) { TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods(); if (taoBaoGoodsBrief == null) { continue; } // 计算推广红包 String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date()); BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, taoBaoGoodsBrief); // 推广红包 不能小于1 if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { continue; } GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate); // 大于1.6.5的才会显示福利价 if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) { if (detailVO.getCouponPrice() != null && detailVO.getCouponPrice().compareTo(new BigDecimal(0)) > 0) detailVO.setCouponPrice(detailVO.getCouponPrice().subtract(spreadMoney)); else detailVO.setZkPrice(detailVO.getZkPrice().subtract(spreadMoney)); } // 去掉标签 detailVO.setLabels(null); goodsArray.add(gson.toJson(detailVO)); } data.put("goodsList", goodsArray); data.put("count", count); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -139,11 +139,6 @@ List<SwiperPicture> topPicList = new ArrayList<>(); if (oldtopPicList != null && oldtopPicList.size() > 0) topPicList.addAll(oldtopPicList); if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { SwiperPicture notifyReName = swiperPictureService.selectByPrimaryKey(162L); if (notifyReName != null) topPicList.add(0, notifyReName); } root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList)); fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java
@@ -48,13 +48,12 @@ @Resource private TaoBaoUnionConfigService taoBaoUnionConfigService; @Resource private UserTaoLiJinGiveRecordService userTaoLiJinGiveRecordService; @Resource private UserTaoLiJinOriginService userTaoLiJinOriginService; /** * 更新报告 @@ -130,7 +129,7 @@ for (int i = 0; i < list.size(); i++) { if (count >= 10) break; boolean success = shareHotGoodsService.verifyCanCreateTLJ(list.get(i).getGoods().getAuctionId(), boolean success = tljBuyGoodsService.verifyCanCreateTLJ(list.get(i).getGoods().getAuctionId(), new TaoKeAppInfo(app.getAppKey(), app.getAppSecret(), app.getDefaultPid())); if (success) { count++; @@ -179,22 +178,21 @@ addTLJBuyGoods(list, day); } /** * 每2个小时 赠送退回已过期淘礼金 * 每2个小时 赠送退回已过期淘礼金 */ @Scheduled(cron = "0 0 0/2 * * ? ") public void giveSendBack() { if (!Constant.IS_TASK) return; for (int i = 0; i < 100; i++) { List<UserTaoLiJinGiveRecord> overdueList = userTaoLiJinGiveRecordService.overdueList(500); if (overdueList == null || overdueList.size() == 0) { break; } for (UserTaoLiJinGiveRecord record: overdueList) { for (UserTaoLiJinGiveRecord record : overdueList) { try { userTaoLiJinOriginService.giveSendBack(record.getGiveUid(), record); // 更新记录 fanli/src/main/java/com/yeshi/fanli/log/TLJLogHelper.java
@@ -7,7 +7,7 @@ private static Logger tljLogger = Logger.getLogger("tljLog"); public static void info(Long auctionId, String msg) { String message = String.format("商品ID: 错误信息:%s", auctionId + "", msg); String message = String.format("商品ID:%s 错误信息:%s", auctionId + "", msg); tljLogger.info(message); } fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/ShareHotGoodsServiceImpl.java
@@ -22,7 +22,6 @@ import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException; import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService; import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService; import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service; fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java
@@ -11,6 +11,7 @@ import javax.annotation.Resource; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.ehcache.EhCacheCacheManager; import org.springframework.stereotype.Service; @@ -270,6 +271,9 @@ @Override public void removeGoods(Long auctionId) { tljBuyGoodsDao.deleteByAuctionId(auctionId); // 清除列表缓存 ehCacheCacheManager.getCache("commonContentCache") .evict("tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); } } fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanOrderServiceImpl.java
@@ -37,7 +37,8 @@ .selectByOrderIdAndOrderItemId(order.getOrderId(), order.getOrderItemId()); if (taoBaoWeiQuanOrder != null) { // 已经是最新的状态了 if (taoBaoWeiQuanOrder.getState().contains("维权成功") || taoBaoWeiQuanOrder.getState().contains("维权失败")) if (taoBaoWeiQuanOrder.getState() != null && (taoBaoWeiQuanOrder.getState().contains("维权成功") || taoBaoWeiQuanOrder.getState().contains("维权失败"))) return; // 更新金额,状态与时间 TaoBaoWeiQuanOrder update = new TaoBaoWeiQuanOrder(); @@ -56,13 +57,13 @@ for (MsgOrderDetail msg : msgList) { if (msg.getType() == MsgTypeOrderTypeEnum.fanli) { userOrderMsgNotificationService.orderFanLiStateChanged(msg.getUser().getId(), order.getOrderId(),Constant.SOURCE_TYPE_TAOBAO, null, null, CommonOrder.STATE_WQ); order.getOrderId(), Constant.SOURCE_TYPE_TAOBAO, null, null, CommonOrder.STATE_WQ); } else if (msg.getType() == MsgTypeOrderTypeEnum.invite) { userOrderMsgNotificationService.orderInviteStateChanged(msg.getUser().getId(), order.getOrderId(), Constant.SOURCE_TYPE_TAOBAO,null, null, CommonOrder.STATE_WQ); order.getOrderId(), Constant.SOURCE_TYPE_TAOBAO, null, null, CommonOrder.STATE_WQ); } else if (msg.getType() == MsgTypeOrderTypeEnum.share) { userOrderMsgNotificationService.orderShareStateChanged(msg.getUser().getId(), order.getOrderId(),Constant.SOURCE_TYPE_TAOBAO, null, null, CommonOrder.STATE_WQ); order.getOrderId(), Constant.SOURCE_TYPE_TAOBAO, null, null, CommonOrder.STATE_WQ); } } } fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -1905,7 +1905,7 @@ // 淘礼金创建 public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum, Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app) throws TaoKeApiException, TaoLiJinCreateException { throws TaoLiJinCreateException,TaoKeApiException { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.dg.vegas.tlj.create"); map.put("adzone_id", app.getPid().split("_")[3]); @@ -1961,8 +1961,6 @@ } } catch (TaoKeApiException e) { throw e; } catch (Exception e) { LogHelper.errorDetailInfo(e); } return null;