/// <summary>
 /// 更新消息{消息}对象(即:一条记录
 /// </summary>
 public int Update(TemplateMsg templateMsg)
 {
     using (var dbContext = UnitOfWork.Get(Unity.ContainerName))
     {
         return(new TemplateMsgRepository(dbContext).Update(templateMsg));
     }
 }
Esempio n. 2
0
    /// <summary>
    /// 插入上一日的全球分红
    /// </summary>
    /// <param name="dtuser"></param>
    /// <param name="level"></param>
    /// <returns></returns>
    public bool InsertFenHongLastDay(DataTable dtuser, int level, int rmoney, bool shoudong)
    {
        bool   flag     = false;
        int    allmoney = AllMoneyToday();
        int    ucount   = dtuser.Rows.Count;
        int    avg      = 0;
        double levellv  = 0.0;

        switch (level)
        {
        case 3: levellv = cf.leave_1; break;

        case 4: levellv = cf.leave_2; break;

        case 5: levellv = cf.leave_3; break;
        }
        if (ucount > 0)   //有人分,才插入
        {
            if (shoudong) //是否手动分红
            {
                avg = rmoney;
            }
            else
            {
                avg = Convert.ToInt32(Round(Convert.ToDouble(allmoney * levellv / ucount), 0));//四舍五入取2位小数
            }
            //判断今日是否已经进行过分红操作,未分红,插入
            if (!isFengHongToday(level))
            {
                InsertAllMoneyToday(level, ucount, allmoney, avg);
                StringBuilder sql = new StringBuilder();
                sql.Append("insert into  T_AvgMoneyLastDay (userID,userlevel,AvgMoney,CreateTime) values ");
                DateTime    dt     = System.DateTime.Now;
                string      dtDate = dt.ToLongDateString().ToString();
                TemplateMsg tm     = new TemplateMsg();
                for (int i = 0; i < ucount; i++)
                {
                    int    uid     = Convert.ToInt32(dtuser.Rows[i]["nID"]);
                    string opendid = dtuser.Rows[i]["openid"].ToString();
                    string url     = "http://tv.gongxue168.com/wap/Global.aspx?uid=" + uid;
                    if (i == ucount - 1)//最后一个
                    {
                        sql.AppendLine("(" + uid + "," + level + "," + avg + ",'" + dt.ToString() + "')");
                    }
                    else
                    {
                        sql.AppendLine("(" + uid + "," + level + "," + avg + ",'" + dt.ToString() + "'),");
                    }

                    //微信模板,每日分红
                    tm.CommissionRemind(opendid, url, StringDelHTML.PriceToStringLow(avg), dtDate);
                }
                flag = her.ExecuteNonQuery(sql.ToString());
            } //昨日已分红
        }     //没人分
        return(flag);
    }
Esempio n. 3
0
    /// <summary>
    /// 推荐奖励提醒
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="fid"></param>
    /// <param name="money"></param>
    /// <param name="time"></param>
    public void YongJinMouban(int uid, int fid, int money, DateTime time)
    {
        TemplateMsg tm        = new TemplateMsg();
        string      url       = "http://tv.gongxue168.com/wap/Sales.aspx?uid=" + fid;
        string      sql1      = "select nickname from ML_Member where nID=" + uid;
        string      nickname  = her.ExecuteScalar(sql1) == null ? "" : her.ExecuteScalar(sql1).ToString();
        string      sql2      = "select openid from ML_Member where nID=" + fid;
        string      openid    = her.ExecuteScalar(sql2) == null ? "" : her.ExecuteScalar(sql2).ToString();
        string      longdate  = time.ToLongDateString().ToString();
        string      shorttime = time.ToShortTimeString().ToString();
        string      my        = StringDelHTML.PriceToStringLow(money);

        tm.NominateReward(openid, nickname, url, my, longdate + " " + shorttime);
    }
Esempio n. 4
0
    protected void ImgSrs_Click1(object sender, EventArgs e)
    {
        TemplateMsg tm     = new TemplateMsg();
        DateTime    dt     = System.DateTime.Now;
        string      dtDate = dt.ToLongDateString().ToString();

        for (int i = 0; i < 50; i++)
        {
            int       avg     = 1000 + i;
            DataTable table   = tj.GetUserByLevel(6);
            string    opendid = table.Rows[0]["openid"].ToString();
            string    url     = "http://tv.gongxue168.com/wap/Global.aspx?uid=" + table.Rows[0]["nID"].ToString();
            //微信模板,每日分红
            tm.CommissionRemind(opendid, url, StringDelHTML.PriceToStringLow(avg), dtDate);
        }
    }
