Esempio n. 1
0
        public ActionResult PaySuccess(string billNo)
        {
            if (!string.IsNullOrEmpty(billNo))
            {
                int                        oId                      = Utility.Util.ParseHelper.ToInt(billNo);
                int                        gid                      = 0;
                decimal                    orderPrice               = 0;
                string                     goodsMainImgUrl          = string.Empty;
                string                     goodsName                = string.Empty;
                pbs_basic_Order            order                    = new pbs_basic_Order();
                pbs_basic_OrderService     pbsBasicOrderService     = new pbs_basic_OrderService();
                pbs_basic_GoodsService     pbsBasicGoodsService     = new pbs_basic_GoodsService();
                pbs_basic_MyVoucherService pbsBasicMyVoucherService = new pbs_basic_MyVoucherService();
                pbs_basic_VoucherService   pbsBasicVoucherService   = new pbs_basic_VoucherService();

                ResultInfo <bool> result_UpdateOrder = pbsBasicOrderService.UpdateOrders(2, oId);
                if (result_UpdateOrder.Result && result_UpdateOrder.Data)
                {
                    ResultInfo <pbs_basic_Order> result_order = pbsBasicOrderService.GetOrderModelById(oId);
                    if (result_order.Result && result_order.Data != null)
                    {
                        gid        = result_order.Data.GoodsId;
                        orderPrice = result_order.Data.OrderPrice;
                        ResultInfo <pbs_basic_GoodsView> result = pbsBasicGoodsService.GetGoodsModelViewById(gid);
                        if (result.Result && result.Data != null)
                        {
                            goodsMainImgUrl = result.Data.GoodsMainImgUrl;
                            goodsName       = result.Data.GoodsName;
                        }

                        //减少活动数量
                        ResultInfo <bool> result_updateGoodsCount = pbsBasicGoodsService.UpdateGoodsCountMinus(result_order.Data.GoodsId);

                        //更新优惠券使用
                        ResultInfo <bool> result_UpdateMyVoucherIsUsed = pbsBasicMyVoucherService.UpdateMyVoucherIsUsed(1, result_order.Data.VoucherId);

                        if (result_order.Data.VoucherId != 0)
                        {
                            ResultInfo <pbs_basic_Voucher> result_Voucher = pbsBasicVoucherService.GetVoucherModelById(result_order.Data.VoucherId);
                            if (result_Voucher.Result && result_Voucher.Data != null)
                            {
                                orderPrice = orderPrice - result_Voucher.Data.VoucherPrice;

                                //更新订单价格
                                ResultInfo <bool> result_UpdateOrderPrice = pbsBasicOrderService.UpdateOrderPrice(orderPrice, oId);
                            }
                        }
                    }
                }

                ViewData["OrderPrice"] = orderPrice;

                #region 分销
                if (!string.IsNullOrEmpty(FromShareUserId))
                {
                    FXMethod(gid, oId, orderPrice);
                }
                #endregion

                //#region 微信分享
                //string token = string.Empty;
                //string ticket = string.Empty;
                //string timestamp = string.Empty;
                //string nonceStr = string.Empty;
                //string signature = string.Empty;
                //if (Session["Token"] != null && Session["TokenTime"] != null)
                //{
                //    DateTime dt1 = DateTime.Now;
                //    DateTime dt2 = Utility.Util.ParseHelper.ToDatetime(Session["TokenTime"].ToString());
                //    TimeSpan ts = dt1 - dt2;
                //    string tsSen = ts.Seconds.ToString();
                //    if (Utility.Util.ParseHelper.ToInt(tsSen) < 7200)
                //    {
                //        token = Session["Token"].ToString();
                //        ticket = Session["Ticket"].ToString();
                //        timestamp = Session["TimeStamp"].ToString();
                //        nonceStr = Session["NonceStr"].ToString();
                //        //signature = Session["SigNature"].ToString();
                //        signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, Request.Url.AbsoluteUri);
                //        LogUtil.WriteLog("tsSen:" + tsSen);
                //        LogUtil.WriteLog("Session Token:" + token);
                //        LogUtil.WriteLog("Session Ticket:" + ticket);
                //        LogUtil.WriteLog("Session TimeStamp:" + timestamp);
                //        LogUtil.WriteLog("Session NonceStr:" + nonceStr);
                //        LogUtil.WriteLog("Session SigNature:" + signature);
                //    }
                //}
                //if (string.IsNullOrEmpty(token))
                //{
                //    #region 获取token
                //    string token_url = string.Format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", PayConfig.AppId, PayConfig.AppSecret);
                //    string returnToken = HttpUtil.Send("", token_url);
                //    var tokenModel = JsonConvert.DeserializeObject<tokenModel>(returnToken);
                //    token = tokenModel.access_token;
                //    #endregion

                //    #region 获取ticket
                //    string ticket_url = string.Format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi", token);
                //    string returnTicket = HttpUtil.Send("", ticket_url);
                //    var ticketModel = JsonConvert.DeserializeObject<ticketModel>(returnTicket);
                //    ticket = ticketModel.ticket;
                //    #endregion

                //    //获取时间戳
                //    timestamp = JSSDKHelper.GetTimestamp();
                //    //获取随机码
                //    nonceStr = JSSDKHelper.GetNoncestr();
                //    //获取签名
                //    signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, Request.Url.AbsoluteUri);
                //    Session["Token"] = token;
                //    Session["TokenTime"] = DateTime.Now;
                //    Session["Ticket"] = ticket;
                //    Session["TimeStamp"] = timestamp;
                //    Session["NonceStr"] = nonceStr;
                //    //Session["SigNature"] = signature;

                //    LogUtil.WriteLog("First Ticket:" + ticket);
                //    LogUtil.WriteLog("First TimeStamp:" + timestamp);
                //    LogUtil.WriteLog("First NonceStr:" + nonceStr);
                //    LogUtil.WriteLog("First SigNature:" + signature);
                //    LogUtil.WriteLog("Request Url:" + Request.Url.AbsoluteUri);
                //}

                //ViewData["AppId"] = PayConfig.AppId;
                //ViewData["Timestamp"] = timestamp;
                //ViewData["NonceStr"] = nonceStr;
                //ViewData["Signature"] = signature;

                //#endregion
            }
            return(View());
        }
Esempio n. 2
0
 public void TestUpdateOrderPrice()
 {
     pbs_basic_OrderService pbsBasicOrderService    = new pbs_basic_OrderService();
     ResultInfo <bool>      result_UpdateOrderPrice = pbsBasicOrderService.UpdateOrderPrice(20, 90);
 }