模拟请求缓存商品数据,淘礼金商品兼容多个appkey
| | |
| | | import com.yeshi.fanli.entity.taobao.ClientTBPid;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.TBPid;
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | import com.yeshi.fanli.service.inter.goods.recommend.RecommendGoodsDeleteHistoryService;
|
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | |
| | | @Resource
|
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService;
|
| | |
|
| | | @Resource
|
| | | private TLJBuyGoodsService tljBuyGoodsService;
|
| | |
|
| | | private void doTaoLiJinBuy(Long uid, Long auctionId, PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | TaoBaoLink taoBaoLink;
|
| | | try {
|
| | | taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuyWithOutFanLi(uid, auctionId);
|
| | | // 根据日期与商品ID查询
|
| | | TLJBuyGoods tljBuyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(auctionId,
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | String appKey = tljBuyGoods.getAppKey();
|
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppKeyCache(appKey);
|
| | | if (config == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "生成推广链接失败"));
|
| | | return;
|
| | | }
|
| | | TaoKeAppInfo app = new TaoKeAppInfo(config.getAppKey(), config.getAppSecret(), config.getDefaultPid());
|
| | | taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuyWithOutFanLi(uid, auctionId, app);
|
| | | } catch (ShareGoodsException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | return;
|
| | |
| | | @RequestMapping(value = "getWebConfig", method = RequestMethod.POST)
|
| | | public void getWebConfig(AcceptData acceptData, String url, PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | if (url != null && (url.contains("s.click") || url.contains("taobao.com") || url.contains("tmall.com")
|
| | |
|
| | | if (url != null && url.contains("ifeeds.tmall.com/article.html?")) {
|
| | | data.put("baichuan", true);
|
| | | data.put("goodsDetail", false);
|
| | | } else if (url != null && (url.contains("s.click") || url.contains("taobao.com") || url.contains("tmall.com")
|
| | | || url.contains("m.tb.cn"))) {
|
| | | data.put("baichuan", true);// 采用阿里百川的方式加载webview
|
| | | data.put("goodsDetail", true);// 需要拦截商品详情
|
| | |
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | |
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | /**
|
| | | * 拉取备选商品
|
| | |
| | | int totalHongBaoCount = 2000 + (int) (Math.random() * 8000);
|
| | | int leftHongBaoCount = 200 + (int) (Math.random() * 2000);
|
| | | tljBuyGoodsService.addTLJBuyGoods(
|
| | | new TLJBuyGoods(null, day, new Date(), goods, totalHongBaoCount, leftHongBaoCount),
|
| | | TaoBaoConstant.ownBuyApp);
|
| | | new TLJBuyGoods(null, day, new Date(), goods, totalHongBaoCount, leftHongBaoCount));
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // 最多30个商品
|
| | | List<TLJBuyGoods> listGoods = tljBuyGoodsService.listByDay(day, 30);
|
| | | List<TLJBuyGoods> listGoods = new ArrayList<>();
|
| | | List<TaoBaoUnionConfig> coinfigList = taoBaoUnionConfigService
|
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
|
| | | for (TaoBaoUnionConfig app : coinfigList) {
|
| | | List<TLJBuyGoods> list = tljBuyGoodsService.listByDay(app.getAppKey(), day, 30);
|
| | | if (list != null && list.size() > 0) {
|
| | | listGoods.addAll(list);
|
| | | }
|
| | | }
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | for (TLJBuyGoods sh : listGoods) {
|
| | | TaoBaoGoodsBriefExtra item = TaoBaoUtil.getTaoBaoGoodsBriefExtra(sh.getGoods(),
|
| | |
| | | int updateByPrimaryKeySelective(TaoBaoUnionConfig record); |
| | | |
| | | int updateByPrimaryKey(TaoBaoUnionConfig record); |
| | | //根据appkey查询 |
| | | TaoBaoUnionConfig selectByAppKey(String appKey); |
| | | |
| | | |
| | | } |
| | |
| | | @Repository
|
| | | public class TLJBuyGoodsDao extends MongodbBaseDao<TLJBuyGoods> {
|
| | |
|
| | |
|
| | | public List<TLJBuyGoods> listByDayOrderByUpdateTime(String day, int page, int pageSize) {
|
| | | public List<TLJBuyGoods> listByDayOrderByUpdateTime(String appKey, String day, int page, int pageSize) {
|
| | | Query query = new Query();
|
| | | Criteria ca = Criteria.where("day").is(day);
|
| | | if (appKey != null)
|
| | | ca = ca.and("appKey").is(appKey);
|
| | | query.addCriteria(ca);
|
| | | query.limit(pageSize);
|
| | | query.skip((page - 1) * pageSize).with(new Sort(Sort.Direction.DESC, "updateTime"));
|
| | | return mongoTemplate.find(query, TLJBuyGoods.class);
|
| | | }
|
| | |
|
| | | public long countByDayAndAppKey(String appKey, String day) {
|
| | | Query query = new Query();
|
| | | Criteria ca = Criteria.where("day").is(day);
|
| | | if (appKey != null)
|
| | | ca = ca.and("appKey").is(appKey);
|
| | | query.addCriteria(ca);
|
| | | return mongoTemplate.count(query, TLJBuyGoods.class);
|
| | | }
|
| | |
|
| | | public void deleteByGoodsId(Long goodsId) {
|
| | | Query query = new Query();
|
| | | Criteria ca = Criteria.where("goods.auctionId").is(goodsId);
|
| | |
| | | public final static int TYPE_ANDROID = 1;
|
| | | public final static int TYPE_IOS = 2;
|
| | | public final static int TYPE_SHARE = 0;
|
| | | public final static int TYPE_TLJ_BUY = 3;// 自购立减淘礼金
|
| | |
|
| | | public final static int STATE_VALID = 0;// 正常
|
| | | public final static int STATE_NOVALID = 1;// 不正常
|
| | |
|
| | | @Column(name = "tc_id")
|
| | | private Long id;
|
| | | @Column(name = "tc_account")
|
| | |
| | | private String appName;
|
| | | @Column(name = "tc_type")
|
| | | private Integer type;
|
| | | @Column(name = "tc_state")
|
| | | private Integer state;
|
| | | @Column(name = "tc_state_desc")
|
| | | private String stateDesc;
|
| | |
|
| | | public Integer getState() {
|
| | | return state;
|
| | | }
|
| | |
|
| | | public void setState(Integer state) {
|
| | | this.state = state;
|
| | | }
|
| | |
|
| | | public String getStateDesc() {
|
| | | return stateDesc;
|
| | | }
|
| | |
|
| | | public void setStateDesc(String stateDesc) {
|
| | | this.stateDesc = stateDesc;
|
| | | }
|
| | |
|
| | | public TaoBaoUnionConfig() {
|
| | |
|
| | |
| | | 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.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinReportService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | /**
|
| | | * 更新报告
|
| | |
| | | return;
|
| | | LogHelper.test("验证自购立减商品");
|
| | | String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
|
| | | List<TLJBuyGoods> list = tljBuyGoodsService.listByDay(day, 15);
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
|
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
|
| | | for (TaoBaoUnionConfig app : configList) {
|
| | | List<TLJBuyGoods> list = tljBuyGoodsService.listByDay(app.getAppKey(), day, 15);// 获取最多15个商品
|
| | | int count = 0;
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (count >= 10)
|
| | | break;
|
| | | boolean success = shareHotGoodsService.verifyCanCreateTLJ(list.get(i).getGoods().getAuctionId(),
|
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
|
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
|
| | | new TaoKeAppInfo(app.getAppKey(), app.getAppSecret(), app.getDefaultPid()));
|
| | | if (success) {
|
| | | count++; |
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | if (goods != null && goods.getCouponAmount() != null
|
| | | && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
|
| | |
|
| | | if (TaoBaoUtil.getAfterUseCouplePrice(goods).multiply(goods.getTkRate())
|
| | | .compareTo(new BigDecimal("143")) >= 0) {
|
| | | goods = daTaoKeGoodsDetailService.filterTaoBaoGoods(goods);
|
| | | int totalHongBaoCount = 2000 + (int) (Math.random() * 8000);
|
| | | int leftHongBaoCount = 200 + (int) (Math.random() * 2000);
|
| | | tljBuyGoodsService.addTLJBuyGoods(
|
| | | new TLJBuyGoods(null, day, new Date(), goods, totalHongBaoCount, leftHongBaoCount),
|
| | | TaoBaoConstant.ownBuyApp);
|
| | | new TLJBuyGoods(null, day, new Date(), goods, totalHongBaoCount, leftHongBaoCount));
|
| | | } |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 每天晚上11点50添加淘礼金1个商品,用于兼容Android前端没有商品不显示banner的问题
|
| | | */
|
| | | @Scheduled(cron = "0 50 23 * * ? ")
|
| | | public void autoAddTLJBuyGoods() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | String day = TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd");
|
| | | List<TaoBaoGoodsBrief> list = tljBuyGoodsService.listPreGoods(1);
|
| | | Collections.shuffle(list);
|
| | | if (list.size() > 0)
|
| | | list = list.subList(0, 1);
|
| | | addTLJBuyGoods(list, day);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
|
| | | List<TaoBaoGoodsBrief> list = tljBuyGoodsService.listPreGoods(1);
|
| | | Collections.shuffle(list);
|
| | | if (list.size() > 20)
|
| | | list = list.subList(0, 20);
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
|
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
|
| | |
|
| | | if (list.size() > 12 * configList.size())
|
| | | list = list.subList(0, 12 * configList.size());
|
| | | addTLJBuyGoods(list, day);
|
| | | }
|
| | |
|
| | |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.cache.HttpGoodsCacheManager;
|
| | |
|
| | | /**
|
| | | * 淘宝商品更细
|
| | |
| | |
|
| | | @Resource
|
| | | private BrandClassShopGoodsService brandClassShopGoodsService;
|
| | |
|
| | | @Resource
|
| | | private HttpGoodsCacheManager httpGoodsCacheManager;
|
| | |
|
| | | // 动态商品更新 ,1个小时更新
|
| | | @Scheduled(cron = "0 0 */1 * * ?")
|
| | |
| | | return;
|
| | | brandClassShopGoodsService.startUpdateGoods();
|
| | | }
|
| | |
|
| | | // 每天凌晨4点模拟请求
|
| | | @Scheduled(cron = "0 0 4 * * ? ")
|
| | | public void simulateRequest() {
|
| | | httpGoodsCacheManager.requestHomeRecommend();
|
| | | httpGoodsCacheManager.requestClassGoods();
|
| | | httpGoodsCacheManager.requestBrandGoods();
|
| | | httpGoodsCacheManager.requestDynamic();
|
| | | httpGoodsCacheManager.requestCommonTemplate();
|
| | | }
|
| | | }
|
| | |
| | | <result column="tc_beizhu" property="beizhu" jdbcType="VARCHAR" /> |
| | | <result column="tc_appname" property="appName" jdbcType="VARCHAR" /> |
| | | <result column="tc_type" property="type" jdbcType="INTEGER" /> |
| | | <result column="tc_state" property="state" jdbcType="INTEGER" /> |
| | | <result column="tc_state_desc" property="stateDesc" jdbcType="VARCHAR" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">tc_id,tc_account,tc_account_id,tc_appkey,tc_appsecret,tc_appid,tc_default_pid,tc_beizhu,tc_appname,tc_type |
| | | <sql id="Base_Column_List">tc_id,tc_account,tc_account_id,tc_appkey,tc_appsecret,tc_appid,tc_default_pid,tc_beizhu,tc_appname,tc_type,tc_state,tc_state_desc |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_union_config where tc_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByType" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Integer"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_union_config where tc_type = #{type,jdbcType=INTEGER} |
| | | from yeshi_ec_taobao_union_config where tc_type = |
| | | #{type,jdbcType=INTEGER} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByAppId" resultMap="BaseResultMap" |
| | | parameterType="java.lang.String"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_union_config where tc_appid = #{0} |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="selectByAppKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.String"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_union_config where tc_appkey = #{0} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_taobao_union_config where tc_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_taobao_union_config |
| | | (tc_id,tc_account,tc_account_id,tc_appkey,tc_appsecret,tc_appid,tc_default_pid,tc_beizhu,tc_appname,tc_type) |
| | | (tc_id,tc_account,tc_account_id,tc_appkey,tc_appsecret,tc_appid,tc_default_pid,tc_beizhu,tc_appname,tc_type,tc_state,tc_state_desc) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{account,jdbcType=VARCHAR},#{accountId,jdbcType=VARCHAR},#{appKey,jdbcType=VARCHAR},#{appSecret,jdbcType=VARCHAR},#{appId,jdbcType=VARCHAR},#{defaultPid,jdbcType=VARCHAR},#{beizhu,jdbcType=VARCHAR},#{appName,jdbcType=VARCHAR},#{type,jdbcType=INTEGER}) |
| | | (#{id,jdbcType=BIGINT},#{account,jdbcType=VARCHAR},#{accountId,jdbcType=VARCHAR},#{appKey,jdbcType=VARCHAR},#{appSecret,jdbcType=VARCHAR},#{appId,jdbcType=VARCHAR},#{defaultPid,jdbcType=VARCHAR},#{beizhu,jdbcType=VARCHAR},#{appName,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{stateDesc,jdbcType=VARCHAR}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | |
| | | <if test="beizhu != null">tc_beizhu,</if> |
| | | <if test="appName != null">tc_appname,</if> |
| | | <if test="type != null">tc_type,</if> |
| | | <if test="state != null">tc_state,</if> |
| | | <if test="stateDesc != null">tc_state_desc,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | <if test="beizhu != null">#{beizhu,jdbcType=VARCHAR},</if> |
| | | <if test="appName != null">#{appName,jdbcType=VARCHAR},</if> |
| | | <if test="type != null">#{type,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER}</if> |
| | | <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig">update |
| | |
| | | #{appId,jdbcType=VARCHAR},tc_default_pid = |
| | | #{defaultPid,jdbcType=VARCHAR},tc_beizhu = |
| | | #{beizhu,jdbcType=VARCHAR},tc_appname = |
| | | #{appName,jdbcType=VARCHAR},tc_type = #{type,jdbcType=INTEGER} where |
| | | tc_id = #{id,jdbcType=BIGINT} |
| | | #{appName,jdbcType=VARCHAR},tc_type = #{type,jdbcType=INTEGER} |
| | | ,tc_state =#{state,jdbcType=INTEGER} ,tc_state_desc |
| | | =#{stateDesc,jdbcType=VARCHAR} where tc_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig"> |
| | | update yeshi_ec_taobao_union_config |
| | |
| | | <if test="beizhu != null">tc_beizhu=#{beizhu,jdbcType=VARCHAR},</if> |
| | | <if test="appName != null">tc_appname=#{appName,jdbcType=VARCHAR},</if> |
| | | <if test="type != null">tc_type=#{type,jdbcType=INTEGER},</if> |
| | | <if test="state !=null">tc_state =#{state,jdbcType=INTEGER},</if> |
| | | <if test="stateDesc !=null">tc_state_desc =#{stateDesc,jdbcType=VARCHAR},</if> |
| | | </set> |
| | | where tc_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.impl.monitor.BusinessEmergent110ServiceImpl;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.UserTLJBuyHistoryService;
|
| | |
| | |
|
| | | @Resource
|
| | | private TLJBuyGoodsService tljBuyGoodsService;
|
| | |
|
| | | @Resource
|
| | | private BusinessEmergent110Service businessEmergent110Service;
|
| | |
|
| | | @Override
|
| | | public void addShareGoodsHistory(UserShareGoodsHistory history) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoLiJinLinkForBuyWithOutFanLi(Long uid, Long auctionId) throws ShareGoodsException {
|
| | | public TaoBaoLink getTaoLiJinLinkForBuyWithOutFanLi(Long uid, Long auctionId, TaoKeAppInfo app)
|
| | | throws ShareGoodsException {
|
| | | if (uid == null || uid <= 0) {
|
| | | throw new ShareGoodsException(1, "用户ID不能为空");
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | BigDecimal perface = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70));
|
| | | TaoKeAppInfo app = TaoBaoConstant.ownBuyApp;
|
| | | TaoLiJinDTO taoLiJinDTO = null;
|
| | | try {
|
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "自购立减", perface, 1, new Date(currentTime), sendEndTime,
|
| | | new Date(currentTime), sendEndTime, app);
|
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "自购立减", perface, 1,
|
| | | new Date(currentTime - 1000 * 60 * 10L), sendEndTime, new Date(currentTime - 1000 * 60 * 10L),
|
| | | sendEndTime, app);
|
| | | } catch (TaoKeApiException e) {
|
| | | if (e.getCode() == TaoKeApiException.CODE_TLJ_NO_MONEY) {// 资金不足
|
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppKeyCache(app.getAppKey());
|
| | | businessEmergent110Service.tljNoMoney(config.getAccount());
|
| | | }
|
| | | LogHelper.errorDetailInfo(e, e.getMessage(), null);
|
| | | throw new ShareGoodsException(5, "生成推广链接失败");
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
|
| | | import com.yeshi.fanli.util.EmergencyUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class BusinessEmergent110ServiceImpl implements BusinessEmergent110Service {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void tljNoMoney(String account) {
|
| | | String key = "monitor-error-tlj-no-money-" + StringUtil.Md5(account);
|
| | | EmergencyUtil.baoJin(key, String.format("淘礼金账户余额不足【账号:%s】", account), phones);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
| | | import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | @Override
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods, TaoKeAppInfo taoKeAppInfo) {
|
| | | if (goods == null || StringUtil.isNullOrEmpty(goods.getDay()) || goods.getGoods() == null)
|
| | |
| | | tljBuyGoodsDao.save(goods);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
|
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
|
| | |
|
| | | for (TaoBaoUnionConfig app : configList) {
|
| | | long count = tljBuyGoodsDao.countByDayAndAppKey(app.getAppKey(), goods.getDay());
|
| | | if (count < 12) {
|
| | | addTLJBuyGoods(goods, new TaoKeAppInfo(app.getAppKey(), app.getAppSecret(), app.getDefaultPid()));
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Cacheable(value = "commonContentCache", key = "'tljBuy-listByDay'+#day")
|
| | | @Override
|
| | | public List<TLJBuyGoods> listByDay(String day) {
|
| | | List<TLJBuyGoods> list = listByDay(day, 10);
|
| | | // if (list.size() <= 10)
|
| | | // return list;
|
| | | // else {
|
| | | // List<TLJBuyGoods> newList = new ArrayList<>();
|
| | | // for (int i = 0; i < 10; i++) {
|
| | | // newList.add(list.get(i));
|
| | | // }
|
| | | // return newList;
|
| | | // }
|
| | | |
| | | return list;
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
|
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
|
| | | List<TLJBuyGoods> goodsList = new ArrayList<>();
|
| | | for (TaoBaoUnionConfig appInfo : configList) {
|
| | | List<TLJBuyGoods> list = listByDay(appInfo.getAppKey(), day, 10);
|
| | | if (list != null && list.size() > 0)
|
| | | goodsList.addAll(list);
|
| | | }
|
| | | Collections.shuffle(goodsList);
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TLJBuyGoods> listByDay(String day, int count) {
|
| | | List<TLJBuyGoods> list = tljBuyGoodsDao.listByDayOrderByUpdateTime(day, 1, count);
|
| | | public List<TLJBuyGoods> listByDay(String appKey, String day, int count) {
|
| | | List<TLJBuyGoods> list = tljBuyGoodsDao.listByDayOrderByUpdateTime(appKey, day, 1, count);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | if (list != null) {
|
| | | for (TLJBuyGoods shg : list)
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean verifyCanCreateTLJ(Long auctionId) {
|
| | | public boolean verifyCanCreateTLJ(Long auctionId,TaoKeAppInfo app) {
|
| | | TaoLiJinDTO taoLiJinDTO = null;
|
| | | try {
|
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "淘礼金验证", new BigDecimal("1.00"), 1, new Date(),
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), new Date(),
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), TaoBaoConstant.ownBuyApp);
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), app);
|
| | | } catch (TaoKeApiException e) {
|
| | | if (e.getCode() == TaoKeApiException.CODE_TLJ_FORBIDDEN) {
|
| | | // 该商品不支持创建淘礼金红包
|
| | |
| | | public TLJBuyGoods selectByAuctionIdAndDay(Long auctionId, String day) {
|
| | | return tljBuyGoodsDao.selectByAuctionIdAndDay(auctionId, day);
|
| | | }
|
| | |
|
| | | } |
| | |
| | | public List<TaoBaoUnionConfig> getConfigByType(int type) {
|
| | | return taoBaoUnionConfigMapper.selectByType(type);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "configCache", key = "'getConfigByType-'+#type")
|
| | | @Override
|
| | | public List<TaoBaoUnionConfig> getConfigByTypeCache(int type) {
|
| | |
| | | public TaoBaoUnionConfig getConfigByAppId(String appId) {
|
| | | return taoBaoUnionConfigMapper.selectByAppId(appId);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "configCache", key = "'getConfigByAppId-'+#appId")
|
| | | @Override
|
| | | public TaoBaoUnionConfig getConfigByAppIdCache(String appId) {
|
| | | return getConfigByAppId(appId);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "configCache", key = "'getConfigByAppKeyCache-'+#appKey")
|
| | | @Override
|
| | | public TaoBaoUnionConfig getConfigByAppKeyCache(String appKey) {
|
| | | return taoBaoUnionConfigMapper.selectByAppKey(appKey);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.ShareGoodsException;
|
| | |
|
| | | public interface ShareGoodsService {
|
| | |
| | | * @return
|
| | | * @throws ShareGoodsException
|
| | | */
|
| | | public TaoBaoLink getTaoLiJinLinkForBuyWithOutFanLi(Long uid, Long auctionId) throws ShareGoodsException;
|
| | | public TaoBaoLink getTaoLiJinLinkForBuyWithOutFanLi(Long uid, Long auctionId,TaoKeAppInfo app) throws ShareGoodsException;
|
| | |
|
| | | }
|
| | |
| | | * @param identifyCode
|
| | | */
|
| | | public void taoBaoAPPKeyLimitError(String appKey, String identifyCode);
|
| | | |
| | | |
| | | /**
|
| | | * 淘礼金账户资金不足
|
| | | * @param account
|
| | | */
|
| | | public void tljNoMoney(String account);
|
| | |
|
| | | }
|
| | |
| | | public void addTLJBuyGoods(TLJBuyGoods goods,TaoKeAppInfo taoKeAppInfo);
|
| | |
|
| | | /**
|
| | | * 添加自购立减商品
|
| | | * |
| | | * @param goods
|
| | | * @param taoKeAppInfo
|
| | | */
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods);
|
| | |
|
| | | /**
|
| | | * 根据日期查找
|
| | | *
|
| | | * @param day
|
| | |
| | | */
|
| | | public List<TLJBuyGoods> listByDay(String day);
|
| | |
|
| | | public List<TLJBuyGoods> listByDay(String day, int count);
|
| | | /**
|
| | | * 根据appkey与日期查找
|
| | | * |
| | | * @param appKey
|
| | | * @param day
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<TLJBuyGoods> listByDay(String appKey, String day, int count);
|
| | |
|
| | | /**
|
| | | * 根据主键删除
|
| | |
| | | * @param auctionId
|
| | | * @return
|
| | | */
|
| | | public boolean verifyCanCreateTLJ(Long auctionId);
|
| | | public boolean verifyCanCreateTLJ(Long auctionId,TaoKeAppInfo app);
|
| | |
|
| | | /**
|
| | | * 更新商品
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | |
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | |
|
| | | public interface TaoBaoUnionConfigService {
|
| | |
| | |
|
| | | public TaoBaoUnionConfig getConfigByAppIdCache(String appId);
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 根据appKey查询
|
| | | * @param appKey
|
| | | * @return
|
| | | */
|
| | | public TaoBaoUnionConfig getConfigByAppKeyCache(String appKey);
|
| | | }
|
| | |
| | | // 淘宝将渠道ID处理成会员ID的pid
|
| | | public static final String TAOBAO_RELATION_AS_SPECIAL_PID = "mm_124933865_56750082_18689550042";
|
| | |
|
| | | |
| | | //淘礼金渠道ID
|
| | | public static final String TAOBAO_TLJ_RELATION_PID_DEFAULT = "mm_124933865_56750082_19507100253";
|
| | | //淘礼金渠道会员
|
| | | public static final String TAOBAO_TLJ_RELATION_AS_SPECIAL_PID = "mm_124933865_56750082_19508150186";
|
| | | //淘礼金会员
|
| | | public static final String TAOBAO_TLJ_SPECIAL_PID_DEFAULT = "mm_124933865_56750082_19509300170";
|
| | | |
| | |
|
| | | // 自购立减PID
|
| | | public static TaoKeAppInfo ownBuyApp = new TaoKeAppInfo("24937414", "0457746e24622a6c8c7924288550af5f",
|
| | | "mm_133239778_45820106_699710614");
|
| | | |
| | | public static TaoKeAppInfo[] ownBuyApps=new TaoKeAppInfo[]{
|
| | | new TaoKeAppInfo("27759529", "2c0ecd37cf53eff0439a386c4eba2772","mm_472550068_628200329_109272850337"),
|
| | | new TaoKeAppInfo("27743325", "527a23554f71557d7b786bc479fcd5fe","mm_472720008_629400173_109272950312"),
|
| | | new TaoKeAppInfo("27770097", "fd896b718e2b0a833f0b7524cb83d092","mm_474720121_631000170_109273750171"),
|
| | | new TaoKeAppInfo("27762518", "2b2077798b7f8c5c94d337ac69d86a83","mm_474970057_635750171_109272950316"),
|
| | | new TaoKeAppInfo("27757101", "47921196e59a7999637269f486865096","mm_476760152_635550267_109272750381"),
|
| | | };
|
| | |
|
| | | public static BigDecimal OWN_BUY_WITHOUT_FANLI_RATE = new BigDecimal(70);// 自购立减的比例
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.cache;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.common.CommonContentNav;
|
| | | import com.yeshi.fanli.dto.common.CommonContentTypeEnum;
|
| | | import com.yeshi.fanli.entity.brand.BrandClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsClassService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
| | |
|
| | | /**
|
| | | * 采用http请求触发商品缓存
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class HttpGoodsCacheManager {
|
| | |
|
| | | @Resource
|
| | | private CommonTemplateContentService commonTemplateContentService;
|
| | |
|
| | | @Resource
|
| | | private GoodsClassService goodsClassService;
|
| | |
|
| | | @Resource
|
| | | private BrandClassService brandClassService;
|
| | |
|
| | | private static String getSign(Map<String, String> params) {
|
| | | List<String> list = new ArrayList<>();
|
| | | Iterator<String> its = params.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | Object value = params.get(key);
|
| | | list.add(key + "=" + value.toString());
|
| | | }
|
| | | Collections.sort(list);
|
| | | String str = "";
|
| | | for (String st : list) {
|
| | | str += st + "&";
|
| | | }
|
| | | String sign = null;
|
| | |
|
| | | sign = StringUtil.Md5(str + Constant.systemCommonConfig.getSignKey());
|
| | | return sign;
|
| | | }
|
| | |
|
| | | private void request(String url, Map<String, String> par) {
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("packages", "com.yeshi.ec.rebate");
|
| | | params.put("Version", "46");
|
| | | params.put("appkey", "24587154");
|
| | | params.put("platform", "android");
|
| | | params.put("apiversion", "1");
|
| | | params.put("channel", "GuanWang");
|
| | | params.put("imei", "862977040115210");
|
| | | params.put("osVersion", "8.0.0");
|
| | | params.put("network", "WIFI");
|
| | | params.put("deviceType", "LND-AL30");
|
| | | params.put("time", System.currentTimeMillis() + "");
|
| | | params.put("Device", "da105e2c-a7e8-3739-8fb8-4100da3c3aac");
|
| | |
|
| | | if (par != null) {
|
| | | for (Iterator<String> its = par.keySet().iterator(); its.hasNext();) {
|
| | | String key = its.next();
|
| | | params.put(key, par.get(key));
|
| | | }
|
| | | }
|
| | | params.put("time", System.currentTimeMillis() + "");
|
| | | params.put("sign", getSign(params));
|
| | | String result = HttpUtil.post(url, params, null);
|
| | | System.out.println(result);
|
| | | }
|
| | |
|
| | | // 触发首页的商品更新
|
| | | public void requestHomeRecommend() {
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("goodsType", 1 + "");
|
| | | for (int p = 1; p < 5; p++) {
|
| | | params.put("page", p + "");
|
| | | request("http://api.flqapp.com/fanli/api/v2/recommend/getGoodList", params);
|
| | | }
|
| | | }
|
| | |
|
| | | // 触发通用模板
|
| | | public void requestCommonTemplate() {
|
| | | CommonContentTypeEnum[] types = CommonContentTypeEnum.values();
|
| | | for (int p = 1; p < 3; p++) {
|
| | | for (CommonContentTypeEnum type : types) {
|
| | | List<CommonContentNav> navList = commonTemplateContentService.getNavList(type);
|
| | | if (navList != null && navList.size() > 0)
|
| | | for (CommonContentNav nav : navList) {
|
| | | commonTemplateContentService.getContentList(type, nav.getCid(), p, 50);
|
| | | }
|
| | | else {
|
| | | commonTemplateContentService.getContentList(type, null, p, 50);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 触发分类商品
|
| | | public void requestClassGoods() {
|
| | | Map<String, String> params = new HashMap<>();
|
| | | List<GoodsClass> classList = goodsClassService.getEffectiveClassCache();
|
| | | for (int p = 1; p < 3; p++) {
|
| | | params.put("page", p + "");
|
| | | for (GoodsClass gc : classList)
|
| | | params.put("gcid", gc.getId() + "");
|
| | | request("http://api.flqapp.com/fanli/api/v2/class/getClassGoods", params);
|
| | | }
|
| | | }
|
| | |
|
| | | // 触发动态
|
| | | public void requestDynamic() {
|
| | | // 热销
|
| | | List<GoodsClass> list = new ArrayList<GoodsClass>();
|
| | | list.add(new GoodsClass(0L, "今日单品"));
|
| | | list.addAll(DaTaoKeUtil.goodsClasses);
|
| | |
|
| | | for (int p = 1; p < 5; p++) {
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("cid", 1 + "");
|
| | | params.put("page", p + "");
|
| | | for (GoodsClass gc : list) {
|
| | | params.put("subId", gc.getId() + "");
|
| | | request("http://api.flqapp.com/fanli/api/v2/dynamic/getList", params);
|
| | | }
|
| | | // 推荐
|
| | | params = new HashMap<>();
|
| | | params.put("cid", 2 + "");
|
| | | params.put("page", p + "");
|
| | | request("http://api.flqapp.com/fanli/api/v2/dynamic/getList", params);
|
| | |
|
| | | // 好店
|
| | | params = new HashMap<>();
|
| | | params.put("cid", 3 + "");
|
| | | params.put("page", p + "");
|
| | | request("http://api.flqapp.com/fanli/api/v2/dynamic/getList", params);
|
| | | }
|
| | | }
|
| | |
|
| | | // 触发品牌商品列表
|
| | | public void requestBrandGoods() {
|
| | | List<BrandClass> list = brandClassService.listBrandClassEffectiveCache();
|
| | | list.add(new BrandClass(0L));
|
| | | list.addAll(list);
|
| | | for (int p = 1; p < 5; p++) {
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("page", p + "");
|
| | | for (BrandClass gc : list) {
|
| | | params.put("cid", gc.getId() + "");
|
| | | request("http://api.flqapp.com/fanli/api/v2/brand/getShopList", params);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|