コード例 #1
0
        /// <summary>
        /// 保存商品规格
        /// </summary>
        /// <param name="user"></param>
        /// <param name="specName"></param>
        /// <param name="specValues"></param>
        /// <returns></returns>
        public JsonResult SaveSpecName(SysUser user, SpecName specName, string specValues)
        {
            //属性值集合
            string[] arr_val = null;
            if (specValues != null && specValues.IndexOf(",") != -1)
            {
                specValues = specValues.Replace(",", ",");
            }
            arr_val = StringHelper.StringToArray(specValues);

            if (specName.id == 0)
            {
                specName.created_user_id = user.id;
                specName.created_date    = DateTime.Now;
            }
            else
            {
                specName.updated_user_id = user.id;
                specName.updated_date    = DateTime.Now;
            }

            //保存
            StateCode state = ServiceIoc.Get <SpecNameService>().Save(specName, arr_val);

            return(Json(GetResult(state)));
        }
コード例 #2
0
        /// <summary>
        /// 获取规格详情
        /// </summary>
        /// <param name="specset"></param>
        /// <returns></returns>
        public string GetSkuMsg(string specset)
        {
            StringBuilder sb = new StringBuilder();

            string[] arr = StringHelper.StringToArray(specset);

            using (ISession s = SessionFactory.Instance.CreateSession())
            {
                foreach (string i in arr)
                {
                    int specname_id  = 0;
                    int specvalue_id = 0;
                    if (i.IndexOf("_") != -1)
                    {
                        int.TryParse(i.Split('_')[0], out specname_id);
                        int.TryParse(i.Split('_')[1], out specvalue_id);

                        SpecName  specname  = s.Get <SpecName>("where id = @0 ", specname_id);
                        SpecValue specvalue = s.Get <SpecValue>("where id = @0 ", specvalue_id);

                        if (specname != null && specvalue != null)
                        {
                            sb.Append(string.Format("{0}:{1}; ", specname.name, specvalue.val));
                        }
                        else
                        {
                            throw new Exception("商品规格信息异常");
                        }
                    }
                }

                return(sb.Length > 0 ? sb.Remove(sb.Length - 1, 1).ToString() : null);
            }
        }
コード例 #3
0
 public Stirrup(string name, double fy, double ds, int ns, double ss, SpecName spec = SpecName.D60V2004)
 {
     Fy      = fy;
     Name    = name;
     Num     = ns;
     this.ds = ds;
     Sv      = ss;
     Spec    = spec;
 }
コード例 #4
0
 public Reinforcement(string name, double fy, double ds, int ns, double locY, double locZ, SpecName spec = SpecName.D60V2004)
 {
     Fy        = fy;
     Name      = name;
     Num       = ns;
     this.ds   = ds;
     this.locY = locY;
     this.locZ = locZ;
     Spec      = spec;
 }
コード例 #5
0
 public Reinforcement(string v)
 {
     Name      = v;
     Fy        = double.Parse(v.Substring(v.Length - 3, 3));
     Num       = 1;
     this.ds   = 32;
     this.locY = 0;
     this.locZ = 0;
     Spec      = SpecName.D60V2004;
 }
コード例 #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id.GetHashCode();
         hashCode = (hashCode * 397) ^ IsDel.GetHashCode();
         hashCode = (hashCode * 397) ^ (SpecCode != null ? SpecCode.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SpecName != null ? SpecName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (EducProgram != null ? EducProgram.GetHashCode() : 0);
         return(hashCode);
     }
 }
