Exemplo n.º 1
0
        /// <summary>
        /// 发起退款
        /// </summary>
        /// <returns></returns>
        public ActionResult OutOrder()
        {
            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}";

            if (storeId > 0)
            {
                storeSqlwhere = $"id={storeId}";
            }
            FootBath storeModel = FootBathBLL.SingleModel.GetModel(storeSqlwhere);

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

            if (orderId <= 0)
            {
                return(Json(new { isok = false, msg = "系统繁忙orderId_null" }));
            }
            EntGoodsOrder orderInfo = EntGoodsOrderBLL.SingleModel.GetModel($"aId={storeModel.appId} and id={orderId}");

            if (orderInfo == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙order_null" }));
            }
            List <EntGoodsCart> goodscarts = EntGoodsCartBLL.SingleModel.GetList($"GoodsOrderId={orderInfo.Id}");
            bool   isok = EntGoodsOrderBLL.SingleModel.outOrder(goodscarts, storeModel, orderInfo);
            string msg  = "操作失败";

            if (isok)
            {
                msg = "操作成功";
                var data = TemplateMsg_Miniapp.MutilStoreGetTemplateMessageData(orderInfo, SendTemplateMessageTypeEnum.多门店退款通知);
                TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, SendTemplateMessageTypeEnum.多门店退款通知, TmpType.小程序多门店模板, data);
            }
            return(Json(new { isok = isok, msg = msg }));
        }
Exemplo n.º 2
0
        public FlashDealPayment GetByOrder(EntGoodsOrder order)
        {
            order.attrbuteModel = !string.IsNullOrWhiteSpace(order.attribute) ? JsonConvert.DeserializeObject <EntGoodsOrderAttr>(order.attribute) : null;
            if (order.attrbuteModel == null || order.attrbuteModel.flashDealId == 0 || order.attrbuteModel.flashItemId == 0)
            {
                return(null);
            }
            string whereSql = BuildWhereSql(dealId: order.attrbuteModel.flashDealId, itemId: order.attrbuteModel.flashItemId, userId: order.UserId, Aid: order.aId, payOrderId: order.Id);

            return(GetModel(whereSql));
        }
Exemplo n.º 3
0
        public bool PayByEntOrder(EntGoodsOrder order)
        {
            order.attrbuteModel = JsonConvert.DeserializeObject <EntGoodsOrderAttr>(order.attribute);
            miniAppBuyMode payWay    = (miniAppBuyMode)Enum.Parse(typeof(miniAppBuyMode), order.BuyMode.ToString());
            FlashDealItem  flashItem = FlashDealItemBLL.SingleModel.GetModel(order.attrbuteModel.flashItemId);

            TransactionModel tran = new TransactionModel();

            tran.Add(AddUserPayment(item: flashItem, userId: order.UserId, payWay: payWay, payPrice: order.BuyPrice, payOrderId: order.Id, buyCount: order.QtyCount));
            return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray));
        }
Exemplo n.º 4
0
        /// <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 createOrder()
        {
            #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" }));
            }
            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

            if (orderInfo.State == (int)MiniAppEntOrderState.已超时)
            {
                orderInfo.State = (int)MiniAppEntOrderState.务中;
            }
            orderInfo.OrderType = 0;
            orderInfo.ConfDate  = DateTime.Now;
            bool isok = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,ordertype,ConfDate") && VipRelationBLL.SingleModel.updatelevel(orderInfo.UserId, "footbath");
            #region 预约成功通知 模板消息
            if (isok)
            {
                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 }));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 储值支付(足浴版)
        /// </summary>
        /// <param name="orderModel"></param>
        /// <param name="saveMoneyUser"></param>
        /// <returns></returns>
        public bool payOrderBySaveMoneyUser(EntGoodsOrder orderModel, SaveMoneySetUser saveMoneyUser)
        {
            if (saveMoneyUser == null || saveMoneyUser.Id <= 0)
            {
                return(false);
            }
            if (saveMoneyUser.AccountMoney < orderModel.BuyPrice)
            {
                return(false);
            }
            TransactionModel _tranModel = new TransactionModel();

            if (orderModel != null)
            {
                orderModel.PayDate = DateTime.Now;//支付时间
                orderModel.State   = (int)MiniAppEntOrderState.待服务;

                _tranModel.Add(EntGoodsOrderBLL.SingleModel.BuildUpdateSql(orderModel, $"State,PayDate"));

                _tranModel.Add(EntGoodsOrderLogBLL.SingleModel.BuildAddSql(new EntGoodsOrderLog()
                {
                    GoodsOrderId = orderModel.Id, UserId = orderModel.UserId, LogInfo = $" 订单成功支付(储值支付):{orderModel.BuyPrice * 0.01} 元 ", CreateDate = DateTime.Now
                }));
            }
            _tranModel.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog()
            {
                AppId          = saveMoneyUser.AppId,
                UserId         = orderModel.UserId,
                MoneySetUserId = saveMoneyUser.Id,
                Type           = -1,
                BeforeMoney    = saveMoneyUser.AccountMoney,
                AfterMoney     = saveMoneyUser.AccountMoney - orderModel.BuyPrice,
                ChangeMoney    = orderModel.BuyPrice,
                ChangeNote     = $" 购买商品,订单号:{orderModel.OrderNum} ",
                CreateDate     = DateTime.Now,
                State          = 1
            }));

            _tranModel.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney - {orderModel.BuyPrice} where id =  {saveMoneyUser.Id} ; ");
            var isSuccess = SaveMoneySetUserLogBLL.SingleModel.ExecuteTransaction(_tranModel.sqlArray);

            if (isSuccess)
            {
                AfterPaySuccesExecFun(orderModel);
            }

            return(isSuccess);
        }
Exemplo n.º 7
0
        ///// <summary>
        ///// 物流跟踪接口
        ///// </summary>
        ///// <param name="delivery"></param>
        ///// <returns>接口返回JSON</returns>
        //public string GetDeliveryFeed(DeliveryFeedback delivery)
        //{
        //    //string apiStr = WebConfigBLL.DeliveryAPI;
        //    string paramStr = $"&com={delivery.CompanyCode}&nu={delivery.DeliveryNo}";
        //    string requestUrl = $"{apiStr}{paramStr}";
        //    return Utility.HttpHelper.GetData(requestUrl);
        //}

        public bool IsDelivery(EntGoodsOrder order)
        {
            bool isHasInfo = false;

            switch (order.State)
            {
            case (int)MiniAppEntOrderState.退款中:
                isHasInfo = IsHasDelivery(order.Id, DeliveryOrderType.专业版订单用户退货);
                break;

            default:
                isHasInfo = IsHasDelivery(order.Id, DeliveryOrderType.专业版订单商家发货);
                break;
            }
            return(isHasInfo);
        }
