Example #1
0
        /// <summary>
        /// 获取订单状态
        /// </summary>
        /// <param name="dingdan"></param>
        private void GetOrderStatusMsg(wx_hotel_dingdan dingdan)
        {
            orderStatus = dingdan.orderStatus.Value;
            //支付状态下默认退款金额为订单总额
            if (orderStatus == HotelStatusManager.OrderStatus.Payed.StatusId)
            {
                var result = GetPrice(dingdan);

                txtAmount.Text = result.ToString();
                if (isAdmin)
                {
                    hidConfirmStr.Value = "确定执行【退款】操作吗?";

                    if (listCode != null && listCode.Any(c => c.Status == "已使用"))//订单中有验证码已使用
                    {
                        hidConfirmStr.Value = string.Format("{0},{1}", "订单中有验证码已使用", hidConfirmStr.Value);
                    }
                }
            }
            else if (orderStatus == HotelStatusManager.OrderStatus.Refunding.StatusId ||
                     orderStatus == HotelStatusManager.OrderStatus.Refunded.StatusId)
            {
                var hotelService = new HotelService();
                tuidan = hotelService.GetModel(dingdan.id, dingdan.hotelid.Value);
                if (tuidan != null && tuidan.operateUser > 0)
                {
                    var manager = new BLL.manager().GetModel(tuidan.operateUser);
                    uName    = manager.real_name;
                    roleName = new WeiXinPF.BLL.manager_role().GetTitle(manager.role_id);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 获取验证码剩余数量
        /// </summary>
        /// <returns></returns>
        private int GetCodeCount(wx_hotel_dingdan dingdan)
        {
            var count = 0;

            var wxHotelsInfo = new BLL.wx_hotels_info().GetModel(dingdan.hotelid.Value);
            var listCodes    = IdentifyingCodeService.GetIdentifyingCodeInfoByOrderId
                                   (dingdan.hotelid.Value, "hotel",
                                   dingdan.id.ToString(), wxHotelsInfo.wid.Value);

            //查询状态为已使用的
            var usedCode = listCodes.Where(t => t.Status == 2);

            if (usedCode.Any())
            {
                count = dingdan.orderNum.Value - usedCode.Count();
            }
            else
            {
                count = dingdan.orderNum.Value;
            }

            if (count <= 0)
            {
                //                ordermsg = "房间已全部入住";
                //                ordermsg = string.Format(@"  <div class='alert alert-warning' role='alert'>
                //      <strong> 提示!</strong>  {0}
                //         </div>", ordermsg);
            }
            else
            {
            }
            return(count);
        }
Example #3
0
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="dingdanbll"></param>
        /// <param name="jsonDict"></param>
        /// <param name="context"></param>
        private void UpdateOrder(wx_hotel_dingdan dingdanbll, Dictionary <string, string> jsonDict,
                                 HttpContext context, int statusId, string msg)
        {
            int ddid = MyCommFun.RequestInt("dingdanidnum");

            dingdanbll.Update(ddid, statusId.ToString());
            jsonDict.Add("ret", "ok");
            jsonDict.Add("content", msg);
            context.Response.Write(MyCommFun.getJsonStr(jsonDict));
            return;
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dingdanbll"></param>
        /// <param name="jsonDict"></param>
        /// <param name="context"></param>
        private void GetPayUrl(wx_hotel_dingdan dingdanbll, HttpContext context)
        {
            int ddid = MyCommFun.RequestInt("dingdanidnum");

            if (ddid > 0)
            {
                var dingdan = dingdanbll.GetModel(ddid);
                if (dingdan != null)
                {
                    Model.wx_hotels_info hotelInfo = new wx_hotels_info();
                    int wid = 0;
                    if (dingdan.hotelid != null)
                    {
                        hotelInfo = new BLL.wx_hotels_info().GetModel(dingdan.hotelid.Value);
                        if (hotelInfo.wid != null)
                        {
                            wid = hotelInfo.wid.Value;
                        }
                    }
                    //总花费
                    var dateSpan   = dingdan.leaveTime.Value - dingdan.arriveTime.Value;
                    var totalPrice = dingdan.price.Value * dingdan.orderNum.Value * dateSpan.Days;

                    var port   = WebHelper.GetHostPort();
                    var url    = string.Format("{0}/weixin/KNSHotel/hotel_order_paycallback.aspx", port);
                    var entity = new UnifiedOrderEntity
                    {
                        wid          = wid,
                        total_fee    = totalPrice == null ? 0 : (int)totalPrice,
                        out_trade_no = dingdan.OrderNumber,
                        openid       = dingdan.openid,
                        OrderId      = dingdan.id.ToString(),
                        body         = string.Format("订单编号{2} {3}{1}{0}间", dingdan.orderNum, dingdan.roomType
                                                     , dingdan.OrderNumber, hotelInfo.hotelName),
                        PayModuleID = (int)PayModuleEnum.Hotel,
                        PayComplete = url
                    };

                    entity.Extra.Add("dingdanidnum", ddid.ToString());
                    entity.Extra.Add("openid", dingdan.openid);
                    entity.Extra.Add("hotelid", dingdan.hotelid.ToString());
                    entity.Extra.Add("roomid", dingdan.roomid.ToString());

                    var ticket  = EncryptionManager.CreateIV();
                    var payData = EncryptionManager.AESEncrypt(entity.ToJson(), ticket);

                    context.Response.Write(AjaxResult.Success(PayHelper.GetPayUrl(payData, ticket)));
                }
            }
            else
            {
                context.Response.Write(AjaxResult.Error("获取支付状态失败!"));
            }
        }
Example #5
0
        /// <summary>
        /// 微信退单
        /// </summary>
        /// <param name="dingdan"></param>
        /// <param name="dto"></param>
        /// <param name="returnMsg"></param>
        /// <returns></returns>
        private bool WeChatRefund(wx_hotel_dingdan dingdan, TuidanDto dto, int wid, out string returnMsg)
        {
            bool result = false;

            returnMsg = null;

            var refundResult = dingdanbll.GetWeChatRefundParams(wid, dingdan.hotelid.Value, dingdan.id, dto.refundCode);

            //使用系统订单号退单
            if (refundResult != null && refundResult.Tables.Count > 0 && refundResult.Tables[0].Rows.Count > 0)
            {
                var orderNumber    = refundResult.Tables[0].Rows[0]["orderNumber"].ToString();
                var transaction_id = refundResult.Tables[0].Rows[0]["transaction_id"].ToString();
                var refundAmount   = Convert.ToInt32(refundResult.Tables[0].Rows[0]["refundAmount"]);
                var payAmount      = Convert.ToInt32(refundResult.Tables[0].Rows[0]["payAmount"]);


                var wxModel = new BLL.wx_userweixin().GetModel(wid);
                var payInfo = new BLL.wx_payment_wxpay().GetModelByWid(wid);

                var requestHandler = new RequestHandler(null);
                requestHandler.SetParameter("out_trade_no", orderNumber);
                //requestHandler.SetParameter("transaction_id", transaction_id);
                requestHandler.SetParameter("out_refund_no", dto.refundCode);
                requestHandler.SetParameter("appid", wxModel.AppId);
                requestHandler.SetParameter("mch_id", payInfo.mch_id);//商户号
                requestHandler.SetParameter("nonce_str", Guid.NewGuid().ToString().Replace("-", ""));

                //退款金额
                if (PayHelper.IsDebug)
                {
                    requestHandler.SetParameter("total_fee", (payAmount).ToString());
                    requestHandler.SetParameter("refund_fee", (refundAmount).ToString());
                }
                else
                {
                    requestHandler.SetParameter("total_fee", (payAmount * 100).ToString());
                    requestHandler.SetParameter("refund_fee", (refundAmount * 100).ToString());
                }

                requestHandler.SetParameter("op_user_id", wxModel.AppId);
                requestHandler.SetParameter("sign", requestHandler.CreateMd5Sign("key", payInfo.paykey));

                var refundInfo          = TenPayV3Helper.Refund(requestHandler.ParseXML(), string.Format(@"{0}{1}", AppDomain.CurrentDomain.BaseDirectory, payInfo.certInfoPath), payInfo.cerInfoPwd);
                var refundOrderResponse = new RefundOrderResponse(refundInfo);

                result    = refundOrderResponse.IsSuccess;
                returnMsg = refundOrderResponse.return_msg;
            }

            return(result);
        }
Example #6
0
        /// <summary>
        /// 获取最大可退价格
        /// </summary>
        /// <param name="dingdan"></param>
        private decimal GetPrice(wx_hotel_dingdan dingdan)
        {
            decimal result = 0;

            var count = GetCodeCount(dingdan);
            //总花费
            var dateSpan = dingdan.leaveTime.Value - dingdan.arriveTime.Value;
            //            var totalPrice = dingdan.price.Value * (dingdan.orderNum.Value - count) * dateSpan.Days;
            var totalPrice = dingdan.price.Value * (dingdan.orderNum.Value) * dateSpan.Days;

            result = totalPrice;
            return(result);
        }
Example #7
0
        /// <summary>
        /// 获取验证码
        /// todo:添加功能
        /// </summary>
        /// <param name="wxHotelDingdan"></param>
        private void GetVerificationCode(wx_hotel_dingdan wxHotelDingdan)
        {
            if (wxHotelDingdan.orderStatus == HotelStatusManager.OrderStatus.Payed.StatusId

                || wxHotelDingdan.orderStatus == HotelStatusManager.OrderStatus.Refunded.StatusId ||
                wxHotelDingdan.orderStatus == HotelStatusManager.OrderStatus.Refunding.StatusId
                )
            {
                var wxHotelsInfo = new BLL.wx_hotels_info().GetModel(wxHotelDingdan.hotelid.Value);
                var list         = IdentifyingCodeService.GetIdentifyingCodeInfoByOrderId
                                       (wxHotelDingdan.hotelid.Value, "hotel",
                                       wxHotelDingdan.id.ToString(), wxHotelsInfo.wid.Value);
                foreach (var code in list)
                {
                    //根据验证码状态, 显示在界面的状态
                    int showStatus = 0;
                    switch (code.Status)
                    {
                    case 0:
                    case 1:
                        showStatus = 1;
                        if (wxHotelDingdan.orderStatus == HotelStatusManager.OrderStatus.Payed.StatusId)
                        {
                            VerificationCode += string.Format(@"<div class='swiper-slide swiper-image'>
                                  <input type ='hidden' value='{0}' status='{1}' />
                                   </div>", code.IdentifyingCode, showStatus);
                        }
                        else
                        {
                            VerificationCode += string.Format(@"<div class='swiper-slide swiper-image'>
                                 <img class='img-ercode' src='../restaurant/images/orderRefunded.png' value='{0}' status='{1}'>
                                   </div>", code.IdentifyingCode, showStatus);
                        }

                        break;

                    case 2:
                        showStatus        = 2;
                        VerificationCode += string.Format(@"<div class='swiper-slide swiper-image'>
                                 <img class='img-ercode' src='../restaurant/images/orderUsed.png' value='{0}' status='{1}'>
                                   </div>", code.IdentifyingCode, showStatus);
                        break;

                    case 3:
                    case 4:
                        showStatus = 3;
                        break;
                    }
                }
            }
        }
Example #8
0
        /// <summary>
        /// 微信退单
        /// </summary>
        /// <param name="dingdan"></param>
        /// <param name="dto"></param>
        /// <param name="returnMsg"></param>
        /// <returns></returns>
        private bool WeChatRefund(wx_hotel_dingdan dingdan, TuidanDto dto, int wid, out string returnMsg)
        {
            bool result = false;
            returnMsg = null;

            var refundResult = _hotelOrderService.GetWeChatRefundParams(wid, dingdan.hotelid.Value, dingdan.id, dto.refundCode);

            //使用系统订单号退单
            if (refundResult != null && refundResult.Tables.Count > 0 && refundResult.Tables[0].Rows.Count > 0)
            {
                var orderNumber = refundResult.Tables[0].Rows[0]["orderNumber"].ToString();
                var transaction_id = refundResult.Tables[0].Rows[0]["transaction_id"].ToString();
                var refundAmount = Convert.ToInt32(refundResult.Tables[0].Rows[0]["refundAmount"]);
                var payAmount = Convert.ToInt32(refundResult.Tables[0].Rows[0]["payAmount"]);


                var wxModel = new BLL.wx_userweixin().GetModel(wid);
                var payInfo = new BLL.wx_payment_wxpay().GetModelByWid(wid);

                var requestHandler = new RequestHandler(null);
                requestHandler.SetParameter("out_trade_no", orderNumber);
                //requestHandler.SetParameter("transaction_id", transaction_id);
                requestHandler.SetParameter("out_refund_no", dto.refundCode);
                requestHandler.SetParameter("appid", wxModel.AppId);
                requestHandler.SetParameter("mch_id", payInfo.mch_id);//商户号
                requestHandler.SetParameter("nonce_str", Guid.NewGuid().ToString().Replace("-", ""));

                //退款金额
                if (PayHelper.IsDebug)
                {
                    requestHandler.SetParameter("total_fee", (payAmount).ToString());
                    requestHandler.SetParameter("refund_fee", (refundAmount).ToString());
                }
                else
                {
                    requestHandler.SetParameter("total_fee", (payAmount * 100).ToString());
                    requestHandler.SetParameter("refund_fee", (refundAmount * 100).ToString());
                }

                requestHandler.SetParameter("op_user_id", wxModel.AppId);
                requestHandler.SetParameter("sign", requestHandler.CreateMd5Sign("key", payInfo.paykey));

                var refundInfo = TenPayV3Helper.Refund(requestHandler.ParseXML(), string.Format(@"{0}{1}", AppDomain.CurrentDomain.BaseDirectory, payInfo.certInfoPath), payInfo.cerInfoPwd);
                var refundOrderResponse = new RefundOrderResponse(refundInfo);

                result = refundOrderResponse.IsSuccess;
                returnMsg = refundOrderResponse.return_msg;
            }

            return result;
        }