Commit 63794f7559e37bfe0934dab315652a703a61f14d

Authored by zhangxing
1 parent 628d2af8

update buyer

src/main/java/com/diligrp/xtrade/order/dao/OrderDao.java
... ... @@ -66,8 +66,8 @@ public interface OrderDao {
66 66 * @return
67 67 * @throws
68 68 */
69   - int updateBuyerInfo(@Param("baccount") Long baccount, @Param("bcardNo") Long bcardNo,
70   - @Param("bcardType") Long bcardType, @Param("bname") Long bname, @Param("bmobile") Long bmobile);
  69 + int updateBuyerInfo(@Param("baccount") Long baccount, @Param("bcardNo") String bcardNo,
  70 + @Param("bcardType") Integer bcardType, @Param("bname") String bname, @Param("bmobile") String bmobile);
71 71  
72 72 /**
73 73 *
... ...
src/main/java/com/diligrp/xtrade/order/exception/OrderError.java 0 → 100644
  1 +package com.diligrp.xtrade.order.exception;
  2 +
  3 +import java.util.Arrays;
  4 +
  5 +import com.diligrp.xtrade.shared.type.IEnumType;
  6 +
  7 +/**
  8 + * 订单错误信息描述
  9 + */
  10 +public enum OrderError implements IEnumType{
  11 +
  12 + ORDER_NOT_EXIST(300001, "订单不存在"),
  13 + ORDER_IS_PAIED(300002, "订单已支付"),
  14 + ORDER_IS_CLOSED(300003, "订单已关闭"),
  15 + SELLER_EQUAL_BUYER(300004, "买卖家相同");
  16 +
  17 + private int code;
  18 + private String name;
  19 +
  20 + OrderError(int code, String name) {
  21 + this.setCode(code);
  22 + this.name = name;
  23 + }
  24 +
  25 + public static OrderError getByType(int code) {
  26 + return Arrays.stream(values())
  27 + .filter(e -> e.getCode() == code)
  28 + .findFirst()
  29 + .orElse(null);
  30 + }
  31 +
  32 + public static String getName(int index) {
  33 + return Arrays.stream(OrderError.values())
  34 + .filter(e -> e.getCode() == index)
  35 + .findFirst().map(e -> e.name)
  36 + .orElse(null);
  37 + }
  38 +
  39 +
  40 + @Override
  41 + public int getCode() {
  42 + return this.code;
  43 + }
  44 +
  45 + @Override
  46 + public String getName() {
  47 + return this.name;
  48 + }
  49 +
  50 + public void setCode(int code) {
  51 + this.code = code;
  52 + }
  53 +
  54 +}
... ...
src/main/java/com/diligrp/xtrade/order/service/impl/OrderServiceImpl.java
... ... @@ -68,19 +68,25 @@ public class OrderServiceImpl implements OrderService {
68 68 // 插入订单信息
69 69 orderDao.insertEntity(defaultOrderCreator.createOrder());
70 70 }
71   -
  71 +
72 72 // TODO need modify because of change
73 73 @Override
74 74 public void updateBuyer(OrderRequestDto orderRequestDto) {
75 75 OrderDo orderDo = orderDao.selectEntityByOrderId(orderRequestDto.getOrderId());
76   - if (orderDo == null ) {
  76 + if (orderDo == null) {
77 77 throw new OrderException(OrderError.ORDER_NOT_EXIST);
78 78 }
79 79 if (orderDo.getOrderStatus() == OrderStatus.PAIED.getCode()) {
80 80 throw new OrderException(OrderError.ORDER_IS_PAIED);
81 81 }
82   - AccountDto baccountDto = accountResolver.getAccount(orderRequestDto.getBaccount());
83   - //TODO
  82 +
  83 + AccountDto buyer = accountResolver.getAccount(orderRequestDto.getBaccount());
  84 + if (orderDo.getSaccount().equals(orderRequestDto.getBaccount())
  85 + || orderDo.getSaccount().equals(buyer.getParentAccountId())) {
  86 + throw new OrderException(OrderError.SELLER_EQUAL_BUYER);
  87 + }
  88 + orderDao.updateBuyerInfo(buyer.getAccountId(), buyer.getCardNo(), buyer.getType(), buyer.getAccountName(),
  89 + buyer.getMobile());
84 90 }
85 91  
86 92 // TODO need modify because of change
... ... @@ -107,8 +113,8 @@ public class OrderServiceImpl implements OrderService {
107 113 // TODO need modify because of change
108 114 @Override
109 115 public OrderResponseDto orderDetail(Long orderId) {
110   - OrderResponseDto orderResponseDto = OrderDataBuilder
111   - .buildOrderDetail(orderDao.selectEntityByOrderId(orderId), orderItemDao.selectItemsByOrderId(orderId));
  116 + OrderResponseDto orderResponseDto = OrderDataBuilder.buildOrderDetail(orderDao.selectEntityByOrderId(orderId),
  117 + orderItemDao.selectItemsByOrderId(orderId));
112 118 return orderResponseDto;
113 119 }
114 120  
... ...