Exemplo n.º 8
0
        public int AddPayRecordEnt(EntGoodsOrder order, EntNews attachContent, PayContent payContent, PayContentPayment payInfo)
        {
            PaidSnapShot snapshot = new PaidSnapShot
            {
                UserName      = order.AccepterName,
                Contact       = order.AccepterTelePhone,
                ContentType   = payContent.ContentType,
                ArticleId     = attachContent.id,
                VideoCover    = payContent.VideoCover,
                VideoURL      = payContent.VideoURL,
                PaidAmout     = order.BuyPrice,
                OriginalAmout = payInfo.OrgAmount,
                DiscountInfo  = payInfo.Info,
            };

            return(AddPayRecord(attachContent.aid, attachContent.title, attachContent.paycontent, order.UserId, order.Id, snapshot: snapshot));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 预约付费储值支付
        /// </summary>
        /// <param name="dbOrder"></param>
        /// <param name="saveMoneyUser"></param>
        /// <returns></returns>
        public bool paySubscribeFromOrderBySaveMoneyUser(EntGoodsOrder dbOrder, SaveMoneySetUser saveMoneyUser)
        {
            if (saveMoneyUser == null || saveMoneyUser.Id <= 0)
            {
                return(false);
            }
            if (saveMoneyUser.AccountMoney < dbOrder.BuyPrice)
            {
                return(false);
            }



            TransactionModel tran = new TransactionModel();

            tran.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog()
            {
                AppId          = saveMoneyUser.AppId,
                UserId         = dbOrder.UserId,
                MoneySetUserId = saveMoneyUser.Id,
                Type           = -1,
                BeforeMoney    = saveMoneyUser.AccountMoney,
                AfterMoney     = saveMoneyUser.AccountMoney - dbOrder.BuyPrice,
                ChangeMoney    = dbOrder.BuyPrice,
                ChangeNote     = $" 预约付费,订单号:{dbOrder.OrderNum} ",
                CreateDate     = DateTime.Now,
                State          = 1
            }));
            dbOrder.State = (int)MiniAppEntOrderState.交易成功;

            dbOrder.PayDate = DateTime.Now;
            tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney - {dbOrder.BuyPrice} where id =  {saveMoneyUser.Id} ; ");
            tran.Add($" update Entgoodsorder set state = {dbOrder.State},PayDate = '{dbOrder.PayDateStr}',OrderNum = {dbOrder.OrderNum} where Id = {dbOrder.Id} and state = {(int)MiniAppEntOrderState.待付款 } ; ");


            //记录订单支付日志
            tran.Add(EntGoodsOrderLogBLL.SingleModel.BuildAddSql(new EntGoodsOrderLog()
            {
                GoodsOrderId = dbOrder.Id, UserId = dbOrder.UserId, LogInfo = $" 专业版预约付费订单使用储值金额成功支付:{dbOrder.BuyPrice * 0.01} 元 ", CreateDate = DateTime.Now
            }));
            return(SaveMoneySetUserLogBLL.SingleModel.ExecuteTransaction(tran.sqlArray));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 标记订单已评论
        /// </summary>
        /// <param name="xcxtemplateType">模板类型</param>
        /// <param name="goodsType">商品类型</param>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public bool OrderCommenting(int xcxtemplateType, int goodsType, int orderId)
        {
            switch (xcxtemplateType)
            {
            case (int)TmpType.小程序专业模板:
                switch (goodsType)
                {
                case (int)EntGoodsType.拼团产品:
                case (int)EntGoodsType.普通产品:
                    EntGoodsOrder entOrder = EntGoodsOrderBLL.SingleModel.GetModel(orderId);
                    if (entOrder == null)
                    {
                        return(false);
                    }
                    entOrder.IsCommentting = true;
                    return(EntGoodsOrderBLL.SingleModel.Update(entOrder, "IsCommentting"));

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

            case (int)TmpType.小未平台子模版:
                PlatChildGoodsOrder platOrder = PlatChildGoodsOrderBLL.SingleModel.GetModel(orderId);
                if (platOrder == null)
                {
                    return(false);
                }
                platOrder.IsCommentting = true;
                return(PlatChildGoodsOrderBLL.SingleModel.Update(platOrder, "IsCommentting"));
            }

            return(false);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 储值支付后
        /// </summary>
        /// <param name="foodGoodsOrder"></param>
        public void AfterPaySuccesExecFun(EntGoodsOrder orderModel)
        {
            if (orderModel == null)
            {
                return;
            }

            #region 预订成功通知商家 公众号模板消息

            //FootBathBLL _footbathBll = new FootBathBLL();

            //FootBath store = _footbathBll.GetModel(orderModel.StoreId);
            //XcxAppAccountRelation relationInfo = xapprBll.GetModelById(store.Id);
            ////Account account = accountBll.GetModel($"id='{}'")
            ////relationInfo.AccountId
            ////var xappr = xapprBll.GetModel(food.appId);

            //#region 发送订单支付成功通知 模板消息
            //#endregion

            //#region 发送模板消息通知商家
            //TemplateMsg_Gzh.SendTemplateMessage(WebSiteConfig.DZ_footbath_ReserveTemplateId,"", .);
            #endregion
        }
Exemplo n.º 12
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);
            }
        }