Esempio n. 5
0
        /// <summary>
        /// 乘客支付完成
        /// 支付时间:20160511010101
        /// 支付金额:11.3元
        /// 支付类型:银联支付
        /// 点击查看详细信息
        /// </summary>
        /// <returns></returns>
        public static void PayNotify(string openid, string first, string key1, string key2, string key3)
        {
            var template = new TemplateMsg
            {
                touser      = openid,
                template_id = "zLahvh03lGYAgsGsJiGAkV8RxtKp1TNlyxrSO_c4kmE",
                data        = new TemplateNotes
                {
                    first    = new TemplateNote(first),
                    keyword1 = new TemplateNote(key1),
                    keyword2 = new TemplateNote(key2),
                    keyword3 = new TemplateNote(key3),
                    remark   = new TemplateNote("只是提醒,无需操作。")
                }
            };

            WeiXinService.SendTemplateMsg(template);
        }
Esempio n. 6
0
        /// <summary>
        /// 订单支付成功通知
        /// </summary>
        /// <param name="openid"></param>
        /// <param name="key1">订单商品</param>
        /// <param name="key2">订单编号</param>
        /// <param name="key3">支付金额</param>
        /// <param name="key4">支付时间</param>
        /// <param name="url">跳转链接</param>
        public static void PaySuccess(string openid, string key1, string key2, string key3, string key4, string url)
        {
            var template = new TemplateMsg
            {
                touser      = openid,
                template_id = "BLbaYmzPFrgDMNc-GlTHXQ33Q4OSDn1STBCDvNUNZj0",
                url         = url,
                data        = new TemplateNotes
                {
                    first    = new TemplateNote("尊敬的用户,您的订单已支付成功"),
                    keyword1 = new TemplateNote(key1),
                    keyword2 = new TemplateNote(key2),
                    keyword3 = new TemplateNote(key3),
                    keyword4 = new TemplateNote(key4),
                    remark   = new TemplateNote("感谢您对我们的关注及认可,点击详情可查看。")
                }
            };

            WeiXinService.SendTemplateMsg(template);
        }
Esempio n. 7
0
        /// <summary>
        /// 发送模版消息
        /// </summary>
        /// <param name="templateMsg">发送消息内容</param>
        /// <param name="config">配置</param>
        /// <returns>结果</returns>
        public static Result SendTemplateMessage <T>(TemplateMsg <T> templateMsg, Config config)
        {
            Result            res        = new Result();
            var               configData = config;
            string            url        = TenpayUtil.GetTemplateUrl(configData, false);
            var               strSendRes = HttpHelp.PostXmlToUrl(url, JsonConvert.SerializeObject(templateMsg));
            TemplateMsgResult sendRes    = JsonConvert.DeserializeObject <TemplateMsgResult>(strSendRes);

            res.IsSucceed = sendRes.ErrorMsg.Trim().ToLower() == "ok";
            res.Message   = sendRes.ErrorMsg;
            if (sendRes.ErrorCode == 40001)
            {
                string            url1        = TenpayUtil.GetTemplateUrl(configData, true);
                var               strSendRes1 = HttpHelp.PostXmlToUrl(url1, JsonConvert.SerializeObject(templateMsg));
                TemplateMsgResult sendRes1    = JsonConvert.DeserializeObject <TemplateMsgResult>(strSendRes1);
                res.IsSucceed = sendRes1.ErrorMsg.Trim().ToLower() == "ok";
                res.Message   = sendRes1.ErrorMsg;
            }
            return(res);
        }
Esempio n. 8
0
        //OPENTM207622205

        /// <summary>
        /// 推送提醒
        /// </summary>
        /// <param name="openid"></param>
        /// <param name="title">系统检测到您昨日未读经</param>
        /// <param name="content">您昨日未读书,请您及时补读</param>
        /// <param name="time">昨日</param>
        /// <param name="msg">点击打开账户,补读未读经</param>
        /// <param name="link">http://www.yuedujing.com/wx_login.aspx</param>
        /// <returns></returns>
        public bool SendRemind(string openid, string title, string content, string time, string msg, string link)
        {
            try
            {
                string templateId = "R-Ply-04h1bSfrtOcGZtetWcblblPAlgW9JmpBaFfeM";

                if (!AccessTokenContainer.CheckRegistered(appId))                                    //检查是否已经注册
                {
                    AccessTokenContainer.Register(appId, appSecret);                                 //如果没有注册则进行注册
                }
                string access_token = AccessTokenContainer.GetAccessTokenResult(appId).access_token; //AccessToken
                string link_url     = link;
                var    data         = new TemplateMsg()
                {
                    first    = new TemplateDataItem(title, "#000000"),
                    keyword1 = new TemplateDataItem(content, "#000000"),
                    keyword2 = new TemplateDataItem(time, "#000000"),
                    remark   = new TemplateDataItem(msg, "#0077ff")
                };

                //发送成功
                if (Send(openid, templateId, link_url, data))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteDebugLog("[wx push msg]:" + ex.Message + "," + ex.Source);
                return(false);
            }
        }
