public bool addToOrder(transactionClass trans)
        {
            OOrder order = new OOrder
            {
                Client_ID       = trans.clientId,
                Payment_Id      = trans.PaymentId,
                Delivery_Id     = trans.DeliveryID,
                OrderNumber     = trans.OrderNumber,
                OrderDate       = trans.OrderDate,
                ShipDate        = trans.ShipDate,
                Tax             = Convert.ToDecimal(trans.tax),
                Delivery_Status = trans.DeliveryStatus,
                Payment_Status  = trans.PayemntStatus,
                Payment_Date    = trans.PaymentDate
            };

            db.OOrders.InsertOnSubmit(order);
            try
            {
                db.SubmitChanges();
                return(true);
            }catch (Exception ex)
            {
                ex.GetBaseException();
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 添加订单
        /// </summary>
        public void AddOrder(string oorderInfo, string websiteOwner)
        {
            OOrder          oorder    = ZentCloud.Common.JSONHelper.JsonToModel <OOrder>(oorderInfo);
            WXMallOrderInfo mallOrder = bllMall.Get <WXMallOrderInfo>(string.Format(" WebsiteOwner='{0}' AND OutOrderId='{1}'", websiteOwner, oorder.orderId));

            if (mallOrder == null)
            {
                mallOrder = new WXMallOrderInfo();
                ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZentCloud.ZCBLLEngine.BLLTransaction();
                mallOrder.OrderID      = bllMall.GetGUID(ZentCloud.BLLJIMP.TransacType.AddMallOrder);
                mallOrder.OutOrderId   = oorder.orderId;
                mallOrder.Address      = oorder.address;
                mallOrder.OrderType    = 8;
                mallOrder.WebsiteOwner = websiteOwner;
                mallOrder.TakeOutType  = "Eleme";
                mallOrder.OrderMemo    = oorder.description;
                if (!string.IsNullOrEmpty(oorder.createdAt))
                {
                    mallOrder.InsertDate = GetDate(oorder.createdAt);
                }
                if (!string.IsNullOrEmpty(oorder.activeAt))
                {
                    mallOrder.PayTime = GetDate(oorder.activeAt);
                }
                if (oorder.deliverFee.HasValue)
                {
                    mallOrder.Transport_Fee = (decimal)oorder.deliverFee;
                }
                if (!string.IsNullOrEmpty(oorder.deliverTime))
                {
                    mallOrder.Ex2 = GetDate(oorder.deliverTime).ToString();
                }
                mallOrder.Ex3 = oorder.invoice;
                mallOrder.Ex4 = oorder.book.ToString();
                mallOrder.Ex5 = oorder.onlinePaid.ToString();
                List <string> phoneList = oorder.phoneList;
                if (phoneList.Count > 0)
                {
                    for (int i = 0; i < phoneList.Count; i++)
                    {
                        if (i == 0)
                        {
                            mallOrder.Phone = phoneList[i];
                        }
                        mallOrder.Ex6 += phoneList[i] + ",";
                    }
                    mallOrder.Ex6 = mallOrder.Ex6.Remove(mallOrder.Ex6.Length - 1, 1);
                }
                mallOrder.Ex7         = oorder.shopId.ToString();
                mallOrder.Ex9         = oorder.shopName;
                mallOrder.OrderUserID = oorder.userId.ToString();
                if (oorder.totalPrice.HasValue)
                {
                    mallOrder.TotalAmount = (decimal)oorder.totalPrice;
                }
                if (oorder.originalPrice.HasValue)
                {
                    mallOrder.Ex10 = oorder.originalPrice.ToString();
                }
                mallOrder.Consignee = oorder.consignee;
                mallOrder.Ex11      = oorder.deliveryGeo;
                mallOrder.Ex12      = oorder.deliveryPoiAddress;
                mallOrder.Ex13      = oorder.invoiced.ToString();
                if (oorder.income.HasValue)
                {
                    mallOrder.Ex14 = oorder.income.ToString();
                }
                if (oorder.serviceRate.HasValue)
                {
                    mallOrder.Ex15 = oorder.serviceRate.ToString();
                }
                if (oorder.serviceFee.HasValue)
                {
                    mallOrder.Ex16 = oorder.serviceFee.ToString();
                }
                if (oorder.hongbao.HasValue)
                {
                    mallOrder.Ex17 = oorder.hongbao.ToString();
                }
                if (oorder.packageFee.HasValue)
                {
                    mallOrder.Ex18 = oorder.packageFee.ToString();
                }
                if (oorder.activityTotal.HasValue)
                {
                    mallOrder.Ex19 = oorder.activityTotal.ToString();
                }
                if (oorder.shopPart.HasValue)
                {
                    mallOrder.Ex20 = oorder.shopPart.ToString();
                }
                if (oorder.elemePart.HasValue)
                {
                    mallOrder.Ex21 = oorder.elemePart.ToString();
                }
                if (mallOrder.TotalAmount > 0)
                {
                    mallOrder.PaymentStatus = 1;
                }
                mallOrder.Ex22            = oorder.downgraded.ToString();
                mallOrder.OutOrderStatus  = GetOrderStatus(oorder.status);
                mallOrder.Status          = "待发货";
                mallOrder.OutRefundStatus = GetRefStatus(oorder.refundStatus);
                mallOrder.Ex8             = oorder.openId;
                if (oorder.vipDeliveryFeeDiscount.HasValue)
                {
                    mallOrder.Ex10 = oorder.vipDeliveryFeeDiscount.ToString();
                }
                if (!bllWebsite.Add(mallOrder, tran))
                {
                    tran.Rollback();
                    resp.msg = "添加订单出错";
                    Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
                List <OGoodsGroup> goodsGroupList = oorder.groups;
                foreach (var item in goodsGroupList)
                {
                    WXMallOrderDetailsInfo oorderDetail = new WXMallOrderDetailsInfo();
                    oorderDetail.Ex1     = item.name;
                    oorderDetail.Ex2     = item.type;
                    oorderDetail.OrderID = mallOrder.OrderID;
                    List <OGoodsItem> goodItems = item.items;
                    foreach (var good in goodItems)
                    {
                        oorderDetail.PID         = good.id.ToString();
                        oorderDetail.Ex3         = good.id.ToString();
                        oorderDetail.Ex9         = good.skuId.ToString();
                        oorderDetail.ProductName = good.name;
                        oorderDetail.Ex4         = good.categoryId.ToString();
                        if (good.price.HasValue)
                        {
                            oorderDetail.OrderPrice = (decimal)good.price;
                        }
                        oorderDetail.TotalCount = good.quantity;
                        if (good.total.HasValue)
                        {
                            oorderDetail.TotalPrice = (decimal)good.total;
                        }
                        oorderDetail.Ex7 = good.extendCode;
                        oorderDetail.Ex8 = good.barCode;
                        if (good.userPrice.HasValue)
                        {
                            oorderDetail.Ex10 = good.userPrice.ToString();
                        }
                        if (good.shopPrice.HasValue)
                        {
                            oorderDetail.Ex11 = good.shopPrice.ToString();
                        }
                        if (good.weight.HasValue)
                        {
                            oorderDetail.Wegith = (decimal)good.weight;
                        }
                        oorderDetail.Unit = "元";
                        if (good.newSpecs != null)
                        {
                            List <OGroupItemSpec> specList = good.newSpecs;
                            oorderDetail.Ex5 = ZentCloud.Common.JSONHelper.ListToJson <OGroupItemSpec>(specList);
                        }
                        if (good.attributes != null)
                        {
                            List <OGroupItemAttribute> attrList = good.attributes;
                            oorderDetail.Ex6 = ZentCloud.Common.JSONHelper.ListToJson <OGroupItemAttribute>(attrList);
                        }
                        if (!bllWebsite.Add(oorderDetail, tran))
                        {
                            tran.Rollback();
                            resp.msg = "添加商品出错";
                            Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                            return;
                        }
                    }
                }
                tran.Commit();
            }
        }