Beispiel #1
0
        /// <summary>
        /// 周报发送记录新增
        /// Created:20170509(ChengMengjia)
        /// </summary>
        /// <param name="project"></param>
        /// <param name="node"></param>
        /// <param name="id"></param>
        public JsonResult AddPubInfo(PubInfo entity, List <PubInfoFiles> list)
        {
            JsonResult jsonreslut = new JsonResult();
            ISession   s          = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                s.Save(entity);
                list.ForEach(t =>
                {
                    s.Save(t);
                });
                UpdateProject(s);
                s.Transaction.Commit();
                s.Close();
                jsonreslut.result = true;
                jsonreslut.msg    = "操作成功!";
                jsonreslut.data   = entity.ID;
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(ex, LogType.DataAccessDLL);
                jsonreslut.result = false;
                jsonreslut.msg    = ex.Message;
                s.Transaction.Rollback();
                s.Close();
            }
            return(jsonreslut);
        }
Beispiel #2
0
        /// <summary>
        ///  邮件发送
        /// Created:20170527(ChengMengjia)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                #region 检查
                if (string.IsNullOrEmpty(txtSend.Text))
                {
                    MessageHelper.ShowMsg(MessageID.W000000001, MessageType.Alert, "收件人");
                    return;
                }
                if (string.IsNullOrEmpty(txtTitle.Text))
                {
                    MessageHelper.ShowMsg(MessageID.W000000001, MessageType.Alert, "主题");
                    return;
                }
                if (string.IsNullOrEmpty(txtContent.Text))
                {
                    MessageHelper.ShowMsg(MessageID.W000000001, MessageType.Alert, "内容");
                    return;
                }
                #endregion
                #region 附件添加附件
                List <Attachment> listA = new List <Attachment>();
                foreach (DeliverablesFiles obj in EmailFiles)
                {
                    if (!string.IsNullOrEmpty(obj.NodeID))
                    {
                        obj.Path = FileHelper.GetWorkdir() + FileHelper.GetUploadPath(UploadType.WBS, ProjectId, obj.NodeID) + obj.Path;
                    }
                    string pathFileName = obj.Path;
                    string extName      = Path.GetExtension(pathFileName).ToLower(); //获取扩展名
                    listA.Add((extName == ".rar" || extName == ".zip")
                        ? new Attachment(pathFileName, MediaTypeNames.Application.Zip)
                        : new Attachment(pathFileName, MediaTypeNames.Application.Octet));
                }
                #endregion
                EmailHelper email = new EmailHelper(txtSend.Text, txtCC.Text, null, txtTitle.Text, false, txtContent.Text, listA);
                email.Send();

                PubInfo entity = new PubInfo();
                entity.PID     = ProjectId;
                entity.Title   = txtTitle.Text;
                entity.SendTo  = txtSend.Text;
                entity.CopyTo  = txtCC.Text;
                entity.Content = txtContent.Text;
                JsonResult result = pubBll.SavePubInfo(entity, EmailFiles);
                if (result.result)
                {
                    MessageBox.Show("发送成功!");
                }
                else
                {
                    MessageBox.Show(result.msg);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("发送失败!失败原因:" + ex.Message);
            }
        }
