/// <summary> /// 插入优惠券信息 /// </summary> /// <param name="GiftCardEntity"></param> /// <returns></returns> public bool SaveGiftCard(GiftCardEntity GiftCardEntity, Database db, DbTransaction tran) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into GiftCard("); strSql.Append("BatchId,BatchName,UserId,CardId,CardSum,CardType,Status,BeginTime,EndTime,SatisfyPrice,SatisfyProduct,AddTime)"); strSql.Append(" values ("); strSql.Append("@BatchId,@BatchName,@UserId,@CardId,@CardSum,@CardType,@Status,@BeginTime,@EndTime,@SatisfyPrice,@SatisfyProduct,@AddTime)"); var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@BatchId", GiftCardEntity.BatchId); parameters.Append("@BatchName", GiftCardEntity.BatchName); parameters.Append("@UserId", GiftCardEntity.UserId); parameters.Append("@CardId", GiftCardEntity.CardId); parameters.Append("@CardSum", GiftCardEntity.CardSum); parameters.Append("@CardType", GiftCardEntity.CardType); parameters.Append("@Status", GiftCardEntity.Status); parameters.Append("@BeginTime", GiftCardEntity.BeginTime); parameters.Append("@EndTime", GiftCardEntity.EndTime); parameters.Append("@SatisfyPrice", GiftCardEntity.SatisfyPrice); parameters.Append("@SatisfyProduct", GiftCardEntity.SatisfyProduct); parameters.Append("@AddTime", GiftCardEntity.AddTime); return(db.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters, tran) > 0); }
public bool UpdateMessageStatus(MessageInfo messageInfo) { if (messageInfo == null) { return(false); } string UPDATE_SQL = @" update Message set status = @status where ID=@ID "; var dbParameters = DbSFO2OMain.CreateParameterCollection(); dbParameters.Append("@ID", messageInfo.ID); dbParameters.Append("@status", messageInfo.Status); if (!string.IsNullOrEmpty(messageInfo.UpdateBy)) { UPDATE_SQL = @" update Message set status = @status ,UpdateBy=@UpdateBy,UpdateTime=@UpdateTime where ID=@ID "; dbParameters.Append("@UpdateBy", messageInfo.UpdateBy); dbParameters.Append("@UpdateTime", messageInfo.UpdateTime); } int effectCount = 0; try { effectCount = DbSFO2OMain.ExecuteNonQuery(CommandType.Text, UPDATE_SQL, dbParameters); } catch (Exception ex) { LogHelper.Error(ex); } return(effectCount > 0); }
//插入 DividedPercentStationVisitedLog public int InsertVisitedLog(string StationSource, int ChannelId) { string sql = @"INSERT INTO DividedPercentStationVisitedLog ( -- Id -- this column value is auto-generated DPID, ZDID, VisitedDate, VisitedCount ) VALUES ( @DPID, @ZDID, @VisitedDate, @VisitedCount )"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@DPID", ChannelId); parameters.Append("@ZDID", StationSource); parameters.Append("@VisitedDate", DateTime.Now); parameters.Append("@VisitedCount", 1); return(Convert.ToInt32(DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters))); }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool Add(OrderPaymentEntity entity) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into OrderPayment("); strSql.Append("PayCode,TradeCode,UserId,OrderType,OrderCode,PayAmount,PaidAmount,PayPlatform,PayType,PayStatus,PayTerminal,PayCompleteTime,PayBackRemark,Remark,CreateTime,CreateBy)"); strSql.Append(" values ("); strSql.Append("@PayCode,@TradeCode,@UserId,@OrderType,@OrderCode,@PayAmount,@PaidAmount,@PayPlatform,@PayType,@PayStatus,@PayTerminal,@PayCompleteTime,@PayBackRemark,@Remark,@CreateTime,@CreateBy)"); var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@PayCode", entity.PayCode); parameters.Append("@TradeCode", entity.TradeCode); parameters.Append("@UserId", entity.UserId); parameters.Append("@OrderType", entity.OrderType); parameters.Append("@OrderCode", entity.OrderCode); parameters.Append("@PayAmount", entity.PayAmount); parameters.Append("@PaidAmount", entity.PaidAmount); parameters.Append("@PayPlatform", entity.PayPlatform); parameters.Append("@PayType", entity.PayType); parameters.Append("@PayStatus", entity.PayStatus); parameters.Append("@PayTerminal", entity.PayTerminal); parameters.Append("@PayCompleteTime", entity.PayCompleteTime); parameters.Append("@PayBackRemark", entity.PayBackRemark); parameters.Append("@Remark", entity.Remark); parameters.Append("@CreateTime", entity.CreateTime); parameters.Append("@CreateBy", entity.CreateBy); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0); }
/// <summary> /// 新增结算单 /// </summary> /// <param name="e"></param> /// <returns></returns> public bool AddSettle(SettleOrderInfoEntity e) { string sql = @"insert into SettlementOrderInfo(SettlementCode,OrderCode,RefundCode,SettlementStatus,SettlementType,SupplierId,ExchangeRate,RmbProductTotalAmount, ProductTotalAmount,RmbProductRefundAmount,ProductRefundAmount,RmbSettlementAmount,SettlementAmount, RmbSupplierBearDutyAmount,SupplierBearDutyAmount,RmbBearDutyAmount,BearDutyAmount,CreateTime,CreateBy) Values(@SettlementCode,@OrderCode,@RefundCode,@SettlementStatus,@SettlementType,@SupplierId,@ExchangeRate, @RmbProductTotalAmount,@ProductTotalAmount,@RmbProductRefundAmount,@ProductRefundAmount,@RmbSettlementAmount,@SettlementAmount, @RmbSupplierBearDutyAmount,@SupplierBearDutyAmount,@RmbBearDutyAmount,@BearDutyAmount,@CreateTime,@CreateBy);"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@SettlementCode", e.SettlementCode); parameters.Append("@OrderCode", e.OrderCode); parameters.Append("@RefundCode", e.RefundCode); parameters.Append("@SettlementStatus", e.SettlementStatus); parameters.Append("@SettlementType", e.SettlementType); parameters.Append("@SupplierId", e.SupplierId); parameters.Append("@ExchangeRate", e.ExchangeRate); parameters.Append("@RmbProductTotalAmount", e.RmbProductTotalAmount); parameters.Append("@ProductTotalAmount", e.ProductTotalAmount); parameters.Append("@RmbProductRefundAmount", e.RmbProductRefundAmount); parameters.Append("@ProductRefundAmount", e.ProductRefundAmount); parameters.Append("@RmbSettlementAmount", e.RmbSettlementAmount); parameters.Append("@SettlementAmount", e.SettlementAmount); parameters.Append("@RmbSupplierBearDutyAmount", e.RmbSupplierBearDutyAmount); parameters.Append("@SupplierBearDutyAmount", e.SupplierBearDutyAmount); parameters.Append("@RmbBearDutyAmount", e.RmbBearDutyAmount); parameters.Append("@BearDutyAmount", e.BearDutyAmount); parameters.Append("@CreateTime", e.CreateTime); parameters.Append("@CreateBy", e.CreateBy); return(DbSFO2OMain.ExecuteSqlNonQuery(sql, parameters) > 0); }
/// <summary> /// 新增退款单 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddRefund(RefundOrderEntity model) { string sql = @"Insert Into RefundOrderInfo(RefundCode,RefundType,OrderCode,UserId,RefundReason,RefundDescription,RefundStatus,TotalAmount,RMBTotalAmount,CreateTime,CreateBy,ImagePath,ExchangeRate,SupplierId,RegionCode,ProductStatus,Commission) Values (@RefundCode,@RefundType,@OrderCode,@UserId,@RefundReason,@RefundDescription,@RefundStatus,@TotalAmount,@RMBTotalAmount,@CreateTime,@CreateBy,@ImagePath,@ExchangeRate,@SupplierId,@RegionCode,@ProductStatus,@Commission);"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@RefundCode", model.RefundCode); parameters.Append("@RefundType", model.RefundType); parameters.Append("@OrderCode", model.OrderCode); parameters.Append("@UserId", model.UserId); parameters.Append("@RefundReason", model.RefundReason); parameters.Append("@RefundDescription", model.RefundDescription); parameters.Append("@RefundStatus", model.RefundStatus); parameters.Append("@TotalAmount", model.TotalAmount); parameters.Append("@RMBTotalAmount", model.RMBTotalAmount); parameters.Append("@CreateTime", model.CreateTime); parameters.Append("@CreateBy", model.CreateBy); parameters.Append("@ImagePath", model.ImagePath); parameters.Append("@ExchangeRate", model.ExchangeRate); parameters.Append("@SupplierId", model.SupplierId); parameters.Append("@RegionCode", model.RegionCode); parameters.Append("@ProductStatus", model.ProductStatus); parameters.Append("@Commission", model.Commision); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }
/// <summary> /// /// </summary> /// <returns></returns> public bool IsFirstOrderAuthorize(string userName) { string sql = @"SELECT FirstOrderAuthorize FROM Customer WHERE UserName=@UserName "; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserName", userName); return(DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters).ToString() == "1" ? true : false); }
/// <summary> /// 更新是否首次下单 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool UpdateFirstOrderAuthorize(string userName) { string sql = "Update Customer Set FirstOrderAuthorize=1 Where UserName=@UserName"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserName", userName); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }
/// <summary> /// 获取所有省份 /// </summary> /// <param name="language"></param> /// <returns></returns> public SourceEntity GetSourcePercentById(int cid) { string sql = "SELECT [Id],[OrderSourceType],[DividedPercent],[Status],[ChannelNo],[ChannelName],[CreateTime],[CreateBy] FROM [DividedPercent] WHERE id=@cid"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@cid", cid); return(DbSFO2ORead.ExecuteSqlFirst <SourceEntity>(sql, parameters)); }
/// <summary> /// 更新密码 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool UpdatePassword(CustomerEntity entity) { string sql = "Update Customer Set Password=@Password Where UserName=@UserName"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@Password", MD5Hash.Md5Encrypt(entity.Password)); parameters.Append("@UserName", entity.UserName); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }
/// <summary> /// 删除地址 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Delete(int id, int userId) { string sql = "Update AddressInfo Set IsEnable=0 Where Id=@Id And UserId=@UserId"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@Id", id); parameters.Append("@UserId", userId); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }
/// <summary> /// 获取所有区县 /// </summary> /// <param name="language"></param> /// <returns></returns> public IList <AreaModel> GetAllArea(int language) { string sql = "select AreaId,AreaName,ParentId from Area where IsDelete=0 and LanguageVersion=@LanguageVersion AND IsSFSupport=1"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@LanguageVersion", language); return(DbSFO2ORead.ExecuteSqlList <AreaModel>(sql, parameters)); }
//通过StationSource ChannelId 更新 DividedPercentStationVisitedLog 表的记录 public bool UpdateVisitedLog(string StationSource, int ChannelId) { string sql = "UPDATE DividedPercentStationVisitedLog SET VisitedCount = VisitedCount + 1 WHERE DPID=@ChannelId AND ZDID=@StationSource "; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@StationSource", StationSource); parameters.Append("@ChannelId", ChannelId); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }
/// <summary> /// 更新退款商品数量 /// </summary> /// <param name="ordercode"></param> /// <param name="spu"></param> /// <param name="sku"></param> /// <returns></returns> public bool UpdateRefundQuantity(string ordercode, string spu, string sku) { string sql = "Update OrderProducts Set RefundQuantity=isnull(RefundQuantity,0)+1 Where OrderCode=@OrderCode And Spu=@spu and Sku=@sku;"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@spu", spu); parameters.Append("@sku", sku); parameters.Append("@OrderCode", ordercode); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }
/// <summary> /// 获取所有省份 /// </summary> /// <param name="language"></param> /// <returns></returns> public IList <ProvinceModel> GetAllProvince(string country, int language) { string sql = "select ProvinceId,ProvinceName,ParentId from province where IsDelete=0 and LanguageVersion=@LanguageVersion And ParentId=@ParentId AND IsSFSupport=1"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@LanguageVersion", language); parameters.Append("@ParentId", country); return(DbSFO2ORead.ExecuteSqlList <ProvinceModel>(sql, parameters)); }
public int InsertTemp(string UserName, string pwd, int UserType) { string sql = @"INSERT INTO CustomerTemp(UserName,UserPwd,UserType) VALUES(@UserName,@UserPwd,@UserType)"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserName", UserName); parameters.Append("@UserPwd", pwd); parameters.Append("@UserType", UserType); return(Convert.ToInt32(DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters))); }
public List <RefundProductEntity> getOrderProductCount(string orderCode, string sku) { string sql = @"SELECT roi.RefundCode FROM RefundOrderInfo AS roi LEFT JOIN RefundOrderProducts AS rop ON rop.RefundCode = roi.RefundCode WHERE rop.Sku=@sku AND roi.OrderCode=@OrderCode and roi.RefundStatus!=-1"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@OrderCode", orderCode); parameters.Append("@sku", sku); var list = DbSFO2ORead.ExecuteSqlList <RefundProductEntity>(sql, parameters); return(list.ToList()); }
/// <summary> /// 查询用户的地址数量 /// </summary> /// <param name="userId"></param> /// <param name="countryId"></param> /// <returns></returns> public int GetUserAddressCount(int userId, int countryId) { string sql = "Select count(1) From AddressInfo (nolock) Where UserId=@UserId And CountryId=(select top 1 CountryId From Country Where Id=@CountryId) and IsEnable=1"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserId", userId); parameters.Append("@CountryId", countryId); object cnt = DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters); return(cnt == null ? 0 : cnt.AsInt32()); }
/// <summary> /// 设置默认地址 /// </summary> /// <param name="userId"></param> /// <param name="id"></param> /// <param name="countryId"></param> /// <returns></returns> public bool SetDefaultAddress(int userId, int id, int countryId) { string sql = @"Update AddressInfo Set IsDefault=0 Where UserId=@UserId and CountryId=(select top 1 CountryId From Country Where Id=@CountryId); Update AddressInfo Set IsDefault=1 Where Id=@Id;"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserId", userId); parameters.Append("@CountryId", countryId); parameters.Append("@Id", id); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }
/// <summary> /// 添加新用户酒豆 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool InsertHuoli(CustomerEntity entity, int UserId, decimal huoli, decimal lockHuoli) { string sql = @"INSERT INTO [HuoLiTotal] ([UserId],[HuoLi],[LockedHuoLi],[CreateTime],[CreateBy]) Values( @UserId,@HuoLi,@LockedHuoLi,getdate(),@CreateBy)"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserId", UserId); parameters.Append("@HuoLi", huoli); parameters.Append("@LockedHuoLi", lockHuoli); parameters.Append("@CreateBy", 0); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }
/// <summary> /// 申诉详情 /// </summary> /// <param name="refundCode">退款单号</param> /// <returns></returns> public RefundOrderEntity GetRefundOrderInfo(string refundCode) { string sql = "Select * From RefundOrderInfo Where RefundCode=@RefundCode"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@RefundCode", refundCode); var list = DbSFO2ORead.ExecuteSqlList <RefundOrderEntity>(sql, parameters).ToList(); if (list.Any()) { return(list.First()); } return(new RefundOrderEntity()); }
/// <summary> /// 插入物流速递用户信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public CustomerEntity InsertSFExpressCustomer(CustomerEntity entity) { string sql = @" EXEC [dbo].[sp_InsertSFExpressUser] @Password = @Password, @SourceType = @SourceType, @SFId = @SFId, @UnionId = @UnionId"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@Password", entity.Password); parameters.Append("@SourceType", entity.SourceType); parameters.Append("@SFId", entity.SFId); parameters.Append("@UnionId", entity.UnionId); return(DbSFO2ORead.ExecuteSqlFirst <CustomerEntity>(sql, parameters)); }
/// <summary> /// 修改申诉 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool EditRefund(RefundOrderEntity model) { string sql = @"Update RefundOrderInfo Set RefundReason=@RefundReason,RefundType=@RefundType,RefundDescription=@RefundDescription,RefundStatus=@RefundStatus,ImagePath=@ImagePath,ProductStatus=@ProductStatus Where RefundCode=@RefundCode;"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@RefundCode", model.RefundCode); parameters.Append("@RefundType", model.RefundType); parameters.Append("@RefundReason", model.RefundReason); parameters.Append("@RefundDescription", model.RefundDescription); parameters.Append("@RefundStatus", model.RefundStatus); parameters.Append("@ImagePath", model.ImagePath); parameters.Append("@ProductStatus", model.ProductStatus); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }
/// <summary> /// 该商品是否还能进行申诉 /// </summary> /// <param name="orderCode"></param> /// <param name="sku"></param> /// <returns></returns> public bool IsCanRefund(string orderCode, string sku) { bool isCan = false; string sql = @"select Quantity,RefundQuantity from OrderProducts where OrderCode=@OrderCode and sku=@sku"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@OrderCode", orderCode); parameters.Append("@sku", sku); DataTable dt = DbSFO2ORead.ExecuteDataSet(CommandType.Text, sql, parameters).Tables[0]; if (dt != null && dt.Rows.Count > 0) { isCan = Convert.ToInt32(dt.Rows[0][0]) > Convert.ToInt32(dt.Rows[0][1]) ? true : false; } return(isCan); }
/// <summary> /// 支付失败 /// </summary> public bool UpdatePayFailure(OrderPaymentEntity entity) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE OrderPayment "); strSql.Append("SET TradeCode=@TradeCode,PayStatus=@PayStatus, "); strSql.Append("PayCompleteTime=@PayCompleteTime,PayBackRemark=@PayBackRemark "); strSql.Append("WHERE PayCode=@PayCode "); var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@PayCode", entity.PayCode); parameters.Append("@TradeCode", entity.TradeCode); parameters.Append("@PayStatus", entity.PayStatus); parameters.Append("@PayCompleteTime", entity.PayCompleteTime); parameters.Append("@PayBackRemark", entity.PayBackRemark); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0); }
public AddressEntity GetAddressById(int id) { AddressEntity model = new AddressEntity(); string sql = @"Select a.*,p.ProvinceName,c.CityName,aa.AreaName From AddressInfo (nolock) a inner join Province p on p.ProvinceId=a.ProvinceId inner join City c on c.CityId=a.CityId inner join area aa on aa.AreaId=a.areaId Where a.Id=@Id" ; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@Id", id); IList <AddressEntity> list = DbSFO2ORead.ExecuteSqlList <AddressEntity>(sql, parameters); if (list != null && list.Count > 0) { return(list.First()); } return(model); }
/// <summary> /// 添加新用户 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool Add(OrderInfoLogEntity entity) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into OrderInfoLog("); strSql.Append("OrderCode,CurrentStatus,AfterStatus,OperateIp,Remark,CreateBy,CreateTime)"); strSql.Append(" values ("); strSql.Append("@OrderCode,@CurrentStatus,@AfterStatus,@OperateIp,@Remark,@CreateBy,@CreateTime)"); var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@OrderCode", entity.OrderCode); parameters.Append("@CurrentStatus", entity.CurrentStatus); parameters.Append("@AfterStatus", entity.AfterStatus); parameters.Append("@OperateIp", entity.OperateIp); parameters.Append("@Remark", entity.Remark); parameters.Append("@CreateBy", entity.CreateBy); parameters.Append("@CreateTime", entity.CreateTime); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0); }
/// <summary> /// 添加新用户 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Insert(CustomerEntity entity) { string sql = @"Insert Into Customer(UserName,Password,Mobile,RegionCode,Gender,Email,Type,Status,CreateTime,IsPushingInfo,SourceValue,SourceType,ChannelId) Values( @UserName,@Password,@Mobile,@RegionCode,@Gender,@Email,@Type,@Status,getdate(),1,@SourceValue,@SourceType,@ChannelId); select @@IDENTITY"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserName", entity.Mobile); parameters.Append("@Password", MD5Hash.Md5Encrypt(entity.Password)); parameters.Append("@Mobile", entity.Mobile); parameters.Append("@RegionCode", entity.RegionCode); parameters.Append("@Gender", entity.Gender); parameters.Append("@Email", entity.Email); parameters.Append("@Type", entity.RegionCode == "86" ? 0 : 1); parameters.Append("@Status", 1); parameters.Append("@SourceValue", entity.SourceValue); parameters.Append("@SourceType", entity.SourceType); parameters.Append("@ChannelId", entity.ChannelId); return(Convert.ToInt32(DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters))); }
/// <summary> /// 点击搜索按钮,更新热词搜索记录表 /// </summary> /// <param name="keyword">关键词</param> /// <param name="source">来源:(1.M站 2.PC 3.APP)默认值1</param> public bool AddSearchHotWordRecord(string keyword, int source) { try { //将来如果需要区分开来源统计的话 //需要在where条件里添加source属性:where Keyword=@keyword and DATEDIFF(day,SearchDate,GETDATE())=0) and [Source]=@source string sql = @"DECLARE @Id int,@Currdate int set @Id=(select top 1 ID from HotWordSearchLog where Keyword=@keyword and DATEDIFF(day,SearchDate,GETDATE())=0) print @Id if(@Id>0) begin --print '有结果:'+cast(@Id as varchar(10))+'开始执行update操作' update HotWordSearchLog set SearchCount=SearchCount+1 where ID=@Id end else begin --print '木有结果,开始执行Insert操作' INSERT INTO [HotWordSearchLog]([Keyword],[SearchDate],[SearchCount],[Source]) VALUES(@keyword,convert(datetime,convert(varchar(10),getdate(),120)),1,@source) end"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@keyword", keyword); parameters.Append("@source", source); if (DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) == 1) { //如果考虑到关键词搜索数量太大的话,那就不用写这个了,这个log有个好处是能统计某个时段的搜索热门词汇 //LogHelper.Info("关键词更新成功!关键词:" + keyword); return(true); } else { LogHelper.ErrorMsg("关键词更新失败,关键词:" + keyword); return(false); } } catch (Exception ex) { LogHelper.ErrorMsg(ex.Message); return(false); } }
/// <summary> /// 退款单商品 /// </summary> /// <param name="e"></param> /// <returns></returns> public bool AddRefundProduct(RefundProductEntity model, string orderCode) { string sql = @"Insert Into RefundOrderProducts(RefundCode,spu,sku,Quantity,UnitPrice,RMBUnitPrice,TaxRate,IsBearDuty,HuoLi,Coupon) Values(@RefundCode,@spu,@sku,@Quantity,@UnitPrice,@RMBUnitPrice,@TaxRate,@IsBearDuty,@HuoLi,@Coupon);"; // sql += "Update OrderProducts Set RefundQuantity=isnull(RefundQuantity,0)+1 Where OrderCode=@OrderCode And Spu=@spu and Sku=@sku;"; // sql += @"if exists(select * from OrderProducts where ordercode=@OrderCode and Quantity=RefundQuantity) // begin // update OrderInfo set OrderStatus=5 where OrderCode=@OrderCode // end"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@RefundCode", model.RefundCode); parameters.Append("@spu", model.Spu); parameters.Append("@sku", model.Sku); parameters.Append("@Quantity", model.Quantity); parameters.Append("@UnitPrice", model.UnitPrice); parameters.Append("@RMBUnitPrice", model.RMBUnitPrice); parameters.Append("@TaxRate", model.TaxRate); parameters.Append("@IsBearDuty", model.IsBearDuty); parameters.Append("@HuoLi", model.HuoLi); parameters.Append("@Coupon", model.Coupon); return(DbSFO2OMain.ExecuteNonQuery(CommandType.Text, sql, parameters) > 0); }