Beispiel #1
0
    /// <summary>
    /// 购买服务
    /// </summary>
    /// <param name="type">服务种类</param>
    /// <returns></returns>
    public string AddOrder(string type)
    {
        try
        {
            LoginModel logUser = Session["UserModel"] as LoginModel;

            List <Hi.Model.Pay_Service> deleteList = new Hi.BLL.Pay_Service().GetList("*", " CompID=" + logUser.CompID + " and  PayedPrice=0 and IsAudit=2 ", " createdate desc");
            if (deleteList.Count > 0)
            {
                foreach (var item in deleteList)
                {
                    new Hi.BLL.Pay_Service().Delete(item.ID);
                }
            }

            string outdata    = "0"; //判断是否已经存在有效的服务(获取已存在的服务过期日期)
            string CreateDate = "0"; //同上

            Hi.Model.Pay_Service service = new Hi.Model.Pay_Service();
            service.CompID   = logUser.CompID;
            service.CompName = logUser.CompName;
            outdata          = Common.GetCompService(logUser.CompID.ToString(), out CreateDate);// 存在有效服务 有效日期累加
            //List<Hi.Model.Pay_Service> serviceord = new Hi.BLL.Pay_Service().GetList("*", " compid=" + logUser.CompID + " and isaudit=1 and outofdata=0 and OutData>'" + DateTime.Now.ToString("yyyy-MM-dd") + "' ", " OutData desc");
            //if (serviceord.Count>0)
            //{
            //    outdata = serviceord[0].OutData.ToString();//存在有效服务  有效日期累加
            //    CreateDate= serviceord[0].CreateDate.ToString();
            //}


            if (type == "1")                                                                                             //月服务
            {
                service.ServiceType = 2;                                                                                 //服务类别 2:月  1:年
                service.OutData     = outdata == "0"?DateTime.Now.AddMonths(1):Convert.ToDateTime(outdata).AddMonths(1); //服务到期日期
                service.Price       = 499;                                                                               //服务金额
            }
            else//年服务
            {
                service.ServiceType = 1;                                                                                  //服务类别 2:月  1:年
                service.OutData     = outdata == "0" ? DateTime.Now.AddYears(1): Convert.ToDateTime(outdata).AddYears(1); // 服务到期日期
                service.Price       = 4999;
            }
            service.CreateDate = CreateDate == "0"? DateTime.Now:Convert.ToDateTime(CreateDate);
            service.CreateUser = logUser.UserID;
            service.OutOfData  = 0; //是否过期 0否 1是
            service.PayedPrice = 0; //已经支付金额
            service.IsAudit    = 2; //支付状态 1成功  2失败
            service.ts         = DateTime.Now;
            service.dr         = 0;
            service.modifyuser = logUser.UserID;
            int OrderId = new Hi.BLL.Pay_Service().Add(service);
            KeyID = Common.DesEncrypt(OrderId.ToString(), Common.EncryptKey);
            if (OrderId > 0)
            {
                return("{\"rel\":\"OK\",\"Orderid\":\"" + KeyID + "\"}");
            }
            else
            {
                return("{\"rel\":\"NO\",\"Msg\":\"网络异常 请稍后再试\"}");
            }
            //return "{\"rel\":\"OK\",\"Orderid\":\"2\"}";
        }
        catch (Exception e)
        {
            return("{\"rel\":\"NO\",\"Msg\":\"" + e.Message + "\"}");

            throw;
        }
    }
Beispiel #2
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.Pay_Service model)
 {
     return(dal.Add(model));
 }
Beispiel #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.Pay_Service model)
 {
     return(dal.Update(model));
 }