Esempio n. 9
0
        public ActionResult stopTmg(int appId, int TempMsgId, int PageType)
        {
            try
            {
                if (dzaccount == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙auth_null!" }, JsonRequestBehavior.AllowGet));
                }
                XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());
                if (app == null)
                {
                    return(Json(new { isok = false, msg = "未授权!" }, JsonRequestBehavior.AllowGet));
                }
                if (app.AppId.IsNullOrWhiteSpace())
                {
                    return(Json(new { isok = false, msg = "未授权!" }, JsonRequestBehavior.AllowGet));
                }
                Food miAppfood = FoodBLL.SingleModel.GetModel($"appId={appId}");

                int TmpId = 0;
                //获取当前小程序模板类型
                string typeSql = $" select type from xcxtemplate where id = {app.TId} ";
                int    temp    = Convert.ToInt32(DAL.Base.SqlMySql.ExecuteScalar(XcxAppAccountRelationBLL.SingleModel.connName, CommandType.Text, typeSql, null));

                if (temp == (int)TmpType.小程序电商模板 || temp == (int)TmpType.小程序电商模板测试)
                {
                    Store store = StoreBLL.SingleModel.GetModelByRid(app.Id) ?? new Store();
                    TmpId = store.Id;
                }
                else if (temp == (int)TmpType.小程序餐饮模板)
                {
                    Food store = FoodBLL.SingleModel.GetModel($" appId = {app.Id} ") ?? new Food();
                    TmpId = store.Id;
                }
                TemplateMsg miniapptemplatemsg = TemplateMsgBLL.SingleModel.GetModel(TempMsgId);
                if (miniapptemplatemsg == null)
                {
                    return(Json(new { isok = false, msg = "系统内置的模板Id错误!" }, JsonRequestBehavior.AllowGet));
                }
                //string msg = "";
                TemplateMsg_User newUserMsg = TemplateMsg_UserBLL.SingleModel.getModelByAppId(app.AppId, PageType, miniapptemplatemsg.Id);
                if (newUserMsg == null)
                {
                    return(Json(new { isok = false, msg = "未找到模板" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    newUserMsg.State = 0;//0为停用
                    bool isSuccess = TemplateMsg_UserBLL.SingleModel.Update(newUserMsg, "State");

                    //var isSuccess = _miniapptemplatemsg_userBll.stopTemplate(newUserMsg);
                    if (!isSuccess)
                    {
                        return(Json(new { isok = false, msg = "停用失败" }, JsonRequestBehavior.AllowGet));
                    }

                    //var _deleteResult = _msnModelHelper.deleteMyMsn(app.AppId, newUserMsg.TemplateId, ref msg);
                    //if (_deleteResult.errcode != 0)
                    //{
                    //    return Json(new { isok = false, msg = _deleteResult.errmsg }, JsonRequestBehavior.AllowGet);
                    //}
                }

                return(Json(new { isok = true, msg = "停用成功" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new { isok = false, msg = "网络忙,请重试" }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 10
0
        public ActionResult startTmg(int appId, int TempMsgId, int PageType)
        {
            try
            {
                if (dzaccount == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙auth_null!" }, JsonRequestBehavior.AllowGet));
                }
                XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());
                if (app == null)
                {
                    return(Json(new { isok = false, msg = "未授权!" }, JsonRequestBehavior.AllowGet));
                }
                if (app.AppId.IsNullOrWhiteSpace())
                {
                    return(Json(new { isok = false, msg = "未授权!" }, JsonRequestBehavior.AllowGet));
                }

                TemplateMsg miniapptemplatemsg = TemplateMsgBLL.SingleModel.GetModel(TempMsgId);
                if (miniapptemplatemsg == null)
                {
                    return(Json(new { isok = false, msg = "系统内置的模板Id错误!" }, JsonRequestBehavior.AllowGet));
                }
                int TmpId = 0;
                //获取当前小程序模板类型
                string typeSql = $" select type from xcxtemplate where id = {app.TId} ";
                int    temp    = Convert.ToInt32(DAL.Base.SqlMySql.ExecuteScalar(XcxAppAccountRelationBLL.SingleModel.connName, CommandType.Text, typeSql, null));

                if (temp == (int)TmpType.小程序电商模板 || temp == (int)TmpType.小程序电商模板测试)
                {
                    Store store = StoreBLL.SingleModel.GetModelByRid(app.Id) ?? new Store();
                    TmpId = store.Id;
                }
                else if (temp == (int)TmpType.小程序餐饮模板)
                {
                    Food store = FoodBLL.SingleModel.GetModel($" appId = {app.Id} ") ?? new Food();
                    TmpId = store.Id;
                }

                if (temp == (int)TmpType.小程序专业模板)
                {
                    int          industr      = app.VersionId;
                    FunctionList functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={temp} and VersionId={industr}");
                    if (functionList == null)
                    {
                        return(Json(new { isok = false, msg = "此功能未开启" }, JsonRequestBehavior.AllowGet));
                    }
                    MessageMgr messageMgr = new MessageMgr();
                    if (!string.IsNullOrEmpty(functionList.MessageMgr))
                    {
                        messageMgr = JsonConvert.DeserializeObject <MessageMgr>(functionList.MessageMgr);
                    }
                    if (messageMgr.TemplateMessage == 1)
                    {
                        return(Json(new { isok = false, msg = "请升级到更高版本才能开启此功能" }, JsonRequestBehavior.AllowGet));
                    }
                }

                string           msg        = "";
                TemplateMsg_User newUserMsg = TemplateMsg_UserBLL.SingleModel.getModelByAppId(app.AppId, PageType, miniapptemplatemsg.Id);
                if (newUserMsg == null)
                {
                    //往微信appid加模板消息

                    addResultModel _addResult = MsnModelHelper.addMsnToMy(app.AppId, miniapptemplatemsg.TitileId, miniapptemplatemsg.ColNums.Split(','), ref msg);
                    log4net.LogHelper.WriteInfo(GetType(), JsonConvert.SerializeObject(_addResult));


                    if (_addResult.errcode != 0)
                    {
                        return(Json(new { isok = false, msg = _addResult.errmsg, newUserMsg = newUserMsg }, JsonRequestBehavior.AllowGet));
                    }

                    newUserMsg       = new TemplateMsg_User();
                    newUserMsg.AppId = app.AppId;
                    //newUserMsg.TmpId = miAppfood.Id;
                    newUserMsg.TmpId      = TmpId;
                    newUserMsg.Ttypeid    = miniapptemplatemsg.Ttypeid;
                    newUserMsg.TmId       = miniapptemplatemsg.Id;
                    newUserMsg.ColNums    = miniapptemplatemsg.ColNums;
                    newUserMsg.TitleId    = miniapptemplatemsg.TitileId;
                    newUserMsg.State      = 1;                      //启用
                    newUserMsg.CreateDate = DateTime.Now;
                    newUserMsg.TemplateId = _addResult.template_id; //微信公众号内的模板Id
                    newUserMsg.TmgType    = miniapptemplatemsg.TmgType;

                    int result = Convert.ToInt32(TemplateMsg_UserBLL.SingleModel.Add(newUserMsg));
                    //var result = Convert.ToInt32(_miniapptemplatemsg_userBll.startTemplate(newUserMsg));

                    if (result <= 0)
                    {
                        return(Json(new { isok = false, msg = "启用失败" }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    newUserMsg.State = 1;
                    bool isSuccess = TemplateMsg_UserBLL.SingleModel.Update(newUserMsg, "State");

                    if (!isSuccess)
                    {
                        return(Json(new { isok = false, msg = "启用失败" }, JsonRequestBehavior.AllowGet));
                    }
                }

                return(Json(new { isok = true, msg = "启用成功" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new { isok = false, msg = "网络忙,请重试" }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 11
0
 /// <summary>
 /// 更新消息{消息}对象(即:一条记录
 /// </summary>
 public int Update(TemplateMsg templateMsg)
 {
     return(Update <TemplateMsg>(templateMsg));
 }
Esempio n. 12
0
 /// <summary>
 /// 添加消息{消息}对象(即:一条记录
 /// </summary>
 public long Add(TemplateMsg templateMsg)
 {
     return(Add <TemplateMsg>(templateMsg));
 }