Selaa lähdekoodia

双十一活动 说明:
结算赠品:按照顺序结算时展示出赠品,赠品可以按顺序选择赠品,赠品含有库存设置。
秒杀:秒杀支持按照时间显示秒杀的价格。

wangxiaoming 5 vuotta sitten
vanhempi
commit
392185f2aa
51 muutettua tiedostoa jossa 2249 lisäystä ja 369 poistoa
  1. 10 0
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/activity/ActivityDate.java
  2. 11 0
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/cart/CartDto.java
  3. 0 83
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/cart/SettlementGift.java
  4. 53 0
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/GiftCondition.java
  5. 123 0
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/GiftPool.java
  6. 52 0
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/ItemGift.java
  7. 115 0
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/Promotions.java
  8. 95 0
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/SettlementGift.java
  9. 83 0
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/Spike.java
  10. 11 0
      iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/order/OrderItem.java
  11. 25 0
      iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/GiftConditionService.java
  12. 38 0
      iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/GiftPoolService.java
  13. 45 0
      iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/ItemGiftService.java
  14. 30 0
      iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/PromotionsService.java
  15. 9 14
      iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/cart/SettlementGiftService.java
  16. 31 0
      iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/SpikeService.java
  17. 276 29
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/ActivityUtil.java
  18. 33 4
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/CartServiceImpl.java
  19. 0 56
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/SettlementGiftServiceImpl.java
  20. 8 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/dao/CartDao.java
  21. 9 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/dao/impl/CartDaoImpl.java
  22. 37 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/GiftConditionServiceImpl.java
  23. 59 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/GiftPoolServiceImpl.java
  24. 68 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/ItemGiftServiceImpl.java
  25. 68 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/PromotionsServiceImpl.java
  26. 77 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/SettlementGiftServiceImpl.java
  27. 44 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/SpikeServiceImpl.java
  28. 25 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/GiftConditionMapper.java
  29. 39 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/GiftPoolMapper.java
  30. 44 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/ItemGiftMapper.java
  31. 9 1
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/OrderMapper.java
  32. 30 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/PromotionsMapper.java
  33. 10 13
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/SettlementGiftMapper.java
  34. 32 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/SpikeMapper.java
  35. 1 1
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/adminOrderMapper.xml
  36. 17 2
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/cartMapper.xml
  37. 1 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/couponItemMapper.xml
  38. 38 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/giftConditionMapper.xml
  39. 83 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/giftPoolMapper.xml
  40. 91 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/itemGiftMapper.xml
  41. 42 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/orderMapper.xml
  42. 5 5
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/productInfoMapper.xml
  43. 65 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/promotionsMapper.xml
  44. 65 64
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/settlementGiftMapper.xml
  45. 63 0
      iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/spikeMapper.xml
  46. 27 12
      iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/cart/CartHandlers.java
  47. 35 0
      iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/cart/ProductInfoHandler.java
  48. 57 0
      iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/coupon/CouponTypeHandler.java
  49. 32 0
      iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/home/HomeHandler.java
  50. 16 84
      iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/order/OrderHandler.java
  51. 12 1
      iamberry-wechat-web/src/main/resources/iamberry-wechat-service-mybatis.xml

+ 10 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/activity/ActivityDate.java

@@ -1,6 +1,7 @@
 package com.iamberry.wechat.core.entity.activity;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.iamberry.wechat.core.entity.eo.Promotions;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
