From ec60e757d358636dcac1589c44a66f3e276fe58c Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期一, 29 六月 2020 14:41:42 +0800
Subject: [PATCH] 拉新

---
 fanli/src/main/java/com/yeshi/fanli/vo/user/PullNewRuleNumVO.java                              |   32 
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/FreeGoodsCouponServiceImpl.java         |   69 +
 fanli/src/main/java/com/yeshi/fanli/dto/pdd/PDDSearchRange.java                                |   48 +
 fanli/src/main/java/com/yeshi/fanli/entity/goods/PullNewGoods.java                             |  510 +++++++++++++
 fanli/src/main/java/com/yeshi/fanli/job/goods/FreeGoodsCouponJob.java                          |  397 ++++++++++
 fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java      |  170 +++
 fanli/src/main/java/com/yeshi/fanli/dto/taobao/haodanku/HDKSearchFilter.java                   |  142 +++
 fanli/src/main/java/com/yeshi/fanli/job/goods/PullNewGoodsJob.java                             |   73 +
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/PullNewGoodsServiceImpl.java            |   81 ++
 fanli/src/main/java/com/yeshi/fanli/job/RedPackJob.java                                        |   89 ++
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java        |  187 ++++
 fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java         |   27 
 fanli/src/main/java/com/yeshi/fanli/dao/goods/FreeGoodsCouponDao.java                          |   45 +
 utils/src/main/java/org/yeshi/utils/DateUtil.java                                              |   46 +
 fanli/src/main/java/com/yeshi/fanli/dto/user/PullNewRuleTerm.java                              |   33 
 fanli/src/main/resource/image/invite/pull_new.png                                              |    0 
 fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java |   41 
 fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCoupon.java                      |    1 
 fanli/src/main/java/com/yeshi/fanli/entity/goods/FreeGoodsCoupon.java                          |   83 ++
 fanli/src/main/resource/image/invite/blks_ico.png                                              |    0 
 fanli/src/main/java/com/yeshi/fanli/vo/user/PullNewRuleVO.java                                 |   63 +
 fanli/src/main/java/com/yeshi/fanli/service/inter/goods/FreeGoodsCouponService.java            |   38 +
 fanli/src/main/java/com/yeshi/fanli/dao/goods/PullNewGoodsDao.java                             |   39 +
 fanli/src/main/java/com/yeshi/fanli/service/inter/goods/PullNewGoodsService.java               |   29 
 fanli/src/main/resource/image/invite/qr_code_frame.png                                         |    0 
 25 files changed, 2,200 insertions(+), 43 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java
