Subversion Repositories SmartDukaan

Rev

Rev 3061 | Rev 3374 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3061 Rev 3226
Line 351... Line 351...
351
     * 	2. Creates a return order for the warehouse executive to return the shipped material.
351
     * 	2. Creates a return order for the warehouse executive to return the shipped material.
352
     * 	3. Marks the current order as SALES_RET_REFUNDED, DOA_VALID_REFUNDED or DOA_INVALID_REFUNDED final states.
352
     * 	3. Marks the current order as SALES_RET_REFUNDED, DOA_VALID_REFUNDED or DOA_INVALID_REFUNDED final states.
353
     * 
353
     * 
354
     * If the order is in SUBMITTED_FOR_PROCESSING or INVENTORY_LOW state, it does the following:
354
     * If the order is in SUBMITTED_FOR_PROCESSING or INVENTORY_LOW state, it does the following:
355
     * 	1. Creates a refund request for batch processing.
355
     * 	1. Creates a refund request for batch processing.
-
 
356
     * 	2. Cancels the reservation of the item in the warehouse.
356
     * 	2. Marks the current order as the REFUNDED final state.
357
     * 	3. Marks the current order as the REFUNDED final state.
357
     * 
358
     * 
-
 
359
     * For all COD orders, if the order is in INIT, SUBMITTED_FOR_PROCESSING or INVENTORY_LOW state, it does the following:
-
 
360
     * 	1. Cancels the reservation of the item in the warehouse.
-
 
361
     * 	2. Marks the current order as CANCELED.
-
 
362
     * 	
-
 
363
     * In all cases, it updates the reason for cancellation or refund and the person who performed the action.
-
 
364
     *  
358
     * Returns True if it is successful, False otherwise.
365
     * Returns True if it is successful, False otherwise.
359
     * 
366
     * 
360
     * Throws an exception if the order with the given id couldn't be found.
367
     * Throws an exception if the order with the given id couldn't be found.
361
     * 
368
     * 
362
     * @param orderId
369
     * @param orderId
-
 
370
     * @param refundedBy
-
 
371
     * @param reason
363
     */
372
     */
364
    public boolean refundOrder(long orderId) throws TransactionServiceException, TException;
373
    public boolean refundOrder(long orderId, String refundedBy, String reason) throws TransactionServiceException, TException;
365
 
374
 
