Beispiel #1
0
        /// <summary>
        /// [main]获取目标微信的缓存,如果不存在则插入缓存
        /// 根据需要对其中的数据进行局部更新: WxAPI.Code_Get(appmod).AppId.WelStr = appmod.WelStr;
        /// </summary>
        public static WxAPI Code_Get(M_WX_APPID appMod)
        {
            if (appMod == null || appMod.ID < 1)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(appMod.APPID) || string.IsNullOrEmpty(appMod.Secret))
            {
                return(null);
            }
            WxAPI m_api = WXCodeList.FirstOrDefault(p => p.AppId.APPID.Equals(appMod.APPID) && p.AppId.Secret.Equals(appMod.Secret));

            if (m_api == null)
            {
                m_api = new WxAPI(appMod);
                string token = m_api.AccessToken;
                Code_Add(m_api);
            }
            else if (m_api.AppId.ID == 0)
            {
                WXCodeList.Remove(m_api);
                return(Code_Get(appMod));
            }
            return(m_api);
        }
Beispiel #2
0
 /// <summary>
 /// 如处理微信浏览器,但未登录,则自动注册或登录(按公众号)
 /// </summary>
 public static void AutoSync(string url, M_WX_APPID appMod = null)
 {
     if (DeviceHelper.GetBrower() == DeviceHelper.Brower.Micro)
     {
         B_User buser = new B_User();
         if (!buser.CheckLogin())
         {
             WxAPI  wxapi        = WxAPI.Code_Get();
             string redirect_uri = SiteConfig.SiteInfo.SiteUrl + "/user/wxuser.aspx";
             string api          = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + wxapi.AppId.APPID + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=" + url + "#wechat_redirect";
             HttpContext.Current.Response.Redirect(api);
         }
     }
 }
Beispiel #3
0
        private static void Code_Add(WxAPI apiMod)
        {
            if (apiMod.AppId == null || string.IsNullOrEmpty(apiMod.AppId.APPID) || string.IsNullOrEmpty(apiMod.AppId.Secret))
            {
                return;
            }
            //如果不存在则加入,否则更新
            WxAPI m_api = WXCodeList.FirstOrDefault(p => p.AppId.APPID.Equals(apiMod.AppId.APPID));

            if (m_api == null)
            {
                WXCodeList.Add(apiMod);
            }
            else
            {
                WXCodeList.Remove(m_api);
                WXCodeList.Add(apiMod);
            }
        }