new file mode 100644
index 0000000..4865bc4
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java
@@ -0,0 +1,187 @@
+package com.yeshi.fanli.controller.client.v1.h5;
+
+import java.io.PrintWriter;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.yeshi.utils.DateUtil;
+import org.yeshi.utils.JsonUtil;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+import com.yeshi.fanli.dto.ConfigParamsDTO;
+import com.yeshi.fanli.entity.accept.AcceptData;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.bus.user.UserRankings;
+import com.yeshi.fanli.entity.goods.PullNewGoods;
+import com.yeshi.fanli.service.inter.goods.PullNewGoodsService;
+import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
+import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
+import com.yeshi.fanli.service.inter.user.QrCodeService;
+import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
+import com.yeshi.fanli.service.inter.user.UserInfoService;
+import com.yeshi.fanli.service.inter.user.UserRankingsService;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
+import com.yeshi.fanli.util.factory.goods.TaoBaoGoodsFactory;
+import com.yeshi.fanli.vo.user.PullNewRuleVO;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+@Controller
+@RequestMapping("api/apph5/v1/pullNew")
+public class AppH5PullNewController {
+
+	@Resource
+	private PullNewGoodsService pullNewGoodsService;
+
+	@Resource
+	private RedPackConfigService redPackConfigService;
+
+	@Resource
+	private UserRankingsService userRankingsService;
+
+	@Resource
+	private HongBaoManageService hongBaoManageService;
+
+	@Resource
+	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
+	
+	@Resource
+	private QrCodeService qrCodeService;
+	
+	@Resource
+	private UserInfoService userInfoService;
+
+	@Resource
+	private UserInfoExtraService userInfoExtraService;
+
+	
+
+	/**
+	 * 鎷夋柊鍟嗗搧
+	 * 
+	 * @param acceptData
+	 * @param callback
+	 * @param uid
+	 * @param page
+	 * @param goodsType
+	 * @param out
+	 */
+	@RequestMapping("getGoodsList")
+	public void getGoodsList(AcceptData acceptData, String callback, Long uid, Integer page, PrintWriter out) {
+		JSONArray array = new JSONArray();
+		List<PullNewGoods> list = pullNewGoodsService.listQuery((page-1)*Constant.PAGE_SIZE, Constant.PAGE_SIZE);
+		if (list != null && list.size() > 0) {
+			Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
+			ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
+					acceptData.getVersion());
+			paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+			
+			for (PullNewGoods goods : list) {
+				array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(TaoBaoGoodsFactory.create(goods),paramsDTO)));
+			}
+		}
+		
+
+		JSONObject data = new JSONObject();
+		if (page == 1) {
+			String ruleStr = redPackConfigService.getValueByKey("pullnew_activity_rule");
+			if (!StringUtil.isNullOrEmpty(ruleStr)) {
+				Type type = new TypeToken<PullNewRuleVO>() {
+				}.getType();
+				PullNewRuleVO rule = new Gson().fromJson(ruleStr, type);
+				rule.setRuleName(DateUtil.getCurrentMonthChinese() + "鏈堟椿鍔ㄨ鍒�");
+				data.put("rule", rule);
+			}
+			data.put("tip", redPackConfigService.getValueByKey("pullnew_page_tip"));
+		}
+		data.put("count", pullNewGoodsService.countQuery());
+		data.put("list", array);
+		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+	}
+
+	/**
+	 * 鎷夋柊鎺掕姒�
+	 * 
+	 * @param acceptData
+	 * @param callback
+	 * @param uid
+	 * @param page
+	 * @param out
+	 */
+	@RequestMapping("getRankList")
+	public void getRankList(AcceptData acceptData, String callback, Long uid, PrintWriter out) {
+		JSONArray array = new JSONArray();
+		List<UserRankings> list = userRankingsService.getRankList(0, 10);
+		if (list != null && list.size() > 0) {
+			for (UserRankings rank : list) {
+				JSONObject user = new JSONObject();
+				user.put("nickName", rank.getNickName());
+				user.put("portrait", rank.getPortrait());
+				user.put("money", "楼 " + rank.getShareReward().setScale(2, BigDecimal.ROUND_DOWN));
+				array.add(user);
+			}
+		}
+		JSONObject data = new JSONObject();
+		data.put("count", array.size());
+		data.put("list", array);
+		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+	}
+
+	/**
+	 * 鍒涘缓鍒嗕韩鍥�
+	 * 
+	 * @param acceptData
+	 * @param callback
+	 * @param uid
+	 * @param out
+	 */
+	@RequestMapping("getShareImg")
+	public void getShareImg(AcceptData acceptData, String callback, Long uid, PrintWriter out) {
+		if (uid == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+			return;
+		}
+
+		UserInfo userInfo = userInfoService.selectByPKey(uid);
+		if (userInfo == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ敤鎴蜂笉瀛樺湪"));
+			return;
+		}
+		
+		String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+		if (StringUtil.isNullOrEmpty(inviteCode)) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("閭�璇风爜鏈縺娲�"));
+			return;
+		}
+		
+		PullNewRuleVO rule = null;
+		String ruleStr = redPackConfigService.getValueByKey("pullnew_activity_rule");
+		if (!StringUtil.isNullOrEmpty(ruleStr)) {
+			Type type = new TypeToken<PullNewRuleVO>() {
+			}.getType();
+			rule = new Gson().fromJson(ruleStr, type);
+			rule.setRuleName(DateUtil.getCurrentMonthChinese() + "鏈堟椿鍔ㄨ鍒�");
+		}
+		
+		String url = qrCodeService.drawPullNewPoster(uid, userInfo.getPortrait(), inviteCode, rule);
+		if (StringUtil.isNullOrEmpty(url)) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢熸垚鍒嗕韩鍥惧け璐�"));
+			return;
+		}
+		
+		JSONObject data = new JSONObject();
+		data.put("imgUrl",url);
+		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+	}
+}
\ No newline at end of file
diff --git a/fanli/src/main/java/com/yeshi/fanli/dao/goods/FreeGoodsCouponDao.java b/fanli/src/main/java/com/yeshi/fanli/dao/goods/FreeGoodsCouponDao.java
new file mode 100644
index 0000000..565fe5b
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/dao/goods/FreeGoodsCouponDao.java
@@ -0,0 +1,45 @@
+package com.yeshi.fanli.dao.goods;
+
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
+import org.springframework.stereotype.Repository;
+
+import com.yeshi.fanli.dao.MongodbBaseDao;
+import com.yeshi.fanli.entity.goods.FreeGoodsCoupon;
+import com.yeshi.fanli.vo.goods.GoodsDetailVO;
+
+@Repository
+public class FreeGoodsCouponDao extends MongodbBaseDao<FreeGoodsCoupon> {
+
+
+	/**
+	 * 鏌ヨ鍏嶅崟鍟嗗搧-鏇存柊鍦ㄥ墠
+	 * @param start
+	 * @param count
+	 * @param goodsType
+	 * @return
+	 */
+	public List<FreeGoodsCoupon> listByType(int start,int count, Integer goodsType) {
+		Query query = new Query();
+		if (goodsType != null)
+			query.addCriteria(Criteria.where("goodsType").is(goodsType));
+		query.with(new Sort(Sort.Direction.DESC, "updateTime"));
+		query.skip(start).limit(count);
+		return mongoTemplate.find(query, getEntityClass());
+	}
+
+	public long countByType(Integer goodsType) {
+		Query query = new Query();
+		if (goodsType != null)
+			query.addCriteria(Criteria.where("goodsType").is(goodsType));
+		return mongoTemplate.count(query, getEntityClass());
+	}
+
+	
+	
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/dao/goods/PullNewGoodsDao.java b/fanli/src/main/java/com/yeshi/fanli/dao/goods/PullNewGoodsDao.java
new file mode 100644
index 0000000..b835a29
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/dao/goods/PullNewGoodsDao.java
@@ -0,0 +1,39 @@
+package com.yeshi.fanli.dao.goods;
+
+import java.util.List;
+
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.stereotype.Repository;
+
+import com.yeshi.fanli.dao.MongodbBaseDao;
+import com.yeshi.fanli.entity.goods.PullNewGoods;
+
+@Repository
+public class PullNewGoodsDao extends MongodbBaseDao<PullNewGoods> {
+
+	public List<PullNewGoods> listQuery(int start, int count) {
+		Query query = new Query();
+        query.skip(start).limit(count);
+		return mongoTemplate.find(query, getEntityClass());
+	}
+
+	public long countQuery() {
+		Query query = new Query();
+		return mongoTemplate.count(query, getEntityClass());
+	}
+	
+	
+	public List<PullNewGoods> getByItemid(Long itemid) {
+		Query query = new Query();
+		query.addCriteria(Criteria.where("itemid").is(itemid));
+		return mongoTemplate.find(query, getEntityClass());
+	}
+	
+	
+	public void deleteByItemid(Long itemid) {
+		Query query = new Query();
+		query.addCriteria(Criteria.where("itemid").is(itemid));
+		mongoTemplate.remove(query, getEntityClass());
+	}
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/dto/pdd/PDDSearchRange.java b/fanli/src/main/java/com/yeshi/fanli/dto/pdd/PDDSearchRange.java
new file mode 100644
index 0000000..e589a53
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/dto/pdd/PDDSearchRange.java
@@ -0,0 +1,48 @@
+package com.yeshi.fanli.dto.pdd;
+
+public class PDDSearchRange{
+	private Long range_from; // 鍖洪棿鐨勫紑濮嬪��
+	private Long range_to; // 鍖洪棿鐨勭粨鏉熷��
+	private Integer range_id; // 0锛屾渶灏忔垚鍥环 1锛屽埜鍚庝环 2锛屼剑閲戞瘮渚� 3锛屼紭鎯犲埜浠锋牸 4锛屽箍鍛婂垱寤烘椂闂� 5锛岄攢閲� 6锛屼剑閲戦噾棰� 7锛屽簵閾烘弿杩板垎 8锛屽簵閾虹墿娴佸垎 9锛屽簵閾烘湇鍔″垎 
+							// 10锛� 搴楅摵鎻忚堪鍒嗗嚮璐ュ悓琛屼笟鐧惧垎姣� 11锛� 搴楅摵鐗╂祦鍒嗗嚮璐ュ悓琛屼笟鐧惧垎姣� 12锛屽簵閾烘湇鍔″垎鍑昏触鍚岃涓氱櫨鍒嗘瘮 13锛屽晢鍝佸垎 17 锛屼紭鎯犲埜/鏈�灏忓洟璐环 18锛岃繃鍘讳袱灏忔椂pv 19锛岃繃鍘讳袱灏忔椂閿�閲�
+	
+	public PDDSearchRange() {}
+	
+	public PDDSearchRange(Long range_from, Integer range_id) {
+		this.range_from = range_from;
+		this.range_id = range_id;
+	}
+	
+	public PDDSearchRange(Integer range_id, Long range_to) {
+		this.range_id = range_id;
+		this.range_to = range_to;
+	}
+	
+	public PDDSearchRange(Long range_from, Integer range_id, Long range_to) {
+		this.range_from = range_from;
+		this.range_id = range_id;
+		this.range_to = range_to;
+	}
+	
+	public Long getrange_from() {
+		return range_from;
+	}
+	public void setrange_from(Long range_from) {
+		this.range_from = range_from;
+	}
+	public Long getrange_to() {
+		return range_to;
+	}
+	public void setrange_to(Long range_to) {
+		this.range_to = range_to;
+	}
+	public Integer getrange_id() {
+		return range_id;
+	}
+	public void setrange_id(Integer range_id) {
+		this.range_id = range_id;
+	}
+	
+	 
+	
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/dto/taobao/haodanku/HDKSearchFilter.java b/fanli/src/main/java/com/yeshi/fanli/dto/taobao/haodanku/HDKSearchFilter.java
new file mode 100644
index 0000000..b2b205e
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/dto/taobao/haodanku/HDKSearchFilter.java
@@ -0,0 +1,142 @@
+package com.yeshi.fanli.dto.taobao.haodanku;
+
+public class HDKSearchFilter {
+	private Integer minId;// 椤电爜
+	private Integer back;// 椤垫暟閲�
+	private Integer nav;// 榛樿鏄叏閮ㄥ晢鍝�1锛�1瀹炴椂璺戝崟鍟嗗搧锛�2鐖嗗崟姒滃晢鍝侊紝3鍏ㄩ儴鍟嗗搧锛�4绾棰戝崟锛�5鑱氭窐涓撳尯锛�
+	private Integer sort;// 鎺掑簭绫诲瀷
+	private Integer priceMin;// 鍒稿悗浠风瓫閫夛紝绛涢�夊ぇ浜庣瓑浜庢墍璁剧疆鐨勫埜鍚庝环鐨勫晢鍝�
+	private Integer priceMax;// 鍒稿悗浠风瓫閫夛紝绛涢�夊皬浜庣瓑浜庢墍璁剧疆鐨勫埜鍚庝环鐨勫晢鍝�
+	private Integer saleMin;// 閿�閲忕瓫閫夛紝绛涢�夊ぇ浜庣瓑浜庢墍璁剧疆鐨勯攢閲忕殑鍟嗗搧
+	private Integer saleMax;// 閿�閲忕瓫閫夛紝绛涢�夊皬浜庣瓑浜庢墍璁剧疆鐨勯攢閲忕殑鍟嗗搧
+	private Integer couponMin;// 鍒搁噾棰濈瓫閫夛紝绛涢�夊ぇ浜庣瓑浜庢墍璁剧疆鐨勫埜閲戦鐨勫晢鍝�
+	private Integer couponMax;// 鍒搁噾棰濈瓫閫夛紝绛涢�夊皬浜庣瓑浜庢墍璁剧疆鐨勫埜閲戦鐨勫晢鍝�
+	private Integer tkratesMin;// 浣i噾姣斾緥绛涢�夛紝绛涢�夊ぇ浜庣瓑浜庢墍璁剧疆鐨勪剑閲戞瘮渚嬬殑鍟嗗搧
+	private Integer tkratesMax;// 浣i噾姣斾緥绛涢�夛紝绛涢�夊皬浜庢墍璁剧疆鐨勪剑閲戞瘮渚嬬殑鍟嗗搧
+	private Integer tkmoneyMin;// 浣i噾绛涢�夛紝绛涢�夊ぇ浜庣瓑浜庢墍璁剧疆鐨勪剑閲戠殑鍟嗗搧
+	private Integer itemType;// 鏄惁鍙幏鍙栬惀閿�杩斿埄鍟嗗搧锛�1鏄紝0鍚�
+	private String cid;// 鍟嗗搧绫荤洰锛� 鍟嗗搧绫荤洰锛�
+	//0鍏ㄩ儴锛�1濂宠锛�2鐢疯锛�3鍐呰。锛�4缇庡锛�5閰嶉グ锛�6闉嬪搧锛�7绠卞寘锛�8鍎跨锛�9姣嶅┐锛�10灞呭锛�11缇庨锛�12鏁扮爜锛�13瀹剁數锛�14鍏朵粬锛�15杞﹀搧锛�16鏂囦綋锛�17瀹犵墿锛堟敮鎸佸绫荤洰绛涢�夛紝濡�1,2鑾峰彇绫荤洰涓哄コ瑁呫�佺敺瑁呯殑鍟嗗搧锛岄�楀彿浠呴檺鑻辨枃閫楀彿锛�
+	
+	
+	public Integer getMinId() {
+		return minId;
+	}
+
+	public void setMinId(Integer minId) {
+		this.minId = minId;
+	}
+
+	public Integer getBack() {
+		return back;
+	}
+
+	public void setBack(Integer back) {
+		this.back = back;
+	}
+
+	public Integer getNav() {
+		return nav;
+	}
+
+	public void setNav(Integer nav) {
+		this.nav = nav;
+	}
+
+	public String getCid() {
+		return cid;
+	}
+
+	public void setCid(String cid) {
+		this.cid = cid;
+	}
+
+	public Integer getSort() {
+		return sort;
+	}
+
+	public void setSort(Integer sort) {
+		this.sort = sort;
+	}
+
+	public Integer getPriceMin() {
+		return priceMin;
+	}
+
+	public void setPriceMin(Integer priceMin) {
+		this.priceMin = priceMin;
+	}
+
+	public Integer getPriceMax() {
+		return priceMax;
+	}
+
+	public void setPriceMax(Integer priceMax) {
+		this.priceMax = priceMax;
+	}
+
+	public Integer getSaleMin() {
+		return saleMin;
+	}
+
+	public void setSaleMin(Integer saleMin) {
+		this.saleMin = saleMin;
+	}
+
+	public Integer getSaleMax() {
+		return saleMax;
+	}
+
+	public void setSaleMax(Integer saleMax) {
+		this.saleMax = saleMax;
+	}
+
+	public Integer getCouponMin() {
+		return couponMin;
+	}
+
+	public void setCouponMin(Integer couponMin) {
+		this.couponMin = couponMin;
+	}
+
+	public Integer getCouponMax() {
+		return couponMax;
+	}
+
+	public void setCouponMax(Integer couponMax) {
+		this.couponMax = couponMax;
+	}
+
+	public Integer getTkratesMin() {
+		return tkratesMin;
+	}
+
+	public void setTkratesMin(Integer tkratesMin) {
+		this.tkratesMin = tkratesMin;
+	}
+
+	public Integer getTkratesMax() {
+		return tkratesMax;
+	}
+
+	public void setTkratesMax(Integer tkratesMax) {
+		this.tkratesMax = tkratesMax;
+	}
+
+	public Integer getTkmoneyMin() {
+		return tkmoneyMin;
+	}
+
+	public void setTkmoneyMin(Integer tkmoneyMin) {
+		this.tkmoneyMin = tkmoneyMin;
+	}
+
+	public Integer getItemType() {
+		return itemType;
+	}
+
+	public void setItemType(Integer itemType) {
+		this.itemType = itemType;
+	}
+
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/dto/user/PullNewRuleTerm.java b/fanli/src/main/java/com/yeshi/fanli/dto/user/PullNewRuleTerm.java
new file mode 100644
index 0000000..ce8f2c0
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/dto/user/PullNewRuleTerm.java
@@ -0,0 +1,33 @@
+package com.yeshi.fanli.dto.user;
+
+import java.math.BigDecimal;
+
+public class PullNewRuleTerm {
+	private Long min;
+	private Long max;
+	private BigDecimal money;
+
+	public Long getMin() {
+		return min;
+	}
+
+	public void setMin(Long min) {
+		this.min = min;
+	}
+
+	public Long getMax() {
+		return max;
+	}
+
+	public void setMax(Long max) {
+		this.max = max;
+	}
+
+	public BigDecimal getMoney() {
+		return money;
+	}
+
+	public void setMoney(BigDecimal money) {
+		this.money = money;
+	}
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCoupon.java b/fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCoupon.java
index d9cff53..d1732a8 100644
--- a/fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCoupon.java
+++ b/fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCoupon.java
@@ -45,6 +45,7 @@
 	public final static String SOURCE_DAILY_REBATE = "澶╁ぉ鎶�";
 	public final static String SOURCE_EXCHANGE = "閲戝竵鍏戞崲";
 	public final static String SOURCE_GIVE = "濂藉弸璧犻��";
+	public final static String SOURCE_PULL_NEW = "鎷夋柊濂栧姳";
 	
 	@Expose
 	@Column(name = "usc_id")
diff --git a/fanli/src/main/java/com/yeshi/fanli/entity/goods/FreeGoodsCoupon.java b/fanli/src/main/java/com/yeshi/fanli/entity/goods/FreeGoodsCoupon.java
new file mode 100644
index 0000000..665a879
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/entity/goods/FreeGoodsCoupon.java
@@ -0,0 +1,83 @@
+package com.yeshi.fanli.entity.goods;
+
+import java.util.Date;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.index.Indexed;
+import org.springframework.data.mongodb.core.mapping.Document;
+import org.springframework.data.mongodb.core.mapping.Field;
+
+import com.yeshi.fanli.vo.goods.GoodsDetailVO;
+
+/**
+ * 鍏嶅崟鍒稿晢鍝�
+ * 
+ * @author Administrator
+ *
+ */
+@Document(collection = "FreeGoodsCoupon")
+public class FreeGoodsCoupon {
+	@Id
+	private String id;// 鑷ID
+	@Field
+	@Indexed
+	private String goodsId;// 鍟嗗搧id--鎼滅储
+	@Field
+	@Indexed
+	private Integer goodsType;// 鍟嗗搧绫诲瀷--鎼滅储
+	@Field
+	private GoodsDetailVO goods; // 鍟嗗搧淇℃伅
+	@Field
+	private Date createTime;// 鍒涘缓鏃堕棿
+	@Field
+	private Date updateTime;// 鏇存柊鏃堕棿
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getGoodsId() {
+		return goodsId;
+	}
+
+	public void setGoodsId(String goodsId) {
+		this.goodsId = goodsId;
+	}
+
+	public Integer getGoodsType() {
+		return goodsType;
+	}
+
+	public void setGoodsType(Integer goodsType) {
+		this.goodsType = goodsType;
+	}
+
+	public GoodsDetailVO getGoods() {
+		return goods;
+	}
+
+	public void setGoods(GoodsDetailVO goods) {
+		this.goods = goods;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/entity/goods/PullNewGoods.java b/fanli/src/main/java/com/yeshi/fanli/entity/goods/PullNewGoods.java
new file mode 100644
index 0000000..1eced29
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/entity/goods/PullNewGoods.java
@@ -0,0 +1,510 @@
+package com.yeshi.fanli.entity.goods;
+
+import java.util.Date;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.index.Indexed;
+import org.springframework.data.mongodb.core.mapping.Document;
+import org.springframework.data.mongodb.core.mapping.Field;
+
+/**
+ *  鎷夋柊鍟嗗搧
+ * 
+ * @author Administrator
+ *
+ */
+@Document(collection = "pullNewGoods")
+public class PullNewGoods {
+	@Id
+	private Integer product_id;// 鑷ID
+	@Field
+	@Indexed
+	private Long itemid;// 瀹濊礉ID
+	@Field
+	private String itemtitle;// 瀹濊礉鏍囬
+	@Field
+	private String itemshorttitle;// 瀹濊礉鐭爣棰�
+	@Field
+	private String itemdesc;// 瀹濊礉鎺ㄨ崘璇�
+	@Field
+	private Double itemprice;// 鍦ㄥ敭浠�
+	@Field
+	private Integer itemsale;// 瀹濊礉鏈堥攢閲�
+	@Field
+	private Integer itemsale2;// 瀹濊礉杩�2灏忔椂璺戝崟
+	@Field
+	private Integer todaysale;// 褰撳ぉ閿�閲�
+	@Field
+	private String itempic;// 瀹濊礉涓诲浘鍘熷鍥惧儚
+	@Field
+	private String itempic_copy;// 鎺ㄥ箍闀垮浘
+	@Field
+	private String taobao_image;// 杞挱涓诲浘锛岀敤鑻辨枃閫楀彿鍒嗛殧寮�鏉�
+	@Field
+	private Integer fqcat;// 鍟嗗搧绫荤洰
+	@Field
+	private Double itemendprice;// 瀹濊礉鍒稿悗浠�
+	@Field
+	private String shoptype;// 搴楅摵绫诲瀷
+	@Field
+	private String couponurl;// 浼樻儬鍒搁摼鎺�
+	@Field
+	private Double couponmoney;// 浼樻儬鍒搁噾棰�
+	@Field
+	private Integer is_brand;// 鏄惁涓哄搧鐗屼骇鍝�
+	@Field
+	private Integer is_live;// 鏄惁涓虹洿鎾�
+	@Field
+	private String guide_article;// 鎺ㄥ箍瀵艰喘鏂囨
+	@Field
+	private String videoid;// 鍟嗗搧瑙嗛ID
+	@Field
+	private String activity_type;// 娲诲姩绫诲瀷
+	@Field
+	private String planlink;// 钀ラ攢璁″垝閾炬帴
+	@Field
+	private String userid;// 搴椾富鐨剈serid
+	@Field
+	private String sellernick;// 搴楅摵鎺屾煖鍚�
+	@Field
+	private String shopname;// 搴楅摵鍚�
+	@Field
+	private String tktype;// 浣i噾璁″垝锛氶殣钘� ,钀ラ攢
+	@Field
+	private Double tkrates;// 浣i噾姣斾緥
+	@Field
+	private Integer cuntao;// 鏄惁鏉戞窐锛�1鏄級
+	@Field
+	private Double tkmoney;// 棰勮鍙緱锛堝疂璐濅环鏍� * 浣i噾姣斾緥 / 100锛�
+	@Field
+	private Integer couponreceive2;// 褰撳ぉ浼樻儬鍒搁鍙栭噺
+	@Field
+	private Integer couponsurplus;// 浼樻儬鍒稿墿浣欓噺
+	@Field
+	private Integer couponnum;// 浼樻儬鍒告�绘暟閲�
+	@Field
+	private String coupon_condition;// 浼樻儬鍒镐娇鐢ㄦ潯浠�
+	@Field
+	private String couponexplain;// 浼樻儬鍒镐娇鐢ㄦ潯浠�
+	@Field
+	private Integer couponstarttime;// 浼樻儬鍒稿紑濮嬫椂闂�
+	@Field
+	private Integer couponendtime;// 浼樻儬鍒哥粨鏉熸椂闂�
+	@Field
+	private Integer start_time;// 娲诲姩寮�濮嬫椂闂�
+	@Field
+	private Integer end_time;// 娲诲姩缁撴潫鏃堕棿
+	@Field
+	private Integer starttime;// 鍙戝竷鏃堕棿
+	@Field
+	private Integer report_status;// 涓炬姤澶勭悊鏉′欢 0鏈妇鎶� 1涓哄緟澶勭悊 2涓哄拷鐣� 3涓轰笅鏋�
+	@Field
+	private Integer general_index;// 濂藉崟鎸囨暟
+	@Field
+	private String seller_name;// 鏀惧崟浜哄悕鍙�
+	@Field
+	private Double discount;// 鎶樻墸鍔涘害
+	@Field
+	private Double deposit;// 鍙屽崄涓�瀹氶噾
+	@Field
+	private Double deposit_deduct;// 鍙屽崄涓�瀹氶噾鎶垫墸閲戦
+	@Field
+	private Date createTime;// 鍒涘缓鏃堕棿
+	@Field
+	private Date updateTime;// 鏇存柊鏃堕棿
+	@Field
+	private String activityid;
+
+	public String getActivityid() {
+		return activityid;
+	}
+
+	public void setActivityid(String activityid) {
+		this.activityid = activityid;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public Integer getProduct_id() {
+		return product_id;
+	}
+
+	public void setProduct_id(Integer product_id) {
+		this.product_id = product_id;
+	}
+
+	public Long getItemid() {
+		return itemid;
+	}
+
+	public void setItemid(Long itemid) {
+		this.itemid = itemid;
+	}
+
+	public String getItemtitle() {
+		return itemtitle;
+	}
+
+	public void setItemtitle(String itemtitle) {
+		this.itemtitle = itemtitle;
+	}
+
+	public String getItemshorttitle() {
+		return itemshorttitle;
+	}
+
+	public void setItemshorttitle(String itemshorttitle) {
+		this.itemshorttitle = itemshorttitle;
+	}
+
+	public String getItemdesc() {
+		return itemdesc;
+	}
+
+	public void setItemdesc(String itemdesc) {
+		this.itemdesc = itemdesc;
+	}
+
+	public Double getItemprice() {
+		return itemprice;
+	}
+
+	public void setItemprice(Double itemprice) {
+		this.itemprice = itemprice;
+	}
+
+	public Integer getItemsale() {
+		return itemsale;
+	}
+
+	public void setItemsale(Integer itemsale) {
+		this.itemsale = itemsale;
+	}
+
+	public Integer getItemsale2() {
+		return itemsale2;
+	}
+
+	public void setItemsale2(Integer itemsale2) {
+		this.itemsale2 = itemsale2;
+	}
+
+	public Integer getTodaysale() {
+		return todaysale;
+	}
+
+	public void setTodaysale(Integer todaysale) {
+		this.todaysale = todaysale;
+	}
+
+	public String getItempic() {
+		return itempic;
+	}
+
+	public void setItempic(String itempic) {
+		this.itempic = itempic;
+	}
+
+	public String getItempic_copy() {
+		return itempic_copy;
+	}
+
+	public void setItempic_copy(String itempic_copy) {
+		this.itempic_copy = itempic_copy;
+	}
+
+	public String getTaobao_image() {
+		return taobao_image;
+	}
+
+	public void setTaobao_image(String taobao_image) {
+		this.taobao_image = taobao_image;
+	}
+
+	public Integer getFqcat() {
+		return fqcat;
+	}
+
+	public void setFqcat(Integer fqcat) {
+		this.fqcat = fqcat;
+	}
+
+	public Double getItemendprice() {
+		return itemendprice;
+	}
+
+	public void setItemendprice(Double itemendprice) {
+		this.itemendprice = itemendprice;
+	}
+
+	public String getShoptype() {
+		return shoptype;
+	}
+
+	public void setShoptype(String shoptype) {
+		this.shoptype = shoptype;
+	}
+
+	public String getCouponurl() {
+		return couponurl;
+	}
+
+	public void setCouponurl(String couponurl) {
+		this.couponurl = couponurl;
+	}
+
+	public Double getCouponmoney() {
+		return couponmoney;
+	}
+
+	public void setCouponmoney(Double couponmoney) {
+		this.couponmoney = couponmoney;
+	}
+
+	public Integer getIs_brand() {
+		return is_brand;
+	}
+
+	public void setIs_brand(Integer is_brand) {
+		this.is_brand = is_brand;
+	}
+
+	public Integer getIs_live() {
+		return is_live;
+	}
+
+	public void setIs_live(Integer is_live) {
+		this.is_live = is_live;
+	}
+
+	public String getGuide_article() {
+		return guide_article;
+	}
+
+	public void setGuide_article(String guide_article) {
+		this.guide_article = guide_article;
+	}
+
+	public String getVideoid() {
+		return videoid;
+	}
+
+	public void setVideoid(String videoid) {
+		this.videoid = videoid;
+	}
+
+	public String getActivity_type() {
+		return activity_type;
+	}
+
+	public void setActivity_type(String activity_type) {
+		this.activity_type = activity_type;
+	}
+
+	public String getPlanlink() {
+		return planlink;
+	}
+
+	public void setPlanlink(String planlink) {
+		this.planlink = planlink;
+	}
+
+	public String getUserid() {
+		return userid;
+	}
+
+	public void setUserid(String userid) {
+		this.userid = userid;
+	}
+
+	public String getSellernick() {
+		return sellernick;
+	}
+
+	public void setSellernick(String sellernick) {
+		this.sellernick = sellernick;
+	}
+
+	public String getShopname() {
+		return shopname;
+	}
+
+	public void setShopname(String shopname) {
+		this.shopname = shopname;
+	}
+
+	public String getTktype() {
+		return tktype;
+	}
+
+	public void setTktype(String tktype) {
+		this.tktype = tktype;
+	}
+
+	public Double getTkrates() {
+		return tkrates;
+	}
+
+	public void setTkrates(Double tkrates) {
+		this.tkrates = tkrates;
+	}
+
+	public Integer getCuntao() {
+		return cuntao;
+	}
+
+	public void setCuntao(Integer cuntao) {
+		this.cuntao = cuntao;
+	}
+
+	public Double getTkmoney() {
+		return tkmoney;
+	}
+
+	public void setTkmoney(Double tkmoney) {
+		this.tkmoney = tkmoney;
+	}
+
+	public Integer getCouponreceive2() {
+		return couponreceive2;
+	}
+
+	public void setCouponreceive2(Integer couponreceive2) {
+		this.couponreceive2 = couponreceive2;
+	}
+
+	public Integer getCouponsurplus() {
+		return couponsurplus;
+	}
+
+	public void setCouponsurplus(Integer couponsurplus) {
+		this.couponsurplus = couponsurplus;
+	}
+
+	public Integer getCouponnum() {
+		return couponnum;
+	}
+
+	public void setCouponnum(Integer couponnum) {
+		this.couponnum = couponnum;
+	}
+
+	public String getCouponexplain() {
+		return couponexplain;
+	}
+
+	public void setCouponexplain(String couponexplain) {
+		this.couponexplain = couponexplain;
+	}
+
+	public Integer getCouponstarttime() {
+		return couponstarttime;
+	}
+
+	public void setCouponstarttime(Integer couponstarttime) {
+		this.couponstarttime = couponstarttime;
+	}
+
+	public Integer getCouponendtime() {
+		return couponendtime;
+	}
+
+	public void setCouponendtime(Integer couponendtime) {
+		this.couponendtime = couponendtime;
+	}
+
+	public Integer getStart_time() {
+		return start_time;
+	}
+
+	public void setStart_time(Integer start_time) {
+		this.start_time = start_time;
+	}
+
+	public Integer getEnd_time() {
+		return end_time;
+	}
+
+	public void setEnd_time(Integer end_time) {
+		this.end_time = end_time;
+	}
+
+	public Integer getStarttime() {
+		return starttime;
+	}
+
+	public void setStarttime(Integer starttime) {
+		this.starttime = starttime;
+	}
+
+	public Integer getReport_status() {
+		return report_status;
+	}
+
+	public void setReport_status(Integer report_status) {
+		this.report_status = report_status;
+	}
+
+	public Integer getGeneral_index() {
+		return general_index;
+	}
+
+	public void setGeneral_index(Integer general_index) {
+		this.general_index = general_index;
+	}
+
+	public String getSeller_name() {
+		return seller_name;
+	}
+
+	public void setSeller_name(String seller_name) {
+		this.seller_name = seller_name;
+	}
+
+	public Double getDiscount() {
+		return discount;
+	}
+
+	public void setDiscount(Double discount) {
+		this.discount = discount;
+	}
+
+	public Double getDeposit() {
+		return deposit;
+	}
+
+	public void setDeposit(Double deposit) {
+		this.deposit = deposit;
+	}
+
+	public Double getDeposit_deduct() {
+		return deposit_deduct;
+	}
+
+	public void setDeposit_deduct(Double deposit_deduct) {
+		this.deposit_deduct = deposit_deduct;
+	}
+
+	public String getCoupon_condition() {
+		return coupon_condition;
+	}
+
+	public void setCoupon_condition(String coupon_condition) {
+		this.coupon_condition = coupon_condition;
+	}
+
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/job/RedPackJob.java b/fanli/src/main/java/com/yeshi/fanli/job/RedPackJob.java
new file mode 100644
index 0000000..96495a4
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/job/RedPackJob.java
@@ -0,0 +1,89 @@
+package com.yeshi.fanli.job;
+
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.yeshi.fanli.dto.user.PullNewRuleTerm;
+import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
+import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
+import com.yeshi.fanli.util.StringUtil;
+
+@Component
+public class RedPackJob {
+
+	@Resource
+	private RedPackWinInviteService redPackWinInviteService;
+	
+	@Resource
+	private RedPackConfigService redPackConfigService;
+	
+	
+	/**
+	 * 绾㈠寘姣忔湀26鍒拌处
+	 */
+	@Scheduled(cron = "0 20 0 26 * ? ")
+	public void arriveMoney() {
+		try {
+			String value = redPackConfigService.getValueByKey("win_redpack_term");
+			if (StringUtil.isNullOrEmpty(value)) {
+				return;
+			}
+			
+			Type type = new TypeToken<ArrayList<PullNewRuleTerm>>() {
+			}.getType();
+			List<PullNewRuleTerm> listRule = new Gson().fromJson(value, type);
+			if (listRule == null || listRule.size() == 0) {
+				return;
+			}
+			
+			int start = 0;
+			Date date = new Date();
+			while(true) {
+				// 涓婃湀瀛樺湪閭�璇风殑鐢ㄧ敤鎴穒d
+				List<Long> list = redPackWinInviteService.listWinUid(start, 1000);
+				if (list == null || list.size() == 0) {
+					break;
+				}
+				
+				for (Long uid: list) {
+					// 缁熻涓婃湀閭�璇锋垚鍔熸暟閲�
+					long count = redPackWinInviteService.countLastMonthByUid(uid);
+					if (count == 0)
+						continue;
+					
+					BigDecimal money = null;
+					for (PullNewRuleTerm term: listRule) {
+						if (count >= term.getMin() && (term.getMax() != null && count <= term.getMax())) {
+							money = term.getMoney();
+						}
+					}
+					
+					if (money == null) {
+						LogHelper.test("绾㈠寘濂栧姳鏈尮閰嶅埌瑙勫垯count =" + count + " uid =" + uid);
+						continue;
+					}
+					
+					try {
+						redPackWinInviteService.arriveMoney(uid, money, date);
+					} catch (Exception e) {
+						LogHelper.errorDetailInfo(e);
+					}
+				}
+			}
+		} catch (Exception e) {
+			LogHelper.errorDetailInfo(e);
+		}
+	}
+	 
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/job/goods/FreeGoodsCouponJob.java b/fanli/src/main/java/com/yeshi/fanli/job/goods/FreeGoodsCouponJob.java
new file mode 100644
index 0000000..7b6d82c
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/job/goods/FreeGoodsCouponJob.java
@@ -0,0 +1,397 @@
+package com.yeshi.fanli.job.goods;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import com.yeshi.fanli.dto.ConfigParamsDTO;
+import com.yeshi.fanli.dto.jd.JDCommissionInfo;
+import com.yeshi.fanli.dto.jd.JDFilter;
+import com.yeshi.fanli.dto.jd.JDSearchResult;
+import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
+import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
+import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
+import com.yeshi.fanli.dto.pdd.PDDSearchRange;
+import com.yeshi.fanli.dto.taobao.haodanku.HDKGoodsListResultDTO;
+import com.yeshi.fanli.dto.taobao.haodanku.HDKSearchFilter;
+import com.yeshi.fanli.entity.goods.FreeGoodsCoupon;
+import com.yeshi.fanli.entity.jd.JDGoods;
+import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
+import com.yeshi.fanli.service.inter.goods.FreeGoodsCouponService;
+import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.MoneyBigDecimalUtil;
+import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
+import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
+import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
+import com.yeshi.fanli.util.factory.goods.TaoBaoGoodsFactory;
+import com.yeshi.fanli.util.jd.JDApiUtil;
+import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
+import com.yeshi.fanli.util.taobao.HaoDanKuApiUtil;
+import com.yeshi.fanli.vo.goods.GoodsDetailVO;
+
+@Component
+public class FreeGoodsCouponJob {
+
+	@Resource
+	private FreeGoodsCouponService freeGoodsCouponService;
+
+	@Resource
+	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
+
+	@Resource
+	private HongBaoManageService hongBaoManageService;
+
+	@Resource
+	private JDGoodsCacheUtil jdGoodsCacheUtil;
+
+	@Resource
+	private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
+
+	@Scheduled(cron = "0 5 0/1 * * ? ")
+	public void addFreeGoods() {
+		if (!Constant.IS_TASK) {
+			return;
+		}
+		
+		updateGoodsTB();
+		
+		updateGoodsPDD();
+	}
+	
+	
+	/**
+	 * 鏇存柊娣樺疂鍟嗗搧-鍏嶅崟
+	 */
+	private void updateGoodsTB() {
+		int maxNum = 5;
+		BigDecimal limitPrice = new BigDecimal(2);
+		List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_TAOBAO);
+
+		ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
+		params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+
+		// 淇℃伅鏇存柊
+		List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>();
+		List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>();
+
+		if (listExist != null && listExist.size() > 0) {
+			for (FreeGoodsCoupon freeGood : listExist) {
+				HDKGoodsDetail itemDetail = HaoDanKuApiUtil.getInstance().getItemDetail(freeGood.getGoodsId());
+				if (itemDetail == null) {
+					listdel.add(freeGood);
+				} else {
+					if (listNew.size() >= 5) {
+						listdel.add(freeGood);
+						continue;
+					}
+					
+					// 姣斾緥闄愬埗锛� 閲戞瘮楂樹簬60%
+					if (itemDetail.getTkrates() == null || itemDetail.getTkrates() < 60) {
+						listdel.add(freeGood);
+						continue;
+					}
+					
+					TaoBaoGoodsBrief tbGoods = TaoBaoGoodsFactory.create(itemDetail);
+					GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(tbGoods, params);
+					if (detailVO.getCouponPrice() == null) {
+						if (detailVO.getCouponPrice().compareTo(limitPrice) > 0)
+							continue;
+					} else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) {
+						continue;
+					}
+					
+					boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
+					if (saveResult) {
+						listNew.add(detailVO);
+					}
+				}
+			}
+		}
+
+		if (listNew.size() < 5) {
+			Integer minId = 1;
+			HDKSearchFilter filter = new HDKSearchFilter();
+			filter.setBack(100);
+			filter.setPriceMax(2);
+			filter.setTkratesMin(60);
+			while (minId != null) {
+				filter.setMinId(minId);
+				HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().queryList(filter);
+				if (dto == null) {
+					break;
+				}
+				minId = dto.getMinId();
+				List<HDKGoodsDetail> goodsList = dto.getGoodsList();
+				if (goodsList == null || goodsList.size() == 0) {
+					break;
+				}
+
+				for (HDKGoodsDetail goods : goodsList) {
+					// 姣斾緥闄愬埗锛� 閲戞瘮楂樹簬60%
+					if (goods.getTkrates() == null || goods.getTkrates() < 60)
+						continue;
+					
+					boolean exist = false;
+					if (listNew.size() > 0) {
+						for (GoodsDetailVO goodsDetailVO : listNew) {
+							if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getItemid() + "")) {
+								exist = true;
+								break;
+							}
+						}
+					}
+					if (exist)
+						continue;
+
+					TaoBaoGoodsBrief tbGoods = TaoBaoGoodsFactory.create(goods);
+					GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(tbGoods, params);
+					boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
+					if (saveResult) {
+						listNew.add(detailVO);
+					}
+
+					if (listNew.size() >= maxNum)
+						break;
+				}
+
+				if (listNew.size() >= maxNum)
+					break;
+			}
+		}
+
+		// 鍒犻櫎涓嶆弧瓒虫潯浠�
+		if (listdel.size() > 0) {
+			for (FreeGoodsCoupon freeGoods : listdel) {
+				freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType());
+			}
+		}
+	}
+
+	/**
+	 * 鏇存柊浜笢鍟嗗搧-鍏嶅崟
+	 */
+	private void updateGoodsJD() {
+		int maxNum = 5;
+		BigDecimal limitPrice = new BigDecimal(2);
+		List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_JD);
+
+		ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
+		params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+
+		// 淇℃伅鏇存柊
+		List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>();
+		List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>();
+		if (listExist != null && listExist.size() > 0) {
+			for (FreeGoodsCoupon freeGood : listExist) {
+				JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(freeGood.getGoodsId()));
+				if (goodsInfo == null) {
+					listdel.add(freeGood);
+				} else {
+					if (listNew.size() >= 5) {
+						listdel.add(freeGood);
+						continue;
+					}
+					
+					// 姣斾緥闄愬埗锛� 閲戞瘮楂樹簬60%
+					JDCommissionInfo commissionInfo = goodsInfo.getCommissionInfo();
+					if (commissionInfo == null) {
+						continue;
+					}
+					if (commissionInfo.getCommissionShare().compareTo(BigDecimal.valueOf(60)) < 0) {
+						continue;
+					}
+
+					GoodsDetailVO detailVO = GoodsDetailVOFactory.convertJDGoods(goodsInfo, params);
+					
+					if (detailVO.getCouponPrice() == null) {
+						if (detailVO.getCouponPrice().compareTo(limitPrice) > 0)
+							continue;
+					} else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) {
+						continue;
+					}
+					
+					
+					boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
+					if (saveResult) {
+						listNew.add(detailVO);
+					}
+				}
+			}
+		}
+		// 涓嶈冻琛ラ綈
+		if (listNew.size() < maxNum) {
+			JDFilter filterAPI = new JDFilter();
+			filterAPI.setPageSize(Constant.PAGE_SIZE);
+			filterAPI.setPriceto(2.0);
+			filterAPI.setCommissionShareStart(60);
+			for (int page = 1; page < 1000; page++) {
+				filterAPI.setPageIndex(page);
+				JDSearchResult result = JDApiUtil.queryByKey(filterAPI);
+				if (result == null) {
+					break;
+				}
+
+				List<JDGoods> goodsList = result.getGoodsList();
+				if (goodsList == null || goodsList.size() == 0) {
+					break;
+				}
+
+				for (JDGoods goods : goodsList) {
+					// 姣斾緥闄愬埗锛� 閲戞瘮楂樹簬60%
+					JDCommissionInfo commissionInfo = goods.getCommissionInfo();
+					if (commissionInfo == null) {
+						continue;
+					}
+					if (commissionInfo.getCommissionShare().compareTo(BigDecimal.valueOf(60)) < 0) {
+						continue;
+					}
+
+					boolean exist = false;
+					if (listNew.size() > 0) {
+						for (GoodsDetailVO goodsDetailVO : listNew) {
+							if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getSkuId() + "")) {
+								exist = true;
+								break;
+							}
+						}
+					}
+					if (exist)
+						continue;
+
+					GoodsDetailVO detailVO = GoodsDetailVOFactory.convertJDGoods(goods, params);
+					boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
+					if (saveResult) {
+						listNew.add(detailVO);
+					}
+
+					if (listNew.size() >= maxNum)
+						break;
+				}
+
+				if (listNew.size() >= maxNum)
+					break;
+			}
+		}
+
+		// 鍒犻櫎涓嶆弧瓒虫潯浠�
+		if (listdel.size() > 0) {
+			for (FreeGoodsCoupon freeGoods : listdel) {
+				freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType());
+			}
+		}
+	}
+
+	/**
+	 * 鏇存柊浜笢鍟嗗搧-鍏嶅崟
+	 */
+	private void updateGoodsPDD() {
+		int maxNum = 5;
+		BigDecimal limitPrice = new BigDecimal(2);
+		List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_PDD);
+
+		ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
+		params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+
+		// 淇℃伅鏇存柊
+		List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>();
+		List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>();
+		if (listExist != null && listExist.size() > 0) {
+			for (FreeGoodsCoupon freeGood : listExist) {
+				PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(freeGood.getGoodsId()));
+				if (goodsInfo == null) {
+					listdel.add(freeGood);
+				} else {
+					if (listNew.size() >= 5) {
+						listdel.add(freeGood);
+						continue;
+					}
+					
+					// 姣斾緥闄愬埗锛� 閲戞瘮楂樹簬60%
+					BigDecimal promotionRate = 	new BigDecimal(goodsInfo.getPromotionRate());
+					if (promotionRate.compareTo(BigDecimal.valueOf(600)) < 0)
+						continue;
+
+					GoodsDetailVO detailVO = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, params);
+					if (detailVO.getCouponPrice() == null) {
+						if (detailVO.getCouponPrice().compareTo(limitPrice) > 0)
+							continue;
+					} else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) {
+						continue;
+					}
+					
+					boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
+					if (saveResult) {
+						listNew.add(detailVO);
+					}
+				}
+			}
+		}
+
+		// 涓嶈冻琛ラ綈
+		if (listNew.size() < maxNum) {
+			// 绛涢�夎寖鍥村垪琛�
+			List<PDDSearchRange> rangeList = new ArrayList<>(); 
+			// 鍒稿悗浠峰皬浜�2鍏�
+			rangeList.add(new PDDSearchRange(0L,0, 200L)); 
+			// 姣斾緥60%浠ヤ笂
+			rangeList.add(new PDDSearchRange(600L, 2, 1000L));
+			
+			PDDSearchFilter pddfilter = new PDDSearchFilter();
+			pddfilter.setRangeList(rangeList);
+			for (int page = 1; page < 1000; page++) {
+				pddfilter.setPage(page);
+				PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
+				if (result == null) {
+					break;
+				}
+
+				List<PDDGoodsDetail> goodsList = result.getGoodsList();
+				if (goodsList == null || goodsList.size() == 0) {
+					break;
+				}
+
+				for (PDDGoodsDetail goods : goodsList) {
+					boolean exist = false;
+					if (listNew.size() > 0) {
+						for (GoodsDetailVO goodsDetailVO : listNew) {
+							if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getGoodsId()+ "")) {
+								exist = true;
+								break;
+							}
+						}
+					}
+					if (exist)
+						continue;
+
+					GoodsDetailVO detailVO = GoodsDetailVOFactory.convertPDDGoods(goods, params);
+					boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO);
+					if (saveResult) {
+						listNew.add(detailVO);
+					}
+
+					if (listNew.size() >= maxNum)
+						break;
+				}
+
+				if (listNew.size() >= maxNum)
+					break;
+			}
+		}
+
+		// 鍒犻櫎涓嶆弧瓒虫潯浠�
+		if (listdel.size() > 0) {
+			for (FreeGoodsCoupon freeGoods : listdel) {
+				freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType());
+			}
+		}
+	}
+
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/job/goods/PullNewGoodsJob.java b/fanli/src/main/java/com/yeshi/fanli/job/goods/PullNewGoodsJob.java
new file mode 100644
index 0000000..17801df
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/job/goods/PullNewGoodsJob.java
@@ -0,0 +1,73 @@
+package com.yeshi.fanli.job.goods;
+
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import com.yeshi.fanli.dto.taobao.haodanku.HDKGoodsListResultDTO;
+import com.yeshi.fanli.entity.goods.PullNewGoods;
+import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
+import com.yeshi.fanli.service.inter.goods.PullNewGoodsService;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.taobao.HaoDanKuApiUtil;
+
+@Component
+public class PullNewGoodsJob {
+
+	@Resource
+	private PullNewGoodsService pullNewGoodsService;
+
+	/**
+	 * 鎷夋柊鍟嗗搧
+	 */
+	@Scheduled(cron = "0 30 1 * * ? ")
+	private void addPullNewGoods() {
+		if (!Constant.IS_TASK) {
+			return;
+		}
+			
+		Integer array[] = {1,2,3,4,5,6,7,8,9,10,11,12,15};
+		for (Integer catId: array) {
+			Integer minId = 1;
+			while (minId != null) {
+				HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().getHighitems(minId, 100, catId);
+				if (dto == null || dto.getMinId() == null) {
+					break;
+				}
+				
+				minId = dto.getMinId();
+				List<HDKGoodsDetail> goodsList = dto.getGoodsList();
+				if (goodsList == null || goodsList.size() == 0) {
+					break;
+				}
+
+				for (HDKGoodsDetail goods : goodsList) {
+					// 浣i噾姣斾緥澶т簬50%
+					if (goods.getTkrates() == null || goods.getTkrates() < 50)
+						continue;
+					// 鏄惁瀛樺湪鍒�
+					if (goods.getCouponmoney() == null || goods.getCouponmoney() <= 0)
+						continue;
+					// 鍟嗗搧鍒稿悗浠峰ぇ浜�9.9鍏�
+					if (goods.getItemendprice() == null || goods.getItemendprice() <= 9.9)
+						continue;
+
+					PullNewGoods pullNewGoods = new PullNewGoods();
+					try {
+						PropertyUtils.copyProperties(pullNewGoods, goods);
+					} catch (Exception e) {
+						e.printStackTrace();
+						continue;
+					}
+					pullNewGoodsService.saveGoods(pullNewGoods);
+				}
+			}
+		}
+
+	}
+
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/FreeGoodsCouponServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/FreeGoodsCouponServiceImpl.java
new file mode 100644
index 0000000..e3a2f3e
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/FreeGoodsCouponServiceImpl.java
@@ -0,0 +1,69 @@
+package com.yeshi.fanli.service.impl.goods;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+
+import com.yeshi.fanli.dao.goods.FreeGoodsCouponDao;
+import com.yeshi.fanli.entity.goods.FreeGoodsCoupon;
+import com.yeshi.fanli.service.inter.goods.FreeGoodsCouponService;
+import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
+import com.yeshi.fanli.util.RedisManager;
+import com.yeshi.fanli.vo.goods.GoodsDetailVO;
+
+@Service
+public class FreeGoodsCouponServiceImpl implements FreeGoodsCouponService {
+	
+	@Resource
+	private FreeGoodsCouponDao freeGoodsCouponDao;
+	
+	@Resource
+	private RedisManager redisManager;
+	
+	@Resource
+	private HongBaoManageService hongBaoManageService;
+
+	@Resource
+	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
+
+	
+	@Override
+	public boolean saveFreeGoods(GoodsDetailVO detailVO) {
+		if (detailVO == null) {
+			return false;
+		}
+		
+		String id = detailVO.getGoodsType() + "#_#" + detailVO.getGoodsId();
+		FreeGoodsCoupon freeGoods = new FreeGoodsCoupon();
+		freeGoods.setId(id);
+		freeGoods.setGoodsId(detailVO.getGoodsId());
+		freeGoods.setGoodsType(detailVO.getGoodsType());
+		freeGoods.setGoods(detailVO);
+		freeGoods.setCreateTime(new Date());
+		freeGoods.setUpdateTime(new Date());
+		freeGoodsCouponDao.save(freeGoods);
+		return true;
+	}
+	
+	
+	@Override
+	public void delete(String goodsId, Integer goodsType) {
+		freeGoodsCouponDao.delete(goodsId + "#_#" + goodsType);
+	}
+	
+	
+	@Override
+	public List<FreeGoodsCoupon> listByType(int start, int count, Integer goodsType) {
+		return freeGoodsCouponDao.listByType(start,count, goodsType);
+	}
+	
+	@Override
+	public long countByType(Integer goodsType) {
+		return freeGoodsCouponDao.countByType(goodsType);
+	}
+ 
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/PullNewGoodsServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/PullNewGoodsServiceImpl.java
new file mode 100644
index 0000000..62b9d91
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/PullNewGoodsServiceImpl.java
@@ -0,0 +1,81 @@
+package com.yeshi.fanli.service.impl.goods;
+
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.springframework.stereotype.Service;
+
+import com.yeshi.fanli.dao.goods.PullNewGoodsDao;
+import com.yeshi.fanli.entity.goods.PullNewGoods;
+import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
+import com.yeshi.fanli.service.inter.goods.PullNewGoodsService;
+import com.yeshi.fanli.util.taobao.HaoDanKuApiUtil;
+
+@Service
+public class PullNewGoodsServiceImpl implements PullNewGoodsService {
+	
+	@Resource
+	private PullNewGoodsDao pullNewGoodsDao;
+	
+	@Override
+	public void saveGoods(PullNewGoods pullNewGoods) {
+		if (pullNewGoods == null) {
+			return;
+		}
+		pullNewGoodsDao.save(pullNewGoods);
+	}
+	
+	@Override
+	public List<PullNewGoods> listQuery(int start, int count) {
+		return pullNewGoodsDao.listQuery(start, count);
+	}
+
+	@Override
+	public long countQuery() {
+		return pullNewGoodsDao.countQuery();
+	}
+	
+	
+	@Override
+	public void updateGoods(HDKGoodsDetail goods) {
+		if (goods == null)
+			return;
+		
+		List<PullNewGoods> list = pullNewGoodsDao.getByItemid(goods.getItemid());
+		if (list == null || list.size() == 0)
+			return;
+		
+		// 浣i噾姣斾緥澶т簬50%
+		if (goods.getTkrates() == null || goods.getTkrates() < 50)
+			return;
+		// 鏄惁瀛樺湪鍒�
+		if (goods.getCouponmoney() == null || goods.getCouponmoney() <= 0)
+			return;
+		// 鍟嗗搧鍒稿悗浠峰ぇ浜�9.9鍏�
+		if (goods.getItemendprice() == null || goods.getItemendprice() <= 9.9)
+			return;
+		
+		PullNewGoods pullNewGoods = new PullNewGoods();
+		try {
+			PropertyUtils.copyProperties(pullNewGoods, goods);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return;
+		}
+		pullNewGoodsDao.save(pullNewGoods);
+	}
+	
+	
+	@Override
+	public void deleteGoods(List<Long> list) {
+		if (list == null || list.size() == 0)
+			return;
+		
+		for (Long itemid: list) {
+			pullNewGoodsDao.deleteByItemid(itemid);
+		}
+	}
+	
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
index 6db986e..eaeedc7 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
@@ -467,7 +467,7 @@
 	@Override
 	@RequestSerializableByKeyService(key = "#orderUid")
 	@Transactional(rollbackFor = Exception.class)
-	public void winRedPackByOrder(Long orderUid, String orderNo, Integer source) {
+	public void winRedPackByOrder(Long orderUid, String orderNo, Integer source, Date downTime) {
 		if (orderUid == null || StringUtil.isNullOrEmpty(orderNo)) {
 			return;
 		}
@@ -476,20 +476,29 @@
 		UserInfoRegister register = userInfoRegisterService.selectByPrimaryKey(orderUid);
 		if (register == null) 
 			return;
-		// 娉ㄥ唽48灏忔椂 + 浠ュ唴
+		// 娉ㄥ唽48灏忔椂 浠ュ唴 :鏂颁汉
 		long registerTime = register.getCreateTime().getTime();
-		
+		// 48灏忔椂闄愬埗
+		if (downTime.getTime() < registerTime || downTime.getTime() > registerTime + 1000*60*60*48)
+			return;
 		
 		// 鏄惁瀛樺湪涓婁笅绾у叧绯�
 		ThreeSale threeSale = threeSaleSerivce.getByWorkerId(orderUid);
 		if (threeSale == null)
 			return;
-
 		Long bossId = threeSale.getBoss().getId();
 		if (bossId == null)
 			return;
 		
-		// 璇ラ個璇锋槸鍚﹀凡棰嗗彇
+		// 灏忎簬2.1.3鐗堟湰涓嶅鍔�
+		UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
+		if (activeLog == null)
+			return;
+		if (!VersionUtil.greaterThan_2_1_3("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
+				activeLog.getVersionCode()))
+			return;
+		
+		// 璇ラ個璇锋槸鍚﹀凡娣诲姞
 		RedPackWinInvite threeStage = redPackWinInviteMapper.getByUidAndTeamUid(bossId, orderUid);
 		if (threeStage != null)
 			return;
@@ -500,27 +509,15 @@
 			return;
 		}
 		
-		// 48灏忔椂鍐呰鍗�
-		long spaceTime = 1000 * 60 * 48;
-		Long succeedTime = threeSale.getSucceedTime();
-	    Date thirdCreateTime = list.get(0).getThirdCreateTime();
-	    if (thirdCreateTime == null || thirdCreateTime.getTime() > succeedTime + spaceTime) {
-	    	return;
-	    }
-		
 	    // 鍟嗗搧姣斾緥闄愬埗
 	    BigDecimal limitRate = new BigDecimal(redPackConfigService.getValueByKey("goods_reate_limit"));
 	    BigDecimal limitPayMent = new BigDecimal(redPackConfigService.getValueByKey("goods_pay_ment_limit"));
-	    
 	    boolean satisfy = false;
 		// 閬嶅巻鏄惁瀛樺湪绗﹀悎鐩稿簲鍟嗗搧
 		for (CommonOrder commonOrder: list) {
 			// 閭�璇峰叧绯讳箣鍚�
-			long downTime = commonOrder.getThirdCreateTime().getTime();
-			if (downTime < threeSale.getCreateTime())
-				continue;
-			// 48灏忔椂闄愬埗
-			if (downTime < registerTime || downTime > registerTime + 1000*60*60*48)
+			long thirdTime = commonOrder.getThirdCreateTime().getTime();
+			if (thirdTime < threeSale.getCreateTime())
 				continue;
 			// 浠樻閲戦闄愬埗
 			BigDecimal payment = commonOrder.getPayment();
@@ -556,19 +553,148 @@
 		winInvite.setType(RedPackWinInviteTypeEnum.inviteDownOrder);
 		winInvite.setIdentifyCode(StringUtil.Md5(RedPackWinInviteTypeEnum.inviteDownOrder.name() + ":" + orderUid));
 		redPackWinInviteMapper.insertSelective(winInvite);
+	}
+	
+	@Override
+	@RequestSerializableByKeyService(key = "#orderUid")
+	public boolean verifyOrder(Long orderUid, String orderNo, Integer source, Date downTime) {
+	    boolean satisfy = false;
+		// 娉ㄥ唽鏃堕棿
+		UserInfoRegister register = userInfoRegisterService.selectByPrimaryKey(orderUid);
+		if (register == null) 
+			return satisfy;
+		// 娉ㄥ唽48灏忔椂 浠ュ唴:鏂颁汉
+		long registerTime = register.getCreateTime().getTime();
+		// 48灏忔椂闄愬埗
+		if (downTime.getTime() < registerTime || downTime.getTime() > registerTime + 1000*60*60*48)
+			return satisfy;
 		
+		// 鏄惁宸插鍔�
+		List<UserSystemCoupon> coupons = userSystemCouponService.getUserCouponBySource(orderUid, UserSystemCoupon.SOURCE_PULL_NEW);
+		if (coupons != null && coupons.size() > 0) {
+			return satisfy;
+		}
+		
+		// 鏄惁瀛樺湪涓婁笅绾у叧绯�
+		ThreeSale threeSale = threeSaleSerivce.getByWorkerId(orderUid);
+		if (threeSale == null)
+			return satisfy;
+		Long bossId = threeSale.getBoss().getId();
+		if (bossId == null)
+			return satisfy;
+		
+		// 灏忎簬2.1.3鐗堟湰涓嶅鍔�
+		UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(orderUid);
+		if (activeLog == null)
+			return satisfy;
+		if (!VersionUtil.greaterThan_2_1_3("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
+				activeLog.getVersionCode()))
+			return satisfy;
+		
+		// 鏌ヨ璁㈠崟
+		List<CommonOrder> list = commonOrderService.getByOrderNo(orderUid, orderNo);
+		if (list == null || list.size() ==0)
+			return satisfy;
+		
+	    // 鍟嗗搧姣斾緥闄愬埗
+	    BigDecimal limitRate = new BigDecimal(redPackConfigService.getValueByKey("goods_reate_limit"));
+	    BigDecimal limitPayMent = new BigDecimal(redPackConfigService.getValueByKey("goods_pay_ment_limit"));
+		// 閬嶅巻鏄惁瀛樺湪绗﹀悎鐩稿簲鍟嗗搧
+		for (CommonOrder commonOrder: list) {
+			// 閭�璇峰叧绯讳箣鍚�
+			long thirdTime = commonOrder.getThirdCreateTime().getTime();
+			if (thirdTime < threeSale.getCreateTime())
+				continue;
+			// 浠樻閲戦闄愬埗
+			BigDecimal payment = commonOrder.getPayment();
+			if (payment == null || payment.compareTo(limitPayMent) < 0) 
+				continue;
+			
+			// 鍟嗗搧浣i噾姣斾緥闄愬埗
+			BigDecimal eIncome = commonOrder.geteIncome();
+			BigDecimal settlement = commonOrder.getSettlement();
+			if(eIncome == null || settlement == null) {
+				continue;
+			}
+			BigDecimal rete = MoneyBigDecimalUtil.div(eIncome, settlement);
+			if (rete.compareTo(limitRate) >= 0) {
+				satisfy = true;
+				break;
+			}
+		}
+		
+		return satisfy;
+	}
+
+	@Override
+	@RequestSerializableByKeyService(key = "#orderUid")
+	@Transactional(rollbackFor = Exception.class)
+	public void winFreeCoupon(Long orderUid, String orderNo, Integer source, Date downTime) {
+		if (orderUid == null || StringUtil.isNullOrEmpty(orderNo)) {
+			return;
+		}
+		
+		// 娉ㄥ唽鏃堕棿
+		UserInfoRegister register = userInfoRegisterService.selectByPrimaryKey(orderUid);
+		if (register == null) 
+			return;
+		// 娉ㄥ唽48灏忔椂 浠ュ唴:鏂颁汉
+		long registerTime = register.getCreateTime().getTime();
+		// 48灏忔椂闄愬埗
+		if (downTime.getTime() < registerTime || downTime.getTime() > registerTime + 1000*60*60*48)
+			return;
+		
+		// 鏄惁宸插鍔�
+		List<UserSystemCoupon> coupons = userSystemCouponService.getUserCouponBySource(orderUid, UserSystemCoupon.SOURCE_PULL_NEW);
+		if (coupons != null && coupons.size() > 0) {
+			return;
+		}
+		
+		// 鏌ヨ璁㈠崟
+		List<CommonOrder> list = commonOrderService.getByOrderNo(orderUid, orderNo);
+		if (list == null || list.size() ==0) {
+			return;
+		}
+		
+	    // 鍟嗗搧姣斾緥闄愬埗
+	    BigDecimal limitRate = new BigDecimal(redPackConfigService.getValueByKey("goods_reate_limit"));
+	    BigDecimal limitPayMent = new BigDecimal(redPackConfigService.getValueByKey("goods_pay_ment_limit"));
+	    
+	    boolean satisfy = false;
+		// 閬嶅巻鏄惁瀛樺湪绗﹀悎鐩稿簲鍟嗗搧
+		for (CommonOrder commonOrder: list) {
+			// 浠樻閲戦闄愬埗
+			BigDecimal payment = commonOrder.getPayment();
+			if (payment == null || payment.compareTo(limitPayMent) < 0) 
+				continue;
+			
+			// 鍟嗗搧浣i噾姣斾緥闄愬埗
+			BigDecimal eIncome = commonOrder.geteIncome();
+			BigDecimal settlement = commonOrder.getSettlement();
+			if(eIncome == null || settlement == null) {
+				continue;
+			}
+			BigDecimal rete = MoneyBigDecimalUtil.div(eIncome, settlement);
+			if (rete.compareTo(limitRate) >= 0) {
+				satisfy = true;
+				break;
+			}
+		}
+		
+		if (!satisfy) {
+			return;
+		}
 		
 		// 璧犻�佽喘涔拌�呬竴寮犲厤鍗曞埜
 		try {
-			userSystemCouponService.freeCouponWinBySystem(orderUid, CouponTypeEnum.freeCouponBuy, UserSystemCoupon.SOURCE_EXCHANGE,
-					1, true, 2);
+			userSystemCouponService.freeCouponWinBySystem(orderUid, CouponTypeEnum.freeCouponBuy, 
+					UserSystemCoupon.SOURCE_PULL_NEW, 1, true, 2);
 		} catch (UserSystemCouponException e) {
 			e.printStackTrace();
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
 	}
-	
 	
 	@Override
 	public List<Long> listWinUid(int start, int count) {
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/inter/goods/FreeGoodsCouponService.java b/fanli/src/main/java/com/yeshi/fanli/service/inter/goods/FreeGoodsCouponService.java
new file mode 100644
index 0000000..f783ed1
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/service/inter/goods/FreeGoodsCouponService.java
@@ -0,0 +1,38 @@
+package com.yeshi.fanli.service.inter.goods;
+
+import java.util.List;
+
+import com.yeshi.fanli.entity.goods.FreeGoodsCoupon;
+import com.yeshi.fanli.vo.goods.GoodsDetailVO;
+
+public interface FreeGoodsCouponService {
+
+	
+	/**
+	 * 淇濆瓨鎴栨洿鏂�
+	 * @param detailVO
+	 * @return
+	 */
+	public boolean saveFreeGoods(GoodsDetailVO detailVO);
+
+	/**
+	 * 鏍规嵁绫诲瀷杩涜鏌ヨ
+	 * @param start
+	 * @param count
+	 * @param goodsType
+	 * @return
+	 */
+	public List<FreeGoodsCoupon> listByType(int start, int count, Integer goodsType);
+
+	/**
+	 * 鍒犻櫎鍟嗗搧
+	 * @param goodsId
+	 * @param goodsType
+	 */
+	public void delete(String goodsId, Integer goodsType);
+
+	
+	public long countByType(Integer goodsType);
+
+
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/inter/goods/PullNewGoodsService.java b/fanli/src/main/java/com/yeshi/fanli/service/inter/goods/PullNewGoodsService.java
new file mode 100644
index 0000000..a3b8e96
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/service/inter/goods/PullNewGoodsService.java
@@ -0,0 +1,29 @@
+package com.yeshi.fanli.service.inter.goods;
+
+import java.util.List;
+
+import com.yeshi.fanli.entity.goods.PullNewGoods;
+import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
+
+public interface PullNewGoodsService {
+
+
+	public void saveGoods(PullNewGoods pullNewGoods);
+
+	public List<PullNewGoods> listQuery(int start, int count);
+
+	public long countQuery();
+
+	/**
+	 * 鏇存柊鍟嗗搧
+	 * @param itemid 鍟嗗搧id
+	 */
+	public void updateGoods(HDKGoodsDetail goods);
+
+	/**
+	 * 鍒犻櫎鍟嗗搧
+	 * @param itemid 鍟嗗搧id
+	 */
+	public void deleteGoods(List<Long> list);
+
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java b/fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java
index e966511..78b7b6b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java
@@ -100,7 +100,7 @@
 	 * @param orderNo
 	 * @param source
 	 */
-	public void winRedPackByOrder(Long orderUid, String orderNo, Integer source);
+	public void winRedPackByOrder(Long orderUid, String orderNo, Integer source, Date downTime);
 
 	/**
 	 * 鏌ヨ涓婃湀鐢ㄦ埛id
@@ -118,7 +118,7 @@
 	 * @return
 	 */
 
-	long countLastMonthByUid(Long uid);
+	public long countLastMonthByUid(Long uid);
 	
 	/**
 	 * 鏌ヨ涓婃湀鏁版嵁
@@ -126,7 +126,7 @@
 	 * @param count
 	 * @return
 	 */
-	List<RedPackWinInvite> listLastMonthByUid(int start, int count, Long uid);
+	public List<RedPackWinInvite> listLastMonthByUid(int start, int count, Long uid);
 
 	/**
 	 * 绾㈠寘鍒拌处
@@ -134,6 +134,25 @@
 	 * @param money
 	 * @param date
 	 */
-	void arriveMoney(Long uid, BigDecimal money, Date date) throws Exception;
+	public void arriveMoney(Long uid, BigDecimal money, Date date) throws Exception;
+
+	/**
+	 * 娲诲姩鍏嶅崟鍒�
+	 * @param orderUid
+	 * @param orderNo
+	 * @param source
+	 * @param downTime
+	 */
+	public void winFreeCoupon(Long orderUid, String orderNo, Integer source, Date downTime);
+
+	/**
+	 * 楠岃瘉鏄惁婊¤冻寤惰繜娑堟伅
+	 * @param orderUid
+	 * @param orderNo
+	 * @param source
+	 * @param downTime
+	 * @return
+	 */
+	public boolean verifyOrder(Long orderUid, String orderNo, Integer source, Date downTime);
 	
 }
diff --git a/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java b/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java
index 5416749..89e7090 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java
@@ -50,21 +50,30 @@
 
 		if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) {
 			if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatistic.name())) {// 璁㈠崟缁�
-				OrderMQMsg orderMQMsg = new Gson().fromJson(new String(message.getBody()), OrderMQMsg.class);
-				// 鍙戦��24灏忔椂寤舵椂娑堟伅
-				// 娴嬭瘯鏃跺彂閫�
-				int hour = 48;
-				if (Constant.IS_TEST) {
-					hour = 1;
+				OrderMQMsg mqMsg = new Gson().fromJson(new String(message.getBody()), OrderMQMsg.class);
+				
+				try {// 閭�璇峰鍔�
+					redPackWinInviteService.winRedPackByOrder(mqMsg.getUid(), mqMsg.getOrderId(), mqMsg.getType(), mqMsg.getPlaceTime());
+				} catch (Exception e) {
+					LogHelper.errorDetailInfo(e);
 				}
-				orderMQMsg.setDelayHour(hour);
-				Message msg = new Message(message.getTopic(), OrderTopicTagEnum.orderStatisticDelay.name(),
-						new Gson().toJson(orderMQMsg).getBytes());
-				if (orderMQMsg.getStaticticDate().getTime() + 1000 * 60 * 60L * hour > System.currentTimeMillis())// 鏃堕棿鏄惁宸茬粡杩囦簡
-					msg.setStartDeliverTime(orderMQMsg.getStaticticDate().getTime() + 1000 * 60 * 60L * hour);
-				else
-					msg.setStartDeliverTime(System.currentTimeMillis() + 1000 * 60);
-				producer.send(msg);
+				
+				boolean verifyOrder = redPackWinInviteService.verifyOrder(mqMsg.getUid(), mqMsg.getOrderId(), mqMsg.getType(), mqMsg.getPlaceTime());
+				if (verifyOrder) {
+					// 鍙戦��48灏忔椂寤舵椂娑堟伅
+					int hour = 48;
+					if (Constant.IS_TEST) {
+						hour = 1;
+					}
+					mqMsg.setDelayHour(hour);
+					Message msg = new Message(message.getTopic(), OrderTopicTagEnum.orderStatisticDelay.name(),
+							new Gson().toJson(mqMsg).getBytes());
+					if (mqMsg.getStaticticDate().getTime() + 1000 * 60 * 60L * hour > System.currentTimeMillis())// 鏃堕棿鏄惁宸茬粡杩囦簡
+						msg.setStartDeliverTime(mqMsg.getStaticticDate().getTime() + 1000 * 60 * 60L * hour);
+					else
+						msg.setStartDeliverTime(System.currentTimeMillis() + 1000 * 60);
+					producer.send(msg);
+				}
 				return Action.CommitMessage;
 			} else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatisticDelay.name())) {// 璁㈠崟缁熻
 				OrderMQMsg mqMsg = new Gson().fromJson(new String(message.getBody()), OrderMQMsg.class);
@@ -74,8 +83,8 @@
 				}
 
 				if (mqMsg.getDelayHour() == hour) {
-					try {// 閭�璇峰鍔�
-						redPackWinInviteService.winRedPackByOrder(mqMsg.getUid(), mqMsg.getOrderId(), mqMsg.getType());
+					try {
+						redPackWinInviteService.winFreeCoupon(mqMsg.getUid(), mqMsg.getOrderId(), mqMsg.getType(), mqMsg.getPlaceTime());
 					} catch (Exception e) {
 						LogHelper.errorDetailInfo(e);
 						return Action.ReconsumeLater;
diff --git a/fanli/src/main/java/com/yeshi/fanli/vo/user/PullNewRuleNumVO.java b/fanli/src/main/java/com/yeshi/fanli/vo/user/PullNewRuleNumVO.java
new file mode 100644
index 0000000..d17848b
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/vo/user/PullNewRuleNumVO.java
@@ -0,0 +1,32 @@
+package com.yeshi.fanli.vo.user;
+
+public class PullNewRuleNumVO {
+	private String numRange;
+	private String rewardDesc;
+
+	
+	public PullNewRuleNumVO() {}
+	
+	public PullNewRuleNumVO(String numRange, String rewardDesc) {
+		this.numRange = numRange;
+		this.rewardDesc = rewardDesc;
+	}
+	
+	
+	public String getNumRange() {
+		return numRange;
+	}
+
+	public void setNumRange(String numRange) {
+		this.numRange = numRange;
+	}
+
+	public String getRewardDesc() {
+		return rewardDesc;
+	}
+
+	public void setRewardDesc(String rewardDesc) {
+		this.rewardDesc = rewardDesc;
+	}
+
+}
diff --git a/fanli/src/main/java/com/yeshi/fanli/vo/user/PullNewRuleVO.java b/fanli/src/main/java/com/yeshi/fanli/vo/user/PullNewRuleVO.java
new file mode 100644
index 0000000..0854ee9
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/vo/user/PullNewRuleVO.java
@@ -0,0 +1,63 @@
+package com.yeshi.fanli.vo.user;
+
+import java.util.List;
+
+public class PullNewRuleVO {
+	private String ruleName;
+	private String newTitle;
+	private String newRule;
+
+	private String inviterTitle;
+	private String inviterRule;
+
+	private List<PullNewRuleNumVO> list;
+
+	public String getNewTitle() {
+		return newTitle;
+	}
+
+	public void setNewTitle(String newTitle) {
+		this.newTitle = newTitle;
+	}
+
+	public String getNewRule() {
+		return newRule;
+	}
+
+	public void setNewRule(String newRule) {
+		this.newRule = newRule;
+	}
+
+	public String getInviterTitle() {
+		return inviterTitle;
+	}
+
+	public void setInviterTitle(String inviterTitle) {
+		this.inviterTitle = inviterTitle;
+	}
+
+	public String getInviterRule() {
+		return inviterRule;
+	}
+
+	public void setInviterRule(String inviterRule) {
+		this.inviterRule = inviterRule;
+	}
+
+	public List<PullNewRuleNumVO> getList() {
+		return list;
+	}
+
+	public void setList(List<PullNewRuleNumVO> list) {
+		this.list = list;
+	}
+
+	public String getRuleName() {
+		return ruleName;
+	}
+
+	public void setRuleName(String ruleName) {
+		this.ruleName = ruleName;
+	}
+
+}
diff --git a/fanli/src/main/resource/image/invite/blks_ico.png b/fanli/src/main/resource/image/invite/blks_ico.png
new file mode 100644
index 0000000..a27e414
--- /dev/null
+++ b/fanli/src/main/resource/image/invite/blks_ico.png
Binary files differ
diff --git a/fanli/src/main/resource/image/invite/pull_new.png b/fanli/src/main/resource/image/invite/pull_new.png
new file mode 100644
index 0000000..f1b8fca
--- /dev/null
+++ b/fanli/src/main/resource/image/invite/pull_new.png
Binary files differ
diff --git a/fanli/src/main/resource/image/invite/qr_code_frame.png b/fanli/src/main/resource/image/invite/qr_code_frame.png
new file mode 100644
index 0000000..f30c0ee
--- /dev/null
+++ b/fanli/src/main/resource/image/invite/qr_code_frame.png
Binary files differ
diff --git a/utils/src/main/java/org/yeshi/utils/DateUtil.java b/utils/src/main/java/org/yeshi/utils/DateUtil.java
index 915a83b..4d4978c 100644
--- a/utils/src/main/java/org/yeshi/utils/DateUtil.java
+++ b/utils/src/main/java/org/yeshi/utils/DateUtil.java
@@ -635,9 +635,53 @@
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 		return sdf.format(cal.getTime());
 	}
+	
+	public static int getCurrentDate() {
+		Calendar cal = Calendar.getInstance();
+		return cal.get(Calendar.DATE);
+	}
+	
+	public static int getCurrentMonth() {
+		Calendar cal = Calendar.getInstance();
+		return cal.get(Calendar.MONTH) + 1;
+	}
+	
+	public static String getCurrentMonthChinese() {
+		Calendar cal = Calendar.getInstance();
+		int month = cal.get(Calendar.MONTH) + 1;
+		
+		switch(month) {
+			case 1:
+				return "涓�";
+			case 2:
+				return "浜�";
+			case 3:
+				return "涓�";
+			case 4:
+				return "鍥�";
+			case 5:
+				return "浜�";
+			case 6:
+				return "鍏�";
+			case 7:
+				return "涓�";
+			case 8:
+				return "鍏�";
+			case 9:
+				return "涔�";
+			case 10:
+				return "鍗�";
+			case 11:
+				return "鍗佷竴";
+			case 12:
+				return "鍗佷簩";
+			default:
+				return "涓�";
+		}
+	}
 
 	public static void main(String[] args) throws ParseException {
-		System.out.println(getMonthSpace("2012-02", "2012-02"));
+		System.out.println(getCurrentDate());
 	}
 
 }
\ No newline at end of file

--
Gitblit v1.8.0