示例#1
0
        /// <summary>
        /// 根据ID来查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public CommodityServiceInfo GetCommodity(string id)
        {
            //Code Change
            Func<string, Tuple<CommodityDiscountInfoCNb, float>> _codeChangeFunc = new WeShopSeviceOverride().CommodityInfoQueryOnceOpeFunc;

            //创建
            CommodityServiceInfo serInfo = new CommodityServiceInfo();
            float fDiscountValue = 1.0f;

            //单纯商品数据
            //dynamic item = shopCommodityDal.Query("id=@ID", new { ID = id }).ElementAt(0);
            Tuple<CommodityDiscountInfoCNb, float> tupResult = _codeChangeFunc(id);
            CommodityDiscountInfoCNb commItem = tupResult.Item1;
            fDiscountValue = tupResult.Item2;

            //Dynamic赋值
            serInfo.SCommodityInfo = commItem;
            serInfo.DiscountValue = fDiscountValue;

            //商品规格数据List
            IEnumerable<dynamic> itemOption = new WX_ShopCommodityOptionDAL().Query("CommodityID = @ID ORDER BY iOrder", new { ID = id });
            if (itemOption.Count() > 0)
            { //需要备注价格区间
                string maxPrice = itemOption.Max(x => x.Price * fDiscountValue).ToString();
                string minPrice = itemOption.Min(x => x.Price * fDiscountValue).ToString();

                //价格区间,最大值最小值相同,则只展示一个价位
                string strPriceInterval = maxPrice.Equals(minPrice) ? maxPrice : string.Format("{0} - {1}", minPrice, maxPrice);

                serInfo.SCommodityPriceInterVal = strPriceInterval;
            }
            else
            {
                serInfo.SCommodityPriceInterVal = serInfo.SCommodityInfo.DiscountPrice.ToString();
            }
            serInfo.SCommdityOptionInfo = itemOption;

            //商品图片信息
            IEnumerable<dynamic> PhotoDetail = photoDicDAL.Query("Source=@Source AND RelationID=@RelationID AND Flag IN (2,3) Order by iOrder",
                                new { Source = "commodity", RelationID = id });
            serInfo.SDicPhoto.Add(2, PhotoDetail.Where(x => x.Flag.Equals(2)).Select(x => x.Value.ToString()).ToArray());
            serInfo.SDicPhoto.Add(3, PhotoDetail.Where(x => x.Flag.Equals(3)).Select(x => x.Value.ToString()).ToArray());

            //商品运送方式
            serInfo.SPostType = commItem.PostType.Equals(0) ? ZZSCResource.PostOption(commItem.PostType) : commItem.PostPrice.ToString();

            return serInfo;
        }
示例#2
0
        public ActionResult TestNr()
        {
            var list = new WeShopSeviceOverride().CommodityInfoQueryByPage(1, 10, "-1", "测试");

            return Content(JsonConvert.SerializeObject(new { List = list }));
        }
示例#3
0
        /// <summary>
        /// 立即购买业务:Insert 表数据
        /// </summary>
        /// <param name="model"></param>
        public bool PlaceOrderOpe(PlaceOrderServiceInfo model, Func<WX_ZZSCOrderLineInfo, WX_ZZSCOrderLineInfo> funNa = null)
        {
            //Init
            List<string> listSql = new List<string>();
            List<object> listPar = new List<object>();

            //DAL
            WX_ZZSCBeOrderDAL beOrderDal = new WX_ZZSCBeOrderDAL();
            WX_ZZSCOrderLineDAL lineDal = new WX_ZZSCOrderLineDAL();

            //Result
            bool result = false;

            try
            {
                //1.ZZSCOrderLine表
                listSql.Add(beOrderDal.AddSQL());
                listPar.Add(model.beOrderInfo);

                //2.ZZSCBeOrder表
                foreach (var item in model.beOrderLineList)
                {
                    if (funNa == null) { funNa = new WeShopSeviceOverride().PlaceOrderOpe; }

                    listSql.Add(lineDal.AddSQL());
                    listPar.Add(funNa(item));
                }

                //执行
                result = beOrderDal.ExecuteTran(listSql, listPar);
            }
            catch (Exception ex)
            {
                result = false;
                LogFileHelper.WriteLogByTxt("立即购买:PlaceOrderOpe方法执行失败:" + ex.Message);
            }

            return result;
        }