后端:增加支付成功后,回调支付模块
This commit is contained in:
@@ -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 查询
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 查询
|
||||
-->
|
||||
|
||||
Reference in New Issue
Block a user