/// <summary> /// 我的小店统计 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> private string VipStoreInfo(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <EmptyRequestParameter> >(); LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); try { VipStoreBLL vipStoreBll = new VipStoreBLL(loggingSessionInfo); DataSet dt = vipStoreBll.VipStoreInfo(rp.UserID); var rd = DataTableToObject.ConvertToObject <VipStoreInfoRD>(dt.Tables[0].Rows[0]); var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); } catch (Exception) { return(new ErrorResponse() { ResultCode = 500, Message = "查询错误" }.ToJSON()); } }
/// <summary> /// 删除小店商品 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> private string VipStoreDelItem(string pRequest) { //删除用户商品 var rp = pRequest.DeserializeJSONTo <APIRequest <VipStoreRP> >(); LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); VipStoreBLL vipStoreBlll = new VipStoreBLL(loggingSessionInfo); VipStoreEntity vipstoreEntity = vipStoreBlll.QueryByEntity( new VipStoreEntity() { ItemID = rp.Parameters.ItemID, VIPID = rp.UserID }, null ).FirstOrDefault(); if (vipstoreEntity != null) { vipStoreBlll.Delete(vipstoreEntity); } return(new SuccessResponse <IAPIResponseData>().ToJSON()); }
/// <summary> /// 我的小店增加商品 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> private string VipStoreAddItem(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <VipStoreRP> >(); LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); //先判断商品是否存在 if (string.IsNullOrWhiteSpace(rp.Parameters.ItemID)) { return(new ErrorResponse(500, "没有添加商品信息").ToJSON()); } //要传入的商品id组 string[] items = rp.Parameters.ItemID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //给用户增加商品 VipStoreBLL vipStoreBlll = new VipStoreBLL(loggingSessionInfo); List <string> arrItem = new List <string>(); for (int i = 0; i < items.Length; i++) { string itemID = items[i]; VipStoreEntity vipstoreEntityO = vipStoreBlll.QueryByEntity( new VipStoreEntity() { ItemID = itemID, VIPID = rp.UserID }, null ).FirstOrDefault(); //如果加入该商品就加入 if (vipstoreEntityO == null && !arrItem.Contains(itemID)) { arrItem.Add(itemID); } } IDbTransaction tran = new JIT.CPOS.BS.DataAccess.Base.TransactionHelper(loggingSessionInfo).CreateTransaction(); foreach (var item in arrItem) { VipStoreEntity vipStoreEntity = new VipStoreEntity() { vipStoreID = Guid.NewGuid().ToString(), VIPID = rp.UserID, ItemID = item, SoldCount = 0 }; vipStoreBlll.Create(vipStoreEntity, tran); } tran.Commit(); //用户是否开通小店 VipBLL vipBll = new VipBLL(loggingSessionInfo); VipEntity vipEntity = vipBll.GetByID(rp.UserID); vipEntity.IsSotre = vipEntity.IsSotre ?? 0; if (vipEntity != null && vipEntity.IsSotre == 0) { vipEntity.IsSotre = 1; vipBll.Update(vipEntity); } return(new SuccessResponse <IAPIResponseData>().ToJSON()); }