229 lines
8.3 KiB
C#
229 lines
8.3 KiB
C#
using Newtonsoft.Json;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
|
|
|
|
using USER_GUID = System.String;
|
|
using BEACON_GUID = System.String;
|
|
using META_ID = System.UInt32;
|
|
|
|
|
|
|
|
namespace ServerCommon;
|
|
|
|
public class BeaconShopSoldPriceAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
|
{
|
|
[JsonProperty]
|
|
public USER_GUID UserGuid { get; set; } = string.Empty;
|
|
|
|
[JsonProperty]
|
|
public BEACON_GUID BeaconGuid { get; set; } = string.Empty;
|
|
|
|
[JsonProperty]
|
|
public double TaxPrice { get; set; } = 0;
|
|
|
|
[JsonProperty]
|
|
public double GivenPrice { get; set; } = 0;
|
|
|
|
[JsonProperty]
|
|
public int NumOfReceiptNotReceived { get; set; } = 0;
|
|
|
|
public BeaconShopSoldPriceAttribute(EntityBase owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
|
|
public override void onClear()
|
|
{
|
|
UserGuid = string.Empty;
|
|
BeaconGuid = string.Empty;
|
|
TaxPrice = 0;
|
|
GivenPrice = 0;
|
|
NumOfReceiptNotReceived = 0;
|
|
}
|
|
|
|
public override EntityAttributeBase onCloned()
|
|
{
|
|
var cloned = new BeaconShopSoldPriceAttribute(getOwner());
|
|
cloned.UserGuid = UserGuid;
|
|
cloned.BeaconGuid = BeaconGuid;
|
|
cloned.TaxPrice = TaxPrice;
|
|
cloned.GivenPrice = GivenPrice;
|
|
cloned.NumOfReceiptNotReceived = NumOfReceiptNotReceived;
|
|
|
|
return cloned;
|
|
}
|
|
|
|
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
|
{
|
|
return new BeaconShopSoldPriceAttributeTransactor(getOwner());
|
|
}
|
|
|
|
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
|
{
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
//=====================================================================================
|
|
// Attribute => try pending Doc
|
|
//=====================================================================================
|
|
var try_pending_doc = getTryPendingDocBase() as BeaconShopSoldPriceDoc;
|
|
if (null == try_pending_doc)
|
|
{
|
|
var to_copy_doc = new BeaconShopSoldPriceDoc(UserGuid);
|
|
|
|
var origin_doc = getOriginDocBase<BeaconShopSoldPriceAttribute>();
|
|
if (null != origin_doc)
|
|
{
|
|
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
|
}
|
|
|
|
try_pending_doc = to_copy_doc;
|
|
|
|
setTryPendingDocBase(try_pending_doc);
|
|
}
|
|
|
|
var to_copy_doc_attrib = try_pending_doc.getAttrib<BeaconShopSoldPriceAttrib>();
|
|
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
|
|
|
to_copy_doc_attrib.UserGuid = UserGuid;
|
|
to_copy_doc_attrib.BeaconGuid = BeaconGuid;
|
|
to_copy_doc_attrib.GivenPrice = GivenPrice;
|
|
to_copy_doc_attrib.TaxPrice = TaxPrice;
|
|
to_copy_doc_attrib.NumOfReceiptNotReceived = NumOfReceiptNotReceived;
|
|
|
|
if (false == isForQuery)
|
|
{
|
|
return (result, try_pending_doc);
|
|
}
|
|
|
|
//=====================================================================================
|
|
// Doc QueryType 반영
|
|
//=====================================================================================
|
|
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
|
if (result.isFail())
|
|
{
|
|
return (result, to_query_doc);
|
|
}
|
|
|
|
return (result, to_query_doc);
|
|
}
|
|
|
|
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
|
{
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
var to_cast_string = typeof(BeaconShopSoldPriceDoc).Name;
|
|
|
|
var beacon_shop_item_history_doc_base = docBase as BeaconShopSoldPriceDoc;
|
|
if (null == beacon_shop_item_history_doc_base)
|
|
{
|
|
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, beacon_shop_item_history_doc_base is null :{to_cast_string}";
|
|
Log.getLogger().error(err_msg);
|
|
return false;
|
|
}
|
|
|
|
//=====================================================================================
|
|
// New Doc => Origin Doc
|
|
//=====================================================================================
|
|
syncOriginDocBaseWithNewDoc<BeaconShopSoldPriceAttribute>(beacon_shop_item_history_doc_base);
|
|
|
|
//=====================================================================================
|
|
// Doc => Attribute
|
|
//=====================================================================================
|
|
var doc_attrib = beacon_shop_item_history_doc_base.getAttrib<BeaconShopSoldPriceAttrib>();
|
|
if (doc_attrib == null)
|
|
{
|
|
err_msg = $"Failed to get beacon_shop attrib : {nameof(BeaconShopSoldPriceAttrib)}";
|
|
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
|
Log.getLogger().error(err_msg);
|
|
return false;
|
|
}
|
|
|
|
UserGuid = doc_attrib.UserGuid;
|
|
BeaconGuid = doc_attrib.BeaconGuid;
|
|
GivenPrice = doc_attrib.GivenPrice;
|
|
TaxPrice = doc_attrib.TaxPrice;
|
|
NumOfReceiptNotReceived = doc_attrib.NumOfReceiptNotReceived;
|
|
|
|
return true;
|
|
}
|
|
|
|
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
|
{
|
|
var owner = getOwner();
|
|
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
|
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
if (null == otherEntityAttribute)
|
|
{
|
|
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
|
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
|
Log.getLogger().error(result.toBasicString());
|
|
|
|
return result;
|
|
}
|
|
|
|
//=====================================================================================
|
|
// OtherAttribute => Attribute
|
|
//=====================================================================================
|
|
var beacon_shop_item_history_attribute = otherEntityAttribute as BeaconShopSoldPriceAttribute;
|
|
if (null == beacon_shop_item_history_attribute)
|
|
{
|
|
err_msg = $"Failed to cast Attribute !!!, beacon_shop_item_history_attribute is null";
|
|
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
|
Log.getLogger().error(result.toBasicString());
|
|
|
|
return result;
|
|
}
|
|
|
|
UserGuid = beacon_shop_item_history_attribute.UserGuid;
|
|
BeaconGuid = beacon_shop_item_history_attribute.BeaconGuid;
|
|
GivenPrice = beacon_shop_item_history_attribute.GivenPrice;
|
|
TaxPrice = beacon_shop_item_history_attribute.TaxPrice;
|
|
NumOfReceiptNotReceived = beacon_shop_item_history_attribute.NumOfReceiptNotReceived;
|
|
|
|
//=====================================================================================
|
|
// Attribute Try Pending Doc => Origin Doc
|
|
//=====================================================================================
|
|
var try_pending_doc = beacon_shop_item_history_attribute.getTryPendingDocBase() as BeaconShopSoldPriceDoc;
|
|
if (null != try_pending_doc)
|
|
{
|
|
beacon_shop_item_history_attribute.resetTryPendingDocBase();
|
|
|
|
syncOriginDocBaseWithNewDoc<BeaconShopSoldPriceAttribute>(try_pending_doc);
|
|
}
|
|
|
|
var origin_doc_base = getOriginDocBase<BeaconShopSoldPriceAttribute>();
|
|
if (null == origin_doc_base)
|
|
{
|
|
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
|
return result;
|
|
}
|
|
|
|
var beacon_shop_item_history_attrib = origin_doc_base.getAttrib<BeaconShopSoldPriceAttrib>();
|
|
NullReferenceCheckHelper.throwIfNull(beacon_shop_item_history_attrib, () => $"beacon_shop_item_history_attrib is null !!! - {owner.toBasicString()}");
|
|
|
|
beacon_shop_item_history_attrib.UserGuid = UserGuid;
|
|
beacon_shop_item_history_attrib.BeaconGuid = BeaconGuid;
|
|
beacon_shop_item_history_attrib.GivenPrice = GivenPrice;
|
|
beacon_shop_item_history_attrib.TaxPrice = TaxPrice;
|
|
beacon_shop_item_history_attrib.NumOfReceiptNotReceived = NumOfReceiptNotReceived;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public class BeaconShopSoldPriceAttributeTransactor : EntityAttributeTransactorBase<BeaconShopSoldPriceAttribute>
|
|
{
|
|
public BeaconShopSoldPriceAttributeTransactor(EntityBase owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
}
|