Example #1
0
        /// <summary>
        /// 客户预订成功后将选定的时间点添加到已服务时间表
        /// </summary>
        /// <param name="store"></param>
        /// <param name="goodsCart"></param>
        public void AddSelServiceTime(FootBath store, EntGoodsCart goodsCart, SwitchModel switchModel = null)
        {
            ServiceTime serviceTimeModel = GetModel($"aid={store.appId} and storeid={store.Id} and tid={goodsCart.technicianId} and date='{goodsCart.reservationTime.ToShortDateString()}'");

            if (serviceTimeModel == null)
            {
                serviceTimeModel            = new ServiceTime();
                serviceTimeModel.aid        = store.appId;
                serviceTimeModel.storeId    = store.Id;
                serviceTimeModel.tid        = goodsCart.technicianId;
                serviceTimeModel.date       = Convert.ToDateTime(goodsCart.reservationTime.ToShortDateString());
                serviceTimeModel.time       = goodsCart.reservationTime.ToString("HH:mm");//SelTimeStr(goodsCart.reservationTime, goodsCart.goodsMsg.ServiceTime, switchModel.TimeInterval);
                serviceTimeModel.createTime = DateTime.Now;
                Add(serviceTimeModel);
            }
            else
            {
                serviceTimeModel.time      += "," + goodsCart.reservationTime.ToString("HH:mm"); //SelTimeStr(goodsCart.reservationTime, goodsCart.goodsMsg.ServiceTime, switchModel.TimeInterval);
                serviceTimeModel.date       = Convert.ToDateTime(goodsCart.reservationTime.ToShortDateString());
                serviceTimeModel.createTime = DateTime.Now;
                MySqlParameter[] arr    = null;
                string           strSql = BuildUpdateSql(serviceTimeModel, "time,createtime", out arr);
                Update(serviceTimeModel, "time,createtime,date");
            }
        }
Example #2
0
        public EntGoodsCart GetFlashDealPrice(EntGoodsCart cartItem, FlashDealItem flashItem)
        {
            if (flashItem == null || flashItem.Id == 0)
            {
                return(cartItem);
            }
            FlashItemSpec flashItemSpec = null;

            if (!string.IsNullOrWhiteSpace(cartItem.SpecIds))
            {
                flashItemSpec = flashItem.GetSpecs().FirstOrDefault(spec => spec.Id == cartItem.SpecIds);
            }
            if (flashItemSpec != null)
            {
                cartItem.Price         = flashItemSpec.DealPrice;
                cartItem.originalPrice = flashItemSpec.OrigPrice;
            }
            else
            {
                cartItem.Price         = flashItem.DealPrice;
                cartItem.originalPrice = flashItem.OrigPrice;
            }
            //折扣最低0.01元
            //cartItem.Price = cartItem.Price <= 0 ? 1 : cartItem.Price;
            return(cartItem);
        }
Example #3
0
        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);
        }
        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 }));
        }
