public ActionResult RichText(int id = 0) { //string token = AccessTokenContainer.GetAccessToken(AccessTokenContainer.GetFirstOrDefaultAppId()); string token = WxHelper.GetToken(webview_appid, webview_appsecret, false); ViewBag.appid = AccessTokenContainer.GetFirstOrDefaultAppId(); ViewBag.ticket = JsApiTicketContainer.GetJsApiTicket(JsApiTicketContainer.GetFirstOrDefaultAppId()); ViewBag.timestamp = JSSDKHelper.GetTimestamp(); ViewBag.nonceStr = JSSDKHelper.GetNoncestr(); ViewBag.signature = JSSDKHelper.GetSignature(ViewBag.ticket, ViewBag.nonceStr, ViewBag.timestamp, GetPageUrl()); ViewBag.pageUrl = GetPageUrl(); if (id == 0) { ViewBag.description = ""; } else { EntGoods good = EntGoodsBLL.SingleModel.GetModel(id); if (good == null) { ViewBag.description = ""; return(Content("产品不存在或已删除")); } ViewBag.description = good.description; } return(View()); }
public override ActionResult pedit() { int id = Utility.IO.Context.GetRequestInt("id", 0); int goodtype = Context.GetRequestInt("goodtype", (int)EntGoodsType.普通产品); EntGoods goodModel = EntGoodsBLL.SingleModel.GetModel(id); ViewBag.goodtype = goodtype; if (goodModel == null) { goodModel = new EntGoods() { goodtype = goodtype, EntGroups = new EntGroupsRelation() } } ; else { var entGroups = EntGroupsRelationBLL.SingleModel.GetModel($"EntGoodsId={goodModel.id}"); if (entGroups != null) { goodModel.EntGroups = entGroups; } else { goodModel.EntGroups = new EntGroupsRelation(); } ViewBag.goodtype = goodModel.goodtype; } return(View(goodModel)); }
/// <summary> /// 专业版普通订单:15天后订单商品自动评论 /// </summary> public void StartEntGoodsCommentServer(int timelength) { List <EntGoodsCart> entgoodscartlist = EntGoodsCartBLL.SingleModel.GetSuccessDataList(0, timelength); if (entgoodscartlist != null && entgoodscartlist.Count > 0) { string userids = string.Join(",", entgoodscartlist.Select(s => s.UserId).Distinct()); List <C_UserInfo> userinfolist = C_UserInfoBLL.SingleModel.GetListByIds(userids); userinfolist = userinfolist == null ? new List <C_UserInfo>() : userinfolist; string aids = string.Join(",", entgoodscartlist.Select(s => s.aId).Distinct()); List <XcxAppAccountRelation> xcxrelationlist = XcxAppAccountRelationBLL.SingleModel.GetListByIds(aids); xcxrelationlist = xcxrelationlist == null ? new List <XcxAppAccountRelation>() : xcxrelationlist; string goodsids = string.Join(",", entgoodscartlist.Select(s => s.FoodGoodsId).Distinct()); List <EntGoods> entgoodslist = EntGoodsBLL.SingleModel.GetListByIds(goodsids); entgoodslist = entgoodslist == null ? new List <EntGoods>() : entgoodslist; foreach (EntGoodsCart itemcart in entgoodscartlist) { C_UserInfo userinfo = userinfolist?.FirstOrDefault(f => f.Id == itemcart.UserId); XcxAppAccountRelation xcxrelation = xcxrelationlist?.FirstOrDefault(f => f.Id == itemcart.aId); EntGoods entgood = entgoodslist?.FirstOrDefault(f => f.id == itemcart.FoodGoodsId); string imgurl = string.IsNullOrEmpty(itemcart.SpecImg) ? entgood.img : itemcart.SpecImg; itemcart.IsCommentting = true; EntGoodsCartBLL.SingleModel.Update(itemcart, "IsCommentting"); SingleModel.AddComment(xcxrelation.Id, userinfo, entgood.goodtype, itemcart.FoodGoodsId, itemcart.GoodName, itemcart.Price, imgurl, itemcart.GoodsOrderId, itemcart.SpecInfo); } } }
/// <summary> /// 检查购买团商品是否超出限制 /// </summary> /// <param name="userid">用户Id</param> /// <param name="qty">购买数量</param> /// <param name="good">商品</param> /// <param name="attrSpacStr">规格参数</param> /// <param name="price">价格</param> /// <returns></returns> protected string CheckGoodCount(int userid, int qty, EntGoods good, string attrSpacStr, ref int price) { string msg = ""; EntGroupsRelation entgroupremodel = EntGroupsRelationBLL.SingleModel.GetModelByGroupGoodType(good.id, good.aid, good.storeId); if (entgroupremodel == null) { msg = "团商品不存在"; } price = entgroupremodel.GroupPrice; //用户已团数量 int buycount = EntGoodsOrderBLL.SingleModel.GetGroupPersonCount(userid, entgroupremodel.EntGoodsId, good.storeId); if (entgroupremodel.LimitNum > 0 && qty > entgroupremodel.LimitNum - buycount) { msg = "超过购买限制"; } //判断是否带有规格参数 if (!string.IsNullOrWhiteSpace(attrSpacStr)) { EntGoodsAttrDetail curEntGoodsAttrDtl = good.GASDetailList.First(x => x.id.Equals(attrSpacStr)); if (curEntGoodsAttrDtl == null) { msg = $"商品不存在:goodId={good.id}||spec={attrSpacStr} "; } price = Convert.ToInt32(curEntGoodsAttrDtl.groupPrice * 100); } return(msg); }
// GET: footbath_gift:足浴版小程序-送花管理 #region 送花管理 /// <summary> /// 送花配置界面 /// </summary> /// <returns></returns> public ActionResult GiftSetting() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(View("PageError", new Return_Msg() { Msg = "参数错误!", code = "500" })); } ViewBag.appId = appId; if (dzaccount == null) { return(Redirect("/dzhome/login")); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(View("PageError", new Return_Msg() { Msg = "没有权限!", code = "403" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId); if (storeModel == null) { return(View("PageError", new Return_Msg() { Msg = "没有数据!", code = "500" })); } ViewBag.GiftPrice = storeModel.ShowGiftPrice; SwitchModel switchModel = JsonConvert.DeserializeObject <SwitchModel>(storeModel.SwitchConfig); ViewBag.ShowPhotoByGift = switchModel.ShowPhotoByGift; List <EntGoods> giftPackages = EntGoodsBLL.SingleModel.GetGiftPackages(appId, (int)GoodsType.足浴版送花套餐); if (giftPackages == null || giftPackages.Count <= 0) { EntGoods giftPackage = new EntGoods() { aid = appId, exttypes = ((int)GoodsType.足浴版送花套餐).ToString(), stock = 2, name = "看相册", state = 1, }; giftPackage.id = Convert.ToInt32(EntGoodsBLL.SingleModel.Add(giftPackage)); giftPackages = new List <EntGoods>(); giftPackages.Add(giftPackage); } return(View(giftPackages)); }
/// <summary> /// 序列化为专业版接口数据 /// </summary> /// <returns></returns> public List <object> FormatForEnt(List <FlashDeal> flashDeals, int userId = 0) { string flashDealIds = string.Join(",", flashDeals.Select(item => item.Id)); List <FlashDealItem> flashItem = FlashDealItemBLL.SingleModel.GetByDealIds(flashDealIds); string flashItemIds = string.Join(",", flashItem.Select(item => item.SourceId)); List <EntGoods> itemsDetail = EntGoodsBLL.SingleModel.GetListByIds(flashItemIds); List <object> formatFlashDeal = new List <object>(); flashDeals.ForEach(flashDeal => { List <FlashDealItem> thisDealItem = flashItem.FindAll(item => item.DealId == flashDeal.Id); List <object> formatItem = new List <object>(); thisDealItem.ForEach(item => { EntGoods detail = itemsDetail.FirstOrDefault(sourceItem => sourceItem.id == item.SourceId); int stock = detail.stock; if (detail.GASDetailList?.Count > 0) { stock += detail.GASDetailList.Sum(spec => spec.stock); } if (item.GetSpecs()?.Count > 0) { //显示秒杀规格最低价 item.DealPrice = item.GetSpecs().OrderBy(spec => spec.DealPrice).First().DealPrice; } formatItem.Add(new { FlashItemId = item.Id, GoodId = detail.id, Title = detail.name, Img = detail.img, OrigPrice = double.Parse((item.OrigPrice * 0.01).ToString()), DealPrice = double.Parse((item.DealPrice * 0.01).ToString()), Sale = FlashDealPaymentBLL.SingleModel.GetSaleCountByEnt(item.Id), Stock = stock, StockLimit = detail.stockLimit, IsNotify = FlashDealItemBLL.SingleModel.CheckSubscribeMark(item, userId), SubVer = RedisUtil.Get <int?>(string.Format("subscribe_flashItem_{0}_{1}", item.Id, userId)), Ver = FlashDealItemBLL.SingleModel.GetSubscribeCacheVer(item.DealId) }); }); formatFlashDeal.Add(new { Id = flashDeal.Id, State = flashDeal.State, Title = flashDeal.Title, Banner = flashDeal.Banner, Begin = flashDeal.Begin, End = flashDeal.End, Item = formatItem, description = flashDeal.Description, }); }); return(formatFlashDeal); }
public ActionResult UpdateTagOrDelete(EntGoods serviceInfo) { string action = Context.GetRequest("action", string.Empty); if (serviceInfo.aid <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(serviceInfo.aid, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={serviceInfo.aid}"); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } EntGoods model = EntGoodsBLL.SingleModel.GetServiceById(serviceInfo.aid, serviceInfo.id); if (model == null) { return(Json(new { isok = false, msg = "系统繁忙info_null" })); } bool isok = false; model.updatetime = DateTime.Now; switch (action) { case "updateTag": if (model.tag == 1) { model.tag = 0; } else { model.tag = 1; } isok = EntGoodsBLL.SingleModel.Update(model, "tag,updatetime"); break; case "delete": model.state = 0; isok = EntGoodsBLL.SingleModel.Update(model, "state,updatetime"); break; default: return(Json(new { isok = false, msg = "参数错误" })); } string msg = isok ? "操作成功" : "操作失败"; return(Json(new { isok = isok, msg = msg })); }
/// <summary> /// 编辑门店产品 /// </summary> /// <returns></returns> public ActionResult subgoodedit() { int id = Context.GetRequestInt("id", 0); int subid = Context.GetRequestInt("subid", 0); if (id <= 0 || subid <= 0) { return(View("PageError", new Return_Msg() { Msg = "参数错误!", code = "500" })); } EntGoods entModelOld = EntGoodsBLL.SingleModel.GetModel(id); if (entModelOld == null || entModelOld.state == 0 || entModelOld.tag == 0) { return(View("PageError", new Return_Msg() { Msg = "总店产品不可用!", code = "500" })); } SubStoreEntGoods subModel = SubStoreEntGoodsBLL.SingleModel.GetModel(subid); if (subModel == null || subModel.SubState == 0) { if (subModel.SubTag == 1) { return(View("PageError", new Return_Msg() { Msg = "下架后才可以编辑!", code = "500" })); } return(View("PageError", new Return_Msg() { Msg = "产品不可用!", code = "500" })); } entModelOld.specificationdetail = subModel.SubSpecificationdetail; entModelOld.stock = subModel.SubStock; entModelOld.sort = subModel.SubSort; //拼团 if (entModelOld.goodtype == (int)EntGoodsType.拼团产品) { EntGroupsRelation group = EntGroupsRelationBLL.SingleModel.GetModelByGroupGoodType(entModelOld.id, entModelOld.aid); if (group == null) { return(View("PageError", new Return_Msg() { Msg = "拼团不可编辑!", code = "500" })); } entModelOld.EntGroups = group; } return(View(entModelOld)); }
/// <summary> /// 下单时判断是否是拼团 /// </summary> /// <param name="isgroup"></param> /// <param name="groupid"></param> /// <param name="specificationId"></param> /// <param name="goodscar"></param> /// <param name="grouperprice"></param> /// <param name="groupmodel"></param> /// <returns></returns> protected string CommandEntGroup(int isgroup, int groupid, int userid, int storeid, int goodid, ref int grouperprice, ref EntGroupsRelation groupmodel, int buyCount) { if (isgroup <= 0 && groupid <= 0) { return(""); } if (isgroup > 0 && groupid > 0) { return("拼团参数错误"); } groupmodel = EntGroupsRelationBLL.SingleModel.GetModelByGroupGoodType(goodid, groupmodel.RId, storeid); if (groupmodel == null) { return("产品匹配不到拼团信息"); } #region 判断开团时,库存是否满足成团 EntGoods entgood = EntGoodsBLL.SingleModel.GetModel(groupmodel.EntGoodsId); if (entgood == null) { return("拼团产品已下架"); } //已团件数 if (isgroup > 0 && entgood.stockLimit) { //判定是否当前用户下单后,剩余的数量是否足够成一个团,如果不足够,那么不允许用户再开团 if (entgood.stock - buyCount < groupmodel.GroupSize - 1) { return("商品库存不足,无法成团"); } } #endregion grouperprice = groupmodel.HeadDeduct; //判断是否是团长,团员不减团长优惠价 if (groupid > 0) { grouperprice = 0; } //判断是否已参加该团 if (groupid > 0) { EntGoodsOrder entgoodorder = EntGoodsOrderBLL.SingleModel.GetModelGroupByGrouId(groupid, userid); if (entgoodorder != null) { return("您已经参加过该拼团了"); } } return(""); }
/// <summary> /// 删除套餐 /// </summary> /// <returns></returns> public ActionResult DelGift() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙id_null" })); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙account_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙store_null" })); } int id = Context.GetRequestInt("id", 0); if (id <= 0) { return(Json(new { isok = false, msg = "参数错误" })); } EntGoods giftInfo = EntGoodsBLL.SingleModel.GetGiftInfo(appId, id, (int)GoodsType.足浴版送花套餐); if (giftInfo == null) { return(Json(new { isok = false, msg = "系统繁忙giftInfo_null" })); } giftInfo.state = 0; bool isok = EntGoodsBLL.SingleModel.Update(giftInfo, "state"); string msg = isok ? "删除成功" : "删除失败"; return(Json(new { isok = isok, msg = msg })); }
//public FlashDealItem GetByEntGood(EntGoods good) //{ // return GetBySourceIdAid(sourceId: good.id, Aid: good.aid, state: (int)FlashItemState.使用中); //} public EntGoods GetFlashDealPrice(EntGoods good, FlashDealItem flashItem) { if (flashItem == null || flashItem.Id == 0) { return(good); } List <FlashItemSpec> flashItemSpecs = flashItem.GetSpecs(); List <EntGoodsAttrDetail> formatAttr = good.GASDetailList?.Where(attr => flashItemSpecs.Exists(spec => spec.Id == attr.id)).ToList(); formatAttr?.ForEach(attr => { FlashItemSpec spec = flashItemSpecs.Find(item => item.Id == attr.id); attr.discountPrice = float.Parse((spec.DealPrice * 0.01).ToString("0.00")); attr.originalPrice = float.Parse((spec.OrigPrice * 0.01).ToString("0.00")); }); good.specificationdetail = JsonConvert.SerializeObject(formatAttr); good.originalPrice = float.Parse((flashItem.OrigPrice * 0.01).ToString("0.00")); good.discountPrice = float.Parse((flashItem.DealPrice * 0.01).ToString("0.00")); return(good); }
public List <EntGoodsCart> GetListByOrderIds(string orderids) { if (string.IsNullOrEmpty(orderids)) { return(new List <EntGoodsCart>()); } List <EntGoodsCart> list = GetList($" GoodsOrderId in ({orderids}) "); string goodsIds = string.Join(",", list?.Select(s => s.FoodGoodsId).Distinct()); List <EntGoods> entGoodsList = EntGoodsBLL.SingleModel.GetListByIds(goodsIds); list.ForEach(x => { if (string.IsNullOrEmpty(x.GoodName)) { EntGoods entGoods = entGoodsList?.FirstOrDefault(f => f.id == x.FoodGoodsId); if (entGoods != null) { x.GoodName = entGoods.name; } } }); return(list); }
/// <summary> /// 获取商品运费(专业版:通过购物车商品) /// </summary> /// <param name="goodCarts"></param> /// <param name="sumMethod"></param> /// <returns></returns> public DeliveryFeeResult GetDeliveryFeeSum(List <EntGoodsCart> goodCarts, string provinces, string city, DeliveryFeeSumMethond sumMethod) { DeliveryFeeResult result = new DeliveryFeeResult(); if (string.IsNullOrWhiteSpace(provinces) || string.IsNullOrWhiteSpace(city)) { result.InRange = false; result.Message = "无效配送地址"; return(result); } //获取商品 string goodsId = string.Join(",", goodCarts.Select(good => good.FoodGoodsId)); if (string.IsNullOrWhiteSpace(goodsId)) { result.InRange = false; return(result); } List <EntGoods> goods = EntGoodsBLL.SingleModel.GetListByIds(goodsId); List <DeliveryProduct> computedProduct = goodCarts.Where(item => goods.FindIndex(good => good.id == item.FoodGoodsId) > -1).Select(item => { //商品 EntGoods good = goods.Find(thisGood => thisGood.id == item.FoodGoodsId); return(new DeliveryProduct { Name = good.name, Count = item.Count, TemplateId = good.TemplateId, Weight = good.Weight, Amount = item.Price, Id = good.id }); }).ToList(); return(GetDeliveryFeeCommon(productInfo: computedProduct, provinces: provinces, city: city, sumMethod: sumMethod)); }
public ActionResult SaveRichText(int id, string content) { if (id > 0) { EntGoods good = EntGoodsBLL.SingleModel.GetModel(id); if (good == null) { return(Json(new { isok = false, msg = "产品不存在或已删除" })); } if (content.Trim() == "") { return(Json(new { isok = false, msg = "产品详情不能为空" })); } good.description = content; if (EntGoodsBLL.SingleModel.Update(good, "description")) { return(Json(new { isok = true, msg = "保存成功!" })); } else { return(Json(new { isok = false, msg = "保存失败!" })); } } else { //如果是新增的产品 没有id用一个缓存来保存 if (RedisUtil.Set(EntGoodsBLL.key_new_ent_goods, content)) { return(Json(new { isok = true, msg = "保存成功!" })); } else { return(Json(new { isok = false, msg = "保存失败!" })); } } }
public EntGroupSponsor GetGroupDetail(int groupid, int type) { EntGroupSponsor model = GetModel(groupid); if (model == null) { return(model); } EntGroupsRelation entgroup = EntGroupsRelationBLL.SingleModel.GetModel(model.EntGoodRId); if (entgroup == null) { return(new EntGroupSponsor()); } int groupnum = 0; model.GroupPrice = entgroup.GroupPriceStr; model.OriginalPrice = entgroup.OriginalPriceStr; switch (type) { case (int)TmpType.小程序专业模板: EntGoods entgood = EntGoodsBLL.SingleModel.GetModel(entgroup.EntGoodsId); if (entgood == null) { return(new EntGroupSponsor()); } model.GroupName = entgood.name; model.GoodId = entgood.id; EntGoodsOrder order = EntGoodsOrderBLL.SingleModel.GetModel($"ordertype = 3 and groupid = {groupid}"); model.GroupImage = ImgHelper.ResizeImg(entgood.img, 220, 220); if (order != null) { EntGoodsCart goodOrderDtl = EntGoodsCartBLL.SingleModel.GetModelByGoodsOrderId(order.Id); if (goodOrderDtl != null && !string.IsNullOrEmpty(goodOrderDtl.SpecImg)) { model.GroupImage = ImgHelper.ResizeImg(goodOrderDtl.SpecImg, 220, 220); } } ; model.GroupUserList = EntGoodsOrderBLL.SingleModel.GetPersonByGroup(groupid.ToString(), ref groupnum); break; case (int)TmpType.小程序餐饮模板: groupnum = FoodGoodsOrderBLL.SingleModel.GetGroupPersonCount(0, entgroup.EntGoodsId); model.GroupUserList = FoodGoodsOrderBLL.SingleModel.GetPersonByGroup(groupid.ToString()); FoodGoods foodgood = FoodGoodsBLL.SingleModel.GetModel(entgroup.EntGoodsId); if (foodgood == null) { return(new EntGroupSponsor()); } model.GroupName = foodgood.GoodsName; model.GoodId = foodgood.Id; model.GroupImage = ImgHelper.ResizeImg(foodgood.ImgUrl, 220, 220);; break; } model.GroupNum = groupnum + entgroup.InitSaleCount;//加上初始化销售量 return(model); }
/// <summary> /// 获取商品名称 /// </summary> /// <param name="xcxtemplatetype">模板类型</param> /// <param name="goodstype">商品类型</param> /// <param name="goodsid">商品ID(拼团entgoods表ID,团购groups表ID,普通商品entgoods表ID,砍价bargain表ID)</param> /// <param name="msg"></param> /// <returns></returns> public string GetGoodsName(int xcxtemplatetype, int goodstype, int goodsid, ref string msg) { string goodsname = ""; switch (xcxtemplatetype) { case (int)TmpType.小程序专业模板: switch (goodstype) { case (int)EntGoodsType.团购商品: Groups groups = GroupsBLL.SingleModel.GetModel(goodsid); if (groups == null) { msg = "找不到商品数据"; } else { goodsname = groups.GroupName; } break; case (int)EntGoodsType.拼团产品: EntGoods entgroupgoods = EntGoodsBLL.SingleModel.GetModel(goodsid); if (entgroupgoods == null) { msg = "找不到商品数据"; } else { goodsname = entgroupgoods.name; } break; case (int)EntGoodsType.普通产品: EntGoods entgoods = EntGoodsBLL.SingleModel.GetModel(goodsid); if (entgoods == null) { msg = "找不到商品数据"; } else { goodsname = entgoods.name; } break; case (int)EntGoodsType.价产品: Bargain bargain = BargainBLL.SingleModel.GetModel(goodsid); if (bargain == null) { msg = "找不到商品数据"; } else { goodsname = bargain.BName; } break; } break; case (int)TmpType.小未平台子模版: PlatChildGoods platchildgoods = PlatChildGoodsBLL.SingleModel.GetModel(goodsid); if (platchildgoods == null) { msg = "找不到商品数据"; } else { goodsname = platchildgoods.Name; } break; } return(goodsname); }
public ActionResult SaveServiceInfo(EntGoods serviceInfo) { if (serviceInfo.aid <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(serviceInfo.aid, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={serviceInfo.aid}"); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } if (string.IsNullOrEmpty(serviceInfo.name)) { return(Json(new { isok = false, msg = "请输入项目名称" })); } if (serviceInfo.name.Length > 30) { return(Json(new { isok = false, msg = "项目名称字数不可超过30字" })); } if (string.IsNullOrEmpty(serviceInfo.ptypes)) { return(Json(new { isok = false, msg = "请选择项目分类" })); } if (serviceInfo.price < 0 || serviceInfo.price > 999999999) { return(Json(new { isok = false, msg = "价格范围:0~999999999,最多两位小数" })); } if (serviceInfo.ServiceTime < 0 || serviceInfo.ServiceTime > 999) { return(Json(new { isok = false, msg = "服务时长:0~999分钟之间" })); } if (string.IsNullOrEmpty(serviceInfo.img)) { return(Json(new { isok = false, msg = "请上传项目主图" })); } if (serviceInfo.stock < 0 || serviceInfo.stock > 999) { return(Json(new { isok = false, msg = "已订人数范围:0~999" })); } if (serviceInfo.specificationkeys != null && serviceInfo.specificationkeys.Length > 100) { return(Json(new { isok = false, msg = "服务流程字数不能超过100字" })); } bool isok = false; if (serviceInfo.id > 0)//编辑 { EntGoods model = EntGoodsBLL.SingleModel.GetServiceById(serviceInfo.aid, serviceInfo.id); if (model == null) { return(Json(new { isok = false, msg = "系统繁忙info_null" })); } serviceInfo.updatetime = DateTime.Now; isok = EntGoodsBLL.SingleModel.Update(serviceInfo, "updatetime,name,ptypes,price,ServiceTime,img,stock,specificationkeys,description"); } else//添加 { serviceInfo.addtime = serviceInfo.updatetime = DateTime.Now; serviceInfo.exttypes = ((int)GoodsType.足浴版服务).ToString(); isok = Convert.ToInt32(EntGoodsBLL.SingleModel.Add(serviceInfo)) > 0; } string msg = isok ? "保存成功" : "保存失败"; return(Json(new { isok = isok, msg = msg })); }
public ActionResult SaveOrderInfo() { #region 数据验证 int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } string reservationTime = Context.GetRequest("ReservationTime", string.Empty); if (string.IsNullOrEmpty(reservationTime)) { return(Json(new { isok = false, msg = "请选择服务时间" })); } string remark = Context.GetRequest("remark", string.Empty); if (remark.Length > 100) { return(Json(new { isok = false, msg = "备注内容不能超过100字" })); } int tid = Context.GetRequestInt("tid", 0); if (tid <= 0) { return(Json(new { isok = false, msg = "系统繁忙tid_null" })); } TechnicianInfo technicianInfo = TechnicianInfoBLL.SingleModel.GetModel($"storeid={storeModel.Id} and state>=0 and id={tid}"); if (technicianInfo == null) { return(Json(new { isok = false, msg = "该技师不存在" })); } int orderId = Context.GetRequestInt("orderId", 0); if (orderId <= 0) { return(Json(new { isok = false, msg = "系统繁忙orderId_null" })); } EntGoodsOrder orderInfo = EntGoodsOrderBLL.SingleModel.GetModelByOrderIdAndAid(orderId, appId, 0); if (orderInfo == null) { return(Json(new { isok = false, msg = "系统繁忙order_null" })); } int state = Context.GetRequestInt("state", 0); if (state <= 0) { return(Json(new { isok = false, msg = "系统繁忙state_null" })); } EntGoodsCart cartInfo = EntGoodsCartBLL.SingleModel.GetModelByGoodsOrderId(orderInfo.Id, 1); if (cartInfo == null) { return(Json(new { isok = false, msg = "系统繁忙cart_null" })); } TechnicianInfo beforeTechnicianInfo = TechnicianInfoBLL.SingleModel.GetModelById(cartInfo.technicianId); if (beforeTechnicianInfo == null) { return(Json(new { isok = false, msg = "原订单技师不存在" })); } EntGoods serviceInfo = EntGoodsBLL.SingleModel.GetServiceById(cartInfo.aId, cartInfo.FoodGoodsId); if (serviceInfo == null) { return(Json(new { isok = false, msg = "系统繁忙serviceInfo_null" })); } #endregion 数据验证 //假设没有修改技师 if (technicianInfo.id == beforeTechnicianInfo.id) { //减少单数 if ((orderInfo.State == (int)MiniAppEntOrderState.已完成 || orderInfo.State == (int)MiniAppEntOrderState.已超时) && (state != (int)MiniAppEntOrderState.已完成 && state != (int)MiniAppEntOrderState.已超时)) { technicianInfo.serviceCount--; serviceInfo.salesCount--; } //增加单数 else if ((orderInfo.State != (int)MiniAppEntOrderState.已完成 && orderInfo.State != (int)MiniAppEntOrderState.已超时) && (state == (int)MiniAppEntOrderState.已完成 || state == (int)MiniAppEntOrderState.已超时)) { technicianInfo.serviceCount++; serviceInfo.salesCount++; } //同步技师工作状态 if (state == (int)MiniAppEntOrderState.已完成 || state == (int)MiniAppEntOrderState.已超时) { technicianInfo.state = (int)TechnicianState.空闲; } else if (state == (int)MiniAppEntOrderState.务中) { technicianInfo.state = (int)TechnicianState.钟; } else if (state == (int)MiniAppEntOrderState.待服务) { technicianInfo.state = (int)TechnicianState.空闲; } } else //前后技师不一致 { //减少原先技师的接单数 if ((orderInfo.State == (int)MiniAppEntOrderState.已完成 || orderInfo.State == (int)MiniAppEntOrderState.已超时) && (state != (int)MiniAppEntOrderState.已完成 && state != (int)MiniAppEntOrderState.已超时)) { beforeTechnicianInfo.serviceCount--; serviceInfo.salesCount--; } //增加之后技师的接单数 else if ((orderInfo.State != (int)MiniAppEntOrderState.已完成 && orderInfo.State != (int)MiniAppEntOrderState.已超时) && (state == (int)MiniAppEntOrderState.已完成 || state == (int)MiniAppEntOrderState.已超时)) { technicianInfo.serviceCount++; serviceInfo.salesCount++; } //更换技师应该把接单数累计到更改后的技师上,减掉原技师接单数 else if ((orderInfo.State == (int)MiniAppEntOrderState.已完成 || orderInfo.State == (int)MiniAppEntOrderState.已超时) && (state == (int)MiniAppEntOrderState.已完成 || state == (int)MiniAppEntOrderState.已超时)) { beforeTechnicianInfo.serviceCount--; technicianInfo.serviceCount++; } //同步技师工作状态 if (state == (int)MiniAppEntOrderState.已完成 || state == (int)MiniAppEntOrderState.已超时) { technicianInfo.state = (int)TechnicianState.空闲; beforeTechnicianInfo.state = (int)TechnicianState.空闲; } else if (state == (int)MiniAppEntOrderState.务中) { technicianInfo.state = (int)TechnicianState.钟; beforeTechnicianInfo.state = (int)TechnicianState.空闲; } else if (state == (int)MiniAppEntOrderState.待服务) { //考虑如果被换过来的技师,其他项目还没完结,只是安排待服务,那么不能影响她原来的状态 //technicianInfo.state = (int)TechnicianState.休息中; beforeTechnicianInfo.state = (int)TechnicianState.空闲; } } //修改之前的服务时间,如果修改成功要将此时间从已预订时间表里取消 DateTime beforeTime = cartInfo.reservationTime; try { cartInfo.reservationTime = Convert.ToDateTime(reservationTime); } catch { return(Json(new { isok = false, msg = "时间格式不合法" })); } //ServiceTime dates = null; ServiceTime dates = ServiceTimeBLL.SingleModel.GetModel(storeModel.appId, technicianInfo.id, storeModel.Id, cartInfo.reservationTime.ToShortDateString()); if (DateTime.Compare(beforeTime, cartInfo.reservationTime) != 0) { //验证服务时间是否已经被选 if (dates != null && !string.IsNullOrEmpty(dates.time)) { List <string> list = dates.time.Split(',').ToList();; if (list.Contains(cartInfo.reservationTime.ToString("HH:mm"))) { return(Json(new { isok = -1, msg = "这个点已经被预订了" }, JsonRequestBehavior.AllowGet)); } } } orderInfo.Remark = remark; orderInfo.State = state; int beforeTid = cartInfo.technicianId; cartInfo.technicianId = tid; bool isok = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "remark,state") && EntGoodsCartBLL.SingleModel.Update(cartInfo, "roomNo,technicianId,reservationTime"); if (isok) { if (DateTime.Compare(beforeTime, cartInfo.reservationTime) != 0 || cartInfo.technicianId != beforeTid) { //修改成功后将选定的时间点添加到已服务时间表 ServiceTimeBLL.SingleModel.AddSelServiceTime(storeModel, cartInfo, storeModel.switchModel); //取消已预订的技师服务时间 dates = ServiceTimeBLL.SingleModel.GetModel(storeModel.appId, beforeTid, storeModel.Id, beforeTime.ToShortDateString()); if (dates != null && !string.IsNullOrEmpty(dates.time)) { List <string> timeList = dates.time.Split(',').ToList(); timeList.Remove(beforeTime.ToString("HH:mm")); dates.time = string.Join(",", timeList); ServiceTimeBLL.SingleModel.Update(dates, "time"); } } //前后技师不同时,才会去更新前者的状态 if (beforeTechnicianInfo.id != technicianInfo.id) { TechnicianInfoBLL.SingleModel.Update(beforeTechnicianInfo, "state,serviceCount"); } TechnicianInfoBLL.SingleModel.Update(technicianInfo, "state,serviceCount"); EntGoodsBLL.SingleModel.Update(serviceInfo, "salesCount"); } string msg = isok ? "操作成功" : "操作失败"; return(Json(new { isok = isok, msg = msg })); }
public void ExportOrder() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { Response.Write("<script>alert('系统繁忙appid_null');window.opener=null;window.close();</script>"); return; } if (dzaccount == null) { Response.Write("<script>alert('系统繁忙auth_null');window.opener=null;window.close();</script>"); return; } var appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel($"id ={appId}"); if (appAcountRelation == null) { Response.Write("<script>alert('系统繁忙relation_null');window.opener=null;window.close();</script>"); return; } int storeId = Context.GetRequestInt("storeid", -1); if (storeId < 0) { Response.Write("<script>alert('系统繁忙storeId_null');window.opener=null;window.close();</script>"); return; } string storeSqlwhere = $"appid={appId}"; if (storeId > 0) { storeSqlwhere = $"id={storeId}"; } FootBath storeModel = FootBathBLL.SingleModel.GetModel(storeSqlwhere); if (storeModel == null) { Response.Write("<script>alert('系统繁忙model_null');window.opener=null;window.close();</script>"); return; } string startdate = Context.GetRequest("startdate", string.Empty); string enddate = Context.GetRequest("enddate", string.Empty); int orderType = Context.GetRequestInt("orderType", 0); if (orderType <= 0) { Response.Write("<script>alert('系统繁忙orderType_null');window.opener=null;window.close();</script>"); return; } if (string.IsNullOrEmpty(startdate) || string.IsNullOrEmpty(enddate)) { Response.Write("<script>alert('请选择导出订单时间段');window.opener=null;window.close();</script>"); return; } string filename = $"表单导出-{storeModel.StoreName}-{startdate}至{enddate}"; List <MySqlParameter> parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("@startdate", $"{startdate} 00:00:00")); parameters.Add(new MySqlParameter("@enddate", $"{enddate} 23:59:59")); string sqlwhere = $"aid={storeModel.appId} and getway={orderType} and CreateDate>=@startdate and CreateDate<=@enddate"; if (storeId > 0) { sqlwhere = $"aid={storeModel.appId} and StoreId={storeModel.Id} and getway={orderType}"; } List <EntGoodsOrder> orderList = EntGoodsOrderBLL.SingleModel.GetListByParam(sqlwhere, parameters.ToArray()); if (orderList != null && orderList.Count > 0) { string bathIds = string.Join(",", orderList.Select(s => s.StoreId).Distinct()); List <FootBath> footBathList = FootBathBLL.SingleModel.GetListByIds(bathIds); string userIds = string.Join(",", orderList.Select(s => s.UserId).Distinct()); List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds); string orderIds = string.Join(",", orderList.Select(s => s.Id)); List <EntGoodsCart> entGoodsCartList = EntGoodsCartBLL.SingleModel.GetListByOrderIds(orderIds); string goodsIds = string.Join(",", entGoodsCartList?.Select(s => s.FoodGoodsId).Distinct()); List <EntGoods> entGoodsList = EntGoodsBLL.SingleModel.GetListByIds(goodsIds); orderList.ForEach(o => { FootBath store = footBathList?.FirstOrDefault(f => f.Id == o.StoreId); if (store != null) { o.storeName = store.StoreName; } C_UserInfo userInfo = userInfoList?.FirstOrDefault(f => f.Id == o.UserId); string sql = $"select * from viprelation as a left join viplevel as b on a.levelid = b.id where a.uid={o.UserId}"; o.vipLevelName = SqlMySql.ExecuteScalar(dbEnum.MINIAPP.ToString(), CommandType.Text, sql).ToString();//获取会员等级 if (userInfo != null) { o.nickName = userInfo.NickName; } //获取购买的商品 o.goodsCarts = entGoodsCartList?.Where(w => w.GoodsOrderId == o.Id).ToList(); if (o.goodsCarts != null && o.goodsCarts.Count > 0) { o.goodsNames = string.Empty; foreach (var goodsCart in o.goodsCarts) { EntGoods goods = entGoodsList?.FirstOrDefault(f => f.id == goodsCart.FoodGoodsId); if (goods == null) { continue; } if (!string.IsNullOrEmpty(goodsCart.SpecInfo)) { o.goodsNames += $"{goods.name}({goodsCart.SpecInfo}),"; } else { o.goodsNames += $"{goods.name}"; } } } }); DataTable exportTable = new DataTable(); switch (orderType) { case (int)multiStoreOrderType.到店自取: exportTable = ExportExcelBLL.GetDaoDianZiquData(orderList); break; case (int)multiStoreOrderType.城配送: exportTable = ExportExcelBLL.GetTongChengPeisongData(orderList); break; case (int)multiStoreOrderType.快递配送: exportTable = ExportExcelBLL.GetKuaiDiPeisongData(orderList); break; } ExcelHelper <EntUserForm> .Out2Excel(exportTable, filename);//导出 } else { Response.Write("<script>alert('查无数据');window.opener=null;window.close();</script>"); return; } }
/// <summary> /// 足浴版获取会员折扣(用到EntGoods的都可用) /// </summary> /// <param name="goods"></param> /// <param name="userVipLevel"></param> public void CalculateVipGoodsPrice(EntGoods goods, VipLevel userVipLevel) { if (userVipLevel == null) { goods.discount = 100; goods.discountPrice = goods.price; //多规格处理 if (goods.GASDetailList != null && goods.GASDetailList.Count > 0) { var detaillist = goods.GASDetailList.ToList(); detaillist.ForEach(g => g.originalPrice = g.discountPrice = g.price); goods.specificationdetail = JsonConvert.SerializeObject(detaillist); } return; } switch (userVipLevel.type) { //全场折扣 case 1: goods.discount = userVipLevel.discount; float discountPrice = goods.price * (userVipLevel.discount * 0.01F); goods.discountPrice = discountPrice < 0.01 ? 0.01F : discountPrice; //多规格处理 if (goods.GASDetailList != null && goods.GASDetailList.Count > 0) { var detaillist = goods.GASDetailList.ToList(); detaillist.ForEach(g => { g.originalPrice = g.price; g.discount = userVipLevel.discount; discountPrice = g.price * (userVipLevel.discount * 0.01F); g.discountPrice = discountPrice < 0.01 ? 0.01F : discountPrice; }); goods.specificationdetail = JsonConvert.SerializeObject(detaillist); } break; //部分折扣 case 2: goods.discount = 100; goods.discountPrice = goods.price; //多规格处理 if (goods.GASDetailList != null && goods.GASDetailList.Count > 0) { var detaillist = goods.GASDetailList.ToList(); detaillist.ForEach(g => g.discountPrice = g.price); goods.specificationdetail = JsonConvert.SerializeObject(detaillist); } if (!string.IsNullOrEmpty(userVipLevel.gids)) { List <string> gidList = userVipLevel.gids.Split(',').ToList(); if (gidList.Contains(goods.id.ToString())) { goods.discount = userVipLevel.discount; discountPrice = goods.price * (userVipLevel.discount * 0.01F); goods.discountPrice = discountPrice < 0.01 ? 0.01F : discountPrice; //多规格处理 if (goods.GASDetailList != null && goods.GASDetailList.Count > 0) { var detaillist = goods.GASDetailList.ToList(); detaillist.ForEach(g => { g.originalPrice = g.price; g.discount = userVipLevel.discount; discountPrice = g.price * (userVipLevel.discount * 0.01F); g.discountPrice = discountPrice < 0.01 ? 0.01F : discountPrice; }); goods.specificationdetail = JsonConvert.SerializeObject(detaillist); } } } break; default: goods.discount = 100; goods.discountPrice = goods.price; //多规格处理 if (goods.GASDetailList != null && goods.GASDetailList.Count > 0) { var detaillist = goods.GASDetailList.ToList(); detaillist.ForEach(g => g.discountPrice = g.price); goods.specificationdetail = JsonConvert.SerializeObject(detaillist); } break; } }
/// <summary> /// 创建预约付费订单 /// </summary> /// <param name="aid">小程序aid</param> /// <param name="uid">userId</param> /// <param name="remark">预约商品信息Json字符串 EntFormRemark</param> /// <returns></returns> public EntGoodsOrder CreateOrder(int aid, int userId, Store store, string remark, int buyMode, out string msg) { EntGoodsOrder order = null; try { EntFormRemark formRemark = JsonConvert.DeserializeObject <EntFormRemark>(remark); EntGoods goods = EntGoodsBLL.SingleModel.GetModel(formRemark.goods.id); if (goods == null) { msg = "订单生成失败:商品信息不存在"; return(order); } //商品标价 int originalPrice = originalPrice = Convert.ToInt32(!string.IsNullOrWhiteSpace(formRemark.attrSpacStr) ? goods.GASDetailList.First(x => x.id.Equals(formRemark.attrSpacStr)).originalPrice * 100 : goods.originalPrice * 100); //商品未打折价格 int price = Convert.ToInt32(!string.IsNullOrWhiteSpace(formRemark.attrSpacStr) ? goods.GASDetailList.First(x => x.id.Equals(formRemark.attrSpacStr)).price * 100 : goods.price * 100); //清单 EntGoodsCart goodsCar = new EntGoodsCart { NotDiscountPrice = price, originalPrice = originalPrice, GoodName = goods.name, FoodGoodsId = goods.id, SpecIds = formRemark.attrSpacStr, Count = formRemark.count, Price = price, SpecInfo = formRemark.SpecInfo, SpecImg = formRemark.SpecImg,//规格图片 UserId = userId, CreateDate = DateTime.Now, State = 0, GoToBuy = 1, aId = aid, type = (int)EntGoodCartType.预约表单 }; goodsCar.Id = Convert.ToInt32(EntGoodsCartBLL.SingleModel.Add(goodsCar)); if (goodsCar.Id <= 0) { msg = "订单生成失败:购物车添加失败"; return(order); } C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(userId); if (userInfo == null) { msg = "订单生成失败:用户信息不存在"; return(order); } XcxAppAccountRelation xcxAppAccount = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcxAppAccount == null) { msg = "订单生成失败:小程序信息不存在"; return(order); } int buyPrice = 0; if (store.funJoinModel.YuyuePayType == 0)//固定金额付费 { buyPrice = store.funJoinModel.YuyuePayCount * 100 * goodsCar.Count; } else { double priceData = goodsCar.Price * goodsCar.Count * store.funJoinModel.YuyuePayCount * 0.01; buyPrice = Convert.ToInt32(Math.Ceiling(priceData)); } order = new EntGoodsOrder() { BuyPrice = buyPrice, GoodsGuid = goodsCar.FoodGoodsId.ToString(), UserId = userInfo.Id, CreateDate = DateTime.Now, OrderType = (int)EntOrderType.预约付费订单, QtyCount = goodsCar.Count, aId = aid, BuyMode = buyMode, }; order.Id = Convert.ToInt32(EntGoodsOrderBLL.SingleModel.Add(order)); if (order.Id <= 0) { msg = "订单生成失败:生成失败"; return(null); } //将订单id添加到清单 goodsCar.GoodsOrderId = order.Id; goodsCar.State = 1; EntGoodsCartBLL.SingleModel.Update(goodsCar, "state,goodsorderid"); //生成对外订单号 string outTradeNo = order.Id.ToString(); if (outTradeNo.Length >= 3) { outTradeNo = outTradeNo.Substring(outTradeNo.Length - 3, 3); } else { outTradeNo.PadLeft(3, '0'); } outTradeNo = $"{DateTime.Now.ToString("yyyyMMddHHmm")}{outTradeNo}"; order.OrderNum = outTradeNo; if (order.BuyMode == (int)miniAppBuyMode.微信支付) { CityMordersBLL cityMordersBLL = new CityMordersBLL(); //创建微信订单 CityMorders cityMorders = cityMordersBLL.CreateCityMorder((int)ArticleTypeEnum.EntSubscribeFormPay, (int)ArticleTypeEnum.EntSubscribeFormPay, order.BuyPrice, 99, aid, userInfo.Id, userInfo.NickName, order.Id, xcxAppAccount.AppId, xcxAppAccount.Title); if (cityMorders == null) { msg = "订单生成失败:生成微信订单失败"; return(null); } order.OrderId = cityMorders.Id; if (!EntGoodsOrderBLL.SingleModel.Update(order, "orderid,OrderNum")) { msg = "订单生成失败:微信支付错误"; return(null); } msg = string.Empty; return(order); } else if (order.BuyMode == (int)miniAppBuyMode.储值支付) { SaveMoneySetUser saveMoneyUser = SaveMoneySetUserBLL.SingleModel.getModelByUserId(xcxAppAccount.AppId, userInfo.Id); if (saveMoneyUser == null || saveMoneyUser.AccountMoney < order.BuyPrice) { msg = "订单生成失败:预存款余额不足"; return(null); } if (!SaveMoneySetUserBLL.SingleModel.paySubscribeFromOrderBySaveMoneyUser(order, saveMoneyUser)) { msg = "订单生成失败:储值支付失败"; return(null); } msg = string.Empty; return(order); } else { msg = "订单生成失败:支付方式错误"; return(null); } } catch { msg = "订单生成失败:remark error"; return(order); } }
/// <summary> /// 添加门店产品 /// </summary> /// <param name="appId"></param> /// <param name="storeId"></param> /// <returns></returns> public ActionResult AddStoreProduct(int appId = 0, int storeId = 0) { string ids = Context.GetRequest("ids", string.Empty); if (appId == 0 || storeId == 0 || ids == "") { return(Json(new { isok = false, msg = "非法请求" })); } string[] idsArray = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (idsArray.Length <= 0) { return(Json(new { isok = false, msg = "请选择要添加的产品" })); } SubStoreEntGoods subGoodsModel; List <string> addSqlList = new List <string>(); foreach (string id in idsArray) { int pid = 0; if (int.TryParse(id, out pid)) { EntGoods goodModel = EntGoodsBLL.SingleModel.GetModel(pid); if (goodModel != null && !SubStoreEntGoodsBLL.SingleModel.Exists($"pid={pid} and aid={appId} and storeid={storeId} and SubState=1")) { subGoodsModel = new SubStoreEntGoods() { Aid = goodModel.aid, Pid = goodModel.id, StoreId = storeId, SubSpecificationdetail = goodModel.specificationdetail, SubState = 1, SubTag = 1, SubsalesCount = 0, SubStock = goodModel.stock, }; addSqlList.Add(SubStoreEntGoodsBLL.SingleModel.BuildAddSql(subGoodsModel)); #region 拼团 if (goodModel.goodtype == (int)EntGoodsType.拼团产品) { EntGroupsRelation entgroups = EntGroupsRelationBLL.SingleModel.GetModelByGroupGoodType(goodModel.id, goodModel.aid); if (entgroups == null) { return(Json(new { isok = false, msg = "团商品已失效!" })); } entgroups.AddTime = DateTime.Now; entgroups.RId = goodModel.aid; entgroups.EntGoodsId = goodModel.id;//占位 entgroups.StoreId = storeId; string addsql = EntGroupsRelationBLL.SingleModel.BuildAddSql(entgroups); //获取最新插入的多门店产品ID //addsql = addsql.Replace("-9999", "(select last_insert_id())"); //log4net.LogHelper.WriteInfo(this.GetType(),addsql); addSqlList.Add(addsql); } #endregion } } } if (SubStoreEntGoodsBLL.SingleModel.ExecuteTransaction(addSqlList.ToArray())) { return(Json(new { isok = true, msg = $"选择{idsArray.Length}个产品,添加成功{addSqlList.Count}个" })); } else { return(Json(new { isok = false, msg = "添加失败!" })); } }
public bool CheckAvailable(EntGoods good) { return(CheckAvailable(good.id, good.aid)); }
public ActionResult subgoodedit(int appId, EntGoods model) { string act = Context.GetRequest("act", ""); int storeId = Context.GetRequestInt("storeId", 0); int subid = Context.GetRequestInt("subid", 0); int pid = Context.GetRequestInt("id", 0); if (act == "batch") { int actval = Context.GetRequestInt("actval", -1); if (actval < 0 || storeId < 0) { return(Json(new { isok = true, msg = "非法参数" })); } string ids = Context.GetRequest("ids", string.Empty); if (string.IsNullOrEmpty(ids)) { return(Json(new { isok = true, msg = "请先选择产品" })); } string sql = $"update substoreentgoods set SubTag=@tag where StoreId={storeId} and find_in_set(id,@ids)>0"; SqlMySql.ExecuteTransaction(EntGoodsBLL.SingleModel.connName, sql, CommandType.Text, new MySqlParameter[] { new MySqlParameter("@ids", ids), new MySqlParameter("@tag", actval) }); return(Json(new { isok = true, msg = "设置成功" })); } else if (act == "del") { SubStoreEntGoods subModel = SubStoreEntGoodsBLL.SingleModel.GetModel(subid); if (subModel == null) { return(Json(new { isok = false, msg = "产品不存在" })); } subModel.SubState = 0; var TranModel = new TransactionModel(); TranModel.Add(SubStoreEntGoodsBLL.SingleModel.BuildUpdateSql(subModel, "SubState")); bool result = SubStoreEntGoodsBLL.SingleModel.ExecuteTransactionDataCorect(TranModel.sqlArray, TranModel.ParameterArray); return(Json(new { isok = result, msg = "删除" + (result ? "成功" : "失败") })); } else if (act == "tag") { int tag = Context.GetRequestInt("tag", -1); if (pid <= 0 || tag < 0) { return(Json(new { isok = false, msg = "参数错误" })); } SubStoreEntGoods subModel = SubStoreEntGoodsBLL.SingleModel.GetModel(subid); if (subModel == null || subModel.SubState == 0) { return(Json(new { isok = false, msg = "产品不存在或已删除" })); } EntGoods entGood = EntGoodsBLL.SingleModel.GetModel(pid); if (entGood == null || entGood.state == 0) { return(Json(new { isok = false, msg = "总店产品不存在或已删除" })); } if (tag != -1) { //如果总店产品下架,分店下架的产品不能再上架 if (entGood.tag == 0 && subModel.SubTag == 0 && tag == 1) { return(Json(new { isok = false, msg = "总店产品已下架,分店产品不能再上架" })); } subModel.SubTag = tag; var TranModel = new TransactionModel(); TranModel.Add(SubStoreEntGoodsBLL.SingleModel.BuildUpdateSql(subModel, "SubTag")); string actionName = (tag == 0 ? "下架" : "上架"); bool result = SubStoreEntGoodsBLL.SingleModel.ExecuteTransactionDataCorect(TranModel.sqlArray, TranModel.ParameterArray); return(Json(new { isok = result, msg = actionName + (result ? "成功" : "失败") })); } return(Json(new { isok = false, msg = "操作失败!" })); } else if (act == "edit") { SubStoreEntGoods subModel = SubStoreEntGoodsBLL.SingleModel.GetModel(subid); if (subModel == null || subModel.SubState == 0) { return(Json(new { isok = true, msg = "产品不可用" })); } EntGoods entModelOld = EntGoodsBLL.SingleModel.GetModel(model.id); if (entModelOld == null || entModelOld.state == 0 || entModelOld.tag == 0) { return(Json(new { isok = true, msg = "总店产品不可用" })); } var TranModel = new TransactionModel(); TranModel.Add(EntGoodsBLL.SingleModel.GetSyncSql(entModelOld, model, subModel)); bool reault = SubStoreEntGoodsBLL.SingleModel.ExecuteTransactionDataCorect(TranModel.sqlArray, TranModel.ParameterArray); if (reault) { return(Json(new { isok = true, msg = "修改成功" })); } } return(Json(new { isok = false, msg = "操作失败" })); }
public ActionResult GetGoodInfo() { returnObj = new Return_Msg_APP(); returnObj.isok = false; int goodid = Context.GetRequestInt("goodid", 0); int storeId = Context.GetRequestInt("storeId", 0); int aid = Context.GetRequestInt("aid", 0); if (goodid == 0 || storeId < 0 || (storeId > 0 && aid == 0)) { returnObj.Msg = "非法请求"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } int xtype = _xcxAppAccountRelationBLL.GetXcxTemplateType(aid); if (xtype == 0) { returnObj.Msg = "小程序没授权"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } EntGroupsRelation relationmodel = EntGroupsRelationBLL.SingleModel.GetModelByGroupGoodType(goodid, aid, storeId); if (relationmodel == null) { returnObj.Msg = "该拼团已不存在"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } //已团数量 int groupnum = 0; List <object> userlist = EntGroupSponsorBLL.SingleModel.GetGoupsUserImgs(relationmodel.Id, ref groupnum, xtype, relationmodel.EntGoodsId); List <EntGroupSponsor> groupSponsorList = EntGroupSponsorBLL.SingleModel.GetHaveSuccessGroup(relationmodel.Id, 10, goodid); switch (xtype) { case (int)TmpType.小程序专业模板: break; case (int)TmpType.小程序多门店模板: EntGoods goodModel = EntGoodsBLL.SingleModel.GetModel(goodid); if (goodModel == null || goodModel.state == 0) { returnObj.Msg = "产品不存在或已删除"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } if (storeId > 0) { SubStoreEntGoods subGood = SubStoreEntGoodsBLL.SingleModel.GetModelByAppIdStoreIdGoodsId(aid, storeId, goodid); if (subGood == null) { returnObj.Msg = "产品不存在或已下架"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } goodModel.specificationdetail = subGood.SubSpecificationdetail; goodModel.stock = subGood.SubStock; } if (!string.IsNullOrEmpty(goodModel.plabels)) { goodModel.plabelstr = EntGoodsBLL.SingleModel.GetPlabelStr(goodModel.plabels); goodModel.plabelstr_array = goodModel.plabelstr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } goodModel.EntGroups.GroupUserList = userlist; goodModel.EntGroups.GroupsNum = groupnum; goodModel.EntGroups.GroupSponsorList = groupSponsorList; returnObj.dataObj = goodModel; break; } returnObj.isok = true; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取订单列表数据 /// </summary> /// <returns></returns> public ActionResult GetOrderList() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } var appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel($"id ={appId}"); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } int storeId = Context.GetRequestInt("storeid", -1); if (storeId < 0) { return(Json(new { isok = false, msg = "系统繁忙storeId_null" })); } string storeSqlwhere = $"appid={appId} and homeid=0"; if (storeId > 0) { storeSqlwhere = $"id={storeId}"; } FootBath storeModel = FootBathBLL.SingleModel.GetModel(storeSqlwhere); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } int tab = Context.GetRequestInt("tab", 0); if (tab <= 0) { return(Json(new { isok = false, msg = "系统繁忙tab_null" })); } string orderNum = Context.GetRequest("orderNum", string.Empty); string nickName = Context.GetRequest("accName", string.Empty); string phone = Context.GetRequest("accPhone", string.Empty); int buyMode = Context.GetRequestInt("buyMode", 0); string goodsName = Context.GetRequest("goodsName", string.Empty); int levelid = Context.GetRequestInt("levelid", 0); int orderState = Context.GetRequestInt("orderState", -999); int pageIndex = Context.GetRequestInt("pageIndex", 1); int pageSize = Context.GetRequestInt("pageSize", 10); string startdate = Context.GetRequest("startdate", string.Empty); string enddate = Context.GetRequest("enddate", string.Empty); List <EntGoodsOrder> OrderList = null; List <MySqlParameter> parameters = null; string sqlwhere = $" getway={tab}"; string storeids = string.Empty; if (storeId > 0) { storeids = storeId.ToString(); sqlwhere += $" and storeId={storeId}"; } else { List <FootBath> storeList = FootBathBLL.SingleModel.GetList($"HomeId={storeModel.Id} and state>0 and IsDel>-1"); if (storeList == null || storeList.Count <= 0) { storeids = storeModel.Id.ToString(); sqlwhere += $" and storeId={storeModel.Id}"; } else { string ids = string.Join(",", storeList.Select(s => s.Id)); storeids = $"{storeModel.Id},{ids}"; sqlwhere += $" and storeId in ({storeModel.Id},{ids})"; } } int recordCount = 0; List <string> userUidList = new List <string>(); if (!string.IsNullOrEmpty(nickName)) { parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("@NickName", $"%{nickName}%")); List <C_UserInfo> userList = C_UserInfoBLL.SingleModel.GetListByParam($"nickname like @NickName and appId='{appAcountRelation.AppId}'", parameters.ToArray()); if (userList == null || userList.Count <= 0) { return(Json(new { isok = true, OrderList = OrderList, recordCount = recordCount })); } userUidList = userList.Select(s => s.Id.ToString()).ToList(); if (userUidList == null || userUidList.Count <= 0) { return(Json(new { isok = true, OrderList = OrderList, recordCount = recordCount })); } } List <string> levelUidList = new List <string>(); if (levelid > 0) { List <VipRelation> relationList = VipRelationBLL.SingleModel.GetList($"levelid={levelid}"); if (relationList == null || relationList.Count <= 0) { return(Json(new { isok = true, OrderList = OrderList, recordCount = recordCount })); } levelUidList = relationList.Select(s => s.uid.ToString()).ToList(); if (levelUidList == null || levelUidList.Count <= 0) { return(Json(new { isok = true, OrderList = OrderList, recordCount = recordCount })); } } List <string> uidList = new List <string>(); if (levelUidList.Count > 0 || userUidList.Count > 0) { if (levelUidList.Count > 0 && levelUidList.Count > 0) { uidList = levelUidList.Intersect(levelUidList).ToList(); } else if (levelUidList.Count > 0) { uidList = levelUidList; } else if (userUidList.Count > 0) { uidList = userUidList; } } if (uidList.Count > 0) { sqlwhere += $" and UserId in ({string.Join(",", uidList)})"; } if (!string.IsNullOrEmpty(goodsName)) { List <FootBath> stores = FootBathBLL.SingleModel.GetList($" id in ({storeids})"); string aids = string.Join(",", stores.Select(s => s.appId).ToList()); parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("@name", $"%{goodsName}%")); List <EntGoods> goodsList = EntGoodsBLL.SingleModel.GetListByParam($" aid in ({aids}) and state> 0 and name like @name", parameters.ToArray()); if (goodsList == null || goodsList.Count <= 0) { return(Json(new { isok = true, OrderList = OrderList, recordCount = recordCount, msg = "name_null" })); } List <string> typeidSplit = goodsList.Select(g => g.id.ToString()).ToList(); if (typeidSplit.Count > 0) { typeidSplit = typeidSplit.Select(p => p = "FIND_IN_SET('" + p + "',GoodsGuid)").ToList(); sqlwhere += $" and (" + string.Join(" or ", typeidSplit) + ")"; } } parameters = new List <MySqlParameter>(); if (!string.IsNullOrEmpty(orderNum)) { sqlwhere += $" and orderNum like @orderNum"; parameters.Add(new MySqlParameter("@orderNum", $"%{orderNum}%")); } if (!string.IsNullOrEmpty(phone)) { sqlwhere += $" and AccepterTelePhone like @phone"; parameters.Add(new MySqlParameter("@phone", $"%{phone}%")); } if (!string.IsNullOrEmpty(startdate)) { sqlwhere += $" and CreateDate >= @startdate"; parameters.Add(new MySqlParameter("@startdate", $"{startdate} 00:00:00")); } if (!string.IsNullOrEmpty(enddate)) { sqlwhere += $" and CreateDate <= @enddate"; parameters.Add(new MySqlParameter("@enddate", $"{enddate} 23:59:59")); } if (buyMode > 0) { sqlwhere += $" and buyMode={buyMode}"; } if (orderState > -999) { if (orderState == -2) { sqlwhere += $" and State in({(int)MiniAppEntOrderState.退款中},{(int)MiniAppEntOrderState.退款成功},{(int)MiniAppEntOrderState.退款失败})"; } else { sqlwhere += $" and State={orderState}"; } } List <EntGoodsOrder> orderList = EntGoodsOrderBLL.SingleModel.GetListByParam(sqlwhere, parameters.ToArray(), pageSize, pageIndex, "*", "id desc"); //log4net.LogHelper.WriteInfo(this.GetType(), sqlwhere); if (orderList != null && orderList.Count > 0) { string bathIds = string.Join(",", orderList.Select(s => s.StoreId).Distinct()); List <FootBath> footBathList = FootBathBLL.SingleModel.GetListByIds(bathIds); string userIds = string.Join(",", orderList.Select(s => s.UserId).Distinct()); List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds); string orderIds = string.Join(",", orderList.Select(s => s.Id)); List <EntGoodsCart> entGoodsCartList = EntGoodsCartBLL.SingleModel.GetListByOrderIds(orderIds); string goodsIds = string.Join(",", entGoodsCartList?.Select(s => s.FoodGoodsId).Distinct()); List <EntGoods> entGoodsList = EntGoodsBLL.SingleModel.GetListByIds(goodsIds); orderList.ForEach(o => { FootBath store = footBathList?.FirstOrDefault(f => f.Id == o.StoreId); if (store != null) { UserRole userrole = UserRoleBLL.SingleModel.GetModel($"storeid={store.Id} and appid={store.appId} and state>0"); if (userrole != null) { o.isSelfOrder = userrole.UserId == dzaccount.Id; } o.storeName = store.StoreName; } C_UserInfo userInfo = userInfoList?.FirstOrDefault(f => f.Id == o.UserId); string sql = $"select name from viprelation as a left join viplevel as b on a.levelid = b.id where a.uid={o.UserId}"; o.vipLevelName = SqlMySql.ExecuteScalar(dbEnum.MINIAPP.ToString(), CommandType.Text, sql).ToString();//获取会员等级 if (userInfo != null) { o.nickName = userInfo.NickName; } //获取购买的商品 o.goodsCarts = entGoodsCartList?.Where(w => w.GoodsOrderId == o.Id).ToList(); if (o.goodsCarts != null && o.goodsCarts.Count > 0) { o.goodsNames = string.Empty; foreach (var goodsCart in o.goodsCarts) { EntGoods goods = entGoodsList?.FirstOrDefault(f => f.id == goodsCart.FoodGoodsId); if (goods == null) { continue; } goodsCart.GoodName = goods.name; if (!string.IsNullOrEmpty(goodsCart.SpecInfo)) { o.goodsNames += $"{goods.name}({goodsCart.SpecInfo}),"; } else { o.goodsNames += $"{goods.name},"; } o.goodsNames = o.goodsNames.TrimEnd(','); } } }); } //判断是否有团订单 EntGroupSponsorBLL.SingleModel.GetSponsorState(ref orderList); recordCount = EntGoodsOrderBLL.SingleModel.GetCount(sqlwhere, parameters.ToArray()); return(Json(new { isok = true, orderList = orderList, recordCount = recordCount })); }
/// <summary> /// 添加编辑 礼物 /// </summary> /// <returns></returns> public ActionResult SaveGiftInfo() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙id_null" })); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙account_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙store_null" })); } int id = Context.GetRequestInt("id", 0); string name = Context.GetRequest("name", string.Empty); int count = Context.GetRequestInt("stock", 0); if (string.IsNullOrEmpty(name)) { return(Json(new { isok = false, msg = "请输入套餐名称" })); } if (name.Length > 20) { return(Json(new { isok = false, msg = "套餐名称不能超过5字" })); } if (count < 1 || count > 999) { return(Json(new { isok = false, msg = "鲜花数量范围:0~999之间" })); } EntGoods giftInfo = EntGoodsBLL.SingleModel.GetGiftInfoByName(appId, (int)GoodsType.足浴版送花套餐, name); bool isok = false; if (giftInfo != null && giftInfo.state > 0 && id <= 0) { return(Json(new { isok = false, msg = "该套餐名称已存在" })); } if (giftInfo != null && giftInfo.state > 0 && id > 0 && giftInfo.id != id) { return(Json(new { isok = false, msg = "该套餐名称已存在" })); } //添加 if (id <= 0) { giftInfo = new EntGoods() { aid = appId, exttypes = ((int)GoodsType.足浴版送花套餐).ToString(), stock = count, name = name, state = 1, }; giftInfo.id = Convert.ToInt32(EntGoodsBLL.SingleModel.Add(giftInfo)); isok = giftInfo.id > 0; } //$"aid ={appId} and state> 0 and exttypes='{(int)GoodsType.足浴版送花套餐}'"; else { //编辑保存 giftInfo = EntGoodsBLL.SingleModel.GetGiftInfo(appId, id, (int)GoodsType.足浴版送花套餐); if (giftInfo == null) { return(Json(new { isok = false, msg = "数据错误" })); } giftInfo.stock = count; giftInfo.name = name; isok = EntGoodsBLL.SingleModel.Update(giftInfo, "name,stock"); } string msg = isok ? "保存成功" : "保存失败"; if (isok) { return(Json(new { isok = isok, msg = msg, info = giftInfo })); } else { return(Json(new { isok = isok, msg = msg })); } }
/// <summary> /// 更新分销产品分销相关信息 只有返回大于0才表示成功 /// </summary> /// <param name="salesmanGoods"></param> /// <param name="appId"></param> /// <param name="pageType"></param> /// <param name="ids"></param> /// <returns></returns> public int UpdateSalesmanGoods(SalesmanGoods salesmanGoods, int appId, int pageType, string ids = "") { int code = -999; string strWhere = string.Empty; switch (pageType) { case (int)TmpType.小程序专业模板: SalesManConfig salesManConfig = base.GetModel($"appId={appId}"); if (!string.IsNullOrEmpty(salesManConfig.configStr)) { salesManConfig.configModel = JsonConvert.DeserializeObject <ConfigModel>(salesManConfig.configStr); } double cps_rate = 0.00; if (salesmanGoods.isDefaultCps_Rate == 0 && salesManConfig.configModel != null) { //默认佣金比例后台设置的 cps_rate = salesManConfig.configModel.payMentManager.cps_rate; } else { //自定义佣金比例 cps_rate = salesmanGoods.cps_rate; } if (string.IsNullOrEmpty(ids)) { //单个设置 strWhere = $"aid={appId} and Id={salesmanGoods.goodsId} and state=1 and goodtype={(int)EntGoodsType.普通产品}"; EntGoods entGood = EntGoodsBLL.SingleModel.GetModel(strWhere); if (entGood == null) { code = -1; } else { entGood.distributionTime = DateTime.Now; entGood.isDefaultCps_Rate = salesmanGoods.isDefaultCps_Rate; entGood.isDistribution = salesmanGoods.isDistribution; entGood.cps_rate = cps_rate; if (EntGoodsBLL.SingleModel.Update(entGood, "distributionTime,isDefaultCps_Rate,isDistribution,cps_rate")) { code = 1; } else { code = -2; } } } else { //批量设置 code = EntGoodsBLL.SingleModel.ExecuteNonQuery($"update EntGoods set distributionTime='{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}',isDefaultCps_Rate={salesmanGoods.isDefaultCps_Rate},isDistribution={salesmanGoods.isDistribution},cps_rate={cps_rate} where Id in({ids})"); } break; } return(code); }
/// <summary> /// 返回购物车里对应的产品佣金比例 /// </summary> /// <param name="userId"></param> /// <param name="goodsId"></param> /// <returns></returns> public CpsRateCar GetCps_rate(int userId, int goodsId, int appId, int salesManRecordId) { CpsRateCar cpsRateCar = new CpsRateCar(); EntGoods entGoods = EntGoodsBLL.SingleModel.GetModel(goodsId); SalesManConfig salesManConfig = SalesManConfigBLL.SingleModel.GetModel($"appId={appId}"); if (entGoods != null && entGoods.isDistribution != 0 && salesManConfig != null && !string.IsNullOrEmpty(salesManConfig.configStr)) { #region 表示开启分销员购买权限,分销员购买自己分享的产品不受保护期限制,佣金算自己的 SalesMan salesMan = SalesManBLL.SingleModel.GetModel($"UserId={userId} and state=2"); ConfigModel configModel = JsonConvert.DeserializeObject <ConfigModel>(salesManConfig.configStr); if (configModel.payMentManager.allow_seller_buy == 1 && salesMan != null) { salesManRecordId = Convert.ToInt32(base.Add(new SalesManRecord() { appId = entGoods.aid, salesManId = salesMan.Id, configStr = salesManConfig.configStr, salesmanGoodsId = goodsId, state = 1, addTime = DateTime.Now, cps_rate = (entGoods.isDefaultCps_Rate == 0 ? configModel.payMentManager.cps_rate : entGoods.cps_rate) })); if (salesManRecordId <= 0) { return(cpsRateCar); } cpsRateCar.salesManRecordUserId = -1; cpsRateCar.recordId = salesManRecordId; cpsRateCar.cps_rate = entGoods.cps_rate; return(cpsRateCar); } #endregion // SalesManRecordUser salesManRecordUser = salesManRecordUserBLL.GetModel($" userId={userId} and goodsId={goodsId} and DATE_ADD(UpdateTime,INTERVAL protected_time Day)>now()"); SalesManRecordUser salesManRecordUser = SalesManRecordUserBLL.SingleModel.GetModel($" userId={userId} and DATE_ADD(UpdateTime,INTERVAL protected_time Day)>now()"); //MINUTE if (salesManRecordUser != null) //用户-分销员存在绑定关系 计算佣金才返回对应每条购物车产品佣金比例 { SalesManRecord salesManRecord = base.GetModel($"Id={salesManRecordId} and state=1"); if (salesManRecord != null)//表示从分享推广页面进入购买的 { salesManRecord.configModel = JsonConvert.DeserializeObject <ConfigModel>(salesManRecord.configStr); salesMan = SalesManBLL.SingleModel.GetModel(salesManRecord.salesManId); if (salesManRecord.configModel.payMentManager.allow_seller_buy == 1 && salesMan != null && salesMan.UserId == userId) { //表示开启分销员购买权限,分销员购买自己分享的产品不受保护期限制,佣金算自己的 cpsRateCar.salesManRecordUserId = -1; cpsRateCar.recordId = salesManRecord.Id; cpsRateCar.cps_rate = entGoods.cps_rate; return(cpsRateCar); } } //表示从普通页面进入购买的 salesManRecord = base.GetModel($"Id={salesManRecordUser.recordId} and state=1"); if (salesManRecord != null && entGoods != null) { if (entGoods.isDefaultCps_Rate == 0) { salesManRecord.configModel = JsonConvert.DeserializeObject <ConfigModel>(salesManConfig.configStr); if (salesManRecord.configModel != null && salesManRecord.configModel.payMentManager != null) { cpsRateCar.cps_rate = salesManRecord.configModel.payMentManager.cps_rate; } } else { cpsRateCar.cps_rate = entGoods.cps_rate; } cpsRateCar.salesManRecordUserId = salesManRecordUser.Id; cpsRateCar.recordId = salesManRecordUser.recordId; return(cpsRateCar); } } else { //这里表示没有保护期或者保护期失效 再根据是不是直接通过分销分享链接买的如果是则算给该分销员 SalesManRecord salesManRecord = base.GetModel($"Id={salesManRecordId} and state=1"); if (salesManRecord != null) { //表示关闭了保护期设置 直接通过分享链接购买 salesManRecordUser = SalesManRecordUserBLL.SingleModel.GetModel($" userId={userId} and protected_time=0 and salesmanId={salesManRecord.salesManId}"); if (salesManRecordUser != null) { cpsRateCar.salesManRecordUserId = salesManRecordUser.Id; cpsRateCar.recordId = salesManRecord.Id; cpsRateCar.cps_rate = entGoods.cps_rate; } } } } return(cpsRateCar); }
/// <summary> /// 获取技师服务时间表 /// </summary> /// <returns></returns> public ActionResult GetServiceTimeTable() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } //获取可做此服务的技师 int serviceId = Context.GetRequestInt("serviceId", 0); if (serviceId <= 0) { return(Json(new { isok = false, msg = "系统繁忙serviceId_null" })); } EntGoods serviceInfo = EntGoodsBLL.SingleModel.GetServiceById(storeModel.appId, serviceId, 1); if (serviceInfo == null) { return(Json(new { isok = -1, msg = "该服务已下架" }, JsonRequestBehavior.AllowGet)); } List <TechnicianInfo> technicianList = TechnicianInfoBLL.SingleModel.GetListByServiceId(storeModel.Id, serviceInfo.id); //获取技师的服务时间表 int tid = Context.GetRequestInt("tid", 0); if (tid <= 0) { return(Json(new { isok = false, msg = "系统繁忙tid_null" })); } TechnicianInfo technicianInfo = TechnicianInfoBLL.SingleModel.GetModelById(tid); if (technicianInfo == null) { return(Json(new { isok = false, msg = "系统繁忙technicianInfo_null" })); } storeModel.switchModel = JsonConvert.DeserializeObject <SwitchModel>(storeModel.SwitchConfig); List <object> timeList = new List <object>(); for (int i = 0; i <= storeModel.switchModel.PresetTime; i++) { object timeTable = ServiceTimeBLL.SingleModel.GetTimeTable(storeModel.switchModel, i, storeModel.appId, storeModel.Id, technicianInfo.id); timeList.Add(timeTable); } return(Json(new { isok = true, timeList = timeList, technicianList = technicianList })); }