增加会员专区 积分专区 积分兑换内容 增加三个专区的字段

This commit is contained in:
2025-02-10 11:09:32 +08:00
committed by axindata
parent 0badf9eac2
commit 48f6dd405b
8 changed files with 136 additions and 25 deletions

View File

@@ -1,6 +1,5 @@
package com.buy507.mall.service.impl; package com.buy507.mall.service.impl;
import com.github.pagehelper.PageHelper;
import com.buy507.mall.component.RedisLock; import com.buy507.mall.component.RedisLock;
import com.buy507.mall.dao.*; import com.buy507.mall.dao.*;
import com.buy507.mall.dto.PmsProductParam; import com.buy507.mall.dto.PmsProductParam;
@@ -9,6 +8,7 @@ import com.buy507.mall.dto.PmsProductResult;
import com.buy507.mall.mapper.*; import com.buy507.mall.mapper.*;
import com.buy507.mall.model.*; import com.buy507.mall.model.*;
import com.buy507.mall.service.PmsProductService; import com.buy507.mall.service.PmsProductService;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@@ -23,6 +23,9 @@ public class SmsHomeNewProductServiceImpl implements SmsHomeNewProductService {
for (SmsHomeNewProduct SmsHomeNewProduct : homeNewProductList) { for (SmsHomeNewProduct SmsHomeNewProduct : homeNewProductList) {
SmsHomeNewProduct.setRecommendStatus(1); SmsHomeNewProduct.setRecommendStatus(1);
SmsHomeNewProduct.setSort(0); SmsHomeNewProduct.setSort(0);
SmsHomeNewProduct.setVipStatus(1);
SmsHomeNewProduct.setPointsAreaStatus(1);
SmsHomeNewProduct.setPointsExchangeStatus(1);
homeNewProductMapper.insert(SmsHomeNewProduct); homeNewProductMapper.insert(SmsHomeNewProduct);
} }
return homeNewProductList.size(); return homeNewProductList.size();

View File

@@ -4,6 +4,7 @@ import com.buy507.mall.model.SmsHomeNewProduct;
import com.buy507.mall.model.SmsHomeNewProductExample; import com.buy507.mall.model.SmsHomeNewProductExample;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface SmsHomeNewProductMapper { public interface SmsHomeNewProductMapper {
long countByExample(SmsHomeNewProductExample example); long countByExample(SmsHomeNewProductExample example);
@@ -27,4 +28,10 @@ public interface SmsHomeNewProductMapper {
int updateByPrimaryKeySelective(SmsHomeNewProduct record); int updateByPrimaryKeySelective(SmsHomeNewProduct record);
int updateByPrimaryKey(SmsHomeNewProduct record); int updateByPrimaryKey(SmsHomeNewProduct record);
/**
* 通过 productId 查询 SmsHomeNewProduct
*/
@Select("SELECT * FROM pms_product WHERE product_id = #{productId} LIMIT 1")
SmsHomeNewProduct selectByProductId(@Param("productId") Long productId);
} }

View File

@@ -16,6 +16,17 @@ public class SmsHomeNewProduct implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// 会员专区状态
private Integer vipStatus;
// 积分专区状态
private Integer pointsAreaStatus;
// 积分兑换专区状态
private Integer pointsExchangeStatus;
public Long getId() { public Long getId() {
return id; return id;
} }
@@ -56,6 +67,35 @@ public class SmsHomeNewProduct implements Serializable {
this.sort = sort; this.sort = sort;
} }
public Integer getVipStatus() {
return vipStatus;
}
public void setVipStatus(Integer vipStatus) {
this.vipStatus = vipStatus;
}
public Integer getPointsAreaStatus() {
return pointsAreaStatus;
}
public void setPointsAreaStatus(Integer pointsAreaStatus) {
this.pointsAreaStatus = pointsAreaStatus;
}
public Integer getPointsExchangeStatus() {
return pointsExchangeStatus;
}
public void setPointsExchangeStatus(Integer pointsExchangeStatus) {
this.pointsExchangeStatus = pointsExchangeStatus;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View File

@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayApiException;
import com.buy507.mall.model.SmsHomeNewProduct;
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.*; import org.springframework.web.bind.annotation.*;
@@ -215,6 +216,13 @@ public class OmsPortalOrderController {
@ApiOperation("普通单排队信息") @ApiOperation("普通单排队信息")
@RequestMapping("/orderQueue/info") @RequestMapping("/orderQueue/info")
public CommonResult orderQueueInfo() { public CommonResult orderQueueInfo() {
SmsHomeNewProduct smsHomeNewProduct = new SmsHomeNewProduct();
//如果是积分专区的商品和积分兑换的商品则不进行排队
if(smsHomeNewProduct.getPointsAreaStatus() == 1 || smsHomeNewProduct.getPointsExchangeStatus() == 1){
return CommonResult.success("该商品不参与排队流程");
}
//否则进行排队
return portalOrderService.orderQueueInfo(); return portalOrderService.orderQueueInfo();
} }
@@ -224,6 +232,11 @@ public class OmsPortalOrderController {
@ApiOperation(" 加速单排队信息") @ApiOperation(" 加速单排队信息")
@RequestMapping("/accelerateOrder/info") @RequestMapping("/accelerateOrder/info")
public CommonResult accelerateOrderInfo(@RequestParam Long orderId) { public CommonResult accelerateOrderInfo(@RequestParam Long orderId) {
SmsHomeNewProduct smsHomeNewProduct = new SmsHomeNewProduct();
//如果是积分专区的商品和积分兑换的商品则不进行排队
if(smsHomeNewProduct.getPointsAreaStatus() == 1 || smsHomeNewProduct.getPointsExchangeStatus() == 1){
return CommonResult.success("该商品不参与排队流程");
}
return portalOrderService.accelerateOrderInfo(orderId); return portalOrderService.accelerateOrderInfo(orderId);
} }

View File

@@ -137,6 +137,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
@Autowired @Autowired
private UmsMemberOrderQueueMapper umsMemberOrderQueueMapper; private UmsMemberOrderQueueMapper umsMemberOrderQueueMapper;
@Autowired
private SmsHomeNewProductMapper homeNewProductMapper;
@Value("${kuaidi100.url}") @Value("${kuaidi100.url}")
@@ -438,6 +441,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
UmsMember member = memberMapper.selectByPrimaryKey(loginMember.getId()); UmsMember member = memberMapper.selectByPrimaryKey(loginMember.getId());
orderResult.setShareUrl("http://49.233.215.129:688/#/pages/public/register?inviteCode="+member.getInvitationCode()); orderResult.setShareUrl("http://49.233.215.129:688/#/pages/public/register?inviteCode="+member.getInvitationCode());
UmsMemberOrderQueueExample example1 = new UmsMemberOrderQueueExample(); UmsMemberOrderQueueExample example1 = new UmsMemberOrderQueueExample();
example1.createCriteria().andQuitQueueMarkEqualTo(UmsMemberOrderQueue.QUEUE_STATUS_WAIT).andQueueTypeEqualTo(UmsMemberOrderQueue.QUEUE_TYPE_ORDINARY); example1.createCriteria().andQuitQueueMarkEqualTo(UmsMemberOrderQueue.QUEUE_STATUS_WAIT).andQueueTypeEqualTo(UmsMemberOrderQueue.QUEUE_TYPE_ORDINARY);
long allQueue = umsMemberOrderQueueMapper.countByExample(example1); long allQueue = umsMemberOrderQueueMapper.countByExample(example1);
@@ -697,20 +702,23 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
*/ */
@Transactional @Transactional
@Override @Override
/**
* 创建订单
*/
public CommonResult createOrder(OrderParam orderParam) { public CommonResult createOrder(OrderParam orderParam) {
//orderParam.setSkuId(98L); //orderParam.setSkuId(98L);
if(orderParam.getSkuId() == null) { if(orderParam.getSkuId() == null) {
return CommonResult.validateFailed("商品SKU不能为空"); return CommonResult.validateFailed("商品SKU不能为空");
} }
if(orderParam.getDeliveryType() == null || (orderParam.getDeliveryType() != 0 && orderParam.getDeliveryType() != 1) ) { if(orderParam.getDeliveryType() == null || (orderParam.getDeliveryType() != 0 && orderParam.getDeliveryType() != 1) ) {
return CommonResult.validateFailed("提货方式不能为空"); return CommonResult.validateFailed("提货方式不能为空");
} }
if(orderParam.getMemberReceiveAddressId() == null) { if(orderParam.getMemberReceiveAddressId() == null) {
return CommonResult.validateFailed("会员收货地址不能为空"); return CommonResult.validateFailed("会员收货地址不能为空");
} }
UmsMemberReceiveAddress address = memberReceiveAddressMapper.selectOneById(orderParam.getMemberReceiveAddressId()); UmsMemberReceiveAddress address = memberReceiveAddressMapper.selectOneById(orderParam.getMemberReceiveAddressId());
if(address == null) { if(address == null) {
return CommonResult.validateFailed("未查询到会员收货地址"); return CommonResult.validateFailed("未查询到会员收货地址");
@@ -730,28 +738,42 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
if ((skuStock.getStock() - skuStock.getLockStock()) < orderParam.getQuantity()) { if ((skuStock.getStock() - skuStock.getLockStock()) < orderParam.getQuantity()) {
return CommonResult.validateFailed("库存不足,无法下单"); return CommonResult.validateFailed("库存不足,无法下单");
} }
//通过productId查询专区信息
SmsHomeNewProduct homeNewProduct = homeNewProductMapper.selectByProductId(skuStock.getProductId());
if (homeNewProduct == null) {
return CommonResult.validateFailed("未查询到商品所属专区");
}
// 积分兑换专区逻辑
if (homeNewProduct.getPointsExchangeStatus() != null && homeNewProduct.getPointsExchangeStatus() == 1) {
log.info("当前商品属于【积分兑换专区】");
}
//根据商品id查询商品信息 //根据商品id查询商品信息
PmsProduct product = productMapper.selectByPrimaryKey(skuStock.getProductId()); PmsProduct product = productMapper.selectByPrimaryKey(skuStock.getProductId());
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if(product != null) { if(product != null) {
UmsMember member = memberMapper.selectByPrimaryKey(memberService.getCurrentMember().getId()); UmsMember member = memberMapper.selectByPrimaryKey(memberService.getCurrentMember().getId());
BigDecimal discount = commonService.getDiscount(member.getId()); BigDecimal discount = commonService.getDiscount(member.getId());
BigDecimal price = new BigDecimal(skuStock.getPrice().doubleValue()); BigDecimal price = new BigDecimal(skuStock.getPrice().doubleValue());
if(discount != null) { if(discount != null) {
price = skuStock.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP); price = skuStock.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
} }
BigDecimal totalAmount = new BigDecimal(0); BigDecimal totalAmount = new BigDecimal(0);
BigDecimal zero = new BigDecimal(0); BigDecimal zero = new BigDecimal(0);
totalAmount = price.multiply(new BigDecimal(orderParam.getQuantity())); totalAmount = price.multiply(new BigDecimal(orderParam.getQuantity()));
if(orderParam.getIntegration() == null) { if(orderParam.getIntegration() == null) {
orderParam.setIntegration(zero); orderParam.setIntegration(zero);
} }
//先判断积分是否大于0大于0表示使用了积分支付 //先判断积分是否大于0大于0表示使用了积分支付
//flag 等于1表示使用积分支付 判断用户积分是否充足 //flag 等于1表示使用积分支付 判断用户积分是否充足
//flag = -1,表示integration小于0flag = 0,表示integration等于0flag = 1,表示integration大于0 //flag = -1,表示integration小于0flag = 0,表示integration等于0flag = 1,表示integration大于0
@@ -764,18 +786,19 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
return CommonResult.validateFailed("森态积分不足,无法抵扣"); return CommonResult.validateFailed("森态积分不足,无法抵扣");
}*/ }*/
} }
while(true) { while(true) {
long time = System.currentTimeMillis() + RedisLock.TIMEOUT; long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
if(redisLock.lock(String.valueOf(skuStock.getProductId()), String.valueOf(time))) { if(redisLock.lock(String.valueOf(skuStock.getProductId()), String.valueOf(time))) {
//重新查询获取最新的数据 //重新查询获取最新的数据
skuStock = skuStockMapper.selectByPrimaryKey(orderParam.getSkuId()); skuStock = skuStockMapper.selectByPrimaryKey(orderParam.getSkuId());
//判断购物车中商品是否都有库存 (库存 - 锁定库存 = 真实库存) //判断购物车中商品是否都有库存 (库存 - 锁定库存 = 真实库存)
if ((skuStock.getStock() - skuStock.getLockStock()) < orderParam.getQuantity()) { if ((skuStock.getStock() - skuStock.getLockStock()) < orderParam.getQuantity()) {
return CommonResult.validateFailed("库存不足,无法下单"); return CommonResult.validateFailed("库存不足,无法下单");
} }
skuStock.setLockStock(skuStock.getLockStock() + orderParam.getQuantity()); skuStock.setLockStock(skuStock.getLockStock() + orderParam.getQuantity());
skuStockMapper.updateByPrimaryKey(skuStock); skuStockMapper.updateByPrimaryKey(skuStock);
redisLock.unlock(String.valueOf(skuStock.getProductId()), String.valueOf(time)); redisLock.unlock(String.valueOf(skuStock.getProductId()), String.valueOf(time));
@@ -783,6 +806,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
} }
} }
//生成订单信息 //生成订单信息
OmsOrder order = new OmsOrder(); OmsOrder order = new OmsOrder();
order.setTotalAmount(totalAmount); // 订单总金额 order.setTotalAmount(totalAmount); // 订单总金额
@@ -801,7 +825,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
order.setIntegrationAmount(totalAmount); order.setIntegrationAmount(totalAmount);
integeration = totalAmount; integeration = totalAmount;
} }
//冻结用户余额 //冻结用户余额
member = memberMapper.selectByPrimaryKey(member.getId()); member = memberMapper.selectByPrimaryKey(member.getId());
//flag = -1,表示balance小于integerationflag = 0,表示balance等于integerationflag = 1,表示balance大于integeration //flag = -1,表示balance小于integerationflag = 0,表示balance等于integerationflag = 1,表示balance大于integeration
@@ -838,12 +862,12 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
order.setStatus(0); order.setStatus(0);
//订单类型0->正常订单1->秒杀订单 2->5连订单 //订单类型0->正常订单1->秒杀订单 2->5连订单
order.setOrderType(0); order.setOrderType(0);
OmsOrderSetting orderSetting = orderSettingMapper.selectByPrimaryKey(1L); OmsOrderSetting orderSetting = orderSettingMapper.selectByPrimaryKey(1L);
order.setAutoConfirmDay(orderSetting.getConfirmOvertime()); order.setAutoConfirmDay(orderSetting.getConfirmOvertime());
order.setIntegration(0); order.setIntegration(0);
order.setGrowth(0); order.setGrowth(0);
//收货人信息:姓名、电话、邮编、地址 //收货人信息:姓名、电话、邮编、地址
order.setReceiverName(address.getName()); order.setReceiverName(address.getName());
order.setReceiverPhone(address.getPhoneNumber()); order.setReceiverPhone(address.getPhoneNumber());
@@ -852,9 +876,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
order.setReceiverCity(address.getCity()); order.setReceiverCity(address.getCity());
order.setReceiverRegion(address.getRegion()); order.setReceiverRegion(address.getRegion());
order.setReceiverDetailAddress(address.getDetailAddress()); order.setReceiverDetailAddress(address.getDetailAddress());
order.setNote(orderParam.getNote() == null ? null : orderParam.getNote()); order.setNote(orderParam.getNote() == null ? null : orderParam.getNote());
//确认收货状态0->未确认1->已确认 //确认收货状态0->未确认1->已确认
order.setConfirmStatus(0); order.setConfirmStatus(0);
//删除状态0->未删除1->已删除 //删除状态0->未删除1->已删除
@@ -862,9 +886,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
order.setUseIntegration(0); order.setUseIntegration(0);
order.setPromotionInfo("无优惠"); order.setPromotionInfo("无优惠");
order.setSettlementStatus(0); //分销结算状态0->未结算1->已结算2->不结算) order.setSettlementStatus(0); //分销结算状态0->未结算1->已结算2->不结算)
orderMapper.insert(order); orderMapper.insert(order);
//生成订单商品信息 //生成订单商品信息
OmsOrderItem orderItem = new OmsOrderItem(); OmsOrderItem orderItem = new OmsOrderItem();
orderItem.setOrderId(order.getId()); orderItem.setOrderId(order.getId());
@@ -890,21 +914,26 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
orderItem.setCouponAmount(new BigDecimal(0)); orderItem.setCouponAmount(new BigDecimal(0));
orderItem.setIntegrationAmount(new BigDecimal(0)); orderItem.setIntegrationAmount(new BigDecimal(0));
orderItem.setRealAmount(new BigDecimal(0)); orderItem.setRealAmount(new BigDecimal(0));
orderItemMapper.insert(orderItem); orderItemMapper.insert(orderItem);
//超时未支付,自动取消订单 //超时未支付,自动取消订单
//分钟转换成毫秒 //分钟转换成毫秒
long delayTimes = orderSetting.getNormalOrderOvertime() * 60 * 1000; long delayTimes = orderSetting.getNormalOrderOvertime() * 60 * 1000;
cancelOrderSender.sendMessage(order.getId(), delayTimes); cancelOrderSender.sendMessage(order.getId(), delayTimes);
result.put("orderId", order.getId()); result.put("orderId", order.getId());
result.put("totalAmount", order.getPayAmount()); result.put("totalAmount", order.getPayAmount());
} }
return CommonResult.success(result, "下单成功"); return CommonResult.success(result, "下单成功");
} }
/**
* 订单超时取消
* @return
*/
@Transactional @Transactional
@Override @Override
public CommonResult cancelTimeOutOrder() { public CommonResult cancelTimeOutOrder() {
@@ -927,6 +956,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
return CommonResult.success(null); return CommonResult.success(null);
} }
/**
* 删除订单
* @param orderId
* @return
*/
@Transactional @Transactional
@Override @Override
public CommonResult cancelOrder(Long orderId) { public CommonResult cancelOrder(Long orderId) {
@@ -1680,6 +1714,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
} }
/**
* 加速订单
* @param orderId
* @return
*/
@Override @Override
public CommonResult accelerateOrder(Long orderId) { public CommonResult accelerateOrder(Long orderId) {
OmsOrder order = orderMapper.selectByPrimaryKey(orderId); OmsOrder order = orderMapper.selectByPrimaryKey(orderId);
@@ -1738,6 +1777,10 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
@Value("${alipay.signType}") @Value("${alipay.signType}")
private String signType; private String signType;
/**
* 支付宝支付回调
* @param params
*/
@Override @Override
public void alipayCallback(Map<String, String> params) { public void alipayCallback(Map<String, String> params) {
LOGGER.info("============开始处理支付宝的支付异步通知 接收到参数 {}", JSONUtil.toJsonStr(params)); LOGGER.info("============开始处理支付宝的支付异步通知 接收到参数 {}", JSONUtil.toJsonStr(params));

View File

@@ -61,6 +61,11 @@
WHERE WHERE
hp.recommend_status = 1 hp.recommend_status = 1
AND p.publish_status = 1 AND p.publish_status = 1
AND (
p.vip_status = 1 OR
p.points_area_status = 1 OR
p.points_exchange_status = 1
)
ORDER BY ORDER BY
hp.sort DESC hp.sort DESC
LIMIT #{offset}, #{limit}; LIMIT #{offset}, #{limit};

0
mysql
View File