Kaynağa Gözat

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

release_toaliyun_real
masterspirit 7 yıl önce
ebeveyn
işleme
8072b584f2
5 değiştirilmiş dosya ile 40 ekleme ve 8 silme
  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 Dosyayı Görüntüle

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

WxCouponCVo selectDetailForCUser(WxCouponChannel wxCouponChannel);
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 Dosyayı Görüntüle

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

void reduceInventory(Long id,Integer number);

}

+ 26
- 8
mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java Dosyayı Görüntüle

@@ -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


+ 5
- 0
mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

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

</select>

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


</mapper>

Yükleniyor…
İptal
Kaydet