using System;
using System.Collections.Generic;
using System.Text;
using ChuPiao.Common.Models;
using ChuPiao.Common.Core.Security;

namespace ChuPiao.Common.Communication.GtdJson.Packs
{
    public class A10002NotifyTicket:PackBase
    {
        public override string Action
        {
            get { return "notifyTicket"; }
        }

        private L_LotTicketEntity _ticket=new L_LotTicketEntity();
        public L_LotTicketEntity Ticket
        {
            get { return _ticket; }
            set { _ticket = value; }
        }

        public override void PackBody(Newtonsoft.Json.JsonWriter jsonWriter)
        {
            jsonWriter.WritePropertyName("expect");
            jsonWriter.WriteValue(Ticket.L_Expect);
            jsonWriter.WritePropertyName("lotId");
            jsonWriter.WriteValue(Ticket.LotId);
            jsonWriter.WritePropertyName("playtype");
            jsonWriter.WriteValue(Ticket.L_PlayId);
            jsonWriter.WritePropertyName("prntext");
            jsonWriter.WriteValue(Ticket.L_PrnText);
            jsonWriter.WritePropertyName("rate");
            jsonWriter.WriteValue(Ticket.L_CodeRate);
            jsonWriter.WritePropertyName("status");
            jsonWriter.WriteValue(Ticket.L_Status);
            jsonWriter.WritePropertyName("returntype");
            jsonWriter.WriteValue(Ticket.L_LimitType);
            jsonWriter.WritePropertyName("suctime");
            jsonWriter.WriteValue(Ticket.L_SucTime.ToString("yyyy-MM-dd HH:mm:ss"));
            jsonWriter.WritePropertyName("ticketcode");
            jsonWriter.WriteValue(Ticket.L_TicketCode);
            jsonWriter.WritePropertyName("ticketpw");
            jsonWriter.WriteValue(DesUtil.Encrypt(Ticket.L_Password));
            jsonWriter.WritePropertyName("ticketsn");
            jsonWriter.WriteValue(Ticket.L_TicketSn);
            jsonWriter.WritePropertyName("reference");
            jsonWriter.WriteValue(Ticket.L_CodeReference);
            jsonWriter.WritePropertyName("addtype");     //大乐透加奖类型：0-无加奖(默认)；1-1.6倍；2-2倍；3-“加油中国”3元；4-“光芒焕新”3元
            jsonWriter.WriteValue(Ticket.L_AddType);



            jsonWriter.WritePropertyName("addtext");     //大乐透加奖类型文本
            jsonWriter.WriteValue(Ticket.L_AddText);


            jsonWriter.WritePropertyName("code");
            jsonWriter.WriteValue(Ticket.L_Code);
            jsonWriter.WritePropertyName("codetype");
            jsonWriter.WriteValue(Ticket.L_CodeType);
            jsonWriter.WritePropertyName("money");
            jsonWriter.WriteValue(Ticket.L_Money);
            jsonWriter.WritePropertyName("multiple");
            jsonWriter.WriteValue(Ticket.L_Mutiple);

            if (!string.IsNullOrEmpty(fromtype)) {
                jsonWriter.WritePropertyName("fromtype");
                jsonWriter.WriteValue(fromtype);
            }
        }

        public string fromtype = "";


        public void asBackDataCom()
        {
            fromtype = "2";
            //fromtype：电子票来源（1：盒子；2：串口）
        }
    }
}
