/// <summary> /// 判断当前节点是否已存在相同的 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int ExistNum(OrderAddressEntity entity) { ///id=0,判断总数,ID>0判断除自己之外的总数 string sql = @"Select count(1) from dbo.[OrderAddress] WITH(NOLOCK) "; string where = "where "; if (entity.Id == 0) { where = where + " (AccepterName=@AccepterName) "; where = where + " (CountryName=@CountryName) "; } else { where = where + " id<>@Id and (AccepterName=@AccepterName) "; where = where + " id<>@Id and (CountryName=@CountryName) "; } sql = sql + where; DbCommand cmd = db.GetSqlStringCommand(sql); if (entity.Id > 0) { db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id); } db.AddInParameter(cmd, "@AccepterName", DbType.String, entity.AccepterName); db.AddInParameter(cmd, "@CountryName", DbType.String, entity.CountryName); object identity = db.ExecuteScalar(cmd); if (identity == null || identity == DBNull.Value) { return(0); } return(Convert.ToInt32(identity)); }
/// <summary> /// 插入一条记录到表OrderAddress,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="orderAddress">待插入的实体对象</param> public int AddOrderAddress(OrderAddressEntity entity) { string sql = @"insert into OrderAddress( [OrderCode],[AccepterName],[CtType],[CountryCode],[CountryName],[ProvinceId],[CityId],[DistrictIdId],[Address],[Postcode],[Telephone],[MobilePhone],[IsDefault],[Sort])VALUES ( @OrderCode,@AccepterName,@CtType,@CountryCode,@CountryName,@ProvinceId,@CityId,@DistrictId,@Address,@Postcode,@Telephone,@MobilePhone,@IsDefault,@Sort); SELECT SCOPE_IDENTITY();" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@OrderCode", DbType.Int32, entity.OrderCode); db.AddInParameter(cmd, "@AccepterName", DbType.String, entity.AccepterName); db.AddInParameter(cmd, "@CtType", DbType.Int32, entity.CtType); db.AddInParameter(cmd, "@CountryCode", DbType.String, entity.CountryCode); db.AddInParameter(cmd, "@CountryName", DbType.String, entity.CountryName); db.AddInParameter(cmd, "@ProvinceId", DbType.String, entity.ProvinceId); db.AddInParameter(cmd, "@CityId", DbType.String, entity.CityId); db.AddInParameter(cmd, "@DistrictIdId", DbType.String, entity.DistrictId); db.AddInParameter(cmd, "@Address", DbType.String, entity.Address); db.AddInParameter(cmd, "@Postcode", DbType.String, entity.Postcode); db.AddInParameter(cmd, "@Telephone", DbType.String, entity.Telephone); db.AddInParameter(cmd, "@MobilePhone", DbType.String, entity.MobilePhone); db.AddInParameter(cmd, "@IsDefault", DbType.Int32, entity.IsDefault); db.AddInParameter(cmd, "@Sort", DbType.Int32, entity.Sort); object identity = db.ExecuteScalar(cmd); if (identity == null || identity == DBNull.Value) { return(0); } return(Convert.ToInt32(identity)); }
/// <summary> /// 根据主键值读取记录。如果数据库不存在这条数据将返回null /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public OrderAddressEntity GetOrderAddressByOrderCode(long ordercode) { string sql = @"SELECT [Id],[OrderCode],[AccepterName],[CtType],[CountryCode],[CountryName],[ProvinceId],[CityId],[DistrictId],[Address],[Postcode],[Telephone],[MobilePhone],[IsDefault],[Sort] FROM dbo.[OrderAddress] WITH(NOLOCK) WHERE [OrderCode]=@OrderCode" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@OrderCode", DbType.Int64, ordercode); OrderAddressEntity entity = new OrderAddressEntity(); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.OrderCode = StringUtils.GetDbLong(reader["OrderCode"]); entity.AccepterName = StringUtils.GetDbString(reader["AccepterName"]); entity.CtType = StringUtils.GetDbInt(reader["CtType"]); entity.CountryCode = StringUtils.GetDbString(reader["CountryCode"]); entity.CountryName = StringUtils.GetDbString(reader["CountryName"]); entity.ProvinceId = StringUtils.GetDbInt(reader["ProvinceId"]); entity.CityId = StringUtils.GetDbInt(reader["CityId"]); entity.DistrictId = StringUtils.GetDbString(reader["DistrictId"]); entity.Address = StringUtils.GetDbString(reader["Address"]); entity.Postcode = StringUtils.GetDbString(reader["Postcode"]); entity.Telephone = StringUtils.GetDbString(reader["Telephone"]); entity.MobilePhone = StringUtils.GetDbString(reader["MobilePhone"]); entity.IsDefault = StringUtils.GetDbInt(reader["IsDefault"]); entity.Sort = StringUtils.GetDbInt(reader["Sort"]); } } return(entity); }
/// <summary> /// 读取记录列表。 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public IList <OrderAddressEntity> GetOrderAddressAll() { string sql = @"SELECT [Id],[OrderCode],[AccepterName],[CtType],[CountryCode],[CountryName],[ProvinceId],[CityId],[DistrictId],[Address],[Postcode],[Telephone],[MobilePhone],[IsDefault],[Sort] from dbo.[OrderAddress] WITH(NOLOCK) "; IList <OrderAddressEntity> entityList = new List <OrderAddressEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { OrderAddressEntity entity = new OrderAddressEntity(); entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.OrderCode = StringUtils.GetDbInt(reader["OrderCode"]); entity.AccepterName = StringUtils.GetDbString(reader["AccepterName"]); entity.CtType = StringUtils.GetDbInt(reader["CtType"]); entity.CountryCode = StringUtils.GetDbString(reader["CountryCode"]); entity.CountryName = StringUtils.GetDbString(reader["CountryName"]); entity.ProvinceId = StringUtils.GetDbInt(reader["ProvinceId"]); entity.CityId = StringUtils.GetDbInt(reader["CityId"]); entity.DistrictId = StringUtils.GetDbString(reader["DistrictId"]); entity.Address = StringUtils.GetDbString(reader["Address"]); entity.Postcode = StringUtils.GetDbString(reader["Postcode"]); entity.Telephone = StringUtils.GetDbString(reader["Telephone"]); entity.MobilePhone = StringUtils.GetDbString(reader["MobilePhone"]); entity.IsDefault = StringUtils.GetDbInt(reader["IsDefault"]); entity.Sort = StringUtils.GetDbInt(reader["Sort"]); entityList.Add(entity); } } return(entityList); }
/// <summary> /// 生成订单 /// </summary> /// <param name="products"></param> /// <param name="memid"></param> /// <returns></returns> public string CreateOrder(VWOrderEntity order, OrderAddressEntity _address, OrderBillBasicEntity _billentity) { Random rd = new Random(); order.Code = StringUtils.GetDbLong(XTCodeBLL.Instance.GetCodeFromProc(XTCodeType.OrderDayNo) + rd.Next(100, 999).ToString()); order.OrderVisualCode = order.Code; order.CreateTime = DateTime.Now; order.Status = (int)OrderStatus.WaitPay; return(OrderDA.Instance.CreateOrder(order, _address, _billentity)); }
/// <summary> /// 读取记录列表。 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public IList <OrderAddressEntity> GetOrderAddressList(int pagesize, int pageindex, ref int recordCount) { string sql = @"SELECT [Id],[OrderCode],[AccepterName],[CtType],[CountryCode],[CountryName],[ProvinceId],[CityId],[DistrictId],[Address],[Postcode],[Telephone],[MobilePhone],[IsDefault],[Sort] FROM (SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER, [Id],[OrderCode],[AccepterName],[CtType],[CountryCode],[CountryName],[ProvinceId],[CityId],[DistrictId],[Address],[Postcode],[Telephone],[MobilePhone],[IsDefault],[Sort] from dbo.[OrderAddress] WITH(NOLOCK) WHERE 1=1 ) as temp where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize" ; string sql2 = @"Select count(1) from dbo.[OrderAddress] with (nolock) "; IList <OrderAddressEntity> entityList = new List <OrderAddressEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageindex); db.AddInParameter(cmd, "@PageSize", DbType.Int32, pagesize); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { OrderAddressEntity entity = new OrderAddressEntity(); entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.OrderCode = StringUtils.GetDbInt(reader["OrderCode"]); entity.AccepterName = StringUtils.GetDbString(reader["AccepterName"]); entity.CtType = StringUtils.GetDbInt(reader["CtType"]); entity.CountryCode = StringUtils.GetDbString(reader["CountryCode"]); entity.CountryName = StringUtils.GetDbString(reader["CountryName"]); entity.ProvinceId = StringUtils.GetDbInt(reader["ProvinceId"]); entity.CityId = StringUtils.GetDbInt(reader["CityId"]); entity.DistrictId = StringUtils.GetDbString(reader["DistrictId"]); entity.Address = StringUtils.GetDbString(reader["Address"]); entity.Postcode = StringUtils.GetDbString(reader["Postcode"]); entity.Telephone = StringUtils.GetDbString(reader["Telephone"]); entity.MobilePhone = StringUtils.GetDbString(reader["MobilePhone"]); entity.IsDefault = StringUtils.GetDbInt(reader["IsDefault"]); entity.Sort = StringUtils.GetDbInt(reader["Sort"]); entityList.Add(entity); } } cmd = db.GetSqlStringCommand(sql2); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { recordCount = StringUtils.GetDbInt(reader[0]); } else { recordCount = 0; } } return(entityList); }
public string CreateOrderList(Dictionary <int, VWOrderEntity> orderlist, OrderAddressEntity _address, OrderBillBasicEntity _billentity) { Random rd = new Random(); string vbatchno = XTCodeBLL.Instance.GetCodeFromProc(XTCodeType.OrderDayNo) + rd.Next(1, 9).ToString(); int suborderi = 0; foreach (int orderkey in orderlist.Keys) { suborderi++; VWOrderEntity order = orderlist[orderkey]; order.Code = StringUtils.GetDbLong(vbatchno + suborderi.ToString().PadLeft(2, '0')); order.OrderVisualCode = StringUtils.GetDbLong(vbatchno); order.CreateTime = DateTime.Now; order.Status = (int)OrderStatus.XuQiuSubmit; OrderDA.Instance.CreateOrderXuQiu(order, _address, _billentity); } return(vbatchno); }
public string CreateOrderByCart() { ResultObj result = new ResultObj(); long _ordercode = FormString.LongIntSafeQ("ordercode"); long _cartcode = FormString.LongIntSafeQ("cartcode"); OrderAddressEntity _address = new OrderAddressEntity(); _address = OrderAddressBLL.Instance.GetOrderAddressByOrderCode(_ordercode); OrderBillBasicEntity _billentity = new OrderBillBasicEntity(); _billentity = OrderBillBasicBLL.Instance.GetBillBasicByOrderCode(_ordercode); VWOrderEntity _vworder = OrderDetailPreTempBLL.Instance.GetVWOrderByTempCode(_cartcode); OrderEntity _orderentity = OrderBLL.Instance.GetOrderByCode(_ordercode); if (_address != null && _address.Id > 0 && _billentity != null && _billentity.Id > 0 && _vworder != null && _vworder.ActPrice > 0) { _vworder.MemId = _orderentity.MemId; _vworder.MemLevel = _orderentity.MemLevel; _vworder.IsStore = _orderentity.IsStore; _vworder.Integral = 0; _vworder.IntegralFee = 0; string newordercode = OrderBLL.Instance.CreateOrder(_vworder, _address, _billentity); OrderCreateLogEntity log = new OrderCreateLogEntity(); log.OldOrderCode = _ordercode; log.PreTempCode = _cartcode; log.CreateManId = memid; log.NewOrderCode = StringUtils.GetDbLong(newordercode); OrderCreateLogBLL.Instance.AddOrderCreateLog(log); result.Status = (int)SuperMarket.Model.CommonStatus.Success; } else { result.Status = (int)SuperMarket.Model.CommonStatus.Fail; } return(JsonJC.ObjectToJson(result)); }
/// <summary> /// 插入一条记录到表OrderAddress,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。 /// 该方法提供给界面等UI层调用 /// </summary> /// <param name="orderAddress">要添加的OrderAddress数据实体对象</param> public int AddOrderAddress(OrderAddressEntity orderAddress) { if (orderAddress.Id > 0) { return(UpdateOrderAddress(orderAddress)); } else if (string.IsNullOrEmpty(orderAddress.AccepterName)) { return((int)CommonStatus.ADD_Fail_Empty); } else if (string.IsNullOrEmpty(orderAddress.CountryName)) { return((int)CommonStatus.ADD_Fail_Empty); } else if (OrderAddressBLL.Instance.IsExist(orderAddress)) { return((int)CommonStatus.ADD_Fail_Exist); } else { return(OrderAddressDA.Instance.AddOrderAddress(orderAddress)); } }
/// <summary> /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。 /// 如果数据库有数据被更新了则返回True,否则返回False /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="orderAddress">待更新的实体对象</param> public int UpdateOrderAddress(OrderAddressEntity entity) { string sql = @" UPDATE dbo.[OrderAddress] SET [OrderCode]=@OrderCode,[AccepterName]=@AccepterName,[CtType]=@CtType,[CountryCode]=@CountryCode,[CountryName]=@CountryName,[ProvinceId]=@ProvinceId,[CityId]=@CityId,[DistrictId]=@DistrictId,[Address]=@Address,[Postcode]=@Postcode,[Telephone]=@Telephone,[MobilePhone]=@MobilePhone,[IsDefault]=@IsDefault,[Sort]=@Sort WHERE [Id]=@id"; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id); db.AddInParameter(cmd, "@OrderCode", DbType.Int32, entity.OrderCode); db.AddInParameter(cmd, "@AccepterName", DbType.String, entity.AccepterName); db.AddInParameter(cmd, "@CtType", DbType.Int32, entity.CtType); db.AddInParameter(cmd, "@CountryCode", DbType.String, entity.CountryCode); db.AddInParameter(cmd, "@CountryName", DbType.String, entity.CountryName); db.AddInParameter(cmd, "@ProvinceId", DbType.String, entity.ProvinceId); db.AddInParameter(cmd, "@CityId", DbType.String, entity.CityId); db.AddInParameter(cmd, "@DistrictId", DbType.String, entity.DistrictId); db.AddInParameter(cmd, "@Address", DbType.String, entity.Address); db.AddInParameter(cmd, "@Postcode", DbType.String, entity.Postcode); db.AddInParameter(cmd, "@Telephone", DbType.String, entity.Telephone); db.AddInParameter(cmd, "@MobilePhone", DbType.String, entity.MobilePhone); db.AddInParameter(cmd, "@IsDefault", DbType.Int32, entity.IsDefault); db.AddInParameter(cmd, "@Sort", DbType.Int32, entity.Sort); return(db.ExecuteNonQuery(cmd)); }
/// <summary> /// 更新一条OrderAddress记录。 /// 该方法提供给界面等UI层调用 /// </summary> /// <param name="orderAddress">待更新的实体对象</param> /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param> public int UpdateOrderAddress(OrderAddressEntity orderAddress) { return(OrderAddressDA.Instance.UpdateOrderAddress(orderAddress)); }
/// <summary> /// 判断对象是否存在 /// </summary> /// <param name="dicEnum"></param> /// <returns></returns> public bool IsExist(OrderAddressEntity orderAddress) { return(OrderAddressDA.Instance.ExistNum(orderAddress) > 0); }
/// <summary> /// 生成真实订单 /// </summary> /// <returns></returns> public string CreateOrderXuQiu() { ResultObj _result = new ResultObj(); int _resultstatus = (int)CommonStatus.Fail; long _preordercode = FormString.LongIntSafeQ("preordercode"); int _addressid = FormString.IntSafeQ("addressid"); int _paytype = FormString.IntSafeQ("paytype"); string _remark = FormString.SafeQ("remark", 80000); string acceptername = FormString.SafeQ("acceptername"); int province = FormString.IntSafeQ("province"); int city = FormString.IntSafeQ("city"); string address = FormString.SafeQ("address", 500); string mobilephone = FormString.SafeQ("mobilephone"); int jifen = FormString.IntSafeQ("jifen"); int memcouponid = FormString.IntSafeQ("memcouponid");//折扣券Id int expressid = FormString.IntSafeQ("expressid"); int ordertype = FormString.IntSafeQ("ordertype", -1); if (jifen % 100 != 0) { jifen = jifen / 100 * 100; } if (jifen > 0 && !AssetBLL.Instance.CheckIntegralEnough(memid, jifen)) { jifen = 0; } int billtype = FormString.IntSafeQ("billtype"); OrderBillBasicEntity _billentity = new OrderBillBasicEntity(); _billentity.BillType = billtype; if (billtype == (int)BillType.Normal) { string title = FormString.SafeQ("billtitle", 200); _billentity.CompanyName = title; } else if (billtype == (int)BillType.VAT) { _billentity.BillId = FormString.IntSafeQ("billvatid"); MemBillVATEntity _mementity = MemBillVATBLL.Instance.GetMemBillVAT(memid); _billentity.ReceiverName = FormString.SafeQ("billvatrename"); _billentity.ReceiverPhone = FormString.SafeQ("billvatrephone"); _billentity.ReceiverProvince = FormString.IntSafeQ("billvatreprovince"); _billentity.ReceiverCity = FormString.IntSafeQ("billvatrecity"); _billentity.ReceiverAddress = FormString.SafeQ("billvatreaddress", 300); _billentity.CompanyName = _mementity.CompanyName; _billentity.CompanyPhone = _mementity.CompanyPhone; _billentity.CompanyCode = _mementity.CompanyCode; _billentity.CompanyBank = _mementity.CompanyBank; _billentity.CompanyAddress = _mementity.CompanyAddress; _billentity.BankAccount = _mementity.BankAccount; _billentity.Status = _mementity.Status; } OrderAddressEntity _address = new OrderAddressEntity(); _address.CityId = city; _address.AccepterName = acceptername; _address.ProvinceId = province; _address.Address = address; _address.MobilePhone = mobilephone; Dictionary <int, VWOrderEntity> _vworderdic = OrderDetailPreTempBLL.Instance.GetVWOrdersByTempCode(_preordercode); List <int> listpdids = new List <int>(); string productdetails = ""; if (_vworderdic.Keys.Count > 0) { IList <VWOrderRemarkEntity> remarklist = new List <VWOrderRemarkEntity>(); if (!string.IsNullOrEmpty(_remark)) { remarklist = JsonJC.JsonToObject <List <VWOrderRemarkEntity> >(_remark.Replace(""", "\"")); } Dictionary <int, string> remarkdic = new Dictionary <int, string>(); foreach (VWOrderRemarkEntity reenti in remarklist) { remarkdic.Add(StringUtils.GetDbInt(reenti.CGMemId), reenti.Remark); } foreach (int okey in _vworderdic.Keys) { if (okey > 0) { foreach (VWOrderDetailEntity oden in _vworderdic[okey].Details) { listpdids.Add(oden.ProductDetailId); productdetails += "|" + oden.ProductDetailId.ToString() + "_" + oden.Num.ToString(); } productdetails = productdetails.TrimStart('|'); OrderCommonBLL.Instance.GetTransFeeForOrder(_vworderdic[okey]); _vworderdic[okey].CGMemId = okey; _vworderdic[okey].PreOrderCode = _preordercode; _vworderdic[okey].OrderType = (int)OrderType.OnLine; _vworderdic[okey].NeedDeliver = 1; //需要发货 _vworderdic[okey].PayPrice = 0; //支付价格0 _vworderdic[okey].PayType = _paytype; _vworderdic[okey].ExpressCom = 0; //普通配送 _vworderdic[okey].MemId = memid; _vworderdic[okey].MemLevel = member.MemGrade; _vworderdic[okey].IsStore = member.IsStore; _vworderdic[okey].OrderStyle = (int)OrderStyleEnum.XuQiu; if (remarkdic.ContainsKey(okey)) { _vworderdic[okey].Remark = remarkdic[okey]; } } else { foreach (VWOrderDetailEntity oden in _vworderdic[okey].Details) { listpdids.Add(oden.ProductDetailId); } } } if (ProductStyleBLL.Instance.ProductsEnough(productdetails)) { string ordercode = OrderBLL.Instance.CreateOrderList(_vworderdic, _address, _billentity); if (!string.IsNullOrEmpty(ordercode)) { if (productdetails != "") { if (ProductStyleBLL.Instance.ProductsToOrder(productdetails) > 0) { VWShoppingCartInfo ShoppingCartentity = ShoppingXuQiuProcessor.GetShoppingXuQiu(); ShoppingXuQiuProcessor.RemoveCartXuQiuItems(ShoppingCartentity, listpdids); _result.Status = (int)CommonStatus.Success; _result.Obj = ordercode; return(JsonJC.ObjectToJson(_result)); } else { _result.Status = (int)CommonStatus.ProductLess; _result.Obj = ""; return(JsonJC.ObjectToJson(_result)); } } else { _result.Status = (int)CommonStatus.Success; _result.Obj = ordercode; return(JsonJC.ObjectToJson(_result)); } } } else { _result.Status = (int)CommonStatus.ProductLess; _result.Obj = ""; return(JsonJC.ObjectToJson(_result)); } } _result.Status = (int)CommonStatus.Fail; _result.Obj = ""; return(JsonJC.ObjectToJson(_result)); }
/// <summary> /// 生成真实订单 /// </summary> /// <returns></returns> public string CreateOrder() { ResultObj _result = new ResultObj(); int _resultstatus = (int)CommonStatus.Fail; long _preordercode = FormString.LongIntSafeQ("preordercode"); int _addressid = FormString.IntSafeQ("addressid"); //int _paytype = FormString.IntSafeQ("paytype"); int _systype = FormString.IntSafeQ("systype"); if (_systype == 0) { _systype = (int)SystemType.B2B; } string _remark = FormString.SafeQ("remark"); string acceptername = FormString.SafeQ("acceptername"); int province = FormString.IntSafeQ("province"); int city = FormString.IntSafeQ("city"); string address = FormString.SafeQ("address", 500); string mobilephone = FormString.SafeQ("mobilephone"); int jifen = FormString.IntSafeQ("jifen"); int memcouponid = FormString.IntSafeQ("memcouponid"); int expressid = FormString.IntSafeQ("expressid"); int ordertype = FormString.IntSafeQ("ordertype", -1); if (jifen % 100 != 0) { jifen = jifen / 100 * 100; } if (jifen > 0 && !AssetBLL.Instance.CheckIntegralEnough(memid, jifen)) { jifen = 0; } int billtype = FormString.IntSafeQ("billtype"); OrderBillBasicEntity _billentity = new OrderBillBasicEntity(); _billentity.BillType = billtype; if (billtype == (int)BillType.Normal) { string title = FormString.SafeQ("billtitle", 200); _billentity.CompanyName = title; } else if (billtype == (int)BillType.VAT) { _billentity.BillId = FormString.IntSafeQ("billvatid"); MemBillVATEntity _mementity = MemBillVATBLL.Instance.GetMemBillVAT(memid); //if (_mementity.Status != 1) //{ // resultstatus = (int)CommonStatus.BillVATNoCheck; // _result.Status = resultstatus; // return JsonJC.ObjectToJson(_result); //} _billentity.ReceiverName = FormString.SafeQ("billvatrename"); _billentity.ReceiverPhone = FormString.SafeQ("billvatrephone"); _billentity.ReceiverProvince = FormString.IntSafeQ("billvatreprovince"); _billentity.ReceiverCity = FormString.IntSafeQ("billvatrecity"); _billentity.ReceiverAddress = FormString.SafeQ("billvatreaddress", 300); _billentity.CompanyName = _mementity.CompanyName; _billentity.CompanyPhone = _mementity.CompanyPhone; _billentity.CompanyCode = _mementity.CompanyCode; _billentity.CompanyBank = _mementity.CompanyBank; _billentity.CompanyAddress = _mementity.CompanyAddress; _billentity.BankAccount = _mementity.BankAccount; _billentity.Status = _mementity.Status; } VWOrderEntity _vworder = OrderDetailPreTempBLL.Instance.GetVWOrderByTempCode(_preordercode); if (ordertype != -1) { _vworder.OrderType = ordertype; } _vworder.OrderStyle = (int)OrderStyleEnum.Normal; _vworder.DisCountFee = _vworder.DisCountFee; decimal tempprice = _vworder.PreDisCountPrice - _vworder.DisCountFee; if (tempprice > 1) { decimal jifenamt = OrderCommonBLL.Instance.GetJiFenAmt(jifen); _vworder.Integral = jifen; _vworder.IntegralFee = jifenamt; tempprice = tempprice - jifenamt; } else { _vworder.Integral = 0; _vworder.IntegralFee = 0; } if (memcouponid > 0) { MemCouponsEntity couponen = MemCouponsBLL.Instance.GetCouponByMemCouponId(memid, memcouponid); if (couponen != null && couponen.Id == memcouponid && couponen.EndTime > DateTime.Now) { DicCouponsEntity dicen = couponen.DicCoupons; if (dicen.CouponType == (int)CouponTypeEnum.Money && dicen.MinimumReqAmount < tempprice) { _vworder.MemCouponsId = memcouponid; _vworder.CouponsFee = dicen.CouponValue; tempprice = tempprice - dicen.CouponValue; } } } _vworder.ActPrice = tempprice; //_vworder.PayType = _paytype; _vworder.ExpressCom = expressid; _vworder.Remark = _remark; _vworder.MemId = memid; _vworder.MemLevel = member.MemGrade; _vworder.IsStore = member.IsStore; //if (_paytype == (int)PayType.OutLine) //{ // _vworder.PayConfirmCode = StringUtils.GetRandomString(12); //} //if (billtype == 1) //{ // _vworder.BillType = (int)BillType.Normal; //} //else if (billtype == 2) //{ // _vworder.BillType = (int)BillType.VAT; //} OrderAddressEntity _address = new OrderAddressEntity(); _address.CityId = city; _address.AccepterName = acceptername; _address.ProvinceId = province; _address.Address = address; _address.MobilePhone = mobilephone; //_vworder.AcceptAddress = _address; if (_vworder.ActPrice >= 1) { List <int> listpdids = new List <int>(); string productdetails = ""; if (_vworder != null && _vworder.Details != null && _vworder.Details.Count > 0) { foreach (VWOrderDetailEntity ordetailentity in _vworder.Details) { listpdids.Add(ordetailentity.ProductDetailId); productdetails += "|" + ordetailentity.ProductDetailId.ToString() + "_" + ordetailentity.Num.ToString(); } if (productdetails != "") { productdetails = productdetails.TrimStart('|'); if (ProductStyleBLL.Instance.ProductsEnough(productdetails)) { string ordercode = OrderBLL.Instance.CreateOrder(_vworder, _address, _billentity); if (!string.IsNullOrEmpty(ordercode)) { //IList<OrderDetailEntity> _listproduct = OrderDetailBLL.Instance.GetOrderDetailAllByOrder(memid, StringUtils.GetDbLong(ordercode), false); //foreach (OrderDetailEntity _entity in _listproduct) //{ // productdetails += "|" + _entity.ProductDetailId.ToString() + "_" + _entity.Num.ToString(); //} if (productdetails != "") { if (ProductStyleBLL.Instance.ProductsToOrder(productdetails) > 0) { VWShoppingCartInfo ShoppingCartentity = ShoppingCartProcessor.GetShoppingCart(); ShoppingCartProcessor.RemoveCartItems(ShoppingCartentity, listpdids); //if (_vworder.PayType == (int)PayType.WeChat) //{ _result.Obj = ordercode; //} //else //{ // _result.Obj = ordercode; //} _result.Status = (int)CommonStatus.Success; return(JsonJC.ObjectToJson(_result)); } else { _result.Status = (int)CommonStatus.ProductLess; _result.Obj = ""; return(JsonJC.ObjectToJson(_result)); } } else { _result.Status = (int)CommonStatus.Success; _result.Obj = ordercode; return(JsonJC.ObjectToJson(_result)); } } } else { _result.Status = (int)CommonStatus.ProductLess; _result.Obj = ""; return(JsonJC.ObjectToJson(_result)); } } } } _result.Status = (int)CommonStatus.Fail; _result.Obj = ""; return(JsonJC.ObjectToJson(_result)); }