示例#1
0
        /// <summary>
        /// 消费记录
        /// </summary>
        /// <param name="id">Uid</param>
        /// <param name="name">SourceAccountId</param>
        /// <param name="companyId">CompanyId</param>
        /// <returns></returns>
        public ActionResult ConsumptionRecords(string id, string name, string companyId)
        {
            List <PrepayRecord> p = null;

            try
            {
                Session["SourceAccountId"] = name;
                CrmMemberModel   cmm = new CrmMemberModel();
                List <CrmMember> crm = cmm.getCrmMemberListInfoData(name);
                ViewBag.PrepayAccount = 0;
                if (crm.Count() > 0)
                {
                    decimal dec = cmm.GetPrepayAccount(crm.First().Uid).AccountMoney;
                    ViewBag.PrepayAccount = dec;
                }
                ViewBag.Uid       = id;
                ViewBag.CompanyId = companyId;
                PrepayRecordModel prm = new PrepayRecordModel();
                p = prm.getConsumptionRecordsListInfoData(id);
            }
            catch
            {
            }
            finally
            {
            }

            return(View(p));
        }
示例#2
0
        public ActionResult getMemProducts(string id, string name)
        {
            ProductModel p = new ProductModel();

            ViewBag.Uid       = name;
            ViewBag.CompanyId = id;
            List <MemProduct> result = p.getMemProducts(id);

            ViewBag.PrepayAccount = 0;
            CrmMemberModel   cdb = new CrmMemberModel();
            List <CrmMember> crm = cdb.getCrmMemberListInfoData(name);

            if (crm.Count() > 0)
            {
                decimal dec = cdb.GetPrepayAccount(crm.First().Uid).AccountMoney;
                ViewBag.PrepayAccount = dec;
            }
            return(View(result));
        }
