diff --git a/common/common-framework/pom.xml b/common/common-framework/pom.xml
index e88edb5ff..5c8c10317 100644
--- a/common/common-framework/pom.xml
+++ b/common/common-framework/pom.xml
@@ -45,10 +45,12 @@
2.9.7
- org.hibernate.validator
+ org.hibernate
hibernate-validator
- 6.0.15.Final
+
+ 6.0.16.Final
+
@@ -84,5 +86,4 @@
-
diff --git a/mobile-web/package.json b/mobile-web/package.json
index 430724bc5..09fda12f3 100644
--- a/mobile-web/package.json
+++ b/mobile-web/package.json
@@ -14,7 +14,8 @@
"vant": "^1.3.1",
"vue": "^2.5.17",
"vue-router": "^3.0.1",
- "vuex": "^3.1.0"
+ "vuex": "^3.1.0",
+ "pingpp-js": "^2.2.13"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.4.1",
diff --git a/mobile-web/src/page/pay/index.vue b/mobile-web/src/page/pay/index.vue
new file mode 100644
index 000000000..441a57616
--- /dev/null
+++ b/mobile-web/src/page/pay/index.vue
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+ 领取优惠劵
+
+
+
+
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersOrderController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersOrderController.java
index 911051198..4d47364b1 100644
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersOrderController.java
+++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersOrderController.java
@@ -57,10 +57,11 @@ public class UsersOrderController {
@PostMapping("create_order")
@ApiOperation("创建订单")
- public CommonResult createOrder(@RequestBody @Validated OrderCreatePO orderCreatePO) {
+ public CommonResult createOrder(@RequestBody @Validated OrderCreatePO orderCreatePO,
+ HttpServletRequest request) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.convert(orderCreatePO);
- orderCreateDTO.setUserId(userId);
+ orderCreateDTO.setUserId(userId).setIp(HttpUtil.getIp(request));
return orderService.createOrder(orderCreateDTO);
}
diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/PayAppId.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/PayAppId.java
index 139d4783d..8d729ab8c 100644
--- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/PayAppId.java
+++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/PayAppId.java
@@ -11,6 +11,6 @@ public class PayAppId {
/**
* 电商
*/
- public static final String APP_ID_1024 = "1024";
+ public static final String APP_ID_SHOP_ORDER = "POd4RC6a";
}
diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderServiceImpl.java
index a8c9a3c3b..b167032aa 100644
--- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderServiceImpl.java
+++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderServiceImpl.java
@@ -1,6 +1,7 @@
package cn.iocoder.mall.order.biz.service;
import cn.iocoder.common.framework.constant.DeletedStatusEnum;
+import cn.iocoder.common.framework.util.DateUtil;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderService;
@@ -8,6 +9,7 @@ import cn.iocoder.mall.order.api.bo.*;
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.order.api.constant.OrderHasReturnExchangeEnum;
import cn.iocoder.mall.order.api.constant.OrderStatusEnum;
+import cn.iocoder.mall.order.api.constant.PayAppId;
import cn.iocoder.mall.order.api.dto.*;
import cn.iocoder.mall.order.biz.constants.OrderDeliveryTypeEnum;
import cn.iocoder.mall.order.biz.constants.OrderRecipientTypeEnum;
@@ -15,6 +17,8 @@ import cn.iocoder.mall.order.biz.convert.*;
import cn.iocoder.mall.order.biz.dao.*;
import cn.iocoder.mall.order.biz.dataobject.*;
import cn.iocoder.mall.pay.api.PayTransactionService;
+import cn.iocoder.mall.pay.api.bo.PayTransactionBO;
+import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO;
import cn.iocoder.mall.product.api.ProductSpuService;
import cn.iocoder.mall.product.api.bo.ProductSkuDetailBO;
import cn.iocoder.mall.user.api.UserAddressService;
@@ -41,9 +45,9 @@ import java.util.stream.Collectors;
public class OrderServiceImpl implements OrderService {
/**
- * 支付过期时间 15 分钟
+ * 支付过期时间 120 分钟
*/
- public static final int PAY_EXPIRE_TIME = 15;
+ public static final int PAY_EXPIRE_TIME = 120;
@Autowired
private OrderMapper orderMapper;
@@ -64,7 +68,7 @@ public class OrderServiceImpl implements OrderService {
private CartServiceImpl cartService;
@Reference
private UserAddressService userAddressService;
- @Reference
+ @Reference(validation = "true")
private PayTransactionService payTransactionService;
@Override
@@ -187,7 +191,7 @@ public class OrderServiceImpl implements OrderService {
}
@Override
- @Transactional
+ @Transactional // TODO 芋艿,先不考虑分布式事务的问题
public CommonResult createOrder(OrderCreateDTO orderCreateDTO) {
Integer userId = orderCreateDTO.getUserId();
List orderItemDTOList = orderCreateDTO.getOrderItems();
@@ -245,6 +249,9 @@ public class OrderServiceImpl implements OrderService {
.setPresentTotal(priceItem.getPresentTotal());
}
+ // TODO 芋艿,标记优惠劵使用
+ // TODO 芋艿,扣除库存
+
// order
// TODO: 2019-04-11 Sin 订单号需要生成规则
@@ -310,19 +317,10 @@ public class OrderServiceImpl implements OrderService {
orderItemMapper.insert(orderItemDOList);
// 创建预订单
- // TODO sin 支付订单 orderSubject 暂时取第一个子订单商品信息
-// String orderSubject = orderItemDOList.get(0).getSkuName();
-// Date expireTime = DateUtil.addDate(Calendar.MINUTE, PAY_EXPIRE_TIME);
-// CommonResult commonResult = payTransactionService.createTransaction(
-// new PayTransactionCreateDTO()
-// .setCreateIp(orderCreateDTO.getIp())
-// .setAppId(PayAppId.APP_ID_1024)
-// .setExpireTime(expireTime)
-// .setPrice(orderDO.getPayAmount())
-// .setOrderSubject(orderSubject)
-// .setOrderMemo(orderDO.getRemark())
-// .setOrderDescription("")
-// );
+ CommonResult createPayTransactionResult = createPayTransaction(orderDO, orderItemDOList, orderCreateDTO.getIp());
+ if (calcOrderPriceResult.isError()) {
+ return CommonResult.error(calcOrderPriceResult);
+ }
// if (commonResult.isError()) {
// //手动开启事务回滚
@@ -352,6 +350,23 @@ public class OrderServiceImpl implements OrderService {
return cartService.calcOrderPrice(calcOrderPriceDTO);
}
+ private CommonResult createPayTransaction(OrderDO order, List orderItems, String ip) {
+ // TODO sin 支付订单 orderSubject 暂时取第一个子订单商品信息
+ String orderSubject = orderItems.get(0).getSkuName();
+ Date expireTime = DateUtil.addDate(Calendar.MINUTE, PAY_EXPIRE_TIME);
+ return payTransactionService.createTransaction(
+ new PayTransactionCreateDTO()
+ .setCreateIp(ip)
+ .setAppId(PayAppId.APP_ID_SHOP_ORDER)
+ .setOrderId(order.getId().toString())
+ .setExpireTime(expireTime)
+ .setPrice(order.getPresentPrice())
+ .setOrderSubject(orderSubject)
+ .setOrderMemo("测试备注") // TODO 芋艿,后面补充
+ .setOrderDescription("测试描述") // TODO 芋艿,后面补充
+ );
+ }
+
@Override
public CommonResult updateOrderItem(OrderItemUpdateDTO orderUpdateDTO) {
OrderItemDO orderItemDO = OrderItemConvert.INSTANCE.convert(orderUpdateDTO);
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/PayTransactionCreateDTO.java b/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/PayTransactionCreateDTO.java
index e55966e0b..ec89b8ec9 100644
--- a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/PayTransactionCreateDTO.java
+++ b/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/PayTransactionCreateDTO.java
@@ -2,11 +2,11 @@ package cn.iocoder.mall.pay.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.DecimalMin;
-import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
@@ -36,18 +36,18 @@ public class PayTransactionCreateDTO implements Serializable {
* 订单商品名
*/
@NotEmpty(message = "商品名不能为空")
- @Size(max = 32, message = "商品名不能超过32")
+ @Length(max = 32, message = "商品名不能超过32")
private String orderSubject;
/**
* 订单商品描述
*/
@NotEmpty(message = "商品描述不能为空")
- @Size(max = 128, message = "商品描述长度不能超过128")
+ @Length(max = 128, message = "商品描述长度不能超过128")
private String orderDescription;
/**
* 订单备注
*/
- @Size(max = 256, message = "商品描述长度不能超过256")
+ @Length(max = 256, message = "商品描述长度不能超过256")
private String orderMemo;
/**
* 支付金额,单位:分。
diff --git a/pom.xml b/pom.xml
index 5c5481e3c..4faca0c36 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,7 @@
pom
+ 2.1.3.RELEASE
2.6.5
5.1.47
0.2.1.RELEASE
@@ -118,6 +119,30 @@
org.apache.rocketmq
rocketmq-spring-boot-starter
${rocketmq-spring-boot-starter.version}
+
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+ ${springboot.version}
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ ${springboot.version}
+
+
+
+
+
+