Exemple #1
0
        /// <summary>
        /// 无效投资标的处理
        /// </summary>
        /// <param name="investor_registerid">投资用户id</param>
        /// <param name="bid_records_id">投资记录id</param>
        /// <param name="OrdId">投资订单号</param>
        /// <param name="OrdDate">投资订单日期</param>
        /// <param name="UsrCustId">客户号</param>
        /// <param name="FreezeOrdId">冻结订单号</param>
        /// <param name="TransAmt">交易金额</param>
        /// <param name="FreezeTrxId">冻结唯一标识</param>
        /// <param name="MerPriv">优惠券字符串</param>
        /// <param name="QueryTransType">查询类型   LOANS:放款交易查询 REPAYMENT:还款交易查询 TENDER:投标交易查询 CASH:取现交易查询     FREEZE:冻结解冻交易查询     </param>
        public void setRecords_Lost(string investor_registerid, string bid_records_id, string OrdId, string OrdDate, string UsrCustId, string FreezeOrdId, string TransAmt, string FreezeTrxId, string MerPriv, string QueryTransType = "TENDER")
        {
            TransStat ts = new TransStat();
            bool      d  = ts.checktrans(OrdId, OrdDate, QueryTransType);

            if (d == false)
            {
                string sql = "update hx_UserAct set UseState=0,AmtProid=0 where UseState=3 and AmtProid=" + bid_records_id + "and registerid=" + investor_registerid;
                DbHelperSQL.RunSql(sql);
                sql = "delete hx_Bid_records where OrdId ='" + OrdId + "' and ordstate=0 and bid_records_id=" + bid_records_id;
                DbHelperSQL.RunSql(sql);
            }
            else
            {//TODO 此处有bug,自动查询的更新冻结表时缺少 FreezeTrxId 值,放款时没有该值会报错。 考虑注释该逻辑,等待汇付异步回调????
                B_usercenter BUC = new B_usercenter();
                //取得投标记录使用的优惠券
                string AmtProid = BUC.GetBid_AmtProid(int.Parse(bid_records_id));
                int    de       = BUC.ReInvest_success(UsrCustId, FreezeOrdId, TransAmt, FreezeTrxId, OrdId, AmtProid);
                if (de > 0)
                {
                    string    sql = "select targetid,bid_records_id, borrowing_title,investor_registerid ,username,mobile,invitationcode,investment_amount,life_of_loan,unit_day,borrowing_balance,bonusAmt  from  V_hx_Bid_records_borrowing_target where OrdId='" + OrdId + "'";
                    DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);
                    if (dt.Rows.Count > 0)
                    {
                        decimal investAmt  = decimal.Parse(dt.Rows[0]["investment_amount"].ToString());
                        int     registerid = int.Parse(dt.Rows[0]["investor_registerid"].ToString());
                        string  targetid   = dt.Rows[0]["targetid"].ToString();

                        #region 待提取为公共方法
                        #region MyRegion  系统消息
                        DateTime            dti = DateTime.Now;
                        M_td_System_message pm  = new M_td_System_message();
                        pm.MReg     = registerid;
                        pm.Mstate   = 0;
                        pm.MTitle   = "投资成功";
                        pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + investAmt + "。如有问题可咨询创利投的客服!谢谢!";
                        pm.PubTime  = dti;
                        pm.Mtype    = 1;
                        B_usercenter.AddMessage(pm);
                        #endregion

                        #region MyRegion                                        //短信通知
                        string        contxt = Utils.GetMSMEmailContext(15, 1); // 获取注册成功邮件内容
                        StringBuilder sbsms  = new StringBuilder(contxt);
                        sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString());
                        sbsms = sbsms.Replace("#PID#", targetid);
                        sbsms = sbsms.Replace("#MONEY#", investAmt.ToString());
                        string          mobile  = dt.Rows[0]["mobile"].ToString();
                        M_td_SMS_record psms    = new M_td_SMS_record();
                        B_td_SMS_record osms    = new B_td_SMS_record();
                        int             smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资成功.ToString());
                        psms.phone_number = mobile;
                        psms.sendtime     = DateTime.Now;
                        psms.senduserid   = registerid;
                        psms.smstype      = smstype;
                        psms.smscontext   = sbsms.ToString();
                        psms.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                        psms.vcode        = "";
                        osms.Add(psms);
                        #endregion

                        #region 远程调用生成合同??? 稍后替换为本地方法调用  微信端可远程调用
                        string postString = "action=MUserPDF&data=" + targetid.ToString() + "&uc=" + registerid.ToString() + "&OrdId=" + OrdId;
                        string sr         = Utils.PostWebRequest(Utils.GetRemote_url("pdf/index"), postString, Encoding.UTF8);
                        #endregion

                        #region  道合作 第一投标调用接口???
                        B_member_table bmt = new B_member_table();
                        M_member_table mmt = new M_member_table();
                        mmt = bmt.GetModel(registerid);
                        if (mmt.Tid != null && mmt.Channelsource == 1)
                        {
                            if (B_usercenter.GetInvestCountByUserid(mmt.registerid) == 1)
                            {
                                string ret3 = Utils.GetCoopAPI(mmt.Tid, investAmt.ToString("0.00"), 2);
                                LogInfo.WriteLog("前台渠道合作第一次返回结果:" + ret3 + "  用户id:" + mmt.registerid + " 订单id " + OrdId);
                            }
                        }
                        #endregion
                        #endregion 待提取为公共方法

                        //发放奖励
                        ActFacade act = new ActFacade();
                        act.SendBonusAfterInvest(dt, EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.web);
                    }
                }
            }
        }