Beispiel #1
0
        //初始会员密码
        public static string initialuser(int id, int comid)
        {
            var b2b      = new B2bCrmData();
            var phone    = b2b.Readuser(id, comid).Phone.ToString();
            var pass     = phone.Substring(5, 6).ToString();
            var name     = b2b.Readuser(id, comid).Name.ToString();
            var cardcode = b2b.Readuser(id, comid).Idcard.ToString();

            try
            {
                var prodata = new B2bCrmData();

                B2b_crm b2bcrm = new B2b_crm()
                {
                    Id        = id,
                    Com_id    = comid,
                    Password1 = pass
                };
                var pro = prodata.initialuser(b2bcrm);
                if (int.Parse(pro) == id)
                {
                    SendSmsHelper.GetMember_sms(phone, name, cardcode, pass, 0, "初始化密码", comid);
                }
                return(JsonConvert.SerializeObject(new { type = 100, msg = pro }));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message }));

                throw;
            }
        }
Beispiel #2
0
        public static string WriteMoney(int id, int comid, string acttype, string money, decimal orderid, string ordername, string remark = "")
        {
            try
            {
                //获得操作用户
                B2b_company_manageuser user    = UserHelper.CurrentUser();
                B2b_company            company = UserHelper.CurrentCompany;
                string username = user.Accounts;
                //获得IP
                string addressIP = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(0).ToString();
                int    pro       = 0;

                //判断金额有效性
                bool isNum = Domain_def.RegexValidate("^[0-9]*$", money);
                if (!isNum)
                {
                    return(JsonConvert.SerializeObject(new { type = 1, msg = "操作错误,金额只能包含数字" }));
                }

                //充等积分
                if (acttype == "add_dengjifen")
                {
                    B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog
                    {
                        id        = 0,
                        crmid     = id,
                        dengjifen = decimal.Parse(money),
                        ptype     = 1,
                        opertor   = user.Id.ToString(),
                        opertime  = DateTime.Now,
                        orderid   = int.Parse(orderid.ToString()),
                        ordername = ordername,
                        remark    = remark
                    };


                    pro = new B2bCrmData().Adjust_dengjifen(djflog, id, comid, decimal.Parse(money));
                    if (pro == 0)
                    {
                        return(JsonConvert.SerializeObject(new { type = 1, msg = "调整用户等积分失败" }));
                    }
                }
                //减等积分
                else if (acttype == "reduce_dengjifen")
                {
                    B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog
                    {
                        id        = 0,
                        crmid     = id,
                        dengjifen = 0 - decimal.Parse(money),
                        ptype     = 2,
                        opertor   = user.Id.ToString(),
                        opertime  = DateTime.Now,
                        orderid   = int.Parse(orderid.ToString()),
                        ordername = ordername,
                        remark    = remark
                    };


                    pro = new B2bCrmData().Adjust_dengjifen(djflog, id, comid, 0 - decimal.Parse(money));
                    if (pro == 0)
                    {
                        return(JsonConvert.SerializeObject(new { type = 1, msg = "调整用户等积分失败" }));
                    }
                }
                //充积分
                else if (acttype == "add_integral")
                {
                    MemberIntegralData intdate = new MemberIntegralData();
                    Member_Integral    Intinfo = new Member_Integral()
                    {
                        Id        = id,
                        Comid     = comid,
                        Acttype   = acttype,               //操作类型
                        Money     = decimal.Parse(money),  //交易金额
                        Admin     = username,
                        Ip        = addressIP,
                        Ptype     = 1,
                        Oid       = 0,
                        Remark    = "",
                        OrderId   = orderid,
                        OrderName = ordername
                    };
                    pro = intdate.InsertOrUpdate(Intinfo);
                    if (pro != 0)
                    {
                        //积分变动 触发等积分变动
                        B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog
                        {
                            id        = 0,
                            crmid     = id,
                            dengjifen = decimal.Parse(money),
                            ptype     = 1,
                            opertor   = user.Id.ToString(),
                            opertime  = DateTime.Now,
                            orderid   = int.Parse(orderid.ToString()),
                            ordername = ordername,
                            remark    = "后台调整积分引起等积分变动:" + remark
                        };
                        new B2bCrmData().Adjust_dengjifen(djflog, id, comid, decimal.Parse(money));



                        B2bCrmData prodata = new B2bCrmData();
                        var        list    = prodata.Readuser(Intinfo.Id, Intinfo.Comid);

                        //微信消息模板
                        if (list.Weixin != "")
                        {
                            new Weixin_tmplmsgManage().WxTmplMsg_CrmIntegralReward(list.Com_id, list.Weixin, "您好,积分已经打入您的账户", list.Idcard.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "活动赠送", Intinfo.Money.ToString(), list.Integral.ToString(), "如有疑问,请致电客服。");
                        }

                        SendSmsHelper.GetMember_sms(list.Phone, list.Name, list.Idcard.ToString(), list.Password1, Intinfo.Money, "充积分", comid);//发送短信
                    }
                }//减积分
                else if (acttype == "reduce_integral")
                {
                    MemberIntegralData intdate = new MemberIntegralData();
                    Member_Integral    Intinfo = new Member_Integral()
                    {
                        Id        = id,
                        Comid     = comid,
                        Acttype   = acttype,                  //操作类型
                        Money     = 0 - decimal.Parse(money), //交易金额
                        Admin     = username,
                        Ip        = addressIP,
                        Ptype     = 2,
                        Oid       = 0,
                        Remark    = "",
                        OrderId   = orderid,
                        OrderName = ordername
                    };
                    pro = intdate.InsertOrUpdate(Intinfo);
                    if (pro != 0)
                    {
                        ////积分变动 触发等积分变动
                        //B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog
                        //{
                        //    id = 0,
                        //    crmid = id,
                        //    dengjifen = 0-decimal.Parse(money),
                        //    ptype = 2,
                        //    opertor = user.Id.ToString(),
                        //    opertime = DateTime.Now,
                        //    orderid = int.Parse(orderid.ToString()),
                        //    ordername = ordername,
                        //    remark = "后台调整积分引起等积分变动:" + remark
                        //};
                        //new B2bCrmData().Adjust_dengjifen(djflog, id, comid, 0-decimal.Parse(money));



                        B2bCrmData prodata = new B2bCrmData();
                        var        list    = prodata.Readuser(Intinfo.Id, Intinfo.Comid);
                        //SendSmsHelper.GetMember_sms(list.Phone, list.Name, list.Idcard.ToString(), list.Password1, Intinfo.Money, "减积分", comid);//发送短信

                        if (list.Weixin != "")
                        {
                            new Weixin_tmplmsgManage().WxTmplMsg_CrmConsume(list.Com_id, list.Weixin, "名称", "使用积分", "会员卡号", list.Idcard.ToString(), DateTime.Now.ToString(), " 使用" + Intinfo.Money + " 积分,如有疑问,请致电客服。");
                        }
                    }
                }//充预付款
                else if (acttype == "add_imprest")
                {
                    MemberImprestData impdate = new MemberImprestData();
                    Member_Imprest    Impinfo = new Member_Imprest()
                    {
                        Id        = id,
                        Comid     = comid,
                        Acttype   = acttype,              //操作类型
                        Money     = decimal.Parse(money), //交易金额
                        Admin     = username,
                        Ip        = addressIP,
                        Ptype     = 1,
                        Oid       = 0,
                        Remark    = "",
                        OrderId   = orderid,
                        OrderName = ordername
                    };
                    pro = impdate.InsertOrUpdate(Impinfo);
                    if (pro != 0)
                    {
                        B2bCrmData prodata = new B2bCrmData();
                        var        list    = prodata.Readuser(Impinfo.Id, Impinfo.Comid);
                        //微信消息模板
                        if (list.Weixin != "")
                        {
                            new Weixin_tmplmsgManage().WxTmplMsg_CrmRecharge(list.Com_id, list.Weixin, "您好,已成功进行会员卡充值", "会员卡号", list.Idcard.ToString(), Impinfo.Money.ToString() + "元", "充值成功", "如有疑问,请致电客服。");
                        }
                        SendSmsHelper.GetMember_sms(list.Phone, list.Name, list.Idcard.ToString(), list.Password1, Impinfo.Money, "充预付款", comid);//发送短信
                    }
                }//减预付款
                else if (acttype == "reduce_imprest")
                {
                    MemberImprestData impdate = new MemberImprestData();
                    Member_Imprest    Impinfo = new Member_Imprest()
                    {
                        Id        = id,
                        Comid     = comid,
                        Acttype   = acttype,                  //操作类型
                        Money     = 0 - decimal.Parse(money), //交易金额
                        Admin     = username,
                        Ip        = addressIP,
                        Ptype     = 2,
                        Oid       = 0,
                        Remark    = "",
                        OrderId   = orderid,
                        OrderName = ordername
                    };
                    pro = impdate.InsertOrUpdate(Impinfo);
                    if (pro != 0)
                    {
                        B2bCrmData prodata = new B2bCrmData();
                        var        list    = prodata.Readuser(Impinfo.Id, Impinfo.Comid);
                        //SendSmsHelper.GetMember_sms(list.Phone, list.Name, list.Idcard.ToString(), list.Password1, Impinfo.Money, "减预付款", comid);//发送短信
                        if (list.Weixin != "")
                        {
                            new Weixin_tmplmsgManage().WxTmplMsg_CrmConsume(list.Com_id, list.Weixin, "名称", "使用预付款", "会员卡号", list.Idcard.ToString(), DateTime.Now.ToString(), " 使用" + Impinfo.Money + " 元预付款,如有疑问,请致电客服。");
                        }
                    }
                }
                else
                {
                    pro = 0;//正常操作返回0错误
                }

                return(JsonConvert.SerializeObject(new { type = 100, msg = pro }));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message }));

                throw;
            }
        }