public static string AccountClaimActPageList(int aid, int cardid, int AccountId, int comid)
        {
            int totalcount = 0;
            var aaid       = 0;
            var ret        = "";

            try
            {
                if (cardid != 0)
                {
                    //查询优惠券
                    MemberActivityData Activitydata  = new MemberActivityData();
                    Member_Activity    Activitymodel = Activitydata.GetMemberActivityById(aid);

                    if (Activitymodel != null)
                    {
                        if (Activitymodel.Runstate == false)
                        {
                            return(JsonConvert.SerializeObject(new { type = 1, msg = "活动已结束" }));
                        }
                        var today = DateTime.Now;

                        if (Activitymodel.Actstar < today && Activitymodel.Actend.AddDays(1) > today)
                        {
                        }
                        else
                        {
                            return(JsonConvert.SerializeObject(new { type = 1, msg = "活动已结束" }));
                        }
                    }


                    //每个活动只能领取一次,防止重复领取,
                    var listact = Activitydata.AccountActInfo(aid, AccountId, comid, out totalcount);
                    if (listact == null)
                    {
                        //领取活动
                        aaid = Activitydata.AccountClaimActPageList(aid, cardid, comid);
                        if (aaid != 0)
                        {
                            if (Activitymodel != null)
                            {
                                if (Activitymodel.Acttype == 4)//只有积分优惠券才会领取时充入积分
                                {
                                    MemberIntegralData intdate = new MemberIntegralData();
                                    Member_Integral    Intinfo = new Member_Integral()
                                    {
                                        Id        = AccountId,
                                        Comid     = comid,
                                        Acttype   = "add_integral",      //操作类型,增加积分
                                        Money     = Activitymodel.Money, //交易金额
                                        Admin     = "领取积分优惠券",
                                        Ip        = "",
                                        Ptype     = 1,
                                        Oid       = 0,
                                        Remark    = "",
                                        OrderId   = 0,
                                        OrderName = Activitymodel.Atitle
                                    };
                                    var InsertIntegral = intdate.InsertOrUpdate(Intinfo);

                                    //优惠券确认使用
                                    Member_Activity actinfo     = null;
                                    string          phone       = "";
                                    string          name        = "";
                                    decimal         idcard      = 0;
                                    decimal         aggcardcode = 0;

                                    MemberCardData carddata = new MemberCardData();
                                    var            confirm  = carddata.EconfirmCard(aaid, aid, cardid, comid, out actinfo, out phone, out name, out idcard, out aggcardcode);



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

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

                throw;
            }
        }
        public static string ERNIEZhongjiang(ERNIE_Record Recordinfo)
        {
            MemberERNIEData ernieddate = new MemberERNIEData();
            string          rtstr      = "";//返回文字

            try
            {
                var pror = ernieddate.ERNIERecordInfo(Recordinfo.Id);//查询中奖纪录
                if (pror != null)
                {
                    if (pror.Process_state == 0)
                    {
                        var pro = MemberERNIEData.ERNIEZhongjiang(Recordinfo);//中奖提交

                        if (pro > 0)
                        {
                            var proernie = MemberERNIEData.ERNIEGetActById(Recordinfo.ERNIE_id);//查询活动
                            if (proernie != null)
                            {
                                var prow = MemberERNIEData.ERNIEGetAwardById(pror.Awardid);//查询奖品纪录,成功状态修改为中奖奖品级别

                                if (prow != null)
                                {
                                    if (prow.Award_type == 2)//必须是赠送积分的才会自动赠送
                                    {
                                        //中奖状态修改,为已处理
                                        var prochuli = MemberERNIEData.ERNIEZhongjiangChuli(Recordinfo.Id);
                                        if (prochuli > 0)
                                        {
                                            //插入积分
                                            MemberIntegralData intdate = new MemberIntegralData();
                                            Member_Integral    Intinfo = new Member_Integral()
                                            {
                                                Id        = pror.ERNIE_uid,
                                                Comid     = proernie.Com_id,
                                                Acttype   = "add_integral",       //操作类型
                                                Money     = prow.Award_Get_Num,   //交易金额
                                                Admin     = proernie.Title,
                                                Ip        = CommonFunc.GetRealIP(),
                                                Ptype     = 1,
                                                Oid       = 0,
                                                Remark    = "",
                                                OrderId   = 0,
                                                OrderName = ""
                                            };
                                            pro = intdate.InsertOrUpdate(Intinfo);
                                            //抽奖赠送等积分
                                            B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog
                                            {
                                                id        = 0,
                                                crmid     = pror.ERNIE_uid,
                                                dengjifen = prow.Award_Get_Num,
                                                ptype     = 1,
                                                opertor   = "抽奖赠送等积分",
                                                opertime  = DateTime.Now,
                                                orderid   = 0,
                                                ordername = "抽奖赠送等积分",
                                                remark    = "抽奖赠送等积分"
                                            };
                                            new B2bCrmData().Adjust_dengjifen(djflog, pror.ERNIE_uid, proernie.Com_id, prow.Award_Get_Num);

                                            if (pro > 0)
                                            {
                                                rtstr = "您中奖的" + prow.Award_Get_Num + "元,已经打入您的积分中,请查收!";
                                            }
                                            else
                                            {
                                                rtstr = "中奖信息已经提交成功!";
                                            }
                                        }
                                        else
                                        {
                                            rtstr = "中奖信息已经提交成功!";
                                        }
                                    }
                                    else
                                    {
                                        rtstr = "中奖信息已经提交成功!";
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        return(JsonConvert.SerializeObject(new { rt = -1, msg = "中奖信息提交失败" }));
                    }
                    return(JsonConvert.SerializeObject(new { rt = 1, msg = rtstr }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new { rt = -1, msg = "中奖信息提交失败!" }));
                }
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { rt = -1, msg = ex.Message }));

                throw;
            }
        }
Exemple #3
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;
            }
        }