Kaynağa Gözat

生日积分定时任务配置

release_toaliyun_real
Burce 6 yıl önce
ebeveyn
işleme
cbd6e9a234
1 değiştirilmiş dosya ile 25 ekleme ve 22 silme
  1. +25
    -22
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java

+ 25
- 22
mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java Dosyayı Görüntüle

@@ -489,19 +489,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
public void saveOrUpdateConfig(Integer beforeDays, Integer sendType, String tenantId) {
WxCouponSend config = getConfig(sendType, tenantId);
if (Objects.isNull(config)) {
WxCouponSend couponSendQuery = new WxCouponSend();
couponSendQuery.setSendType(sendType);
couponSendQuery.setTenantId(tenantId);
couponSendQuery.setCouponId(0L);
couponSendQuery.setTitle(EnumCouponSendSendType.BIRTHDAY.getMessage() + "配置信息 ");
final IdWorker idWorker = IdWorker.get();
couponSendQuery.setId(idWorker.nextId());
couponSendQuery.setStatus(EnumCouponSendStatus.INVALID.getCode());
couponSendQuery.setCreateDate(new Date());
JSONObject couponSendJo = new JSONObject();
couponSendJo.put(WxCouponSend.KEY_BEFOREDAYS, beforeDays);
couponSendQuery.setConditions(couponSendJo.toJSONString());
wxCouponSendMapper.insertSelective(couponSendQuery);
WxCouponSend couponSendQuery = createCouponSendQuery(sendType, tenantId) ;
insertCouponSend(beforeDays, couponSendQuery);
} else {
JSONObject couponSendJo = JSONObject.parseObject(config.getConditions());
if (Objects.isNull(couponSendJo)) {
@@ -514,25 +503,39 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
}
}

private void insertCouponSend(Integer beforeDays, WxCouponSend couponSendQuery) {
couponSendQuery.setTitle(EnumCouponSendSendType.BIRTHDAY.getMessage() + "配置信息 ");
final IdWorker idWorker = IdWorker.get();
couponSendQuery.setId(idWorker.nextId());
couponSendQuery.setCreateDate(new Date());
JSONObject couponSendJo = new JSONObject();
couponSendJo.put(WxCouponSend.KEY_BEFOREDAYS, beforeDays);
couponSendQuery.setConditions(couponSendJo.toJSONString());
wxCouponSendMapper.insertSelective(couponSendQuery);
}

@Override
public WxCouponSend getConfig(Integer sendType, String tenantId) {
WxCouponSend couponSendQuery = new WxCouponSend();
couponSendQuery.setSendType(sendType);
couponSendQuery.setTenantId(tenantId);
couponSendQuery.setCouponId(0L);
WxCouponSend couponSendQuery = createCouponSendQuery(sendType, tenantId) ;
//读取会员生日券配置信息
couponSendQuery.setStatus(EnumCouponSendStatus.INVALID.getCode());
List<WxCouponSend> wxCouponSendList = wxCouponSendMapper.select(couponSendQuery);
if (CollectionUtils.isEmpty(wxCouponSendList)) {
//默认配置
JSONObject couponSendJo = new JSONObject();
couponSendJo.put(WxCouponSend.KEY_BEFOREDAYS, 0);
couponSendQuery.setConditions(couponSendJo.toJSONString());
//配置不存在,添加默认配置
insertCouponSend(0, couponSendQuery);
return couponSendQuery;
}
return wxCouponSendList.get(0);
}

private WxCouponSend createCouponSendQuery(Integer sendType, String tenantId) {
WxCouponSend couponSendQuery = new WxCouponSend();
couponSendQuery.setSendType(sendType);
couponSendQuery.setTenantId(tenantId);
couponSendQuery.setCouponId(0L);
couponSendQuery.setStatus(EnumCouponSendStatus.INVALID.getCode());
return couponSendQuery ;
}

@Override
public void reduceMerchantRemainInventory(Long id, Integer remainInventory, Integer number) {
int num = wxCouponSendMapper.reduceMerchantRemainInventory(id, remainInventory, number);


Yükleniyor…
İptal
Kaydet