Beispiel #4
0
        //支付成功时执行的操作
        private void PayOrder_Success(M_Payment pinfo, WxPayData result)
        {
            ZLLog.L(ZLEnum.Log.pay, PayPlat + " 支付单:" + result.GetValue("out_trade_no") + " 金额:" + result.GetValue("total_fee"));
            try
            {
                M_Order_PayLog paylogMod = new M_Order_PayLog();
                if (pinfo == null)
                {
                    throw new Exception("支付单不存在");
                }                                                    //支付单检测合为一个方法
                if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                {
                    throw new Exception("支付单状态不为未支付");
                }
                pinfo.Status        = (int)M_Payment.PayStatus.HasPayed;
                pinfo.PlatformInfo += PayPlat;
                pinfo.SuccessTime   = DateTime.Now;
                pinfo.PayTime       = DateTime.Now;
                pinfo.CStatus       = true;
                //1=100,
                double tradeAmt = Convert.ToDouble(result.GetValue("total_fee")) / 100;
                pinfo.MoneyTrue = tradeAmt;
                payBll.Update(pinfo);
                DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                foreach (DataRow dr in orderDT.Rows)
                {
                    M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                    OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                    //发送微信消息
                    ZoomLa.BLL.WxAPI wxapi = ZoomLa.BLL.WxAPI.Code_Get();
                    ZoomLa.BLL.User.Addon.B_UserAPP appBll = new ZoomLa.BLL.User.Addon.B_UserAPP();
                    ZoomLa.Model.User.M_UserAPP     appMod = appBll.SelModelByUid(orderMod.Userid, "wechat");
                    switch (orderMod.Ordertype)
                    {
                    case (int)M_OrderList.OrderEnum.Score://押金
                    {
                        if (appMod != null && !string.IsNullOrEmpty(appMod.OpenID))
                        {
                            //发送模板消息通知用户
                            string json = "{\"first\": {\"value\":\"订单支付成功\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + orderMod.OrderNo + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + orderMod.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"remark\":{\"value\":\"您的押金已成功支付!\",\"color\":\"#173177\"}}";
                            wxapi.Tlp_SendTlpMsg(appMod.OpenID, "dlAIEAkV0lgDfc7-RYsdLVFMyP9UF7gHi_9kjPblVAU", ZoomLa.Components.SiteConfig.SiteInfo.SiteUrl + "/BU/UE/MyLend.aspx", json);
                        }
                    }
                    break;

                    case (int)M_OrderList.OrderEnum.Purse://充值
                    {
                        if (appMod != null && !string.IsNullOrEmpty(appMod.OpenID))
                        {
                            //发送模板消息通知用户
                            string json = "{\"first\": {\"value\":\"订单支付成功\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + orderMod.OrderNo + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + orderMod.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"remark\":{\"value\":\"你已成功充值!\",\"color\":\"#173177\"}}";
                            wxapi.Tlp_SendTlpMsg(appMod.OpenID, "dlAIEAkV0lgDfc7-RYsdLVFMyP9UF7gHi_9kjPblVAU", ZoomLa.Components.SiteConfig.SiteInfo.SiteUrl + "/BU/UE/MyLend.aspx", json);
                        }
                    }
                    break;

                    case (int)M_OrderList.OrderEnum.Fast://借伞|转借
                        //{
                        //    //转借订单不需要还
                        //    if (orderMod.Promoter == 0) { break; }
                        //    ZoomLa.BLL.Shop.B_Store_Info storeBll = new ZoomLa.BLL.Shop.B_Store_Info();
                        //    ZoomLa.Model.Shop.M_Store_Info storeMod = storeBll.SelReturnModel(orderMod.StoreID);
                        //    if (storeMod != null && storeMod.UserID > 0)
                        //    {
                        //        appMod = appBll.SelModelByUid(storeMod.UserID,"wechat");
                        //        if (appMod != null && !string.IsNullOrEmpty(appMod.OpenID))
                        //        {
                        //            string json = "{\"first\": {\"value\":\"订单支付成功\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + orderMod.OrderNo + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + orderMod.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"remark\":{\"value\":\"用户押金已成功支付!\",\"color\":\"#173177\"}}";
                        //            wxapi.Tlp_SendTlpMsg(appMod.OpenID, "dlAIEAkV0lgDfc7-RYsdLVFMyP9UF7gHi_9kjPblVAU", ZoomLa.Components.SiteConfig.SiteInfo.SiteUrl + "/Class_2/NodePage.aspx", json);
                        //        }
                        //    }
                        //}
                        break;
                    }



                    /*
                     * B_UserAPP userappBll = new B_UserAPP();
                     * M_UserAPP userappMod = new M_UserAPP();
                     *
                     * M_UserInfo mu = buser.SeachByID(orderMod.Userid);
                     * userappMod = userappBll.SelModelByUid(mu.UserID, "wechat");
                     * if (userappMod != null)
                     * {
                     * WxAPI wxapi = WxAPI.Code_Get(1);
                     * string json = "{\"first\": {\"value\":\"订单支付成功\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + orderMod.OrderNo + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + orderMod.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"remark\":{\"value\":\"您的押金已成功支付!\",\"color\":\"#173177\"}}";
                     * wxapi.Tlp_SendTlpMsg(userappMod.OpenID, "dlAIEAkV0lgDfc7-RYsdLVFMyP9UF7gHi_9kjPblVAU", SiteConfig.SiteInfo.SiteUrl + "/BU/UE/MyLend.aspx", json);
                     * }
                     */
                    //发送消息给店主和送货员

                    /*
                     * if (orderMod.StoreID > 0)
                     * {
                     * B_Content contBll = new B_Content();
                     * M_CommonData CData = contBll.SelReturnModel(orderMod.StoreID);
                     * if (CData != null)
                     * {
                     * //店主
                     * M_UserInfo smu = buser.GetUserIDByUserName(CData.Inputer);
                     *              userappMod = userappBll.SelModelByUid(smu.UserID, "wechat");
                     * if (smu != null && smu.UserID > 0)
                     * {
                     * string json = "{\"first\": {\"value\":\"订单支付成功\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + orderMod.OrderNo + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + orderMod.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"remark\":{\"value\":\"用户押金已成功支付!\",\"color\":\"#173177\"}}";
                     *                      wxapi.Tlp_SendTlpMsg(userappMod.OpenID, "dlAIEAkV0lgDfc7-RYsdLVFMyP9UF7gHi_9kjPblVAU", SiteConfig.SiteInfo.SiteUrl + "/Class_2/NodePage.aspx", json);
                     * }
                     * }
                     * }
                     */
                    //if (orderMod.Ordertype == (int)M_OrderList.OrderEnum.Purse)
                    //{

                    //    M_UserInfo mu = buser.SelReturnModel(orderMod.Userid);
                    //    new B_Shop_MoneyRegular().AddMoneyByMin(mu, orderMod.Ordersamount, ",订单号[" + orderMod.OrderNo + "]");
                    //}
                    //orderCom.SendMessage(orderMod, paylogMod, "payed");
                    //orderCom.SaveSnapShot(orderMod);
                }
                ZLLog.L(ZLEnum.Log.pay, PayPlat + "成功!支付单:" + result.GetValue("out_trade_no").ToString());
            }
            catch (Exception ex)
            {
                ZLLog.L(ZLEnum.Log.pay, new M_Log()
                {
                    Action  = "支付回调报错",
                    Message = PayPlat + ",支付单:" + result.GetValue("out_trade_no").ToString() + ",原因:" + ex.Message
                });
            }
        }