Esempio n. 1
0
        /// <summary>
        /// 刷新系统参数配置
        /// </summary>
        public void RefreshConfigSite()
        {
            XMLHelp xmlhelp = new Common.XMLHelp("/XmlConfig/site.config");

            xmlsite = new Xml_Site();
            #region 通过反射来取各个字段
            var type = typeof(Xml_Site);
            var ps   = type.GetProperties();
            foreach (var item in ps)
            {
                var name  = item.Name;
                var value = WebTools.ChangeType(xmlhelp.GetNodeValue(name), item.PropertyType);
                if (value != null && !string.IsNullOrEmpty(value.ToString()))
                {
                    item.SetValue(xmlsite, value);
                }
            }
            #endregion
        }
Esempio n. 2
0
        public void SaveSite(Xml_Site entity)
        {
            XMLHelp xmlhelp = new Common.XMLHelp("/XmlConfig/site.config");

            #region 通过反射来取各个字段
            var type = typeof(DataBase.Xml_Site);
            var ps   = type.GetProperties();
            foreach (var item in ps)
            {
                var name  = item.Name;
                var value = item.GetValue(entity);
                if (value != null)
                {
                    xmlhelp.SetXmlNodeValue("//" + item.Name, value.ToString());
                }
            }
            #endregion
            xmlhelp.SavexmlDocument();
            RefreshConfigSite();
        }