366
    /**
375
    /**
367
     * Get all return orders created between the from and to dates for the given warehouse.
376
     * Get all return orders created between the from and to dates for the given warehouse.
368
     * Ignores the warehouse if it is passed as -1.
377
     * Ignores the warehouse if it is passed as -1.
369
     * 
378
     * 
Line 2038... Line 2047...
2038
        throw result.ex;
2047
        throw result.ex;
2039
      }
2048
      }
2040
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "reshipOrder failed: unknown result");
2049
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "reshipOrder failed: unknown result");
2041
    }
2050
    }
2042
 
2051
 
2043
    public boolean refundOrder(long orderId) throws TransactionServiceException, TException
2052
    public boolean refundOrder(long orderId, String refundedBy, String reason) throws TransactionServiceException, TException
2044
    {
2053
    {
2045
      send_refundOrder(orderId);
2054
      send_refundOrder(orderId, refundedBy, reason);
2046
      return recv_refundOrder();
2055
      return recv_refundOrder();
2047
    }
2056
    }
2048
 
2057
 
2049
    public void send_refundOrder(long orderId) throws TException
2058
    public void send_refundOrder(long orderId, String refundedBy, String reason) throws TException
2050
    {
2059
    {
2051
      oprot_.writeMessageBegin(new TMessage("refundOrder", TMessageType.CALL, seqid_));
2060
      oprot_.writeMessageBegin(new TMessage("refundOrder", TMessageType.CALL, seqid_));
2052
      refundOrder_args args = new refundOrder_args();
2061
      refundOrder_args args = new refundOrder_args();
2053
      args.orderId = orderId;
2062
      args.orderId = orderId;
-
 
2063
      args.refundedBy = refundedBy;
-
 
2064
      args.reason = reason;
2054
      args.write(oprot_);
2065
      args.write(oprot_);
2055
      oprot_.writeMessageEnd();
2066
      oprot_.writeMessageEnd();
2056
      oprot_.getTransport().flush();
2067
      oprot_.getTransport().flush();
2057
    }
2068
    }
2058
 
2069
 
Line 3477... Line 3488...
3477
        refundOrder_args args = new refundOrder_args();
3488
        refundOrder_args args = new refundOrder_args();
3478
        args.read(iprot);
3489
        args.read(iprot);
3479
        iprot.readMessageEnd();
3490
        iprot.readMessageEnd();
3480
        refundOrder_result result = new refundOrder_result();
3491
        refundOrder_result result = new refundOrder_result();
3481
        try {
3492
        try {
3482
          result.success = iface_.refundOrder(args.orderId);
3493
          result.success = iface_.refundOrder(args.orderId, args.refundedBy, args.reason);
3483
          result.setSuccessIsSet(true);
3494
          result.setSuccessIsSet(true);
3484
        } catch (TransactionServiceException ex) {
3495
        } catch (TransactionServiceException ex) {
3485
          result.ex = ex;
3496
          result.ex = ex;
3486
        } catch (Throwable th) {
3497
        } catch (Throwable th) {
3487
          LOGGER.error("Internal error processing refundOrder", th);
3498
          LOGGER.error("Internal error processing refundOrder", th);
Line 35117... Line 35128...
35117
 
35128
 
35118
  public static class refundOrder_args implements TBase<refundOrder_args._Fields>, java.io.Serializable, Cloneable, Comparable<refundOrder_args>   {
35129
  public static class refundOrder_args implements TBase<refundOrder_args._Fields>, java.io.Serializable, Cloneable, Comparable<refundOrder_args>   {
35119
    private static final TStruct STRUCT_DESC = new TStruct("refundOrder_args");
35130
    private static final TStruct STRUCT_DESC = new TStruct("refundOrder_args");
35120
 
35131
 
35121
    private static final TField ORDER_ID_FIELD_DESC = new TField("orderId", TType.I64, (short)1);
35132
    private static final TField ORDER_ID_FIELD_DESC = new TField("orderId", TType.I64, (short)1);
-
 
35133
    private static final TField REFUNDED_BY_FIELD_DESC = new TField("refundedBy", TType.STRING, (short)2);
-
 
35134
    private static final TField REASON_FIELD_DESC = new TField("reason", TType.STRING, (short)3);
35122
 
35135
 
35123
    private long orderId;
35136
    private long orderId;
-
 
35137
    private String refundedBy;
-
 
35138
    private String reason;
35124
 
35139
 
35125
    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
35140
    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
35126
    public enum _Fields implements TFieldIdEnum {
35141
    public enum _Fields implements TFieldIdEnum {
35127
      ORDER_ID((short)1, "orderId");
35142
      ORDER_ID((short)1, "orderId"),
-
 
35143
      REFUNDED_BY((short)2, "refundedBy"),
-
 
35144
      REASON((short)3, "reason");
35128
 
35145
 
35129
      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
35146
      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
35130
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
35147
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
35131
 
35148
 
35132
      static {
35149
      static {
Line 35182... Line 35199...
35182
    private BitSet __isset_bit_vector = new BitSet(1);
35199
    private BitSet __isset_bit_vector = new BitSet(1);
35183
 
35200
 
35184
    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
35201
    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
35185
      put(_Fields.ORDER_ID, new FieldMetaData("orderId", TFieldRequirementType.DEFAULT, 
35202
      put(_Fields.ORDER_ID, new FieldMetaData("orderId", TFieldRequirementType.DEFAULT, 
35186
          new FieldValueMetaData(TType.I64)));
35203
          new FieldValueMetaData(TType.I64)));
-
 
35204
      put(_Fields.REFUNDED_BY, new FieldMetaData("refundedBy", TFieldRequirementType.DEFAULT, 
-
 
35205
          new FieldValueMetaData(TType.STRING)));
-
 
35206
      put(_Fields.REASON, new FieldMetaData("reason", TFieldRequirementType.DEFAULT, 
-
 
35207
          new FieldValueMetaData(TType.STRING)));
35187
    }});
35208
    }});
35188
 
35209
 
35189
    static {
35210
    static {
35190
      FieldMetaData.addStructMetaDataMap(refundOrder_args.class, metaDataMap);
35211
      FieldMetaData.addStructMetaDataMap(refundOrder_args.class, metaDataMap);
35191
    }
35212
    }
35192
 
35213
 
35193
    public refundOrder_args() {
35214
    public refundOrder_args() {
35194
    }
35215
    }
35195
 
35216
 
35196
    public refundOrder_args(
35217
    public refundOrder_args(
35197
      long orderId)
35218
      long orderId,
-
 
35219
      String refundedBy,
-
 
35220
      String reason)
35198
    {
35221
    {
35199
      this();
35222
      this();
35200
      this.orderId = orderId;
35223
      this.orderId = orderId;
35201
      setOrderIdIsSet(true);
35224
      setOrderIdIsSet(true);
-
 
35225
      this.refundedBy = refundedBy;
-
 
35226
      this.reason = reason;
35202
    }
35227
    }
35203
 
35228
 
35204
    /**
35229
    /**
35205
     * Performs a deep copy on <i>other</i>.
35230
     * Performs a deep copy on <i>other</i>.
35206
     */