@@ -27,6 +28,8 @@ public class ActivityDate implements Serializable{
     //说明
     private String remark;
 
+    //优惠活动
+    private Promotions promotions;
 
     public Date getBeginDate() {
         return beginDate;
@@ -68,4 +71,11 @@ public class ActivityDate implements Serializable{
         this.remark = remark;
     }
 
+    public Promotions getPromotions() {
+        return promotions;
+    }
+
+    public void setPromotions(Promotions promotions) {
+        this.promotions = promotions;
+    }
 }

+ 11 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/cart/CartDto.java

@@ -1,5 +1,6 @@
 package com.iamberry.wechat.core.entity.cart;
 
+import com.iamberry.wechat.core.entity.eo.ItemGift;
 import com.iamberry.wechat.core.entity.product.SalesUserGift;
 
 import java.io.Serializable;
@@ -56,6 +57,8 @@ public class CartDto implements Serializable{
 
 	private List<SalesUserGift> salesUserGiftList; //赠品集合
 
+	private List<ItemGift> itemGiftList;		//订单项关联赠品
+
 	public Integer getCartIsSource() {
 		return cartIsSource;
 	}
@@ -208,4 +211,12 @@ public class CartDto implements Serializable{
 	public void setColorStatus(Integer colorStatus) {
 		this.colorStatus = colorStatus;
 	}
+
+	public List<ItemGift> getItemGiftList() {
+		return itemGiftList;
+	}
+
+	public void setItemGiftList(List<ItemGift> itemGiftList) {
+		this.itemGiftList = itemGiftList;
+	}
 }

+ 0 - 83
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/cart/SettlementGift.java

@@ -1,83 +0,0 @@
-package com.iamberry.wechat.core.entity.cart;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- *  结算赠品类
- * @author Administrator
- * @Date 2019-05-23
- */
-public class SettlementGift implements  Serializable{
-    private static final long serialVersionUID = -1083848908128493893L;
-    //结算赠品Id
-    private Integer settGiftId;
-    //满足颜色id
-    private Integer settGiftFillColorId;
-    //
-    private Integer settGiftGiftColorId;
-    //价格
-    private Integer settGiftPrice;
-    //赠送数量
-    private Integer settGiftNum;
-    //1.使用中 2.未使用
-    private Integer settGiftStatus;
-    //创建时间'
-    private Date settGiftCreateTime;
-
-    public Integer getSettGiftId(){
-        return settGiftId;
-    }
-
-    public void setSettGiftId(Integer  settGiftId){
-        this.settGiftId=settGiftId;
-    }
-
-    public Integer getSettGiftFillColorId(){
-        return settGiftFillColorId;
-    }
-
-    public void setSettGiftFillColorId(Integer  settGiftFillColorId){
-        this.settGiftFillColorId=settGiftFillColorId;
-    }
-
-    public Integer getSettGiftGiftColorId(){
-        return settGiftGiftColorId;
-    }
-
-    public void setSettGiftGiftColorId(Integer  settGiftGiftColorId){
-        this.settGiftGiftColorId=settGiftGiftColorId;
-    }
-
-    public Integer getSettGiftPrice(){
-        return settGiftPrice;
-    }
-
-    public void setSettGiftPrice(Integer  settGiftPrice){
-        this.settGiftPrice=settGiftPrice;
-    }
-
-    public Integer getSettGiftNum(){
-        return settGiftNum;
-    }
-
-    public void setSettGiftNum(Integer  settGiftNum){
-        this.settGiftNum=settGiftNum;
-    }
-
-    public Integer getSettGiftStatus(){
-        return settGiftStatus;
-    }
-
-    public void setSettGiftStatus(Integer  settGiftStatus){
-        this.settGiftStatus=settGiftStatus;
-    }
-
-    public Date getSettGiftCreateTime(){
-        return settGiftCreateTime;
-    }
-
-    public void setSettGiftCreateTime(Date  settGiftCreateTime){
-        this.settGiftCreateTime=settGiftCreateTime;
-    }
-}

+ 53 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/GiftCondition.java

@@ -0,0 +1,53 @@
+package com.iamberry.wechat.core.entity.eo;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ *  赠品条件类
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public class GiftCondition  implements  Serializable{
+    private static final long serialVersionUID = -671237415967603102L;
+    //赠品条件id
+    private Integer giftConditionId;
+    //赠品id
+    private Integer settGiftId;
+    //满足颜色id
+    private Integer giftConditionFillColorId;
+    //创建时间'
+    private Date giftConditionCreateTime;
+
+    public Integer getGiftConditionId(){
+        return giftConditionId;
+    }
+
+    public void setGiftConditionId(Integer  giftConditionId){
+        this.giftConditionId=giftConditionId;
+    }
+
+    public Integer getSettGiftId(){
+        return settGiftId;
+    }
+
+    public void setSettGiftId(Integer  settGiftId){
+        this.settGiftId=settGiftId;
+    }
+
+    public Integer getGiftConditionFillColorId(){
+        return giftConditionFillColorId;
+    }
+
+    public void setGiftConditionFillColorId(Integer  giftConditionFillColorId){
+        this.giftConditionFillColorId=giftConditionFillColorId;
+    }
+
+    public Date getGiftConditionCreateTime(){
+        return giftConditionCreateTime;
+    }
+
+    public void setGiftConditionCreateTime(Date  giftConditionCreateTime){
+        this.giftConditionCreateTime=giftConditionCreateTime;
+    }
+}

+ 123 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/GiftPool.java

@@ -0,0 +1,123 @@
+package com.iamberry.wechat.core.entity.eo;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ *  赠品池类
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public class GiftPool  implements  Serializable{
+    private static final long serialVersionUID = 7148244471904713727L;
+    //赠品池id
+    private Integer giftPoolId;
+    //赠品id
+    private Integer settGiftId;
+    //赠送颜色id
+    private Integer giftPoolColorId;
+    //价格
+    private Integer giftPoolPrice;
+    //赠送数量
+    private Integer giftPoolNum;
+    //状态 1.使用中 2.未使用
+    private Integer giftPoolStatus;
+    //顺序
+    private Integer giftPoolSort;
+    //库存
+    private Integer giftPoolStock;
+    //关系 1:互斥 2:共用
+    private Integer giftPoolRelation;
+    //关系描述
+    private String giftPoolRelationDesc;
+    //创建时间'
+    private Date giftPoolCreateTime;
+
+    public Integer getGiftPoolId(){
+        return giftPoolId;
+    }
+
+    public void setGiftPoolId(Integer  giftPoolId){
+        this.giftPoolId=giftPoolId;
+    }
+
+    public Integer getSettGiftId(){
+        return settGiftId;
+    }
+
+    public void setSettGiftId(Integer  settGiftId){
+        this.settGiftId=settGiftId;
+    }
+
+    public Integer getGiftPoolColorId(){
+        return giftPoolColorId;
+    }
+
+    public void setGiftPoolColorId(Integer  giftPoolColorId){
+        this.giftPoolColorId=giftPoolColorId;
+    }
+
+    public Integer getGiftPoolPrice(){
+        return giftPoolPrice;
+    }
+
+    public void setGiftPoolPrice(Integer  giftPoolPrice){
+        this.giftPoolPrice=giftPoolPrice;
+    }
+
+    public Integer getGiftPoolNum(){
+        return giftPoolNum;
+    }
+
+    public void setGiftPoolNum(Integer  giftPoolNum){
+        this.giftPoolNum=giftPoolNum;
+    }
+
+    public Integer getGiftPoolStatus(){
+        return giftPoolStatus;
+    }
+
+    public void setGiftPoolStatus(Integer  giftPoolStatus){
+        this.giftPoolStatus=giftPoolStatus;
+    }
+
+    public Integer getGiftPoolSort(){
+        return giftPoolSort;
+    }
+
+    public void setGiftPoolSort(Integer  giftPoolSort){
+        this.giftPoolSort=giftPoolSort;
+    }
+
+    public Integer getGiftPoolStock(){
+        return giftPoolStock;
+    }
+
+    public void setGiftPoolStock(Integer  giftPoolStock){
+        this.giftPoolStock=giftPoolStock;
+    }
+
+    public Integer getGiftPoolRelation() {
+        return giftPoolRelation;
+    }
+
+    public void setGiftPoolRelation(Integer giftPoolRelation) {
+        this.giftPoolRelation = giftPoolRelation;
+    }
+
+    public String getGiftPoolRelationDesc() {
+        return giftPoolRelationDesc;
+    }
+
+    public void setGiftPoolRelationDesc(String giftPoolRelationDesc) {
+        this.giftPoolRelationDesc = giftPoolRelationDesc;
+    }
+
+    public Date getGiftPoolCreateTime(){
+        return giftPoolCreateTime;
+    }
+
+    public void setGiftPoolCreateTime(Date  giftPoolCreateTime){
+        this.giftPoolCreateTime=giftPoolCreateTime;
+    }
+}

+ 52 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/ItemGift.java

@@ -0,0 +1,52 @@
+package com.iamberry.wechat.core.entity.eo;
+
+import java.io.Serializable;
+
+/**
+ *  订单项关联赠品池类
+ * @author Administrator
+ * @Date 2019-10-29
+ */
+public class ItemGift  implements Serializable {
+    private static final long serialVersionUID = 1321211845089063931L;
+    //关联id
+    private Integer itemGiftId;
+    //订单项ID
+    private Integer itemId;
+    //赠品池ID
+    private Integer giftPoolId;
+    //数量'
+    private Integer itemGiftNum;
+
+    public Integer getItemGiftId(){
+        return itemGiftId;
+    }
+
+    public void setItemGiftId(Integer  itemGiftId){
+        this.itemGiftId=itemGiftId;
+    }
+
+    public Integer getItemId(){
+        return itemId;
+    }
+
+    public void setItemId(Integer  itemId){
+        this.itemId=itemId;
+    }
+
+    public Integer getGiftPoolId(){
+        return giftPoolId;
+    }
+
+    public void setGiftPoolId(Integer  giftPoolId){
+        this.giftPoolId=giftPoolId;
+    }
+
+    public Integer getItemGiftNum(){
+        return itemGiftNum;
+    }
+
+    public void setItemGiftNum(Integer  itemGiftNum){
+        this.itemGiftNum=itemGiftNum;
+    }
+}

+ 115 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/Promotions.java

@@ -0,0 +1,115 @@
+package com.iamberry.wechat.core.entity.eo;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ *  优惠活动类
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public class Promotions  implements  Serializable{
+    private static final long serialVersionUID = 8267100500015387060L;
+    //活动id
+    private Integer promotionsId;
+    //活动名称
+    private String promotionsName;
+    //类型 1:满减 2:满赠 3:秒杀
+    private Integer promotionsType;
+    //状态 1.使用中 2.未使用
+    private Integer promotionsStatus;
+    //活动开始时间
+    private Date promotionsBeginTime;
+    //活动结束时间
+    private Date promotionsEndTime;
+    //备注
+    private String promotionsDesc;
+    //创建时间'
+    private Date promotionsCreateTime;
+    //结算赠品
+    private List<SettlementGift> settlementGiftList = new ArrayList<>();
+    //结算赠品
+    private List<Spike> spikeList = new ArrayList<>();
+
+    public Integer getPromotionsId(){
+        return promotionsId;
+    }
+
+    public void setPromotionsId(Integer  promotionsId){
+        this.promotionsId=promotionsId;
+    }
+
+    public String getPromotionsName(){
+        return promotionsName;
+    }
+
+    public void setPromotionsName(String  promotionsName){
+        this.promotionsName=promotionsName;
+    }
+
+    public Integer getPromotionsType(){
+        return promotionsType;
+    }
+
+    public void setPromotionsType(Integer  promotionsType){
+        this.promotionsType=promotionsType;
+    }
+
+    public Integer getPromotionsStatus(){
+        return promotionsStatus;
+    }
+
+    public void setPromotionsStatus(Integer  promotionsStatus){
+        this.promotionsStatus=promotionsStatus;
+    }
+
+    public Date getPromotionsBeginTime(){
+        return promotionsBeginTime;
+    }
+
+    public void setPromotionsBeginTime(Date  promotionsBeginTime){
+        this.promotionsBeginTime=promotionsBeginTime;
+    }
+
+    public Date getPromotionsEndTime(){
+        return promotionsEndTime;
+    }
+
+    public void setPromotionsEndTime(Date  promotionsEndTime){
+        this.promotionsEndTime=promotionsEndTime;
+    }
+
+    public String getPromotionsDesc(){
+        return promotionsDesc;
+    }
+
+    public void setPromotionsDesc(String  promotionsDesc){
+        this.promotionsDesc=promotionsDesc;
+    }
+
+    public Date getPromotionsCreateTime(){
+        return promotionsCreateTime;
+    }
+
+    public void setPromotionsCreateTime(Date  promotionsCreateTime){
+        this.promotionsCreateTime=promotionsCreateTime;
+    }
+
+    public List<SettlementGift> getSettlementGiftList() {
+        return settlementGiftList;
+    }
+
+    public void setSettlementGiftList(List<SettlementGift> settlementGiftList) {
+        this.settlementGiftList = settlementGiftList;
+    }
+
+    public List<Spike> getSpikeList() {
+        return spikeList;
+    }
+
+    public void setSpikeList(List<Spike> spikeList) {
+        this.spikeList = spikeList;
+    }
+}

+ 95 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/SettlementGift.java

@@ -0,0 +1,95 @@
+package com.iamberry.wechat.core.entity.eo;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ *  结算赠品类
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public class SettlementGift  implements  Serializable{
+    private static final long serialVersionUID = -2406158685606440068L;
+    //结算赠品Id
+    private Integer settGiftId;
+    //活动id
+    private Integer promotionsId;
+    //1.使用中 2.未使用
+    private Integer settGiftStatus;
+    //备注
+    private String settGiftDesc;
+    //顺序
+    private Integer settGiftSort;
+    //创建时间'
+    private Date settGiftCreateTime;
+    //赠品条件类
+    private List<GiftCondition> giftConditionList = new ArrayList<>();
+    //赠品池
+    private List<GiftPool> giftPoolList = new ArrayList<>();
+
+    public Integer getSettGiftId(){
+        return settGiftId;
+    }
+
+    public void setSettGiftId(Integer  settGiftId){
+        this.settGiftId=settGiftId;
+    }
+
+    public Integer getPromotionsId(){
+        return promotionsId;
+    }
+
+    public void setPromotionsId(Integer  promotionsId){
+        this.promotionsId=promotionsId;
+    }
+
+    public Integer getSettGiftStatus(){
+        return settGiftStatus;
+    }
+
+    public void setSettGiftStatus(Integer  settGiftStatus){
+        this.settGiftStatus=settGiftStatus;
+    }
+
+    public String getSettGiftDesc(){
+        return settGiftDesc;
+    }
+
+    public void setSettGiftDesc(String  settGiftDesc){
+        this.settGiftDesc=settGiftDesc;
+    }
+
+    public Date getSettGiftCreateTime(){
+        return settGiftCreateTime;
+    }
+
+    public void setSettGiftCreateTime(Date  settGiftCreateTime){
+        this.settGiftCreateTime=settGiftCreateTime;
+    }
+
+    public Integer getSettGiftSort() {
+        return settGiftSort;
+    }
+
+    public void setSettGiftSort(Integer settGiftSort) {
+        this.settGiftSort = settGiftSort;
+    }
+
+    public List<GiftCondition> getGiftConditionList() {
+        return giftConditionList;
+    }
+
+    public void setGiftConditionList(List<GiftCondition> giftConditionList) {
+        this.giftConditionList = giftConditionList;
+    }
+
+    public List<GiftPool> getGiftPoolList() {
+        return giftPoolList;
+    }
+
+    public void setGiftPoolList(List<GiftPool> giftPoolList) {
+        this.giftPoolList = giftPoolList;
+    }
+}

+ 83 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/eo/Spike.java

@@ -0,0 +1,83 @@
+package com.iamberry.wechat.core.entity.eo;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ *  秒杀类
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public class Spike  implements  Serializable{
+    private static final long serialVersionUID = -2749553830069392383L;
+    //秒杀id
+    private Integer spikeId;
+    //活动id
+    private Integer promotionsId;
+    //满足颜色id
+    private Integer spikeColorId;
+    //
+    private Integer spikePrice;
+    //
+    private Integer spikeDiscount;
+    //状态 1.使用中 2.未使用
+    private String spikeStatus;
+    //创建时间'
+    private Date spikeCreateTime;
+
+    public Integer getSpikeId(){
+        return spikeId;
+    }
+
+    public void setSpikeId(Integer  spikeId){
+        this.spikeId=spikeId;
+    }
+
+    public Integer getPromotionsId(){
+        return promotionsId;
+    }
+
+    public void setPromotionsId(Integer  promotionsId){
+        this.promotionsId=promotionsId;
+    }
+
+    public Integer getSpikeColorId(){
+        return spikeColorId;
+    }
+
+    public void setSpikeColorId(Integer  spikeColorId){
+        this.spikeColorId=spikeColorId;
+    }
+
+    public Integer getSpikePrice(){
+        return spikePrice;
+    }
+
+    public void setSpikePrice(Integer  spikePrice){
+        this.spikePrice=spikePrice;
+    }
+
+    public Integer getSpikeDiscount() {
+        return spikeDiscount;
+    }
+
+    public void setSpikeDiscount(Integer spikeDiscount) {
+        this.spikeDiscount = spikeDiscount;
+    }
+
+    public String getSpikeStatus(){
+        return spikeStatus;
+    }
+
+    public void setSpikeStatus(String  spikeStatus){
+        this.spikeStatus=spikeStatus;
+    }
+
+    public Date getSpikeCreateTime(){
+        return spikeCreateTime;
+    }
+
+    public void setSpikeCreateTime(Date  spikeCreateTime){
+        this.spikeCreateTime=spikeCreateTime;
+    }
+}

+ 11 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/order/OrderItem.java

@@ -1,5 +1,6 @@
 package com.iamberry.wechat.core.entity.order;
 
+import com.iamberry.wechat.core.entity.eo.ItemGift;
 import com.iamberry.wechat.core.entity.product.SalesUserGift;
 
 import java.io.Serializable;
@@ -54,6 +55,8 @@ public class OrderItem implements Serializable {
 
 	private List<SalesUserGift> salesUserGiftList; //赠品集合
 
+	private List<ItemGift> itemGiftList;		//订单项关联赠品
+
 	public Integer getItemGiftSource() {
 		return itemGiftSource;
 	}
@@ -226,4 +229,12 @@ public class OrderItem implements Serializable {
 	public void setProductTypeName(String productTypeName) {
 		this.productTypeName = productTypeName;
 	}
+
+	public List<ItemGift> getItemGiftList() {
+		return itemGiftList;
+	}
+
+	public void setItemGiftList(List<ItemGift> itemGiftList) {
+		this.itemGiftList = itemGiftList;
+	}
 }

+ 25 - 0
iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/GiftConditionService.java

@@ -0,0 +1,25 @@
+package com.iamberry.wechat.face.eo;
+
+import com.iamberry.wechat.core.entity.eo.GiftCondition;
+
+import java.util.List;
+
+/**
+ *  赠品条件接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public interface GiftConditionService {
+    /**
+     * 获取集合
+     * @param  giftCondition
+     * @return List
+     */
+    List<GiftCondition> getGiftConditionList(GiftCondition giftCondition);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  giftCondition
+     */
+    GiftCondition getGiftConditionById(Integer id);
+}

+ 38 - 0
iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/GiftPoolService.java

@@ -0,0 +1,38 @@
+package com.iamberry.wechat.face.eo;
+
+import com.iamberry.wechat.core.entity.eo.GiftPool;
+
+import java.util.List;
+
+/**
+ *  赠品池接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public interface GiftPoolService {
+    /**
+     * 获取集合
+     * @param  giftPool
+     * @return List
+     */
+    List<GiftPool> getGiftPoolList(GiftPool giftPool);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  giftPool
+     */
+    GiftPool getGiftPoolById(Integer id);
+
+    /**
+     * 修改数据 - 减去库存
+     * @param  giftPool
+     * @return Integer
+     */
+    Integer  updateStock(GiftPool  giftPool);
+    /**
+     * 修改数据 - 增加库存
+     * @param  giftPool
+     * @return Integer
+     */
+    Integer  updateAddStock(GiftPool  giftPool);
+}

+ 45 - 0
iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/ItemGiftService.java

@@ -0,0 +1,45 @@
+package com.iamberry.wechat.face.eo;
+
+import com.iamberry.wechat.core.entity.eo.ItemGift;
+
+import java.util.List;
+
+/**
+ *  订单项关联赠品池接口
+ * @author Administrator
+ * @Date 2019-10-29
+ */
+public interface ItemGiftService {
+    /**
+     * 获取集合
+     * @param  itemGift
+     * @return List
+     */
+    List<ItemGift> getItemGiftList(ItemGift itemGift);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  itemGift
+     */
+    ItemGift getItemGiftById(Integer id);
+    /**
+     * 增加数据
+     * @param  itemGift
+     * @return Integer
+     */
+    Integer  save(ItemGift itemGift);
+    /**
+     * 修改数据
+     * @param  itemGift
+     * @return Integer
+     */
+    Integer  update(ItemGift itemGift);
+
+    /**
+     * 增加数据 <集合>
+     * @param  itemGiftList
+     * @return Integer
+     */
+    Integer  saveList(List<ItemGift> itemGiftList);
+
+}

+ 30 - 0
iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/PromotionsService.java

@@ -0,0 +1,30 @@
+package com.iamberry.wechat.face.eo;
+
+import com.iamberry.wechat.core.entity.eo.Promotions;
+
+import java.util.List;
+
+/**
+ *  优惠活动接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public interface PromotionsService {
+    /**
+     * 获取集合
+     * @param  promotions
+     * @return List
+     */
+    List<Promotions> getPromotionsList(Promotions promotions);
+    /**
+     * 获取集合
+     * @return List
+     */
+    Promotions getPromotionsListByTime();
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  promotions
+     */
+    Promotions getPromotionsById(Integer id);
+}

+ 9 - 14
iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/cart/SettlementGiftService.java

@@ -1,6 +1,6 @@
-package com.iamberry.wechat.face.cart;
+package com.iamberry.wechat.face.eo;
 
-import com.iamberry.wechat.core.entity.cart.SettlementGift;
+import com.iamberry.wechat.core.entity.eo.SettlementGift;
 
 import java.util.List;
 
@@ -17,21 +17,16 @@ public interface SettlementGiftService {
      */
     List<SettlementGift> getSettlementGiftList(SettlementGift settlementGift);
     /**
+     * 获取集合-所有活动的满赠
+     * @param  promotionsList
+     * @return List
+     */
+    List<SettlementGift> getSettlementGiftListAll(int[] str);
+    /**
      * 查询单条数据
      * @param  id
      * @return  settlementGift
      */
     SettlementGift getSettlementGiftById(Integer id);
-    /**
-     * 增加数据
-     * @param  settlementGift
-     * @return Integer
-     */
-    Integer  save(SettlementGift settlementGift);
-    /**
-     * 修改数据
-     * @param  settlementGift
-     * @return Integer
-     */
-    Integer  update(SettlementGift settlementGift);
+
 }

