|
@@ -16,11 +16,21 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.jupiter.api.extension.ParameterResolutionException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
+/**
|
|
|
+ * 平台订单逻辑开发
|
|
|
+ *
|
|
|
+ * @author xufeng
|
|
|
+ * @date 2022-06-06 17:06
|
|
|
+ */
|
|
|
+
|
|
|
+@Component
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class PlatformOrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements PlatformOrderService {
|
|
@@ -53,18 +63,17 @@ public class PlatformOrderServiceImpl extends ServiceImpl<OrderMapper, Order> im
|
|
|
if (!order.getStatus().equals(OrderStateEnum.NO_PAY.getCode())) {
|
|
|
throw new ParameterResolutionException("订单状态非待支付");
|
|
|
}
|
|
|
+ if (!order.getUserId().equals(platformOrderBO.getUserId())) {
|
|
|
+ throw new ParameterResolutionException("订单与用户关系不符");
|
|
|
+ }
|
|
|
order.setRealAmount(platformOrderBO.getRealAmount());
|
|
|
order.setMerchantOrderNo(platformOrderBO.getMerchantOrderNo());
|
|
|
order.setStatus(OrderStateEnum.SUCCESS.getCode());
|
|
|
order.setGamePaywayId(platformOrderBO.getGamePaywayId());
|
|
|
- order.setPayTime(LocalDateTime.now());
|
|
|
+ order.setPayTime(platformOrderBO.getPayTime() == null ? platformOrderBO.getPayTime() : new Date());
|
|
|
order.setMemNote(StringUtils.isEmpty(platformOrderBO.getMemNote()) ? null : platformOrderBO.getMemNote());
|
|
|
logger.info("订单支付提交数据 data:{}", order);
|
|
|
- LambdaUpdateWrapper<Order> wrapper = Wrappers.lambdaUpdate(Order.class)
|
|
|
- .eq(Order::getId, platformOrderBO.getId())
|
|
|
- .eq(Order::getUserId, platformOrderBO.getUserId())
|
|
|
- .setEntity(order);
|
|
|
- return super.update(wrapper);
|
|
|
+ return updateById(order);
|
|
|
} catch (ParameterResolutionException e) {
|
|
|
logger.error("订单支付失败 platformOrderBO:{}, error:{}", platformOrderBO, e);
|
|
|
e.printStackTrace();
|
|
@@ -84,10 +93,7 @@ public class PlatformOrderServiceImpl extends ServiceImpl<OrderMapper, Order> im
|
|
|
order.setAdminNote(StringUtils.isEmpty(platformOrderBO.getAdminNote()) ? null : platformOrderBO.getAdminNote());
|
|
|
order.setRemark(StringUtils.isEmpty(platformOrderBO.getRemark()) ? null : platformOrderBO.getRemark());
|
|
|
logger.info("订单取消提交数据 data:{}", order);
|
|
|
- LambdaUpdateWrapper<Order> wrapper = Wrappers.lambdaUpdate(Order.class)
|
|
|
- .eq(Order::getId, platformOrderBO.getId())
|
|
|
- .setEntity(order);
|
|
|
- return super.update(wrapper);
|
|
|
+ return updateById(order);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("订单取消失败 platformOrderBO:{}, error:{}", platformOrderBO, e);
|
|
|
e.printStackTrace();
|
|
@@ -96,13 +102,13 @@ public class PlatformOrderServiceImpl extends ServiceImpl<OrderMapper, Order> im
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PlatformOrderDTO info(Long id) {
|
|
|
+ public PlatformOrderDTO info(String id) {
|
|
|
Order order = getOne(new LambdaQueryWrapper<Order>().eq(Order::getId, id));
|
|
|
return BeanUtils.copy(order, PlatformOrderDTO.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 检查订单创建参数
|
|
|
+ * 检查订单参数
|
|
|
*
|
|
|
* @param platformOrderBO
|
|
|
* @return
|
|
@@ -136,6 +142,9 @@ public class PlatformOrderServiceImpl extends ServiceImpl<OrderMapper, Order> im
|
|
|
if (platformOrderBO.getId() == null) {
|
|
|
throw new NullPointerException("id");
|
|
|
}
|
|
|
+ if (platformOrderBO.getUserId() == null) {
|
|
|
+ throw new NullPointerException("UserId");
|
|
|
+ }
|
|
|
if (platformOrderBO.getStatus() == 0) {
|
|
|
throw new NullPointerException("Status");
|
|
|
}
|
|
@@ -149,6 +158,7 @@ public class PlatformOrderServiceImpl extends ServiceImpl<OrderMapper, Order> im
|
|
|
throw new NullPointerException("MerchantOrderNo");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case "cancel":
|