35231
     */
35207
    public refundOrder_args(refundOrder_args other) {
35232
    public refundOrder_args(refundOrder_args other) {
35208
      __isset_bit_vector.clear();
35233
      __isset_bit_vector.clear();
35209
      __isset_bit_vector.or(other.__isset_bit_vector);
35234
      __isset_bit_vector.or(other.__isset_bit_vector);
35210
      this.orderId = other.orderId;
35235
      this.orderId = other.orderId;
-
 
35236
      if (other.isSetRefundedBy()) {
-
 
35237
        this.refundedBy = other.refundedBy;
-
 
35238
      }
-
 
35239
      if (other.isSetReason()) {
-
 
35240
        this.reason = other.reason;
-
 
35241
      }
35211
    }
35242
    }
35212
 
35243
 
35213
    public refundOrder_args deepCopy() {
35244
    public refundOrder_args deepCopy() {
35214
      return new refundOrder_args(this);
35245
      return new refundOrder_args(this);
35215
    }
35246
    }
Line 35240... Line 35271...
35240
 
35271
 
35241
    public void setOrderIdIsSet(boolean value) {
35272
    public void setOrderIdIsSet(boolean value) {
35242
      __isset_bit_vector.set(__ORDERID_ISSET_ID, value);
35273
      __isset_bit_vector.set(__ORDERID_ISSET_ID, value);
35243
    }
35274
    }
35244
 
35275
 
-
 
35276
    public String getRefundedBy() {
-
 
35277
      return this.refundedBy;
-
 
35278
    }
-
 
35279
 
-
 
35280
    public refundOrder_args setRefundedBy(String refundedBy) {
-
 
35281
      this.refundedBy = refundedBy;
-
 
35282
      return this;
-
 
35283
    }
-
 
35284
 
-
 
35285
    public void unsetRefundedBy() {
-
 
35286
      this.refundedBy = null;
-
 
35287
    }
-
 
35288
 
-
 
35289
    /** Returns true if field refundedBy is set (has been asigned a value) and false otherwise */
-
 
35290
    public boolean isSetRefundedBy() {
-
 
35291
      return this.refundedBy != null;
-
 
35292
    }
-
 
35293
 
-
 
35294
    public void setRefundedByIsSet(boolean value) {
-
 
35295
      if (!value) {
-
 
35296
        this.refundedBy = null;
-
 
35297
      }
-
 
35298
    }
-
 
35299
 
-
 
35300
    public String getReason() {
-
 
35301
      return this.reason;
-
 
35302
    }
-
 
35303
 
-
 
35304
    public refundOrder_args setReason(String reason) {
-
 
35305
      this.reason = reason;
-
 
35306
      return this;
-
 
35307
    }
-
 
35308
 
-
 
35309
    public void unsetReason() {
-
 
35310
      this.reason = null;
-
 
35311
    }
-
 
35312
 
-
 
35313
    /** Returns true if field reason is set (has been asigned a value) and false otherwise */
-
 
35314
    public boolean isSetReason() {
-
 
35315
      return this.reason != null;
-
 
35316
    }
-
 
35317
 
-
 
35318
    public void setReasonIsSet(boolean value) {
-
 
35319
      if (!value) {
-
 
35320
        this.reason = null;
-
 
35321
      }
-
 
35322
    }
-
 
35323
 
35245
    public void setFieldValue(_Fields field, Object value) {
35324
    public void setFieldValue(_Fields field, Object value) {
35246
      switch (field) {
35325
      switch (field) {
35247
      case ORDER_ID:
35326
      case ORDER_ID:
35248
        if (value == null) {
35327
        if (value == null) {
35249
          unsetOrderId();
35328
          unsetOrderId();
35250
        } else {
35329
        } else {
35251
          setOrderId((Long)value);
35330
          setOrderId((Long)value);
35252
        }
35331
        }
35253
        break;
35332
        break;
35254
 
35333
 
-
 
35334
      case REFUNDED_BY:
-
 
35335
        if (value == null) {
-
 
35336
          unsetRefundedBy();
-
 
35337
        } else {
-
 
35338
          setRefundedBy((String)value);
-
 
35339
        }
-
 
35340
        break;
-
 
35341
 
-
 
35342
      case REASON:
-
 
35343
        if (value == null) {
-
 
35344
          unsetReason();
-
 
35345
        } else {
-
 
35346
          setReason((String)value);
-
 
35347
        }
-
 
35348
        break;
-
 
35349
 
35255
      }
35350
      }
35256
    }
35351
    }
