| | |
| | | SIX(6, "骑手已取货,正在送货"), |
| | | SEVEN(7, "商品已送达"), |
| | | EIGHT(8, "订单已完成"), |
| | | NINE(9, "用户取消订单"), |
| | | UNKNOWN(99, "未知枚举"); |
| | | |
| | | private final Integer key; |
| | |
| | | import com.oying.modules.sh.domain.vo.OrderResponse; |
| | | import com.oying.modules.sh.service.OrderReturnService; |
| | | import com.oying.modules.sh.service.OrderService; |
| | | import com.oying.utils.enums.OrderStatusEnum; |
| | | import com.oying.utils.enums.PayStateEnum; |
| | | import com.oying.utils.enums.PayTypeEnum; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | PayStateEnum stateEnum = PayStateEnum.NOTPAY; |
| | | if ("0".equals(map.get("pay_result"))) { |
| | | stateEnum = PayStateEnum.SUCCESS; |
| | | orderService.operationLog(order); |
| | | orderService.operationLog(order, OrderStatusEnum.TWO); |
| | | } |
| | | orderService.updatePayStatus(map.get("out_trade_no"), stateEnum, map.get("pay_info"), map.get("time_end")); |
| | | // 处理成功 |
| | |
| | | import com.oying.modules.sh.domain.Order; |
| | | import com.oying.modules.sh.domain.OrderAddressSnapshot; |
| | | import com.oying.modules.sh.domain.OrderOperationLog; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @AllArgsConstructor |
| | | public class OrderResponse { |
| | | |
| | | private Order order; |
| | |
| | | |
| | | void updatePayStatus(String orderNum, String payState, String payMessage, String payTime); |
| | | |
| | | void updateCloseStatus(String orderNum, String payState); |
| | | void updateCloseStatus(String orderNum, String payState, String payMessage); |
| | | |
| | | void updateOrderStatus(String orderNum, Integer key, String value); |
| | | } |
| | |
| | | package com.oying.modules.sh.service; |
| | | |
| | | import com.oying.modules.sh.domain.Order; |
| | | import com.oying.modules.sh.domain.OrderAddressSnapshot; |
| | | import com.oying.modules.sh.domain.OrderOperationLog; |
| | | import com.oying.modules.sh.domain.dto.OrderOperationLogQueryCriteria; |
| | | import java.util.List; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.oying.modules.sh.domain.vo.OrderResponse; |
| | | import com.oying.utils.PageResult; |
| | | import com.oying.utils.enums.OrderStatusEnum; |
| | | |
| | | /** |
| | | * @description 服务接口 |
| | |
| | | List<OrderOperationLog> queryAll(OrderOperationLogQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | */ |
| | | void create(OrderOperationLog resources); |
| | | |
| | | /** |
| | | * 创建 |
| | | */ |
| | | void create(Order order, OrderAddressSnapshot addressSnapshot); |
| | | void create(OrderResponse response, OrderStatusEnum statusEnum); |
| | | |
| | | /** |
| | | * 编辑 |
| | |
| | | import com.oying.modules.sh.domain.vo.OrderInfo; |
| | | import com.oying.modules.sh.domain.vo.OrderResponse; |
| | | import com.oying.utils.PageResult; |
| | | import com.oying.utils.enums.OrderStatusEnum; |
| | | import com.oying.utils.enums.PayStateEnum; |
| | | |
| | | /** |
| | |
| | | |
| | | OrderResponse getByOrderNum(String orderNum); |
| | | |
| | | void operationLog(OrderResponse order); |
| | | void operationLog(OrderResponse order, OrderStatusEnum stateEnum); |
| | | |
| | | void updatePayStatus(String outTradeNo, PayStateEnum stateEnum, String payInfo, String timeEnd); |
| | | |
| | |
| | | package com.oying.modules.sh.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.oying.modules.sh.domain.Order; |
| | | import com.oying.modules.sh.domain.OrderAddressSnapshot; |
| | | import com.oying.modules.sh.domain.OrderOperationLog; |
| | | import com.oying.modules.sh.domain.vo.OrderResponse; |
| | | import com.oying.modules.sh.mapper.OrderMapper; |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void create(OrderOperationLog resources) { |
| | | orderOperationLogMapper.insert(resources); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void create(Order order, OrderAddressSnapshot addressSnapshot) { |
| | | OrderResponse response = new OrderResponse(); |
| | | response.setOrder(order); |
| | | response.setAddress(addressSnapshot); |
| | | public void create(OrderResponse response, OrderStatusEnum statusEnum) { |
| | | String userType = ConstantsKey.BUYER; |
| | | switch (statusEnum) { |
| | | case ZERO: |
| | | case ONE: |
| | | case EIGHT: |
| | | case NINE: |
| | | userType = ConstantsKey.BUYER; |
| | | break; |
| | | case TWO: |
| | | case FOUR: |
| | | userType = ConstantsKey.MERCHANT; |
| | | break; |
| | | case THREE: |
| | | case FIVE: |
| | | case SIX: |
| | | case SEVEN: |
| | | userType = ConstantsKey.RIDER; |
| | | break; |
| | | default: |
| | | } |
| | | String username = SecurityUtils.getCurrentUsername(); |
| | | Timestamp time = new Timestamp(System.currentTimeMillis()); |
| | | OrderOperationLog resources = new OrderOperationLog(); |
| | | resources.setOrderNum(order.getOrderNum()); |
| | | resources.setOrderNum(response.getOrder().getOrderNum()); |
| | | resources.setUsername(username); |
| | | resources.setUserType(ConstantsKey.BUYER); |
| | | resources.setOperation(OrderStatusEnum.ZERO.getKey()); |
| | | resources.setOperationDescribe(OrderStatusEnum.ZERO.getValue()); |
| | | resources.setRemark(username + ":" + time + ">" + OrderStatusEnum.ZERO.getValue() + ":" + order.getOrderNum()); |
| | | resources.setUserType(userType); |
| | | resources.setOperation(statusEnum.getKey()); |
| | | resources.setOperationDescribe(statusEnum.getValue()); |
| | | resources.setRemark(username + ":" + time + ">" + statusEnum.getValue() + ":" + response.getOrder().getOrderNum()); |
| | | resources.setSnapshotData(JSON.toJSONString(response)); |
| | | resources.setOperationTime(time); |
| | | orderOperationLogMapper.insert(resources); |
| | | orderMapper.updateOrderStatus(response.getOrder().getOrderNum(), statusEnum.getKey(), statusEnum.getValue()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | productSnapshotService.saveBatch(snapshots); |
| | | |
| | | order.setProductSnapshots(new HashSet<>(snapshots)); |
| | | operationLogService.create(order, addressSnapshot); |
| | | OrderResponse response = new OrderResponse(order, addressSnapshot, null); |
| | | |
| | | operationLogService.create(response, OrderStatusEnum.ZERO); |
| | | return order; |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public OrderResponse getByOrderNum(String orderNum) { |
| | | OrderResponse response = new OrderResponse(); |
| | | response.setOrder(orderMapper.getByOrderNum(orderNum)); |
| | | response.setAddress(addressSnapshotService.queryByOrderNum(orderNum)); |
| | | response.setOperation(operationLogService.getByOrderNum(orderNum)); |
| | | return response; |
| | | return new OrderResponse(orderMapper.getByOrderNum(orderNum), |
| | | addressSnapshotService.queryByOrderNum(orderNum), |
| | | operationLogService.getByOrderNum(orderNum)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void operationLog(OrderResponse order) { |
| | | orderMapper.updateOrderStatus(order.getOrder().getOrderNum(), OrderStatusEnum.TWO.getKey(), OrderStatusEnum.TWO.getValue()); |
| | | public void operationLog(OrderResponse order, OrderStatusEnum stateEnum) { |
| | | operationLogService.create(order, stateEnum); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void closeOrder(String orderNum) { |
| | | Order order = orderMapper.getByOrderNum(orderNum); |
| | | OrderResponse response = getByOrderNum(orderNum); |
| | | Order order = response.getOrder(); |
| | | if (order == null) { |
| | | throw new BadRequestException("订单不存在"); |
| | | } |
| | | if (!SecurityUtils.getCurrentUserId().equals(order.getUserId())) { |
| | | throw new BadRequestException("不能修改他人订单"); |
| | | } |
| | | if (!order.getPayState().equals(PayStateEnum.NOTPAY.getKey())) { |
| | | throw new BadRequestException(PayStateEnum.getValue(order.getPayState())); |
| | |
| | | swiftPassService.closeOrder(orderNum, anEnum); |
| | | break; |
| | | } |
| | | orderMapper.updateCloseStatus(orderNum, PayStateEnum.CLOSED.getKey()); |
| | | operationLogService.create(response, OrderStatusEnum.NINE); |
| | | orderMapper.updateCloseStatus(orderNum, PayStateEnum.CLOSED.getKey(), PayStateEnum.CLOSED.getValue()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | redis: |
| | | #数据库索引 |
| | | database: 0 |
| | | host: 192.168.18.13 |
| | | host: 127.0.0.1 |
| | | port: 6379 |
| | | password: |
| | | #连接超时时间 |
| | |
| | | |
| | | <update id="updateCloseStatus"> |
| | | update sh_order |
| | | set pay_state = #{payState} |
| | | set pay_state = #{payState}, |
| | | pay_message = #{payMessage} |
| | | where order_num = #{orderNum} |
| | | </update> |
| | | |
| | | <update id="updateOrderStatus"> |
| | | update sh_order |
| | | set order_status = #{key}, |
| | | set order_status = #{key}, |
| | | order_status_describe = #{value} |
| | | where order_num = #{orderNum} |
| | | </update> |