Ejemplo n.º 1
0
    protected void dlOrderDetail_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item)
        {
            OrderDetail od = e.Item.DataItem as OrderDetail;
            if (od != null && od.GroupPurchaseEvent != null)
            {
                HyperLink hlGroupPurchaseEventStatus = e.Item.FindControl("hlGroupPurchaseEventStatus") as HyperLink;
                hlGroupPurchaseEventStatus.NavigateUrl = Request.Url.AbsolutePath + "?GroupEventID=" + od.GroupPurchaseEvent.ID;
                hlGroupPurchaseEventStatus.ToolTip     = "查看此团购活动的所有订单";
                //查询此用户的当前订单项对应的团购活动状态,需要判断活动中已支付人数是否符合要求、此用户是否支付
                switch (GroupPurchaseEvent.CheckGroupPurchaseEventStatus(od.GroupPurchaseEvent, od.ProductOrder.Purchaser))
                {
                case GroupEventStatus.EVENT_SUCCESS:
                    hlGroupPurchaseEventStatus.CssClass = "label label-success";
                    hlGroupPurchaseEventStatus.Text     = "<i class=\"fa fa-group fa-fw\"></i>团购成功";
                    break;

                case GroupEventStatus.EVENT_GOING:
                    hlGroupPurchaseEventStatus.CssClass = "label label-info";
                    hlGroupPurchaseEventStatus.Text     = "<i class=\"fa fa-group fa-fw\"></i>团购进行中";
                    break;

                case GroupEventStatus.EVENT_FAIL:
                    hlGroupPurchaseEventStatus.CssClass = "label label-danger";
                    hlGroupPurchaseEventStatus.Text     = "<i class=\"fa fa-group fa-fw\"></i>团购失败";
                    break;
                }
            }
        }
    }
