예제 #1
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="text">发送文本</param>
        /// <returns></returns>
        public string SendMessage(string text)
        {
            string paramData = "{";

            if (!string.IsNullOrEmpty(ToUserID))
            {
                paramData += "\"touser\": \"" + ToUserID + "\",";
            }
            if (!string.IsNullOrEmpty(ToPartyID))
            {
                paramData += "\"toparty\": \"" + ToPartyID + "\",";
            }
            if (!string.IsNullOrEmpty(ToTagID))
            {
                paramData += "\"totag\": \"" + ToTagID + "\",";
            }
            paramData += "\"msgtype\": \"text\",";
            paramData += "\"agentid\": \"" + AgentId + "\",";
            paramData += "\"text\": {\"content\": \"" + text + "\"},";
            paramData += "\"safe\":\"0\"";
            paramData += "}";

            Encoding dataEncode = Encoding.UTF8;

            WeiXinProvider provider    = EnvProvider.Default.WeiXinProvider;
            string         accessToken = GetAccessToken(provider.CorpId, provider.Secret);
            string         postUrl     = string.Format("https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={0}", accessToken);

            return(PostWebRequest(postUrl, paramData, dataEncode));
        }
예제 #2
0
        public string SendMessage(DataRow row)
        {
            string paramData = "{";

            paramData += "\"userid\": \"" + LibSysUtils.ToString(row["PERSONID"]) + "\",";
            paramData += "\"name\": \"" + LibSysUtils.ToString(row["PERSONNAME"]) + "\",";
            paramData += "\"department\": " + "[36]" + ",";
            paramData += "\"position\": \"" + LibSysUtils.ToString(row["POSITION"]) + "\",";
            paramData += "\"mobile\": \"" + LibSysUtils.ToString(row["PHONENO"]) + "\",";
            paramData += "\"gender\": \"" + LibSysUtils.ToInt32(row["GENDER"]) + "\",";
            paramData += "\"email\": \"" + LibSysUtils.ToString(row["MAIL"]) + "\",";
            paramData += "\"weixinid\": \"" + LibSysUtils.ToString(row["WECHAT"]) + "\",";
            paramData += "}";

            Encoding dataEncode = Encoding.UTF8;

            WeiXinProvider provider    = EnvProvider.Default.WeiXinProvider;
            string         accessToken = GetAccessToken(provider.CorpId, provider.Secret);
            string         postUrl     = string.Format("https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token={0}", accessToken);

            return(PostWebRequest(postUrl, paramData, dataEncode));
        }
예제 #3
0
        /// <summary>
        /// 驳回
        /// </summary>
        /// <param name="sysNo">编码</param>
        /// <returns>影响行数</returns>
        public JResult H5CashoutWeiXin(int sysNo, string certPath)
        {
            var response = new JResult()
            {
                Status = false
            };

            var cashout = Using <IFnCashout>().Get(sysNo);

            if (cashout == null)
            {
                response.Message = "记录不存在!";
                return(response);
            }

            var customer = Using <ICrCustomer>().Get(cashout.CustomerSysNo);

            if (customer == null)
            {
                response.Message = "会员不存在!";
                return(response);
            }
            if (string.IsNullOrEmpty(customer.OpenId))
            {
                response.Message = "会员openId为空!";
                return(response);
            }

            WeiXinProvider wx = new WeiXinProvider();

            var result = wx.Transfers(new TransfersRequest()
            {
                mch_appid        = "wx9535283296d186c3",
                mchid            = "1491518502",
                nonce_str        = "1213546623546",
                partner_trade_no = cashout.SysNo.ToString(),
                openid           = customer.OpenId,
                check_name       = customer.RealName,
                amount           = cashout.Amount,
                desc             = "代理商佣金提现",
                spbill_create_ip = WebUtil.GetUserIp(),
                apiKey           = "0bad12ce2b775367347d0b3a4bacd698",
                isUseCert        = true,
                cert             = certPath,
                password         = "******"
            });

            Log4Helper.WriteInfoLog("EC.H5 提现" + result.ToJson2(), "Cashout");

            if (result.return_code.ToUpper() == "SUCCESS" && result.result_code.ToUpper() == "SUCCESS")
            {
                response.Message = "操作成功!";
                response.Status  = true;
            }
            else
            {
                response.Message = result.return_msg + result.err_code_des;
            }

            return(response);
        }
