Browse Source

fix bug

release_toaliyun_real
winter 4 years ago
parent
commit
5d4eaa8e45
6 changed files with 87 additions and 35 deletions
  1. +20
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java
  2. +22
    -3
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java
  3. +16
    -0
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java
  4. +20
    -2
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java
  5. +1
    -30
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java
  6. +8
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java

+ 20
- 0
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java View File

@@ -14,6 +14,7 @@ import com.iformall.domain.po.base.BaseEntity;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import com.iformall.service.util.CouponCacheUtils;
import com.iformall.utils.RedisLock;

import io.swagger.annotations.Api;
@@ -24,6 +25,8 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
@@ -45,6 +48,10 @@ public class WxCouponChannelController extends BaseController {
@Autowired
private WxCouponService wxCouponService;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;

@ApiOperation("分页列表接口")
@GetMapping("list")
@@ -86,6 +93,7 @@ public class WxCouponChannelController extends BaseController {
if(couponChannel!=null){
wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType());
}
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return resultData;
}

@@ -109,6 +117,14 @@ public class WxCouponChannelController extends BaseController {
String[] channelId = wxCouponChannelDto.getChannelId().split(",");
ResultData resultData = wxCouponChannelService.addBatch(wxCouponChannelDto.getType(),ids, channelId, getTenantInfo(),
wxCouponChannelDto.getShowBeginTime(), wxCouponChannelDto.getBeginTime(), wxCouponChannelDto.getEndTime(),wxCouponChannelDto.getChannelPrice(),wxCouponChannelDto.getChannelStock());
if (null != channelId && channelId.length > 0 ) {
for (String chId: channelId) {
if (!StringUtils.isBlank(chId)) {
CouponCacheUtils.removeCouponChannelCache(redisTemplate, Long.parseLong(chId));
}
}
}
return resultData;
}

@@ -149,6 +165,7 @@ public class WxCouponChannelController extends BaseController {
wxCouponChannelService.setChannelStock(wxCouponChannel, wxCouponChannel.getChannelStock());
redisLock.setCouponStock(wxCouponChannel.getCouponId(), coupon.getRemainInventory());
redisLock.setCouponChannelStock(wxCouponChannel.getId(), wxCouponChannel.getChannelStock());
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("setChannelStock error.",e);
@@ -168,6 +185,7 @@ public class WxCouponChannelController extends BaseController {
wxCouponChannelService.releaseChannelStock(wxCouponChannel);
redisLock.removeCouponStock(wxCouponChannel.getCouponId());
redisLock.removeCouponChannelStock(wxCouponChannel.getId());
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("releaseChannelStock error.",e);
@@ -188,6 +206,7 @@ public class WxCouponChannelController extends BaseController {
try {
wxCouponChannel.updateTenantInfo(getTenantInfo());
wxCouponChannelService.setChannelPrice(wxCouponChannel);
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("setChannelPrice error.",e);
@@ -205,6 +224,7 @@ public class WxCouponChannelController extends BaseController {
wxCouponChannel.updateTenantInfo(getTenantInfo());
try {
wxCouponChannelService.setChannelPrice(wxCouponChannel);
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("releaseSetChannelPrice error.",e);


+ 22
- 3
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java View File

@@ -21,6 +21,7 @@ import com.iformall.service.WxCouponService;
import com.iformall.service.WxFlowService;
import com.iformall.service.WxMallService;
import com.iformall.service.WxPayAccountService;
import com.iformall.service.util.CouponCacheUtils;
import com.iformall.utils.DateUtils;
import com.iformall.utils.RedisLock;

@@ -34,6 +35,8 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
@@ -58,6 +61,10 @@ public class WxCouponController extends BaseController {
private WxMallService wxMallService;
@Autowired
RedisLock redisLock;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;

@ApiOperation("分页列表接口")
@GetMapping("list")
@@ -170,6 +177,8 @@ public class WxCouponController extends BaseController {
//修改coupon applyStatus状态为审核中
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
}
CouponCacheUtils.setCouponCache(redisTemplate, wxCoupon.getId(), wxCoupon);
return resultData;
}

@@ -213,7 +222,10 @@ public class WxCouponController extends BaseController {
}
}
return wxCouponService.saveOrUpdate(wxCoupon);
ResultData result = wxCouponService.saveOrUpdate(wxCoupon);
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId());
return result;
}

@ApiOperation("根据id更新库存及有效期接口")
@@ -336,7 +348,7 @@ public class WxCouponController extends BaseController {
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
return wxCouponService.updateCouponStockAndEndTime(wxCoupon);
}
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
return new ResultData();
}

@@ -347,6 +359,8 @@ public class WxCouponController extends BaseController {
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::delete");
wxCouponService.deleteById(id,getTenantInfo().getTenantId());
CouponCacheUtils.removeCouponCache(redisTemplate, id);
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@@ -498,6 +512,9 @@ public class WxCouponController extends BaseController {
wxCouponPassword.setCouponId(0L);
}
couponPasswordService.exportData(request, response, wxCouponPassword);
if (null != wxCouponPassword.getCouponId()) {
CouponCacheUtils.removeCouponCache(redisTemplate, wxCouponPassword.getCouponId());
}
}

@ApiOperation("根据id获取富文本接口")
@@ -520,7 +537,9 @@ public class WxCouponController extends BaseController {
return new ResultData(ResultData.ERROR, "缺少validEndDate");
}
return new ResultData(wxCouponService.cardDefer(wxCoupon.getId(),getTenantInfo().getTenantId(),wxCoupon.getValidEndDate()));
ResultData result = wxCouponService.cardDefer(wxCoupon.getId(),getTenantInfo().getTenantId(),wxCoupon.getValidEndDate());
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
return result;
}

}

