コード例 #1
0
        public void ToOrder(int totalprice, int remain, int cartId)
        {
            CMember member = (CMember)Session[CMemberSession.Session_Login_User];//會員
            COrder  o      = new COrder();

            o.fPurchaseDate = DateTime.UtcNow.AddHours(08);
            o.fTotalPrice   = totalprice;
            o.fMemberId     = member.fMemberId;
            COrderFactory.fn訂單新增(o);

            CMemberFactory.fn會員更新點數(member, remain);

            CNotice c = new CNotice();

            c.fCategoryType   = "系統";
            c.fLink           = "超連結";
            c.fNoticeDatetime = DateTime.UtcNow.AddHours(08);
            c.fMemberId       = member.fMemberId;
            c.fNoticeContent  = "您的訂單已完成了";
            CNoticeFactory.fn通知訂單訊息新增(c);

            List <CCartProduct> CP = CCartProductFactory.fn購物車商品個人查詢(cartId).ToList();

            var f = CNoteFolderFactory.fn筆記資料夾查詢(member).Where(q => q.fFolderName == "未分類筆記").ToList();

            int orderid = COrderFactory.fn訂單查詢(member).LastOrDefault().fOrderId;

            foreach (var a in CP)
            {
                CDetailOrderFactory.fn訂單明細新增(orderid, a.fProductId);
                CNotice c1 = new CNotice();
                c1.fCategoryType   = "銷售";
                c1.fLink           = "超連結";
                c1.fNoticeDatetime = DateTime.UtcNow.AddHours(08);
                c1.fMemberId       = a.fMemberSellerId;
                c1.fNoticeContent  = "您的" + a.fName + "已被購買";
                CNoticeFactory.fn通知訂單訊息新增(c1);

                CIncome i1 = new CIncome();
                i1.fIncome          = a.fPrice;
                i1.fPaymentDateTime = DateTime.UtcNow.AddHours(08);
                i1.fIncomeCategory  = "獲利";
                i1.fMemberId        = a.fMemberSellerId;
                CIncomeFactory.fn公司獲利新增(i1);

                var     point  = CMemberFactory.fn會員查詢().Where(z => z.fMemberId == a.fMemberSellerId);
                int     point1 = (point.Single().fMoneyPoint) + a.fPrice;
                CMember cm1    = new CMember();
                cm1.fMemberId = point.Single().fMemberId;
                CMemberFactory.fn會員更新點數(cm1, point1);

                var t = CNoteFactory.fn私人筆記全部查詢().Where(q => q.fFolderId == f.Single().fFolderId).ToList();

                int t1 = t.Count();

                CNote n = new CNote();
                n.fNoteListName     = a.fName;
                n.fCreateDateTime   = DateTime.UtcNow.AddHours(08);
                n.fEditDateTime     = DateTime.UtcNow.AddHours(08);
                n.fNoteListLevel    = t1;
                n.fIsMyFavourite    = false;
                n.fIsTrash          = false;
                n.fFolderId         = f.Single().fFolderId;
                n.fJsonContent      = a.fContent;
                n.fTheShareLink     = null;
                n.fTheContactPerson = null;
                n.fHTMLContent      = "";
                CNoteFactory.fn訂單私人筆記新增(n);
            }

            CCartFactory.fn購物車個人更新(cartId);
        }