Beispiel #3
0
        public static void OperateRSA(ref Common.Transfer Trans, string MacType)
        {
            try
            {
                PubInfo Rp = (PubInfo)Assembly.Load("Business").CreateInstance("Business." + Trans.Class);
                //验证令牌请求
                //string HashString = Trans.Attribute.ToString() + DateTime.Now.ToString("yyyyMMdd") + Rp.Token.ToString();
                //解密参数
                //string mac = RSAHelperBGY.getInstance(MacType).Encrypt("<attributes><LoginCode>yinlian</LoginCode><Password>yl@123</Password><ComCode>UnionPay</ComCode><Token>20180528IntelligencePOS_Y</Token></attributes>");
                //new Logger().WriteLog("Mac", Trans.Mac);
                if (MacType == "UnionPay")
                {
                    Trans.Attribute = System.Web.HttpUtility.UrlDecode(RSAHelperBGY.getInstance(MacType).Decrypt(Trans.Mac));
                    new Logger().WriteLog("post数据", "http://218.13.58.36:8888/Service/BGYPost.ashx?Class=" + Trans.Class + "&Command=" + Trans.Command + "&ComCode=UnionPay&Mac=" + Trans.Mac + "&Attribute=" + Trans.Attribute);
                }
                else
                {
                    Trans.Attribute = System.Web.HttpUtility.UrlDecode(RSAHelperBGY_ALL.getInstance(MacType).Decrypt(Trans.Mac));
                }


                Rp.Operate(ref Trans);
            }
            catch (Exception ex)
            {
                Trans.Error = JSONHelper.JsonConvertBGY("0001", ex.Message, "");
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     PubInfo PI = new PubInfo();
     if(!chbNeedCheck.Checked)  //不需要审核的话,忽略免审核人员
     {
       txtFreeUserName.Text="";
         hidFreeUserGuid.Value="";
     }
     PI.InsertPubInfoType(txtTypeName.Text.Trim(), chbNeedCheck.Checked, chbOpen.Checked, hidFreeUserGuid.Value, txtFreeUserName.Text);
     CallJsFun("alert('添加成功.');window.close();");
 }
Beispiel #5
0
 private string ReceFees(DataRow row)
 {
     #region 获取基本参数
     string CommID = string.Empty;
     if (row.Table.Columns.Contains("CommID"))
     {
         CommID = row["CommID"].ToString();
     }
     string RoomID = string.Empty;
     if (row.Table.Columns.Contains("RoomID"))
     {
         RoomID = row["RoomID"].ToString();
     }
     string CustID = string.Empty;
     if (row.Table.Columns.Contains("CustID"))
     {
         CustID = row["CustID"].ToString();
     }
     #endregion
     #region 计算金额
     if (!row.Table.Columns.Contains("PayData") || string.IsNullOrEmpty(row["PayData"].ToString()))
     {
         return new ApiResult(false, "缺少参数PayData").toJson();
     }
     string PayData = row["PayData"].ToString();
     if (!CheckPayData(Global_Fun.BurstConnectionString(Convert.ToInt32(CommID), Global_Fun.BURST_TYPE_CHARGE), Convert.ToInt64(CustID), Convert.ToInt64(RoomID), PayData, out decimal Amt, out string errMsg, true, false, !"1940".Equals(Global_Var.LoginCorpID)))
     {
         return new ApiResult(false, errMsg).toJson();
     }
     if (Amt <= 0.00M)
     {
         return new ApiResult(false, "金额必须大于0").toJson();
     }
     #endregion
     JObject jObj = JObject.Parse(PayData);
     int Type = (int)jObj["Type"];
     if (Type != 1)
     {
         return new ApiResult(false, "收费类型有误").toJson();
     }
     JArray Data = (JArray)jObj["Data"];
     StringBuilder FeesIds = new StringBuilder();
     foreach (JObject item in Data)
     {
         FeesIds.Append((string)item["FeesId"] + ",");
     }
     if (!PubInfo.ReceFees(Global_Fun.BurstConnectionString(Convert.ToInt32(CommID), Global_Fun.BURST_TYPE_CHARGE), out long ReceID, CommID, CustID, RoomID, FeesIds.ToString(), 0.00M, "员工APP", "扫码支付", Global_Var.UserCode, 1))
     {
         return new ApiResult(false, "下账失败").toJson();
     }
     return new ApiResult(true, "下账成功").toJson();
 }
        /// <summary>
        /// 公告信息
        /// </summary>
        protected void GetGongGaoInfo()
        {
            PubInfo PI = new PubInfo();
            bool IsKAW = Convert.ToString(Session["IsCAW"]) == "Y" ? true : false;
            DataView dv = IsKAW ? (SysCache.CacheGet("ZJGLastPubInfo0") as DataView) : (SysCache.CacheGet("ZJGLastPubInfo1") as DataView);
            if (dv == null || dv.Count == 0)
            {
                int TotalNum = 0;
                dv = PI.SelectPubInfo(IsKAW, false, "", "", "", "", 8, 1, out TotalNum);
                if (IsKAW)
                {
                    SysCache.CacheAdd("ZJGLastPubInfo0", dv, 900, 0);
                }
                else
                {
                    SysCache.CacheAdd("ZJGLastPubInfo1", dv, 900, 0);
                }
            }

            if (dv.Count == 0)
            {
                uclPubNote.TitleImg = "";
                uclPubNote.PubTitleList = "&nbsp;&nbsp;&nbsp;&nbsp;<img src='/Images/loginf.gif' class='InfoList_img' />没有相关公告.";
                uclPubNote.PubURLList = "";
                uclPubNote.PubTimeList = "";
                return;
            }
            else
            {
                StringBuilder sbTitleList = new StringBuilder();
                StringBuilder sbPubURLList = new StringBuilder();
                StringBuilder sbTimeList = new StringBuilder();
                for (int i = 0; i < dv.Count - 1; i++)
                {
                    sbTitleList.Append("【").Append(dv[i]["TypeName"].ToString()).Append("】").Append(dv[i]["InfoTitle"].ToString()).Append("★");
                    sbPubURLList.Append("/Projects/ZJGEportPubInfo/Pages/PubInfoDetail_Show.aspx?InfoGuid=" + dv[i]["InfoGuid"].ToString()).Append("★");
                    sbTimeList.Append(dv[i]["PublishDate"].ToString().Split(' ')[0]).Append("★");
                }
                sbTitleList.Append("【").Append(dv[dv.Count - 1]["TypeName"].ToString()).Append("】").Append(dv[dv.Count - 1]["InfoTitle"].ToString());
                sbPubURLList.Append("/Projects/ZJGEportPubInfo/Pages/PubInfoDetail_Show.aspx?InfoGuid=" + dv[dv.Count - 1]["InfoGuid"].ToString());
                sbTimeList.Append(dv[dv.Count - 1]["PublishDate"].ToString().Split(' ')[0]);

                uclPubNote.PubTitleList = sbTitleList.ToString();
                uclPubNote.PubURLList = sbPubURLList.ToString();
                uclPubNote.PubTimeList = sbTimeList.ToString();
            }
        }
Beispiel #7
0
        /// <summary>
        /// 保存信息发布报发送记录
        /// Created:20170527(ChengMengjia)
        /// </summary>
        /// <param name="risk"></param>
        /// <param name="_id"></param>
        /// <returns></returns>
        public JsonResult SavePubInfo(PubInfo entity, List <DeliverablesFiles> list)
        {
            List <PubInfoFiles> listFiles = new List <PubInfoFiles>();

            entity.ID      = Guid.NewGuid().ToString();
            entity.Status  = 1;
            entity.CREATED = DateTime.Now;
            list.ForEach(t =>
            {
                listFiles.Add(new PubInfoFiles()
                {
                    ID      = Guid.NewGuid().ToString(),
                    PubID   = entity.ID,
                    Name    = t.Name,
                    Path    = t.Path,
                    Status  = 1,
                    CREATED = DateTime.Now,
                });
            });
            return(dao.AddPubInfo(entity, listFiles));
        }
Beispiel #8
0
 public static void Operate(ref Common.Transfer Trans)
 {
     try
     {
         PubInfo Rp         = (PubInfo)Assembly.Load("Business").CreateInstance("Business." + Trans.Class);
         var     HashString = Trans.Attribute.ToString() + DateTime.Now.ToString("yyyyMMdd") + Rp.Token;
         var     Mac        = AppPKI.getMd5Hash(HashString);
         #region 针对参数值带特殊字符的进行修改转义
         if (Trans.Attribute.Contains("&"))
         {
             Trans.Attribute = Trans.Attribute.Replace("&", "&amp;");
         }
         #endregion
         //鸿坤第三方 不要安全验证 单独去掉
         if (Trans.Class == "HKCallCenter")
         {
             Rp.Operate(ref Trans);
         }
         else if (Trans.Class == "DataVHJ")
         {
             //合景datav 大屏 去掉验证
             Rp.Operate(ref Trans);
         }
         else if (Trans.Class == "ContractAuditInfo_FanWei")
         {
             //合景经营合同审核 去掉验证
             Rp.Operate(ref Trans);
         }
         else if (Trans.Class == "PolyDataV")
         {
             //合景datav 大屏 去掉验证
             Rp.Operate(ref Trans);
         }
         else if (Trans.Class == "CostInfoSunshineNewest")
         {
             Rp.Operate(ref Trans);
         }
         else if (Trans.Class == "HKParkCostInfo")
         {
             Rp.Operate(ref Trans);
         }
         else if (Trans.Class == "CostInfo_RS" || Trans.Class == "Meter_RS" || Trans.Class == "Material_RS")
         {
             if (Trans.Mac == Mac)
             {
                 Rp.Operate(ref Trans);
             }
             else
             {
                 Trans.Error = "验证令牌错误";
             }
         }
         else
         {
             if (HttpContext.Current.Request.Url.Host.ToLower() == "localhost")
             {
                 Rp.Operate(ref Trans);
             }
             else
             {
                 if (!OperateKnownClass(ref Trans))
                 {
                     if (Trans.Mac == Mac)
                     {
                         Rp.Operate(ref Trans);
                     }
                     else
                     {
                         Trans.Error = "验证令牌错误";
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         PubInfo.GetLog().Error(ex);
         Trans.Error = new ApiResult(false, ex.Message + Environment.NewLine + ex.StackTrace).toJson();
     }
 }
Beispiel #9
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                //接收回调xml信息
                byte[] byts = new byte[context.Request.InputStream.Length];
                context.Request.InputStream.Read(byts, 0, byts.Length);
                string req = Encoding.UTF8.GetString(byts);

                PubInfo.GetLog().Info("鸿坤京东收款通接收内容:" + req);
                if (string.IsNullOrEmpty(req))
                {
                    throw new Exception("接口未获取到任何数据");
                }

                //初步解析接收内容,获取到商家编号
                var res = XMLUtil.decryptResXmlNew <JdPayResponse>(req);

                //根据商家编号获取配置信息
                WxPayConfig payConfig = GenerateConfig(res.merchant);
                if (payConfig == null)
                {
                    throw new Exception("根据商家编号没有找到配置信息");
                }
                //根据配置的密钥进行解析数据
                AsynNotifyResponse anyResponse = XMLUtil.decryptResXml <AsynNotifyResponse>(payConfig.APPID, payConfig.KEY, req);

                //判断订单是否成过
                if ("success".Equals(anyResponse.result.desc))
                {
                    DateTime DateNow = DateTime.Now;
                    string   orderId = anyResponse.tradeNum;
                    string   amt     = anyResponse.amount.ToString();
                    // 通过OrderID订单号查询对应订单
                    using (IDbConnection conn = new SqlConnection(PubConstant.UnifiedContionString))
                    {
                        dynamic OrderInfo = conn.QueryFirstOrDefault("SELECT * FROM Tb_CCBPay_Order WHERE OrderSN = @OrderSN", new { OrderSN = orderId });
                        if (null == OrderInfo)
                        {
                            PubInfo.GetLog().Info("鸿坤京东收款通知内容:订单不存在");
                            return;
                        }
                        if (3 == Convert.ToInt32(OrderInfo.IsSucc))
                        {
                            PubInfo.GetLog().Info("鸿坤京东收款通知内容:订单已下账");
                            return;
                        }

                        // 获取支付配置信息
                        dynamic PayConfig = conn.QueryFirstOrDefault("SELECT * FROM Tb_JDPay_Config WHERE Id = @Id", new { Id = OrderInfo.PayConfigNewId });
                        if (null == PayConfig)
                        {
                            PubInfo.GetLog().Info("鸿坤京东收款通知内容:支付配置不存在");
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, null, 0, req, 2, "支付配置不存在");
                            return;
                        }

                        // 获取小区信息
                        Tb_Community tb_Community = PubInfo.GetCommunity(Convert.ToString(PayConfig.CommunityId));
                        if (null == tb_Community)
                        {
                            PubInfo.GetLog().Info("鸿坤京东收款通知内容:小区配置不存在");
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, null, 0, req, 2, "小区配置不存在");
                            return;
                        }
                        decimal SAmt = Convert.ToDecimal(amt) / 100;
                        // 判断金额是否一致
                        if (Convert.ToDecimal(OrderInfo.Amt) != SAmt)
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤京东收款通知内容:账单金额与实收金额不一致(SAmt={0})", SAmt);
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, null, 0, req, 2, "账单金额与实收金额不一致");
                            return;
                        }

                        string erpConnStr = PubInfo.GetConnectionStr(tb_Community);

                        JObject PayData = JsonConvert.DeserializeObject <JObject>(Convert.ToString(OrderInfo.PayData));

                        int Type = (int)PayData["Type"];
                        if (Type == 1)
                        {
                            JArray Data = (JArray)PayData["Data"];
                            if (null == Data || Data.Count == 0)
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤京东收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, req, 2, "下账失败(订单支付信息有误)");
                                return;
                            }
                            StringBuilder FeesIds = new StringBuilder();
                            foreach (JObject item in Data)
                            {
                                FeesIds.Append((string)item["FeesId"] + ",");
                            }
                            if (PubInfo.ReceFees(erpConnStr, out long ReceID, Convert.ToString(tb_Community.CommID), Convert.ToString(OrderInfo.CustID), Convert.ToString(OrderInfo.RoomID), FeesIds.ToString(), 0.00M, "自助缴费-京东"))
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤京东收款通知内容:下账成功(PayData={0})", OrderInfo.PayData);

                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString().ToString(), SAmt, req, 3, "下账成功");

                                return;
                            }
                            else
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤京东收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString().ToString(), SAmt, req, 4, "下账失败");
                                return;
                            }
                        }
                        else if (Type == 2)
                        {
                            JObject Data = (JObject)PayData["Data"];
                            if (null == Data)
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤京东收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, req, 2, "支付金额必须大于0");
                                return;
                            }
                            string CostID = (string)Data["CostID"];

                            decimal Amt = (Decimal)Data["Amt"];
                            if (PubInfo.RecePreFees(erpConnStr, out long ReceID, Convert.ToString(tb_Community.CommID), Convert.ToString(OrderInfo.CustID), Convert.ToString(OrderInfo.RoomID), CostID, Amt, "自助缴费-京东"))
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤京东收款通知内容:下账成功(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, req, 3, "下账成功");
                                return;
                            }
                            else
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤京东收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, req, 4, "下账失败");
                                return;
                            }
                        }
                        else
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤京东收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, req, 2, "下账失败(订单支付信息有误)");
                            return;
                        }
                    }