+ 16
- 0
mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java View File

@@ -9,6 +9,8 @@ import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.util.CouponCacheUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -17,6 +19,8 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
@@ -32,6 +36,10 @@ public class WxCouponChannelController extends BaseController {

@Autowired
private WxCouponChannelService wxCouponChannelService;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;

@ApiOperation("分页列表接口")
@GetMapping("list")
@@ -68,6 +76,7 @@ public class WxCouponChannelController extends BaseController {
if(couponChannel!=null){
wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType());
}
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return resultData;
}

@@ -88,6 +97,13 @@ public class WxCouponChannelController extends BaseController {
String[] ids = wxCouponChannelDto.getCouponIds().split(",");
String[] channelId = wxCouponChannelDto.getChannelId().split(",");
ResultData resultData = wxCouponChannelService.addBatch(wxCouponChannelDto.getType(),ids, channelId, getTenantInfo(),wxCouponChannelDto.getShowBeginTime(), wxCouponChannelDto.getBeginTime(), wxCouponChannelDto.getEndTime(),null,null);
if (null != channelId && channelId.length > 0 ) {
for (String chId: channelId) {
if (!StringUtils.isBlank(chId)) {
CouponCacheUtils.removeCouponChannelCache(redisTemplate, Long.parseLong(chId));
}
}
}
return resultData;
}



+ 20
- 2
mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java View File

@@ -17,6 +17,7 @@ import com.iformall.domain.vo.WxCouponStatisVo;
import com.iformall.enums.*;
import com.iformall.mapper.WxCouponChannelMapper;
import com.iformall.service.*;
import com.iformall.service.util.CouponCacheUtils;
import com.iformall.utils.DateUtils;
import com.iformall.utils.RedisLock;
import io.swagger.annotations.Api;
@@ -29,6 +30,8 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
@@ -55,6 +58,10 @@ public class WxCouponController extends BaseController {
private WxMallService wxMallService;
@Autowired
RedisLock redisLock;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;

@ApiOperation("分页列表接口")
@GetMapping("list")
@@ -217,6 +224,7 @@ public class WxCouponController extends BaseController {
//修改coupon applyStatus状态为审核中
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
}
CouponCacheUtils.setCouponCache(redisTemplate, wxCoupon.getId(), wxCoupon);
return resultData;
}

