|
|
|
@@ -133,8 +133,7 @@ public class WxCouponController extends BaseController { |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) |
|
|
|
public ResultData couponPriceAndStock(String couponChannelId) { |
|
|
|
if ((StringUtils.isBlank(couponChannelId) || couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) |
|
|
|
) { |
|
|
|
if ((StringUtils.isBlank(couponChannelId) || couponChannelId.equalsIgnoreCase(Constant.UNDEFINED))) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); |
|
|
|
} |
|
|
|
Long couponChannelIdL = 0L; |
|
|
|
@@ -177,6 +176,102 @@ public class WxCouponController extends BaseController { |
|
|
|
return new ResultData(sb.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("批量根据id(couponChannel)查询库存价格接口") |
|
|
|
@GetMapping("/batchCouponPriceAndStock") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "couponChannelIds", value = "couponChannelIds", dataType = "String", paramType = "query", required = true)}) |
|
|
|
public ResultData batchCouponPriceAndStock(String couponChannelIds) { |
|
|
|
if ((StringUtils.isBlank(couponChannelIds) || couponChannelIds.equalsIgnoreCase(Constant.UNDEFINED))) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); |
|
|
|
} |
|
|
|
|
|
|
|
String[] couponChannelSs = couponChannelIds.split(","); |
|
|
|
if (null == couponChannelSs || couponChannelSs.length <= 0 ) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> ccids = new ArrayList<Long>();; |
|
|
|
for (int i = 0 ; i < couponChannelSs.length; i ++ ) { |
|
|
|
Long couponChannelIdL = 0L; |
|
|
|
String ccid = couponChannelSs[i]; |
|
|
|
try { |
|
|
|
if (StringUtils.isNotBlank(ccid) && !ccid.equalsIgnoreCase(Constant.UNDEFINED)) { |
|
|
|
couponChannelIdL = Long.valueOf(ccid); |
|
|
|
} |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
logger.error("id转换失败" + ccid); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + ccid); |
|
|
|
} |
|
|
|
|
|
|
|
if(couponChannelIdL <= 0){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); |
|
|
|
} |
|
|
|
ccids.add(couponChannelIdL); |
|
|
|
} |
|
|
|
|
|
|
|
List<WxCouponChannel> channelPriceAndStock = wxCouponChannelService.getPriceAndStock(this.getTenantInfo(), ccids); |
|
|
|
if (null == channelPriceAndStock || channelPriceAndStock.size() <= 0 ) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId非法"); |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> couponIds = new ArrayList<Long>(); |
|
|
|
List<Long> couponChannelList = new ArrayList<Long>(); |
|
|
|
Map<Long,WxCouponChannel> couponChannelMap = new HashMap<Long,WxCouponChannel>(); |
|
|
|
for (int i = 0 ; i < channelPriceAndStock.size() ; i ++ ) { |
|
|
|
WxCouponChannel cc = channelPriceAndStock.get(i); |
|
|
|
couponChannelList.add(cc.getId()); |
|
|
|
if (null != cc.getCouponId()) { |
|
|
|
couponIds.add(cc.getCouponId()); |
|
|
|
} |
|
|
|
couponChannelMap.put(cc.getId(), cc); |
|
|
|
} |
|
|
|
|
|
|
|
if (couponIds.size() <= 0 ) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId查询不到coupon"); |
|
|
|
} |
|
|
|
|
|
|
|
List<WxCoupon> couponList = couponService.getPriceAndStock(couponIds,this.getTenantInfo().getTenantId()); |
|
|
|
if (null == couponList) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId查询不到coupon"); |
|
|
|
} |
|
|
|
Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>(); |
|
|
|
for (int i = 0 ; i < couponList.size() ; i ++ ) { |
|
|
|
WxCoupon cc = couponList.get(i); |
|
|
|
couponMap.put(cc.getId(), cc); |
|
|
|
} |
|
|
|
StringBuffer sb = new StringBuffer("["); |
|
|
|
for (int i = 0 ; i < couponChannelList.size() ; i ++) { |
|
|
|
Long ccid = couponChannelList.get(i); |
|
|
|
WxCouponChannel cc = couponChannelMap.get(ccid); |
|
|
|
if (null != cc) { |
|
|
|
WxCoupon coupon = null; |
|
|
|
if (null != cc.getCouponId()) { |
|
|
|
coupon = couponMap.get(cc.getCouponId()); |
|
|
|
} |
|
|
|
if (null == coupon) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId查询不到coupon"); |
|
|
|
} |
|
|
|
sb.append("{\"salePrice\":"); |
|
|
|
if (null != cc.getChannelPrice()) { |
|
|
|
sb.append(cc.getChannelPrice()); |
|
|
|
}else { |
|
|
|
sb.append(coupon.getSalePrice()); |
|
|
|
} |
|
|
|
sb.append(",\"remainInventory\":"); |
|
|
|
if (null != cc.getChannelStock()) { |
|
|
|
sb.append(cc.getChannelStock()); |
|
|
|
}else { |
|
|
|
sb.append(coupon.getRemainInventory()); |
|
|
|
} |
|
|
|
sb.append(",\"inventory\":").append(coupon.getInventory()).append(",\"price\":").append(coupon.getPrice()).append(",\"creditPrice\":").append(coupon.getCreditPrice()).append("}"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
sb.append("]"); |
|
|
|
|
|
|
|
return new ResultData(sb.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("根据id(couponChannel)查询商品商户接口") |
|
|
|
@GetMapping("/couponMerchant") |
|
|
|
@ApiImplicitParams({ |
|
|
|
|