Ejemplo n.º 1
0
 public bool userPaidOrder(salesslip paidOrder)
 {
     bool res = false;
     using (IDbConnection conn = DapperHelper.MySqlConnection())
     {
         IDbTransaction transaction = conn.BeginTransaction();
         try
         {
             string updateSalesSlipSQL = "update salesslip set receiver=@receiver,province=@province,city=@city,county=@county,detailAddress=@detailAddress,Phone=@Phone,amount=@amount,postage=@postage,payDate=@payDate,status=@status,column1=@column1,column2=@payDate where salesId=@salesId and salesNo=@salesNo and userOpenId = @userOpenId";
             string updateSales2ProductsSQL = "update sales2products a inner join products b on a.productid=b.productid  set a.originalPrice=b.originalPrice,a.discountedPrice=b.discountedPrice,a.nw=b.nw,a.status=@status where a.salesId = @salesId";
             conn.Execute(updateSalesSlipSQL, paidOrder, transaction).ToString();
             conn.Execute(updateSales2ProductsSQL, paidOrder, transaction).ToString();
             //提交事务
             transaction.Commit();
             res = true;
         }
         catch (Exception e)
         {
             //出现异常,事务Rollback
             transaction.Rollback();
             throw new Exception(e.Message);
         }
     }
     return res;
 }
