|
|
@@ -14,6 +14,7 @@ import com.opensymphony.xwork2.ActionSupport;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.apache.struts2.ServletActionContext;
|
|
|
import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@@ -139,6 +140,16 @@ public class AppHotelCouponAction extends ActionSupport implements ServletReques
|
|
|
this.bookingId = bookingId;
|
|
|
}
|
|
|
|
|
|
+ public Double totalPrice;
|
|
|
+
|
|
|
+ public Double getTotalPrice() {
|
|
|
+ return totalPrice;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setTotalPrice(Double totalPrice) {
|
|
|
+ this.totalPrice = totalPrice;
|
|
|
+ }
|
|
|
+
|
|
|
@Resource
|
|
|
BookService bookService;
|
|
|
|
|
|
@@ -296,10 +307,10 @@ public class AppHotelCouponAction extends ActionSupport implements ServletReques
|
|
|
public JSONObject usefulCoupon() {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
- if (Func.checkNull(hotelId) && Func.checkNull(userId)) {
|
|
|
+ if (Func.checkNull(hotelId) && Func.checkNull(userId)&&totalPrice==null) {
|
|
|
jsonObject.put("code", 400);
|
|
|
jsonObject.put("success", false);
|
|
|
- jsonObject.put("message", "缺少数据hotelId或userId---usefulCoupon");
|
|
|
+ jsonObject.put("message", "缺少数据hotelId,userId,totalPrice---usefulCoupon");
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
return null;
|
|
|
}
|
|
|
@@ -312,7 +323,7 @@ public class AppHotelCouponAction extends ActionSupport implements ServletReques
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- IPage<UsefulCouponVo> iPage = hotelCoupomService.usefulCoupon(hotelId, userId, page, rows);
|
|
|
+ IPage<UsefulCouponVo> iPage = hotelCoupomService.usefulCoupon(hotelId, userId, page, rows,totalPrice);
|
|
|
|
|
|
jsonObject.put("code", 200);
|
|
|
jsonObject.put("success", true);
|
|
|
@@ -404,6 +415,23 @@ public class AppHotelCouponAction extends ActionSupport implements ServletReques
|
|
|
useCouponsVo.setDiscountAmount(deductionPrice);
|
|
|
|
|
|
} else if (2 == type1) {
|
|
|
+ // 满减金额
|
|
|
+ Double meetPrice = hotelCoupon.getMeetPrice();
|
|
|
+ if (meetPrice==null||meetPrice<0) {
|
|
|
+ meetPrice=0.0;
|
|
|
+ }
|
|
|
+ BigDecimal meetPriceBigDecimal = new BigDecimal(meetPrice);
|
|
|
+
|
|
|
+ if (meetPrice > totalPrice) {
|
|
|
+ BigDecimal subtract = meetPriceBigDecimal.subtract(houseTotalPriceBigDecimal);
|
|
|
+ double v = subtract.doubleValue();
|
|
|
+ jsonObject.put("code", 400);
|
|
|
+ jsonObject.put("success", false);
|
|
|
+ jsonObject.put("message", "还差" + v + "元可使用");
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
// 享受的折扣
|
|
|
Double rebatePrice = hotelCoupon.getRebatePrice();
|
|
|
BigDecimal rebatePriceBigDecimal = new BigDecimal(rebatePrice/10);
|