+ 31 - 0
iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/eo/SpikeService.java

@@ -0,0 +1,31 @@
+package com.iamberry.wechat.face.eo;
+
+import com.iamberry.wechat.core.entity.eo.Spike;
+
+import java.util.List;
+
+/**
+ *  秒杀接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public interface SpikeService {
+    /**
+     * 获取集合
+     * @param  spike
+     * @return List
+     */
+    List<Spike> getSpikeList(Spike spike);
+    /**
+     * 获取集合
+     * @param  str
+     * @return List
+     */
+    List<Spike> getSpikeListAll(int[] str);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  spike
+     */
+    Spike getSpikeById(Integer id);
+}

+ 276 - 29
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/ActivityUtil.java

@@ -1,14 +1,26 @@
 package com.iamberry.wechat.service;
 
-
 import com.iamberry.wechat.core.entity.activity.ActivityDate;
+import com.iamberry.wechat.core.entity.cart.CartDto;
+import com.iamberry.wechat.core.entity.eo.*;
+import com.iamberry.wechat.core.entity.product.Product;
+import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.face.admin.SystemService;
+import com.iamberry.wechat.face.cart.ProductInfoService;
+import com.iamberry.wechat.face.eo.PromotionsService;
 import com.iamberry.wechat.face.member.MemberService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * 上朵活动类
