コード例 #1
0
        /// <summary>
        /// 订单取消发送订单取消通知模板消息
        /// </summary>
        /// <param name="pinOrder"></param>
        public void SendTemplateMsg_PayCancel(PinGoodsOrder pinOrder)
        {
            PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(pinOrder.aid, pinOrder.storeId);

            if (store == null && pinOrder.orderType == 0)
            {
                log4net.LogHelper.WriteError(GetType(), new Exception($"拼享惠发送订单取消模板消息失败,找不到店铺信息 aid:{pinOrder.aid}, storeid:{pinOrder.storeId}"));
                return;
            }

            //如果未支付,获取预支付码的formid是无效的,要取消
            if (pinOrder.payState == (int)PayState.未付款)
            {
                C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(pinOrder.userId);
                if (userInfo == null)
                {
                    log4net.LogHelper.WriteError(GetType(), new Exception($"拼享惠发送订单取消模板消息失败,找不到用户信息 userid:{pinOrder.userId}"));
                    return;
                }
                TemplateMsg_UserParam userParam = TemplateMsg_UserParamBLL.SingleModel.GetModel($" Form_Id is not null and appId = '{userInfo.appId}'  and  Open_Id = '{userInfo.OpenId}' and State = 1 and LoseDateTime > now() and orderId={pinOrder.id} ");
                if (userParam != null)
                {
                    userParam.State = -1;
                    TemplateMsg_UserParamBLL.SingleModel.Update(userParam, "state");
                }
            }
            //发给用户通知
            object orderData = TemplateMsg_Miniapp.PinGetTemplateMessageData(SendTemplateMessageTypeEnum.拼享惠订单取消通知, order: pinOrder, store: store);

            TemplateMsg_Miniapp.SendTemplateMessage(pinOrder.userId, SendTemplateMessageTypeEnum.拼享惠订单取消通知, TmpType.拼享惠, orderData, $"pages/shopping/orderInfo/orderInfo?orderid={pinOrder.id}&storeid={pinOrder.storeId}");
        }
コード例 #2
0
ファイル: BaseController.cs プロジェクト: soon14/vzan
        public ReturnMsg commitFormId(string utoken, dynamic postData)
        {
            string appid = postData.appid;

            //string openid, string formid
            if (string.IsNullOrEmpty(appid))
            {
                result.msg = "appid不能为空";
                return(result);
            }

            XcxAppAccountRelation umodel = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(appid);

            if (umodel == null)
            {
                result.msg = "小程序不存在";
                return(result);
            }
            C_UserInfo user = GetUserInfo(utoken);

            if (user == null)
            {
                result.msg = "非法请求";
                return(result);
            }
            string formid = postData.formid;

            if (string.IsNullOrEmpty(formid))
            {
                result.msg = "formid为空";
                return(result);
            }

            if (formid.Equals("the formId is a mock one"))
            {
                result.msg = "formId错误";
                return(result);
            }

            //增加发送模板消息参数
            TemplateMsg_UserParam userParam = new TemplateMsg_UserParam();

            userParam.AppId        = umodel.AppId;
            userParam.Form_IdType  = 0;//form_id
            userParam.Open_Id      = user.OpenId;
            userParam.AddDate      = DateTime.Now;
            userParam.Form_Id      = formid;
            userParam.State        = 1;
            userParam.SendCount    = 0;
            userParam.AddDate      = DateTime.Now;
            userParam.LoseDateTime = DateTime.Now.AddDays(7);//form_id 有效期7天

            userParam.Id = Convert.ToInt32(TemplateMsg_UserParamBLL.SingleModel.Add(userParam));
            result.code  = 1;
            result.obj   = new { FormId = formid };
            return(result);
        }