@@ -252,7 +260,10 @@ public class WxCouponController extends BaseController {
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId());
}
redisLock.setCouponStock(wxCoupon.getId(), coupon.getRemainInventory());
return wxCouponService.saveOrUpdate(wxCoupon);
ResultData result = wxCouponService.saveOrUpdate(wxCoupon);
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId());
return result;
}

@ApiOperation("根据id更新库存及有效期接口")
@@ -323,7 +334,9 @@ public class WxCouponController extends BaseController {
}
}
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
return wxCouponService.updateCouponStockAndEndTime(wxCoupon);
ResultData result = wxCouponService.updateCouponStockAndEndTime(wxCoupon);
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
return result;
}

@ApiOperation("根据id删除接口")
@@ -335,6 +348,8 @@ public class WxCouponController extends BaseController {
}
logger.debug("[" + getIpAddr() + "] WxCouponController::delete");
wxCouponService.deleteById(id,getTenantInfo().getTenantId());
CouponCacheUtils.removeCouponCache(redisTemplate, id);
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@@ -433,6 +448,9 @@ public class WxCouponController extends BaseController {
wxCouponPassword.setCouponId(0L);
}
couponPasswordService.exportData(request, response, wxCouponPassword);
if (null != wxCouponPassword.getCouponId()) {
CouponCacheUtils.removeCouponCache(redisTemplate, wxCouponPassword.getCouponId());
}
}

@ApiOperation("根据id获取富文本接口")


+ 1
- 30
mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java View File

@@ -221,10 +221,7 @@ public class WxCouponController extends BaseController {
}

@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> objectCommonRedisTemplate;

@Deprecated
@ApiOperation("根据id(couponChannel)查询接口")
@GetMapping("/detail")
@ApiImplicitParams({
@@ -371,32 +368,6 @@ public class WxCouponController extends BaseController {
return new ResultData(wxCouponCVo);
}

// @ApiOperation("根据id(couponId)查询接口")
// @GetMapping("/getMerchantList")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "couponId", value = "couponId", dataType = "String", paramType = "query", required = true)
// })
// public ResultData getMerchantList(Long couponId) {
//
// if (couponId == null) {
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
//
// String key = Constant.coupon_merchants_key+getTenantInfo().getTenantId()+":"+couponId;
//
// List<WxMerchantVo> valueList = RedisCacheUtils.getCacheListObject(objectCommonRedisTemplate, key, WxMerchantVo.class);
// if(valueList != null && valueList.size() > 0){
// return new ResultData(valueList);
// }
// valueList = couponService.getCouponMerchantList(getTenantInfo(),couponId);
// if(valueList == null || valueList.size() == 0){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
// }
//
// RedisCacheUtils.cache(objectCommonRedisTemplate,key,valueList,3600l);
// return new ResultData(valueList);
// }
private WxCouponCVo generateWxCouponCVo(Long couponChannelIdL,String tenantId) {
WxCouponChannel cc = wxCouponChannelService.getById(couponChannelIdL,tenantId);
if (cc == null) {


+ 8
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java View File

@@ -19,6 +19,7 @@ import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.*;
import com.iformall.service.*;
import com.iformall.service.util.CouponCacheUtils;
import com.iformall.utils.Constant;
import com.iformall.utils.DateUtils;
import org.apache.commons.collections.CollectionUtils;
@@ -26,7 +27,9 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
@@ -143,6 +146,10 @@ public class WxMerchantServiceImpl implements WxMerchantService {
@Autowired
WxBrandMapper wxBrandMapper;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;

@Override
public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) {
@@ -446,6 +453,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {
wxCoupon.updateTenantInfo(wxMerchant);
wxCoupon.setStatus(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode());
wxCouponService.saveOrUpdate(wxCoupon);
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, cid);
});
}
}


Loading…
Cancel
Save