@@ -16,62 +28,297 @@ import java.util.Date;
 @Component
 public class ActivityUtil {
 
+    Logger logger = LoggerFactory.getLogger(ActivityUtil.class);
+
     @Autowired
     private SystemService systemService;
-
     @Autowired
     private MemberService memberService;
+    @Autowired
+    private PromotionsService promotionsService;
+    @Autowired
+    private ProductInfoService productInfoService;
 
     private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
     /**
      * 获取日期
-     * @param type
      * @return
      */
-    private ActivityDate initDate(Integer type){
+    private ActivityDate initDate(){
         ActivityDate activityDate  = new ActivityDate();
+        activityDate.setStatus(false);
+        String begin = systemService.selectOneShopRuleByIdDynamic(256).getRuleDesc();
+        String end = systemService.selectOneShopRuleByIdDynamic(257).getRuleDesc();
         try {
-            switch (type){
-                case 1:
-                    String begin = systemService.selectOneShopRuleByIdDynamic(256).getRuleDesc();
-                    activityDate.setBeginDate(sd.parse(begin)); ;
-                    String end = systemService.selectOneShopRuleByIdDynamic(257).getRuleDesc();
-                    activityDate.setEndDate(sd.parse(end));
-                    break;
-                default:
-                    activityDate = null;
-                    break;
-            }
-        }catch (Exception e){
-            activityDate = null;
+            activityDate.setBeginDate(sd.parse(begin));
+            activityDate.setEndDate(sd.parse(end));
+        } catch (ParseException e) {
+            logger.info("活动日期转换错误!");
             e.printStackTrace();
+            activityDate.setStatus(false);
+            return activityDate;
+        }
+        Date date = new Date();
+        if (activityDate.getBeginDate().before(date) && date.before(activityDate.getEndDate())){  //beginDate 比 date 早? true :false
+            activityDate.setStatus(true);
         }
-
         return activityDate;
     }
 
+    /**
+     * 判断是否在注销时间内
+     * @return 期限内true;
+     */
+    public boolean isActivity(){
+        ActivityDate activityDate = initDate();
+        return activityDate.isStatus();
+    }
 
     /**
      * 判断是否在注销时间内
      * @return 期限内true;
      */
-    public ActivityDate isActivity(){
-        ActivityDate activityDate = initDate(1);
+    public ActivityDate getActivityDate(){
+        ActivityDate activityDate = initDate();
+        if(!activityDate.isStatus()){
+            return activityDate;
+        }
+        Promotions promotions = getAllPromotions();
+        activityDate.setPromotions(promotions);
+        return activityDate;
+    }
 
-        activityDate.setRemark("618活动");
+    /**
+     * 获取所有优惠信息
+     * @return 期限内true;
+     */
+    public Promotions getAllPromotions(){
+        if(!isActivity()){
+            return null;
+        }
+        return promotionsService.getPromotionsListByTime();
+    }
 
-        if(activityDate == null){
-            activityDate.setStatus(false);
+    /**
+     * 订单结算满足优惠
+     * @param cartDtoList
+     */
+    public void giftCart(List<CartDto> cartDtoList){
+        if(!isActivity()){
+            return;
         }
-        Date date = new Date();
+        Promotions promotions = promotionsService.getPromotionsListByTime();
+        this.giftCartPriv(cartDtoList,promotions);
+    }
 
-        if (activityDate.getBeginDate().before(date) && date.before(activityDate.getEndDate())){  //beginDate 比 date 早? true :false
-            activityDate.setStatus(true);
-            return activityDate;
+    /**
+     * 赠送赠品+秒杀减价
+     * @param cartDtoList
+     */
+    public void preferential(List<CartDto> cartDtoList){
+        if(!isActivity()){
+            return;
+        }
+        Promotions promotions = promotionsService.getPromotionsListByTime();
+        this.giftCartPriv(cartDtoList,promotions);
+        this.getColorSpikePriv(cartDtoList,promotions);
+    }
+
+    /**
+     * 查询秒杀
+     * @param colorId
+     */
+    public Spike getColorSpike(Integer colorId){
+        Spike spk = new Spike();
+        if(!isActivity()){
+            return null;
+        }
+        Promotions promotions = promotionsService.getPromotionsListByTime();
+        return getColorSpikePriv(colorId,promotions);
+    }
+
+    /**
+     * 查询秒杀
+     * @param list
+     */
+    public void getColorSpike(List list){
+        Spike spk = new Spike();
+        if(!isActivity()){
+            return;
+        }
+        Promotions promotions = promotionsService.getPromotionsListByTime();
+        this.getColorSpikePriv(list,promotions);
+    }
+
+
+    /**
+     * 赠送赠品 - 私有
+     * @param cartDtoList
+     */
+    public void giftCartPriv(List<CartDto> cartDtoList,Promotions promotions){
+        if(promotions == null){
+            return;
+        }
+        List<CartDto> giftList = new ArrayList<>();
+        for (SettlementGift settlementGift:promotions.getSettlementGiftList()) {
+            boolean isHaveColor = false;
+            for (CartDto cd:cartDtoList) {
+                Integer cdNum = 0;
+                for (GiftCondition giftCondition:settlementGift.getGiftConditionList()) {
+                    if(cd.getCartColorId() == giftCondition.getGiftConditionFillColorId()){//添加赠送产品
+                        isHaveColor = true;
+                        cdNum = cd.getCartNum();
+                    }
+                }
+                if(isHaveColor){
+                    String giftPoolRelationDesc = "";
+                    for (GiftPool giftPool:settlementGift.getGiftPoolList()) {
+                        CartDto cartDto = new CartDto();
+
+                        Integer num = giftPool.getGiftPoolNum();
+                        if(giftPool.getGiftPoolNum() < 1){	//判断赠送数量,大于0就用该数量
+                            num = cdNum;
+                        }
+                        if(num > giftPool.getGiftPoolStock()){
+                            continue;
+                        }
+
+                        if(!"".equals(giftPoolRelationDesc)){
+                            if(1 == giftPool.getGiftPoolRelation() || !giftPoolRelationDesc.equals(giftPool.getGiftPoolRelationDesc())){
+                                continue;
+                            }
+                        }
+                        cartDto.setCartColorId(giftPool.getGiftPoolColorId());
+                        cartDto.setCartNum(num);
+                        cartDto.setProductDiscount(giftPool.getGiftPoolPrice());
+                        cartDto.setProductPrice(giftPool.getGiftPoolPrice());
+                        cartDto.setTotal(giftPool.getGiftPoolPrice()*num);
+
+                        List<ItemGift> itemGiftList = new ArrayList<>();
+                        ItemGift itemGift = new ItemGift();
+                        itemGift.setGiftPoolId(giftPool.getGiftPoolId());
+                        itemGift.setItemGiftNum(num);
+                        itemGiftList.add(itemGift);
+                        cartDto.setItemGiftList(itemGiftList);
+
+                        giftList.add(cartDto);
+
+                        if( 1 == giftPool.getGiftPoolRelation()){
+                            break;
+                        }else{
+                            giftPoolRelationDesc = giftPool.getGiftPoolRelationDesc();
+                        }
+                    }
+                }
+            }
+        }
+
+        List<CartDto> newGiftList = new ArrayList<>();
+        if(giftList != null && giftList.size() > 0){
+            for (CartDto carD:giftList) {
+                boolean fl = false;
+                for(CartDto newCarD:newGiftList) {
+                    if(Objects.equals(newCarD.getCartColorId(), carD.getCartColorId())){	//赠品相同,合并
+                        fl = true;
+                        newCarD.setCartNum(newCarD.getCartNum() + carD.getCartNum());
+                        newCarD.setProductDiscount(newCarD.getProductDiscount() +  carD.getProductDiscount());
+                        newCarD.setProductPrice( newCarD.getProductPrice() + carD.getProductPrice());
+                        newCarD.setTotal(newCarD.getTotal() + carD.getTotal());
+                        if(carD.getItemGiftList() != null && carD.getItemGiftList().size() > 0){
+                            if(newCarD.getItemGiftList() != null && newCarD.getItemGiftList().size() > 0){
+                                List<ItemGift> itemIG = new ArrayList<>();
+                                for (ItemGift carDIG:carD.getItemGiftList()) {
+                                    for (ItemGift newCarDIG:newCarD.getItemGiftList()) {
+                                        if(carDIG.getGiftPoolId() == newCarDIG.getGiftPoolId()){
+                                            newCarDIG.setItemGiftNum(newCarDIG.getItemGiftNum()+carDIG.getItemGiftNum());
+                                        }
+                                    }
+                                }
+                            }else{
+                                newCarD.setItemGiftList(carD.getItemGiftList());
+                            }
+                        }
+                    }
+                }
+                if(!fl){
+                    Product product = productInfoService.selectProductByColorId(carD.getCartColorId());
+                    carD.setCartId(1);
+                    carD.setCartProductId(product.getProductId());
+                    carD.setProductName("【赠品】"+product.getProductName());
+                    carD.setProductType(product.getProductTypeId());
+                    carD.setProductStatus(1);
+                    carD.setColorStatus(1);
+                    carD.setProductIntroduceImg(product.getColorProductPic());
+                    carD.setProductRemark(product.getColorPresent());
+                    carD.setProductColor(product.getColorName());
+                    carD.setProductIntroduceImg(product.getColorProductPic());	//productIntroduceImg
+                    carD.setProductChildType(product.getProductChildTypeId());	//productChildType
+                    carD.setCartIsSource(1);
+                    CartDto newCartDto = new CartDto();
+                    BeanUtils.copyProperties(carD,newCartDto);
+                    newGiftList.add(newCartDto);
+                }
+            }
+        }
+        if(newGiftList != null && newGiftList.size() > 0){
+            cartDtoList.addAll(newGiftList);
+        }
+    }
+
+    /**
+     * 查询秒杀
+     * @param colorId
+     */
+    public Spike getColorSpikePriv(Integer colorId,Promotions promotions){
+        Spike spk = new Spike();
+        if(promotions == null){
+            return spk;
+        }
+        for (Spike spike:promotions.getSpikeList()) {
+            if(colorId == spike.getSpikeColorId()){
+                spk = spike;
+            }
+        }
+        return spk;
+    }
+
+    /**
+     * 查询秒杀
+     */
+    public void getColorSpikePriv(List list,Promotions promotions){
+        if(promotions == null){
+            return;
+        }
+        if(list==null || list.size()<1){
+            return;
+        }
+        String nowClass = list.get(0).getClass().getName();
+        switch (nowClass){
+            case ("com.iamberry.wechat.core.entity.product.ProductColor"):
+                for (Object obj:list) {
+                    for (Spike spike:promotions.getSpikeList()) {
+                        ProductColor productColor = (ProductColor) obj;
+                        if(spike.getSpikeColorId() == productColor.getColorId()){
+                            productColor.setColorPrice(spike.getSpikePrice());
+                            productColor.setColorDiscount(spike.getSpikeDiscount());
+                        }
+                    }
+                }
+                break;
+            case "com.iamberry.wechat.core.entity.cart.CartDto":
+                for (Object obj:list) {
+                    for (Spike spike:promotions.getSpikeList()) {
+                        CartDto cd = (CartDto) obj;
+                        if(spike.getSpikeColorId() == cd.getCartColorId()){
+                            cd.setProductPrice(spike.getSpikePrice());
+                            cd.setProductDiscount(spike.getSpikeDiscount());
+                        }
+                    }
+                }
+                break;
+                default:break;
         }
-        activityDate.setStatus(false);
-        return activityDate;
     }
 
 }

+ 33 - 4
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/CartServiceImpl.java

@@ -7,9 +7,13 @@ import java.util.List;
 import java.util.Map;
 
 import com.iamberry.app.tool.log.RatFWLogger;
+import com.iamberry.wechat.core.entity.eo.GiftPool;
+import com.iamberry.wechat.core.entity.eo.ItemGift;
 import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.core.entity.product.ProductFittings;
 import com.iamberry.wechat.core.entity.product.SalesUserGift;
+import com.iamberry.wechat.face.eo.GiftPoolService;
+import com.iamberry.wechat.face.eo.ItemGiftService;
 import com.iamberry.wechat.face.order.AdminOrderService;
 import com.iamberry.wechat.tools.ResultInfo;
 import com.iamberry.wechat.tools.SendMessageUtil;
@@ -64,6 +68,10 @@ public class CartServiceImpl implements CartService {
 	private RatFWLogger logger;
 	@Autowired
 	private SendMessageUtil sendMessageUtil;
+	@Autowired
+	private GiftPoolService giftPoolService;
+	@Autowired
+	private ItemGiftService itemGiftService;
 	
 	
 	@Override
@@ -176,11 +184,32 @@ public class CartServiceImpl implements CartService {
 		// TODO Auto-generated method stub
 		int count = cartDao.insertOrderInfo(order);
 		if (count < 1) {
-			throw new Exception();
+			throw new RuntimeException("添加订单失败");
 		}
-		count = cartDao.insertOrderItemList(items);
-		if (count < 1) {
-			throw new Exception();
+		for (OrderItem oi: items) {
+			count = cartDao.save(oi);
+			if (count < 1) {
+				throw new RuntimeException("添加订单项失败");
+			}
+
+			if(oi.getItemGiftList() != null && oi.getItemGiftList().size() > 0){
+				for (ItemGift ig : oi.getItemGiftList()) {
+					ig.setItemId(oi.getItemId());
+
+					GiftPool giftPool = new GiftPool();
+					giftPool.setGiftPoolId(ig.getGiftPoolId());
+					giftPool.setGiftPoolStock(ig.getItemGiftNum());
+					count = giftPoolService.updateStock(giftPool);
+					if (count < 1) {
+						throw new RuntimeException("修改订单项关联赠品库存失败");
+					}
+				}
+
+				count = itemGiftService.saveList(oi.getItemGiftList());
+				if (count < 1) {
+					throw new RuntimeException("添加订单项赠品失败");
+				}
+			}
 		}
 		// 删除购物车项目
 		cartDao.deleteBatchCartListById(cartIds);

+ 0 - 56
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/SettlementGiftServiceImpl.java

@@ -1,56 +0,0 @@
-package com.iamberry.wechat.service.cart;
-
-import com.iamberry.wechat.core.entity.cart.SettlementGift;
-import com.iamberry.wechat.face.cart.SettlementGiftService;
-import com.iamberry.wechat.service.mapper.SettlementGiftMapper;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- *  结算赠品接口
- * @author Administrator
- * @Date 2019-05-23
- */
-@Service
-public class SettlementGiftServiceImpl implements SettlementGiftService {
-    @Autowired
-    private SettlementGiftMapper settlementGiftMapper;
-    /**
-     * 获取集合
-     * @param  settlementGift
-     * @return List
-     */
-    @Override
-    public List<SettlementGift> getSettlementGiftList(SettlementGift settlementGift){
-        return  settlementGiftMapper.getSettlementGiftList(settlementGift);
-    }
-    /**
-     * 查询单条数据
-     * @param  id
-     * @return  settlementGift
-     */
-    @Override
-    public SettlementGift getSettlementGiftById(Integer  id){
-        return  settlementGiftMapper.getSettlementGiftById(id);
-    }
-    /**
-     * 增加数据
-     * @param  settlementGift
-     * @return Integer
-     */
-    @Override
-    public  Integer  save(SettlementGift settlementGift){
-        return  settlementGiftMapper.save(settlementGift);
-    }
-    /**
-     * 修改数据
-     * @param  settlementGift
-     * @return Integer
-     */
-    @Override
-    public  Integer  update(SettlementGift settlementGift){
-        return  settlementGiftMapper.update(settlementGift);
-    }
-}

+ 8 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/dao/CartDao.java

@@ -85,6 +85,14 @@ public interface CartDao {
 	public Integer insertOrderInfo(Order order);
 
 	/**
+	 * 增加数据
+	 * @param  orderItem
+	 * @return Integer
+	 */
+	Integer  save(OrderItem  orderItem);
+
+
+	/**
 	 * 添加订单项信息
 	 * @param items
 	 * @return

+ 9 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/dao/impl/CartDaoImpl.java

@@ -124,6 +124,15 @@ public class CartDaoImpl implements CartDao{
 		// TODO Auto-generated method stub
 		return orderMapper.insertOrderInfo(order);
 	}
+	/**
+	 * 增加数据
+	 * @param  orderItem
+	 * @return Integer
+	 */
+	@Override
+	public  Integer  save(OrderItem  orderItem){
+		return  orderMapper.save(orderItem);
+	}
 
 
 	@Override

+ 37 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/GiftConditionServiceImpl.java

@@ -0,0 +1,37 @@
+package com.iamberry.wechat.service.eo;
+import com.iamberry.wechat.core.entity.eo.GiftCondition;
+import com.iamberry.wechat.face.eo.GiftConditionService;
+import com.iamberry.wechat.service.mapper.GiftConditionMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  赠品条件接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+@Service
+public class GiftConditionServiceImpl  implements GiftConditionService {
+    @Autowired
+    private GiftConditionMapper giftConditionMapper;
+    /**
+     * 获取集合
+     * @param  giftCondition
+     * @return List
+     */
+    @Override
+    public List<GiftCondition> getGiftConditionList(GiftCondition giftCondition){
+        return  giftConditionMapper.getGiftConditionList(giftCondition);
+    }
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  giftCondition
+     */
+    @Override
+    public GiftCondition getGiftConditionById(Integer  id){
+        return  giftConditionMapper.getGiftConditionById(id);
+    }
+}

+ 59 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/GiftPoolServiceImpl.java

@@ -0,0 +1,59 @@
+package com.iamberry.wechat.service.eo;
+
+import com.iamberry.wechat.core.entity.eo.GiftPool;
+import com.iamberry.wechat.face.eo.GiftPoolService;
+import com.iamberry.wechat.service.mapper.GiftPoolMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  赠品池接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+@Service
+public class GiftPoolServiceImpl  implements GiftPoolService {
+    @Autowired
+    private GiftPoolMapper giftPoolMapper;
+    /**
+     * 获取集合
+     * @param  giftPool
+     * @return List
+     */
+    @Override
+    public List<GiftPool> getGiftPoolList(GiftPool giftPool){
+        return  giftPoolMapper.getGiftPoolList(giftPool);
+    }
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  giftPool
+     */
+    @Override
+    public GiftPool getGiftPoolById(Integer  id){
+        return  giftPoolMapper.getGiftPoolById(id);
+    }
+
+    /**
+     * 修改数据
+     * @param  giftPool
+     * @return Integer
+     */
+    @Override
+    public  Integer  updateStock(GiftPool  giftPool){
+        return  giftPoolMapper.updateStock(giftPool);
+    }
+
+    /**
+     * 修改数据
+     * @param  giftPool
+     * @return Integer
+     */
+    @Override
+    public  Integer  updateAddStock(GiftPool  giftPool){
+        return  giftPoolMapper.updateAddStock(giftPool);
+    }
+
+}

+ 68 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/ItemGiftServiceImpl.java

@@ -0,0 +1,68 @@
+package com.iamberry.wechat.service.eo;
+
+import com.iamberry.wechat.core.entity.eo.ItemGift;
+import com.iamberry.wechat.face.eo.ItemGiftService;
+import com.iamberry.wechat.service.mapper.ItemGiftMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  订单项关联赠品池接口
+ * @author Administrator
+ * @Date 2019-10-29
+ */
+@Service
+public class ItemGiftServiceImpl implements ItemGiftService {
+    @Autowired
+    private ItemGiftMapper itemGiftMapper;
+    /**
+     * 获取集合
+     * @param  itemGift
+     * @return List
+     */
+    @Override
+    public List<ItemGift> getItemGiftList(ItemGift itemGift){
+        return  itemGiftMapper.getItemGiftList(itemGift);
+    }
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  itemGift
+     */
+    @Override
+    public ItemGift getItemGiftById(Integer  id){
+        return  itemGiftMapper.getItemGiftById(id);
+    }
+    /**
+     * 增加数据
+     * @param  itemGift
+     * @return Integer
+     */
+    @Override
+    public  Integer  save(ItemGift itemGift){
+        return  itemGiftMapper.save(itemGift);
+    }
+    /**
+     * 修改数据
+     * @param  itemGift
+     * @return Integer
+     */
+    @Override
+    public  Integer  update(ItemGift itemGift){
+        return  itemGiftMapper.update(itemGift);
+    }
+
+    /**
+     * 增加数据 <集合>
+     * @param  itemGiftList
+     * @return Integer
+     */
+    @Override
+    public  Integer  saveList(List<ItemGift>  itemGiftList){
+        return  itemGiftMapper.saveList(itemGiftList);
+    }
+
+
+}

+ 68 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/PromotionsServiceImpl.java

@@ -0,0 +1,68 @@
+package com.iamberry.wechat.service.eo;
+import com.iamberry.wechat.core.entity.eo.Promotions;
+import com.iamberry.wechat.core.entity.eo.SettlementGift;
+import com.iamberry.wechat.core.entity.eo.Spike;
+import com.iamberry.wechat.face.eo.PromotionsService;
+import com.iamberry.wechat.face.eo.SettlementGiftService;
+import com.iamberry.wechat.face.eo.SpikeService;
+import com.iamberry.wechat.service.mapper.PromotionsMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  优惠活动接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+@Service
+public class PromotionsServiceImpl  implements PromotionsService {
+    @Autowired
+    private PromotionsMapper promotionsMapper;
+
+    @Autowired
+    private SettlementGiftService settlementGiftService;
+    @Autowired
+    private SpikeService spikeService;
+    /**
+     * 获取集合
+     * @param  promotions
+     * @return List
+     */
+    @Override
+    public List<Promotions> getPromotionsList(Promotions promotions){
+        return  promotionsMapper.getPromotionsList(promotions);
+    }
+
+    @Override
+    public Promotions getPromotionsListByTime() {
+        Promotions promotions = new Promotions();
+        //获取当前时间所有活动
+        List<Promotions> promotionsList = promotionsMapper.getPromotionsListByTime();
+        int[] str = new int[promotionsList.size()];
+        for (int i = 0; i < promotionsList.size(); i++) {
+            str[i] = promotionsList.get(i).getPromotionsId();
+        }
+        //获取当前活动的所有满赠
+        List<SettlementGift> settlementGiftList = settlementGiftService.getSettlementGiftListAll(str);
+        promotions.setSettlementGiftList(settlementGiftList);
+
+        //获取当前活动所有秒杀
+        List<Spike> spikeList = spikeService.getSpikeListAll(str);
+        promotions.setSpikeList(spikeList);
+
+        //获取当前活动所有满减
+        return promotions;
+    }
+
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  promotions
+     */
+    @Override
+    public Promotions getPromotionsById(Integer  id){
+        return  promotionsMapper.getPromotionsById(id);
+    }
+}

+ 77 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/SettlementGiftServiceImpl.java

@@ -0,0 +1,77 @@
+package com.iamberry.wechat.service.eo;
+
+import com.iamberry.wechat.core.entity.eo.SettlementGift;
+import com.iamberry.wechat.face.eo.SettlementGiftService;
+import com.iamberry.wechat.service.mapper.SettlementGiftMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  结算赠品接口
+ * @author Administrator
+ * @Date 2019-05-23
+ */
+@Service
+public class SettlementGiftServiceImpl  implements SettlementGiftService {
+    @Autowired
+    private SettlementGiftMapper settlementGiftMapper;
+    /**
+     * 获取集合
+     * @param  settlementGift
+     * @return List
+     */
+    @Override
+    public List<SettlementGift> getSettlementGiftList(SettlementGift settlementGift){
+        return  settlementGiftMapper.getSettlementGiftList(settlementGift);
+    }
+
+    @Override
+    public List<SettlementGift> getSettlementGiftListAll(int[] str) {
+
+        List<SettlementGift> settlementGiftList = settlementGiftMapper.getSettlementGiftListAll(str);
+//        for (Promotions pro:promotionsList) {
+//            SettlementGift settlementGift = new SettlementGift();
+//            settlementGift.setPromotionsId( pro.getPromotionsId());
+//            List<SettlementGift> settlementGiftPartList = settlementGiftMapper.getSettlementGiftListAll(settlementGift);
+//            for (SettlementGift sg:settlementGiftPartList){
+//                boolean flag = true;
+//                for (SettlementGift allsg:settlementGiftList) {
+//                    if(allsg.getSettGiftId() == sg.getSettGiftId()){
+//                        flag = false;
+//                    }
+//                }
+//                if(flag){
+//                    settlementGiftList.add(sg);
+//                }
+//            }
+//        }
+//        Collections.sort(settlementGiftList, new Comparator<SettlementGift>() {
+//            @Override
+//            public int compare(SettlementGift o1, SettlementGift o2) {
+//                // 按照学生的年龄进行升序排列
+//                if (o1.getSettGiftSort() > o2.getSettGiftSort()) {
+//                    return 1;
+//                }
+//                if (o1.getSettGiftSort() == o2.getSettGiftSort()) {
+//                    return 0;
+//                }
+//                return -1;
+//            }
+//        });
+
+        return  settlementGiftList;
+    }
+
+
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  settlementGift
+     */
+    @Override
+    public SettlementGift getSettlementGiftById(Integer  id){
+        return  settlementGiftMapper.getSettlementGiftById(id);
+    }
+}

+ 44 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/eo/SpikeServiceImpl.java

@@ -0,0 +1,44 @@
+package com.iamberry.wechat.service.eo;
+
+import com.iamberry.wechat.core.entity.eo.Spike;
+import com.iamberry.wechat.face.eo.SpikeService;
+import com.iamberry.wechat.service.mapper.SpikeMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  秒杀接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+@Service
+public class SpikeServiceImpl  implements SpikeService {
+    @Autowired
+    private SpikeMapper spikeMapper;
+    /**
+     * 获取集合
+     * @param  spike
+     * @return List
+     */
+    @Override
+    public List<Spike> getSpikeList(Spike spike){
+        return  spikeMapper.getSpikeList(spike);
+    }
+
+    @Override
+    public List<Spike> getSpikeListAll(int[] str) {
+        return spikeMapper.getSpikeListAll(str);
+    }
+
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  spike
+     */
+    @Override
+    public Spike getSpikeById(Integer  id){
+        return  spikeMapper.getSpikeById(id);
+    }
+}

+ 25 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/GiftConditionMapper.java

@@ -0,0 +1,25 @@
+package com.iamberry.wechat.service.mapper;
+
+import com.iamberry.wechat.core.entity.eo.GiftCondition;
+
+import java.util.List;
+
+/**
+ *  赠品条件接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public interface GiftConditionMapper {
+    /**
+     * 获取集合
+     * @param  giftCondition
+     * @return List
+     */
+    List<GiftCondition> getGiftConditionList(GiftCondition giftCondition);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  giftCondition
+     */
+    GiftCondition getGiftConditionById(Integer id);
+}

+ 39 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/GiftPoolMapper.java

@@ -0,0 +1,39 @@
+package com.iamberry.wechat.service.mapper;
+
+import com.iamberry.wechat.core.entity.eo.GiftPool;
+
+import java.util.List;
+
+/**
+ *  赠品池接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public interface GiftPoolMapper {
+    /**
+     * 获取集合
+     * @param  giftPool
+     * @return List
+     */
+    List<GiftPool> getGiftPoolList(GiftPool giftPool);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  giftPool
+     */
+    GiftPool getGiftPoolById(Integer id);
+
+    /**
+     * 修改数据
+     * @param  giftPool
+     * @return Integer
+     */
+    Integer  updateStock(GiftPool  giftPool);
+
+    /**
+     * 修改数据 - 增加库存
+     * @param  giftPool
+     * @return Integer
+     */
+    Integer  updateAddStock(GiftPool  giftPool);
+}

+ 44 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/ItemGiftMapper.java

@@ -0,0 +1,44 @@
+package com.iamberry.wechat.service.mapper;
+
+import com.iamberry.wechat.core.entity.eo.ItemGift;
+
+import java.util.List;
+
+/**
+ *  订单项关联赠品池接口
+ * @author Administrator
+ * @Date 2019-10-29
+ */
+public interface ItemGiftMapper {
+    /**
+     * 获取集合
+     * @param  itemGift
+     * @return List
+     */
+    List<ItemGift> getItemGiftList(ItemGift itemGift);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  itemGift
+     */
+    ItemGift getItemGiftById(Integer id);
+    /**
+     * 增加数据
+     * @param  itemGift
+     * @return Integer
+     */
+    Integer  save(ItemGift itemGift);
+    /**
+     * 修改数据
+     * @param  itemGift
+     * @return Integer
+     */
+    Integer  update(ItemGift itemGift);
+
+    /**
+     * 增加数据 <集合>
+     * @param  itemGiftList
+     * @return Integer
+     */
+    Integer  saveList(List<ItemGift> itemGiftList);
+}

+ 9 - 1
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/OrderMapper.java

@@ -14,7 +14,15 @@ public interface OrderMapper {
 	 * @return
 	 */
 	public Integer insertOrderInfo(Order order);
-	
+
+	/**
+	 * 增加数据
+	 * @param  orderItem
+	 * @return Integer
+	 */
+	Integer  save(OrderItem  orderItem);
+
+
 	/**
 	 * 添加订单项信息
 	 * @param items

+ 30 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/PromotionsMapper.java

@@ -0,0 +1,30 @@
+package com.iamberry.wechat.service.mapper;
+
+import com.iamberry.wechat.core.entity.eo.Promotions;
+
+import java.util.List;
+
+/**
+ *  优惠活动接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public interface PromotionsMapper {
+    /**
+     * 获取集合
+     * @param  promotions
+     * @return List
+     */
+    List<Promotions> getPromotionsList(Promotions promotions);
+    /**
+     * 获取集合
+     * @return List
+     */
+    List<Promotions> getPromotionsListByTime();
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  promotions
+     */
+    Promotions getPromotionsById(Integer id);
+}

+ 10 - 13
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/SettlementGiftMapper.java

@@ -1,6 +1,6 @@
 package com.iamberry.wechat.service.mapper;
 
-import com.iamberry.wechat.core.entity.cart.SettlementGift;
+import com.iamberry.wechat.core.entity.eo.SettlementGift;
 
 import java.util.List;
 
@@ -16,22 +16,19 @@ public interface SettlementGiftMapper {
      * @return List
      */
     List<SettlementGift> getSettlementGiftList(SettlementGift settlementGift);
+
+    /**
+     * 获取集合
+     * @param  str
+     * @return List
+     */
+    List<SettlementGift> getSettlementGiftListAll(int[] str);
+
     /**
      * 查询单条数据
      * @param  id
      * @return  settlementGift
      */
     SettlementGift getSettlementGiftById(Integer id);
-    /**
-     * 增加数据
-     * @param  settlementGift
-     * @return Integer
-     */
-    Integer  save(SettlementGift settlementGift);
-    /**
-     * 修改数据
-     * @param  settlementGift
-     * @return Integer
-     */
-    Integer  update(SettlementGift settlementGift);
+
 }

+ 32 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/SpikeMapper.java

@@ -0,0 +1,32 @@
+package com.iamberry.wechat.service.mapper;
+
+import com.iamberry.wechat.core.entity.eo.Spike;
+
+import java.util.List;
+
+/**
+ *  秒杀接口
+ * @author Administrator
+ * @Date 2019-10-21
+ */
+public interface SpikeMapper {
+    /**
+     * 获取集合
+     * @param  spike
+     * @return List
+     */
+    List<Spike> getSpikeList(Spike spike);
+
+    /**
+     * 获取集合
+     * @param  str
+     * @return List
+     */
+    List<Spike> getSpikeListAll(int[] str);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  spike
+     */
+    Spike getSpikeById(Integer id);
+}

+ 1 - 1
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/adminOrderMapper.xml

@@ -143,7 +143,7 @@ Reback_status  = 2) placeId
 	<!-- 根据orderId获取订单项数据 -->
 	<select id="getShopOrderItemByOrderId" parameterType="String" resultType="OrderItem">
 		SELECT
-			I.ITEM_PRODUCT_NAME itemProductName, i.item_product_color itemProductColor,
+			I.ITEM_ID itemId,I.ITEM_PRODUCT_NAME itemProductName, i.item_product_color itemProductColor,
 			I.ITEM_PRODUCT_PIC itemProductPic, I.ITEM_PRODUCT_PRICE itemProductPrice,
 			I.ITEM_PRODUCT_DISCOUNT itemProductDiscount, I.ITEM_NUM itemNum, I.ITEM_TOTAL itemTotal, P.PRODUCT_COLOR productColor,
 			pc.color_69code produectRemark

+ 17 - 2
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/cartMapper.xml

@@ -17,6 +17,7 @@ PUBLIC
 			pc.color_status,
 			P.PRODUCT_NAME,
 			pc.color_discount,
+			pc.color_discount AS productDiscount,
 			P.PRODUCT_STATUS,
 			pc.color_name,
 			pc.color_product_pic,
@@ -294,10 +295,24 @@ PUBLIC
 		SELECT
 			C.CART_ID cartId,
 			C.CART_NUM cartNum,
-			C.cart_color_id cartColorId,
+			C.cart_color_id,
+			c.cart_product_id,
+			pc.color_status,
+			pi.PRODUCT_ID cartProductId,
+			pi.PRODUCT_STATUS productStatus,
+			pi.PRODUCT_NAME productName,
+			pc.COLOR_DISCOUNT productDiscount,
+			PC.color_product_pic productIntroduceImg,
+			pc.COLOR_PRICE productPrice,
+			PC.COLOR_69CODE productRemark,
+			pc.COLOR_NAME productColor,
+			pi.PRODUCT_CHILD_TYPE productChildType,
+			pi.PRODUCT_TYPE productType,
 			C.cart_is_source cartIsSource
 		FROM
-		TB_IAMBERRY_SHOP_CART C
+			TB_IAMBERRY_SHOP_CART C
+		LEFT JOIN tb_iamberry_product_color pc ON C.cart_color_id = pc.color_id
+		LEFT JOIN tb_iamberry_product_info pi ON C.cart_product_id = pi.product_id
 		WHERE
 			C.CART_ID IN (
 			<foreach collection="array" item="item" separator=",">

+ 1 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/couponItemMapper.xml

@@ -28,6 +28,7 @@
  		FROM TB_IAMBERRY_COUPON_ITEM CI
  		JOIN TB_IAMBERRY_COUPON_TYPE CT ON CI.COUPON_ID=CT.COUPON_ID
 		<where>
+			 CI.COUPON_ID IN  (31000,31001,31002)
 			<if test="couponId != null and couponId != ''">
 				AND CI.COUPON_ID=#{couponId}
 			</if>

+ 38 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/giftConditionMapper.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.iamberry.wechat.service.mapper.GiftConditionMapper">
+	<resultMap  id="BaseResultMap" type="GiftCondition" >
+		<result    column="gift_condition_id"    property="giftConditionId" />
+		<result    column="sett_gift_id"    property="settGiftId" />
+		<result    column="gift_condition_fill_color_id"    property="giftConditionFillColorId" />
+		<result    column="gift_condition_create_time"    property="giftConditionCreateTime" />
+	</resultMap>
+	<sql    id="Base_List" >
+		t.gift_condition_id,
+		t.sett_gift_id,
+		t.gift_condition_fill_color_id,
+		t.gift_condition_create_time
+	</sql>
+	<select id="getGiftConditionList" resultMap="BaseResultMap" parameterType="GiftCondition" >
+		select
+		<include refid="Base_List" />
+		from tb_iamberry_eo_gift_condition t
+		<where>
+			<if test="giftConditionId != null ">
+				AND t.gift_condition_id = #{giftConditionId}
+			</if >
+			<if test="settGiftId != null ">
+				AND t.sett_gift_id = #{settGiftId}
+			</if >
+			<if test="giftConditionFillColorId != null ">
+				AND t.gift_condition_fill_color_id = #{giftConditionFillColorId}
+			</if >
+		</where>
+	</select>
+	<select id="getGiftConditionById" resultMap="BaseResultMap" parameterType="Integer" >
+		select
+		<include refid="Base_List" />
+		from tb_iamberry_eo_gift_condition t
+		where t.gift_condition_id= #{giftConditionId}
+	</select>
+</mapper>

+ 83 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/giftPoolMapper.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.iamberry.wechat.service.mapper.GiftPoolMapper">
+    <resultMap  id="BaseResultMap" type="GiftPool" >
+        <result    column="gift_pool_id"    property="giftPoolId" />
+        <result    column="sett_gift_id"    property="settGiftId" />
+        <result    column="gift_pool_color_id"    property="giftPoolColorId" />
+        <result    column="gift_pool_price"    property="giftPoolPrice" />
+        <result    column="gift_pool_num"    property="giftPoolNum" />
+        <result    column="gift_pool_status"    property="giftPoolStatus" />
+        <result    column="gift_pool_sort"    property="giftPoolSort" />
+        <result    column="gift_pool_stock"    property="giftPoolStock" />
+        <result    column="gift_pool_relation"    property="giftPoolRelation" />
+        <result    column="gift_pool_relation_desc"    property="giftPoolRelationDesc" />
+        <result    column="gift_pool_create_time"    property="giftPoolCreateTime" />
+    </resultMap>
+    <sql    id="Base_List" >
+        t.gift_pool_id,
+        t.sett_gift_id,
+        t.gift_pool_color_id,
+        t.gift_pool_price,
+        t.gift_pool_num,
+        t.gift_pool_status,
+        t.gift_pool_sort,
+        t.gift_pool_stock,
+        t.gift_pool_relation,
+        t.gift_pool_relation_desc,
+        t.gift_pool_create_time
+    </sql>
+    <select id="getGiftPoolList" resultMap="BaseResultMap" parameterType="GiftPool" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_gift_pool t
+        <where>
+            <if test="giftPoolId != null ">
+                AND t.gift_pool_id = #{giftPoolId}
+            </if >
+            <if test="settGiftId != null ">
+                AND t.sett_gift_id = #{settGiftId}
+            </if >
+            <if test="giftPoolColorId != null ">
+                AND t.gift_pool_color_id = #{giftPoolColorId}
+            </if >
+            <if test="giftPoolPrice != null ">
+                AND t.gift_pool_price = #{giftPoolPrice}
+            </if >
+            <if test="giftPoolNum != null ">
+                AND t.gift_pool_num = #{giftPoolNum}
+            </if >
+            <if test="giftPoolStatus != null ">
+                AND t.gift_pool_status = #{giftPoolStatus}
+            </if >
+            <if test="giftPoolSort != null ">
+                AND t.gift_pool_sort = #{giftPoolSort}
+            </if >
+            <if test="giftPoolStock != null ">
+                AND t.gift_pool_stock = #{giftPoolStock}
+            </if >
+        </where>
+    </select>
+    <select id="getGiftPoolById" resultMap="BaseResultMap" parameterType="Integer" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_gift_pool t
+        where t.gift_pool_id= #{giftPoolId}
+    </select>
+
+    <update id="updateStock" parameterType="GiftPool" >
+        update
+        tb_iamberry_eo_gift_pool
+        SET
+        gift_pool_stock = gift_pool_stock - #{giftPoolStock}
+        where gift_pool_id= #{giftPoolId}
+    </update>
+
+    <update id="updateAddStock" parameterType="GiftPool" >
+        update
+        tb_iamberry_eo_gift_pool
+        SET
+        gift_pool_stock = gift_pool_stock + #{giftPoolStock}
+        where gift_pool_id= #{giftPoolId}
+    </update>
+</mapper>

+ 91 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/itemGiftMapper.xml

@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.iamberry.wechat.service.mapper.ItemGiftMapper">
+    <resultMap  id="BaseResultMap" type="ItemGift" >
+        <result    column="item_gift_id"    property="itemGiftId" />
+        <result    column="item_id"    property="itemId" />
+        <result    column="gift_pool_id"    property="giftPoolId" />
+        <result    column="item_gift_num"    property="itemGiftNum" />
+    </resultMap>
+    <sql    id="Base_List" >
+        t.item_gift_id,
+        t.item_id,
+        t.gift_pool_id,
+        t.item_gift_num
+    </sql>
+    <select id="getItemGiftList" resultMap="BaseResultMap" parameterType="ItemGift" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_item_gift t
+        <where>
+            <if test="itemGiftId != null ">
+                AND t.item_gift_id = #{itemGiftId}
+            </if >
+            <if test="itemId != null ">
+                AND t.item_id = #{itemId}
+            </if >
+            <if test="giftPoolId != null ">
+                AND t.gift_pool_id = #{giftPoolId}
+            </if >
+            <if test="itemGiftNum != null ">
+                AND t.item_gift_num = #{itemGiftNum}
+            </if >
+        </where>
+    </select>
+    <select id="getItemGiftById" resultMap="BaseResultMap" parameterType="Integer" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_item_gift t
+        where t.item_gift_id= #{itemGiftId}
+    </select>
+    <insert id="save" parameterType="ItemGift" >
+        insert into
+        tb_iamberry_eo_item_gift
+        (
+        item_id,
+        gift_pool_id,
+        item_gift_num
+        )
+        values
+        (
+        #{itemId},
+        #{giftPoolId},
+        #{itemGiftNum}
+        )
+    </insert>
+    <update id="update" parameterType="ItemGift" >
+        update
+        tb_iamberry_eo_item_gift
+        <set >
+            <if test="itemId != null ">
+                item_id = #{itemId},
+            </if >
+            <if test="giftPoolId != null ">
+                gift_pool_id = #{giftPoolId},
+            </if >
+            <if test="itemGiftNum != null ">
+                item_gift_num = #{itemGiftNum}
+            </if >
+        </set >
+        where item_gift_id= #{itemGiftId}
+    </update>
+
+    <insert id="saveList" parameterType="java.util.List" >
+        insert into
+        tb_iamberry_eo_item_gift
+        (
+        item_id,
+        gift_pool_id,
+        item_gift_num
+        )
+        values
+        <foreach collection="list" item="node" index="index" separator="," open="" close="">
+            (
+            #{node.itemId},
+            #{node.giftPoolId},
+            #{node.itemGiftNum}
+            )
+        </foreach >
+    </insert>
+
+</mapper>

+ 42 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/orderMapper.xml

@@ -41,6 +41,48 @@ PUBLIC
 			  #{balancePayAmount}
 		  	)
 	</insert>
+
+	<insert id="save" parameterType="OrderItem" keyProperty="itemId" useGeneratedKeys="true">
+		insert into
+		tb_iamberry_shop_order_item
+		(
+			item_id,
+			item_sales_orderid,
+			item_product_id,
+			item_num,
+			item_total,
+			item_create_date,
+			item_product_name,
+			item_product_discount,
+			item_product_price,
+			item_product_pic,
+			item_product_type,
+			item_color_id,
+			item_product_color,
+			item_product_child_type,
+			item_is_source,
+			item_gift_source
+		)
+		values
+		(
+			#{itemId},
+			#{itemSalesOrderid},
+			#{itemProductId},
+			#{itemNum},
+			#{itemTotal},
+			NOW(),
+			#{itemProductName},
+			#{itemProductDiscount},
+			#{itemProductPrice},
+			#{itemProductPic},
+			#{itemProductType},
+			#{itemColorId},
+			#{itemProductColor},
+			#{itemProductChildType},
+			#{itemIsSource},
+			#{itemGiftSource}
+		)
+	</insert>
 	
 	<!-- 插入订单条目信息 -->
 	<insert id="insertOrderItemList" parameterType="java.util.List">

+ 5 - 5
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/productInfoMapper.xml

@@ -25,8 +25,8 @@
 		<result column="product_choiceness_im" property="productChoicenessIm"/>
 		<result column="product_child_type" property="productChildType"/>
 		<result column="child_type_name" property="productChildTypeName"/>
-	<collection property="productColorList" column="product_id" ofType="colorMap" select="selectProductColor"/>
-</resultMap>
+		<collection property="productColorList" column="product_id" ofType="colorMap" select="selectProductColor"/>
+	</resultMap>
 
 	<resultMap id="colorMap" type="ProductColor">
 		<id column="color_id" property="colorId"/>
@@ -72,12 +72,12 @@
 				AND PRODUCT_NAME like #{str} 
 			</if>
 			<if test="otherInt != null and otherInt != ''">
-				AND TB_IAMBERRY_PRODUCT_INFO.product_type = #{otherInt}
+				AND tb_iamberry_product_child_type.type_id = #{otherInt}
 			</if>
 			GROUP BY TB_IAMBERRY_PRODUCT_INFO.PRODUCT_ID
 			ORDER BY product_choiceness_sort DESC
-		LIMIT 
-			#{minNum},#{maxNum}
+			LIMIT
+				#{minNum},#{maxNum}
 	</select>
 
 	<!-- 分页查询配件信息 -->

+ 65 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/promotionsMapper.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.iamberry.wechat.service.mapper.PromotionsMapper">
+    <resultMap  id="BaseResultMap" type="Promotions" >
+        <result    column="promotions_id"    property="promotionsId" />
+        <result    column="promotions_name"    property="promotionsName" />
+        <result    column="promotions_type"    property="promotionsType" />
+        <result    column="promotions_status"    property="promotionsStatus" />
+        <result    column="promotions_begin_time"    property="promotionsBeginTime" />
+        <result    column="promotions_end_time"    property="promotionsEndTime" />
+        <result    column="promotions_desc"    property="promotionsDesc" />
+        <result    column="promotions_create_time"    property="promotionsCreateTime" />
+    </resultMap>
+    <sql    id="Base_List" >
+        t.promotions_id,
+        t.promotions_name,
+        t.promotions_type,
+        t.promotions_status,
+        t.promotions_begin_time,
+        t.promotions_end_time,
+        t.promotions_desc,
+        t.promotions_create_time
+    </sql>
+    <select id="getPromotionsList" resultMap="BaseResultMap" parameterType="Promotions" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_promotions t
+        <where>
+            <if test="promotionsId != null ">
+                AND t.promotions_id = #{promotionsId}
+            </if >
+            <if test="promotionsName != null and promotionsName != ''">
+                AND t.promotions_name  like  CONCAT ('%',#{promotionsName},'%')
+            </if >
+            <if test="promotionsType != null ">
+                AND t.promotions_type = #{promotionsType}
+            </if >
+            <if test="promotionsStatus != null ">
+                AND t.promotions_status = #{promotionsStatus}
+            </if >
+            <if test="promotionsDesc != null and promotionsDesc != ''">
+                AND t.promotions_desc  like  CONCAT ('%',#{promotionsDesc},'%')
+            </if >
+        </where>
+    </select>
+    <select id="getPromotionsListByTime" resultMap="BaseResultMap" parameterType="Promotions" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_promotions t
+        <where>
+            AND t.promotions_status = 1
+            AND t.promotions_begin_time <![CDATA[ <= ]]> NOW()
+            AND t.promotions_end_time <![CDATA[ >= ]]> NOW()
+            <if test="promotionsType != null ">
+                AND t.promotions_type = #{promotionsType}
+            </if >
+        </where>
+    </select>
+    <select id="getPromotionsById" resultMap="BaseResultMap" parameterType="Integer" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_promotions t
+        where t.promotions_id= #{promotionsId}
+    </select>
+</mapper>

+ 65 - 64
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/settlementGiftMapper.xml

@@ -3,94 +3,95 @@
 <mapper namespace="com.iamberry.wechat.service.mapper.SettlementGiftMapper">
     <resultMap  id="BaseResultMap" type="SettlementGift" >
         <result    column="sett_gift_id"    property="settGiftId" />
-        <result    column="sett_gift_fill_color_id"    property="settGiftFillColorId" />
-        <result    column="sett_gift_gift_color_id"    property="settGiftGiftColorId" />
-        <result    column="sett_gift_price"    property="settGiftPrice" />
-        <result    column="sett_gift_num"    property="settGiftNum" />
+        <result    column="promotions_id"    property="promotionsId" />
         <result    column="sett_gift_status"    property="settGiftStatus" />
+        <result    column="sett_gift_desc"    property="settGiftDesc" />
         <result    column="sett_gift_create_time"    property="settGiftCreateTime" />
     </resultMap>
     <sql    id="Base_List" >
         t.sett_gift_id,
-        t.sett_gift_fill_color_id,
-        t.sett_gift_gift_color_id,
-        t.sett_gift_price,
-        t.sett_gift_num,
+        t.promotions_id,
         t.sett_gift_status,
+        t.sett_gift_desc,
+        t.sett_gift_sort,
         t.sett_gift_create_time
     </sql>
     <select id="getSettlementGiftList" resultMap="BaseResultMap" parameterType="SettlementGift" >
         select
         <include refid="Base_List" />
-        from tb_iamberry_settlement_gift t
+        from tb_iamberry_eo_settlement_gift t
         <where>
             <if test="settGiftId != null ">
                 AND t.sett_gift_id = #{settGiftId}
             </if >
-            <if test="settGiftFillColorId != null ">
-                AND t.sett_gift_fill_color_id = #{settGiftFillColorId}
-            </if >
-            <if test="settGiftGiftColorId != null ">
-                AND t.sett_gift_gift_color_id = #{settGiftGiftColorId}
-            </if >
-            <if test="settGiftPrice != null ">
-                AND t.sett_gift_price = #{settGiftPrice}
-            </if >
-            <if test="settGiftNum != null ">
-                AND t.sett_gift_num = #{settGiftNum}
+            <if test="promotionsId != null ">
+                AND t.promotions_id = #{promotionsId}
             </if >
             <if test="settGiftStatus != null ">
                 AND t.sett_gift_status = #{settGiftStatus}
             </if >
         </where>
     </select>
+
+    <resultMap  id="BaseResultAllMap" type="SettlementGift" >
+        <result    column="sett_gift_id"    property="settGiftId" />
+        <result    column="promotions_id"    property="promotionsId" />
+        <result    column="sett_gift_status"    property="settGiftStatus" />
+        <result    column="sett_gift_desc"    property="settGiftDesc" />
+        <result    column="sett_gift_sort"    property="settGiftSort" />
+        <result    column="sett_gift_create_time"    property="settGiftCreateTime" />
+        <collection property="giftConditionList" column="sett_gift_id" ofType="GiftCondition" select="listGiftCondition"/>
+        <collection property="giftPoolList" column="sett_gift_id" ofType="GiftPool" select="listGiftPool"/>
+    </resultMap>
+    <select id="getSettlementGiftListAll" resultMap="BaseResultAllMap" parameterType="java.util.List" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_settlement_gift t
+        <where>
+            AND t.promotions_id IN (
+                <foreach collection="array" item="item" separator=",">
+                    #{item}
+                </foreach>
+            )
+            AND t.sett_gift_status = 1
+        </where>
+        ORDER BY t.sett_gift_sort
+    </select>
+
+    <select id="listGiftCondition" resultType="GiftCondition" parameterType="GiftCondition" >
+        select
+            t.gift_condition_id,
+            t.sett_gift_id,
+            t.gift_condition_fill_color_id,
+            t.gift_condition_create_time
+        from tb_iamberry_eo_gift_condition t
+        WHERE t.sett_gift_id = #{settGiftId}
+    </select>
+
+    <select id="listGiftPool" resultType="GiftPool" parameterType="GiftPool" >
+        select
+            t.gift_pool_id,
+            t.sett_gift_id,
+            t.gift_pool_color_id,
+            t.gift_pool_price,
+            t.gift_pool_num,
+            t.gift_pool_status,
+            t.gift_pool_sort,
+            t.gift_pool_stock,
+            t.gift_pool_relation,
+            t.gift_pool_relation_desc,
+            t.gift_pool_create_time
+        from tb_iamberry_eo_gift_pool t
+        WHERE t.sett_gift_id = #{settGiftId}
+        AND t.gift_pool_status = 1
+        AND t.gift_pool_stock > 0
+        ORDER BY t.gift_pool_sort
+    </select>
+
     <select id="getSettlementGiftById" resultMap="BaseResultMap" parameterType="Integer" >
         select
         <include refid="Base_List" />
-        from tb_iamberry_settlement_gift t
+        from tb_iamberry_eo_settlement_gift t
         where t.sett_gift_id= #{settGiftId}
     </select>
-    <insert id="save" parameterType="SettlementGift" >
-        insert into
-        tb_iamberry_settlement_gift
-        (
-        sett_gift_id,
-        sett_gift_fill_color_id,
-        sett_gift_gift_color_id,
-        sett_gift_price,
-        sett_gift_num,
-        sett_gift_status
-        )
-        values
-        (
-        #{settGiftId},
-        #{settGiftFillColorId},
-        #{settGiftGiftColorId},
-        #{settGiftPrice},
-        #{settGiftNum},
-        #{settGiftStatus}
-        )
-    </insert>
-    <update id="update" parameterType="SettlementGift" >
-        update
-        tb_iamberry_settlement_gift
-        <set >
-            <if test="settGiftFillColorId != null ">
-                sett_gift_fill_color_id = #{settGiftFillColorId},
-            </if >
-            <if test="settGiftGiftColorId != null ">
-                sett_gift_gift_color_id = #{settGiftGiftColorId},
-            </if >
-            <if test="settGiftPrice != null ">
-                sett_gift_price = #{settGiftPrice},
-            </if >
-            <if test="settGiftNum != null ">
-                sett_gift_num = #{settGiftNum},
-            </if >
-            <if test="settGiftStatus != null ">
-                sett_gift_status = #{settGiftStatus},
-            </if >
-        </set >
-        where sett_gift_id= #{settGiftId}
-    </update>
 </mapper>

+ 63 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/spikeMapper.xml

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.iamberry.wechat.service.mapper.SpikeMapper">
+    <resultMap  id="BaseResultMap" type="Spike" >
+        <result    column="spike_id"    property="spikeId" />
+        <result    column="promotions_id"    property="promotionsId" />
+        <result    column="spike_color_id"    property="spikeColorId" />
+        <result    column="spike_price"    property="spikePrice" />
+        <result    column="spike_discount"    property="spikeDiscount" />
+        <result    column="spike_status"    property="spikeStatus" />
+        <result    column="spike_create_time"    property="spikeCreateTime" />
+    </resultMap>
+    <sql    id="Base_List" >
+        t.spike_id,
+        t.promotions_id,
+        t.spike_color_id,
+        t.spike_price,
+        t.spike_discount,
+        t.spike_status,
+        t.spike_create_time
+    </sql>
+    <select id="getSpikeList" resultMap="BaseResultMap" parameterType="Spike" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_spike t
+        <where>
+            <if test="spikeId != null ">
+                AND t.spike_id = #{spikeId}
+            </if >
+            <if test="promotionsId != null ">
+                AND t.promotions_id = #{promotionsId}
+            </if >
+            <if test="spikeColorId != null ">
+                AND t.spike_color_id = #{spikeColorId}
+            </if >
+            <if test="spikeDiscount != null and spikeDiscount != ''">
+                AND t.spike_discount  like  CONCAT ('%',#{spikeDiscount},'%')
+            </if >
+            <if test="spikeStatus != null">
+                AND t.spike_status  = #{spikeStatus}
+            </if >
+        </where>
+    </select>
+    <select id="getSpikeListAll" resultMap="BaseResultMap" parameterType="java.util.List" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_spike t
+        <where>
+            t.spike_status  = 1
+            AND t.promotions_id IN (
+                <foreach collection="array" item="item" separator=",">
+                    #{item}
+                </foreach>
+            )
+        </where>
+    </select>
+    <select id="getSpikeById" resultMap="BaseResultMap" parameterType="Integer" >
+        select
+        <include refid="Base_List" />
+        from tb_iamberry_eo_spike t
+        where t.spike_id= #{spikeId}
+    </select>
+</mapper>

+ 27 - 12
iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/cart/CartHandlers.java

@@ -5,10 +5,15 @@ import java.util.*;
 
 import javax.servlet.http.HttpServletRequest;
 
+import com.iamberry.wechat.core.entity.eo.GiftPool;
+import com.iamberry.wechat.core.entity.eo.ItemGift;
 import com.iamberry.wechat.core.entity.order.OrderItem;
 import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.core.entity.product.SalesUserGift;
 import com.iamberry.wechat.face.cart.ProductInfoService;
+import com.iamberry.wechat.face.eo.GiftPoolService;
+import com.iamberry.wechat.face.eo.ItemGiftService;
+import com.iamberry.wechat.service.ActivityUtil;
 import com.iamberry.wechat.tools.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -55,36 +60,32 @@ public class CartHandlers {
 
 	@Autowired
 	private CartService cartService;
-
 	@Autowired
 	private WechatUtils wechatUtils;
-
 	@Autowired
 	private HomeService homeService;
-
 	@Autowired
 	private SystemService systemService;
-
 	@Autowired
 	private ValidatorUtil validatorUtil;
-
 	@Autowired
 	private AdminOrderService adminOrderService;
-
 	@Autowired
 	private PayService payService;
-
 	@Autowired
 	private MQServiceProxy mQservice;
-
 	@Autowired
 	private MemberService memberService;
-
 	@Autowired
 	private CouponItemService couponItemService;
-
 	@Autowired
-	private ProductInfoService productInfoService;
+	private ItemGiftService itemGiftService;
+	@Autowired
+	private ProductInfoService produtInfoService;
+	@Autowired
+	private GiftPoolService giftPoolService;
+	@Autowired
+	private ActivityUtil activityUtil;
 
 	/**
 	 * 进入购物车页面
@@ -98,7 +99,7 @@ public class CartHandlers {
 		ResultMsg remsg = new ResultMsg();
 		Member member =  wechatUtils.getUserBySession(request);
 		List<CartDto> cartList = cartService.selectCartByOpenId(member.getUserOpenid());
-
+		activityUtil.getColorSpike(cartList);
 		/*
 		 * 金额统计
 		 */
@@ -881,6 +882,20 @@ public class CartHandlers {
 					couponItem.setOldCouponUseStatus(7);
 					couponItemService.updateCouponItemById(couponItem);
 				}
+
+				//恢复赠品的库存
+				List<OrderItem> orderItemList = adminOrderService.getShopOrderItemByOrderId(orderId);
+				for (OrderItem orderItem:orderItemList) {
+					ItemGift itemGift = new ItemGift();
+					itemGift.setItemId(orderItem.getItemId());
+					List<ItemGift> itemGiftList = itemGiftService.getItemGiftList(itemGift);
+					for (ItemGift ig:itemGiftList) {
+						GiftPool gp = new GiftPool();
+						gp.setGiftPoolId(ig.getGiftPoolId());
+						gp.setGiftPoolStock(ig.getItemGiftNum());
+						giftPoolService.updateAddStock(gp);
+					}
+				}
 			}
 		}
 

+ 35 - 0
iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/cart/ProductInfoHandler.java

@@ -12,9 +12,12 @@ import javax.servlet.http.HttpServletResponse;
 
 import com.iamberry.wechat.core.entity.admin.ShopSystemRule;
 import com.iamberry.wechat.core.entity.cart.CartDto;
+import com.iamberry.wechat.core.entity.eo.Promotions;
+import com.iamberry.wechat.core.entity.eo.Spike;
 import com.iamberry.wechat.core.entity.product.*;
 import com.iamberry.wechat.core.entity.search.SearchInfo;
 import com.iamberry.wechat.face.cart.CartService;
+import com.iamberry.wechat.service.ActivityUtil;
 import com.iamberry.wechat.service.cart.dao.CartDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -72,6 +75,8 @@ public class ProductInfoHandler {
 
 	@Autowired
 	private CartService cartService;
+	@Autowired
+	private ActivityUtil activityUtil;
 	/**
 	 * 首页进入商城
 	 * @param request
@@ -121,6 +126,21 @@ public class ProductInfoHandler {
 		product.setProductName(productName);
 		product.setProductType(productType);
 		List<Product> productList = productInfoService.selectPageProduct(pageSize, pageNO,productName,typeId);
+		Promotions promotions = activityUtil.getAllPromotions();
+		if(promotions != null){
+			for (Product pc:productList) {
+				for (ProductColor color : pc.getProductColorList()) {
+					for (Spike spike:promotions.getSpikeList()) {
+						if(spike.getSpikeColorId() == color.getColorId()){
+							pc.setProductPrice(spike.getSpikePrice());
+							pc.setProductDiscount(spike.getSpikeDiscount());
+							color.setColorDiscount(spike.getSpikeDiscount());
+							color.setColorPrice(spike.getSpikePrice());
+						}
+					}
+				}
+			}
+		}
 		int num = this.productInfoService.selectProductCount(product);
 		int count = num % pageSize == 0? num/pageSize:(num/pageSize)+1;
 		map.put("productList", productList);
@@ -204,6 +224,20 @@ public class ProductInfoHandler {
 		
 		if (StaticInfo.pattern.matcher(productId).find()) {
  			Product product = this.productInfoService.getProductByProductId(Integer.parseInt(productId));
+			Promotions promotions = activityUtil.getAllPromotions();
+			if(promotions != null){
+				for (ProductColor color : product.getProductColorList()) {
+					for (Spike spike:promotions.getSpikeList()) {
+						if(spike.getSpikeColorId() == color.getColorId()){
+							product.setProductPrice(spike.getSpikePrice());
+							product.setProductDiscount(spike.getSpikeDiscount());
+							color.setColorDiscount(spike.getSpikeDiscount());
+							color.setColorPrice(spike.getSpikePrice());
+						}
+					}
+				}
+			}
+
 			List<ProductPicture> pictureList = productPictureService.getProductPictureByproductId(Integer.parseInt(productId));
 			product.setPictureList(pictureList);
 			/*
@@ -543,6 +577,7 @@ public class ProductInfoHandler {
 		}
 		//查询所有产品颜色
 		List<ProductColor> productColorList = productInfoService.selectColorByPid(productId);
+		activityUtil.getColorSpike(productColorList);
 		if(productColorList.size() > 0){
 			for (ProductColor color : productColorList){
 				CartDto cartDto = new CartDto();

+ 57 - 0
iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/coupon/CouponTypeHandler.java

@@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletRequest;
 
 import com.iamberry.app.tool.util.Result;
 import com.iamberry.wechat.face.coupon.WelfareService;
+import com.iamberry.wechat.tools.StrUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -479,4 +480,60 @@ public class CouponTypeHandler {
 		rm.setMessage("领取失败!请重试或在微信公众号咨询客服");
 		return rm;
 	}
+
+	/**
+	 * 用户领取优惠券接口
+	 * @return
+	 */
+	@RequestMapping("/receive_coupon_end")
+	@ResponseBody
+	public ResultMsg myReceiveCouponEnd(HttpServletRequest req,@RequestParam(value = "couponId", required = false) Integer couponId) {
+		ResultMsg rm = new ResultMsg();
+		Member member = WechatUtils.getUserBySession(req);
+		member = memberService.getMemberByUserOpenId(member.getUserOpenid());
+
+		CouponType couponType = couponTypeService.getCouponTypeById(couponId);
+		Date date = new Date();
+		if(!date.before(couponType.getCouponEndDate())){
+			rm.setStatus(false);
+			rm.setMessage("该券已过期!");
+			return rm;
+		}
+
+		CouponItemDto couponItemDto = new CouponItemDto();
+		couponItemDto.setUseropenid(member.getUserOpenid());
+		couponItemDto.setCouponId(couponId);
+		List<CouponItemDto> couponItemDtoList = couponItemService.getCouponItemDtoList(couponItemDto);
+		if(couponItemDtoList != null && couponItemDtoList.size() >= couponType.getCouponGetLimit()){
+			rm.setStatus(false);
+			rm.setMessage("已经领取过该优惠券了!");
+			return rm;
+		}
+
+		Calendar calendar = Calendar.getInstance();
+		calendar.set(2019,10,11,23,59,57);
+		synchronized (lock) {
+			//创建优惠券
+			CouponItem couponItem = new CouponItem();
+			String uuidStr = StrUtils.getUUID();
+			couponItem.setCouponItemId(uuidStr);
+			couponItem.setCouponItemUseropenid(member.getUserOpenid());
+			couponItem.setCouponId(couponType.getCouponId());
+			couponItem.setCouponReceiveDate(new Date());
+			couponItem.setCouponUseEndDate(calendar.getTime());
+			couponItem.setCouponUseStatus(1);
+			couponItem.setCouponItemRemark(couponType.getCouponRemark());
+			Integer flag = couponItemService.insertCouponItem(couponItem);
+			if(flag < 1){
+				rm.setStatus(false);
+				rm.setMessage("领取优惠券失败!");
+				return rm;
+			}else{
+				rm.setStatus(false);
+				rm.setMessage("领取成功!");
+				return rm;
+			}
+		}
+	}
+
 }

+ 32 - 0
iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/home/HomeHandler.java

@@ -1,5 +1,7 @@
 package com.iamberry.wechat.handles.home;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -12,7 +14,10 @@ import com.iamberry.wechat.core.entity.admin.ShopSystemRule;
 import com.iamberry.wechat.core.entity.product.ProductChildType;
 import com.iamberry.wechat.core.entity.product.ProductType;
 import com.iamberry.wechat.tools.WeixinUtil;
+import net.sf.json.JSONObject;
 import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Controller;
@@ -44,6 +49,8 @@ import com.iamberry.wechat.tools.ResultInfo;
 @RequestMapping("/wechat")
 public class HomeHandler {
 
+	Logger logger = LoggerFactory.getLogger(HomeHandler.class);
+
 	@Autowired
 	private HomeService homeService;
 	
@@ -84,6 +91,31 @@ public class HomeHandler {
 	@RequestMapping("/indexData")
 	public ResultMsg indexData(HttpServletRequest request) throws Exception {
 		ResultMsg msg = new ResultMsg();
+
+		Member m = WechatUtils.getUserBySession(request);
+		m = memberService.getMemberByUserOpenId(m.getUserOpenid());
+		try{
+			if(m.getUserHead() == null || "".equals(m.getUserHead())){
+				JSONObject jsonObject = WeixinUtil.getUserInfo(m.getUserOpenid());
+				String nickname = jsonObject.getString("nickname");
+				String headimgurl = jsonObject.getString("headimgurl");
+				try {
+					nickname = URLEncoder.encode(jsonObject.getString("nickname"), "UTF-8");
+				} catch (UnsupportedEncodingException e) {
+					nickname = "";
+				}
+				m.setUserHead(headimgurl);
+				m.setUserNickname(nickname);
+				if(nickname != null && !"".equals(nickname)){
+					m.setUserStatus(2);
+				}
+				homeService.updateWechatMemberInfoByByOpenid(m);
+			}
+		}catch (Exception e){
+			logger.info("获取个人信息失败;openid:"+m.getUserOpenid());
+			e.printStackTrace();
+		}
+
 		Member member =  wechatUtils.getUserBySession(request);
 		if (member == null || member.getUserOpenid() == null) {
 			msg.setMessage(ResultInfo.loginOutError);

+ 16 - 84
iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/order/OrderHandler.java

@@ -13,9 +13,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.iamberry.app.tool.log.RatFWLogger;
 import com.iamberry.wechat.core.entity.activity.ActivityDate;
 import com.iamberry.wechat.core.entity.cart.*;
+import com.iamberry.wechat.core.entity.eo.Promotions;
+import com.iamberry.wechat.core.entity.eo.SettlementGift;
 import com.iamberry.wechat.core.entity.product.Product;
-import com.iamberry.wechat.core.entity.product.SalesUserGift;
-import com.iamberry.wechat.face.cart.SettlementGiftService;
+import com.iamberry.wechat.face.eo.SettlementGiftService;
 import com.iamberry.wechat.face.order.AdminOrderService;
 import com.iamberry.wechat.service.ActivityUtil;
 import com.iamberry.wechat.tools.*;
@@ -35,7 +36,6 @@ import com.iamberry.wechat.core.entity.WechatUtils;
 import com.iamberry.wechat.core.entity.coupon.CouponItem;
 import com.iamberry.wechat.core.entity.coupon.CouponItemDto;
 import com.iamberry.wechat.core.entity.coupon.CouponType;
-import com.iamberry.wechat.core.entity.member.CashLog;
 import com.iamberry.wechat.core.entity.member.Member;
 import com.iamberry.wechat.core.entity.mq.MQMessage;
 import com.iamberry.wechat.core.entity.order.Order;
@@ -170,11 +170,13 @@ public class OrderHandler {
 		// 水机数量
 		int waterManchine = 0;
 
+		//查询活动
+		activityUtil.preferential(cartDtos);
+
 		List<CartDto> tempCarts = new ArrayList<CartDto>();
 		for (CartDto cartDto : cartDtos) {
-			cartDto = cartService.selectCartProductColor(cartDto);
 			if (cartDto.getProductStatus() != null && cartDto.getProductStatus().intValue() == 1) {
-				total += cartDto.getCartNum() * cartDto.getProductPrice();
+				total += cartDto.getCartNum() * cartDto.getProductDiscount();
 				sum++;
 				tempCarts.add(cartDto);
 			}
@@ -192,18 +194,11 @@ public class OrderHandler {
 				waterManchine++;
 			}
 		}
-
-		//添加赠品
-		ActivityDate activityDate = activityUtil.isActivity();
-		if(activityDate.isStatus()){
-			giftCart(tempCarts);
-		}
-
 		if (sum <= 0) {
 			msg.setMessage(ResultInfo.cartEmptyError);
 			return msg;
 		}
-		
+
 		//未使用的优惠券
 		CouponItemDto cDto = new CouponItemDto();
 		cDto.setUseropenid(member.getUserOpenid());
@@ -353,31 +348,31 @@ public class OrderHandler {
 			cds.add(c);
 		}
 		cartDtos = cds;
-		//添加赠品
-		ActivityDate activityDate = activityUtil.isActivity();
-		if(activityDate.isStatus()){
-			giftCart(cartDtos);
-		}
+
+		//添加赠品,秒杀
+		activityUtil.preferential(cartDtos);
+
 		for (CartDto cartDto : cartDtos) {
 			if (cartDto.getProductStatus() != null && cartDto.getProductStatus().intValue() == 1) {
 				cartIds.add(cartDto.getCartId());
-				Integer subTotal = cartDto.getCartNum() * cartDto.getProductPrice(); // 小计
+				Integer subTotal = cartDto.getCartNum() * cartDto.getProductDiscount(); // 小计
 				total += subTotal;
 				OrderItem item = new OrderItem();
 				item.setItemNum(cartDto.getCartNum());
-				item.setItemProductDiscount(cartDto.getProductPrice());
+				item.setItemProductDiscount(cartDto.getProductDiscount());
 				item.setItemProductId(cartDto.getCartProductId());
 				item.setItemProductName(cartDto.getProductName());
 				item.setItemProductPic(cartDto.getProductIntroduceImg());
 				item.setItemSalesOrderid(order.getSalesOrderid());
 				item.setItemTotal(subTotal);
-				item.setItemProductPrice(cartDto.getProductDiscount());
+				item.setItemProductPrice(cartDto.getProductPrice());
 				item.setItemColorId(cartDto.getCartColorId());
 				item.setItemProductColor(cartDto.getProductColor());
 				item.setItemProductChildType(cartDto.getProductChildType());
 				item.setItemIsSource(cartDto.getCartIsSource());
 				item.setItemProductType(cartDto.getProductType());
 				item.setItemProductChildType(cartDto.getProductChildType());
+				item.setItemGiftList(cartDto.getItemGiftList());
 				list.add(item);
 			}
 		}
@@ -682,70 +677,7 @@ public class OrderHandler {
 		return cartIntList;
 	}
 
-	/**
-	 * 赠送赠品
-	 * @param cartDtoList
-	 */
-	private void giftCart(List<CartDto> cartDtoList){
-		List<CartDto> giftList = new ArrayList<>();
-		SettlementGift settlementGift = new SettlementGift();
-		settlementGift.setSettGiftStatus(1);
-		List<SettlementGift> settlementGiftList = settlementGiftService.getSettlementGiftList(settlementGift);
-		for (CartDto cd:cartDtoList) {
-			for (SettlementGift sg:settlementGiftList) {
-				if(Objects.equals(cd.getCartColorId(), sg.getSettGiftFillColorId())){//添加赠送产品
-					CartDto cartDto = new CartDto();
-					cartDto.setCartColorId(sg.getSettGiftGiftColorId());
-					Integer num = sg.getSettGiftNum();
-					if(sg.getSettGiftNum() < 1){	//判断赠送数量,大于0就用该数量
-						num = cd.getCartNum();
-					}
-					cartDto.setCartNum(num);
-					cartDto.setProductDiscount(sg.getSettGiftPrice());
-					cartDto.setProductPrice(sg.getSettGiftPrice());
-					cartDto.setTotal(sg.getSettGiftPrice()*num);
-					giftList.add(cartDto);
-				}
-			}
-		}
 
-		List<CartDto> newGiftList = new ArrayList<>();
-		if(giftList != null && giftList.size() > 0){
-			for (CartDto carD:giftList) {
-				boolean fl = false;
-				for(CartDto newCarD:newGiftList) {
-					if(Objects.equals(newCarD.getCartColorId(), carD.getCartColorId())){	//赠品相同,合并
-						fl = true;
-						newCarD.setCartNum(newCarD.getCartNum() + carD.getCartNum());
-						newCarD.setProductDiscount(newCarD.getProductDiscount() +  carD.getProductDiscount());
-						newCarD.setProductPrice( newCarD.getProductPrice() + carD.getProductPrice());
-						newCarD.setTotal(newCarD.getTotal() + carD.getTotal());
-					}
-				}
-				if(!fl){
-					Product product = productInfoService.selectProductByColorId(carD.getCartColorId());
-					carD.setCartId(1);
-					carD.setCartProductId(product.getProductId());
-					carD.setProductName("【赠品】"+product.getProductName());
-					carD.setProductType(product.getProductTypeId());
-					carD.setProductStatus(1);
-					carD.setColorStatus(1);
-					carD.setProductIntroduceImg(product.getColorProductPic());
-					carD.setProductRemark(product.getColorPresent());
-					carD.setProductColor(product.getColorName());
-					carD.setProductIntroduceImg(product.getColorProductPic());	//productIntroduceImg
-					carD.setProductChildType(product.getProductChildTypeId());	//productChildType
-					carD.setCartIsSource(1);
-					CartDto newCartDto = new CartDto();
-					BeanUtils.copyProperties(carD,newCartDto);
-					newGiftList.add(newCartDto);
-				}
-			}
-		}
-		if(newGiftList != null && newGiftList.size() > 0){
-			cartDtoList.addAll(newGiftList);
-		}
-	}
 
 
 	/**

+ 12 - 1
iamberry-wechat-web/src/main/resources/iamberry-wechat-service-mybatis.xml

@@ -177,7 +177,13 @@
 		<typeAlias type="com.iamberry.wechat.core.entity.game.GamePrizeDto" alias="GamePrizeDto"/>
 
 		<!--赠品-->
-		<typeAlias type="com.iamberry.wechat.core.entity.cart.SettlementGift" alias="SettlementGift"/>
+		<typeAlias type="com.iamberry.wechat.core.entity.eo.SettlementGift" alias="SettlementGift"/>
+		<typeAlias type="com.iamberry.wechat.core.entity.eo.GiftCondition" alias="GiftCondition"/>
+		<typeAlias type="com.iamberry.wechat.core.entity.eo.GiftPool" alias="GiftPool"/>
+		<typeAlias type="com.iamberry.wechat.core.entity.eo.Promotions" alias="Promotions"/>
+		<typeAlias type="com.iamberry.wechat.core.entity.eo.Spike" alias="Spike"/>
+		<typeAlias type="com.iamberry.wechat.core.entity.eo.ItemGift" alias="ItemGift"/>
+
 
 		<!-- 营养自测 -->
 		<typeAlias type="com.iamberry.wechat.core.entity.questionnaire.QuestionnairePaper" alias="QuestionnairePaper"/>
@@ -261,6 +267,11 @@
 
 		<!--赠品-->
 		<mapper resource="com/iamberry/wechat/service/mapper/settlementGiftMapper.xml"/>
+		<mapper resource="com/iamberry/wechat/service/mapper/giftPoolMapper.xml"/>
+		<mapper resource="com/iamberry/wechat/service/mapper/promotionsMapper.xml"/>
+		<mapper resource="com/iamberry/wechat/service/mapper/spikeMapper.xml"/>
+		<mapper resource="com/iamberry/wechat/service/mapper/giftConditionMapper.xml"/>
+		<mapper resource="com/iamberry/wechat/service/mapper/itemGiftMapper.xml"/>
 	</mappers>
 
 </configuration>