折扣
This commit is contained in:
@@ -6,12 +6,15 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|||||||
import com.peanut.common.utils.R;
|
import com.peanut.common.utils.R;
|
||||||
import com.peanut.modules.common.entity.*;
|
import com.peanut.modules.common.entity.*;
|
||||||
import com.peanut.modules.book.service.*;
|
import com.peanut.modules.book.service.*;
|
||||||
|
import com.peanut.modules.common.service.UserVipService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -33,6 +36,8 @@ public class BookLabelAndMarketController {
|
|||||||
private ShopProductToBookMarketService toMarketService;
|
private ShopProductToBookMarketService toMarketService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopProductService productService;
|
private ShopProductService productService;
|
||||||
|
@Autowired
|
||||||
|
private UserVipService userVipService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图书标签树
|
* 图书标签树
|
||||||
@@ -375,12 +380,26 @@ public class BookLabelAndMarketController {
|
|||||||
wrapper.eq(ShopProductToBookLabel::getBookLabelId,labelId);
|
wrapper.eq(ShopProductToBookLabel::getBookLabelId,labelId);
|
||||||
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToBookLabel::getProductId);
|
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToBookLabel::getProductId);
|
||||||
// wrapper.selectAll(ShopProduct.class);
|
// wrapper.selectAll(ShopProduct.class);
|
||||||
wrapper.select(ShopProduct::getProductId,ShopProduct::getProductName,ShopProduct::getSumSales,ShopProduct::getIsFreeMail,ShopProduct::getPrice,ShopProduct::getActivityPrice,ShopProduct::getProductStock,ShopProduct::getProductImageList,ShopProduct::getGoodsType,ShopProduct::getProductImages,ShopProduct::getIsNew,ShopProduct::getPublisher);
|
wrapper.select(ShopProduct::getProductId,ShopProduct::getProductName,ShopProduct::getSumSales,ShopProduct::getIsVipPrice,ShopProduct::getIsFreeMail,ShopProduct::getPrice,ShopProduct::getActivityPrice,ShopProduct::getProductStock,ShopProduct::getProductImageList,ShopProduct::getGoodsType,ShopProduct::getProductImages,ShopProduct::getIsNew,ShopProduct::getPublisher);
|
||||||
|
|
||||||
|
|
||||||
// wrapper.orderByAsc(ShopProductToBookLabel::getSort);
|
// wrapper.orderByAsc(ShopProductToBookLabel::getSort);
|
||||||
wrapper.orderByDesc(ShopProduct::getSumSales);
|
wrapper.orderByDesc(ShopProduct::getSumSales);
|
||||||
List list = toLabelService.listMaps(wrapper);
|
List<Map<String,Object>> list = toLabelService.listMaps(wrapper);
|
||||||
|
for (Map<String,Object> map:list){
|
||||||
|
//vip价格,不是vip或者活动价更低,返回0
|
||||||
|
if (map.get("is_vip_price").toString().equals("1")){
|
||||||
|
BigDecimal b = new BigDecimal(0);
|
||||||
|
if (userVipService.is456SVip()||userVipService.is78SVip()){
|
||||||
|
b = ((BigDecimal) map.get("price")).multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
|
}else if (!userVipService.noVip()){
|
||||||
|
b = ((BigDecimal) map.get("price")).multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
if (((BigDecimal) map.get("activity_price")).compareTo(new BigDecimal(0))>0
|
||||||
|
&&b.compareTo(((BigDecimal) map.get("activity_price")))>0){
|
||||||
|
b = new BigDecimal(0);
|
||||||
|
}
|
||||||
|
map.put("vip_price",b);
|
||||||
|
}
|
||||||
|
}
|
||||||
return R.ok().put("result", list);
|
return R.ok().put("result", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.peanut.modules.common.entity.*;
|
|||||||
import com.peanut.modules.common.service.CouponHistoryService;
|
import com.peanut.modules.common.service.CouponHistoryService;
|
||||||
import com.peanut.modules.common.service.CouponService;
|
import com.peanut.modules.common.service.CouponService;
|
||||||
import com.peanut.modules.common.service.JfTransactionDetailsService;
|
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.dto.WechatPaymentInfo;
|
||||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||||
import com.peanut.modules.sys.entity.SysConfigEntity;
|
import com.peanut.modules.sys.entity.SysConfigEntity;
|
||||||
@@ -55,6 +56,8 @@ public class BuyOrderController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ShopProductService shopProductService;
|
private ShopProductService shopProductService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private UserVipService userVipService;
|
||||||
|
@Autowired
|
||||||
private BuyOrderDetailService buyOrderDetailService;
|
private BuyOrderDetailService buyOrderDetailService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderCartService orderCartService;
|
private OrderCartService orderCartService;
|
||||||
@@ -148,6 +151,67 @@ public class BuyOrderController {
|
|||||||
return R.ok().put("map",m);
|
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);
|
List<Integer> prescript_b = Arrays.asList(43,62,124);
|
||||||
boolean prescriot_b_check = false;
|
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) {
|
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||||
@@ -236,6 +304,10 @@ public class BuyOrderController {
|
|||||||
int quantity = buyOrderProduct.getQuantity();
|
int quantity = buyOrderProduct.getQuantity();
|
||||||
ShopProduct product = shopProductService.getById(productId);
|
ShopProduct product = shopProductService.getById(productId);
|
||||||
BigDecimal price = getRealPrice(product);
|
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)) {
|
if (!handleStock(buyOrderProduct, product)) {
|
||||||
return R.error(500, "库存不足");
|
return R.error(500, "库存不足");
|
||||||
}
|
}
|
||||||
@@ -359,6 +431,8 @@ public class BuyOrderController {
|
|||||||
paymentInfo.setAppName("wumen");
|
paymentInfo.setAppName("wumen");
|
||||||
} else if (buyOrder.getCome()==1) {
|
} else if (buyOrder.getCome()==1) {
|
||||||
paymentInfo.setAppName("zmzm");
|
paymentInfo.setAppName("zmzm");
|
||||||
|
} else if (buyOrder.getCome()==3) {
|
||||||
|
paymentInfo.setAppName("xlkj");
|
||||||
}
|
}
|
||||||
wxpayService.prepay(paymentInfo);
|
wxpayService.prepay(paymentInfo);
|
||||||
}
|
}
|
||||||
@@ -596,6 +670,8 @@ public class BuyOrderController {
|
|||||||
paymentInfo.setAppName("wumen");
|
paymentInfo.setAppName("wumen");
|
||||||
} else if (buyOrder.getCome()==1) {
|
} else if (buyOrder.getCome()==1) {
|
||||||
paymentInfo.setAppName("zmzm");
|
paymentInfo.setAppName("zmzm");
|
||||||
|
} else if (buyOrder.getCome()==3) {
|
||||||
|
paymentInfo.setAppName("xlkj");
|
||||||
}else {
|
}else {
|
||||||
paymentInfo.setAppName(buyOrder.getAppName());
|
paymentInfo.setAppName(buyOrder.getAppName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.peanut.modules.book.controller;
|
package com.peanut.modules.book.controller;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -7,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.peanut.modules.book.service.*;
|
import com.peanut.modules.book.service.*;
|
||||||
import com.peanut.modules.book.vo.ShopProductVo;
|
import com.peanut.modules.book.vo.ShopProductVo;
|
||||||
import com.peanut.modules.common.entity.*;
|
import com.peanut.modules.common.entity.*;
|
||||||
|
import com.peanut.modules.common.service.UserVipService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@@ -43,6 +45,8 @@ public class ShopProductController {
|
|||||||
private ShopProductToLabelService shopProductToLabelService;
|
private ShopProductToLabelService shopProductToLabelService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private BuyOrderDetailService buyOrderDetailService;
|
private BuyOrderDetailService buyOrderDetailService;
|
||||||
|
@Autowired
|
||||||
|
private UserVipService userVipService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精选商品 列表
|
* 精选商品 列表
|
||||||
@@ -276,6 +280,9 @@ public class ShopProductController {
|
|||||||
}
|
}
|
||||||
for (ShopProductBookEntity spbe : ss) {
|
for (ShopProductBookEntity spbe : ss) {
|
||||||
ShopProduct ca_sp = shopProductService.getById(spbe.getProductId());
|
ShopProduct ca_sp = shopProductService.getById(spbe.getProductId());
|
||||||
|
if (ca_sp.getIsVipPrice()==1){
|
||||||
|
ca_sp.setVipPrice(shopProductService.getVipPrice(ca_sp));
|
||||||
|
}
|
||||||
frag.add(ca_sp);
|
frag.add(ca_sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +322,20 @@ public class ShopProductController {
|
|||||||
booklist.add(String.valueOf(bookId));
|
booklist.add(String.valueOf(bookId));
|
||||||
list.add(byId);
|
list.add(byId);
|
||||||
}
|
}
|
||||||
|
//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);
|
||||||
|
}
|
||||||
//添加获取标签逻辑
|
//添加获取标签逻辑
|
||||||
List<ShopProductToLabelEntity> shopProductToLabelEntities = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()
|
List<ShopProductToLabelEntity> shopProductToLabelEntities = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()
|
||||||
.eq("product_id", productId).eq("del_flag", 0));
|
.eq("product_id", productId).eq("del_flag", 0));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.modules.common.entity.ShopProduct;
|
import com.peanut.modules.common.entity.ShopProduct;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -23,6 +24,9 @@ public interface ShopProductService extends IService<ShopProduct> {
|
|||||||
|
|
||||||
List<ShopProduct> appGetCategoryList(Integer catId);
|
List<ShopProduct> appGetCategoryList(Integer catId);
|
||||||
|
|
||||||
|
BigDecimal getVipDiscountAmount(ShopProduct shopProduct);
|
||||||
|
|
||||||
|
BigDecimal getVipPrice(ShopProduct shopProduct);
|
||||||
|
|
||||||
PageUtils getNewBook(Map<String, Object> params);
|
PageUtils getNewBook(Map<String, Object> params);
|
||||||
|
|
||||||
|
|||||||
@@ -464,7 +464,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
List<BuyOrderProduct> buyOrderProducts = buyOrderProductService.getBaseMapper().selectList(new LambdaQueryWrapper<BuyOrderProduct>()
|
List<BuyOrderProduct> buyOrderProducts = buyOrderProductService.getBaseMapper().selectList(new LambdaQueryWrapper<BuyOrderProduct>()
|
||||||
.eq(BuyOrderProduct::getOrderId, b.getOrderId()));
|
.eq(BuyOrderProduct::getOrderId, b.getOrderId()));
|
||||||
for (BuyOrderProduct bb : buyOrderProducts){
|
for (BuyOrderProduct bb : buyOrderProducts){
|
||||||
bb.setProduct(shopProductService.getById(bb.getProductId()));
|
bb.setProduct(shopProductService.getOne(new LambdaQueryWrapper<ShopProduct>().select(ShopProduct::getProductId,ShopProduct::getProductName,ShopProduct::getProductImages,ShopProduct::getPrice,ShopProduct::getActivityPrice,ShopProduct::getIsVipPrice)
|
||||||
|
.eq(ShopProduct::getProductId,bb.getProductId())));
|
||||||
UserRecord userRecord = userRecordDao.selectOne(new QueryWrapper<UserRecord>()
|
UserRecord userRecord = userRecordDao.selectOne(new QueryWrapper<UserRecord>()
|
||||||
.eq("userid", ShiroUtils.getUId())
|
.eq("userid", ShiroUtils.getUId())
|
||||||
.eq("orderdid", b.getOrderId())
|
.eq("orderdid", b.getOrderId())
|
||||||
@@ -710,6 +711,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
responseVo.setRealPrice(buyOrder.getRealMoney());
|
responseVo.setRealPrice(buyOrder.getRealMoney());
|
||||||
responseVo.setShippingPrice(buyOrder.getShippingMoney());
|
responseVo.setShippingPrice(buyOrder.getShippingMoney());
|
||||||
responseVo.setDistrictPrice(buyOrder.getDistrictMoney());
|
responseVo.setDistrictPrice(buyOrder.getDistrictMoney());
|
||||||
|
responseVo.setVipDiscountAmount(buyOrder.getVipDiscountAmount());
|
||||||
responseVo.setJfDeduction(buyOrder.getJfDeduction());
|
responseVo.setJfDeduction(buyOrder.getJfDeduction());
|
||||||
responseVo.setAddressId(buyOrder.getAddressId());
|
responseVo.setAddressId(buyOrder.getAddressId());
|
||||||
responseVo.setOrderType(buyOrder.getOrderType());
|
responseVo.setOrderType(buyOrder.getOrderType());
|
||||||
@@ -763,6 +765,11 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
goodsResponseVo.setProductName(shopProduct.getProductName());
|
goodsResponseVo.setProductName(shopProduct.getProductName());
|
||||||
goodsResponseVo.setProductImage(shopProduct.getProductImages());
|
goodsResponseVo.setProductImage(shopProduct.getProductImages());
|
||||||
goodsResponseVo.setProductPrice(shopProduct.getPrice());
|
goodsResponseVo.setProductPrice(shopProduct.getPrice());
|
||||||
|
if (shopProduct.getIsVipPrice()==1){
|
||||||
|
goodsResponseVo.setVipPrice(shopProductService.getVipPrice(shopProduct));
|
||||||
|
}else {
|
||||||
|
goodsResponseVo.setVipPrice(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
goodsResponseVo.setQuantity(buyOrderProduct.getQuantity());
|
goodsResponseVo.setQuantity(buyOrderProduct.getQuantity());
|
||||||
goodsResponseVo.setProductId(shopProduct.getProductId());
|
goodsResponseVo.setProductId(shopProduct.getProductId());
|
||||||
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.peanut.modules.book.service.impl;
|
|||||||
import com.peanut.modules.common.entity.ShopProduct;
|
import com.peanut.modules.common.entity.ShopProduct;
|
||||||
import com.peanut.modules.book.service.ShopProductService;
|
import com.peanut.modules.book.service.ShopProductService;
|
||||||
import com.peanut.modules.book.vo.ShopCartVo;
|
import com.peanut.modules.book.vo.ShopCartVo;
|
||||||
|
import com.peanut.modules.common.service.UserVipService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -28,6 +29,8 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopProductService shopProductService;
|
private ShopProductService shopProductService;
|
||||||
|
@Autowired
|
||||||
|
private UserVipService userVipService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,6 +81,21 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
|
|||||||
price = productEntity.getActivityPrice();
|
price = productEntity.getActivityPrice();
|
||||||
}
|
}
|
||||||
shopCartVo.setActivityPrice(price);
|
shopCartVo.setActivityPrice(price);
|
||||||
|
shopCartVo.setIsVipPrice(productEntity.getIsVipPrice());
|
||||||
|
//vip价格,不是vip或者活动价更低,返回0
|
||||||
|
if (productEntity.getIsVipPrice()==1){
|
||||||
|
BigDecimal b = new BigDecimal(0);
|
||||||
|
if (userVipService.is456SVip()||userVipService.is78SVip()){
|
||||||
|
b = productEntity.getPrice().multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
|
}else if (!userVipService.noVip()){
|
||||||
|
b = productEntity.getPrice().multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
if (productEntity.getActivityPrice().compareTo(new BigDecimal(0))>0
|
||||||
|
&&b.compareTo(productEntity.getActivityPrice())>0){
|
||||||
|
b = new BigDecimal(0);
|
||||||
|
}
|
||||||
|
shopCartVo.setVipPrice(b);
|
||||||
|
}
|
||||||
cartList.add(shopCartVo);
|
cartList.add(shopCartVo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.peanut.modules.book.service.impl;
|
package com.peanut.modules.book.service.impl;
|
||||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||||
|
import com.peanut.modules.common.service.UserVipService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
@@ -18,6 +21,8 @@ import com.peanut.modules.book.service.ShopProductService;
|
|||||||
@Service("shopProductService")
|
@Service("shopProductService")
|
||||||
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProduct> implements ShopProductService {
|
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProduct> implements ShopProductService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserVipService userVipService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
@@ -46,6 +51,44 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getVipDiscountAmount(ShopProduct shopProduct) {
|
||||||
|
BigDecimal p = new BigDecimal(0);
|
||||||
|
if (shopProduct.getIsVipPrice()==1){
|
||||||
|
if (userVipService.is456SVip()||userVipService.is78SVip()){
|
||||||
|
p = shopProduct.getPrice().multiply(new BigDecimal(0.8));
|
||||||
|
}else if (!userVipService.noVip()){
|
||||||
|
p = shopProduct.getPrice().multiply(new BigDecimal(0.9));
|
||||||
|
}
|
||||||
|
//如果有折扣价,比折扣价低就返回vip折扣金额
|
||||||
|
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0
|
||||||
|
&&p.compareTo(shopProduct.getActivityPrice())>0){
|
||||||
|
p = new BigDecimal(0);
|
||||||
|
}else {
|
||||||
|
p = shopProduct.getPrice().subtract(p).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getVipPrice(ShopProduct shopProduct) {
|
||||||
|
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);
|
||||||
|
}else {
|
||||||
|
BigDecimal activityPrice = shopProduct.getActivityPrice();
|
||||||
|
b = (activityPrice == null || activityPrice.equals(BigDecimal.ZERO)) ? shopProduct.getPrice() : activityPrice;
|
||||||
|
}
|
||||||
|
if (shopProduct.getActivityPrice().compareTo(new BigDecimal(0))>0
|
||||||
|
&&b.compareTo(shopProduct.getActivityPrice())>0){
|
||||||
|
b = shopProduct.getActivityPrice();
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils getNewBook(Map<String, Object> params) {
|
public PageUtils getNewBook(Map<String, Object> params) {
|
||||||
IPage<ShopProduct> page = this.page(
|
IPage<ShopProduct> page = this.page(
|
||||||
|
|||||||
@@ -30,6 +30,15 @@ public class ShopCartVo {
|
|||||||
* 商品活动单价
|
* 商品活动单价
|
||||||
*/
|
*/
|
||||||
private BigDecimal activityPrice;
|
private BigDecimal activityPrice;
|
||||||
|
/**
|
||||||
|
* 是否有vip折扣
|
||||||
|
*/
|
||||||
|
private Integer isVipPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品vip价格
|
||||||
|
*/
|
||||||
|
private BigDecimal vipPrice;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ public class BuyOrderResponseVo {
|
|||||||
* 扣减金额
|
* 扣减金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal districtPrice;
|
private BigDecimal districtPrice;
|
||||||
|
/**
|
||||||
|
* vip优惠金额
|
||||||
|
*/
|
||||||
|
private BigDecimal vipDiscountAmount;
|
||||||
/**
|
/**
|
||||||
* 运费
|
* 运费
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ public class GoodsResponseVo {
|
|||||||
* 商品价格
|
* 商品价格
|
||||||
*/
|
*/
|
||||||
private BigDecimal productPrice;
|
private BigDecimal productPrice;
|
||||||
|
/**
|
||||||
|
* 商品vip价格
|
||||||
|
*/
|
||||||
|
private BigDecimal vipPrice;
|
||||||
/**
|
/**
|
||||||
* 商品数量
|
* 商品数量
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -172,6 +172,8 @@ public class CourseRelearnController {
|
|||||||
paymentInfo.setAppName("wumen");
|
paymentInfo.setAppName("wumen");
|
||||||
} else if (buyOrder.getCome()==1) {
|
} else if (buyOrder.getCome()==1) {
|
||||||
paymentInfo.setAppName("zmzm");
|
paymentInfo.setAppName("zmzm");
|
||||||
|
} else if (buyOrder.getCome()==3) {
|
||||||
|
paymentInfo.setAppName("xlkj");
|
||||||
}else {
|
}else {
|
||||||
paymentInfo.setAppName(buyOrder.getAppName());
|
paymentInfo.setAppName(buyOrder.getAppName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ public class OfflineActivityController {
|
|||||||
paymentInfo.setAppName("wumen");
|
paymentInfo.setAppName("wumen");
|
||||||
} else if (buyOrder.getCome()==1) {
|
} else if (buyOrder.getCome()==1) {
|
||||||
paymentInfo.setAppName("zmzm");
|
paymentInfo.setAppName("zmzm");
|
||||||
|
} else if (buyOrder.getCome()==3) {
|
||||||
|
paymentInfo.setAppName("xlkj");
|
||||||
}else {
|
}else {
|
||||||
paymentInfo.setAppName(buyOrder.getAppName());
|
paymentInfo.setAppName(buyOrder.getAppName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,6 +300,8 @@ public class UserVipController {
|
|||||||
paymentInfo.setAppName("wumen");
|
paymentInfo.setAppName("wumen");
|
||||||
} else if (buyOrder.getCome()==1) {
|
} else if (buyOrder.getCome()==1) {
|
||||||
paymentInfo.setAppName("zmzm");
|
paymentInfo.setAppName("zmzm");
|
||||||
|
} else if (buyOrder.getCome()==3) {
|
||||||
|
paymentInfo.setAppName("xlkj");
|
||||||
}else {
|
}else {
|
||||||
paymentInfo.setAppName(buyOrder.getAppName());
|
paymentInfo.setAppName(buyOrder.getAppName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ public class BuyOrder implements Serializable {
|
|||||||
* 优惠金额
|
* 优惠金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal districtMoney;
|
private BigDecimal districtMoney;
|
||||||
|
/**
|
||||||
|
* VIP优惠金额
|
||||||
|
*/
|
||||||
|
private BigDecimal vipDiscountAmount;
|
||||||
/**
|
/**
|
||||||
* 实收金额
|
* 实收金额
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ public class ShopProduct implements Serializable {
|
|||||||
* 商品活动价格
|
* 商品活动价格
|
||||||
*/
|
*/
|
||||||
private BigDecimal activityPrice;
|
private BigDecimal activityPrice;
|
||||||
|
/**
|
||||||
|
* 是否有vip折扣
|
||||||
|
*/
|
||||||
|
private Integer isVipPrice;
|
||||||
/**
|
/**
|
||||||
* 商品重量
|
* 商品重量
|
||||||
*/
|
*/
|
||||||
@@ -186,4 +190,8 @@ public class ShopProduct implements Serializable {
|
|||||||
//课程id
|
//课程id
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<ShopProductCourseEntity> courseIds;
|
private List<ShopProductCourseEntity> courseIds;
|
||||||
|
|
||||||
|
//vip价格
|
||||||
|
@TableField(exist = false)
|
||||||
|
private BigDecimal vipPrice;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,15 @@ import java.util.Set;
|
|||||||
|
|
||||||
public interface UserVipService extends IService<UserVip> {
|
public interface UserVipService extends IService<UserVip> {
|
||||||
|
|
||||||
|
boolean noVip();
|
||||||
boolean noMedicalVip();
|
boolean noMedicalVip();
|
||||||
boolean isMedicalVip();
|
boolean isMedicalVip();
|
||||||
boolean isAcupunctureVip();
|
boolean isAcupunctureVip();
|
||||||
boolean istumorVip();
|
boolean istumorVip();
|
||||||
boolean isSociologyVip();
|
boolean isSociologyVip();
|
||||||
boolean isPsycheVip();
|
boolean isPsycheVip();
|
||||||
|
boolean is456SVip();
|
||||||
|
boolean is78SVip();
|
||||||
|
|
||||||
//是否是这门课的vip
|
//是否是这门课的vip
|
||||||
UserVip ownCourseCatalogueByVip(int courseId);
|
UserVip ownCourseCatalogueByVip(int courseId);
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
|||||||
@Autowired
|
@Autowired
|
||||||
private VipBuyConfigDao vipBuyConfigDao;
|
private VipBuyConfigDao vipBuyConfigDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean noVip() {
|
||||||
|
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||||
|
.eq(UserVip::getUserId, ShiroUtils.getUId())
|
||||||
|
.eq(UserVip::getState,0));
|
||||||
|
if (userVipList.size() > 0) {
|
||||||
|
return false;
|
||||||
|
}else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean noMedicalVip() {
|
public boolean noMedicalVip() {
|
||||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||||
@@ -67,6 +79,23 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
|||||||
public boolean isPsycheVip() {
|
public boolean isPsycheVip() {
|
||||||
return isVip(8);
|
return isVip(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean is456SVip() {
|
||||||
|
if (isVip(4)&&isVip(5)&&isVip(6)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean is78SVip() {
|
||||||
|
if (isVip(7)&&isVip(8)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isVip(int type) {
|
public boolean isVip(int type) {
|
||||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||||
.eq(UserVip::getUserId, ShiroUtils.getUId())
|
.eq(UserVip::getUserId, ShiroUtils.getUId())
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ public class WechatPayConfig implements Serializable {
|
|||||||
private String zmzmappId;
|
private String zmzmappId;
|
||||||
@Value("${wxpay.wumenappId}")
|
@Value("${wxpay.wumenappId}")
|
||||||
private String wumenappId;
|
private String wumenappId;
|
||||||
|
@Value("${wxpay.xlkjappId}")
|
||||||
|
private String xlkjappId;
|
||||||
/**
|
/**
|
||||||
* 商户号
|
* 商户号
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ public class WeChatPayController {
|
|||||||
appid = wechatPayConfig.getZmzmappId();
|
appid = wechatPayConfig.getZmzmappId();
|
||||||
} else if ("wumen".equals(paymentInfo.getAppName())) {
|
} else if ("wumen".equals(paymentInfo.getAppName())) {
|
||||||
appid = wechatPayConfig.getWumenappId();
|
appid = wechatPayConfig.getWumenappId();
|
||||||
|
} else if ("xlkj".equals(paymentInfo.getAppName())) {
|
||||||
|
appid = wechatPayConfig.getXlkjappId();
|
||||||
}
|
}
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
paramMap.put("appid", appid);
|
paramMap.put("appid", appid);
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
|||||||
appid = wechatPayConfig.getZmzmappId();
|
appid = wechatPayConfig.getZmzmappId();
|
||||||
} else if ("wumen".equals(paymentInfo.getAppName())) {
|
} else if ("wumen".equals(paymentInfo.getAppName())) {
|
||||||
appid = wechatPayConfig.getWumenappId();
|
appid = wechatPayConfig.getWumenappId();
|
||||||
|
} else if ("xlkj".equals(paymentInfo.getAppName())) {
|
||||||
|
appid = wechatPayConfig.getXlkjappId();
|
||||||
}
|
}
|
||||||
// app id
|
// app id
|
||||||
paramMap.put("appid", appid);
|
paramMap.put("appid", appid);
|
||||||
|
|||||||
@@ -52,6 +52,20 @@ public class PsycheCourseController {
|
|||||||
return R.ok().put("courseList",courseList);
|
return R.ok().put("courseList",courseList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//免费课程
|
||||||
|
@RequestMapping("/getFreeCourse")
|
||||||
|
public R getFreeCourse(){
|
||||||
|
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||||
|
wrapper.distinct();
|
||||||
|
wrapper.rightJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId);
|
||||||
|
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
||||||
|
wrapper.eq(CourseCatalogueEntity::getType,0);
|
||||||
|
wrapper.selectAll(CourseEntity.class);
|
||||||
|
wrapper.orderByAsc(CourseEntity::getSort);
|
||||||
|
List<CourseEntity> courseList = courseService.list(wrapper);
|
||||||
|
return R.ok().put("courseList",courseList);
|
||||||
|
}
|
||||||
|
|
||||||
//我的课程-过期课程
|
//我的课程-过期课程
|
||||||
@RequestMapping("/getCourseExpire")
|
@RequestMapping("/getCourseExpire")
|
||||||
public R getCourseExpire(){
|
public R getCourseExpire(){
|
||||||
|
|||||||
Reference in New Issue
Block a user