|
|
@ -2,15 +2,17 @@ package com.hai.goods.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.hai.dao.GoodsPresentMapper; |
|
|
|
import com.hai.dao.GoodsPresentMapper; |
|
|
|
import com.hai.dao.GoodsPresentRecordMapper; |
|
|
|
import com.hai.dao.GoodsPresentRecordMapper; |
|
|
|
import com.hai.entity.GoodsPresent; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.entity.GoodsPresentExample; |
|
|
|
|
|
|
|
import com.hai.entity.GoodsPresentRecord; |
|
|
|
|
|
|
|
import com.hai.entity.GoodsRegionFreight; |
|
|
|
|
|
|
|
import com.hai.goods.service.GoodsPresentService; |
|
|
|
import com.hai.goods.service.GoodsPresentService; |
|
|
|
|
|
|
|
import com.hai.service.HighCouponCodeService; |
|
|
|
|
|
|
|
import com.hai.service.HighCouponService; |
|
|
|
|
|
|
|
import com.hai.service.HighDiscountAgentCodeService; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
@ -23,6 +25,18 @@ public class GoodsPresentServiceImpl implements GoodsPresentService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private GoodsPresentRecordMapper goodsPresentRecordMapper; |
|
|
|
private GoodsPresentRecordMapper goodsPresentRecordMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private GoodsPresentService goodsPresentService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighCouponService highCouponService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighCouponCodeService couponCodeService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighDiscountAgentCodeService highDiscountAgentCodeService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void insertPresent(GoodsPresent present) { |
|
|
|
public void insertPresent(GoodsPresent present) { |
|
|
|
goodsPresentMapper.insert(present); |
|
|
|
goodsPresentMapper.insert(present); |
|
|
@ -78,4 +92,50 @@ public class GoodsPresentServiceImpl implements GoodsPresentService { |
|
|
|
public List<GoodsPresentRecord> getPresentRecord(Map<String, Object> map) { |
|
|
|
public List<GoodsPresentRecord> getPresentRecord(Map<String, Object> map) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Async |
|
|
|
|
|
|
|
public void presentUser(HighOrder order, HighChildOrder highChildOrder) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 赠送卡券or优惠券
|
|
|
|
|
|
|
|
List<GoodsPresent> goodsPresents = goodsPresentService.getPresentList(highChildOrder.getGoodsId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (goodsPresents.size() > 0) { |
|
|
|
|
|
|
|
for (int j = 0; j < highChildOrder.getSaleCount(); j++) { |
|
|
|
|
|
|
|
for (GoodsPresent present : goodsPresents) { |
|
|
|
|
|
|
|
GoodsPresentRecord presentRecord = new GoodsPresentRecord(); |
|
|
|
|
|
|
|
presentRecord.setStatus("0"); |
|
|
|
|
|
|
|
if (present.getType() == 1) { |
|
|
|
|
|
|
|
for (int i = 0; i < present.getNum(); i++) { |
|
|
|
|
|
|
|
HighCoupon coupon = highCouponService.getCouponById(present.getSourceId()); |
|
|
|
|
|
|
|
// 支付购买卡券
|
|
|
|
|
|
|
|
couponCodeService.payCoupon(order,highChildOrder,coupon); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (present.getType() == 2) { |
|
|
|
|
|
|
|
highDiscountAgentCodeService.giveDiscount(present.getSourceId() , Long.valueOf(present.getNum()), order.getMemId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
presentRecord.setOrderNo(order.getOrderNo()); |
|
|
|
|
|
|
|
presentRecord.setOrderId(order.getId()); |
|
|
|
|
|
|
|
presentRecord.setChildOrderId(highChildOrder.getOrderId()); |
|
|
|
|
|
|
|
presentRecord.setCreateTime(new Date()); |
|
|
|
|
|
|
|
presentRecord.setNum(presentRecord.getNum()); |
|
|
|
|
|
|
|
presentRecord.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
presentRecord.setType(present.getType()); |
|
|
|
|
|
|
|
presentRecord.setStatus("1"); |
|
|
|
|
|
|
|
presentRecord.setSourceId(present.getSourceId()); |
|
|
|
|
|
|
|
presentRecord.setSourceName(present.getSourceName()); |
|
|
|
|
|
|
|
presentRecord.setOpName("系统赠送"); |
|
|
|
|
|
|
|
presentRecord.setPresentId(present.getId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
goodsPresentService.insertPresentRecord(presentRecord); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|