| | |
| | | import com.yeshi.fanli.entity.dynamic.GoodsEvaluate; |
| | | import com.yeshi.fanli.entity.dynamic.GoodsEvaluate.EvaluateEnum; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.TimeUtil; |
| | | |
| | | @Repository |
| | | public class GoodsEvaluateDao { |
| | |
| | | list.add(Criteria.where("state").is(1)); |
| | | list.add(Criteria.where("goods.goodsId").is(goodsId)); |
| | | list.add(Criteria.where("goods.goodsType").is(goodsType)); |
| | | |
| | | // 限制时间内 |
| | | list.add(Criteria.where("startTime").gte(limitTime)); |
| | | |
| | |
| | | return mongoTemplate.find(query, GoodsEvaluate.class); |
| | | } |
| | | |
| | | |
| | | |
| | | public List<GoodsEvaluate> queryValidZeroPoint(int start, int count) { |
| | | // 今日22点发圈 :0点下单 |
| | | Date now = new Date(); |
| | | Date startTime = TimeUtil.parseYYYYMMDD_HHMM(TimeUtil.getGernalTime(now) + " 22:00"); |
| | | |
| | | Query query = new Query(); |
| | | List<Criteria> list = new ArrayList<Criteria>(); |
| | | |
| | | list.add(Criteria.where("zeroPoint").is(1)); |
| | | list.add(Criteria.where("dynamicType").is(1)); |
| | | list.add(Criteria.where("state").is(1)); |
| | | list.add(Criteria.where("startTime").is(startTime)); |
| | | list.add(new Criteria().orOperator(Criteria.where("type").is("single"), |
| | | new Criteria().andOperator(Criteria.where("type").is("activity")))); |
| | | |
| | | if (list.size() > 0) { |
| | | Criteria[] cas = new Criteria[list.size()]; |
| | | for (int i = 0; i < list.size(); i++) |
| | | cas[i] = list.get(i); |
| | | query.addCriteria(new Criteria().andOperator(cas)); |
| | | } |
| | | query.skip(start).limit(count); |
| | | return mongoTemplate.find(query, GoodsEvaluate.class); |
| | | } |
| | | |
| | | } |
| | |
| | | public final static int LINE_NUM_ONE = 1; |
| | | public final static int LINE_NUM_TWO = 2; |
| | | public final static int LINE_NUM_THREE = 3; |
| | | |
| | | |
| | | public enum EvaluateEnum { |
| | | single("单品"), multiple("多品"), activity("活动"); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Id |
| | | @Expose |
| | | @Field("_id") |
| | |
| | | // 类型 |
| | | @Field("type") |
| | | private EvaluateEnum type; |
| | | |
| | | |
| | | @Expose |
| | | @Field("user") |
| | | private ActivityUser user; // 发布用户 |
| | |
| | | @Expose |
| | | @Field("shareNum") |
| | | private Integer shareNum; // 分享次数 |
| | | |
| | | // 图片一行显示: 0无图 1一张 2两张 3张 |
| | | |
| | | // 图片一行显示: 0无图 1一张 2两张 3张 |
| | | @Expose |
| | | @Field("lineNum") |
| | | private Integer lineNum; |
| | | |
| | | |
| | | @Expose |
| | | @Field("imgList") |
| | | private List<ImgInfo> imgList = new ArrayList<ImgInfo>(); // 图片信息 |
| | | private List<ImgInfo> imgList = new ArrayList<ImgInfo>(); // 图片信息 |
| | | |
| | | |
| | | @Field("shareNumReal") |
| | | private Integer shareNumReal; // 分享次数真实 |
| | | |
| | |
| | | @Expose |
| | | @Field("comments") |
| | | private List<CommentInfo> comments = new ArrayList<CommentInfo>(); // 评论信息 |
| | | |
| | | |
| | | @Expose |
| | | @Field("publishTime") |
| | | private Date publishTime; // 发布时间 |
| | | |
| | | |
| | | @Field("state") |
| | | private Integer state; // 状态 |
| | | |
| | | |
| | | @Field("weight") |
| | | private Double weight; // 权重 |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Field("startTime") |
| | | private Date startTime; // 开始时间 |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Field("endTime") |
| | | private Date endTime; // 结束时间 |
| | | |
| | | |
| | | @Field("createTime") |
| | | private Date createTime; // 创建时间 |
| | | |
| | | @Field("updateTime") |
| | | private Date updateTime; // 更新时间 |
| | | |
| | | |
| | | @Field("mainPicNum") |
| | | private Integer mainPicNum; // 图片主图 |
| | | |
| | | |
| | | @Field("dynamicType") |
| | | private Integer dynamicType; // 1发圈 2素材 |
| | | |
| | | |
| | | @Field("zeroPoint") |
| | | private Integer zeroPoint; // 是否0点活动-10点进行发圈 1-是 |
| | | |
| | | @Expose |
| | | @Field("jumpLink") |
| | | private String jumpLink; |
| | | |
| | | |
| | | |
| | | // 是否云发单 |
| | | @Expose |
| | | private boolean cloud; |
| | | |
| | | |
| | | |
| | | |
| | | private String startTimeChar; |
| | | private String endTimeChar; |
| | | |
| | | |
| | | // 备注 |
| | | private String remarks; |
| | | |
| | | |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | |
| | | public void setCloud(boolean cloud) { |
| | | this.cloud = cloud; |
| | | } |
| | | |
| | | |
| | | public Integer getZeroPoint() { |
| | | return zeroPoint; |
| | | } |
| | | |
| | | public void setZeroPoint(Integer zeroPoint) { |
| | | this.zeroPoint = zeroPoint; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.yeshi.fanli.entity.dynamic.WXMPDynamicInfo;
|
| | | import com.yeshi.fanli.entity.goods.jd.NYouHuiGoods;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
|
| | | import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException;
|
| | |
| | | List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
|
| | | ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
|
| | |
|
| | | goodsEvaluateService.addGoodsEvaluate2(TaoBaoGoodsFactory.create(hdkGoods), pics, user, showtitle, null);
|
| | | addResult = true;
|
| | | break;
|
| | | int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoGoodsFactory.create(hdkGoods), pics, user, showtitle);
|
| | | if (addProcess == 0) {
|
| | | addResult = true;
|
| | | break;
|
| | | }
|
| | | } catch (GoodsEvaluateException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | |
| | | user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
|
| | | }
|
| | |
|
| | | goodsEvaluateService.addGoodsEvaluate2(TaoBaoUtil.convert(tkGoods), null, user, showtitle, null);
|
| | | addResult = true;
|
| | | break;
|
| | | int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoUtil.convert(tkGoods), null, user, showtitle);
|
| | | if (addProcess == 0) {
|
| | | addResult = true;
|
| | | break;
|
| | | }
|
| | | } catch (GoodsEvaluateException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | result = DaTaoKeApiUtil.listAll(result.getPageId());
|
| | | result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
|
| | | } catch (Exception e) {
|
| | | result = DaTaoKeApiUtil.listAll(result.getPageId());
|
| | | result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
|
| | | }
|
| | | try {
|
| | | Thread.sleep(10);
|
| | |
| | | * 定时检测是否存在新的发圈
|
| | | */
|
| | | @Scheduled(cron = "0 0/20 * * * ? ")
|
| | | public void dailyCount() {
|
| | | public void fixedTimeSend() {
|
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | |
| | | // 单品商品
|
| | | List<GoodsEvaluate> listGoods = goodsEvaluateService.queryValidSortASC(1, 5, EvaluateEnum.single, true);
|
| | | // 执行发单
|
| | | userCloudService.fixedTimeSend(listActivity, listGoods);
|
| | | userCloudService.fixedTimeSend(listActivity, listGoods, true);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 每日22点进行深夜发圈
|
| | | */
|
| | | @Scheduled(cron = "0 0 22 * * ? ")
|
| | | public void zeroPoint() {
|
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | |
| | | List<GoodsEvaluate> list = goodsEvaluateService.queryValidZeroPoint(1, 50);
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | // 执行发单
|
| | | userCloudService.fixedTimeSend(null, list, false);
|
| | | }
|
| | | |
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.dynamic.SimpleGoods; |
| | | import com.yeshi.fanli.entity.jd.JDGoods; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.entity.taobao.PidUser; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink; |
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2; |
| | |
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.TimeUtil; |
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil; |
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | |
| | | |
| | | |
| | | @Override |
| | | public List<GoodsEvaluate> queryValidZeroPoint(int start, int count) { |
| | | return goodsEvaluateDao.queryValidZeroPoint(start, count); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void saveComment(String pid, CommentInfo commentInfo) throws GoodsEvaluateException { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateDao.getById(pid); |
| | | if (goodsEvaluate == null) { |
| | |
| | | |
| | | |
| | | @Override |
| | | public void addGoodsEvaluate2(TaoBaoGoodsBrief goodsBrief, List<String> imgs, ActivityUser user, String title, String comment) throws GoodsEvaluateException { |
| | | public int addGoodsEvaluate(TaoBaoGoodsBrief goodsBrief, List<String> imgs, ActivityUser user, String title) throws GoodsEvaluateException { |
| | | if (goodsBrief == null || user == null || StringUtil.isNullOrEmpty(title)) { |
| | | throw new GoodsEvaluateException(1, "相关参数不能为空"); |
| | | } |
| | |
| | | lineNum = 3; |
| | | } |
| | | } |
| | | |
| | | |
| | | int result = 0; |
| | | int zeroPoint = 0; |
| | | // ★深夜大福利:先抢券,0点准时下单★ |
| | | // 含这种文本的定于每晚10点在动态-发圈 集中发,每晚10点在群发单中只发一条。 |
| | | Date startTime = new Date(); |
| | | if (!StringUtil.isNullOrEmpty(title) && title.contains("0点准时下单")) { |
| | | result = 1; |
| | | zeroPoint = 1; |
| | | startTime = TimeUtil.parseYYYYMMDD_HHMM(TimeUtil.getGernalTime(startTime) + " 22:00"); |
| | | } |
| | | |
| | | |
| | | GoodsEvaluate goodsEvaluate = new GoodsEvaluate(); |
| | | goodsEvaluate.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | goodsEvaluate.setUser(user); |
| | | goodsEvaluate.setTitle(getDescNew(title)); |
| | | goodsEvaluate.setState(1); |
| | | goodsEvaluate.setZeroPoint(zeroPoint); |
| | | goodsEvaluate.setDynamicType(1); |
| | | goodsEvaluate.setType(EvaluateEnum.single); |
| | | goodsEvaluate.setShareNum((int) (Math.random() * 5000) + 1000); |
| | | goodsEvaluate.setShareNumReal(0); |
| | | goodsEvaluate.setWeight(0.0); |
| | | goodsEvaluate.setStartTime(new Date()); |
| | | goodsEvaluate.setEndTime(DateUtil.plusDayDate(3, new Date())); |
| | | goodsEvaluate.setStartTime(startTime); |
| | | goodsEvaluate.setEndTime(DateUtil.plusDayDate(3, startTime)); |
| | | goodsEvaluate.setPublishTime(new Date()); |
| | | goodsEvaluate.setCreateTime(new Date()); |
| | | goodsEvaluate.setUpdateTime(new Date()); |
| | |
| | | goodsEvaluate.setImgList(imgList); |
| | | goodsEvaluate.setComments(commentsNew); |
| | | goodsEvaluateDao.save(goodsEvaluate); |
| | | |
| | | return result; |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods) {
|
| | | public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods, boolean timeLimit) {
|
| | | if (listGoods == null && listActivity == null)
|
| | | return;
|
| | | // 一个小时之前
|
| | |
| | | if (cloudManage == null || cloudManage.getOfficial() == null || !cloudManage.getOfficial()) {
|
| | | continue;
|
| | | }
|
| | | // 是否在一个小时内已发送过
|
| | | UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
|
| | | if (last != null)
|
| | | continue;
|
| | |
|
| | | |
| | | // 时间间隔:是否在一个小时内已发送过
|
| | | if (timeLimit) {
|
| | | UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
|
| | | if (last != null)
|
| | | continue;
|
| | | }
|
| | | |
| | | |
| | | String evaluateId = null;
|
| | | // 活动
|
| | | if (listActivity != null && listActivity.size() > 0) {
|
| | |
| | | public boolean addByDaTaoKeGoods(DaTaoKeDetailV2 daTaoKe); |
| | | |
| | | |
| | | public void addGoodsEvaluate2(TaoBaoGoodsBrief goodsBrief, List<String> imgs, ActivityUser user, String title, String comment) |
| | | public int addGoodsEvaluate(TaoBaoGoodsBrief goodsBrief, List<String> imgs, ActivityUser user, String title) |
| | | throws GoodsEvaluateException; |
| | | |
| | | public List<GoodsEvaluate> queryValidZeroPoint(int start, int count); |
| | | |
| | | } |
| | |
| | | * 定时发送云发单
|
| | | * @param id
|
| | | */
|
| | | public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods);
|
| | | public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods, boolean timeLimit);
|
| | |
|
| | | public List<UserCloud> query(int page, int count, String key, Integer state);
|
| | |
|
| | |
| | | String date = sdf.format(new Date(time));
|
| | | return date;
|
| | | }
|
| | | |
| | | public static String getGernalTime(Date date) {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | return sdf.format(date);
|
| | | }
|
| | |
|
| | |
|
| | | public static String getGernalTime(long time, String format) {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat(format);
|
| | |
| | | // 店铺
|
| | | goods.setShopTitle(hdkGoods.getShopname());
|
| | | if ("B".equalsIgnoreCase(hdkGoods.getShoptype()))
|
| | | goods.setUserType(0);
|
| | | goods.setUserType(1); // 天猫
|
| | | else
|
| | | goods.setUserType(1);
|
| | | goods.setUserType(0); // 淘宝
|
| | |
|
| | | return goods;
|
| | | }
|