Ejemplo n.º 2
0
    protected void rpGroupEvents_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            GroupPurchaseEvent groupEvent = e.Item.DataItem as GroupPurchaseEvent;
            if (groupEvent != null)
            {
                HtmlContainerControl liGroupItem = e.Item.Controls[1] as HtmlContainerControl;
                Label lblEventStatus             = liGroupItem.FindControl("lblEventStatus") as Label;

                //判断当前团购活动状态,并标记页面颜色
                switch (GroupPurchaseEvent.CheckGroupPurchaseEventStatus(groupEvent))
                {
                case GroupEventStatus.EVENT_SUCCESS:
                    liGroupItem.Attributes["class"] += " list-group-item-success";
                    lblEventStatus.Text              = "团购成功";
                    break;

                case GroupEventStatus.EVENT_GOING:
                    liGroupItem.Attributes["class"] += " list-group-item-info";
                    lblEventStatus.Text              = "团购进行中";
                    break;

                case GroupEventStatus.EVENT_FAIL:
                    liGroupItem.Attributes["class"] += " list-group-item-danger";
                    lblEventStatus.Text              = "团购失败";
                    break;
                }
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 团购状态变动事件处理函数,通知管理员和所有团购活动成员
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="gpe"></param>
    /// <returns></returns>
    public static void GroupPurchaseEventNotify(object sender, GroupPurchaseEvent.GroupPurchaseEventEventArgs gpe)
    {
        if (sender == null || gpe == null)
        {
            throw new ArgumentNullException("sender或事件参数对象不能为null");
        }

        JsonData jRet;

        try
        {
            GroupPurchaseEvent groupEvent = sender as GroupPurchaseEvent;
            List <string>      adminReceivers, userReceivers;
            JsonData           jTmplMsg = new JsonData(), jTmplMsgData = new JsonData(), jTmplMsgDataValue;

            //给管理员发送模板消息
            jTmplMsg["touser"]   = string.Empty;
            jTmplMsg["url"]      = @"http://mahui.me/admin/ManageGroupPurchase.aspx";
            jTmplMsg["topcolor"] = MSG_HEAD_COLOR;

            //从管理员角度看此团购活动是否成功,即已支付人数是否满足要求
            switch (groupEvent.GroupEventStatus)
            {
            case GroupEventStatus.EVENT_SUCCESS:
                jTmplMsg["template_id"]    = TMPL_GROUP_PURCHASE_EVENT_SUCCESS;
                jTmplMsgDataValue          = new JsonData();
                jTmplMsgDataValue["value"] = string.Format("团购活动“{0}#{1}”已成功,请尽快发货", groupEvent.GroupPurchase.Name, groupEvent.ID);
                jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                jTmplMsgData["first"]      = jTmplMsgDataValue;

                jTmplMsgDataValue          = new JsonData();
                jTmplMsgDataValue["value"] = groupEvent.GroupPurchase.Name;
                jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                jTmplMsgData["keyword1"]   = jTmplMsgDataValue;

                jTmplMsgDataValue          = new JsonData();
                jTmplMsgDataValue["value"] = string.Format("团购价:{0}元", groupEvent.GroupPurchase.GroupPrice.ToString("C"));
                jTmplMsgDataValue["color"] = MSG_HEAD_COLOR;
                jTmplMsgData["keyword2"]   = jTmplMsgDataValue;

                jTmplMsgDataValue          = new JsonData();
                jTmplMsgDataValue["value"] = string.Format("团购有效期:{0}~{1}", groupEvent.GroupPurchase.StartDate, groupEvent.GroupPurchase.EndDate);
                jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                jTmplMsgData["keyword3"]   = jTmplMsgDataValue;

                break;

            case GroupEventStatus.EVENT_FAIL:
                jTmplMsg["template_id"]    = TMPL_GROUP_PURCHASE_EVENT_FAIL;
                jTmplMsgDataValue          = new JsonData();
                jTmplMsgDataValue["value"] = string.Format("团购活动“{0}#{1}”已失效,请尽快退款", groupEvent.GroupPurchase.Name, groupEvent.ID);
                jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                jTmplMsgData["first"]      = jTmplMsgDataValue;

                jTmplMsgDataValue          = new JsonData();
                jTmplMsgDataValue["value"] = string.Format("团购价:{0}元", groupEvent.GroupPurchase.GroupPrice.ToString("C"));
                jTmplMsgDataValue["color"] = MSG_HEAD_COLOR;
                jTmplMsgData["keyword1"]   = jTmplMsgDataValue;

                jTmplMsgDataValue          = new JsonData();
                jTmplMsgDataValue["value"] = groupEvent.GroupPurchase.Name;
                jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                jTmplMsgData["keyword2"]   = jTmplMsgDataValue;

                jTmplMsgDataValue          = new JsonData();
                jTmplMsgDataValue["value"] = string.Format("团购有效期:{0}~{1}", groupEvent.GroupPurchase.StartDate, groupEvent.GroupPurchase.EndDate);
                jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                jTmplMsgData["keyword3"]   = jTmplMsgDataValue;

                break;
            }

            jTmplMsgDataValue          = new JsonData();
            jTmplMsgDataValue["value"] = "";
            jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
            jTmplMsgData["remark"]     = jTmplMsgDataValue;

            jTmplMsg["data"] = jTmplMsgData;

            adminReceivers = new List <string>(Config.WxTmplMsgReceiver.ToArray());
            jRet           = SendTmplMsg(adminReceivers, jTmplMsg);

            //查询此团购活动中的所有订单,并根据每个订单是否支付,来确定此用户的团购活动状态
            List <ProductOrder> poList = groupEvent.FindOrderByGroupEventID();
            poList.ForEach(po =>
            {
                jTmplMsg["touser"]   = string.Empty;
                jTmplMsg["url"]      = string.Format("http://mahui.me/GroupPurchaseEvent.aspx?EventID={0}", groupEvent.ID);
                jTmplMsg["topcolor"] = MSG_HEAD_COLOR;

                //从每个团购活动成员角度看活动状态,即已支付人数是否符合要求,此成员本人是否支付。根据每个成员的团购活动状态,发送不同的微信模板消息
                switch (GroupPurchaseEvent.CheckGroupPurchaseEventStatus(groupEvent, po.Purchaser))
                {
                case GroupEventStatus.EVENT_SUCCESS:
                    jTmplMsg["template_id"]    = TMPL_GROUP_PURCHASE_EVENT_SUCCESS;
                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = string.Format("您的拼团“{0}#{1}”已成功,请注意查收发货消息。", groupEvent.GroupPurchase.Name, groupEvent.ID);
                    jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                    jTmplMsgData["first"]      = jTmplMsgDataValue;

                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = po.OrderDetails;
                    jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                    jTmplMsgData["keyword1"]   = jTmplMsgDataValue;

                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = string.Format("{0}元", po.OrderPrice.ToString("C"));
                    jTmplMsgDataValue["color"] = MSG_HEAD_COLOR;
                    jTmplMsgData["keyword2"]   = jTmplMsgDataValue;

                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = po.OrderDate.ToString();
                    jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                    jTmplMsgData["keyword3"]   = jTmplMsgDataValue;

                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = string.Format("订单号:{0}\n点击详情查看团购活动", po.OrderID.Substring(18));
                    jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                    jTmplMsgData["remark"]     = jTmplMsgDataValue;

                    break;

                case GroupEventStatus.EVENT_FAIL:
                    jTmplMsg["template_id"]    = TMPL_GROUP_PURCHASE_EVENT_FAIL;
                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = string.Format("您的拼团“{0}#{1}”失败,我们将尽快退款给您。", groupEvent.GroupPurchase.Name, groupEvent.ID);
                    jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                    jTmplMsgData["first"]      = jTmplMsgDataValue;

                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = string.Format("{0}元", po.OrderPrice.ToString("C"));
                    jTmplMsgDataValue["color"] = MSG_HEAD_COLOR;
                    jTmplMsgData["keyword1"]   = jTmplMsgDataValue;

                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = po.OrderDetails;
                    jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                    jTmplMsgData["keyword2"]   = jTmplMsgDataValue;

                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = po.OrderID.Substring(18);
                    jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                    jTmplMsgData["keyword3"]   = jTmplMsgDataValue;

                    jTmplMsgDataValue          = new JsonData();
                    jTmplMsgDataValue["value"] = "点击详情查看团购活动";
                    jTmplMsgDataValue["color"] = MSG_BODY_COLOR;
                    jTmplMsgData["remark"]     = jTmplMsgDataValue;

                    break;
                }


                jTmplMsg["data"] = jTmplMsgData;

                userReceivers = new List <string>(new string[] { po.Purchaser.OpenID });
                jRet.Add(SendTmplMsg(userReceivers, jTmplMsg));
            });
        }
        catch (Exception ex)
        {
            Log.Error("GroupPurchaseEventSuccessOnOrderStateChanged", ex.Message);
            throw ex;
        }
    }