Example #5
0
        /// <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>
        /// <returns></returns>
        public ActionResult SaveReserve()
        {
            #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.GetModelById(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, 1);
            if (orderInfo == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙order_null" }));
            }
            #endregion
            orderInfo.Remark = remark;
            orderInfo.State  = (int)MiniAppEntOrderState.待服务;
            EntGoodsCart cartInfo = EntGoodsCartBLL.SingleModel.GetModelByGoodsOrderId(orderInfo.Id, 1);
            if (cartInfo == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙cart_null" }));
            }
            //修改之前的服务时间,如果修改成功要将此时间从已预订时间表里取消
            DateTime beforeTime = cartInfo.reservationTime;
            try
            {
                cartInfo.reservationTime = Convert.ToDateTime(reservationTime);
            }
            catch
            {
                return(Json(new { isok = false, msg = "时间格式不合法" }));
            }
            //验证服务时间是否已经被选
            ServiceTime dates = ServiceTimeBLL.SingleModel.GetModelByDate(storeModel.appId, storeModel.Id, cartInfo.reservationTime.ToShortDateString());
            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));
                }
            }
            //cartInfo.roomNo = roomNo;
            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)
                {
                    //取消已预订的技师服务时间
                    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");
                    }
                    //修改成功后将选定的时间点添加到已服务时间表
                    dates = ServiceTimeBLL.SingleModel.GetModel(storeModel.appId, cartInfo.technicianId, storeModel.Id, beforeTime.ToShortDateString());
                    ServiceTimeBLL.SingleModel.AddSelServiceTime(storeModel, cartInfo, storeModel.switchModel);
                }
            }
            string msg = isok ? "操作成功" : "操作失败";
            return(Json(new { isok = isok, msg = msg }));
        }
        /// <summary>
        /// 取消预订
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateState()
        {
            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.GetModel($"appId={appId}");

            if (storeModel == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙model_null" }));
            }
            int id = Context.GetRequestInt("id", 0);

            if (id <= 0)
            {
                return(Json(new { isok = false, msg = "系统繁忙orderId_null" }));
            }
            int state = Context.GetRequestInt("state", -7);

            if (state <= -7)
            {
                return(Json(new { isok = false, msg = "系统繁忙state_null" }));
            }
            EntGoodsOrder orderInfo = EntGoodsOrderBLL.SingleModel.GetModelByAidAndId(appId, id, 1);

            if (orderInfo == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙model_null" }));
            }
            //是否是要直接取消的订单<未支付的订单取消订单都是直接取消>
            bool isCanncleOrder = orderInfo.PayDate == Convert.ToDateTime("0001-01-01 00:00:00");

            if (isCanncleOrder)
            {
                orderInfo.State = (int)MiniAppEntOrderState.已取消;
            }
            else
            {
                orderInfo.State = state;
            }
            EntGoodsCart cart = EntGoodsCartBLL.SingleModel.GetModelByGoodsOrderId(orderInfo.Id);

            if (cart == null)
            {
                return(Json(new { isok = false, msg = "服务项目不存在" }));
            }
            ServiceTime serviceTime = ServiceTimeBLL.SingleModel.GetModel(storeModel.appId, cart.technicianId, storeModel.Id, cart.reservationTime.ToShortDateString());

            //取消已预订的技师服务时间
            if (serviceTime != null && !string.IsNullOrEmpty(serviceTime.time))
            {
                List <string> timeList = serviceTime.time.Split(',').ToList();
                timeList.Remove(cart.reservationTime.ToString("HH:mm"));
                serviceTime.time = string.Join(",", timeList);
            }
            bool isok = false;

            if (isCanncleOrder)
            {
                isok = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State");
            }
            else
            {
                isok = EntGoodsOrderBLL.SingleModel.outOrder(appAcountRelation.AppId, orderInfo, serviceTime);
            }

            #region 取消预约通知 模板消息
            if (isok && !isCanncleOrder)
            {
                object objData = TemplateMsg_Miniapp.FootbathGetTemplateMessageData(orderInfo, SendTemplateMessageTypeEnum.足浴预约取消通知);
                TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, SendTemplateMessageTypeEnum.足浴预约取消通知, TmpType.小程序足浴模板, objData);
            }
            #endregion

            string msg = isok ? "操作成功" : "操作失败";
            return(Json(new { isok = isok, msg = msg }));
        }
Example #8
0
        /// <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 bool IsComment(int xcxtemplateType, int goodsType, int goodsId, int orderId, int aid)
        {
            bool iscomment = false;

            switch (xcxtemplateType)
            {
            case (int)TmpType.小程序专业模板:
                switch (goodsType)
                {
                case (int)EntGoodsType.团购商品:
                    GroupUser groupuser = GroupUserBLL.SingleModel.GetModel(orderId);
                    if (groupuser == null)
                    {
                        return(true);
                    }
                    iscomment = ExitModel(aid, groupuser.ObtainUserId, groupuser.GroupId, orderId, goodsType);
                    groupuser.IsCommentting = true;
                    GroupUserBLL.SingleModel.Update(groupuser, "IsCommentting");
                    break;

                case (int)EntGoodsType.拼团产品:
                    EntGoodsCart gentgoodscart = EntGoodsCartBLL.SingleModel.GetModelByGoodsId(orderId, goodsId);
                    if (gentgoodscart == null)
                    {
                        return(true);
                    }
                    iscomment = ExitModel(aid, gentgoodscart.UserId, goodsId, orderId, goodsType);
                    gentgoodscart.IsCommentting = true;
                    EntGoodsCartBLL.SingleModel.Update(gentgoodscart, "IsCommentting");
                    break;

                case (int)EntGoodsType.普通产品:
                    EntGoodsCart entgoodscart = EntGoodsCartBLL.SingleModel.GetModelByGoodsId(orderId, goodsId);
                    if (entgoodscart == null)
                    {
                        return(true);
                    }
                    iscomment = ExitModel(aid, entgoodscart.UserId, goodsId, orderId, goodsType);
                    entgoodscart.IsCommentting = true;
                    EntGoodsCartBLL.SingleModel.Update(entgoodscart, "IsCommentting");
                    break;

                case (int)EntGoodsType.价产品:
                    BargainUser bargainuser = BargainUserBLL.SingleModel.GetModel(orderId);
                    if (bargainuser == null)
                    {
                        return(true);
                    }
                    iscomment = ExitModel(aid, bargainuser.UserId, bargainuser.BId, orderId, goodsType);
                    bargainuser.IsCommentting = true;
                    BargainUserBLL.SingleModel.Update(bargainuser, "IsCommentting");
                    break;
                }
                break;

            case (int)TmpType.小未平台子模版:

                PlatChildGoodsCart platChildGoodsCart = PlatChildGoodsCartBLL.SingleModel.GetModelByGoodsId(orderId, goodsId);
                if (platChildGoodsCart == null)
                {
                    return(true);
                }
                iscomment = ExitModel(aid, platChildGoodsCart.UserId, goodsId, orderId, goodsType);
                platChildGoodsCart.IsCommentting = true;
                PlatChildGoodsCartBLL.SingleModel.Update(platChildGoodsCart, "IsCommentting");
                break;
            }

            return(iscomment);
        }