Beispiel #10
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                DateTime      DateNow = DateTime.Now;
                List <string> list    = new List <string>();
                foreach (var item in context.Request.Params.AllKeys)
                {
                    list.Add($"{item}={context.Request.Params[item]}");
                }
                Business.Alipay.Log("收到微信通知" + context.Request.RawUrl + "?" + string.Join("&", list));

                HttpRequest Request = context.Request;
                context.Response.ContentType = "text/plain";

                string respcode = "";
                string respmsg  = "";
                string orderId  = "";
                //string CommunityId = "";
                string amt = "";

                //返回报文中不包含UPOG,表示Server端正确接收交易请求,则需要验证Server端返回报文的签名
                bool      IsValidate = false;
                WxPayData WxPostData = new WxPayData();
                string    Result     = Notify.NotifyDataFromContext(context, ref IsValidate, ref WxPostData);

                respcode = WxPostData.GetValue("result_code").ToString();
                respmsg  = WxPostData.GetValue("result_code").ToString();
                orderId  = WxPostData.GetValue("out_trade_no").ToString();
                //CommunityId = WxPostData.GetValue("attach").ToString();
                amt = WxPostData.GetValue("total_fee").ToString();
                //string userId = null;
                //if (CommunityId.Contains(","))
                //{
                //    userId = CommunityId.Split(',')[1];
                //    CommunityId = CommunityId.Split(',')[0];
                //}

                if (IsValidate == false)
                {
                    //Business.WeiXinPay.Log("验签失败:" + CommunityId + "," + orderId.ToString());
                    Business.WeiXinPay.Log("验签失败:" + orderId.ToString());
                    Result = SetNotifyResult("FAIL", Result);
                    context.Response.Write(Result);
                    return;
                }

                Business.WeiXinPay.Log("微信支付验签成功:" + orderId.ToString());

                if (IsValidate == true)
                {
                    // 通过OrderID订单号查询对应订单
                    using (IDbConnection conn = new SqlConnection(PubConstant.UnifiedContionString))
                    {
                        dynamic OrderInfo = conn.QueryFirstOrDefault("SELECT * FROM Tb_CCBPay_Order WHERE OrderSN = @OrderSN", new { OrderSN = orderId });
                        if (null == OrderInfo)
                        {
                            PubInfo.GetLog().Info("鸿坤建行收款通知内容:订单不存在");
                            return;
                        }
                        if (3 == Convert.ToInt32(OrderInfo.IsSucc))
                        {
                            PubInfo.GetLog().Info("鸿坤建行收款通知内容:订单已下账");
                            return;
                        }

                        // 获取支付配置信息
                        dynamic PayConfig = conn.QueryFirstOrDefault("SELECT * FROM Tb_WeiXinPay_Config WHERE Id = @Id", new { Id = OrderInfo.PayConfigNewId });
                        if (null == PayConfig)
                        {
                            PubInfo.GetLog().Info("鸿坤建行收款通知内容:支付配置不存在");
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, null, 0, JsonConvert.SerializeObject(WxPostData), 2, "支付配置不存在");
                            return;
                        }

                        // 获取小区信息
                        Tb_Community tb_Community = PubInfo.GetCommunity(Convert.ToString(PayConfig.CommunityId));
                        if (null == tb_Community)
                        {
                            PubInfo.GetLog().Info("鸿坤建行收款通知内容:小区配置不存在");
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, null, 0, JsonConvert.SerializeObject(WxPostData), 2, "小区配置不存在");
                            return;
                        }
                        decimal SAmt = Convert.ToDecimal(amt) / 100;
                        // 判断金额是否一致
                        if (Convert.ToDecimal(OrderInfo.Amt) != SAmt)
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:账单金额与实收金额不一致(SAmt={0})", SAmt);
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, null, 0, JsonConvert.SerializeObject(WxPostData), 2, "账单金额与实收金额不一致");
                            return;
                        }

                        string erpConnStr = PubInfo.GetConnectionStr(tb_Community);

                        JObject PayData = JsonConvert.DeserializeObject <JObject>(Convert.ToString(OrderInfo.PayData));

                        int Type = (int)PayData["Type"];
                        if (Type == 1)
                        {
                            JArray Data = (JArray)PayData["Data"];
                            if (null == Data || Data.Count == 0)
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, JsonConvert.SerializeObject(WxPostData), 2, "下账失败(订单支付信息有误)");
                                return;
                            }
                            StringBuilder FeesIds = new StringBuilder();
                            foreach (JObject item in Data)
                            {
                                FeesIds.Append((string)item["FeesId"] + ",");
                            }
                            if (PubInfo.ReceFees(erpConnStr, out long ReceID, Convert.ToString(tb_Community.CommID), Convert.ToString(OrderInfo.CustID), Convert.ToString(OrderInfo.RoomID), FeesIds.ToString(), 0.00M, "自助缴费-微信"))
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账成功(PayData={0})", OrderInfo.PayData);

                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString().ToString(), SAmt, JsonConvert.SerializeObject(WxPostData), 3, "下账成功");
                                return;
                            }
                            else
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString().ToString(), SAmt, JsonConvert.SerializeObject(WxPostData), 4, "下账失败");
                                return;
                            }
                        }
                        else if (Type == 2)
                        {
                            JObject Data = (JObject)PayData["Data"];
                            if (null == Data)
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, JsonConvert.SerializeObject(WxPostData), 2, "支付金额必须大于0");
                                return;
                            }
                            string CostID = (string)Data["CostID"];

                            decimal Amt = (Decimal)Data["Amt"];
                            if (PubInfo.RecePreFees(erpConnStr, out long ReceID, Convert.ToString(tb_Community.CommID), Convert.ToString(OrderInfo.CustID), Convert.ToString(OrderInfo.RoomID), CostID, Amt, "自助缴费-微信"))
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账成功(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, JsonConvert.SerializeObject(WxPostData), 3, "下账成功");
                                return;
                            }
                            else
                            {
                                PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                                Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, JsonConvert.SerializeObject(WxPostData), 4, "下账失败");
                                return;
                            }
                        }
                        else
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString(), SAmt, JsonConvert.SerializeObject(WxPostData), 2, "下账失败(订单支付信息有误)");
                            return;
                        }
                    }