Exemplo n.º 13
0
        public ActionResult GetReductionCard()
        {
            Coupons model     = null;
            int     couponsId = Context.GetRequestInt("couponsId", 0);

            if (couponsId <= 0)
            {
                return(Json(new { isok = false, msg = "我钥匙被弄丢了", coupon = model }));
            }
            int orderId = Context.GetRequestInt("orderId", 0);

            if (orderId <= 0)
            {
                return(Json(new { isok = false, msg = "我是不存在的", coupon = model }));
            }

            int  aId        = 0;
            Food store_Food = null;
            int  orderType  = Context.GetRequestInt("orderType", 0);//默认专业版,多门店版

            switch (orderType)
            {
            case 0:    //专业版,多门店版
                EntGoodsOrder orderInfo = EntGoodsOrderBLL.SingleModel.GetModel(orderId);
                if (orderInfo == null)
                {
                    return(Json(new { isok = false, msg = "活动已过期", coupon = model }));
                }
                aId = orderInfo.aId;
                break;

            case 1:    //餐饮
                FoodGoodsOrder orderInfo_Food = FoodGoodsOrderBLL.SingleModel.GetModel(orderId);
                if (orderInfo_Food == null)
                {
                    return(Json(new { isok = false, msg = "活动已过期", coupon = model }));
                }
                store_Food = FoodBLL.SingleModel.GetModel(orderInfo_Food.StoreId);
                if (store_Food == null)
                {
                    return(Json(new { isok = false, msg = "活动已过期_", coupon = model }));
                }

                aId = store_Food.appId;
                break;
            }

            lock (lockgetReductionCard)
            {
                model = CouponsBLL.SingleModel.GetModelByIdAndAppId(couponsId, aId, (int)CouponState.已开启);
                if (model == null)
                {
                    return(Json(new { isok = false, msg = "立减金已消失", coupon = model }));
                }

                List <CouponLog> loglist = CouponLogBLL.SingleModel.GetList($"couponid in ({model.Id}) and state!=4");

                int userId = Context.GetRequestInt("userId", 0);
                if (userId <= 0)
                {
                    return(Json(new { isok = false, msg = "id错误", coupon = model }));
                }
                C_UserInfo user = C_UserInfoBLL.SingleModel.GetModel(userId);
                if (user == null)
                {
                    return(Json(new { isok = false, msg = "用户不存在", coupon = model }));
                }
                DateTime date = DateTime.Now;

                if ((DateTime.Compare(date, model.StartUseTime) > 0 && DateTime.Compare(date, model.EndUseTime) < 0 && model.ValType == 0) || model.ValType != 0)
                {
                    List <CouponLog>  logList  = CouponLogBLL.SingleModel.GetList($" CouponId={model.Id} and fromorderid={orderId} ") ?? new List <CouponLog>();
                    List <C_UserInfo> userList = new List <C_UserInfo>();
                    string            userIds  = string.Join(",", logList.Select(log => log.UserId).ToList());
                    if (logList.Count > 0)
                    {
                        userList           = C_UserInfoBLL.SingleModel.GetList($"id in ( {userIds} )") ?? new List <C_UserInfo>();
                        model.StartUseTime = logList[0].StartUseTime;
                        model.EndUseTime   = logList[0].EndUseTime;
                    }
                    List <CouponLog> userGetList = CouponLogBLL.SingleModel.GetList($"couponId={couponsId} and userid={user.Id}");

                    //已领取完
                    if (userList.Count >= model.SatisfyNum)
                    {
                        C_UserInfo userInfo = userList.Where(u => u.Id == user.Id).FirstOrDefault();
                        return(Json(new { isok = true, coupon = model, userList = userList, userInfo = userInfo }));
                    }


                    //未领取过这份立减金
                    if (logList.Where(log => log.UserId == user.Id).ToList().Count <= 0)
                    {
                        List <CouponLog> temploglist = loglist?.Where(w => w.CouponId == model.Id).ToList();
                        if (temploglist != null && temploglist.Count > 0)
                        {
                            //已领取份数
                            int orderCount = temploglist.GroupBy(g => g.FromOrderId).Count();
                            //库存是否足够
                            model.RemNum = model.CreateNum - orderCount;
                            if (model.RemNum <= 0)
                            {
                                return(Json(new { isok = false, msg = "立减金已放送完毕,请关注下次的立减金优惠哦", coupon = model }));
                            }
                        }
                        //超过领取限制
                        if (userGetList != null && userGetList.Count >= model.LimitReceive && model.LimitReceive > 0)
                        {
                            return(Json(new { isok = false, msg = "你已超过领取限制", coupon = model }));
                        }
                        bool      isok      = false;
                        CouponLog getCoupon = new CouponLog
                        {
                            CouponId     = model.Id,
                            CouponName   = model.CouponName,
                            FromOrderId  = orderId,
                            UserId       = user.Id,
                            State        = 4,
                            StartUseTime = model.StartUseTime,
                            EndUseTime   = model.EndUseTime,
                            AddTime      = DateTime.Now,
                            StoreId      = model.StoreId
                        };
                        getCoupon.Id = Convert.ToInt32(CouponLogBLL.SingleModel.Add(getCoupon));
                        isok         = getCoupon.Id > 0;

                        if (isok)
                        {
                            logList.Add(getCoupon);
                            userList.Add(user);
                        }
                        else
                        {
                            return(Json(new { isok = false, msg = "出了点小问题~", coupon = model }));
                        }
                        //满足条件
                        if (userList.Count == model.SatisfyNum)
                        {
                            if (model.ValType == 1)
                            {
                                model.StartUseTime = Convert.ToDateTime(date.AddDays(1).ToString("yyyy-MM-dd 00:00:00"));
                                model.EndUseTime   = Convert.ToDateTime(date.AddDays(model.ValDay).ToString("yyyy-MM-dd 23:59:59"));
                            }
                            //领券当天有效
                            else if (model.ValType == 2)
                            {
                                model.StartUseTime = Convert.ToDateTime(date.ToString("yyyy-MM-dd 00:00:00"));
                                model.EndUseTime   = Convert.ToDateTime(date.AddDays(model.ValDay - 1).ToString("yyyy-MM-dd 23:59:59"));
                            }
                            foreach (CouponLog log in logList)
                            {
                                log.StartUseTime = model.StartUseTime;
                                log.EndUseTime   = model.EndUseTime;
                                log.State        = 0;
                                CouponLogBLL.SingleModel.Update(log, "State,StartUseTime,EndUseTime");
                            }
                        }
                    }
                    return(Json(new { isok = true, userList = userList, coupon = model, userInfo = user }));
                }
            }

            return(Json(new { isok = false, msg = "立减金Miss", coupon = model }));
        }
Exemplo n.º 14
0
        /// <summary>
        /// 拼团退款
        /// </summary>
        /// <param name="item"></param>
        /// <param name="type">0:拼团失败退款,1:店主手动退款</param>
        /// <returns></returns>
        public bool EntGroupReFundQueue(EntGoodsOrder item, ref string msg)
        {
            int paytype = item.BuyMode;

            TransactionModel tranmodel = new MiniApp.TransactionModel();
            EntGroupSponsor  csg       = EntGroupSponsorBLL.SingleModel.GetModel(item.GroupId);

            if (csg == null)
            {
                msg        = "小程序拼团商品不存在啦=" + item.GroupId;
                item.State = (int)MiniAppEntOrderState.已取消;
                EntGoodsOrderBLL.SingleModel.Update(item, "State");
                return(false);
            }
            EntGroupSponsor gsinfo = EntGroupSponsorBLL.SingleModel.GetModel(item.GroupId);

            if (gsinfo == null)
            {
                msg        = "小程序拼团团购不存在啦=" + item.GroupId;
                item.State = (int)MiniAppEntOrderState.已取消;
                EntGoodsOrderBLL.SingleModel.Update(item, "State");
                return(false);
            }

            if (item.BuyPrice <= 0)
            {
                msg = "xxxxxxxxxxxxx小程序拼团价格为0不需要退款=" + item.Id;
                return(false);
            }

            if (item.State == (int)MiniAppEntOrderState.退款成功)
            {
                msg = "xxxxxxxxxxxxx小程序拼团状态有误,不能退款=" + item.Id + ",paystate=" + item.State + "," + (int)MiniAppEntOrderState.退款成功;
                return(false);
            }

            item.State = (int)MiniAppEntOrderState.退款成功;
            //更新用户订单状态
            tranmodel.Add($"update EntGoodsOrder set State={item.State} where id={item.Id}");

            //判断是否是微信支付
            if (paytype == (int)miniAppBuyMode.微信支付)
            {
                CityMorders order = _cityMordersBLL.GetModel(item.OrderId);
                if (order == null)
                {
                    msg        = "xxxxxxxxxxxxxxxxxx小程序拼团退款查不到支付订单 ID=" + item.Id;
                    item.State = (int)MiniappPayState.已失效;
                    EntGoodsOrderBLL.SingleModel.Update(item, "State");
                    return(false);
                }

                //插入退款队列
                ReFundQueue reModel = new ReFundQueue();
                reModel.minisnsId = -5;
                reModel.money     = item.BuyPrice;
                reModel.orderid   = item.OrderId;
                reModel.traid     = order.trade_no;
                reModel.addtime   = DateTime.Now;
                reModel.note      = "小程序专业版拼团退款";
                reModel.retype    = 1;
                tranmodel.Add(base.BuildAddSql(reModel));
            }
            else if (paytype == (int)miniAppBuyMode.储值支付)
            {
                //储值卡退款
                tranmodel.Add(SaveMoneySetUserBLL.SingleModel.GetCommandCarPriceSql(item.AppId, item.UserId, item.BuyPrice, 1, item.OrderId, item.OrderNum).ToArray());
                if (tranmodel.sqlArray.Length <= 0)
                {
                    msg = "xxxxxxxxxxxxxxxxxx专业版拼团储值卡退款失败,ID=" + item.Id;
                    return(false);
                }
            }

            if (tranmodel.sqlArray.Length <= 0)
            {
                msg = "xxxxxxxxxxxxxxxxxx专业版拼团退款失败,ID=" + item.Id;
                return(false);
            }

            if (!ExecuteTransactionDataCorect(tranmodel.sqlArray, tranmodel.ParameterArray))
            {
                msg = "xxxxxxxxxxxxxxxxxx专业版拼团退款事务执行失败,ID=" + item.Id + "sql:" + string.Join(";", tranmodel.sqlArray);
                return(false);
            }

            if (!EntGoodsOrderBLL.SingleModel.updateStock(item, (int)MiniAppEntOrderState.退款成功))
            {
                msg = "xxxxxxxxxxxxxxxxxx专业版拼团退款更新库存失败,ID=" + item.Id;
                return(false);
            }

            msg = "xxxxxxxxxxxxxxxxxx专业版拼团退款成功,ID=" + item.Id;

            //根据订单释放库存
            return(true);
        }