35257
 
35352
 
35258
    public void setFieldValue(int fieldID, Object value) {
35353
    public void setFieldValue(int fieldID, Object value) {
35259
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
35354
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
Line 35262... Line 35357...
35262
    public Object getFieldValue(_Fields field) {
35357
    public Object getFieldValue(_Fields field) {
35263
      switch (field) {
35358
      switch (field) {
35264
      case ORDER_ID:
35359
      case ORDER_ID:
35265
        return new Long(getOrderId());
35360
        return new Long(getOrderId());
35266
 
35361
 
-
 
35362
      case REFUNDED_BY:
-
 
35363
        return getRefundedBy();
-
 
35364
 
-
 
35365
      case REASON:
-
 
35366
        return getReason();
-
 
35367
 
35267
      }
35368
      }
35268
      throw new IllegalStateException();
35369
      throw new IllegalStateException();
35269
    }
35370
    }
35270
 
35371
 
35271
    public Object getFieldValue(int fieldId) {
35372
    public Object getFieldValue(int fieldId) {
Line 35275... Line 35376...
35275
    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
35376
    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
35276
    public boolean isSet(_Fields field) {
35377
    public boolean isSet(_Fields field) {
35277
      switch (field) {
35378
      switch (field) {
35278
      case ORDER_ID:
35379
      case ORDER_ID:
35279
        return isSetOrderId();
35380
        return isSetOrderId();
-
 
35381
      case REFUNDED_BY:
-
 
35382
        return isSetRefundedBy();
-
 
35383
      case REASON:
-
 
35384
        return isSetReason();
35280
      }
35385
      }
35281
      throw new IllegalStateException();
35386
      throw new IllegalStateException();
35282
    }
35387
    }
35283
 
35388
 
35284
    public boolean isSet(int fieldID) {
35389
    public boolean isSet(int fieldID) {
Line 35305... Line 35410...
35305
          return false;
35410
          return false;
35306
        if (this.orderId != that.orderId)
35411
        if (this.orderId != that.orderId)
35307
          return false;
35412
          return false;
35308
      }
35413
      }
35309
 
35414
 
-
 
35415
      boolean this_present_refundedBy = true && this.isSetRefundedBy();
-
 
35416
      boolean that_present_refundedBy = true && that.isSetRefundedBy();
-
 
35417
      if (this_present_refundedBy || that_present_refundedBy) {
-
 
35418
        if (!(this_present_refundedBy && that_present_refundedBy))
-
 
35419
          return false;
-
 
35420
        if (!this.refundedBy.equals(that.refundedBy))
-
 
35421
          return false;
-
 
35422
      }
-
 
35423
 
-
 
35424
      boolean this_present_reason = true && this.isSetReason();
-
 
35425
      boolean that_present_reason = true && that.isSetReason();
-
 
35426
      if (this_present_reason || that_present_reason) {
-
 
35427
        if (!(this_present_reason && that_present_reason))
-
 
35428
          return false;
-
 
35429
        if (!this.reason.equals(that.reason))
-
 
35430
          return false;
-
 
35431
      }
-
 
35432
 
35310
      return true;
35433
      return true;
35311
    }
35434
    }
35312
 
35435
 
35313
    @Override
35436
    @Override
35314
    public int hashCode() {
35437
    public int hashCode() {
Line 35329... Line 35452...
35329
      }
35452
      }
35330
      lastComparison = TBaseHelper.compareTo(orderId, typedOther.orderId);
35453
      lastComparison = TBaseHelper.compareTo(orderId, typedOther.orderId);
35331
      if (lastComparison != 0) {
35454
      if (lastComparison != 0) {
35332
        return lastComparison;
35455
        return lastComparison;
35333
      }
35456
      }
-
 
35457
      lastComparison = Boolean.valueOf(isSetRefundedBy()).compareTo(isSetRefundedBy());
-
 
35458
      if (lastComparison != 0) {
-
 
35459
        return lastComparison;
-
 
35460
      }
-
 
35461
      lastComparison = TBaseHelper.compareTo(refundedBy, typedOther.refundedBy);
-
 
35462
      if (lastComparison != 0) {
-
 
35463
        return lastComparison;
-
 
35464
      }
-
 
35465
      lastComparison = Boolean.valueOf(isSetReason()).compareTo(isSetReason());
-
 
35466
      if (lastComparison != 0) {
-
 
35467
        return lastComparison;
-
 
35468
      }
-
 
35469
      lastComparison = TBaseHelper.compareTo(reason, typedOther.reason);
-
 
35470
      if (lastComparison != 0) {
-
 
35471
        return lastComparison;
-
 
35472
      }
35334
      return 0;
35473
      return 0;
35335
    }
35474
    }
