1. 增加 XXL-Job starter
2. 迁移 pay 服务的 Job 逻辑
This commit is contained in:
@@ -17,28 +17,6 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface OrderMapper extends BaseMapper<OrderDO> {
|
||||
|
||||
/**
|
||||
* 更新 - 根据 id 更新
|
||||
*
|
||||
* @param orderDO
|
||||
* @return
|
||||
*/
|
||||
int updateById(OrderDO orderDO);
|
||||
|
||||
int updateByIdAndStatus(@Param("id") Integer id,
|
||||
@Param("status") Integer status,
|
||||
@Param("updateObj") OrderDO updateObj);
|
||||
|
||||
/**
|
||||
* 查询 - 根据id 查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
OrderDO selectById(
|
||||
@Param("id") Integer id
|
||||
);
|
||||
|
||||
/**
|
||||
* 查询 - 后台分页page
|
||||
*
|
||||
|
||||
@@ -326,31 +326,6 @@ public class OrderServiceImpl implements OrderService {
|
||||
return CommonResult.success(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 状态为已支付,等待发货
|
||||
OrderDO updateOrderObj = new OrderDO()
|
||||
.setStatus(OrderStatusEnum.WAIT_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();
|
||||
}
|
||||
// TODO FROM 芋艿 to 小范,把更新 OrderItem 给补全。
|
||||
return "success";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult listenerConfirmGoods() {
|
||||
return null;
|
||||
|
||||
@@ -2,100 +2,6 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.mall.order.biz.dao.order.OrderMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, user_id, order_no, buy_price, discount_price, logistics_price, present_price, pay_amount,
|
||||
payment_time, delivery_time, receiver_time, closing_time,
|
||||
has_return_exchange,
|
||||
status, remark, create_time, update_time, `deleted`
|
||||
</sql>
|
||||
|
||||
<sql id="updateFieldSql" >
|
||||
<set>
|
||||
<if test="orderNo != null">
|
||||
, order_no = #{orderNo}
|
||||
</if>
|
||||
<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>
|
||||
<if test="closingTime != null">
|
||||
, closing_time = #{closingTime}
|
||||
</if>
|
||||
<if test="hasReturnExchange != null">
|
||||
, has_return_exchange = #{hasReturnExchange}
|
||||
</if>
|
||||
|
||||
<if test="status != null">
|
||||
, status = #{status}
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
, remark = #{remark}
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
, `deleted` = #{deleted}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
, create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
, update_time = #{updateTime}
|
||||
</if>
|
||||
</set>
|
||||
</sql>
|
||||
|
||||
<update id="updateById" parameterType="OrderDO">
|
||||
UPDATE `orders`
|
||||
<include refid="updateFieldSql" />
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateByIdAndStatus">
|
||||
UPDATE `orders`
|
||||
<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>
|
||||
|
||||
<select id="selectById" resultType="cn.iocoder.mall.order.biz.dataobject.OrderDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM `orders`
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<sql id="selectWhere">
|
||||
<if test="status != null">
|
||||
AND `status` = #{status}
|
||||
|
||||
Reference in New Issue
Block a user