Exemplo n.º 15
0
        /// <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" }));
            }
            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}";

            if (storeId > 0)
            {
                storeSqlwhere = $"id={storeId}";
            }
            FootBath storeModel = FootBathBLL.SingleModel.GetModel(storeSqlwhere);

            if (storeModel == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙model_null" }));
            }
            string msg     = "操作失败";
            bool   isok    = false;
            int    state   = Context.GetRequestInt("state", -999);
            int    orderId = Context.GetRequestInt("id", 0);

            if (orderId <= 0)
            {
                return(Json(new { isok = false, msg = "系统繁忙orderId_null" }));
            }
            EntGoodsOrder orderInfo = EntGoodsOrderBLL.SingleModel.GetModel($"aId={appId} and id={orderId}");

            if (orderInfo == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙order_null" }));
            }
            SendTemplateMessageTypeEnum templateType = new SendTemplateMessageTypeEnum();

            switch (state)
            {
            case (int)MiniAppEntOrderState.已取消:
                templateType    = SendTemplateMessageTypeEnum.多门店订单取消通知;
                orderInfo.State = (int)MiniAppEntOrderState.已取消;
                break;

            case (int)MiniAppEntOrderState.待接单:
                templateType    = SendTemplateMessageTypeEnum.多门店反馈处理结果通知;
                orderInfo.State = (int)MiniAppEntOrderState.待接单;
                break;

            case (int)MiniAppEntOrderState.待配送:
                templateType    = SendTemplateMessageTypeEnum.多门店订单确认通知;
                orderInfo.State = (int)MiniAppEntOrderState.待配送;
                break;

            case (int)MiniAppEntOrderState.待确认送达:
                templateType    = SendTemplateMessageTypeEnum.多门店订单配送通知;
                orderInfo.State = (int)MiniAppEntOrderState.待确认送达;
                break;

            case (int)MiniAppEntOrderState.交易成功:
                if (orderInfo.GetWay == (int)multiStoreOrderType.城配送)
                {
                    templateType = SendTemplateMessageTypeEnum.多门店订单配送通知;
                }
                orderInfo.AcceptDate = DateTime.Now;
                orderInfo.State      = (int)MiniAppEntOrderState.交易成功;
                break;

            case (int)MiniAppEntOrderState.待收货:
                templateType    = SendTemplateMessageTypeEnum.多门店订单发货提醒;
                orderInfo.State = (int)MiniAppEntOrderState.待收货;
                break;
            }
            isok = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "state,AcceptDate");
            if (isok)
            {
                if (state == (int)MiniAppEntOrderState.交易成功)
                {
                    VipRelationBLL.SingleModel.updatelevel(orderInfo.UserId, "multistore");
                }
                msg = "操作成功";
                var data = TemplateMsg_Miniapp.MutilStoreGetTemplateMessageData(orderInfo, templateType);
                TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, templateType, TmpType.小程序多门店模板, data);
            }
            return(Json(new { isok = isok, msg = msg }));
        }
