Beispiel #1
0
        /// <summary>
        /// 订单未支付-发送微信模板消息
        /// </summary>
        public void ProcessNotPayMsg()
        {
            //
            var numCount  = 100;
            var commonBLL = new CommonBLL();

            //
            var customerIDs = CustomerBLL.Instance.GetCustomerList();//获取所有商户

            foreach (var customer in customerIDs)
            {
                //
                var count = RedisOpenAPI.Instance.CCOrderNotPay().GetOrderNotPayLength(new CC_OrderNotPay
                {
                    CustomerID = customer.Key
                });
                if (count.Code != ResponseCode.Success)
                {
                    continue;
                }
                if (count.Result <= 0)
                {
                    continue;
                }

                //
                if (count.Result < numCount)
                {
                    numCount = Convert.ToInt32(count.Result);
                }

                //
                for (var i = 0; i < numCount; i++)
                {
                    //
                    try
                    {
                        var response = RedisOpenAPI.Instance.CCOrderNotPay().GetOrderNotPay(new CC_OrderNotPay
                        {
                            CustomerID = customer.Key
                        });
                        if (response.Code == ResponseCode.Success)
                        {
                            var templateID         = response.Result.ConfigData.TemplateID;
                            var openID             = response.Result.ConfigData.OpenID;
                            var vipID              = response.Result.ConfigData.VipID;
                            var loggingSessionInfo = CustomerBLL.Instance.GetBSLoggingSession(customer.Key, "1"); //response.Result.ConfigData.LogSession.JsonDeserialize<LoggingSessionInfo>();
                            var Data = new NotPay
                            {
                                first = new DataInfo {
                                    value = response.Result.OrderNotPayData.first.value, color = response.Result.OrderNotPayData.first.color
                                },
                                orderProductPrice = new DataInfo {
                                    value = response.Result.OrderNotPayData.orderProductPrice.value, color = response.Result.OrderNotPayData.orderProductPrice.color
                                },
                                orderProductName = new DataInfo {
                                    value = Math.Round(Convert.ToDecimal(response.Result.OrderNotPayData.orderProductName.value), 2).ToString(), color = response.Result.OrderNotPayData.orderProductName.color
                                },
                                orderAddress = new DataInfo {
                                    value = response.Result.OrderNotPayData.orderAddress.value, color = response.Result.OrderNotPayData.orderAddress.color
                                },
                                orderName = new DataInfo {
                                    value = response.Result.OrderNotPayData.orderName.value, color = response.Result.OrderNotPayData.orderName.color
                                },
                                remark = new DataInfo {
                                    value = response.Result.OrderNotPayData.remark.value, color = response.Result.OrderNotPayData.remark.color
                                }
                            };

                            commonBLL.SendMatchWXTemplateMessage(templateID, null, null, null, null, null, null, null, Data, "2", openID, null, loggingSessionInfo);
                        }
                    }
                    catch
                    {
                        continue;
                    }
                }
            }
        }
        public void NotPayMessage(string orderProductPrice, string orderProductName, string orderAddress, string orderName, string OpenID, LoggingSessionInfo loggingSessionInfo)
        {
            var CommonBLL      = new JIT.CPOS.BS.BLL.WX.CommonBLL();
            var WXTMConfigData = new WXTMConfigBLL(loggingSessionInfo).QueryByEntity(new WXTMConfigEntity()
            {
                TemplateIdShort = "TM00701", CustomerId = loggingSessionInfo.ClientID, IsDelete = 0
            }, null).FirstOrDefault();

            var Data = new NotPay();

            Data.first = new DataInfo()
            {
                value = WXTMConfigData.FirstText, color = WXTMConfigData.FirstColour
            };
            Data.orderProductPrice = new DataInfo()
            {
                value = orderProductPrice, color = WXTMConfigData.Colour1
            };                                                                                                   //订单金额
            Data.orderProductName = new DataInfo()
            {
                value = orderProductName, color = WXTMConfigData.Colour1
            };                                                                                                 //商品详情
            Data.orderAddress = new DataInfo()
            {
                value = orderAddress, color = WXTMConfigData.Colour1
            };                                                                                         //收货信息
            Data.orderName = new DataInfo()
            {
                value = orderName, color = WXTMConfigData.Colour1
            };                                                                                   //订单编号
            Data.remark = new DataInfo()
            {
                value = WXTMConfigData.RemarkText, color = WXTMConfigData.RemarkColour
            };                                                                                                        //remark是从模板里取出来的

            //下面往redis里存入数据
            var response = RedisOpenAPI.Instance.CCOrderNotPay().SetOrderNotPay(new CC_OrderNotPay
            {
                CustomerID = loggingSessionInfo.ClientID,
                ConfigData = new CC_ConfigData
                {
                    LogSession = loggingSessionInfo.JsonSerialize(),
                    OpenID     = OpenID,
                    TemplateID = WXTMConfigData.TemplateID,
                    //   VipID = VipID
                },
                OrderNotPayData = new CC_OrderNotPayData
                {
                    first = new CC_DataInfo {
                        value = Data.first.value, color = Data.first.color
                    },
                    orderProductPrice = new CC_DataInfo {
                        value = Data.orderProductPrice.value, color = Data.orderProductPrice.color
                    },
                    orderProductName = new CC_DataInfo {
                        value = Data.orderProductName.value, color = Data.orderProductName.color
                    },
                    orderAddress = new CC_DataInfo {
                        value = Data.orderAddress.value, color = Data.orderAddress.color
                    },
                    orderName = new CC_DataInfo {
                        value = Data.orderName.value, color = Data.orderName.color
                    },
                    remark = new CC_DataInfo {
                        value = Data.remark.value, color = Data.remark.color
                    }
                }
            });

            //如果往缓存redis里写入不成功,还是按照原来的老方法直接发送**
            if (response.Code != ResponseCode.Success)
            {
                CommonBLL.SendMatchWXTemplateMessage(WXTMConfigData.TemplateID, null, null, null, null, null, null, null, Data, "2", OpenID, null, loggingSessionInfo);

                new RedisXML().RedisReadDBCount("OrderNotPay", "订单未付款通知", 2);
            }
            else
            {
                new RedisXML().RedisReadDBCount("OrderNotPay", "订单未付款通知", 1);
            }

            //return  CommonBLL.SendMatchWXTemplateMessage(WXTMConfigData.TemplateID, CommonData, null, null, null, null, "8", OpenID, VipID, loggingSessionInfo);
        }