Przeglądaj źródła

Merge branch 'devlocal' into develop

release_toaliyun_real
Burce 6 lat temu
rodzic
commit
40ec1d7e7a
1 zmienionych plików z 25 dodań i 22 usunięć
  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 Wyświetl plik

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


Ładowanie…
Anuluj
Zapisz