增加会员专区 积分专区 积分兑换内容 增加三个专区的字段 #1
@@ -1,6 +1,5 @@
|
||||
package com.buy507.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.buy507.mall.component.RedisLock;
|
||||
import com.buy507.mall.dao.*;
|
||||
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.model.*;
|
||||
import com.buy507.mall.service.PmsProductService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -23,6 +23,9 @@ public class SmsHomeNewProductServiceImpl implements SmsHomeNewProductService {
|
||||
for (SmsHomeNewProduct SmsHomeNewProduct : homeNewProductList) {
|
||||
SmsHomeNewProduct.setRecommendStatus(1);
|
||||
SmsHomeNewProduct.setSort(0);
|
||||
SmsHomeNewProduct.setVipStatus(1);
|
||||
SmsHomeNewProduct.setPointsAreaStatus(1);
|
||||
SmsHomeNewProduct.setPointsExchangeStatus(1);
|
||||
homeNewProductMapper.insert(SmsHomeNewProduct);
|
||||
}
|
||||
return homeNewProductList.size();
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.buy507.mall.model.SmsHomeNewProduct;
|
||||
import com.buy507.mall.model.SmsHomeNewProductExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
public interface SmsHomeNewProductMapper {
|
||||
long countByExample(SmsHomeNewProductExample example);
|
||||
@@ -27,4 +28,10 @@ public interface SmsHomeNewProductMapper {
|
||||
int updateByPrimaryKeySelective(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);
|
||||
}
|
||||
@@ -16,6 +16,17 @@ public class SmsHomeNewProduct implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// 会员专区状态
|
||||
private Integer vipStatus;
|
||||
|
||||
// 积分专区状态
|
||||
private Integer pointsAreaStatus;
|
||||
|
||||
// 积分兑换专区状态
|
||||
private Integer pointsExchangeStatus;
|
||||
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -56,6 +67,35 @@ public class SmsHomeNewProduct implements Serializable {
|
||||
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
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.buy507.mall.model.SmsHomeNewProduct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -215,6 +216,13 @@ public class OmsPortalOrderController {
|
||||
@ApiOperation("普通单排队信息")
|
||||
@RequestMapping("/orderQueue/info")
|
||||
public CommonResult orderQueueInfo() {
|
||||
|
||||
SmsHomeNewProduct smsHomeNewProduct = new SmsHomeNewProduct();
|
||||
//如果是积分专区的商品和积分兑换的商品则不进行排队
|
||||
if(smsHomeNewProduct.getPointsAreaStatus() == 1 || smsHomeNewProduct.getPointsExchangeStatus() == 1){
|
||||
return CommonResult.success("该商品不参与排队流程");
|
||||
}
|
||||
//否则进行排队
|
||||
return portalOrderService.orderQueueInfo();
|
||||
}
|
||||
|
||||
@@ -224,6 +232,11 @@ public class OmsPortalOrderController {
|
||||
@ApiOperation(" 加速单排队信息")
|
||||
@RequestMapping("/accelerateOrder/info")
|
||||
public CommonResult accelerateOrderInfo(@RequestParam Long orderId) {
|
||||
SmsHomeNewProduct smsHomeNewProduct = new SmsHomeNewProduct();
|
||||
//如果是积分专区的商品和积分兑换的商品则不进行排队
|
||||
if(smsHomeNewProduct.getPointsAreaStatus() == 1 || smsHomeNewProduct.getPointsExchangeStatus() == 1){
|
||||
return CommonResult.success("该商品不参与排队流程");
|
||||
}
|
||||
return portalOrderService.accelerateOrderInfo(orderId);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
@Autowired
|
||||
private UmsMemberOrderQueueMapper umsMemberOrderQueueMapper;
|
||||
|
||||
@Autowired
|
||||
private SmsHomeNewProductMapper homeNewProductMapper;
|
||||
|
||||
|
||||
|
||||
@Value("${kuaidi100.url}")
|
||||
@@ -438,6 +441,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(loginMember.getId());
|
||||
orderResult.setShareUrl("http://49.233.215.129:688/#/pages/public/register?inviteCode="+member.getInvitationCode());
|
||||
|
||||
|
||||
|
||||
UmsMemberOrderQueueExample example1 = new UmsMemberOrderQueueExample();
|
||||
example1.createCriteria().andQuitQueueMarkEqualTo(UmsMemberOrderQueue.QUEUE_STATUS_WAIT).andQueueTypeEqualTo(UmsMemberOrderQueue.QUEUE_TYPE_ORDINARY);
|
||||
long allQueue = umsMemberOrderQueueMapper.countByExample(example1);
|
||||
@@ -697,20 +702,23 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
/**
|
||||
* 创建订单
|
||||
*/
|
||||
public CommonResult createOrder(OrderParam orderParam) {
|
||||
//orderParam.setSkuId(98L);
|
||||
if(orderParam.getSkuId() == null) {
|
||||
return CommonResult.validateFailed("商品SKU不能为空");
|
||||
}
|
||||
|
||||
|
||||
if(orderParam.getDeliveryType() == null || (orderParam.getDeliveryType() != 0 && orderParam.getDeliveryType() != 1) ) {
|
||||
return CommonResult.validateFailed("提货方式不能为空");
|
||||
}
|
||||
|
||||
|
||||
if(orderParam.getMemberReceiveAddressId() == null) {
|
||||
return CommonResult.validateFailed("会员收货地址不能为空");
|
||||
}
|
||||
|
||||
|
||||
UmsMemberReceiveAddress address = memberReceiveAddressMapper.selectOneById(orderParam.getMemberReceiveAddressId());
|
||||
if(address == null) {
|
||||
return CommonResult.validateFailed("未查询到会员收货地址");
|
||||
@@ -730,28 +738,42 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
if ((skuStock.getStock() - skuStock.getLockStock()) < orderParam.getQuantity()) {
|
||||
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查询商品信息
|
||||
PmsProduct product = productMapper.selectByPrimaryKey(skuStock.getProductId());
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if(product != null) {
|
||||
|
||||
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(memberService.getCurrentMember().getId());
|
||||
|
||||
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
BigDecimal price = new BigDecimal(skuStock.getPrice().doubleValue());
|
||||
if(discount != null) {
|
||||
price = skuStock.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
|
||||
BigDecimal totalAmount = new BigDecimal(0);
|
||||
BigDecimal zero = new BigDecimal(0);
|
||||
totalAmount = price.multiply(new BigDecimal(orderParam.getQuantity()));
|
||||
|
||||
|
||||
if(orderParam.getIntegration() == null) {
|
||||
orderParam.setIntegration(zero);
|
||||
}
|
||||
|
||||
|
||||
//先判断积分是否大于0,大于0表示使用了积分支付
|
||||
//flag 等于1表示使用积分支付 判断用户积分是否充足
|
||||
//flag = -1,表示integration小于0;flag = 0,表示integration等于0;flag = 1,表示integration大于0;
|
||||
@@ -764,18 +786,19 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
return CommonResult.validateFailed("森态积分不足,无法抵扣");
|
||||
}*/
|
||||
}
|
||||
|
||||
while(true) {
|
||||
long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
|
||||
if(redisLock.lock(String.valueOf(skuStock.getProductId()), String.valueOf(time))) {
|
||||
|
||||
|
||||
//重新查询获取最新的数据
|
||||
skuStock = skuStockMapper.selectByPrimaryKey(orderParam.getSkuId());
|
||||
|
||||
|
||||
//判断购物车中商品是否都有库存 (库存 - 锁定库存 = 真实库存)
|
||||
if ((skuStock.getStock() - skuStock.getLockStock()) < orderParam.getQuantity()) {
|
||||
return CommonResult.validateFailed("库存不足,无法下单");
|
||||
}
|
||||
|
||||
|
||||
skuStock.setLockStock(skuStock.getLockStock() + orderParam.getQuantity());
|
||||
skuStockMapper.updateByPrimaryKey(skuStock);
|
||||
redisLock.unlock(String.valueOf(skuStock.getProductId()), String.valueOf(time));
|
||||
@@ -783,6 +806,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//生成订单信息
|
||||
OmsOrder order = new OmsOrder();
|
||||
order.setTotalAmount(totalAmount); // 订单总金额
|
||||
@@ -801,7 +825,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
order.setIntegrationAmount(totalAmount);
|
||||
integeration = totalAmount;
|
||||
}
|
||||
|
||||
|
||||
//冻结用户余额
|
||||
member = memberMapper.selectByPrimaryKey(member.getId());
|
||||
//flag = -1,表示balance小于integeration;flag = 0,表示balance等于integeration;flag = 1,表示balance大于integeration;
|
||||
@@ -838,12 +862,12 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
order.setStatus(0);
|
||||
//订单类型:0->正常订单;1->秒杀订单 2->5连订单
|
||||
order.setOrderType(0);
|
||||
|
||||
|
||||
OmsOrderSetting orderSetting = orderSettingMapper.selectByPrimaryKey(1L);
|
||||
order.setAutoConfirmDay(orderSetting.getConfirmOvertime());
|
||||
order.setIntegration(0);
|
||||
order.setGrowth(0);
|
||||
|
||||
|
||||
//收货人信息:姓名、电话、邮编、地址
|
||||
order.setReceiverName(address.getName());
|
||||
order.setReceiverPhone(address.getPhoneNumber());
|
||||
@@ -852,9 +876,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
order.setReceiverCity(address.getCity());
|
||||
order.setReceiverRegion(address.getRegion());
|
||||
order.setReceiverDetailAddress(address.getDetailAddress());
|
||||
|
||||
|
||||
order.setNote(orderParam.getNote() == null ? null : orderParam.getNote());
|
||||
|
||||
|
||||
//确认收货状态:0->未确认;1->已确认
|
||||
order.setConfirmStatus(0);
|
||||
//删除状态:0->未删除;1->已删除
|
||||
@@ -862,9 +886,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
order.setUseIntegration(0);
|
||||
order.setPromotionInfo("无优惠");
|
||||
order.setSettlementStatus(0); //分销结算状态(0->未结算;1->已结算;2->不结算)
|
||||
|
||||
|
||||
orderMapper.insert(order);
|
||||
|
||||
|
||||
//生成订单商品信息
|
||||
OmsOrderItem orderItem = new OmsOrderItem();
|
||||
orderItem.setOrderId(order.getId());
|
||||
@@ -890,21 +914,26 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
orderItem.setCouponAmount(new BigDecimal(0));
|
||||
orderItem.setIntegrationAmount(new BigDecimal(0));
|
||||
orderItem.setRealAmount(new BigDecimal(0));
|
||||
|
||||
|
||||
orderItemMapper.insert(orderItem);
|
||||
|
||||
|
||||
//超时未支付,自动取消订单
|
||||
//分钟转换成毫秒
|
||||
long delayTimes = orderSetting.getNormalOrderOvertime() * 60 * 1000;
|
||||
cancelOrderSender.sendMessage(order.getId(), delayTimes);
|
||||
|
||||
|
||||
result.put("orderId", order.getId());
|
||||
result.put("totalAmount", order.getPayAmount());
|
||||
}
|
||||
|
||||
|
||||
return CommonResult.success(result, "下单成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 订单超时取消
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public CommonResult cancelTimeOutOrder() {
|
||||
@@ -927,6 +956,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public CommonResult cancelOrder(Long orderId) {
|
||||
@@ -1680,6 +1714,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加速订单
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult accelerateOrder(Long orderId) {
|
||||
OmsOrder order = orderMapper.selectByPrimaryKey(orderId);
|
||||
@@ -1738,6 +1777,10 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
@Value("${alipay.signType}")
|
||||
private String signType;
|
||||
|
||||
/**
|
||||
* 支付宝支付回调
|
||||
* @param params
|
||||
*/
|
||||
@Override
|
||||
public void alipayCallback(Map<String, String> params) {
|
||||
LOGGER.info("============开始处理支付宝的支付异步通知 接收到参数 {}", JSONUtil.toJsonStr(params));
|
||||
|
||||
@@ -61,6 +61,11 @@
|
||||
WHERE
|
||||
hp.recommend_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
|
||||
hp.sort DESC
|
||||
LIMIT #{offset}, #{limit};
|
||||
|
||||
Reference in New Issue
Block a user