Esempio n. 1
0
        public HttpResponseMessage CardCreate(string MemberCode, string CardCorpCode, string CardDescription, float CardFaceValues, decimal CardAmount, int CardDuerationDay, bool CardOnLine, int CardProductType, string BundleCardNo1, string BundleCardNo2, string BundleCardNo3, bool BundleType, string PictureURL, string ShopIDS, bool FirstUse, bool CanBundle, int BundleNumber1, int BundleNumber2, int BundleNumber3)
        {
            var response = new MyHttpResponseMessage();

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

            try
            {
                var VirtualCard       = new ORM.SqlSugar.Model.org.org_VirtualCard();
                var VirtualCardBelong = new ORM.SqlSugar.Model.org.org_VirtualCardBelong();

                VirtualCard.CorpCode    = CardCorpCode;
                VirtualCard.Description = CardDescription;
                VirtualCard.FaceValue   = CardFaceValues;
                VirtualCard.Amount      = CardAmount;
                VirtualCard.OnLine      = CardOnLine;
                VirtualCard.CanBundle   = CanBundle;

                if (BundleType)
                {
                    if (BundleCardNo1 == null && BundleCardNo2 == null && BundleCardNo3 == null)
                    {
                        response.SetContent(HttpStatus.error, "组合卡至少绑定一张卡", BundleType, ResponseType.josn);
                        return(response);
                    }

                    VirtualCard.BundleCardNo1 = BundleCardNo1;
                    VirtualCard.BundleCardNo2 = BundleCardNo2;
                    VirtualCard.BundleCardNo3 = BundleCardNo3;

                    VirtualCard.BundleNumber1 = BundleNumber1;
                    VirtualCard.BundleNumber2 = BundleNumber2;
                    VirtualCard.BundleNumber3 = BundleNumber3;

                    VirtualCard.DuerationDay = 0;
                    VirtualCard.ProductType  = 0;
                    VirtualCard.CardNo       = Utils.GetRamCode() + "_0";
                }
                else
                {
                    if (CardProductType == 0)
                    {
                        response.SetContent(HttpStatus.error, "非组合卡产品类型不能为0", CardProductType, ResponseType.josn);
                        return(response);
                    }
                    VirtualCard.BundleCardNo1 = null;
                    VirtualCard.BundleCardNo2 = null;
                    VirtualCard.BundleCardNo3 = null;

                    VirtualCard.BundleNumber1 = 0;
                    VirtualCard.BundleNumber2 = 0;
                    VirtualCard.BundleNumber3 = 0;

                    VirtualCard.DuerationDay = CardDuerationDay;
                    VirtualCard.ProductType  = CardProductType;
                    VirtualCard.CardNo       = Utils.GetRamCode() + "_" + CardProductType;
                }

                VirtualCard.BundleType  = BundleType;
                VirtualCard.PictureURL  = PictureURL;
                VirtualCard.CreatedTime = DateTime.Now;
                VirtualCard.MemberCode  = MemberCode;
                VirtualCard.FirstUse    = FirstUse;
                var list = ShopIDS.ToArryList('_');// "1_2_3_4"

                var result = db.SqlServerClient.Ado.UseTran(() =>
                {
                    foreach (var id in list)
                    {
                        VirtualCardBelong.ShopID = id.ToInt32();
                        VirtualCardBelong.CardNo = VirtualCard.CardNo;
                        org.org_VirtualCardBelongSugar.Insert(VirtualCardBelong);
                    }
                    org.org_VirtualCardSugar.Insert(VirtualCard);
                });

                if (result.IsSuccess)
                {
                    response.SetContent(HttpStatus.ok, "创建成功", VirtualCard, ResponseType.josn);
                }
                else
                {
                    response.SetContent(HttpStatus.error, result.ErrorMessage, result, 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);
        }
Esempio n. 2
0
        public HttpResponseMessage GetMealList(string MemberCode, string CardCorpCode, bool OnLine, bool isAPP, int ProductType)
        {
            var response = new MyHttpResponseMessage();

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

            try
            {
                var exp = Expressionable.Create <ORM.SqlSugar.Model.org.org_VirtualCard>();
                exp.And(p => p.OnLine == OnLine && p.CorpCode == CardCorpCode);
                var TypeResultList = new List <int>();
                var list1          = new List <object>();
                if (isAPP)
                {
                    if (ProductType != -1)
                    {
                        exp.And(p => p.ProductType == ProductType);
                    }
                }
                else
                {
                    var _types = mb.mb_Assets.GetList(p => p.MemberCode == MemberCode).Select(p => p.ProductType).ToList();
                    if (_types.Count > 0)
                    {
                        exp.And(p => (((_types.Contains(Convert.ToInt32(p.ProductType)) || p.ProductType == 0) && p.FirstUse == false || (!_types.Contains(Convert.ToInt32(p.ProductType)) || p.ProductType == 0) && p.FirstUse == true)));
                    }
                    else
                    {
                        exp.And(p => p.FirstUse == true);
                    }
                    if (ProductType != -1)
                    {
                        exp.And(p => p.ProductType == ProductType);
                    }
                }
                var           ado   = new ORM.SqlSugar.MySqlSugarClient();
                var           list  = ado.SqlServerClient.Queryable <ORM.SqlSugar.Model.org.org_VirtualCard>().Where(exp.ToExpression()).ToList();
                List <object> cards = new List <object>();

                foreach (var item in list)
                {
                    var name = pd.pd_ProductTypeSugar.GetList(p => p.ProductType == item.ProductType).Select(p => p.ProductTypeName).FirstOrDefault();
                    if (item.ProductType == 0)
                    {
                        name = "组合卡";
                    }
                    var CardNum1 = new ORM.SqlSugar.Model.org.org_VirtualCard();
                    var CardNum2 = new ORM.SqlSugar.Model.org.org_VirtualCard();
                    var CardNum3 = new ORM.SqlSugar.Model.org.org_VirtualCard();
                    if (item.BundleType.ToBool())
                    {
                        if (!string.IsNullOrEmpty(item.BundleCardNo1))
                        {
                            CardNum1 = org.org_VirtualCardSugar.GetById(item.BundleCardNo1);;
                        }
                        if (!string.IsNullOrEmpty(item.BundleCardNo2))
                        {
                            CardNum2 = org.org_VirtualCardSugar.GetById(item.BundleCardNo2);;
                        }
                        if (!string.IsNullOrEmpty(item.BundleCardNo3))
                        {
                            CardNum3 = org.org_VirtualCardSugar.GetById(item.BundleCardNo3);;
                        }
                    }
                    else
                    {
                        CardNum3 = CardNum2 = CardNum1 = null;
                    }
                    var rbj = new { Card = item, ProductTypeName = name, CardNum1 = CardNum1, CardNum2 = CardNum2, CardNum3 = CardNum3 };
                    cards.Add(rbj);
                }
                response.SetContent(HttpStatus.ok, "获取成功", cards, ResponseType.josn);
                return(response);
            }

            catch (Exception ex)
            {
                msg = "ERROR";
                AddErrorLog(LogEnum.org, ex.Message, ex.StackTrace);
                response.SetContent(HttpStatus.error, ex.Message, msg, ResponseType.josn);
            }
            return(response);
        }