后端:增加支付成功后,回调支付模块

This commit is contained in:
YunaiV
2019-04-21 15:22:03 +08:00
parent 914de3f2cb
commit 3eca1823ee
8 changed files with 151 additions and 40 deletions

View File

@@ -138,8 +138,21 @@ public interface OrderService {
*
* mq 更新 payStatus
*/
@Deprecated
CommonResult listenerPayment();
/**
* 更新订单支付成功
*
* 如果成功,则返回 success
* 如果失败,则返回具体原因
*
* @param orderId 订单编号
* @param payAmount 支付的订单金额
* @return 支付结果
*/
String updatePaySuccess(String orderId, Integer payAmount);
/**
* 监听确认收货
*

View File

@@ -25,6 +25,8 @@ public enum OrderErrorCodeEnum {
ORDER_NOT_USER_ORDER(1008000011, "不是该用户的订单!"),
ORDER_UNABLE_CONFIRM_ORDER(1008000012, "状态不对不能确认订单!"),
ORDER_CREATE_CART_IS_EMPTY(1008000013, "购物车无选中的商品,无法创建订单"),
ORDER_STATUS_NOT_WAITING_PAYMENT(1008000014, "订单不处于等待支付状态"),
ORDER_PAY_AMOUNT_ERROR(1008000015, "订单金额不正确"),
// order item
ORDER_ITEM_ONLY_ONE(1008000200, "订单Item只有一个!"),

View File

@@ -31,6 +31,10 @@ public interface OrderMapper {
*/
int updateById(OrderDO orderDO);
int updateByIdAndStatus(@Param("id") Integer id,
@Param("status") Integer status,
@Param("updateObj") OrderDO updateObj);
/**
* 查询 - 根据id 查询
*

View File

@@ -598,6 +598,29 @@ public class OrderServiceImpl implements OrderService {
return null;
}
@Override
public String updatePaySuccess(String orderId, Integer payAmount) {
OrderDO order = orderMapper.selectById(Integer.valueOf(orderId));
if (order == null) { // 订单不存在
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode()).getMessage();
}
if (!order.getStatus().equals(OrderStatusEnum.WAITING_PAYMENT.getValue())) { // 状态不处于等待支付
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_STATUS_NOT_WAITING_PAYMENT.getCode()).getMessage();
}
if (!order.getPresentPrice().equals(payAmount)) { // 支付金额不正确
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_PAY_AMOUNT_ERROR.getCode()).getMessage();
}
OrderDO updateOrderObj = new OrderDO()
.setStatus(OrderStatusEnum.ALREADY_SHIPMENT.getValue())
.setPayAmount(payAmount)
.setPaymentTime(new Date());
int updateCount = orderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj);
if (updateCount <= 0) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_STATUS_NOT_WAITING_PAYMENT.getCode()).getMessage();
}
return "success";
}
@Override
public CommonResult listenerConfirmGoods() {
return null;

View File

@@ -34,22 +34,30 @@
<if test="orderNo != null">
, order_no = #{orderNo}
</if>
<!-- <if test="price != null">--> <!-- TODO 后面要改下 -->
<!-- , price = #{price}-->
<!-- </if>-->
<!-- <if test="payAmount != null">-->
<!-- , pay_amount = #{payAmount}-->
<!-- </if>-->
<!-- <if test="logisticsPrice != null">-->
<!-- , logistics_price = #{logisticsPrice}-->
<!-- </if>-->
<if test="paymentTime != null">
, payment_time = #{paymentTime}
<if test="buyPrice != null">
, buy_price = #{buyPrice}
</if>
<if test="discountPrice != null">
, discount_price = #{discountPrice}
</if>
<if test="logisticsPrice != null">
, logistics_price = #{logisticsPrice}
</if>
<if test="logisticsPrice != null">
, logistics_price = #{logisticsPrice}
</if>
<if test="presentPrice != null">
, present_price = #{presentPrice}
</if>
<if test="payAmount != null">
, pay_amount = #{payAmount}
</if>
<if test="deliveryTime != null">
, delivery_time = #{deliveryTime}
</if>
<if test="paymentTime != null">
, payment_time = #{paymentTime}
</if>
<if test="receiverTime != null">
, receiver_time = #{receiverTime}
</if>
@@ -87,6 +95,23 @@
WHERE id = #{id}
</update>
<update id="updateByIdAndStatus">
UPDATE `order`
<set>
<if test="updateObj.payAmount != null">
, pay_amount = #{updateObj.payAmount}
</if>
<if test="updateObj.paymentTime != null">
, payment_time = #{updateObj.paymentTime}
</if>
<if test="updateObj.status != null">
, status = #{updateObj.status}
</if>
</set>
WHERE id = #{id}
AND status = #{status}
</update>
<!--
查询 - 根据id 查询
-->