|
|
|
@@ -6,15 +6,14 @@ import com.github.pagehelper.PageInfo; |
|
|
|
import com.simple.domain.po.WxCoupon; |
|
|
|
import com.simple.domain.po.WxCouponOrder; |
|
|
|
import com.simple.domain.po.WxCouponSend; |
|
|
|
import com.simple.domain.po.WxMallConfig; |
|
|
|
import com.simple.mapper.WxCouponSendMapper; |
|
|
|
import com.simple.service.WxCouponActionLogService; |
|
|
|
import com.simple.service.WxCouponOrderService; |
|
|
|
import com.simple.service.WxCouponSendService; |
|
|
|
import com.simple.service.WxCouponService; |
|
|
|
import com.simple.service.*; |
|
|
|
import org.apache.commons.lang.time.DateUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.simple.common.IdWorker; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
@@ -27,6 +26,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
WxCouponService wxCouponService; |
|
|
|
@Autowired |
|
|
|
WxCouponActionLogService wxCouponActionLogService; |
|
|
|
@Autowired |
|
|
|
WxMallConfigService wxMallConfigService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -57,24 +58,40 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void sendCouponToUser(String tenantId, Long cUserId, int type) { |
|
|
|
//查询开关是否打开 |
|
|
|
//查询停车或者核销的券 |
|
|
|
//查询停车或者核销的券 stopCarCouponSwitch verifyConponSwitch |
|
|
|
WxCouponSend wxCouponSendQuery = new WxCouponSend(); |
|
|
|
wxCouponSendQuery.setTenantId(tenantId); |
|
|
|
int actionLogType=0; |
|
|
|
String configKey=""; |
|
|
|
if(type==2){ |
|
|
|
//停车 |
|
|
|
wxCouponSendQuery.setSendType(2); |
|
|
|
actionLogType=3; |
|
|
|
configKey="stopCarCouponSwitch"; |
|
|
|
} |
|
|
|
if(type==3){ |
|
|
|
//核销 |
|
|
|
wxCouponSendQuery.setSendType(3); |
|
|
|
actionLogType=4; |
|
|
|
configKey="verifyConponSwitch"; |
|
|
|
}else{ |
|
|
|
return; |
|
|
|
} |
|
|
|
WxMallConfig wxMallConfigQuery = new WxMallConfig(); |
|
|
|
wxMallConfigQuery.setKey(configKey); |
|
|
|
wxMallConfigQuery.setTenantId(tenantId); |
|
|
|
PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfigQuery, 1, 1); |
|
|
|
if(page.getSize()>0) { |
|
|
|
WxMallConfig config = page.getList().get(0); |
|
|
|
if(config.getValue()==1){ |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<WxCouponSend> wxCouponSends = wxCouponSendMapper.findList(wxCouponSendQuery); |
|
|
|
for (WxCouponSend send:wxCouponSends) { |
|
|
|
WxCoupon wxCoupon= wxCouponService.getById(send.getCouponId()); |
|
|
|
@@ -85,6 +102,9 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
wxCouponOrder.setCouponPrice(0); |
|
|
|
wxCouponOrder.setCreateDate(new Date()); |
|
|
|
if (wxCoupon.getValidType() == 1) { //时间范围区间 |
|
|
|
if(new Date().after(wxCoupon.getValidEndDate())){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
wxCouponOrder.setExpiredTime(wxCoupon.getValidEndDate()); |
|
|
|
} else { |
|
|
|
Date date = DateUtils.addDays(new Date(), wxCoupon.getValidDays()); |
|
|
|
@@ -93,10 +113,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
wxCouponOrder.setTenantId(wxCoupon.getTenantId()); |
|
|
|
Long couponOrderId = wxCouponOrderService.insertOne(wxCouponOrder); |
|
|
|
wxCouponActionLogService.addOne(tenantId, wxCoupon.getId(), couponOrderId, actionLogType, send.getId()); |
|
|
|
wxCouponService.reduceInventory(wxCoupon.getId(),1); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|