using System;
using MySystem.MpMainModels2;
using System.Linq;

namespace MySystem
{
    public class OrderMessageHelper
    {
        public static void SendOrderMsg(ConsumerOrders order)
        {
            WebCMSEntities db = new WebCMSEntities();
            MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
            OrderMessage msg = new OrderMessage()
            {
                brandId = merchant.BrandId + 1, //品牌/通道（0直联，1银联，2好哒）
                status = order.Status, //订单状态（0待支付，1已支付）
                createDate = order.CreateDate.Value, //创建时间
                payDate = order.UpdateDate.Value, //支付时间
                hdOrderNo = order.SeoTitle, //好哒订单号
                tradeNo = order.SeoKeyword, //支付宝微信平台交易号
                snNo = order.SnNo, //码牌SN
                payMoney = order.PayMoney, //支付金额
                payMode = order.PayMode, //支付方式（1支付宝，2微信）
                orderNo = order.OrderNo, //订单号
                consumerId = order.ConsumerId, //消费者Id
                merchantId = order.MerchantId, //商户Id
                isAct = (int)order.IsAct, //活动标识（1活动，0非活动）
                userId = order.UserId, //创客Id
                merchantActualAmount = order.MerchantActualAmount, //商家实收金额
            };
            db.Dispose();

            MpRedisDbconn.Instance.AddList("MpOrderQueue", Newtonsoft.Json.JsonConvert.SerializeObject(msg));
        }
    }
}