Exemplo n.º 16
0
 /// <summary>
 /// 发送预约(专业版)模板消息
 /// </summary>
 /// <param name="reservation"></param>
 /// <param name="msgState">模板消息状态(接单、退款、取消)</param>
 /// <param name="refundOrder">退款订单(仅退款消息需要)</param>
 /// <returns></returns>
 public bool SendReserveEntMsg(FoodReservation reservation, SendTemplateMessageTypeEnum msgState, EntGoodsOrder refundEntOrder = null)
 {
     return(SendReserveMsg(reservation: reservation, msgState: msgState, tmpType: TmpType.小程序专业模板, refundEntOrder: refundEntOrder));
 }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 开团
        /// </summary>
        /// <param name="isgroup"></param>
        /// <param name="rid"></param>
        /// <param name="buyMode"></param>
        /// <param name="userid"></param>
        /// <param name="groupmodel"></param>
        /// <param name="dbOrder"></param>
        /// <returns></returns>
        protected string OpenGroup(int isgroup, int rid, int buyMode, int userid, EntGroupsRelation groupmodel, ref EntGoodsOrder dbOrder)
        {
            string msg = "";

            //是否开团
            if (isgroup > 0)
            {
                int             groupusersum = EntGroupSponsorBLL.SingleModel.GetGroupSponrUserSum(groupmodel.Id);
                EntGroupSponsor groupSponsor = new EntGroupSponsor();
                groupSponsor.EntGoodRId    = groupmodel.Id;
                groupSponsor.SponsorUserId = userid;
                groupSponsor.GroupSize     = groupmodel.GroupSize;
                groupSponsor.RId           = rid;
                groupSponsor.StartDate     = DateTime.Now;
                groupSponsor.EndDate       = DateTime.Now.AddHours(groupmodel.ValidDateLength);
                groupSponsor.State         = buyMode == (int)miniAppBuyMode.储值支付 || dbOrder.BuyPrice <= 0 ? (int)GroupState.开团成功 : (int)GroupState.待付款; //待付款
                int groupid = Convert.ToInt32(EntGroupSponsorBLL.SingleModel.Add(groupSponsor));
                if (groupid <= 0)
                {
                    msg = $"成团失败!";
                }
                dbOrder.GroupId = groupid;
                EntGoodsOrderBLL.SingleModel.Update(dbOrder, "groupid");
            }

            return(msg);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 获取会员列表
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="userName"></param>
        /// <param name="levelid"></param>
        /// <param name="leveltype"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public MiniappVipInfo GetVipList(string appId, int pageIndex, int pageSize, string userName, int levelid, int leveltype, string startDate, string endDate, string telePhone = "", int isor = 0)
        {
            string userIds  = string.Empty;
            string sqlwhere = $" viprelation.appid='{appId}' and viprelation.state>=0 and c_userinfo.nickname is not NULL and c_userinfo.headimgurl is not NULL";
            List <MySql.Data.MySqlClient.MySqlParameter> mysqlParameter = new List <MySql.Data.MySqlClient.MySqlParameter>();

            if (isor > 0)
            {
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(telePhone))
                {
                    sqlwhere += $" and ( c_userinfo.nickname like @userName or c_userinfo.TelePhone like @telePhone )";
                    mysqlParameter.Add(new MySql.Data.MySqlClient.MySqlParameter("@userName", "%" + userName + "%"));
                    mysqlParameter.Add(new MySql.Data.MySqlClient.MySqlParameter("@TelePhone", "%" + telePhone + "%"));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(userName))
                {
                    sqlwhere += $" and c_userinfo.nickname like @userName ";
                    mysqlParameter.Add(new MySql.Data.MySqlClient.MySqlParameter("@userName", "%" + userName + "%"));
                }
                if (!string.IsNullOrEmpty(telePhone))
                {
                    //再将电话号码匹配订单的收货号码 找出下单的这个用户
                    userIds = EntGoodsOrderBLL.SingleModel.GetListUserIdByAccepterTelePhone(telePhone);

                    if (!string.IsNullOrEmpty(userIds))
                    {
                        sqlwhere += $" and (c_userinfo.Id in({userIds}) or c_userinfo.TelePhone like @telePhone)";
                    }
                    else
                    {
                        sqlwhere += $" and c_userinfo.TelePhone like @telePhone ";
                    }
                    mysqlParameter.Add(new MySql.Data.MySqlClient.MySqlParameter("@TelePhone", "%" + telePhone + "%"));
                }
            }
            if (levelid > 0)
            {
                sqlwhere += $" and viprelation.levelid={levelid}";
            }

            if (leveltype != -1)
            {
                sqlwhere += $" and viplevel.type={leveltype}";
            }
            if (!string.IsNullOrWhiteSpace(startDate))
            {
                sqlwhere += $" and viprelation.addtime>=@startDate ";
                mysqlParameter.Add(new MySql.Data.MySqlClient.MySqlParameter("@startDate", startDate + " 00:00:00"));
            }
            if (!string.IsNullOrWhiteSpace(endDate))
            {
                sqlwhere += $" and viprelation.addtime<=@endDate ";
                mysqlParameter.Add(new MySql.Data.MySqlClient.MySqlParameter("@endDate", endDate + " 23:59:59"));
            }
            string sql      = $"select viprelation.*,c_userinfo.Remark,c_userinfo.id as u_id,c_userinfo.TelePhone,c_userinfo.nickname,c_userinfo.headimgurl,c_userInfo.usertype,viplevel.type,viplevel.discount,viplevel.name,savemoneysetuser.AccountMoney,VipWxCardCode.Code from viprelation left join c_userinfo on viprelation.uid=c_userinfo.id left join viplevel on viprelation.levelid= viplevel.id left join savemoneysetuser on viprelation.uid=savemoneysetuser.userid left join VipWxCardCode on c_userinfo.id=VipWxCardCode.UserId  where {sqlwhere} order by id desc limit {pageSize * (pageIndex - 1)},{pageSize}";
            string countsql = $"select count(*) as count from viprelation left join c_userinfo on viprelation.uid=c_userinfo.id left join viplevel on viprelation.levelid= viplevel.id where {sqlwhere}";


            MiniappVipInfo model = new MiniappVipInfo();
            DataSet        ds    = SqlMySql.ExecuteDataSet(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql, mysqlParameter.ToArray());

            if (ds.Tables.Count <= 0)
            {
                return(model);
            }
            DataTable dt = ds.Tables[0];

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(model);
            }
            model.relationList = new List <VipRelation>();


            foreach (DataRow row in dt.Rows)
            {
                VipRelation viprelation = new VipRelation();
                viprelation.levelInfo = new VipLevel();
                if (row["Code"] != DBNull.Value)
                {
                    viprelation.WxVipCode = row["Code"].ToString();
                }
                if (row["TelePhone"] != DBNull.Value)
                {
                    viprelation.TelePhone = row["TelePhone"].ToString();
                }

                if (row["id"] != DBNull.Value)
                {
                    viprelation.Id = Convert.ToInt32(row["id"]);
                }
                if (row["addtime"] != DBNull.Value)
                {
                    viprelation.addtime = Convert.ToDateTime(row["addtime"]);
                }
                if (row["updatetime"] != DBNull.Value)
                {
                    viprelation.updatetime = Convert.ToDateTime(row["updatetime"]);
                }
                if (row["nickname"] != DBNull.Value)
                {
                    viprelation.username = row["nickname"].ToString();
                }
                if (row["pricesum"] != DBNull.Value)
                {
                    viprelation.PriceSum = Convert.ToInt32(row["pricesum"]);
                }
                if (row["name"] != DBNull.Value)
                {
                    viprelation.levelInfo.name = row["name"].ToString();
                }
                if (row["discount"] != DBNull.Value)
                {
                    viprelation.levelInfo.discount = Convert.ToInt32(row["discount"]);
                }
                if (row["type"] != DBNull.Value)
                {
                    viprelation.levelInfo.type = Convert.ToInt32(row["type"]);
                }
                if (row["levelid"] != DBNull.Value)
                {
                    viprelation.levelid = Convert.ToInt32(row["levelid"]);
                }
                if (row["headimgurl"] != DBNull.Value)
                {
                    viprelation.headimgurl = row["headimgurl"].ToString();
                }
                if (row["AccountMoney"] != DBNull.Value)
                {
                    viprelation.AccountMoney = Convert.ToInt32(row["AccountMoney"]);
                }
                if (row["uid"] != DBNull.Value)
                {
                    viprelation.uid = Convert.ToInt32(row["uid"]);
                }
                if (row["usertype"] != DBNull.Value)
                {
                    viprelation.userType = Convert.ToInt32(row["usertype"]);
                }
                if (row["Remark"] != DBNull.Value)
                {
                    viprelation.Remark = Convert.ToString(row["Remark"]);
                }
                if (string.IsNullOrEmpty(viprelation.TelePhone))
                {
                    //暂时获取该用户普通订单的电话号码,待下次微信授权电话号码再拿微信授权电话号码
                    EntGoodsOrder order = EntGoodsOrderBLL.SingleModel.GetModel($"UserId={viprelation.uid}");
                    if (order != null)
                    {
                        viprelation.TelePhone = order.AccepterTelePhone;
                    }
                }
                viprelation.SaveMoneySum = SaveMoneySetUserBLL.SingleModel.GetSaveMoneySum(viprelation.uid) * 0.01;

                model.relationList.Add(viprelation);
            }
            DataSet dc = SqlMySql.ExecuteDataSet(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, countsql, mysqlParameter.ToArray());

            if (dc.Tables.Count <= 0)
            {
                return(model);
            }
            DataTable cdt = dc.Tables[0];

            model.recordCount = Convert.ToInt32(cdt.Rows[0]["count"]);
            model.kfCount     = model.relationList.Where(relation => relation.userType == 1).Count();
            return(model);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 蜂鸟订单状态改变回调接口
        /// </summary>
        /// <param name="returnModel"></param>
        /// <returns></returns>
        public ActionResult FNnotis(FNApiReponseModel <string> returnModel)
        {
            if (returnModel == null || returnModel.data == null || returnModel.data.Length == 0)
            {
                LogHelper.WriteInfo(this.GetType(), "蜂鸟回调请求参数为空");
                return(Content(""));
            }

            string datajson             = HttpUtility.UrlDecode(returnModel.data);
            FNAccepterOrderModel data   = JsonConvert.DeserializeObject <FNAccepterOrderModel>(datajson);
            string urlencodedata        = returnModel.data;
            DistributionApiConfig model = DistributionApiConfigBLL.SingleModel.GetModelByRedis(FNApi._fnapi_appid);
            string signature            = FNApi.SingleModel.GetSign(model.access_token, urlencodedata, returnModel.salt);

            if (returnModel.signature != signature || data == null)
            {
                LogHelper.WriteInfo(this.GetType(), "蜂鸟配送回调签名错误json:" + JsonConvert.SerializeObject(returnModel) + ",解码后:" + datajson);
                return(Content(""));
            }

            FNOrder order = FNOrderBLL.SingleModel.GetModelByOrderNo(data.partner_order_code);

            if (order == null)
            {
                log4net.LogHelper.WriteInfo(this.GetType(), $"蜂鸟订单回调:找不到订单【{data.partner_order_code}】");
                return(Content(""));
            }

            order.state                = data.order_status;
            order.updatetime           = DateTime.Now;
            order.carrier_driver_name  = data.carrier_driver_name;
            order.carrier_driver_phone = data.carrier_driver_phone;
            order.description          = data.description;
            bool updatebool = FNOrderBLL.SingleModel.Update(order, "state,updatetime,carrier_driver_name,carrier_driver_phone,description");

            if (updatebool && data.order_status == (int)FNOrderEnum.异常)
            {
                FNOrderRelation orelationmodel = FNOrderRelationBLL.SingleModel.GetModelUOrderNo(order.partner_order_code);
                if (orelationmodel == null)
                {
                    log4net.LogHelper.WriteInfo(this.GetType(), "蜂鸟配送取消订单回调发起退款出错:找不到关联该订单的数据");
                    return(Content("success"));
                }

                bool isSuccess = false;
                switch (orelationmodel.ordertype)
                {
                case (int)TmpType.小程序餐饮模板:
                    FoodGoodsOrder foodGoodOrder = FoodGoodsOrderBLL.SingleModel.GetModel($" Id = {orelationmodel.orderid} ");    // and  OrderType ={(int)miniAppFoodOrderType.店内点餐 } ");
                    if (foodGoodOrder == null)
                    {
                        LogHelper.WriteInfo(this.GetType(), "蜂鸟配送:找不到订单");
                        return(Content("success"));
                    }
                    //退款接口 abel
                    if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.微信支付)
                    {
                        isSuccess = FoodGoodsOrderBLL.SingleModel.outOrder(foodGoodOrder, foodGoodOrder.State);
                    }
                    else if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.储值支付)
                    {
                        SaveMoneySetUser userSaveMoney = SaveMoneySetUserBLL.SingleModel.getModelByUserId(foodGoodOrder.UserId) ?? new SaveMoneySetUser();
                        isSuccess = FoodGoodsOrderBLL.SingleModel.outOrderBySaveMoneyUser(foodGoodOrder, userSaveMoney, foodGoodOrder.State);
                    }
                    break;

                case (int)TmpType.小程序专业模板:
                    EntGoodsOrder entorder = EntGoodsOrderBLL.SingleModel.GetModel(orelationmodel.orderid);
                    if (entorder == null)
                    {
                        LogHelper.WriteInfo(this.GetType(), "蜂鸟配送取消订单回调发起退款出错:找不到小程序订单数据");
                        return(Content("success"));
                    }

                    isSuccess = EntGoodsOrderBLL.SingleModel.outOrder(entorder, entorder.State, entorder.BuyMode);
                    if (!isSuccess)
                    {
                        LogHelper.WriteInfo(this.GetType(), "蜂鸟配送取消订单回调发起退款出错:执行退款服务出错");
                        return(Content("success"));
                    }

                    EntGoodsOrderLogBLL.SingleModel.AddLog(entorder.Id, 0, $"蜂鸟:将订单状态改为:{Enum.GetName(typeof(MiniAppEntOrderState), entorder.State)}");
                    break;
                }
            }

            return(Content(""));
        }
        /// <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 }));
        }