35336
 
35475
 
35337
    public void read(TProtocol iprot) throws TException {
35476
    public void read(TProtocol iprot) throws TException {
35338
      TField field;
35477
      TField field;
Line 35354... Line 35493...
35354
                setOrderIdIsSet(true);
35493
                setOrderIdIsSet(true);
35355
              } else { 
35494
              } else { 
35356
                TProtocolUtil.skip(iprot, field.type);
35495
                TProtocolUtil.skip(iprot, field.type);
35357
              }
35496
              }
35358
              break;
35497
              break;
-
 
35498
            case REFUNDED_BY:
-
 
35499
              if (field.type == TType.STRING) {
-
 
35500
                this.refundedBy = iprot.readString();
-
 
35501
              } else { 
-
 
35502
                TProtocolUtil.skip(iprot, field.type);
-
 
35503
              }
-
 
35504
              break;
-
 
35505
            case REASON:
-
 
35506
              if (field.type == TType.STRING) {
-
 
35507
                this.reason = iprot.readString();
-
 
35508
              } else { 
-
 
35509
                TProtocolUtil.skip(iprot, field.type);
-
 
35510
              }
-
 
35511
              break;
35359
          }
35512
          }
35360
          iprot.readFieldEnd();
35513
          iprot.readFieldEnd();
35361
        }
35514
        }
35362
      }
35515
      }
35363
      iprot.readStructEnd();
35516
      iprot.readStructEnd();
Line 35369... Line 35522...
35369
 
35522
 
35370
      oprot.writeStructBegin(STRUCT_DESC);
35523
      oprot.writeStructBegin(STRUCT_DESC);
35371
      oprot.writeFieldBegin(ORDER_ID_FIELD_DESC);
35524
      oprot.writeFieldBegin(ORDER_ID_FIELD_DESC);
35372
      oprot.writeI64(this.orderId);
35525
      oprot.writeI64(this.orderId);
35373
      oprot.writeFieldEnd();
35526
      oprot.writeFieldEnd();
-
 
35527
      if (this.refundedBy != null) {
-
 
35528
        oprot.writeFieldBegin(REFUNDED_BY_FIELD_DESC);
-
 
35529
        oprot.writeString(this.refundedBy);
-
 
35530
        oprot.writeFieldEnd();
-
 
35531
      }
-
 
35532
      if (this.reason != null) {
-
 
35533
        oprot.writeFieldBegin(REASON_FIELD_DESC);
-
 
35534
        oprot.writeString(this.reason);
-
 
35535
        oprot.writeFieldEnd();
-
 
35536
      }
35374
      oprot.writeFieldStop();
35537
      oprot.writeFieldStop();
35375
      oprot.writeStructEnd();
35538
      oprot.writeStructEnd();
35376
    }
35539
    }
35377
 
35540
 
35378
    @Override
35541
    @Override
Line 35381... Line 35544...
35381
      boolean first = true;
35544
      boolean first = true;
35382
 
35545
 
35383
      sb.append("orderId:");
35546
      sb.append("orderId:");
35384
      sb.append(this.orderId);
35547
      sb.append(this.orderId);
35385
      first = false;
35548
      first = false;
-
 
35549
      if (!first) sb.append(", ");
-
 
35550
      sb.append("refundedBy:");
-
 
35551
      if (this.refundedBy == null) {
-
 
35552
        sb.append("null");
-
 
35553
      } else {
-
 
35554
        sb.append(this.refundedBy);
-
 
35555
      }
-
 
35556
      first = false;
-
 
35557
      if (!first) sb.append(", ");
-
 
35558
      sb.append("reason:");
-
 
35559
      if (this.reason == null) {
-
 
35560
        sb.append("null");
-
 
35561
      } else {
-
 
35562
        sb.append(this.reason);
-
 
35563
      }
-
 
35564
      first = false;
35386
      sb.append(")");
35565
      sb.append(")");
35387
      return sb.toString();
35566
      return sb.toString();
35388
    }
35567
    }
35389
 
35568
 
35390
    public void validate() throws TException {
35569
    public void validate() throws TException {