public ActionResult SubmitOrder()
        {
            var status = false;
            var openid = CommonMethod.getCookie("openid");
            var userid = CommonMethod.getCookie("userid");

            if (string.IsNullOrEmpty(userid) || string.IsNullOrEmpty(openid))
            {
                return(this.JsonFormat(status, status, "对不起,请登陆系统!"));
            }


            string orderNum          = CommonMethod.GetOrderNum(); //订单号
            string ThingNum          = Request.Form["thingNum"];   //CommonMethod.GetCode(18);//流水号;
            string thingName         = Request.Form["thingName"];
            string sid               = Request.Form["sid"];
            string suppliername      = Request.Form["suppliername"];
            string uname             = Request.Form["uname"];
            string mobile            = Request.Form["mobile"];
            string currentselectdate = Request.Form["selectdate"];
            string currentselecttime = Request.Form["selecttime"];
            string thingPrice        = Request.Form["thingPrice"];      //总金额
            string thingFrontPrice   = Request.Form["thingFrontPrice"]; //预付
            string supplieraddress   = Request.Form["supplieraddress"]; //地址Id
            string trade_type        = "JSAPI";
            var    order             = new VIEW_TG_order();

            order.orderNum      = orderNum;
            order.ThingNum      = ThingNum;
            order.remark1       = thingName;
            order.userOpenId    = openid;
            order.UserId        = userid;
            order.userName      = uname;
            order.UserTel       = mobile;
            order.UserAddress   = supplieraddress;
            order.remark2       = suppliername;
            order.remark3       = sid;
            order.total_fee     = TypeParser.ToDecimal(thingPrice);
            order.yunPrice      = TypeParser.ToDecimal(thingFrontPrice);
            order.remark4       = currentselectdate;
            order.remark5       = currentselecttime;
            order.trade_type    = trade_type;
            order.years         = DateTime.Now.Year;
            order.months        = DateTime.Now.Month;
            order.ispay         = 0;
            order.ssh_status    = 0;
            order.orderTime     = DateTime.Now;
            order.SYNCFLAG      = "N";
            order.SYNCOPERATION = "A";
            order.SYNCVERSION   = DateTime.Now;
            order.VERSION       = 1;
            orderB.Add(VIEW_TG_order.ToEntity(order));
            status = true;
            var user = weiUserM.GetModelWithOutTrace(u => u.openid == openid);

            if (user != null)
            {
                user.RelName = uname;
                user.userTel = mobile;
                weiUserM.Modify(user, "RelName", "userTel");
            }
            //  string order_sql = "insert into TG_order(flat2,trade_type,orderNum,ThingNum,total_fee,yunPrice,fenxiaoId,UserId,userOpenId,userName,UserTel,UserAddress,UserPostNum,orderTime,remark4,ispay,years,months) values(" + zengsongJifen + ",'" + trade_type + "','" + orderNum + "','" + ThingNum + "'," + total_fee + "," + YunFei + "," + fenxiaoId + "," + userid + ",'" + openid + "','" + userName + "','" + UserTel + "','" + UserAddress + "','" + UserPostNum + "','" + DateTime.Now + "','" + remark4 + "',0," + DateTime.Now.Year + "," + DateTime.Now.Month + ")";
            //string thing_sql = "insert into TG_Thing(UserId,openId,ThingNum,orderNum,productId,productCount,productPrice,productMoney,createTim,ispay,remark4) values(" + userid + ",'" + openid + "','" + ThingNum + "','" + orderNum + "'," + pid + "," + productCount + "," + proprice + "," + (productCount * proprice) + ",'" + DateTime.Now + "',0,'" + proColor + "')";
            //string car_sql = "delete from TG_car where Pid=" + pid + " and (UserOpenId='" + openid + "' or UserId=" + userid + ")";

            return(this.JsonFormat(status, status, "/aoshacar/payorder.aspx?orderid=" + orderNum));
        }
Beispiel #2
0
        public ActionResult Add(VIEW_TG_order model)
        {
            bool status = false;

            if (!ModelState.IsValid)
            {
                return(this.JsonFormat(ModelState, status, "ERROR"));
            }
            if (model.total_fee <= 0)
            {
                return(this.JsonFormat("SYSERROR", status, "订单的金额不正确"));
            }
            try
            {
                var user = userB.Get(u => u.userNum == model.UserId);
                if (user != null)
                {
                    model.userName   = user.userRelname;
                    model.userOpenId = user.openid;
                    model.UserTel    = user.userTel;
                }
                var supplierid = TypeParser.ToInt32(model.remark3);
                var company    = supplierB.Get(u => u.SUPPLIER_ID == supplierid);
                if (company != null)
                {
                    model.remark2     = company.SUPPLIER_NAME;
                    model.UserAddress = company.ADDRESS;
                }
                List <VIEW_TG_Thing> things       = new List <VIEW_TG_Thing>();
                string[]             productID    = Request.Form.GetValues("productID");
                string[]             productName  = Request.Form.GetValues("productName");
                string[]             productCount = Request.Form.GetValues("productCount");
                string[]             productPrice = Request.Form.GetValues("productPrice");
                string[]             productMoney = Request.Form.GetValues("productMoney");
                if (productID != null)
                {
                    for (int i = 0; i < productID.Length; i++)
                    {
                        VIEW_TG_Thing item = new VIEW_TG_Thing();
                        item.orderNum     = model.orderNum;
                        item.ispay        = model.ispay;
                        item.ThingNum     = model.ThingNum;
                        item.UserId       = model.UserId;
                        item.openId       = model.userOpenId;
                        item.productId    = productID[i];
                        item.remark1      = productName[i];
                        item.productCount = TypeParser.ToInt32(productCount[i]);
                        item.productPrice = TypeParser.ToDecimal(productPrice[i]);
                        item.productMoney = TypeParser.ToDecimal(productMoney[i]);
                        item.createTim    = DateTime.Now;
                        things.Add(item);
                    }
                }

                model.ispay         = 0;
                model.ssh_status    = 0;
                model.orderTime     = DateTime.Now;
                model.SYNCFLAG      = "N";
                model.SYNCOPERATION = "A";
                model.SYNCVERSION   = DateTime.Now;
                model.VERSION       = 1;
                orderB.Add(VIEW_TG_order.ToEntity(model));
                foreach (var item in things)
                {
                    thingB.Add(VIEW_TG_Thing.ToEntity(item));
                }
                status = true;
            }
            catch (Exception e)
            {
                return(this.JsonFormat(status, status, SysOperate.Add));
            }
            return(this.JsonFormat("/Admin/Order/OrderDetail?ordernum=" + model.orderNum, status, SysOperate.Add.ToMessage(status), status));
        }