Esempio n. 1
0
        public ActionResult productJsApi(int?id, string host)
        {
            TelphoneLiangH5Entity entity = tlbll.GetEntity(id);
            var sp_billno = string.Format("{0}{1}", "LX-", DateTime.Now.ToString("yyyyMMddHHmmss"));
            var openId    = (string)Session["OpenId"];
            var nonceStr  = TenPayV3Util.GetNoncestr();
            var timeStamp = TenPayV3Util.GetTimestamp();

            //商品Id,用户自行定义
            var xmlDataInfoH5 = new TenPayV3UnifiedorderRequestData(WeixinConfig.AppID2, tenPayV3Info.MchId, "JSAPI购买靓号", sp_billno,
                                                                    Convert.ToInt32(Convert.ToDecimal(entity.Price) * 100),
                                                                    Request.UserHostAddress, tenPayV3Info.TenPayV3Notify, TenPayV3Type.JSAPI, openId, tenPayV3Info.Key, nonceStr);
            var result = TenPayV3.Unifiedorder(xmlDataInfoH5); //调用统一订单接口

            LogHelper.AddLog(result.ResultXml);                //记录日志
            var package = string.Format("prepay_id={0}", result.prepay_id);

            if (result.return_code == "SUCCESS")
            {
                WFTWxModel jsApiPayData = new WFTWxModel()
                {
                    appId        = WeixinConfig.AppID2,
                    timeStamp    = timeStamp,
                    nonceStr     = nonceStr,
                    package      = package,
                    paySign      = TenPayV3.GetJsPaySign(WeixinConfig.AppID2, timeStamp, nonceStr, package, WeixinConfig.Key),
                    callback_url = "https://shop.jnlxsm.net/webapp/jinan2/paymentFinish/" + id
                };
                ViewBag.WxModel = jsApiPayData;
                LogHelper.AddLog(JsonConvert.SerializeObject(jsApiPayData));//记录日志
            }
            ViewBag.OrderSn = sp_billno;
            ViewBag.Host    = host;
            return(View(entity));
        }
Esempio n. 2
0
        public ActionResult JsApi(int?id, string Tel, string Price, string host)
        {
            OrdersEntity ordersEntity = new OrdersEntity()
            {
                TelphoneID = id,
                Tel        = Tel,
                Price      = Convert.ToDecimal(Price),
                Host       = host,
                PayType    = "JsApi"
            };

            //创建订单表
            ordersEntity = ordersbll.SaveForm(ordersEntity);

            var openId    = (string)Session["OpenId"];
            var sp_billno = ordersEntity.OrderSn;
            var nonceStr  = TenPayV3Util.GetNoncestr();
            var timeStamp = TenPayV3Util.GetTimestamp();

            //商品Id,用户自行定义
            var xmlDataInfoH5 = new TenPayV3UnifiedorderRequestData(WeixinConfig.AppID2, tenPayV3Info.MchId, "JSAPI购买靓号", sp_billno,
                                                                    Convert.ToInt32(ordersEntity.Price * 100),
                                                                    Request.UserHostAddress, tenPayV3Info.TenPayV3Notify, TenPayV3Type.JSAPI, openId, tenPayV3Info.Key, nonceStr);
            var result = TenPayV3.Unifiedorder(xmlDataInfoH5); //调用统一订单接口

            LogHelper.AddLog(result.ResultXml);                //记录日志
            var package = string.Format("prepay_id={0}", result.prepay_id);

            if (result.return_code == "SUCCESS")
            {
                WFTWxModel jsApiPayData = new WFTWxModel()
                {
                    appId        = WeixinConfig.AppID2,
                    timeStamp    = timeStamp,
                    nonceStr     = nonceStr,
                    package      = package,
                    paySign      = TenPayV3.GetJsPaySign(WeixinConfig.AppID2, timeStamp, nonceStr, package, WeixinConfig.Key),
                    callback_url = "https://shop.jnlxsm.net/webapp/jinan2/paymentFinish/" + ordersEntity.Id
                };
                ViewBag.WxModel = jsApiPayData;
                LogHelper.AddLog(JsonConvert.SerializeObject(jsApiPayData));//记录日志
            }
            return(View(ordersEntity));
        }