Esempio n. 3
0
        public ActionResult Save(decimal scores, decimal amount, int id = 0)
        {
            //1.添加充值记录
            ScoreRecord record  = null;
            Member_Info curUser = DB.Member_Info.FindEntity(CurrentUser.Id);

            if (id == 0)
            {
                Xml_Site config = DB.XmlConfig.XmlSite;
                if (amount <= 0)
                {
                    return(Content("充值金额要大于0"));
                }
                if (scores % config.ScoreMultiple != 0)
                {
                    return(Content("充值数量要是" + config.ScoreMultiple + "的数量"));
                }
                record            = new ScoreRecord();
                record.CreateTime = DateTime.Now;
                record.Scores     = scores;
                record.Amount     = amount;
                record.State      = Enums.ScoreState.待付款.GetHashCode();
                record.MemberID   = curUser.MemberId;
                record.MemberCode = curUser.Code;
                record.MemberName = curUser.NickName;
                DB.ScoreRecord.Insert(record);
            }
            else
            {
                record = DB.ScoreRecord.FindEntity(id);
            }


            //判断是否是微信端
            if (Url_Mobile.IsWechat() && string.IsNullOrEmpty(curUser.OpenID) == false)
            {
                Xml_Site config = DB.XmlConfig.XmlSite;
                JsonHelp json   = new JsonHelp(true);
                try
                {
                    //使用微信api 下订单
                    PayManage _manage   = new PayManage();
                    string    tradetype = Url_Mobile.IsWechat() ? "JSAPI" : "NATIVE";
                    _manage.OnCreateOrderSuccess += (result) =>
                    {
                        json.Msg   = result.Prepay_ID;
                        json.ReUrl = result.Code_Url; //二维码地址
                                                      //签名处理
                        Dictionary <string, string> dic = new Dictionary <string, string>();
                        int timeStamp = AccessTokenManage.TimeStamp;
                        dic.Add("appId", result.APPID);
                        dic.Add("timeStamp", timeStamp.ToString());
                        dic.Add("nonceStr", timeStamp.ToString());
                        dic.Add("package", $"prepay_id={result.Prepay_ID}");
                        dic.Add("signType", "MD5");
                        json.Data = new
                        {
                            appId     = result.APPID,
                            timeStamp = timeStamp.ToString(),
                            nonceStr  = timeStamp.ToString(),
                            package   = $"prepay_id={result.Prepay_ID}",
                            signType  = "MD5",
                            paySign   = ConfigInfo.GetPaySign(dic)
                        };
                    };
                    _manage.BackHandleUrl = $"http://{Request.Url.Host}/ajax/ScoreWX";//指定回调地址
                    _manage.CreateOrder(DateTime.Now.ToString("MMddms") + "_" + record.ID, config.GetAmount(amount), curUser.OpenID, tradetype, "竹笛商城积分充值");
                }
                catch (Exception ex)
                {
                    json.IsSuccess = false;
                    json.Msg       = ex.Message;

                    Common.LogHelper.Debug("积分充值微信端出错:" + ex.Message);
                    Common.LogHelper.Debug(ex.StackTrace);
                }

                return(Json(json));
            }
            else
            {
                //2.获取充值地址
                //string url = PayHelper.GetPayUrl(DateTime.Now.ToString("MMddms") + "_" + record.ID, amount, "积分充值", true);
                //return Redirect(url);
                return(Redirect("支付接口申请中...."));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 保存(添加与更新)
        /// </summary>
        /// <param name="Pwd2">支付密码</param>
        /// <param name="entity">当前实体对象</param>
        /// <returns></returns>
        public bool Save(string Pwd2, Fin_Convert entity)
        {
            JsonHelp json = new JsonHelp()
            {
                Status = "n", Msg = "保存失败"
            };

            Xml_Site config = DB.XmlConfig.XmlSite;

            #region 检查支付密码是否正确,转换金额是否超限,

            using (var tran = DB.Fin_Convert.BeginTransaction)
            {
                try
                {
                    var model = DB.Member_Info.FindEntity(entity.MemberId);
                    if (model != null && model.Pwd2 == Pwd2)
                    {
                    }
                    else
                    {
                        throw new Exception("支付密码错误");
                    }
                    if (entity.Amount <= 0)
                    {
                        throw new Exception("转换金额要大于0");
                    }

                    if (entity.ConvertType == "奖金转余额")
                    {
                        if (entity.Amount > model.Coins)
                        {
                            throw new Exception("奖金额度不足!");
                        }
                    }


                    if (entity.ConvertId == 0)
                    {
                        if (Insert(entity))
                        {  //流水账单
                            Fin_LiuShui _liushui = new Fin_LiuShui();
                            //更新会员表的收益,电子币
                            if (entity.ConvertType == "奖金转余额")
                            {
                                model.Coins      -= entity.Amount;
                                model.Commission += entity.Amount;
                                DB.Fin_LiuShui.AddLS(model.MemberId, -entity.Amount.Value, "奖金转余额", "奖金");
                                DB.Fin_LiuShui.AddLS(model.MemberId, entity.Amount.Value, "奖金转余额");
                            }


                            DB.Member_Info.Update(model);
                            json.Status = "y";
                            json.Msg    = "操作成功";
                            //添加操作日志
                            DB.SysLogs.setMemberLog(Enums.EventType.Add, string.Format("货币转换,操作人:[{0}],金额:[{1}],操作成功", entity.NickName, entity.Amount));
                        }
                    }
                    tran.Complete();
                    return(true);
                }
                catch (Exception ex)
                {
                    DB.Rollback();
                    throw ex;
                }
            }


            #endregion
        }
Esempio n. 5
0
        /// <summary>
        /// 周结算
        /// </summary>
        public void Send(int type)
        {
            using (var tran = BeginTransaction)
            {
                try
                {
                    Xml_Site config = DB.XmlConfig.XmlSite;
                    //周结算,收益
                    string[] typeName = new string[] {
                        "直推一代奖",
                        "直推二代奖",
                        "互助奖",
                    };
                    if (type == Enums.SettleType.月计算.GetHashCode())
                    {
                        typeName = new string[] {
                            "领导奖",
                            //"师长分红",
                            //"社区店分红",
                            "重消奖",
                        };
                    }


                    //1.添加记录
                    SettleRecord record = new SettleRecord();
                    record.CreateTime = DateTime.Now;
                    record.Type       = type;
                    //2.处理到账
                    var list = DB.Fin_Info.Where(q => typeName.Contains(q.TypeName) &&
                                                 q.IsSettlement != true);
                    foreach (var item in list)
                    {
                        //到账处理
                        Member_Info member = DB.Member_Info.FindEntity(item.MemberId);
                        member.Commission    += item.RealAmount;
                        member.CommissionSum += item.RealAmount;
                        member.ShopCoins     += item.Poundage ?? 0;
                        member.CommissionBan += item.Amount ?? 0;

                        //如果操作1万,赠送路由积分
                        if (member.CommissionBan >= config.TourScoresStep)
                        {
                            member.CommissionBan -= config.TourScoresStep;
                            member.TourScores    += config.TourScores;
                        }
                        DB.Member_Info.Update(member);

                        //修改记录状态
                        item.IsSettlement   = true;
                        item.SettlementTime = DateTime.Now;
                        DB.Fin_Info.Update(item);

                        record.AllAmount     += item.Amount ?? 0;
                        record.AllCoins      += item.Poundage ?? 0;
                        record.AllCommission += item.RealAmount ?? 0;
                        record.AllCount++;
                    }

                    if (base.Insert(record) == false)
                    {
                        throw new Exception("添加记录失败");
                    }

                    //提交处理
                    tran.Complete();
                }
                catch (Exception ex)
                {
                    DB.Rollback();
                    throw ex;
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 确认付款操作
        /// </summary>
        /// <returns></returns>
        public ActionResult DoPay(int addressid, string paytype, string remark, bool isziti, string payPwd)
        {
            JsonHelp json = new JsonHelp(true);

            try
            {
                Xml_Site    config     = DB.XmlConfig.XmlSite;
                Xml_Shop    shopConfig = DB.XmlConfig.XmlShop;
                Member_Info curUser    = User_Shop.GetMember_Info();
                //获取订单信息
                string        orderlist = CookieHelper.GetCookieValue("orderlist");
                List <string> orderList = orderlist.JsonDeserializer <List <string> >();
                if (orderList == null)
                {
                    throw new Exception("订单支付异常");
                }
                if (orderList.Count <= 0)
                {
                    throw new Exception("获取订单信息失败");
                }
                var orderid = orderList.First();
                var query   = DB.ShopOrder.Where(q => q.GUID == orderid).FirstOrDefault();
                if (query.State != 1)
                {
                    throw new Exception("订单不是待支付订单不可支付");
                }

                DB.ShopOrder.UpdateOrderInfo(orderList, addressid, remark, isziti, paytype);

                if (paytype == "余额")
                {
                    //计算处理
                    DB.ShopOrder.Calcute(curUser, orderList.First(), payPwd);
                    CookieHelper.ClearCookie("orderlist");
                }
                else if (paytype == "支付宝")
                {
                    json.ReUrl = "/Member_Mall/Pay/Pay?OrderId=" + orderList.First();//http://tjyy.fabeisha.cn
                    //r.ReUrl = "http://tjyy.fabeisha.cn/Member_Mall/Pay/Pay?BillId=" + r.BillId;//http://www.738600.cn
                }
                else if (paytype == "微信")
                {
                    var    orderModel = DB.ShopOrder.FindEntity(orderList.First());
                    H5Pay  h5Pay      = new H5Pay();
                    var    wxConfig   = WxPayConfig.GetConfig();
                    string clientIP   = wxConfig.GetIp();                                                                                           //获取客户端真实IP
                    var    url        = h5Pay.GetPayUrl(clientIP, orderModel.OrderCode, (orderModel.RealAmount + orderModel.Postage.Value) * 100M); //通过统一下单接口进行H5支付
                                                                                                                                                    //Response.Redirect(url);//跳转到微信支付中间页
                    json.ReUrl = url;
                    //json.ReUrl = "/Member_Mall/Pay/WXPay?OrderId=" + orderList.First();//http://tjyy.fabeisha.cn
                    //r.ReUrl = "/Member_Mall/Pay/WXPay?BillId=" + r.BillId;//http://tjyy.fabeisha.cn
                }

                //3.清空cookie
                CookieHelper.ClearCookie("cart");
                CookieHelper.ClearCookie("total");

                CookieHelper.ClearCookie("traceno");
            }
            catch (Exception ex)
            {
                StringBuilder str   = new StringBuilder();
                Exception     inner = ex;
                while (inner != null)
                {
                    str.AppendLine(inner.Message);
                    inner = inner.InnerException;
                }
                json.IsSuccess = false;
                json.Msg       = str.ToString();

                str.AppendLine("跟踪:" + ex.StackTrace);
                LogHelper.Debug(str.ToString());
            }

            return(Json(json));
        }