Exemplo n.º 1
0
        public HttpResponseMessage SetMemberRole(string MemberCode, int RoleID, string ShopIDS)
        {
            var response = new MyHttpResponseMessage();

            response.apiNumber = "C015_MBController_SetMemberRole";
            var msg = "";

            try
            {
                var ShopIDSList = ShopIDS.ToArryList('_');
                if (ShopIDSList.Count == 0)
                {
                    response.SetContent(HttpStatus.error, "营业部不能为空", ShopIDSList.Count, ResponseType.josn);
                    return(response);
                }

                var role = new ORM.SqlSugar.Model.mb.mb_MemberRole();
                role.MemberCode = MemberCode;
                role.RoleID     = RoleID.ToInt32();
                var result = db.SqlServerClient.Ado.UseTran(() =>
                {
                    mb.mb_MemberRoleSugar.Insert(role);

                    foreach (var item in ShopIDSList)
                    {
                        var memberCrop        = new ORM.SqlSugar.Model.mb.mb_MemberCorp();
                        memberCrop.MemberCode = MemberCode;
                        memberCrop.CorpCode   = org.org_ShopSugar.GetById(item.ToInt32()).CorpCode;
                        memberCrop.ShopID     = item.ToInt32();
                        memberCrop.CreateTime = DateTime.Now;
                        mb.mb_MemberCorpSugar.Insert(memberCrop);
                    }
                });
                if (result.IsSuccess)
                {
                    response.SetContent(HttpStatus.ok, "分配成功", result, ResponseType.josn);
                }
                else
                {
                    response.SetContent(HttpStatus.error, "分配失败", result.ErrorMessage, ResponseType.josn);
                }
            }
            catch (Exception ex)
            {
                msg = "ERROR";
                AddErrorLog(LogEnum.org, ex.Message, ex.StackTrace);
                response.SetContent(HttpStatus.error, ex.Message, msg, ResponseType.josn);
            }
            return(response);
        }
Exemplo n.º 2
0
        public HttpResponseMessage VerifyJoinIn(string MemberCode, string JoinTime)
        {
            var response = new MyHttpResponseMessage();

            response.apiNumber = "C066_EQMController_VerifyJoinIn";
            var msg = "";

            try
            {
                var join = org.org_JoinInSugar.GetSingle(p => p.MemberCode == MemberCode && p.JoinTime == JoinTime.ToDateTime());
                if (join == null)
                {
                    response.SetContent(HttpStatus.error, "不存在这条记录", join, ResponseType.josn);
                    return(response);
                }
                join.Status = 1;

                var result = db.SqlServerClient.Ado.UseTran(() =>
                {
                    if (string.IsNullOrEmpty(join.CorpCode))
                    {
                        //创建企业
                        var corp              = new ORM.SqlSugar.Model.org.org_CorpMaster();
                        var CorpCode          = org.GetCorpCode(join.CorpProvince);
                        corp.CorpCode         = CorpCode;
                        corp.CorpName         = join.CorpName;
                        corp.SocialCreditCode = join.SocialCreditCode;
                        corp.RegisteredAddr   = join.CorpAddr;
                        join.CorpCode         = corp.CorpCode;
                        org.org_CorpMasterSugar.Insert(corp);
                    }
                    if (join.ShopID == 0)
                    {
                        //创建营业部
                        var shop            = new ORM.SqlSugar.Model.org.org_Shop();
                        shop.ShopName       = join.ShopName;
                        shop.Address        = join.CorpAddr;
                        shop.CorpCode       = join.CorpCode;
                        shop.DutyMemberCode = MemberCode;
                        var id      = org.org_ShopSugar.InsertReturnIdentity(shop);
                        join.ShopID = id;
                    }
                    var mc        = new ORM.SqlSugar.Model.mb.mb_MemberCorp();
                    mc.MemberCode = MemberCode;
                    mc.CorpCode   = join.CorpCode;
                    mc.ShopID     = join.ShopID.ToInt32();
                    mc.CreateTime = DateTime.Now;
                    mb.mb_MemberCorpSugar.Insert(mc);
                    org.org_JoinInSugar.Update(join);
                });
                if (result.IsSuccess)
                {
                    response.SetContent(HttpStatus.ok, "审核成功", join, ResponseType.josn);
                }
                else
                {
                    response.SetContent(HttpStatus.error, result.ErrorMessage, null, ResponseType.josn);
                }
            }
            catch (Exception ex)
            {
                msg = "ERROR";
                AddErrorLog(LogEnum.org, ex.Message, ex.StackTrace);
                response.SetContent(HttpStatus.error, ex.Message, msg, ResponseType.josn);
            }
            return(response);
        }