Esempio n. 3
0
        public ActionResult pay(string orderno)
        {
            var ordersEntity = ordersbll.GetEntityByOrderSn(orderno);

            if (ordersEntity != null)
            {
                var nonceStr  = TenPayV3Util.GetNoncestr();
                var timeStamp = TenPayV3Util.GetTimestamp();

                //商品Id,用户自行定义
                var xmlDataInfoH5 = new TenPayV3UnifiedorderRequestData(WeixinConfig.AppID, tenPayV3Info.MchId, ordersEntity.Tel, ordersEntity.OrderSn,
                                                                        Convert.ToInt32(Convert.ToDecimal(ordersEntity.Price) * 100), //1
                                                                        Request.UserHostAddress, WeixinConfig.TenPayV3Notify, TenPayV3Type.JSAPI, CurrentWxUser.OpenId, tenPayV3Info.Key, nonceStr);
                var result = TenPayV3.Unifiedorder(xmlDataInfoH5);                                                                    //调用统一订单接口
                LogHelper.AddLog(result.ResultXml);                                                                                   //记录日志
                var package = string.Format("prepay_id={0}", result.prepay_id);
                if (result.return_code == "SUCCESS")
                {
                    WFTWxModel jsApiPayData = new WFTWxModel()
                    {
                        appId     = WeixinConfig.AppID,
                        timeStamp = timeStamp,
                        nonceStr  = nonceStr,
                        package   = package,
                        paySign   = TenPayV3.GetJsPaySign(WeixinConfig.AppID, timeStamp, nonceStr, package, WeixinConfig.Key)
                    };
                    ViewBag.id      = ordersEntity.Id;
                    ViewBag.WxModel = jsApiPayData;
                    LogHelper.AddLog(JsonConvert.SerializeObject(jsApiPayData));//记录日志
                }
                return(View());
            }
            else
            {
                ReturnJson root = new ReturnJson {
                    code = 400, msg = "订单号不存在!"
                };
                return(Json(root));
            }
        }
Esempio n. 4
0
        public ActionResult upgradeLevel(int?tid)
        {
            var agentEntity = agentBll.GetEntityByOpenId(CurrentWxUser.OpenId);

            if (agentEntity != null)
            {
                //var ordersEntityOld = ordersJMBll.GetList("{\"AgentId\":\"" + agentEntity.Id + "\",\"PayStatus\":\"" + 0 + "\"}");
                //if (ordersEntityOld.Count()>0)
                //{
                //    //存在未付款的升级订单

                //}

                LogHelper.AddLog("upgradeLevel tid=" + tid);//记录日志
                decimal price = 0;
                string  LV    = "";
                if (tid == 2)
                {
                    price = 399;
                    LV    = "黄金代理";
                }
                else if (tid == 3)
                {
                    price = 1999;
                    LV    = "钻石代理";
                }
                var sp_billno = string.Format("{0}{1}", "JM-", DateTime.Now.ToString("yyyyMMddHHmmss"));

                OrdersJMEntity ordersEntity = new OrdersJMEntity()
                {
                    Price    = price,
                    LV       = LV,
                    OrderSn  = sp_billno,
                    OpenId   = CurrentWxUser.OpenId,
                    NickName = CurrentWxUser.NickName,
                    AgentId  = agentEntity.Id,
                    Pid      = agentEntity.Pid,
                    Tid      = agentEntity.Tid
                };

                ordersEntity = ordersJMBll.SaveForm(null, ordersEntity);//创建JM升级订单表

                var nonceStr  = TenPayV3Util.GetNoncestr();
                var timeStamp = TenPayV3Util.GetTimestamp();

                //商品Id,用户自行定义
                var xmlDataInfoH5 = new TenPayV3UnifiedorderRequestData(WeixinConfig.AppID, tenPayV3Info.MchId, LV, sp_billno,
                                                                        Convert.ToInt32(Convert.ToDecimal(price) * 100), //1
                                                                        Request.UserHostAddress, WeixinConfig.TenPayV3Notify, TenPayV3Type.JSAPI, CurrentWxUser.OpenId, tenPayV3Info.Key, nonceStr);
                var result = TenPayV3.Unifiedorder(xmlDataInfoH5);                                                       //调用统一订单接口
                LogHelper.AddLog(result.ResultXml);                                                                      //记录日志
                var package = string.Format("prepay_id={0}", result.prepay_id);
                if (result.return_code == "SUCCESS")
                {
                    WFTWxModel jsApiPayData = new WFTWxModel()
                    {
                        appId     = WeixinConfig.AppID,
                        timeStamp = timeStamp,
                        nonceStr  = nonceStr,
                        package   = package,
                        paySign   = TenPayV3.GetJsPaySign(WeixinConfig.AppID, timeStamp, nonceStr, package, WeixinConfig.Key)
                    };
                    ViewBag.WxModel = jsApiPayData;
                    LogHelper.AddLog(JsonConvert.SerializeObject(jsApiPayData));//记录日志
                }
            }
            return(View());
        }