Просмотр исходного кода

[场景投放][修改] 加入开关判断

release_toaliyun_real
masterspirit 7 лет назад
Родитель
Сommit
8072b584f2
5 измененных файлов: 40 добавлений и 8 удалений
  1. +2
    -0
      mallinkService/src/main/java/com/simple/mapper/WxCouponMapper.java
  2. +2
    -0
      mallinkService/src/main/java/com/simple/service/WxCouponService.java
  3. +26
    -8
      mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java
  4. +5
    -0
      mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java
  5. +5
    -0
      mallinkService/src/main/resources/mapper/WxCouponMapper.xml

+ 2
- 0
mallinkService/src/main/java/com/simple/mapper/WxCouponMapper.java Просмотреть файл

@@ -13,5 +13,7 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> {


WxCouponCVo selectDetailForCUser(WxCouponChannel wxCouponChannel); WxCouponCVo selectDetailForCUser(WxCouponChannel wxCouponChannel);
WxCouponCVo selectDetailForCUserC(WxCoupon wxCoupon); WxCouponCVo selectDetailForCUserC(WxCoupon wxCoupon);

void reduceInventory(@Param("id")Long id,@Param("number")Integer number);
} }

+ 2
- 0
mallinkService/src/main/java/com/simple/service/WxCouponService.java Просмотреть файл

@@ -53,4 +53,6 @@ public interface WxCouponService {
WxCouponCVo selectDetailForCUser(WxCoupon record); WxCouponCVo selectDetailForCUser(WxCoupon record);
ResultData updateCoupon(WxCoupon wxCoupon); ResultData updateCoupon(WxCoupon wxCoupon);


void reduceInventory(Long id,Integer number);

} }

+ 26
- 8
mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java Просмотреть файл

@@ -6,15 +6,14 @@ import com.github.pagehelper.PageInfo;
import com.simple.domain.po.WxCoupon; import com.simple.domain.po.WxCoupon;
import com.simple.domain.po.WxCouponOrder; import com.simple.domain.po.WxCouponOrder;
import com.simple.domain.po.WxCouponSend; import com.simple.domain.po.WxCouponSend;
import com.simple.domain.po.WxMallConfig;
import com.simple.mapper.WxCouponSendMapper; 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.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.simple.common.IdWorker; import com.simple.common.IdWorker;
import org.springframework.transaction.annotation.Transactional;


@Service @Service
public class WxCouponSendServiceImpl implements WxCouponSendService { public class WxCouponSendServiceImpl implements WxCouponSendService {
@@ -27,6 +26,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
WxCouponService wxCouponService; WxCouponService wxCouponService;
@Autowired @Autowired
WxCouponActionLogService wxCouponActionLogService; WxCouponActionLogService wxCouponActionLogService;
@Autowired
WxMallConfigService wxMallConfigService;




@Override @Override
@@ -57,24 +58,40 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
} }


@Override @Override
@Transactional
public void sendCouponToUser(String tenantId, Long cUserId, int type) { public void sendCouponToUser(String tenantId, Long cUserId, int type) {
//查询开关是否打开 //查询开关是否打开
//查询停车或者核销的券
//查询停车或者核销的券 stopCarCouponSwitch verifyConponSwitch
WxCouponSend wxCouponSendQuery = new WxCouponSend(); WxCouponSend wxCouponSendQuery = new WxCouponSend();
wxCouponSendQuery.setTenantId(tenantId); wxCouponSendQuery.setTenantId(tenantId);
int actionLogType=0; int actionLogType=0;
String configKey="";
if(type==2){ if(type==2){
//停车 //停车
wxCouponSendQuery.setSendType(2); wxCouponSendQuery.setSendType(2);
actionLogType=3; actionLogType=3;
configKey="stopCarCouponSwitch";
} }
if(type==3){ if(type==3){
//核销 //核销
wxCouponSendQuery.setSendType(3); wxCouponSendQuery.setSendType(3);
actionLogType=4; actionLogType=4;
configKey="verifyConponSwitch";
}else{ }else{
return; 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); List<WxCouponSend> wxCouponSends = wxCouponSendMapper.findList(wxCouponSendQuery);
for (WxCouponSend send:wxCouponSends) { for (WxCouponSend send:wxCouponSends) {
WxCoupon wxCoupon= wxCouponService.getById(send.getCouponId()); WxCoupon wxCoupon= wxCouponService.getById(send.getCouponId());
@@ -85,6 +102,9 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
wxCouponOrder.setCouponPrice(0); wxCouponOrder.setCouponPrice(0);
wxCouponOrder.setCreateDate(new Date()); wxCouponOrder.setCreateDate(new Date());
if (wxCoupon.getValidType() == 1) { //时间范围区间 if (wxCoupon.getValidType() == 1) { //时间范围区间
if(new Date().after(wxCoupon.getValidEndDate())){
continue;
}
wxCouponOrder.setExpiredTime(wxCoupon.getValidEndDate()); wxCouponOrder.setExpiredTime(wxCoupon.getValidEndDate());
} else { } else {
Date date = DateUtils.addDays(new Date(), wxCoupon.getValidDays()); Date date = DateUtils.addDays(new Date(), wxCoupon.getValidDays());
@@ -93,10 +113,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
wxCouponOrder.setTenantId(wxCoupon.getTenantId()); wxCouponOrder.setTenantId(wxCoupon.getTenantId());
Long couponOrderId = wxCouponOrderService.insertOne(wxCouponOrder); Long couponOrderId = wxCouponOrderService.insertOne(wxCouponOrder);
wxCouponActionLogService.addOne(tenantId, wxCoupon.getId(), couponOrderId, actionLogType, send.getId()); wxCouponActionLogService.addOne(tenantId, wxCoupon.getId(), couponOrderId, actionLogType, send.getId());
wxCouponService.reduceInventory(wxCoupon.getId(),1);
} }



} }


@Override @Override


+ 5
- 0
mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java Просмотреть файл

@@ -90,5 +90,10 @@ public class WxCouponServiceImpl implements WxCouponService {


} }


@Override
public void reduceInventory(Long id, Integer number) {
wxCouponMapper.reduceInventory(id,number);
}



} }

+ 5
- 0
mallinkService/src/main/resources/mapper/WxCouponMapper.xml Просмотреть файл

@@ -291,4 +291,9 @@


</select> </select>


<update id="reduceInventory">
update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
</update>


</mapper> </mapper>

Загрузка…
Отмена
Сохранить