Beispiel #11
0
        /// <summary>
        /// 物业订单收款
        /// </summary>
        /// <param name="CommunityId"></param>
        /// <param name="OrderId"></param>
        /// <param name="respCode"></param>
        /// <param name="respmsg"></param>
        /// <returns></returns>
        public static string ReceProperyOrder(decimal total_amount, string CommunityId, string out_trade_no, string pointUseHistoryID)
        {
            DataTable dAttributeTable = new DataTable();

            dAttributeTable.Columns.Add("CustID", Type.GetType("System.String"));
            DataRow newRow;

            newRow           = dAttributeTable.NewRow();
            newRow["CustID"] = out_trade_no;
            dAttributeTable.Rows.Add(newRow);
            RecordClientInfo record = new RecordClientInfo();

            try
            {
                PubConstant.hmWyglConnectionString = GetConnection(CommunityId);

                using (IDbConnection conn = new SqlConnection(PubConstant.hmWyglConnectionString))
                {
                    var T_Order = conn.Query <Tb_OL_AlipayOrder>(@"SELECT * FROM Tb_OL_AlipayOrder with(nolock) WHERE out_trade_no=@out_trade_no",
                                                                 new { out_trade_no = out_trade_no }).SingleOrDefault();


                    if (T_Order != null && T_Order.IsSucc.GetValueOrDefault().ToString() == "1")
                    {
                        return("物业订单已下账");
                    }

                    //查找当前订单对应的feesid
                    var OrderDetailList = conn.Query <Tb_OL_AlipayDetail>(@"select * from Tb_OL_AlipayDetail with(nolock) WHERE PayOrderId=@PayOrderId", new { PayOrderId = T_Order.Id });
                    if (OrderDetailList.Count() <= 0)
                    {
                        return("物业订单无费用项");
                    }

                    if (T_Order.RoomId != null && T_Order.RoomId.GetValueOrDefault() > 0)
                    {
                        string FeesID = "";
                        foreach (var o in OrderDetailList)
                        {
                            FeesID += (o.FeesId + ",");
                        }

                        FeesID = FeesID.TrimEnd(',');
                        string[] feesArray = FeesID.Split(',').Distinct().ToArray();
                        FeesID = string.Join(",", feesArray.ToArray());

                        if (PubInfo.ReceFees(PubConstant.hmWyglConnectionString, out long ReceID, Convert.ToString(T_Order.CommID), Convert.ToString(T_Order.CustId), Convert.ToString(T_Order.RoomId), FeesID.ToString(), 0.00M, "自助缴费-支付宝", "自助缴费-支付宝"))
                        {
                            //Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString().ToString(), SAmt, JsonConvert.SerializeObject(WxPostData), 3, "下账成功");
                            Business.HKCCBPay.UpdateOrderInfoAlipay(PubConstant.hmWyglConnectionString, out_trade_no, 1, "下账成功");
                            //更新已支付金额
                            Business.HKCCBPay.UpdateOrderDetailAlipay(PubConstant.hmWyglConnectionString, T_Order.Id);
                            return("success");;
                        }
                        else
                        {
                            Business.HKCCBPay.UpdateOrderInfoAlipay(PubConstant.UnifiedContionString, out_trade_no, 0, "下账失败");
                            //Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, orderId, DateNow.ToString().ToString(), SAmt, JsonConvert.SerializeObject(WxPostData), 0, "下账失败");
                            return("fail");;
                        }
                    }
                    else
                    {
                        ReceFees(total_amount, CommunityId, out_trade_no, pointUseHistoryID);
                    }
                }
Beispiel #12
0
        /// <summary>
        /// 计算赠送积分
        /// </summary>
        private void PresentedPoint(string communityId, string orderId, string userId, string useHistoryId, decimal paidAmount)
        {
            using (var appConn = new SqlConnection(PubConstant.UnifiedContionString))
            {
                if (appConn.State == ConnectionState.Closed)
                {
                    appConn.Open();
                }

                var trans = appConn.BeginTransaction();

                short corpId = 0;
                try
                {
                    decimal propertyMaxDiscountsAmount = 0.0m;  // 物管费最大可抵用金额
                    decimal parkingMaxDiscountsAmount  = 0.0m;  // 车位费最大可抵用金额

                    var deductionObject = new List <string>();  // 积分可抵扣对象

                    using (var erpConn = new SqlConnection(PubInfo.GetConnectionStr(PubInfo.GetCommunity(communityId))))
                    {
                        var feesIds = erpConn.Query <long>(@"SELECT FeesId FROM Tb_OL_AlipayDetail WHERE PayOrderId=
                                                            (SELECT Id FROM Tb_OL_AlipayOrder WHERE out_trade_no=@out_trade_no)",
                                                           new { out_trade_no = orderId });

                        if (feesIds.Count() == 0)
                        {
                            return;
                        }

                        #region 获取积分抵扣规则
                        // 企业编号
                        corpId = appConn.Query <short>("SELECT CorpID FROM Tb_Community WHERE Id=@CommunityId",
                                                       new { CommunityId = communityId }, trans).FirstOrDefault();

                        // 积分权限控制
                        var controlInfo = appConn.Query <Tb_Control_AppPoint>(@"SELECT * FROM Tb_Control_AppPoint WHERE CorpID=@CorpID AND IsEnable=1 
                                                                            AND (CommunityID=@CommunityId OR CommunityID IS NULL) ORDER BY CommunityID DESC",
                                                                              new { CorpID = corpId, CommunityId = communityId }, trans).FirstOrDefault();

                        if (controlInfo == null || controlInfo.IsEnable == false)
                        {
                            controlInfo             = Tb_Control_AppPoint.DefaultControl;
                            controlInfo.CommunityID = Guid.Empty.ToString();
                        }

                        // 允许抵用物业费
                        if (controlInfo.AllowDeductionPropertyFees)
                        {
                            deductionObject.Add($@"'{AppPointUsableObjectConverter.GetKey(AppPointUsableObject.PropertyFee)}'");
                        }
                        // 允许抵用车位费
                        if (controlInfo.AllowDeductionParkingFees)
                        {
                            deductionObject.Add($@"'{AppPointUsableObjectConverter.GetKey(AppPointUsableObject.ParkingFee)}'");
                        }
                        #endregion

                        // 不计算违约金
                        string sql    = $@"SELECT isnull(sum(isnull(DebtsAmount,0)),0) 
                                            FROM view_HSPR_Fees_Filter WHERE FeesID IN({string.Join(",", feesIds)}) AND SysCostSign = 'B0001';
                                        SELECT isnull(sum(isnull(DebtsAmount,0)),0)
                                            FROM view_HSPR_Fees_Filter WHERE FeesID IN({string.Join(",", feesIds)}) AND SysCostSign = 'B0002';";
                        var    reader = erpConn.QueryMultiple(sql);

                        // 物业费、车位费实际欠费总额
                        decimal propertyAmount = reader.Read <decimal>().FirstOrDefault();
                        decimal parkingAmount  = reader.Read <decimal>().FirstOrDefault();

                        // 积分抵用了部分金额
                        if (!string.IsNullOrEmpty(useHistoryId))
                        {
                            // 积分抵用的金额数量
                            var deductionAmount = appConn.Query <decimal>(@"SELECT isnull(DeductionAmount,0) FROM Tb_App_Point_UseHistory WHERE IID=@IID;",
                                                                          new { IID = useHistoryId }, trans).FirstOrDefault();

                            // 计算相关抵用的金额
                            if (deductionAmount != 0)
                            {
                                // 积分抵用规则
                                var ruleInfo = appConn.Query($@"SELECT IID,ConditionAmount,DiscountsAmount,DeductionObject,b.Remark AS SysCostSign,StartTime,EndTime 
                                                            FROM Tb_App_Point_PropertyDeductionRule a LEFT JOIN Tb_Dictionary_Point_UsableObject b
                                                            ON a.DeductionObject=b.[Key] 
                                                            WHERE CommunityID=@CommunityId AND DeductionObject IN({string.Join(", ", deductionObject) }) 
                                                            AND getdate() BETWEEN StartTime AND EndTime AND a.IsDelete=0 ORDER BY ConditionAmount,DiscountsAmount",
                                                             new { CommunityId = communityId }, trans);

                                if (ruleInfo.Count() == 0)
                                {
                                    Business.Alipay.Log("支付宝下账:计算赠送积分失败,相关积分抵用规则已被禁用");
                                    return;
                                }

                                // 确定物管费可抵用金额
                                if (propertyAmount > 0)
                                {
                                    string key = AppPointUsableObjectConverter.GetKey(AppPointUsableObject.PropertyFee);
                                    foreach (var item in ruleInfo)
                                    {
                                        if (item.DeductionObject == key && propertyAmount >= item.ConditionAmount)
                                        {
                                            propertyMaxDiscountsAmount = item.DiscountsAmount;
                                        }
                                    }
                                }

                                // 确定车位费可抵用金额
                                if (parkingAmount > 0)
                                {
                                    string key = AppPointUsableObjectConverter.GetKey(AppPointUsableObject.ParkingFee);
                                    foreach (var item in ruleInfo)
                                    {
                                        if (item.DeductionObject == key && parkingAmount >= item.ConditionAmount)
                                        {
                                            parkingMaxDiscountsAmount = item.DiscountsAmount;
                                        }
                                    }
                                }

                                // 积分数量不正常
                                if (deductionAmount > (parkingMaxDiscountsAmount + propertyMaxDiscountsAmount))
                                {
                                    Business.Alipay.Log("支付宝下账:计算赠送积分失败,积分实际抵用金额超出可抵用金额");
                                    return;
                                }
                                else
                                {
                                    decimal tmp = deductionAmount;

                                    // 部分抵扣物业费
                                    if (propertyMaxDiscountsAmount != 0)
                                    {
                                        if (tmp <= propertyMaxDiscountsAmount)
                                        {
                                            propertyMaxDiscountsAmount = tmp;
                                            tmp = 0;
                                        }
                                        else
                                        {
                                            tmp -= propertyMaxDiscountsAmount;
                                        }
                                    }

                                    // 部分抵扣车位费
                                    if (parkingMaxDiscountsAmount != 0 && tmp > 0)
                                    {
                                        if (tmp <= parkingMaxDiscountsAmount)
                                        {
                                            parkingMaxDiscountsAmount = tmp;
                                            tmp = 0;
                                        }
                                        else
                                        {
                                            tmp -= parkingMaxDiscountsAmount;
                                        }
                                    }

                                    if (tmp != 0)
                                    {
                                        Business.Alipay.Log("支付宝下账:计算赠送积分失败,积分实际抵用金额与可抵用金额不相等,可能是更改了积分抵用规则");
                                        return;
                                    }
                                }
                            }
                        }

                        // 计算要赠送的积分数量
                        new AppPoint().CalcPresentedPointForPropertyFees(communityId, propertyAmount - propertyMaxDiscountsAmount, parkingAmount - parkingMaxDiscountsAmount, out int p1, out int p2);

                        if (p1 == 0 && p2 == 0)
                        {
                            return;
                        }

                        int presentedPoints = p1 + p2;

                        var userPoint = appConn.Query("SELECT * FROM Tb_App_UserPoint WHERE UserID=@UserID", new { UserID = userId }, trans).FirstOrDefault();
                        int balance   = 0;

                        if (userPoint == null)
                        {
                            balance = 0;
                            appConn.Execute(@"INSERT INTO Tb_App_UserPoint(UserID, PointBalance) VALUES(@UserID, @PointBalance)",
                                            new { UserID = userId, PointBalance = presentedPoints }, trans);
                        }
                        else
                        {
                            balance = userPoint.PointBalance;
                            appConn.Execute("UPDATE Tb_App_UserPoint SET PointBalance=(PointBalance+@PresentedPoints) WHERE UserID=@UserID",
                                            new
                            {
                                PresentedPoints = presentedPoints,
                                UserID          = userId
                            }, trans);
                        }

                        // 赠送历史
                        appConn.Execute(@"INSERT INTO Tb_App_Point_PresentedHistory(UserID, PresentedWay, PresentedPoints, PointBalance, Remark) 
                                    VALUES(@UserID, @PresentedWay, @PresentedPoints, @PointBalance, @Remark)",
                                        new
                        {
                            UserID          = userId,
                            PresentedWay    = AppPointPresentedWayConverter.GetKey(AppPointPresentedWay.PropertyArrearsPayment),
                            PresentedPoints = presentedPoints,
                            PointBalance    = balance + presentedPoints,
                            Remark          = AppPointPresentedWayConverter.GetValue(AppPointPresentedWay.PropertyArrearsPayment),
                        }, trans);

                        Business.Alipay.Log("支付宝下账:赠送积分=" + presentedPoints);

                        // 力帆,缴清,额外赠送
                        if (corpId == 2015)
                        {
                            // 查询CustID、RoomID
                            var custInfo = erpConn.Query(@"SELECT CustID,RoomID FROM Tb_HSPR_Fees WHERE FeesID=
                                                              (SELECT TOP 1 FeesId FROM Tb_OL_AlipayDetail WHERE PayOrderId IN
                                                                (SELECT Id FROM Tb_OL_AlipayOrder WHERE out_trade_no=@out_trade_no))",
                                                         new { out_trade_no = orderId }).FirstOrDefault();

                            if (custInfo != null && custInfo.CustID != 0 && custInfo.RoomID != 0)
                            {
                                // 无欠费
                                if (erpConn.Query(@"SELECT * FROM Tb_HSPR_Fees WHERE CustID=@CustID AND RoomID=@RoomID AND isnull(IsCharge,0)=0",
                                                  new { CustID = custInfo.CustID, RoomID = custInfo.RoomID }).Count() == 0)
                                {
                                    int extraPoints = new AppPoint().CalcPresentedPointForPayAll();
                                    if (extraPoints > 0)
                                    {
                                        presentedPoints += extraPoints;

                                        // 赠送积分
                                        appConn.Execute(@"UPDATE Tb_App_UserPoint SET PointBalance=(PointBalance+@PresentedPoints) WHERE UserID=@UserID;
                                                      INSERT INTO Tb_App_Point_PresentedHistory(UserID, PresentedWay, PresentedPoints, PointBalance, Remark) 
                                                      VALUES(@UserID, @PresentedWay, @PresentedPoints, @PointBalance, @Remark);",
                                                        new
                                        {
                                            UserID          = userId,
                                            PresentedWay    = AppPointPresentedWayConverter.GetKey(AppPointPresentedWay.PropertyArrearsPayment),
                                            PresentedPoints = extraPoints,
                                            PointBalance    = balance + presentedPoints,
                                            Remark          = "物业欠费缴清赠送",
                                        }, trans);
                                    }
                                }
                            }
                        }
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    Business.Alipay.Log("支付宝下账:计算赠送积分异常," + ex.Message + Environment.NewLine + ex.StackTrace);
                }
            }
        }
Beispiel #13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            try
            {
                Common.Transfer Trans = new Common.Transfer();

                HttpRequest Request = context.Request;
                Dictionary <string, string> param = new Dictionary <string, string>();
                foreach (string key in Request.Form.AllKeys)
                {
                    param.Add(key, Request.Params[key]);
                }
                if (!param.ContainsKey("Class"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Class").toJson());
                    return;
                }
                Trans.Class = param["Class"].ToString();
                if (string.IsNullOrEmpty(Trans.Class))
                {
                    context.Response.Write(new ApiResult(false, "Class不能为空").toJson());
                    return;
                }
                if (!param.ContainsKey("Command"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Command").toJson());
                    return;
                }
                Trans.Command = param["Command"].ToString();

                if (string.IsNullOrEmpty(Trans.Command))
                {
                    context.Response.Write(new ApiResult(false, "Command不能为空").toJson());
                    return;
                }

                string json = JsonConvert.SerializeObject(new { Attribute = param });
                Trans.Attribute = JsonConvert.DeserializeXmlNode(json).OuterXml;
                if (string.IsNullOrEmpty(Trans.Attribute))
                {
                    context.Response.Write(new ApiResult(false, "Attribute不能为空").toJson());
                    return;
                }
                PubInfo Rp         = (PubInfo)Assembly.Load("Business").CreateInstance("Business." + Trans.Class);
                var     HashString = Trans.Attribute.ToString() + DateTime.Now.ToString("yyyyMMdd") + Rp.Token;
                var     Mac        = AppPKI.getMd5Hash(HashString);
                Trans.Mac = Mac;
                if (Trans.Class == "Files")
                {
                    new Files().ProcessRequest(context);
                }
                else
                {
                    PubContext.Operate(ref Trans);
                }

                Compress(context);
                context.Response.Write(Trans.Output());
            }
            catch (Exception ex)
            {
                context.Response.Write(new ApiResult(false, ex.Message + Environment.NewLine + ex.StackTrace).toJson());
            }
        }
Beispiel #14
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest  Request  = context.Request;
            HttpResponse Response = context.Response;

            Response.ContentType = "text/plain";
            DateTime DateNow = DateTime.Now;

            try
            {
                if (!"POST".Equals(Request.HttpMethod.ToUpper()))
                {
                    PubInfo.GetLog().Info("不是鸿坤建行收款通知");
                    return;
                }
                Dictionary <string, string> param = new Dictionary <string, string>();
                foreach (var item in Request.QueryString.AllKeys)
                {
                    param.Add(item, Request.QueryString[item]);
                }
                PubInfo.GetLog().Info("收到鸿坤建行收款通知:" + JsonConvert.SerializeObject(param));
                if (!"Y".Equals(param["SUCCESS"].ToUpper()))
                {
                    PubInfo.GetLog().Info("鸿坤建行收款通知内容:交易状态不是成功状态");
                    return;
                }
                // 通过OrderID订单号查询对应订单
                using (IDbConnection conn = new SqlConnection(PubConstant.UnifiedContionString))
                {
                    dynamic OrderInfo = conn.QueryFirstOrDefault("SELECT * FROM Tb_CCBPay_Order WHERE OrderSN = @OrderSN", new { OrderSN = param["ORDERID"] });
                    if (null == OrderInfo)
                    {
                        PubInfo.GetLog().Info("鸿坤建行收款通知内容:订单不存在");
                        return;
                    }
                    if (3 == Convert.ToInt32(OrderInfo.IsSucc))
                    {
                        PubInfo.GetLog().Info("鸿坤建行收款通知内容:订单已下账");
                        return;
                    }

                    // 获取支付配置信息
                    dynamic PayConfig = conn.QueryFirstOrDefault("SELECT * FROM Tb_CCBPay_Config WHERE Id = @Id", new { Id = OrderInfo.PayConfigId });
                    if (null == PayConfig)
                    {
                        PubInfo.GetLog().Info("鸿坤建行收款通知内容:支付配置不存在");
                        Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, param["ORDERID"], null, 0, JsonConvert.SerializeObject(param), 2, "支付配置不存在");
                        return;
                    }
                    #region 需要进行验签
                    Dictionary <string, string> tempDic = new Dictionary <string, string>(param);
                    tempDic.Remove("SIGN");
                    string initStr = "";
                    foreach (var item in tempDic)
                    {
                        initStr += string.Format("{0}={1}&", item.Key, item.Value);
                    }
                    initStr = initStr.Trim('&');
                    string sign   = param["SIGN"];
                    string pubKey = Convert.ToString(PayConfig.Pub);
                    if (!Business.HKCCBPay.VerifySign(initStr, sign, pubKey))
                    {
                        PubInfo.GetLog().Info("鸿坤建行收款通知内容:签名校验失败");
                        return;
                    }
                    #endregion
                    // 获取小区信息
                    Tb_Community tb_Community = PubInfo.GetCommunity(Convert.ToString(PayConfig.CommunityId));
                    if (null == tb_Community)
                    {
                        PubInfo.GetLog().Info("鸿坤建行收款通知内容:小区配置不存在");
                        Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, param["ORDERID"], null, 0, JsonConvert.SerializeObject(param), 2, "小区配置不存在");
                        return;
                    }
                    decimal SAmt = Convert.ToDecimal(param["PAYMENT"]);
                    // 判断金额是否一致
                    if (Convert.ToDecimal(OrderInfo.Amt) != SAmt)
                    {
                        PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:账单金额与实收金额不一致(SAmt={0})", SAmt);
                        Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, param["ORDERID"], null, 0, JsonConvert.SerializeObject(param), 2, "账单金额与实收金额不一致");
                        return;
                    }

                    string erpConnStr = PubInfo.GetConnectionStr(tb_Community);

                    JObject PayData = JsonConvert.DeserializeObject <JObject>(Convert.ToString(OrderInfo.PayData));

                    int Type = (int)PayData["Type"];
                    if (Type == 1)
                    {
                        JArray Data = (JArray)PayData["Data"];
                        if (null == Data || Data.Count == 0)
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, param["ORDERID"], DateNow.ToString(), SAmt, JsonConvert.SerializeObject(param), 2, "下账失败(订单支付信息有误)");
                            return;
                        }
                        StringBuilder FeesIds = new StringBuilder();
                        foreach (JObject item in Data)
                        {
                            FeesIds.Append((string)item["FeesId"] + ",");
                        }
                        if (PubInfo.ReceFees(erpConnStr, out long ReceID, Convert.ToString(tb_Community.CommID), Convert.ToString(OrderInfo.CustID), Convert.ToString(OrderInfo.RoomID), FeesIds.ToString(), 0.00M, "自助缴费-微信"))
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账成功(PayData={0})", OrderInfo.PayData);

                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, param["ORDERID"], DateNow.ToString().ToString(), SAmt, JsonConvert.SerializeObject(param), 3, "下账成功");
                            return;
                        }
                        else
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, param["ORDERID"], DateNow.ToString().ToString(), SAmt, JsonConvert.SerializeObject(param), 4, "下账失败");
                            return;
                        }
                    }
                    else if (Type == 2)
                    {
                        JObject Data = (JObject)PayData["Data"];
                        if (null == Data)
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, param["ORDERID"], DateNow.ToString(), SAmt, JsonConvert.SerializeObject(param), 2, "支付金额必须大于0");
                            return;
                        }
                        string CostID = (string)Data["CostID"];

                        decimal Amt = (Decimal)Data["Amt"];
                        if (PubInfo.RecePreFees(erpConnStr, out long ReceID, Convert.ToString(tb_Community.CommID), Convert.ToString(OrderInfo.CustID), Convert.ToString(OrderInfo.RoomID), CostID, Amt, "自助缴费-微信"))
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账成功(PayData={0})", OrderInfo.PayData);
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, param["ORDERID"], DateNow.ToString(), SAmt, JsonConvert.SerializeObject(param), 3, "下账成功");
                            return;
                        }
                        else
                        {
                            PubInfo.GetLog().InfoFormat("鸿坤建行收款通知内容:下账失败(订单支付信息有误)(PayData={0})", OrderInfo.PayData);
                            Business.HKCCBPay.UpdateOrderInfo(PubConstant.UnifiedContionString, param["ORDERID"], DateNow.ToString(), SAmt, JsonConvert.SerializeObject(param), 4, "下账失败");
                            return;
                        }
                    }
        public string GenerateOrder(DataRow row)
        {
            #region 获取基本参数
            string CommunityId = string.Empty;
            if (row.Table.Columns.Contains("CommunityId"))
            {
                CommunityId = row["CommunityId"].ToString();
            }
            string RoomID = string.Empty;
            if (row.Table.Columns.Contains("RoomID"))
            {
                RoomID = row["RoomID"].ToString();
            }
            string CustID = string.Empty;
            if (row.Table.Columns.Contains("CustID"))
            {
                CustID = row["CustID"].ToString();
            }
            if (!row.Table.Columns.Contains("PayChannel") || string.IsNullOrEmpty(row["PayChannel"].ToString()))
            {
                return(new ApiResult(false, "参数PayChannel有误").toJson());
            }

            var payChannel = row["PayChannel"].ToString();
            var payType    = 0;
            if (payChannel.ToLower() == "allinpay_alipay")
            {
                payChannel = "A03";
                payType    = 1;
            }
            else if (payChannel.ToLower() == "allinpay_wechatpay")
            {
                payChannel = "W06";
                payType    = 2;
            }
            else
            {
                return(new ApiResult(false, "参数PayChannel有误").toJson());
            }

            #endregion

            var community = PubInfo.GetCommunity(CommunityId);
            if (community == null)
            {
                return(JSONHelper.FromString(false, "未查询到小区信息"));
            }

            int CommID = AppGlobal.StrToInt(community.CommID);
            PubConstant.hmWyglConnectionString = PubInfo.GetConnectionStr(community);

            // 获取对应支付配置
            AllinConfig allinConfig;
            using (IDbConnection erpConn = new SqlConnection(PubConstant.hmWyglConnectionString))
            {
                dynamic tb_Payment_Config = erpConn.QueryFirstOrDefault <dynamic>("SELECT * FROM Tb_Payment_Config WITH(NOLOCK) WHERE CommID = @CommID", new { CommID });
                if (null == tb_Payment_Config)
                {
                    return(new ApiResult(false, "该项目未开通对应支付方式").toJson());
                }
                try
                {
                    allinConfig = JsonConvert.DeserializeObject <AllinConfig>(tb_Payment_Config.Config);
                    if (null == allinConfig)
                    {
                        return(new ApiResult(false, "该项目支付类型对应配置有误").toJson());
                    }
                }
                catch (Exception)
                {
                    return(new ApiResult(false, "该项目支付类型对应配置有误").toJson());
                }

                #region 计算金额
                if (!row.Table.Columns.Contains("PayData") || string.IsNullOrEmpty(row["PayData"].ToString()))
                {
                    return(new ApiResult(false, "缺少参数PayData").toJson());
                }
                string PayData = row["PayData"].ToString();
                if (!PubInfo.CheckPayData(Global_Fun.BurstConnectionString(CommID, Global_Fun.BURST_TYPE_CHARGE), Convert.ToInt64(CustID), Convert.ToInt64(RoomID), PayData, out decimal Amt, out string errMsg, true, false, !"1940".Equals(Global_Var.LoginCorpID)))
                {
                    return(new ApiResult(false, errMsg).toJson());
                }
                if (Amt <= 0.00M)
                {
                    return(new ApiResult(false, "金额必须大于0").toJson());
                }
                #endregion

                JObject PayDataObj = JObject.Parse(PayData);
                int     Type       = (int)PayDataObj["Type"];

                #region 查询项目名称和房屋编号,拼接费用备注
                string FeesMemo = string.Empty;
                string RoomSign = string.Empty;
                if (Type == 1)
                {
                    FeesMemo = "物业综合费用缴纳";
                    string CommName = erpConn.QueryFirstOrDefault <string>("SELECT CommName FROM Tb_HSPR_Community WHERE CommID = @CommID", new { CommID });
                    if (string.IsNullOrEmpty(CommName))
                    {
                        CommName = Convert.ToString(CommID);
                    }
                    RoomSign = erpConn.QueryFirstOrDefault <string>("SELECT ISNULL(RoomSign,RoomName) AS RoomSign FROM Tb_HSPR_Room WHERE RoomID = @RoomID", new { RoomID });
                    if (string.IsNullOrEmpty(RoomSign))
                    {
                        RoomSign = Convert.ToString(RoomID);
                    }

                    FeesMemo += string.Format("-{0}-{1}", CommName, RoomSign);
                }
                else
                {
                    FeesMemo = "物业综合费用预存";
                    string CommName = erpConn.QueryFirstOrDefault <string>("SELECT CommName FROM Tb_HSPR_Community WHERE CommID = @CommID", new { CommID });
                    if (string.IsNullOrEmpty(CommName))
                    {
                        CommName = Convert.ToString(CommID);
                    }
                    RoomSign = erpConn.QueryFirstOrDefault <string>("SELECT ISNULL(RoomSign,RoomName) AS RoomSign FROM Tb_HSPR_Room WHERE RoomID = @RoomID", new { RoomID });
                    if (string.IsNullOrEmpty(RoomSign))
                    {
                        RoomSign = Convert.ToString(RoomID);
                    }

                    FeesMemo += string.Format("-{0}-{1}", CommName, RoomSign);
                }
                #endregion

                string NoticeId = Guid.NewGuid().ToString();

                // 生成订单
                if (erpConn.Execute("INSERT INTO Tb_Notice(Id, CommID, RoomID, CustID, PayData, CreateTime) VALUES(@Id, @CommID, @RoomID, @CustID, @PayData, @CreateTime)", new { Id = NoticeId, CommID, RoomID, CustID, PayData, CreateTime = DateTime.Now.ToString() }) <= 0)
                {
                    return(new ApiResult(false, "创建收款订单失败,请重试").toJson());
                }
                string ChargeMode = "业主APP缴费";
                #region 修改收款方式
                if (erpConn.QueryFirstOrDefault <int>("SELECT COUNT(1) FROM syscolumns WHERE id=object_id('Tb_Notice') AND name = 'ChargeMode'") > 0)
                {
                    erpConn.Execute("UPDATE Tb_Notice SET ChargeMode = @ChargeMode WHERE Id = @Id", new { ChargeMode, Id = NoticeId });
                }
                #endregion
                #region 请求通联微信支付
                DateTime dateNow = DateTime.Now;
                string   OrderSN = dateNow.ToString("yyyyMMddHHmmssfff") + Utils.BuildRandomStr(3);

                #region 获取对应类型的下账地址
                string PaymentNotifyUrl = string.Empty;
                if (Type == 1)
                {
                    PaymentNotifyUrl = AppGlobal.GetAppSetting("AllinPay_Notify_Url") + "?CommID=" + CommID;
                }
                else
                {
                    PaymentNotifyUrl = AppGlobal.GetAppSetting("AllinPay_Prec_Notify_Url") + "?CommID=" + CommID;
                }
                #endregion

                Dictionary <string, string> param;
                try
                {
                    param = SybWxPayService.Pay(Convert.ToInt64(Amt * 100), OrderSN, payChannel, FeesMemo, RoomSign, "", "", PaymentNotifyUrl, "", "", "", "", allinConfig.orgid, allinConfig.appid, allinConfig.custid, allinConfig.appkey, allinConfig.subbranch);

                    if (param == null)
                    {
                        return(new ApiResult(false, "生成支付订单失败,请重试").toJson());
                    }
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(new ApiResult(false, "生成支付订单失败,请重试").toJson());
                }
                #endregion
                if (erpConn.Execute(@"INSERT INTO Tb_Payment_Order(PayType, OrderSN, NoticeId, Amt, CreateTime) 
                                            VALUES(@PayType, @OrderSN, @NoticeId, @Amt, @CreateTime)",
                                    new { PayType = payType, OrderSN = OrderSN, NoticeId = NoticeId, Amt = Amt, CreateTime = dateNow }) <= 0)
                {
                    return(new ApiResult(false, "生成支付订单失败,请重试(1003)").toJson());
                }
                return(new ApiResult(true, new { OrderSN = OrderSN, QrCode = param["payinfo"].ToString() }).toJson());
            }
        }