Esempio n. 1
0
        /// <summary>
        /// 根据模板类型返回填充模板内容(餐饮)
        /// </summary>
        /// <param name="OrderId"></param>
        /// <param name="sendMsgType"></param>
        /// <returns></returns>
        public object getTemplateMessageData(int OrderId, SendTemplateMessageTypeEnum sendMsgType)
        {
            StoreGoodsOrder       model    = GetModel(OrderId) ?? new StoreGoodsOrder();
            List <StoreGoodsCart> modelDtl = StoreGoodsCartBLL.SingleModel.GetList($" GoodsOrderId = {model.Id} ") ?? new List <StoreGoodsCart>();

            string            modelDtlName   = "";
            string            goodsIds       = string.Join(",", modelDtl.Select(s => s.GoodsId).Distinct());
            List <StoreGoods> storeGoodsList = StoreGoodsBLL.SingleModel.GetListByIds(goodsIds);

            modelDtl.ForEach(x =>
            {
                StoreGoods good = storeGoodsList?.FirstOrDefault(f => f.Id == x.GoodsId) ?? new StoreGoods();
                x.goodsMsg      = good;
            });
            modelDtlName = string.Join("+", modelDtl.Select(x => x.goodsMsg.GoodsName));

            //店名
            string           storeName  = "";
            Store            stroe      = StoreBLL.SingleModel.GetModel(model.StoreId) ?? new Store();
            List <ConfParam> paramslist = ConfParamBLL.SingleModel.GetListByRId(stroe.appId);
            ConfParam        cinfo      = paramslist?.Where(w => w.Param == "nparam").FirstOrDefault();

            if (cinfo != null)
            {
                storeName = cinfo.Value;
            }

            object postData = new object();

            switch (sendMsgType)
            {
            case SendTemplateMessageTypeEnum.电商订单支付成功通知:
                postData = new
                {
                    keyword1 = new { value = model.OrderNum, color = "#000000" },
                    keyword2 = new { value = model.CreateDateStr, color = "#000000" },
                    keyword3 = new { value = modelDtlName, color = "#000000" },
                    keyword4 = new { value = model.PayDateStr, color = "#000000" },
                    keyword5 = new { value = Enum.GetName(typeof(miniAppBuyMode), model.buyMode), color = "#000000" },
                    keyword6 = new { value = model.BuyPriceStr, color = "#000000" },
                    keyword7 = new { value = Enum.GetName(typeof(OrderState), model.State), color = "#000000" },
                };
                break;

            case SendTemplateMessageTypeEnum.电商订单配送通知:
                postData = new
                {
                    keyword1 = new { value = model.CreateDateStr, color = "#000000" },
                    keyword2 = new { value = storeName, color = "#000000" },
                    keyword3 = new { value = model.OrderNum, color = "#000000" },
                    keyword4 = new { value = model.Address, color = "#000000" },
                    keyword5 = new { value = model.DistributeDateStr, color = "#000000" },
                    keyword6 = new { value = modelDtlName, color = "#000000" },
                    keyword7 = new { value = Enum.GetName(typeof(OrderState), model.State), color = "#000000" },
                };
                break;
            }
            return(postData);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public List <string> BuildUpdateSendTimeSql(int sourceId, SendTemplateMessageTypeEnum templateType, DateTime newSendTime)
        {
            List <SubscribeMessage> messages = GetListByPara(sourceId: sourceId, templateType: templateType, sendState: SubscribeMsgState.等待发送);

            if (messages == null || messages.Count == 0)
            {
                return(null);
            }

            List <string> updateSqls = new List <string>();

            messages.ForEach(msg =>
            {
                msg.SendTime = newSendTime;
                updateSqls.Add(BuildUpdateSql(msg, "SendTime"));
            });

            return(updateSqls);
        }
Esempio n. 4
0
        public bool DeleteSubscribe(int sourceId, SendTemplateMessageTypeEnum templateType)
        {
            List <SubscribeMessage> messages = GetListByPara(sourceId: sourceId, templateType: templateType, sendState: SubscribeMsgState.等待发送);

            if (messages.Count == 0)
            {
                return(true);
            }

            TransactionModel tran = new TransactionModel();

            messages.ForEach(msg =>
            {
                msg.State = (int)SubscribeMsgState.除;
                tran.Add(BuildUpdateSql(msg, "state"));
            });

            return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray));
        }
Esempio n. 5
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));
 }
Esempio n. 6
0
        public List <SubscribeMessage> GetListByPara(int sourceId, SendTemplateMessageTypeEnum templateType, SubscribeMsgState sendState)
        {
            string whereSql = BuildWhereSql(sourceId: sourceId, templateType: templateType, sendState: sendState);

            return(GetList(whereSql));
        }
Esempio n. 7
0
 public TemplateMsg GetModelByTmgType(SendTemplateMessageTypeEnum templateMsgType)
 {
     return(base.GetModel($"tmgType = {(int)templateMsgType}"));
 }
Esempio n. 8
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 }));
        }