示例#3
0
        public ActionResult Info(string id, string name)
        {
            Session["SourceAccountId"] = name;
            CrmMember model = null;

            ViewBag.AccountMoney    = 0;
            ViewBag.Score           = 0;
            ViewBag.PresentMoney    = 0;
            ViewBag.CompanyId       = id;
            ViewBag.SourceAccountId = name;

            try
            {
                CrmMemberModel      cmModel  = new CrmMemberModel();
                CrmMemberScoreModel cmsModel = new CrmMemberScoreModel();

                if (!string.IsNullOrEmpty(name))
                {
                    model = cmModel.getCrmMemberListInfoData(name).FirstOrDefault();

                    var prepayAccount = cmModel.GetPrepayAccount(model.Uid);
                    var memberScore   = cmsModel.SelCrmMemberScoreInfo(model.Uid).FirstOrDefault();

                    if (prepayAccount != null)
                    {
                        ViewBag.AccountMoney = prepayAccount.AccountMoney;
                        ViewBag.PresentMoney = prepayAccount.PresentMoney;
                    }
                    if (memberScore != null)
                    {
                        ViewBag.Score = memberScore.Score;
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(View(model));
        }
示例#4
0
        public ActionResult editMemberInfo(string id, string name)
        {
            List <CrmMember> p = null;

            try
            {
                CrmMemberModel cmm = new CrmMemberModel();
                p = cmm.getCrmMemberListInfoData(name);
                decimal dec = cmm.GetPrepayAccount(p.First().Uid).AccountMoney;
                ViewBag.PrepayAccount   = dec;
                ViewBag.SourceAccountId = name;
                ViewBag.CompanyId       = id;
            }
            catch
            { }
            finally
            { }

            return(View(p));
        }
示例#5
0
        public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Click requestMessage)
        {
            IResponseMessageBase reponseMessage = null;

            switch (requestMessage.EventKey)
            {
            case "BeginOrderClick":
            {
                var strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();
                strongResponseMessage.Articles.Add(new Article
                    {
                        Title       = "开始预定",
                        Description = "通过微信预订点餐",
                        PicUrl      = ImgUrl + "wxbeginorder.jpg",
                        Url         = string.Format(Constants.HostDomain + "/order/begin/" + Constants.CompanyId + "/{0}?type=Quick", requestMessage.FromUserName)
                    });
                reponseMessage = strongResponseMessage;
            }
            break;

            case "ActivityClick":
            {
                var    strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();
                string picUrl = Constants.HostDomain + "/NewContent/images/w.png";
                string uid    = "";

                try
                {
                    CrmMemberModel model = new CrmMemberModel();
                    uid = model.getCrmMemberListInfoData(requestMessage.FromUserName).FirstOrDefault().Uid;
                    var prepayAccount = model.GetPrepayAccount(uid);
                    if (prepayAccount != null && prepayAccount.AccountMoney > 0)
                    {
                        picUrl = Constants.HostDomain + "/NewContent/images/chu.png";
                    }
                }
                catch (Exception ex)
                {
                    LogException(ex);
                    uid = ex.StackTrace;
                }
                Article article = new Article();

                article.Title       = "小场合活动·微观时代";
                article.Description = "小场合活动·微观时代";
                article.PicUrl      = picUrl;
                article.Url         = string.Format(Constants.HostDomain + "/Jump/To?fromUserName={0}&url=/Activity/Index?activityState=1", requestMessage.FromUserName);

                strongResponseMessage.Articles.Add(article);

                reponseMessage = strongResponseMessage;
            }
            break;

            case "AccountInfoClick":
            {
                var    strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();
                string uid    = string.Empty;
                string picUrl = Constants.HostDomain + "/NewContent/images/w.png";;
                try
                {
                    CrmMemberModel model = new CrmMemberModel();
                    uid = model.getCrmMemberListInfoData(requestMessage.FromUserName).FirstOrDefault().Uid;
                    var prepayAccount = model.GetPrepayAccount(uid);
                    if (prepayAccount != null && prepayAccount.AccountMoney > 0)
                    {
                        picUrl = Constants.HostDomain + "/NewContent/images/chu.png";
                    }
                }
                catch (Exception ex)
                {
                    LogException(ex);
                    uid = ex.StackTrace;
                }
                strongResponseMessage.Articles.Add(new Article
                    {
                        Title       = "会员信息",
                        Description = "您的会员号:" + uid,
                        PicUrl      = picUrl,
                        Url         = string.Format(Constants.HostDomain + "/Member/Info/" + Constants.CompanyId + "/{0}", requestMessage.FromUserName)
                    });
                reponseMessage = strongResponseMessage;
            }
            break;

            case "VipPay":
            {
                string picUrl = Constants.HostDomain + "/NewContent/images/w.png";
                string uid    = "";

                try
                {
                    CrmMemberModel model = new CrmMemberModel();
                    uid = model.getCrmMemberListInfoData(requestMessage.FromUserName).FirstOrDefault().Uid;
                    var prepayAccount = model.GetPrepayAccount(uid);
                    if (prepayAccount != null && prepayAccount.AccountMoney > 0)
                    {
                        picUrl = Constants.HostDomain + "/NewContent/images/chu.png";
                    }
                }
                catch (Exception ex)
                {
                    LogException(ex);
                }
                var strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();

                DateTime     dt          = DateTime.Now.AddMinutes(-15);
                PrepayRecord rec         = new PrepayRecordModel().GetUserLastUnPaidComsumingPrepayRecordWithin5Minutes(requestMessage.FromUserName);
                string       description = string.Empty;
                string       title       = string.Empty;
                string       url         = "";

                if (rec != null)
                {
                    title       = "支付确认";
                    description = "您本次的消费:现金¥" + (0 - rec.PrepayMoney.Value).ToString() +
                                  "/赠送¥" + (0 - rec.PresentMoney.Value).ToString() +
                                  (rec.PayByScore > 0 ? "/积分" + rec.PayByScore.ToString() : "") +
                                  (rec.DiscountlMoeny > 0 ? ",本次优惠:" + rec.DiscountlMoeny.ToString() : "") +
                                  ",账单时间:" + rec.PrepayDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + ",点击本条消息,完成支付!";
                    url = string.Format(Constants.HostDomain + "/pay/payview/?id={0}&value={1}", requestMessage.FromUserName, rec.RecordId + "|" + DateTime.Now.Ticks);

                    strongResponseMessage.Articles.Add(new Article
                        {
                            Title       = title,
                            Description = description,
                            PicUrl      = picUrl,
                            Url         = url
                        });
                    reponseMessage = strongResponseMessage;
                }
                else
                {
                    description = "未查询到未结账单,可能原因为:\n1.您没有未结账单。\n2.您的账单还未生成。\n3.为保护您账号安全,您的生成的账单已经超期!";

                    var result = CreateResponseMessage <ResponseMessageText>();
                    result.Content = description;

                    reponseMessage = result;
                }
            }
            break;

            case "MyOrder":    //我的订单
            {
                var    strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();
                string picUrl = Constants.HostDomain + "/NewContent/images/w.png";
                string uid    = "";

                try
                {
                    CrmMemberModel model = new CrmMemberModel();
                    uid = model.getCrmMemberListInfoData(requestMessage.FromUserName).FirstOrDefault().Uid;
                    var prepayAccount = model.GetPrepayAccount(uid);
                    if (prepayAccount != null && prepayAccount.AccountMoney > 0)
                    {
                        picUrl = Constants.HostDomain + "/NewContent/images/chu.png";
                    }
                }
                catch (Exception ex)
                {
                    LogException(ex);
                    uid = ex.StackTrace;
                }

                strongResponseMessage.Articles.Add(new Article
                    {
                        Title       = "我的订单",
                        Description = "我的订单:",
                        PicUrl      = picUrl,
                        Url         = string.Format(Constants.HostDomain + "/NewOrder/My/" + Constants.CompanyId + "/{0}", requestMessage.FromUserName)
                    });
                reponseMessage = strongResponseMessage;
            }
            break;

            case "CompanyInfo":    //成都印象餐饮有限公司
            {
                //TODO
            }
            break;

            case "Xiaochanghe":    //成都印象小场合
            {
                //TODO
            }
            break;

            case "Culture":    //小场合文化
            {
                //TODO
            }
            break;

            default:
            {
                var strongResponseMessage = CreateResponseMessage <ResponseMessageText>();
                strongResponseMessage.Content = "您点击了按钮,EventKey:" + requestMessage.EventKey;
                reponseMessage = strongResponseMessage;
            }
            break;
            }

            return(reponseMessage);
        }
        public ActionResult CancelOrder(string uid, string orderId, bool isEdit)
        {
            ActionResult result = Content("FAILED");

            try
            {
                bool success      = true;
                var  orderManager = new OrderManager();
                var  order        = orderManager.GetOrderSummary(Guid.Parse(orderId));

                if (order != null)
                {
                    OrderModel orderModel = new OrderModel();

                    using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                    {
                        PrepayRecordModel prepayRecordModel = new PrepayRecordModel();
                        CrmMemberModel    crmMemberModel    = new CrmMemberModel();

                        if (isEdit)
                        {
                            if (order.Status == OrderStatus.New)
                            {
                                success = orderModel.UpdateOrderStatus(Guid.Parse(orderId), OrderStatus.Cancelled);

                                var prepayRecord = prepayRecordModel.GetPrepayRecordByOrderId(orderId);

                                if (prepayRecord != null)
                                {
                                    //取消订单,支付失败
                                    prepayRecord.AsureDate = DateTime.Now;
                                    prepayRecord.RState    = "99";
                                    success = success && prepayRecordModel.UpdatePrepayRecord(prepayRecord);
                                }
                            }
                            else
                            {
                                success = false;
                            }
                        }
                        else
                        {
                            if (OrderStatus.Paid == order.Status)
                            {
                                PrepayRecord  prepayRecord    = null;
                                PrepayRecord  newPrepayRecord = null;
                                PrepayAccount prepayAccount   = null;

                                prepayAccount = crmMemberModel.GetPrepayAccount(uid);
                                prepayRecord  = prepayRecordModel.GetPrepayRecordByOrderId(orderId);

                                //已退款
                                prepayRecord.RState    = "02";
                                prepayRecord.AsureDate = DateTime.Now;

                                newPrepayRecord = new PrepayRecord();

                                newPrepayRecord.AddMoney       = -prepayRecord.AddMoney;
                                newPrepayRecord.AsureDate      = DateTime.Now;
                                newPrepayRecord.BillPayId      = Guid.NewGuid();
                                newPrepayRecord.DiscountlMoeny = 0;
                                newPrepayRecord.PayByScore     = 0;
                                newPrepayRecord.PayModel       = "02";
                                newPrepayRecord.PrepayDate     = DateTime.Now;
                                newPrepayRecord.PrepayMoney    = -0;
                                newPrepayRecord.PresentMoney   = 0;
                                newPrepayRecord.PromotionId    = 0;
                                newPrepayRecord.RecMoney       = 0;
                                newPrepayRecord.RecordId       = -1;
                                newPrepayRecord.RState         = "";
                                newPrepayRecord.RstId          = order.RestaurantId;
                                newPrepayRecord.ScoreVip       = 0;
                                newPrepayRecord.SId            = "";
                                newPrepayRecord.Uid            = uid;
                                newPrepayRecord.UserId         = "System";

                                prepayAccount.AccountMoney += newPrepayRecord.AddMoney.Value;
                                newPrepayRecord.PrepayDate  = DateTime.Now;
                                newPrepayRecord.AsureDate   = DateTime.Now;

                                success = orderModel.UpdateOrderStatus(Guid.Parse(orderId), OrderStatus.Refunded);
                                success = success && prepayRecordModel.AddPrepayRecord(newPrepayRecord);
                                success = success && crmMemberModel.UpdatePrepayAccount(prepayAccount);
                                success = success && prepayRecordModel.UpdatePrepayRecord(prepayRecord);
                            }
                            else
                            {
                                success = false;
                            }
                        }

                        if (success)
                        {
                            result = Content("SUCCESS");
                            scope.Complete();
                        }
                        else
                        {
                            result = Content("FAILED");
                            scope.Dispose();
                        }
                    }
                }
                else
                {
                    result = Content("FAILED");
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }

            return(result);
        }