예제 #4
0
        /// <summary>
        /// 驳回
        /// </summary>
        /// <param name="sysNo">编码</param>
        /// <returns>影响行数</returns>
        public JResult CashoutWeiXin(int sysNo, string certPath)
        {
            var response = new JResult()
            {
                Status = false
            };

            var cashout = Using <IFnCashout>().Get(sysNo);

            if (cashout == null)
            {
                response.Message = "记录不存在!";
                return(response);
            }

            if (cashout.Status != FnEnum.CashoutStatus.处理中.GetHashCode())
            {
                response.Message = "当前状态不能提现!";
                return(response);
            }

            var customer = Using <ICrCustomer>().Get(cashout.CustomerSysNo);

            if (customer == null)
            {
                response.Message = "会员不存在!";
                return(response);
            }
            if (string.IsNullOrEmpty(customer.OpenId))
            {
                response.Message = "会员openId为空!";
                return(response);
            }

            //<xml>
            //<return_code><![CDATA[SUCCESS]]></return_code>
            //<return_msg><![CDATA[]]></return_msg>
            //<mch_appid><![CDATA[wx9535283296d186c3]]></mch_appid>
            //<mchid><![CDATA[1491518502]]></mchid>
            //<nonce_str><![CDATA[1213546623546]]></nonce_str>
            //<result_code><![CDATA[SUCCESS]]></result_code>
            //<partner_trade_no><![CDATA[1111111223]]></partner_trade_no>
            //<payment_no><![CDATA[1000018301201805187873493468]]></payment_no>
            //<payment_time><![CDATA[2018-05-18 22:49:13]]></payment_time>
            //</xml>

            WeiXinProvider wx = new WeiXinProvider();

            var result = wx.Transfers(new TransfersRequest()
            {
                mch_appid        = "wx9535283296d186c3",
                mchid            = "1491518502",
                nonce_str        = "1213546623546",
                partner_trade_no = cashout.SysNo.ToString(),
                openid           = customer.OpenId,
                check_name       = customer.RealName,
                amount           = cashout.Amount,
                desc             = "代理商佣金提现",
                spbill_create_ip = WebUtil.GetUserIp(),
                apiKey           = "0bad12ce2b775367347d0b3a4bacd698",
                isUseCert        = true,
                cert             = certPath,
                password         = "******"
            });

            if (result.return_code.ToUpper() == "SUCCESS" && result.result_code.ToUpper() == "SUCCESS")
            {
                if (Using <IFnCashout>().UpdateStatus(sysNo, FnEnum.CashoutStatus.完成.GetHashCode(), "") <= 0)
                {
                    throw new Exception("修改数据失败");
                }

                response.Message = "操作成功!";
                response.Status  = true;
            }
            else
            {
                response.Message = result.return_msg + result.err_code_des;
            }

            return(response);
        }
