diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java index 199d2aa70..c831cd48d 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -149,26 +149,28 @@ public class WxCouponController extends BaseController { } WxCouponChannel channelPriceAndStock = wxCouponChannelService.getPriceAndStock(this.getTenantInfo(), couponChannelIdL); - if (null != channelPriceAndStock.getChannelPrice() && null != channelPriceAndStock.getChannelStock()) { - return new ResultData(new StringBuffer("{").append("\"salePrice\":").append(channelPriceAndStock.getChannelPrice()) - .append(",\"remainInventory\":").append(channelPriceAndStock.getChannelStock()).append("}")); - }else { - WxCoupon coupon = couponService.getPriceAndStock(channelPriceAndStock.getCouponId(),this.getTenantInfo().getTenantId()); - StringBuffer sb = new StringBuffer("{\"salePrice\":"); - if (null != channelPriceAndStock.getChannelPrice()) { - sb.append(channelPriceAndStock.getChannelPrice()); - }else { - sb.append(coupon.getSalePrice()); - } - sb.append(",\"remainInventory\":"); - if (null != channelPriceAndStock.getChannelStock()) { - sb.append(channelPriceAndStock.getChannelStock()); - }else { - sb.append(coupon.getRemainInventory()); - } - sb.append("}"); - return new ResultData(sb.toString()); + if (null == channelPriceAndStock) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId非法"); } + + WxCoupon coupon = couponService.getPriceAndStock(channelPriceAndStock.getCouponId(),this.getTenantInfo().getTenantId()); + if (null == coupon) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId查询不到coupon"); + } + StringBuffer sb = new StringBuffer("{\"salePrice\":"); + if (null != channelPriceAndStock.getChannelPrice()) { + sb.append(channelPriceAndStock.getChannelPrice()); + }else { + sb.append(coupon.getSalePrice()); + } + sb.append(",\"remainInventory\":"); + if (null != channelPriceAndStock.getChannelStock()) { + sb.append(channelPriceAndStock.getChannelStock()); + }else { + sb.append(coupon.getRemainInventory()); + } + sb.append(",\"inventory\":").append(coupon.getInventory()).append(",\"price\":").append(coupon.getPrice()).append("}"); + return new ResultData(sb.toString()); } @ApiOperation("根据id(couponChannel)查询商品商户接口")