Exemplo n.º 22
0
        /// <summary>
        /// 足浴版退款
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="orderInfo"></param>
        /// <returns></returns>
        public bool ZYReFundQueue(string appId, EntGoodsOrder orderInfo, ServiceTime serviceTime)
        {
            bool result = false;

            if (orderInfo == null || orderInfo.Id <= 0)
            {
                return(result);
            }
            orderInfo.outOrderDate = DateTime.Now;
            if (orderInfo.BuyMode == (int)miniAppBuyMode.储值支付)
            {
                var saveMoneyUser = new SaveMoneySetUser();
                saveMoneyUser = SaveMoneySetUserBLL.SingleModel.getModelByUserId(appId, orderInfo.UserId);
                if (saveMoneyUser == null || saveMoneyUser.Id <= 0)
                {
                    return(result);
                }

                TransactionModel tran = new TransactionModel();
                tran.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog()
                {
                    AppId          = saveMoneyUser.AppId,
                    UserId         = orderInfo.UserId,
                    MoneySetUserId = saveMoneyUser.Id,
                    Type           = 1,
                    BeforeMoney    = saveMoneyUser.AccountMoney,
                    AfterMoney     = saveMoneyUser.AccountMoney + orderInfo.BuyPrice,
                    ChangeMoney    = orderInfo.BuyPrice,
                    ChangeNote     = $" 购买商品,订单号:{orderInfo.OrderNum} ",
                    CreateDate     = DateTime.Now,
                    State          = 1
                }));
                saveMoneyUser.AccountMoney += orderInfo.BuyPrice;
                tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney + {orderInfo.BuyPrice} where id =  {saveMoneyUser.Id} ; ");
                tran.Add($" update EntGoodsOrder set state = {(int)MiniAppEntOrderState.退款成功 },outOrderDate = '{orderInfo.outOrderDate.ToString("yyyy-MM-dd HH:mm:ss")}',Remark = @Remark where Id = {orderInfo.Id} and state <> {(int)MiniAppEntOrderState.退款成功 } ; ", new MySqlParameter[] { new MySqlParameter("@Remark", orderInfo.Remark) });//防止重复退款
                if (serviceTime != null)
                {
                    tran.Add($"update servicetime set time='{serviceTime.time}' where id={serviceTime.Id}");//取消已预订的技师服务时间
                }
                //记录订单退款日志
                tran.Add(EntGoodsOrderLogBLL.SingleModel.BuildAddSql(new EntGoodsOrderLog()
                {
                    GoodsOrderId = orderInfo.Id, UserId = orderInfo.UserId, LogInfo = $" 订单储值支付,退款成功:{orderInfo.BuyPrice * 0.01} 元 ", CreateDate = DateTime.Now
                }));
                result = ExecuteTransaction(tran.sqlArray, tran.ParameterArray);
                if (result)
                {
                    object objData = TemplateMsg_Miniapp.FootbathGetTemplateMessageData(orderInfo, SendTemplateMessageTypeEnum.足浴退款通知);
                    TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, SendTemplateMessageTypeEnum.足浴退款通知, TmpType.小程序足浴模板, objData);
                }
                return(result);
            }

            if (orderInfo.BuyMode == (int)miniAppBuyMode.微信支付)
            {
                CityMorders order = new CityMordersBLL().GetModel(orderInfo.OrderId);
                orderInfo.State = (int)MiniAppEntOrderState.退款中;

                if (order == null)
                {
                    orderInfo.State = (int)MiniAppEntOrderState.退款失败;
                    EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,outOrderDate,Remark");
                    return(result);
                }

                //微信支付
                ReFundQueue reModel = new ReFundQueue
                {
                    minisnsId = -5,
                    money     = orderInfo.BuyPrice,
                    orderid   = order.Id,
                    traid     = order.trade_no,
                    addtime   = DateTime.Now,
                    note      = "小程序足浴版退款",
                    retype    = 1
                };
                try
                {
                    base.Add(reModel);
                    result = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,outOrderDate");
                    return(result);
                }
                catch (Exception ex)
                {
                    log4net.LogHelper.WriteInfo(GetType(), $"{ex.Message} xxxxxxxxxxxxxxxx小程序足浴退款订单插入队列失败 ID={orderInfo.Id}");
                }
            }
            return(result);
        }