예제 #5
0
        public JsonResult Cashout(CashoutRequest request)
        {
            var response = new JResult()
            {
                Status = false
            };

            var result = VHelper.ValidatorRule(
                new Rule_Number(request.Amount.ToString(), "请输入提现金额!")
                );

            if (!result.IsPass)
            {
                response.Status  = false;
                response.Message = result.Message;
                return(Json(response, JsonRequestBehavior.AllowGet));
            }

            lock (_lock)
            {
                Log4Helper.WriteInfoLog("EC.H5 提现" + result.ToJson2(), "Cashout");
                //当前上下文
                var context = CustomerContext.Context;
                if (context == null)
                {
                    response.Message = "用户已超时、请重新登录﹗";
                    return(Json(response, JsonRequestBehavior.AllowGet));
                }
                if (request.Amount <= 0)
                {
                    response.Message = "提现金额不能为零﹗";
                    return(Json(response, JsonRequestBehavior.AllowGet));
                }

                var periodList = FnCashoutApp.Instance.GetPeriodTimes(new FnCashoutQueryRequest()
                {
                    CustomerSysNo = context.SysNo,
                    StartTime     = DateTime.Now.ToString("yyyy-MM-dd 00:00:00"),
                    EndTime       = DateTime.Now.ToString("yyyy-MM-dd 23:59:59")
                });
                if (periodList != null && periodList.Any())
                {
                    response.Message = "每天只能提现一次﹗";
                    return(Json(response, JsonRequestBehavior.AllowGet));
                }
                //提现金额判断(100元的倍数)
                //var remainder = request.Amount % 100;
                //if (remainder != 0)
                //{
                //    response.Message = "提现金额必须为100的倍数﹗";
                //    return Json(response, JsonRequestBehavior.AllowGet);
                //}
                if (request.Amount < 10)
                {
                    response.Message = "提现金额必须为10元﹗";
                    return(Json(response, JsonRequestBehavior.AllowGet));
                }
                //验证是否填写银行卡
                if (request.CashoutType.Equals(FnEnum.CashoutType.银联.GetHashCode()))
                {
                    if (context.Bank <= 0 && context.BankNumber == "")
                    {
                        response.Message = "请设置银行卡";
                        return(Json(response, JsonRequestBehavior.AllowGet));
                    }
                }
                if (context.WalletAmount >= request.Amount)
                {
                    WeiXinProvider wx = new WeiXinProvider();

                    var certPath = Server.MapPath(@"\cert\apiclient_cert.p12");

                    decimal upgradeFundAmount = 0;

                    if (!context.Grade.Equals(CustomerEnum.Grade.股东.GetHashCode()))
                    {
                        upgradeFundAmount = request.Amount / 2;
                    }

                    response = FnCashoutApp.Instance.Cashout(new CashoutRequest()
                    {
                        CustomerSysNo     = context.SysNo,
                        WalletAmount      = request.Amount,
                        UpgradeFundAmount = upgradeFundAmount,
                        Account           = context.Account,
                        CashoutType       = request.CashoutType,
                        CertPath          = certPath
                    });
                }
                else
                {
                    response.Message = "当前余额不足﹗";
                    return(Json(response, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        /// <summary>
        /// 创建微信菜单(开发者模式使用)
        /// </summary>
        /// <returns>视图</returns>
        public ActionResult Index()
        {
            #region 菜单信息

            //var root1 = new MenuFull_RootButton { name = "千年大计" };

            //var root101 = new MenuFull_RootButton
            //{
            //    name = "公司介绍",
            //    type = "view",
            //    url = "http://www.1000n.com/about.html"
            //};
            //var root102 = new MenuFull_RootButton
            //{
            //    name = "软件下载",
            //    type = "view",
            //    url = "http://www.1000n.com"
            //};
            //var root103 = new MenuFull_RootButton
            //{
            //    name = "企业文化",
            //    type = "view",
            //    key = ""
            //};

            //root1.sub_button = new List<MenuFull_RootButton> { root101, root102, root103 };

            //var getMenuResultFull = new GetMenuResultFull
            //{
            //    menu = new MenuFull_ButtonGroup
            //    {
            //        button = new List<MenuFull_RootButton> { root1 }
            //    }
            //};

            ////获取微信 AccessToken
            //var accessToken = WeiXinHelper.GetAccessToken(_weixinAppId, _weixinAppSecret);


            //DeleteMenu(accessToken.access_token);
            //CreateMenu(accessToken.access_token, getMenuResultFull);

            #endregion
            WeiXinProvider wx = new WeiXinProvider();

            var accessTokenResponse = wx.GetAccessToken("wx9535283296d186c3", "543e75c11909f438c02870ecbab85f5d");
            if (accessTokenResponse.return_code.Equals(return_code.SUCCESS.ToString()) && accessTokenResponse.result_code.Equals(result_code.SUCCESS.ToString()))
            {
                var menu = @"
                {
                     ""button"":[
                      {
                           ""name"":""千年大计"",
                           ""sub_button"":[
                            {
                               ""type"":""view"",
                               ""name"":""公司介绍"",
                               ""url"":""http://www.1000n.com/about.html""
                            },
                            {
                               ""type"":""view"",
                               ""name"":""软件下载"",
                               ""url"":""http://www.1000n.com""
                            },
                            {
                               ""type"":""view"",
                               ""name"":""企业文化"",
                               ""key"":""http://www.1000n.com""
                            }]
                      }
                ]}";
                var createMenuResponse = wx.CreateMenu(accessTokenResponse.access_token, menu);
            }
            ViewBag.accessToken = accessTokenResponse.access_token;


            var accessToken = wx.GetAccessToken(_weixinAppId, _weixinAppSecret);

            ViewBag.accessToken = accessToken;
            return(View());
        }