折扣
This commit is contained in:
@@ -22,6 +22,7 @@ import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.CouponHistoryService;
|
||||
import com.peanut.modules.common.service.CouponService;
|
||||
import com.peanut.modules.common.service.JfTransactionDetailsService;
|
||||
import com.peanut.modules.common.service.UserVipService;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import com.peanut.modules.sys.entity.SysConfigEntity;
|
||||
@@ -55,6 +56,8 @@ public class BuyOrderController {
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
@Autowired
|
||||
private OrderCartService orderCartService;
|
||||
@@ -148,6 +151,67 @@ public class BuyOrderController {
|
||||
return R.ok().put("map",m);
|
||||
}
|
||||
|
||||
//获取商品vip折扣金额
|
||||
@RequestMapping("/getVipDiscountAmount")
|
||||
public R getVipDiscountAmount(@RequestBody BuyOrder buyOrder){
|
||||
BigDecimal b = new BigDecimal(0);
|
||||
if (!userVipService.noVip()){
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
BigDecimal pvda = shopProductService.getVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
|
||||
b = b.add(pvda.multiply(new BigDecimal(buyOrderProduct.getQuantity())));
|
||||
}
|
||||
}
|
||||
return R.ok().put("discountAmount",b);
|
||||
}
|
||||
|
||||
//获取商品活动折扣金额
|
||||
@RequestMapping("/getDistrictAmount")
|
||||
public R getDistrictAmount(@RequestBody BuyOrder buyOrder){
|
||||
BigDecimal total = new BigDecimal(0);
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
ShopProduct shopProduct = shopProductService.getById(buyOrderProduct.getProductId());
|
||||
if (!userVipService.noVip()){
|
||||
BigDecimal pvda = shopProductService.getVipDiscountAmount(shopProductService.getById(buyOrderProduct.getProductId()));
|
||||
if (pvda.compareTo(BigDecimal.ZERO)>0){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (shopProduct.getActivityPrice().compareTo(BigDecimal.ZERO)>0){
|
||||
total = total.add((shopProduct.getPrice().subtract(shopProduct.getActivityPrice())).multiply(new BigDecimal(buyOrderProduct.getQuantity())));
|
||||
}
|
||||
}
|
||||
return R.ok().put("districtAmount",total);
|
||||
}
|
||||
|
||||
//
|
||||
@RequestMapping("/getShopProductListByIds")
|
||||
public R getShopProductListByIds(@RequestBody Map<String,Object> params){
|
||||
String[] productIds = params.get("productIds").toString().split(",");
|
||||
LambdaQueryWrapper<ShopProduct> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.select(ShopProduct::getProductId,ShopProduct::getProductName,ShopProduct::getProductImages,ShopProduct::getPrice,ShopProduct::getActivityPrice,ShopProduct::getIsVipPrice);
|
||||
wrapper.in(ShopProduct::getProductId,Arrays.asList(productIds));
|
||||
List<ShopProduct> shopProductList = shopProductService.list(wrapper);
|
||||
for (ShopProduct shopProduct:shopProductList){
|
||||
//vip价格,不是vip或者活动价更低,返回0
|
||||
if (shopProduct.getIsVipPrice()==1){
|
||||
BigDecimal b = new BigDecimal(0);
|
||||
if (userVipService.is456SVip()||userVipService.is78SVip()){
|
||||
b = shopProduct.getPrice().multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
}else if (!userVipService.noVip()){
|
||||
b = shopProduct.getPrice().multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0
|
||||
&&b.compareTo(shopProduct.getActivityPrice())>0){
|
||||
b = new BigDecimal(0);
|
||||
}
|
||||
shopProduct.setVipPrice(b);
|
||||
}
|
||||
}
|
||||
return R.ok().put("shopProductList",shopProductList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*
|
||||
@@ -216,6 +280,10 @@ public class BuyOrderController {
|
||||
List<Integer> prescript_b = Arrays.asList(43,62,124);
|
||||
boolean prescriot_b_check = false;
|
||||
|
||||
if (buyOrder.getVipDiscountAmount()!=null&&buyOrder.getVipDiscountAmount().compareTo(new BigDecimal(0))>0
|
||||
&&buyOrder.getCouponId()!=null&&buyOrder.getCouponId()!=0){
|
||||
return R.error(500, "优惠不能叠加");
|
||||
}
|
||||
|
||||
// 遍历商品总价计算
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
@@ -236,6 +304,10 @@ public class BuyOrderController {
|
||||
int quantity = buyOrderProduct.getQuantity();
|
||||
ShopProduct product = shopProductService.getById(productId);
|
||||
BigDecimal price = getRealPrice(product);
|
||||
if (buyOrder.getVipDiscountAmount()!=null&&buyOrder.getVipDiscountAmount().compareTo(new BigDecimal(0))>0
|
||||
&&product.getIsVipPrice()==1){
|
||||
price = shopProductService.getVipPrice(product);
|
||||
}
|
||||
if (!handleStock(buyOrderProduct, product)) {
|
||||
return R.error(500, "库存不足");
|
||||
}
|
||||
@@ -359,6 +431,8 @@ public class BuyOrderController {
|
||||
paymentInfo.setAppName("wumen");
|
||||
} else if (buyOrder.getCome()==1) {
|
||||
paymentInfo.setAppName("zmzm");
|
||||
} else if (buyOrder.getCome()==3) {
|
||||
paymentInfo.setAppName("xlkj");
|
||||
}
|
||||
wxpayService.prepay(paymentInfo);
|
||||
}
|
||||
@@ -596,6 +670,8 @@ public class BuyOrderController {
|
||||
paymentInfo.setAppName("wumen");
|
||||
} else if (buyOrder.getCome()==1) {
|
||||
paymentInfo.setAppName("zmzm");
|
||||
} else if (buyOrder.getCome()==3) {
|
||||
paymentInfo.setAppName("xlkj");
|
||||
}else {
|
||||
paymentInfo.setAppName(buyOrder.getAppName());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user