コード例 #7
0
 public static string FriendlyName(this SpecName spec)
 {
     return(spec switch
     {
         SpecName.Bard => "Bard",
         SpecName.Crafter => "Crafter",
         SpecName.Mage => "Mage",
         SpecName.Powerplayer => "Power Player",
         SpecName.Ranger => "Ranger",
         SpecName.Warrior => "Warrior",
         SpecName.Thief => "Thief",
         _ => "None"
     });
コード例 #8
0
 /// <summary>
 /// 创建混凝土材料
 /// </summary>
 /// <param name="value">立方体抗压强度(国标)或圆柱体抗压强度(其他)(MPa)</param>
 /// <param name="name">材料名称</param>
 /// <param name="spec">规范体系</param>
 public ConcreteAASHTO(string name, double value, SpecName spec = SpecName.D60V2004)
 {
     Name = name;
     if (spec == SpecName.D60V2004)
     {
         Fck_cube     = value;
         Fck_cylinder = 0;
     }
     else
     {
         Fck_cylinder = value;
         Fck_cube     = 0;
     }
     Spec = spec;
 }
コード例 #9
0
 public static double GetBonusFor(Mobile m, SpecName name) =>
 m is PlayerMobile mobile?mobile.Spec.GetBonusFor(name) : 1.0;
コード例 #10
0
 //constructor needs a reference to the parent playermobile obj.
 public Spec(Mobile parent)
 {
     m_Parent  = parent;
     SpecName  = SpecName.None;
     SpecLevel = 0;
 }
コード例 #11
0
        /// <summary>
        /// 加入购物车
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="product_id"></param>
        /// <param name="specset"></param>
        /// <param name="qty"></param>
        /// <returns></returns>
        public StateCode Join(long user_id, long product_id, string specset, int qty)
        {
            using (ISession s = SessionFactory.Instance.CreateSession())
            {
                try
                {
                    //商品SKU
                    ProductSku sku = s.Get <ProductSku>("where product_id = @0 and dbo.fn_check_specset(specset,@1) = 1 ", product_id, specset ?? "");

                    //商品已删除
                    Product product = s.Get <Product>("where id = @0 ", sku.product_id);
                    if (product == null)
                    {
                        return(StateCode.State_501);
                    }

                    //商品已下架
                    if (!((bool)product.is_shelves && !(bool)product.is_delete && (DateTime.Now > product.shelves_sdate && DateTime.Now < product.shelves_edate)))
                    {
                        return(StateCode.State_505);
                    }

                    s.StartTransaction();

                    //购买数量大于0
                    if (qty > 0 || qty == -1)
                    {
                        //规格详细信息
                        StringBuilder sb = new StringBuilder();

                        //是否开启规格
                        if (product.is_open_spec)
                        {
                            string[] arr = StringHelper.StringToArray(sku.specset);
                            foreach (string i in arr)
                            {
                                int specname_id  = 0;
                                int specvalue_id = 0;
                                if (i.IndexOf("_") != -1)
                                {
                                    int.TryParse(i.Split('_')[0], out specname_id);
                                    int.TryParse(i.Split('_')[1], out specvalue_id);

                                    SpecName  specname  = s.Get <SpecName>("where id = @0 ", specname_id);
                                    SpecValue specvalue = s.Get <SpecValue>("where id = @0 ", specvalue_id);

                                    if (specname != null && specvalue != null)
                                    {
                                        if (sb.Length == 0)
                                        {
                                            sb.Append(string.Format("{0}:{1}", specname.name, specvalue.val));
                                        }
                                        else
                                        {
                                            sb.Append(string.Format(",{0}:{1}", specname.name, specvalue.val));
                                        }
                                    }
                                    else
                                    {
                                        throw new Exception("商品规格信息异常");
                                    }
                                }
                            }
                        }

                        string img_url = "";
                        Img    img     = s.Get <Img>(" where biz_type = @0 and biz_id = @1 and is_main = @2", ImgType.Product_Cover, sku.product_id, true);
                        if (img != null)
                        {
                            if (img.is_webimg)
                            {
                                img_url = img.webimg_url;
                            }
                            else
                            {
                                img.visit_path = img.visit_path.Replace("/Image/", "/Thm_Image/");
                                img_url        = img.domain_name + img.visit_path + img.file_name + img.extend_name;
                            }
                        }

                        //当前购物车信息
                        ShoppingCart shoppingcart = s.Get <ShoppingCart>("where user_id = @0 and dbo.fn_check_specset(specset,@1) = 1 and product_id = @2", user_id, sku.specset, product_id);

                        if (shoppingcart != null)
                        {
                            shoppingcart.product_img_url = img_url;
                            shoppingcart.count          += qty;
                            shoppingcart.market_price    = product.market_price;
                            shoppingcart.product_price   = sku.sale_price;
                            shoppingcart.product_name    = product.name;
                            shoppingcart.weight          = sku.weight;
                            shoppingcart.updated_date    = DateTime.Now;
                            s.Update <ShoppingCart>(shoppingcart);
                        }
                        else
                        {
                            shoppingcart = new ShoppingCart()
                            {
                                user_id         = user_id,
                                product_id      = sku.product_id,
                                market_price    = product.market_price,
                                product_price   = sku.sale_price,
                                product_name    = product.name,
                                product_en_name = product.en_name,
                                weight          = sku.weight,
                                specset         = sku.specset,
                                spec_msg        = sb.ToString(),
                                product_img_url = img_url,
                                count           = qty,
                                created_date    = DateTime.Now,
                                updated_date    = DateTime.Now
                            };
                            s.Insert <ShoppingCart>(shoppingcart);
                        }
                    }

                    s.Commit();
                    return(StateCode.State_200);
                }
                catch (Exception ex)
                {
                    s.RollBack();
                    return(StateCode.State_500);
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// 新增定单
        /// </summary>
        /// <param name="orderProduct"></param>
        /// <param name="isShoppingCart"></param>
        /// <param name="productOrder"></param>
        /// <param name="addressID"></param>
        /// <returns></returns>
        public StateCode Save(List <JsonOrderProduct> orderProduct, ProductOrder productOrder, long addressID, bool isShoppingCart)
        {
            string  freight_str    = "";
            decimal freight        = 0;
            long    deliveryModeID = 0;

            //如果是自提则不计算运费
            if (productOrder.logistic_method == 0)
            {
                StateCode code = ServiceIoc.Get <DeliveryModeService>().GetDefaultFreight(orderProduct, addressID, out freight_str);
                if (code != StateCode.State_200)
                {
                    return(code);
                }
                //运费
                freight = decimal.Parse(freight_str.Split('#')[1]);
                //运费模板ID
                deliveryModeID = int.Parse(freight_str.Split('#')[0]);
            }

            using (ISession s = SessionFactory.Instance.CreateSession())
            {
                try
                {
                    s.StartTransaction();

                    //订单商品较验
                    foreach (var op in orderProduct)
                    {
                        //较验商品规格是否存在
                        ProductSku sku = s.Get <ProductSku>("where product_id = @0 and dbo.fn_check_specset(specset,@1) = 1 ", op.product_id, op.specset);
                        if (sku == null)
                        {
                            productOrder = null;
                            s.RollBack();
                            return(StateCode.State_1);
                        }

                        //较验商品是否存在
                        Product product = s.Get <Product>("where id = @0 ", sku.product_id);
                        if (product == null)
                        {
                            productOrder = null;
                            s.RollBack();
                            return(StateCode.State_1);
                        }

                        //较验商品库存
                        if (op.qty > sku.stock)
                        {
                            productOrder = null;
                            s.RollBack();
                            return(StateCode.State_502);
                        }

                        //较验商品状态
                        if (!((bool)product.is_shelves && !(bool)product.is_delete && (DateTime.Now > product.shelves_sdate && DateTime.Now < product.shelves_edate)))
                        {
                            productOrder = null;
                            s.RollBack();
                            return(StateCode.State_505);
                        }

                        //商品库存处理
                        sku.stock = sku.stock - op.qty;
                        s.Update <ProductSku>(sku);
                    }

                    //创建订单
                    productOrder.serial_no        = AlgorithmHelper.CreateNo();
                    productOrder.status           = OrderStatus.WaitingPayment;
                    productOrder.delete_status    = 0;
                    productOrder.created_date     = DateTime.Now;
                    productOrder.total_amount     = 0;
                    productOrder.actual_amount    = 0;
                    productOrder.cost_price       = 0;
                    productOrder.delivery_mode_id = deliveryModeID;
                    s.Insert <ProductOrder>(productOrder);

                    //总金额,成本价,优惠卷金额
                    decimal totalProdutPrice = 0, costProdutPrice = 0;

                    //商品的总重量,包邮商品的总重量
                    int total_weight = 0, sum_total_weight = 0;

                    int index = 0;

                    foreach (var op in orderProduct)
                    {
                        //商品规格
                        ProductSku sku = s.Get <ProductSku>("where product_id = @0 and dbo.fn_check_specset(specset,@1) = 1", op.product_id, op.specset);
                        //商品
                        Product product = s.Get <Product>(sku.product_id);

                        string[]      arr      = StringHelper.StringToArray(sku.specset);
                        StringBuilder specinfo = new StringBuilder();
                        foreach (string i in arr)
                        {
                            int specname_id  = 0;
                            int specvalue_id = 0;
                            if (i.IndexOf("_") != -1)
                            {
                                int.TryParse(i.Split('_')[0], out specname_id);
                                int.TryParse(i.Split('_')[1], out specvalue_id);

                                SpecName  specname  = s.Get <SpecName>("where id = @0 ", specname_id);
                                SpecValue specvalue = s.Get <SpecValue>("where id = @0 ", specvalue_id);

                                if (specname != null && specvalue != null)
                                {
                                    specinfo.Append(string.Format("{0}:{1}; ", specname.name, specvalue.val));
                                }
                                else
                                {
                                    throw new Exception("商品规格信息异常");
                                }
                            }
                        }

                        //当前当商品成本
                        decimal cost_sum = sku.cost_price * op.qty;

                        //押金
                        decimal sum = sku.sale_price * op.qty;

                        totalProdutPrice += sum;
                        costProdutPrice  += cost_sum;

                        //该商品是否包邮
                        if (!product.is_postage)
                        {
                            sum_total_weight += sku.weight * op.qty;
                        }

                        //计算重量
                        total_weight += sku.weight * op.qty;

                        //获取产品主图片
                        string     mainPic  = "";
                        List <Img> pictures = s.List <Img>("where biz_type = @0 and biz_id = @1", ImgType.Product_Cover, product.id);
                        Img        img      = pictures.Where(p => p.is_main).SingleOrDefault();
                        if (img != null)
                        {
                            mainPic = img.is_webimg ? img.webimg_url : img.getThmImgUrl();
                        }

                        //创建订单明细
                        ProductOrderDetail orderDetail = new ProductOrderDetail()
                        {
                            order_id        = productOrder.id,
                            product_id      = product.id,
                            specset         = op.specset,
                            product_name    = product.name,
                            product_en_name = product.en_name,
                            product_img_url = mainPic,
                            spec_msg        = specinfo.ToString().Trim(),
                            unit_price      = sku.sale_price,
                            count           = op.qty,
                            total_weight    = sku.weight * op.qty,
                            order_index     = ++index,
                            cost_price      = cost_sum,
                            total_amount    = sum,
                            actual_amount   = sum
                        };
                        s.Insert(orderDetail);

                        //购物车删除商品
                        if (isShoppingCart)
                        {
                            s.ExcuteUpdate("delete tb_ord_shoppingcart where user_id = @0 and product_id = @1 and dbo.fn_check_specset(specset,@2) = 1", productOrder.created_user_id, orderDetail.product_id, orderDetail.specset ?? "");
                        }
                    }

                    #region 会员折扣模块

                    //会员折扣优惠金额
                    decimal discount = 0;
                    //累计消费金额
                    object user_total_amount = s.ExecuteScalar("select COALESCE(SUM(total_amount),0) from tb_odr_order where created_user_id = @0 and is_pay = @1", productOrder.created_user_id, true);
                    //累计消费金额
                    decimal amount = decimal.Parse(user_total_amount.ToString());

                    //获取等级列表
                    List <MemberLevelSetting> levels = s.List <MemberLevelSetting>("order by total_amount desc");
                    foreach (var level in levels)
                    {
                        if (amount >= level.total_amount)
                        {
                            discount = totalProdutPrice * (100 - level.discount) / 100;
                            break;
                        }
                    }

                    //会员折扣
                    productOrder.discount_amount = discount;
                    #endregion

                    #region 优惠卷模块

                    if (productOrder.user_coupon_id != 0)
                    {
                        //存在未使用的优惠卷
                        string     coupon_sql = "where id = @0 and is_used = @1 and full_amount <= @2";
                        UserCoupon userCoupon = s.Get <UserCoupon>(coupon_sql, productOrder.user_coupon_id, false, totalProdutPrice);
                        if (userCoupon != null)
                        {
                            //优惠卷金额
                            productOrder.coupon_amount = userCoupon.coupon_amount;
                            //修改会员优惠卷状态
                            s.ExcuteUpdate("update tb_user_aty_coupon set is_used = @0 where id = @1", true, userCoupon.id);
                        }
                    }

                    #endregion

                    #region 发货单

                    ShoppingAddress sa = s.Get <ShoppingAddress>(addressID);
                    if (sa == null)
                    {
                        throw new Exception("收货地址不存在");
                    }

                    //订单发货信息
                    OrderDelivery orderDelivery = new OrderDelivery();
                    orderDelivery.order_id    = productOrder.id;
                    orderDelivery.province    = sa.province;
                    orderDelivery.city        = sa.city;
                    orderDelivery.area        = sa.area;
                    orderDelivery.address     = sa.address;
                    orderDelivery.contact     = sa.contact;
                    orderDelivery.mobile      = sa.mobile;
                    orderDelivery.postal_code = sa.postal_code;
                    orderDelivery.tel         = sa.tel;

                    s.Insert <OrderDelivery>(orderDelivery);
                    #endregion

                    //总计金额(商品总金额+物流费用)
                    var totalPrice = totalProdutPrice + freight;
                    //成本价
                    productOrder.cost_price = costProdutPrice;
                    //配送费
                    productOrder.freight = freight;
                    //总金额
                    productOrder.total_amount = totalPrice;
                    //实付金额
                    productOrder.actual_amount = totalPrice - productOrder.coupon_amount - discount;
                    //总重量
                    productOrder.total_weight = total_weight;
                    //更新订单
                    s.Update <ProductOrder>(productOrder);

                    s.Commit();

                    return(StateCode.State_200);
                }
                catch (Exception ex)
                {
                    s.RollBack();
                    return(StateCode.State_500);
                }
            }
        }
コード例 #13
0
ファイル: MobaItemSpecs.cs プロジェクト: kojosamwoode/MOBA2
 public MobaItemSpecs(SpecName name, int value)
 {
     specName  = name;
     specValue = value;
 }