Beispiel #4
0
    /// <summary>
    /// 订单支付
    /// </summary>
    /// <param name="orderid">订单ID</param>
    /// <param name="txtPayOrder">支付金额</param>
    /// <param name="price">企业钱包金额</param>
    /// <param name="yfk">预付款</param>
    /// <param name="payPas"></param>
    public Wxpay_Url PayOrder(int orderid, decimal txtPayOrder, decimal price, int yfk, string payPas)
    {
        //使用企业钱包

        serviceOrder = new Hi.BLL.Pay_Service().GetModel(orderid);
        #region  界面上显示
        this.lblOrderNO.InnerText = serviceOrder.ID.ToString();;
        this.fee.InnerText        = "医伴金服";//收款方

        #endregion 界面上显示

        decimal payPrice = serviceOrder.Price;//支付金额
        #region  插入支付表记录

        Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment();
        string orderNo = WebConfigurationManager.AppSettings["OrgCode"] + DateTime.Now.ToString("yyyyMMdd");//支付订单号前半部分

        string guid = Guid.NewGuid().ToString().Replace("-", "");
        payModel.OrderID      = serviceOrder.ID; // orderid;
        payModel.DisID        = 0;
        payModel.Type         = 0;               // isDBPay;
        payModel.PayUser      = this.CompName;
        payModel.PayPrice     = payPrice;
        payModel.IsAudit      = 2;
        payModel.guid         = Common.Number_repeat(guid);
        payModel.vdef3        = "3"; //1,订单支付,2,预付款充值、汇款 3购买服务
        payModel.vdef4        = orderNo;
        payModel.CreateDate   = DateTime.Now;
        payModel.CreateUserID = this.UserID;
        payModel.ts           = DateTime.Now;
        payModel.modifyuser   = this.UserID;
        payModel.PrintNum     = 1; //支付宝支付无需结算
        //判断账户类型,判断支付渠道
        payModel.Channel = "7";    //1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付,5,线下支付,6,支付宝支付 7,微信支付
        payModel.State   = 0;      //手续费收取方
        payModel.vdef5   = "0.00"; //支付手续费
        payid            = new Hi.BLL.PAY_Payment().Add(payModel);

        //if (prepayid > 0)
        //{
        //    Hi.Model.PAY_PrePayment prepayMent = new Hi.BLL.PAY_PrePayment().GetModel(prepayid);
        //    prepayMent.vdef4 = payid.ToString();//与企业钱包关联
        //    new Hi.BLL.PAY_PrePayment().Update(prepayMent);
        //}

        Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog();
        regModel.OrderId    = serviceOrder.ID;// orderid;
        regModel.Ordercode  = orderNo + payid.ToString();
        regModel.number     = payModel.guid;
        regModel.Price      = payPrice;
        regModel.Payuse     = "订单支付";
        regModel.PayName    = this.CompName;
        regModel.DisID      = 0;
        regModel.PayTime    = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        regModel.Remark     = "厂商购买服务";// orderModel.Remark;
        regModel.DisName    = this.CompName;
        regModel.BankID     = "微信支付";
        regModel.CreateUser = this.UserID;
        regModel.CreateDate = DateTime.Now;
        regModel.LogType    = 1311;
        int regid = new Hi.BLL.PAY_RegisterLog().Add(regModel);

        serviceOrder.IsAudit    = 1;
        serviceOrder.PayedPrice = payPrice;
        bool serid = new Hi.BLL.Pay_Service().Update(serviceOrder);
        if (payid <= 0 || regid <= 0 || !serid)
        {
            Response.Redirect("Error.aspx", false);
        }

        ;
        #endregion


        int amount = Convert.ToInt32(payPrice * 100);//支付金额(单位:分)

        //隐藏域赋值
        this.hidguid.Value  = payModel.guid;
        this.hidprice.Value = payPrice.ToString();
        this.hidordid.Value = payModel.OrderID.ToString();
        this.hidpid.Value   = payid.ToString();
        this.hidppid.Value  = prepayid.ToString();

        // btnWxPay_Click(payModel.guid, orderid.ToString(), amount);

        Wxpay_Url wxpaymodel = new Wxpay_Url();
        wxpaymodel.Guid    = payModel.guid;
        wxpaymodel.OrderID = orderid.ToString();
        wxpaymodel.Amount  = amount;


        wxpaymodel.Hidguid  = payModel.guid;
        wxpaymodel.Hidprice = payModel.PayPrice.ToString();
        wxpaymodel.Hidordid = payModel.OrderID.ToString();
        wxpaymodel.Hidpid   = payid.ToString();
        wxpaymodel.Hidppid  = prepayid.ToString();

        return(wxpaymodel);
    }