Exemplo n.º 23
0
        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 }));
        }
Exemplo n.º 24
0
        /// <summary>
        /// 多门店退款
        /// </summary>
        /// <param name="orderInfo"></param>
        /// <returns></returns>
        public bool MultiStoreReFundQueue(List <EntGoodsCart> goodsCar, FootBath storeMaterial, EntGoodsOrder orderInfo)
        {
            bool result = false;

            orderInfo.outOrderDate = DateTime.Now;
            orderInfo.State        = (int)MiniAppEntOrderState.退款中;
            if (orderInfo.BuyMode == (int)miniAppBuyMode.微信支付)
            {
                try
                {
                    if (orderInfo.BuyPrice == 0)
                    {
                        orderInfo.State = (int)MiniAppEntOrderState.退款成功;
                        EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,outOrderDate");
                    }
                    else
                    {
                        CityMorders order = _cityMordersBLL.GetModel(orderInfo.OrderId);
                        orderInfo.State = (int)MiniAppEntOrderState.退款中;
                        if (order == null)
                        {
                            orderInfo.State = (int)MiniAppEntOrderState.退款失败;

                            EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,outOrderDate");
                            return(result);
                        }

                        //微信支付
                        ReFundQueue reModel = new ReFundQueue
                        {
                            minisnsId = -5,
                            money     = orderInfo.BuyPrice,
                            orderid   = order.Id,
                            traid     = order.trade_no,
                            addtime   = DateTime.Now,
                            note      = "小程序多门店退款",
                            retype    = 1
                        };
                        base.Add(reModel);
                    }
                    TransactionModel tranModel = new TransactionModel();
                    tranModel.Add(EntGoodsOrderBLL.SingleModel.BuildUpdateSql(orderInfo, "State,outOrderDate"));
                    if (!EntGoodsOrderBLL.SingleModel.HandleStockSql_MultiStore(goodsCar, storeMaterial, tranModel, -1))
                    {
                        log4net.LogHelper.WriteInfo(GetType(), "生成库存处理sql失败 HandleStockSql_MultiStore_error");
                        return(false);
                    }
                    result = ExecuteTransactionDataCorect(tranModel.sqlArray, tranModel.ParameterArray);
                    return(result);
                }
                catch (Exception ex)
                {
                    log4net.LogHelper.WriteInfo(GetType(), $"{ex.Message} xxxxxxxxxxxxxxxx小程序多门店退款订单插入队列失败 ID={orderInfo.Id}");
                    log4net.LogHelper.WriteError(GetType(), ex);
                }
            }
            return(result);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 专业版普通订单打印内容拼接
        /// </summary>
        /// <param name="food"></param>
        /// <param name="foodGoodsOrder"></param>
        /// <param name="cars"></param>
        /// <param name="foodPrintList"></param>
        /// <returns></returns>
        public static string entPrintOrderContent(EntGoodsOrder goodsOrder)
        {
            //打印内容
            string content = "";

            List <EntGoodsCart> cars = EntGoodsCartBLL.SingleModel.GetList($" GoodsOrderId = {goodsOrder.Id} ") ?? new List <EntGoodsCart>();

            string          goodsIds     = string.Join(",", cars.Select(s => s.FoodGoodsId).Distinct());
            List <EntGoods> entGoodsList = EntGoodsBLL.SingleModel.GetListByIds(goodsIds);

            cars.ForEach(c =>
            {
                c.goodsMsg = entGoodsList?.FirstOrDefault(f => f.id == c.FoodGoodsId) ?? new EntGoods();
            });

            XcxAppAccountRelation curXcx = XcxAppAccountRelationBLL.SingleModel.GetModel(goodsOrder.aId);

            if (curXcx == null)
            {
                log4net.LogHelper.WriteInfo(typeof(PrinterHelper), "专业版打印内容拼接失败 curXcx_null");
                return(content);
            }
            //获取店铺名
            OpenAuthorizerConfig XUserList = OpenAuthorizerConfigBLL.SingleModel.GetModelByAppids(curXcx.AppId);

            if (XUserList == null)
            {
                log4net.LogHelper.WriteInfo(typeof(PrinterHelper), "专业版打印内容获取不到小程序名,但仍旧打印 XUserList_null");
            }

            string zqStoreInfo = "送货地址:无(到店自取)\r\n";

            if (!string.IsNullOrEmpty(goodsOrder.attribute))
            {
                goodsOrder.attrbuteModel = JsonConvert.DeserializeObject <EntGoodsOrderAttr>(goodsOrder.attribute);
            }
            PickPlace storeAddress = null;

            if (goodsOrder.attrbuteModel.zqStoreId > 0)
            {
                storeAddress = PickPlaceBLL.SingleModel.GetModel(goodsOrder.attrbuteModel.zqStoreId);
            }
            else if (!string.IsNullOrWhiteSpace(goodsOrder.attrbuteModel.zqStoreName))
            {
                storeAddress = PickPlaceBLL.SingleModel.GetModelByAid_Name(goodsOrder.aId, goodsOrder.attrbuteModel.zqStoreName);
            }
            if (storeAddress != null)
            {
                zqStoreInfo = $"送货地址:【{storeAddress?.name}】{storeAddress?.address}\r\n";
            }

            //拼接订单内容排版
            content  = $"<MC>0,00005,0</MC><FS>{XUserList?.nick_name ?? string.Empty}</FS>\r\n";
            content += "<table><tr><td>商品</td><td>数量</td><td>金额(元)</td></tr>";
            content += "<tr><td>@@2................................</td></tr>";
            foreach (var car in cars)
            {
                //car.goodsMsg = foodGoodsBLL.GetModel($"Id={car.FoodGoodsId}");
                content += $"<tr><td>{car.goodsMsg.name}</td><td>{car.Count}</td><td>{(car.Price * car.Count * 0.01).ToString("0.00")}</td></tr>";
                if (!string.IsNullOrEmpty(car.SpecInfo))
                {
                    content += $"<tr><td>规格:{car.SpecInfo}</td></tr>";
                }

                content += $"<tr><td></td></tr>";
            }
            content += "<tr><td>┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄</td></tr>";
            content += $"<tr><td>实收:</td><td>-</td><td>{(goodsOrder.BuyPrice * 0.01).ToString("0.00")}</td></tr>";
            content += $"<tr><td></td><td></td><td>({Enum.GetName(typeof(miniAppBuyMode), goodsOrder.BuyMode)})</td></tr></table>";
            content += "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄\r\n";
            content += $"订单号:{goodsOrder.OrderNum}\r\n";
            content += $"下单时间:{goodsOrder.CreateDate}\r\n";
            content += $"打印时间:{DateTime.Now}\r\n";
            content += $"收货人:{goodsOrder.AccepterName}\r\n";
            content += $"联系方式:{goodsOrder.AccepterTelePhone}\r\n";
            switch (goodsOrder.GetWay)
            {
            case (int)miniAppOrderGetWay.商家配送:
                content += $"送货地址:{goodsOrder.Address}\r\n";

                break;

            case (int)miniAppOrderGetWay.到店自取:
            case (int)miniAppOrderGetWay.到店消费:
                content += zqStoreInfo;

                break;
            }
            content += $"订单备注:{goodsOrder.Message}\r\n";

            return(content);
        }
Exemplo n.º 26
0
        /// <summary>
        ///  订单退款
        /// </summary>
        /// <param name="item"></param>
        /// <param name="oldState"></param>
        /// <param name="BuyMode">默认微信支付</param>
        /// <param name="isPartOut">是否部分退款</param>
        /// <returns></returns>
        public bool EntReFundQueue(EntGoodsOrder item, int oldState, int BuyMode = (int)miniAppBuyMode.微信支付, int?newState = null, bool isPartOut = false)
        {
            //重新加回库存
            if (EntGoodsOrderBLL.SingleModel.updateStock(item, oldState))
            {
                int money = isPartOut ? item.refundFee : item.BuyPrice;//兼容多版本,目前只有专业版订单有部分退款
                item.refundFee = money;
                if (BuyMode == (int)miniAppBuyMode.微信支付)
                {
                    try
                    {
                        item.outOrderDate = DateTime.Now;
                        if (item.BuyPrice == 0)  //金额为0时,回滚库存后,默认退款成功
                        {
                            item.State = (int)MiniAppEntOrderState.退款成功;
                        }
                        else
                        {
                            CityMorders order = _cityMordersBLL.GetModel(item.OrderId);
                            item.State = (int)MiniAppEntOrderState.退款中;
                            if (newState.HasValue)
                            {
                                item.State = newState.Value;
                            }
                            if (order == null)
                            {
                                item.State = (int)MiniAppEntOrderState.退款失败;
                                EntGoodsOrderBLL.SingleModel.Update(item, "State,outOrderDate,Remark,refundFee");
                                return(false);
                            }
                            //微信支付
                            ReFundQueue reModel = new ReFundQueue
                            {
                                minisnsId = -5,
                                money     = item.refundFee,
                                orderid   = order.Id,
                                traid     = order.trade_no,
                                addtime   = DateTime.Now,
                                note      = "小程序行业版退款",
                                retype    = 1
                            };
                            base.Add(reModel);
                        }
                        bool isSuccess = EntGoodsOrderBLL.SingleModel.Update(item, "State,outOrderDate,Remark,refundFee");
                        if (isSuccess)
                        {
                            //发给用户退款通知
                            object orderData = TemplateMsg_Miniapp.EnterpriseGetTemplateMessageData(item, SendTemplateMessageTypeEnum.专业版订单退款通知, "商家操作退款");
                            TemplateMsg_Miniapp.SendTemplateMessage(item.UserId, SendTemplateMessageTypeEnum.专业版订单退款通知, TmpType.小程序专业模板, orderData);
                        }
                    }
                    catch (Exception ex)
                    {
                        log4net.LogHelper.WriteInfo(GetType(), $"{ex.Message} xxxxxxxxxxxxxxxx小程序餐饮退款订单插入队列失败 ID={item.Id}");
                    }
                }
                else
                {
                    XcxAppAccountRelation r = XcxAppAccountRelationBLL.SingleModel.GetModel(item.aId);
                    if (r == null)
                    {
                        return(false);
                    }

                    SaveMoneySetUser saveMoneyUser = SaveMoneySetUserBLL.SingleModel.getModelByUserId(r.AppId, item.UserId);
                    TransactionModel tran          = new TransactionModel();
                    tran.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog()
                    {
                        AppId          = r.AppId,
                        UserId         = item.UserId,
                        MoneySetUserId = saveMoneyUser.Id,
                        Type           = 1,
                        BeforeMoney    = saveMoneyUser.AccountMoney,
                        AfterMoney     = saveMoneyUser.AccountMoney + item.refundFee,
                        ChangeMoney    = item.refundFee,
                        ChangeNote     = $"专业版购买商品退款,订单号:{item.OrderNum} ",
                        CreateDate     = DateTime.Now,
                        State          = 1
                    }));

                    item.State = (int)MiniAppEntOrderState.退款成功;
                    if (newState.HasValue)
                    {
                        item.State = newState.Value;
                    }
                    tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney + {item.refundFee} where id =  {saveMoneyUser.Id} ; ");
                    tran.Add($" update EntGoodsOrder set State = {item.State },outOrderDate = '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}',Remark = @Remark where Id = {item.Id} and state <> {item.State} ; ",
                             new MySqlParameter[] { new MySqlParameter("@Remark", item.Remark) });//防止重复退款

                    //记录订单储值支付退款日志
                    tran.Add(EntGoodsOrderLogBLL.SingleModel.BuildAddSql(new EntGoodsOrderLog()
                    {
                        GoodsOrderId = item.Id, UserId = item.UserId, LogInfo = $" 储值支付订单退款成功:{item.refundFee * 0.01} 元 ", CreateDate = DateTime.Now
                    }));
                    bool isSuccess = ExecuteTransaction(tran.sqlArray, tran.ParameterArray);

                    if (isSuccess)
                    {
                        //发给用户退款通知
                        object orderData = TemplateMsg_Miniapp.EnterpriseGetTemplateMessageData(item, SendTemplateMessageTypeEnum.专业版订单退款通知, "商家操作退款");
                        TemplateMsg_Miniapp.SendTemplateMessage(item.UserId, SendTemplateMessageTypeEnum.专业版订单退款通知, TmpType.小程序专业模板, orderData);
                    }
                    return(isSuccess);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 27
0
        /// <summary>
        /// 发送预约模板消息
        /// </summary>
        /// <param name="reservation"></param>
        /// <param name="msgState">模板消息状态(接单、退款、取消)</param>
        /// <param name="tmpType">模板消息类型(专业版、餐饮版)</param>
        /// <param name="refundOrder">退款订单(仅退款消息需要)</param>
        /// <param name="refundEntOrder">退款订单(仅退款消息需要)</param>
        /// <returns></returns>
        public bool SendReserveMsg(FoodReservation reservation, SendTemplateMessageTypeEnum msgState, TmpType tmpType, EntGoodsOrder refundEntOrder = null, FoodGoodsOrder refundOrder = null)
        {
            //发送小程序模板消息给用户
            object orderData = TemplateMsg_Miniapp.GetReservationTempMsgData(reservation, msgState, refundOrder: refundOrder, refundEntOrder: refundEntOrder);

            if (orderData == null)
            {
                return(false);
            }
            TemplateMsg_Miniapp.SendTemplateMessage(reservation.UserId, msgState, (int)tmpType, orderData);
            return(true);
        }
        /// <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 }));
        }