状态流程控制

来源:互联网 发布:淘宝招聘中老年女模特 编辑:程序博客网 时间:2024/06/05 15:29
    Date statusModifiedTime = new Date();//信息更新时间    tradeOrder.setModifiedTime(statusModifiedTime);    /**     *  2. 数据更新     */    String staus = tradeOrder.getStatus();//待更新 状态    String stausDB =  tradeOrderDB.getStatus();//数据库当前状态    /**     * 流程 状态 控制中心      */    if(staus != null && !"".equals(staus)){        logger.info("订单当前状态:"+stausDB);        switch (stausDB){

// * WAIT_BUYER_PAY(等待买家付款)
// * WAIT_SELLER_SEND_GOODS(等待卖家发货,即:买家已付款)
// * WAIT_BUYER_CONFIRM_GOODS(等待买家确认收货,即:卖家已发货)
// * TRADE_BUYER_CONFIRM(买家确认收货,待评价)
// * TRADE_FINISHED(交易成功)
// * TRADE_CLOSED(付款以后用户退款成功,交易自动关闭)
// * TRADE_CLOSED_BY_MSHOP(付款以前,卖家主动关闭交易)
// * TRADE_CLOSED_BY_BUYER(付款以前,买家主动关闭交易)

            case "WAIT_BUYER_PAY":                // 订单状态为  等待买家付款  只可以更改为WAIT_SELLER_SEND_GOODS  TRADE_CLOSED_BY_MSHOP  TRADE_CLOSED_BY_BUYER                if(!(staus.equals("WAIT_SELLER_SEND_GOODS")) && !(staus.equals("TRADE_CLOSED_BY_MSHOP")) && !(staus.equals("TRADE_CLOSED_BY_BUYER"))){                    //可更改的状态 为  买家取消 , 或 卖家 同意 ,拒绝, 等待买家发货 WAIT_BUYER_SEND_GOODS                    throw new ParamException(BaseCode.PARAM_ERROR, "订单状态为  等待买家付款,不能更改为"+ staus);                }                // WAIT_SELLER_SEND_GOODS(等待卖家发货,即:买家已付款)                 if(staus.equals("WAIT_SELLER_SEND_GOODS")){                    tradeOrder.setPaymentTime(statusModifiedTime);                }                //TRADE_CLOSED_BY_MSHOP(付款以前,卖家主动关闭交易)                 if(staus.equals("TRADE_CLOSED_BY_MSHOP")){                }                //TRADE_CLOSED_BY_BUYER(付款以前,买家主动关闭交易)                 if(staus.equals("WAIT_SELLER_SEND_GOODS")){                }                break;            case "WAIT_SELLER_SEND_GOODS":                //WAIT_SELLER_SEND_GOODS(等待卖家发货,即:买家已付款)  只可以更改为WAIT_BUYER_CONFIRM_GOODS                 if(!staus.equals("WAIT_BUYER_CONFIRM_GOODS")){                    throw new ParamException(BaseCode.PARAM_ERROR, "订单已付款 等待卖家发货,不能更改为"+ staus);                }                //WAIT_BUYER_CONFIRM_GOODS(等待买家确认收货,即:卖家已发货)                 if(staus.equals("WAIT_BUYER_CONFIRM_GOODS")){                    tradeOrder.setSellerSendGoodsTime(statusModifiedTime);                }                break;            case "WAIT_BUYER_CONFIRM_GOODS":                // WAIT_BUYER_CONFIRM_GOODS(等待买家确认收货,即:卖家已发货)   只可以更改为TRADE_BUYER_CONFIRM                 if(!staus.equals("TRADE_BUYER_CONFIRM")){                    throw new ParamException(BaseCode.PARAM_ERROR, "订单卖家已发货,等待买家确认收货,不能更改为"+ staus);                }                //TRADE_BUYER_CONFIRM(买家确认收货,待评价)                 if(staus.equals("TRADE_BUYER_CONFIRM")){                    tradeOrder.setBuyerConfirmTime(statusModifiedTime);                }                break;            case "TRADE_BUYER_CONFIRM":                // TRADE_BUYER_CONFIRM(买家确认收货,待评价)    只可以更改为TRADE_FINISHED                 if(!staus.equals("TRADE_FINISHED")){                    throw new ParamException(BaseCode.PARAM_ERROR, "订单买家已经确认收货,不能更改为"+ staus);                }                //TRADE_FINISHED(交易成功)                  if(staus.equals("TRADE_FINISHED")){                    tradeOrder.setEvaluationTime(statusModifiedTime);                }                break;            case "TRADE_FINISHED":                if(staus != null){                    throw new ParamException(BaseCode.PARAM_ERROR, "订单交易成功,不能更改为"+ staus);                }                break;            case "TRADE_CLOSED_BY_MSHOP":                if(staus != null){                    throw new ParamException(BaseCode.PARAM_ERROR, "卖家主动关闭订单,不能更改为"+ staus);                }                break;            case "TRADE_CLOSED_BY_BUYER":                if(staus != null){                    throw new ParamException(BaseCode.PARAM_ERROR, "买家主动关闭订单,不能更改为"+ staus);                }                break;            default:                throw new ParamException(BaseCode.PARAM_ERROR, "当前订单异常:"+ stausDB);        }    }    /**     * 订单在关闭状态下才可以 删除     */    Integer isBuyerDelete = tradeOrder.getIsBuyerDelete();    Integer isDelete = tradeOrder.getIsDelete();    Integer isSellerDelete = tradeOrder.getIsSellerDelete();    if("TRADE_FINISHED".equals(stausDB) || "TRADE_CLOSED_BY_MSHOP".equals(stausDB) || "TRADE_CLOSED_BY_BUYER".equals(stausDB) ){         /**         *  买家 删除操作         */        if(isBuyerDelete != null && isBuyerDelete.equals(1)){            tradeOrder.setBuyerDeleteTime(statusModifiedTime);        }        /**         *  系统 删除操作         */        if(isDelete != null && isDelete.equals(1)){            tradeOrder.setDeleteTime(statusModifiedTime);        }        /**         *  卖家 删除操作         */        if(isSellerDelete != null && isSellerDelete.equals(1)){            tradeOrder.setSellerDeleteTime(statusModifiedTime);        }    }else{        if(isBuyerDelete != null && isBuyerDelete.equals(1)){            throw new ParamException(BaseCode.PARAM_ERROR, "当前订单未关闭,不能删!订单状态为:"+ stausDB);        }        if(isSellerDelete != null && isSellerDelete.equals(1)){            throw new ParamException(BaseCode.PARAM_ERROR, "当前订单未关闭,不能删!订单状态为:"+ stausDB);        }        if(isDelete != null && isDelete.equals(1)){            throw new ParamException(BaseCode.PARAM_ERROR, "当前订单未关闭,不能删!订单状态为:"+ stausDB);        }    }    //更新操作    tradeOrderService.updateByPrimaryKeySelective(tradeOrder);

“`

0 0
原创粉丝点击