syntax = "proto3";

package discount;

import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
import "discount/audit.model.proto";

option go_package = "./discount";

message DiscountOptional {
	string ID = 1;
	optional string Name = 2;
	optional uint32 Layer = 3;
	optional string Description = 4;
	optional DiscountCondition Condition = 5;
	optional DiscountCalculationTarget Target = 6;
	optional bool Deprecated = 7;
}

message Discounts {
	repeated Discount Discounts = 1;
}

message Discount {
	string ID = 1;
	string Name = 2;
	uint32 Layer = 3;
	string Description = 4;
	DiscountCondition Condition = 5;
	DiscountCalculationTarget Target = 6;
	Audit Audit = 7;
	bool Deprecated = 8;
}

message DiscountCalculationTarget {
	repeated ProductTarget Products = 1;
	double Factor = 2;
	optional TargetScope TargetScope = 3;
	optional string TargetGroup = 4;
	optional bool Overhelm = 5;
}

message DiscountCondition {
	optional PeriodCondition Period = 1;
	optional string User = 2;
	optional string UserType = 3;
	optional string Coupon = 4;
	optional uint64 PurchasesAmount = 5;
	optional uint64 CartPurchasesAmount = 6;
	optional string Product = 7;
	optional uint64 Term = 8;
	optional uint64 Usage = 9;
	optional uint64 PriceFrom = 10;
	optional string Group = 11;
}

message ProductTarget {
	string ID = 1;
	double Factor = 2;
	optional bool Overhelm = 3;
}

message PeriodCondition {
	google.protobuf.Timestamp From = 1;
	google.protobuf.Timestamp To = 2;
}

message UserInformation {
  string ID = 1;
	string Type = 2;
	uint64 PurchasesAmount = 3;
	uint64 CartPurchasesAmount = 4;
}

message ProductInformation {
	string ID = 1;
	uint64 Price = 2;
	optional uint64 Term = 3;
	optional uint64 Usage = 4;
	optional string Group = 5;
}

enum TargetScope {
	Sum = 0;
	Group = 1;
	Each = 2;
}