Exemplo n.º 3
0
        public HttpResponseMessage PayBalance(string MemberCode, string CardNo)
        {
            var response = new MyHttpResponseMessage();

            response.apiNumber = "C028_SysControllerr_PayBalance";
            try
            {
                if (CardNo.Contains("Card"))
                {
                    var Card  = mb.mb_CardList.GetById(CardNo);
                    var vCard = org.org_VirtualCardSugar.GetById(Card.VCardNo);


                    var wallet = mb.mb_WalletSugar.GetById(MemberCode);
                    if (wallet == null)
                    {
                        response.SetContent(HttpStatus.error, "没找到您的余额账户!", Card, ResponseType.josn);
                        return(response);
                    }
                    if (wallet.Balance < Card.Amount)
                    {
                        response.SetContent(HttpStatus.error, "您的余额不足,请充值!", Card, ResponseType.josn);
                        return(response);
                    }
                    var result = db.SqlServerClient.Ado.UseTran(() =>
                    {
                        var f = mb.FinshRecharg(Card, vCard);
                        if (f)
                        {
                            Card.Status  = 3;
                            Card.PayNo   = "Balance" + JVS_ADM.Common.Utils.GetRamCode();
                            Card.PayTime = DateTime.Now;
                            mb.mb_CardList.Update(Card);
                            var crdLog             = new ORM.SqlSugar.Model.crd.crd_BalanceLog();
                            crdLog.BalanceNo       = "Balance" + Utils.GetRamCode() + "";
                            crdLog.Balance         = -Card.Amount;
                            crdLog.OriginalBalance = -Card.Amount;
                            crdLog.DonationBalance = 0;
                            crdLog.BalanceID       = 0;
                            crdLog.MemberCode      = MemberCode;
                            crdLog.BalanceType     = 2;
                            crdLog.Remark          = "";
                            crdLog.TradeNo         = "";
                            crdLog.PayTime         = null;
                            crdLog.PayWay          = 0;
                            crdLog.Status          = 3;
                            crdLog.CreateDate      = DateTime.Now;
                            crd.crd_BalanceLogSQLSugar.Insert(crdLog);
                            wallet.Balance = wallet.Balance - Card.Amount;
                            mb.mb_WalletSugar.Update(wallet);
                            if (mb.mb_MemberCorpSugar.Count(p => p.MemberCode == Card.MemberCode && p.CorpCode == vCard.CorpCode) <= 0)
                            {
                                var mcorp        = new ORM.SqlSugar.Model.mb.mb_MemberCorp();
                                mcorp.CorpCode   = vCard.CorpCode;
                                mcorp.MemberCode = Card.MemberCode;
                                mcorp.ShopID     = 0;
                                mcorp.CreateTime = DateTime.Now;
                                mb.mb_MemberCorpSugar
                                .Insert(mcorp);
                            }
                        }
                    });

                    if (result.IsSuccess)
                    {
                        response.SetContent(HttpStatus.ok, "支付完成", Card, ResponseType.josn);
                        return(response);
                    }
                    else
                    {
                        response.SetContent(HttpStatus.error, "余额扣款失败", Card, ResponseType.josn);
                        return(response);
                    }
                }



                response.SetContent(HttpStatus.error, "余额支付失败", "", ResponseType.josn);
                return(response);
            }
            catch (Exception ex)
            {
                AddErrorLog(LogEnum.member, ex.Message, ex.StackTrace);
                response.SetContent(HttpStatus.error, ex.Message, ex.Message, ResponseType.josn);
                return(response);
            }
        }