Ejemplo n.º 2
0
        public JsonResult SelAddress(string receiver, string rPhone, string province, string city, string county, string detailAddress, string orderId)
        {
            string    userOpenId    = base.getUserOpenIdFromCookie();
            salesslip userSalesSlip = new salesslip();
            string    res           = "fail";

            try
            {
                userSalesSlip = OrderBiz.CreateNew().getCheckOutInfo(orderId, userOpenId);

                userSalesSlip.receiver      = receiver;
                userSalesSlip.province      = province;
                userSalesSlip.city          = city;
                userSalesSlip.county        = county;
                userSalesSlip.detailAddress = detailAddress;
                userSalesSlip.Phone         = rPhone;

                OrderBiz.CreateNew().userUpdateOrderAddress(userSalesSlip);
            }
            catch (Exception ex)
            {
                _Apilog.WriteLog("ProductsController/SelAddress 异常: " + userOpenId + " orderId: " + orderId + ex.Message);
            }
            return(Json(res));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 获取订单结算信息
 /// </summary>
 /// <param name="orderId">订单编号</param>
 /// <param name="userOpenId">用户微信OpenId</param>
 public salesslip getCheckOutInfo(string orderId, string userOpenId)
 {
     salesslip userSalesSlip = new salesslip();
     using (IDbConnection conn = DapperHelper.MySqlConnection())
     {
         string sqlCommandText = @"SELECT * FROM ganxian.salesslip where salesNo=@orderId and userOpenId=@userOpenId";
         userSalesSlip = conn.Query<salesslip>(sqlCommandText, new { orderId = orderId, userOpenId = userOpenId }).FirstOrDefault();
     }
     return userSalesSlip;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 订单管理页面
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        public ActionResult order(string orderNo, string createDate, string receiver, string expressNo, string status)
        {
            List <GanXian.Model.UserOrderListInfo> userOrderList = new List <GanXian.Model.UserOrderListInfo>();

            try
            {
                salesslip slipCondition = new salesslip();

                if (!string.IsNullOrEmpty(status) && status.ToLower() != "all")
                {
                    slipCondition.status = Convert.ToInt32(status);
                }
                if (!string.IsNullOrEmpty(orderNo))
                {
                    slipCondition.salesNo = orderNo.ToLower();
                }
                if (!string.IsNullOrEmpty(receiver))
                {
                    slipCondition.receiver = receiver.ToLower();
                }
                if (!string.IsNullOrEmpty(expressNo))
                {
                    slipCondition.expressNo = expressNo.ToLower();
                }
                if (!string.IsNullOrEmpty(createDate))
                {
                    slipCondition.createDate = Convert.ToDateTime(createDate);
                }

                userOrderList = OrderBiz.CreateNew().getOrderListInfoByCondition(slipCondition);
            }
            catch (Exception e)
            {
                _Apilog.WriteLog("AdminController order 异常:" + e.Message);
            }
            ViewBag.status     = status;
            ViewBag.orderNo    = orderNo;
            ViewBag.createDate = createDate;
            ViewBag.receiver   = receiver;
            ViewBag.expressNo  = expressNo;

            ViewBag.ProjectUrl = System.Configuration.ConfigurationSettings.AppSettings["projectUrl"];
            return(View(userOrderList));
        }
Ejemplo n.º 5
0
 public bool userUpdateOrderAddress(salesslip paidOrder)
 {
     bool res = false;
     using (IDbConnection conn = DapperHelper.MySqlConnection())
     {
         IDbTransaction transaction = conn.BeginTransaction();
         try
         {
             string updateSalesSlipSQL = "update salesslip set receiver=@receiver,province=@province,city=@city,county=@county,detailAddress=@detailAddress,Phone=@Phone where salesId=@salesId and salesNo=@salesNo and userOpenId = @userOpenId";
             conn.Execute(updateSalesSlipSQL, paidOrder, transaction).ToString();
             //提交事务
             transaction.Commit();
             res = true;
         }
         catch (Exception e)
         {
             //出现异常,事务Rollback
             transaction.Rollback();
             throw new Exception(e.Message);
         }
     }
     return res;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 根据条件获取订单信息
        /// </summary>
        /// <returns></returns>
        public List<UserOrderListInfo> getOrderListInfoByCondition(salesslip slipCondition)
        {
            List<UserOrderListInfo> userOrderList = new List<UserOrderListInfo>();
            List<UserShopcartsInfo> orderProductList = new List<UserShopcartsInfo>();
            using (IDbConnection conn = DapperHelper.MySqlConnection())
            {
                string sqlCondition = string.Empty;
                if (slipCondition.status != null)
                {
                    sqlCondition += " and  salesslip.status='" + slipCondition.status + "'";
                }
                if (!string.IsNullOrEmpty(slipCondition.salesNo))
                {
                    sqlCondition += " and  salesslip.salesNo like '%" + slipCondition.salesNo + "%'";
                }
                if (!string.IsNullOrEmpty(slipCondition.receiver))
                {
                    sqlCondition += " and  salesslip.receiver like '%" + slipCondition.receiver + "%'";
                }
                if (!string.IsNullOrEmpty(slipCondition.expressNo))
                {
                    sqlCondition += " and  salesslip.expressNo like '%" + slipCondition.expressNo + "%'";
                }
                if (slipCondition.createDate != null && slipCondition.createDate != default(DateTime))
                {
                    sqlCondition += " and  datediff(salesslip.createDate,'" + slipCondition.createDate + "')= 0";
                }

                string sqlCommandText = @"SELECT salesslip.*,users.nickname as orderName,users.phone as orderPhone
                                                FROM ganxian.salesslip 
                                                join ganxian.users on salesslip.userOpenId=users.openid
                                                where salesslip.status<>4 and salesslip.status<>6 " + sqlCondition + " order by salesslip.column2 desc, salesslip.salesid desc limit 1000";
                userOrderList = conn.Query<UserOrderListInfo>(sqlCommandText).ToList();

                foreach (var userOrder in userOrderList)
                {
                    //0未付款 1已付款待发货 2 已发货,待收货 3 已完成 4 已删除 5 预付款 6 已失效
                    #region 异常数据情况
                    if (userOrder.status == 5)
                    {
                        userOrder.status = dealExpectionOrder(userOrder.salesNo, userOrder.wechatOrderNo);
                    }
                    #endregion
                    #region status==0 未付款,已失效情况
                    if (userOrder.status == 0 || userOrder.status == 6)
                    {
                        //未付款订单30分钟后失效
                        if (userOrder.status == 0)
                        {
                            double mins = Convert.ToDouble(System.Configuration.ConfigurationSettings.AppSettings["orderExpiredMins"]);
                            if (DateTime.Now.AddMinutes(-mins) > userOrder.createDate)
                            {
                                string sqlCommandTextUpdateOrder = "update salesslip set status=6 ,column2=now() where salesId=@salesId";
                                conn.Execute(sqlCommandTextUpdateOrder, new { salesId = userOrder.salesId });
                                userOrder.status = 6;
                            }
                        }

                        decimal totalPrice = 0;//总价,未付款时需要关联产品表获取当前价格
                        string sqlCommandTextStatus0 = @"SELECT a.num ,b.* FROM ganxian.sales2products a 
                                            inner join products b on a.productid=b.productid
                                            where  b.status=1 and a.salesId=@salesId
                                            order by a.createDate desc";
                        var resStatus0 = conn.Query<UserShopcartsInfo>(sqlCommandTextStatus0, new { salesId = userOrder.salesId }).ToList();
                        if (resStatus0.Any())
                        {
                            resStatus0.ForEach(x => x.productTotalPrice = x.num * x.discountedPrice);
                            foreach (var item in resStatus0)
                            {
                                totalPrice += item.productTotalPrice ?? 0;
                                System.Reflection.PropertyInfo[] pro = item.GetType().GetProperties();
                                foreach (System.Reflection.PropertyInfo item2 in pro)
                                {
                                    if (item2.Name == item.showPic)
                                    {
                                        item.showPic = item2.GetValue(item).ToString();
                                    }
                                }
                            }
                        }
                        userOrder.Order2ProductsList = resStatus0;
                        userOrder.amount = totalPrice;
                        //userOrder.postage
                    }
                    #endregion
                    #region 显示订单处理
                    else if (userOrder.status == 0 || userOrder.status == 1 || userOrder.status == 2 || userOrder.status == 3 || userOrder.status == 7)
                    {
                        //已发货一周后变为已完成状态
                        if (userOrder.status == 2 && userOrder.deliveryDate != null)
                        {
                            if (DateTime.Now.AddDays(-7) > userOrder.deliveryDate)
                            {
                                string sqlCommandTextUpdateOrder = "update salesslip set status=3 ,column2=now() where salesId=@salesId";
                                conn.Execute(sqlCommandTextUpdateOrder, new { salesId = userOrder.salesId });
                                userOrder.status = 3;
                            }
                        }


                        string sqlCommandTextStatus123 = @"SELECT a.num ,b.`productId`,
                                                        b.`productName`,
                                                        b.`specs`,
                                                        a.`originalPrice`,
                                                        a.`discountedPrice`,
                                                        b.`discountedExpiredDate`,
                                                        b.`pic1`,
                                                        b.`pic2`,
                                                        b.`pic3`,
                                                        b.`pic4`,
                                                        b.`showPic`,
                                                        b.`origin`,
                                                        a.`nw`,
                                                        b.`storageCondition`,
                                                        b.`remark`,
                                                        b.`createDate`,
                                                        b.`status`,
                                                        b.`column1`,
                                                        b.`column2` FROM ganxian.sales2products a 
                                            inner join products b on a.productid=b.productid
                                            where a.salesId=@salesId
                                            order by a.createDate desc";
                        var resStatus123 = conn.Query<UserShopcartsInfo>(sqlCommandTextStatus123, new { salesId = userOrder.salesId }).ToList();
                        if (resStatus123.Any())
                        {
                            resStatus123.ForEach(x => x.productTotalPrice = x.num * x.discountedPrice);
                            foreach (var item in resStatus123)
                            {
                                System.Reflection.PropertyInfo[] pro = item.GetType().GetProperties();
                                foreach (System.Reflection.PropertyInfo item2 in pro)
                                {
                                    if (item2.Name == item.showPic)
                                    {
                                        try
                                        {
                                            item.showPic = item2.GetValue(item).ToString();
                                        }
                                        catch
                                        {
                                            continue;
                                        }
                                    }
                                }
                            }
                        }
                        userOrder.Order2ProductsList = resStatus123;
                    }
                    #endregion
                }
            }
            return userOrderList;
        }
Ejemplo n.º 7
0
        public JsonResult PayOrder(string receiver, string rPhone, string province, string city, string county, string detailAddress, string orderId, string toStatus)
        {
            string userOpenId = base.getUserOpenIdFromCookie();
            string res        = "fail";

            try
            {
                if (!string.IsNullOrEmpty(userOpenId) && !string.IsNullOrEmpty(orderId))
                {
                    _Orderlog.WriteLog(orderId + " | " + "用户: " + userOpenId + " 开始付款 | " + (int)EnumOrderLogType.normal);
                    salesslip   userSalesSlip = new salesslip();
                    useraddress userRes       = new useraddress();
                    List <UserShopcartsInfo> userUnpaidOrderInfo = new List <UserShopcartsInfo>();
                    decimal productsPrice = 0;
                    decimal postage       = 0;
                    decimal SFJZF         = Convert.ToDecimal(System.Configuration.ConfigurationSettings.AppSettings["sf:JZH"]);    //顺丰江浙沪快递费
                    decimal SFNonJZF      = Convert.ToDecimal(System.Configuration.ConfigurationSettings.AppSettings["sf:NonJZH"]); //顺丰非江浙沪快递费
                    userSalesSlip = OrderBiz.CreateNew().getCheckOutInfo(orderId, userOpenId);
                    if (userSalesSlip == null)                                                                                      //查不到销售单
                    {
                        res = "订单不存在";                                                                                              //查不到销售单,跳转至订单列表页面
                    }
                    else if (userSalesSlip.status == 0)                                                                             //0未付款 1已付款待发货 2 已发货,待收货 3 已完成 4 已删除 5 预付款 6 已过期
                    {
                        if (DateTime.Now.AddMinutes(-orderExpiredMins) > userSalesSlip.createDate)                                  //订单已失效,为了减少数据库操作,这边做跳转;
                        {
                            res = "订单已过期";                                                                                          //前端页面会做跳转,数据更新部分统一放到了订单列表
                        }
                        else
                        {
                            #region 邮费计算
                            if (!string.IsNullOrEmpty(province))
                            {
                                if (province.IndexOf("上海") >= 0 ||
                                    province.IndexOf("江苏") >= 0 ||
                                    province.IndexOf("浙江") >= 0)
                                {
                                    postage = SFJZF;
                                }
                                else
                                {
                                    postage = SFNonJZF;
                                }
                            }
                            #endregion
                            #region 订单产品部分
                            userUnpaidOrderInfo = OrderBiz.CreateNew().getUnpaidOrderInfo(userSalesSlip.salesId);

                            foreach (var i in userUnpaidOrderInfo)
                            {
                                productsPrice += i.productTotalPrice ?? 0;
                            }
                            #endregion

                            #region 更新记录
                            salesslip newOrder = new salesslip();
                            newOrder.salesId       = userSalesSlip.salesId;
                            newOrder.salesNo       = orderId;
                            newOrder.userOpenId    = userOpenId;
                            newOrder.receiver      = receiver;
                            newOrder.province      = province;
                            newOrder.city          = city;
                            newOrder.county        = county;
                            newOrder.detailAddress = detailAddress;
                            newOrder.Phone         = rPhone;
                            newOrder.amount        = productsPrice;
                            newOrder.postage       = postage;
                            newOrder.payDate       = System.DateTime.Now;
                            newOrder.status        = 5;//预付款  实际付款后会再更新成1

                            string remark = Newtonsoft.Json.JsonConvert.SerializeObject(userUnpaidOrderInfo);
                            newOrder.column1 = remark;

                            if (OrderBiz.CreateNew().userPaidOrder(newOrder))
                            {
                                _Orderlog.WriteLog(orderId + " | " + "用户预支付成功,订单: " + Newtonsoft.Json.JsonConvert.SerializeObject(newOrder) + "详情: " + remark + "| " + (int)EnumOrderLogType.normal);
                                res = "success";
                            }
                            else
                            {
                                _Orderlog.WriteLog(orderId + " | " + "用户预支付失败!,订单: " + Newtonsoft.Json.JsonConvert.SerializeObject(newOrder) + "详情: " + remark + "| " + (int)EnumOrderLogType.fail);
                                res = "付款失败";
                            }
                            #endregion
                        }
                    }
                    else if (userSalesSlip.status == 5)
                    {
                        userSalesSlip.status = Convert.ToInt32(toStatus);
                        if (Convert.ToInt32(toStatus) == 0)
                        {
                            userSalesSlip.payDate = null;
                        }

                        string remark = Newtonsoft.Json.JsonConvert.SerializeObject(userSalesSlip);
                        if (OrderBiz.CreateNew().userPaidOrder(userSalesSlip))
                        {
                            _Orderlog.WriteLog(orderId + " | " + "用户订单状态更新成功,订单: " + Newtonsoft.Json.JsonConvert.SerializeObject(userSalesSlip) + "详情: " + remark + "| " + (int)EnumOrderLogType.normal);
                            res = "success";// "用户订单状态更新成功";
                        }
                        else
                        {
                            _Orderlog.WriteLog(orderId + " | " + "用户订单状态更新失败!,订单: " + Newtonsoft.Json.JsonConvert.SerializeObject(userSalesSlip) + "详情: " + remark + "| " + (int)EnumOrderLogType.fail);
                            res = "用户订单状态更新失败";
                        }
                    }
                    else//订单状态不为 未付款,需要跳转到对应页面
                    {
                        res = "订单已支付";
                    }
                }
                else
                {
                    _Apilog.WriteLog("ProductsController/PayOrder 用户userOpenId 或 orderId 为空, 用户userOpenId: " + userOpenId + " orderId: " + orderId);
                    _Orderlog.WriteLog(orderId + " | " + "用户userOpenId 或 orderId 为空, 用户userOpenId: " + userOpenId + " orderId: " + orderId + "| " + (int)EnumOrderLogType.fail);
                }
            }
            catch (Exception e)
            {
                _Apilog.WriteLog("ProductsController/PayOrder 异常: " + userOpenId + " orderId: " + orderId + e.Message);
                _Orderlog.WriteLog(orderId + " | " + "支付异常: " + e.Message + e.Source + "| " + (int)EnumOrderLogType.error);
            }
            return(Json(res));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 结算页面
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public ActionResult Checkout(string orderId, string code)
        {
            #region 用户信息部分
            string userOpenId             = string.Empty;
            Tuple <string, string> result = base.getUserOpenId(code);
            if (!string.IsNullOrEmpty(result.Item1))
            {
                userOpenId = result.Item1;
            }
            else if (!string.IsNullOrEmpty(result.Item2))
            {
                return(Redirect(result.Item2));
            }
            ViewBag.userOpenId = userOpenId;
            #endregion

            if (string.IsNullOrEmpty(orderId) || string.IsNullOrEmpty(userOpenId))
            {
                return(RedirectToAction("OrderList", "Order"));
            }

            #region 绑定手机部分
            //用户未点击跳过注册 并且电话为空
            users res      = new users();
            var   resCache = CacheHelper.GetCache("userInfo" + userOpenId);
            if (resCache != null)
            {
                res = (users)resCache;
            }
            else
            {
                res = UserBiz.CreateNew().getUserInfoByOpenId(userOpenId);
                if (res == null)
                {
                    return(RedirectToAction("Register", "User", new { needRegister = "1", fromUrl = Request.RawUrl }));//跳转到注册页面,且必须注册
                }
                else
                {
                    var      start       = DateTime.Now;
                    var      expiredDate = start.AddDays(1);
                    TimeSpan ts          = expiredDate - start;
                    CacheHelper.SetCache("userInfo" + res.openid.ToString(), res, ts);
                    if (!string.IsNullOrEmpty(res.openid))
                    {
                        CookieHelper.SetCookie("userOpenId", res.openid);
                    }
                }
            }

            if (string.IsNullOrEmpty(res.phone))
            {
                return(RedirectToAction("Register", "User", new { needRegister = "1", fromUrl = Request.RawUrl }));//跳转到注册页面,且必须注册
            }
            #endregion

            CheckOutModels           checkOutModels      = new CheckOutModels();
            useraddress              userRes             = new useraddress();
            List <UserShopcartsInfo> userUnpaidOrderInfo = new List <UserShopcartsInfo>();
            salesslip userSalesSlip = new salesslip();

            decimal productsPrice = 0;
            decimal postage       = 0;
            decimal SFJZF         = Convert.ToDecimal(System.Configuration.ConfigurationSettings.AppSettings["sf:JZH"]);    //顺丰江浙沪快递费
            decimal SFNonJZF      = Convert.ToDecimal(System.Configuration.ConfigurationSettings.AppSettings["sf:NonJZH"]); //顺丰非江浙沪快递费

            string wechatBody = string.Empty;
            userSalesSlip = OrderBiz.CreateNew().getCheckOutInfo(orderId, userOpenId);
            if (userSalesSlip == null)                          //查不到销售单
            {
                return(RedirectToAction("OrderList", "Order")); //查不到销售单,跳转至订单列表页面
            }
            else if (userSalesSlip.status == 5)
            {
                userSalesSlip.status = OrderBiz.CreateNew().dealExpectionOrder(userSalesSlip.salesNo, userSalesSlip.wechatOrderNo);
            }
            if (userSalesSlip.status == 0)                                                 //0未付款 1已付款待发货 2 已发货,待收货 3 已完成 4 已删除 5 预付款 6 已过期
            {
                if (DateTime.Now.AddMinutes(-orderExpiredMins) > userSalesSlip.createDate) //订单已失效,为了减少数据库操作,这边做跳转;
                {
                    return(RedirectToAction("OrderList", "Order", new { status = "all" }));
                }

                #region 用户收货地址部分
                if (!string.IsNullOrEmpty(userSalesSlip.province) && !string.IsNullOrEmpty(userSalesSlip.receiver)) //先看该订单用户是否已经设置收货地址,没有设置过则读取默认地址,还没有则为空
                {
                    userRes.receiver      = userSalesSlip.receiver;
                    userRes.Phone         = userSalesSlip.Phone;
                    userRes.province      = userSalesSlip.province;
                    userRes.city          = userSalesSlip.city;
                    userRes.county        = userSalesSlip.county;
                    userRes.detailAddress = userSalesSlip.detailAddress;
                }
                else
                {
                    var userAddressList = UserBiz.CreateNew().getUserAddressList(userOpenId);
                    if (userAddressList.Any())
                    {
                        userRes = userAddressList.Find(x => x.SetAsDefault == "1");
                    }
                    if (userRes == null)
                    {
                        userRes          = new useraddress();
                        userRes.receiver = userRes.Phone = userRes.province = userRes.city = userRes.county = userRes.detailAddress = "";
                    }
                }
                if (!string.IsNullOrEmpty(userRes.province))
                {
                    if (userRes.province.IndexOf("上海") >= 0 ||
                        userRes.province.IndexOf("江苏") >= 0 ||
                        userRes.province.IndexOf("浙江") >= 0 ||
                        userRes.province.IndexOf("安徽") >= 0)
                    {
                        postage = SFJZF;
                    }
                    else
                    {
                        postage = SFNonJZF;
                    }
                }

                #endregion

                #region 订单产品部分
                OrderBiz orderBiz = OrderBiz.CreateNew();
                userUnpaidOrderInfo          = orderBiz.getUnpaidOrderInfo(userSalesSlip.salesId);
                checkOutModels.UserOrderInfo = userUnpaidOrderInfo;

                foreach (var i in userUnpaidOrderInfo)
                {
                    try
                    {
                        orderBiz.updateOrder2ProductLogField(i.productId, i.id);
                    }
                    catch (Exception ex)
                    {
                        _Apilog.WriteLog("ProductsController/Checkout更新订单logid异常" + ex.Message);
                    }
                    wechatBody    += i.productName + "*" + i.num.ToString() + ";";
                    productsPrice += i.productTotalPrice ?? 0;
                }
                #endregion
            }
            else//订单状态不为 未付款,需要跳转到对应页面
            {
                return(RedirectToAction("OrderList", "Order", new { status = userSalesSlip.status }));
            }

            decimal factPrice   = 0;
            decimal factPostage = 0;
            if (Convert.IsDBNull(userSalesSlip.adminChangeAmount) || userSalesSlip.adminChangeAmount == null)
            {
                factPrice = productsPrice;
            }
            else
            {
                factPrice = userSalesSlip.adminChangeAmount ?? 1;
            }

            if (Convert.IsDBNull(userSalesSlip.adminChangePostage) || userSalesSlip.adminChangePostage == null)
            {
                factPostage = postage;
            }
            else
            {
                factPostage = userSalesSlip.adminChangePostage ?? 1;
            }

            //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数
            JsApiPay jsApiPay = new JsApiPay();
            jsApiPay.openid    = userOpenId;
            jsApiPay.total_fee = base.isPayTest == "false" ? decimal.ToInt32(factPrice * 100 + factPostage * 100) : 1;//测试环境默认支付1分

            //JSAPI支付预处理
            try
            {
                string wechatOrderId = Guid.NewGuid().ToString("N").ToLower();
                OrderBiz.CreateNew().updateWechatOrderId(orderId, userOpenId, wechatOrderId);

                WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(wechatBody, wechatOrderId); //orderId
                ViewBag.wxJsApiParam = jsApiPay.GetJsApiParameters();                                     //获取H5调起JS API参数
                _Apilog.WriteLog("ProductsController/Checkout 用户userOpenId: " + userOpenId + " wxJsApiParam : " + ViewBag.wxJsApiParam);
                //Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam);
                //在页面上显示订单信息
            }
            catch (Exception ex)
            {
                _Apilog.WriteLog("ProductsController/Checkout下单失败" + ex.Message);
            }



            //_Apilog.WriteLog(orderId);
            ViewBag.productsPrice      = productsPrice;
            ViewBag.postage            = postage;
            ViewBag.totalCost          = factPrice + factPostage;//productsPrice + postage;
            ViewBag.FooterType         = "custom";
            ViewBag.PageName           = "结算";
            ViewBag.ProjectUrl         = base.projectURL;
            ViewBag.adminChangeAmount  = userSalesSlip.adminChangeAmount;
            ViewBag.adminChangePostage = userSalesSlip.adminChangePostage;
            checkOutModels.UserAddress = userRes;
            return(View(checkOutModels));
        }