Esempio n. 1
0
    private void SendPeiHuoRemind()  //配货人员提醒
    {
        BLL.WxBLL wbll        = new BLL.WxBLL();
        string    DingDanId   = ReStr("DingDanId", "");
        DataTable dtUser      = ReTable("UserList");
        string    SendMemo    = ReStr("SendMemo", "");
        decimal   QyWxPtAppId = ReDecimal("QyWxPtAppId", 0);


        StringBuilder w          = new StringBuilder();
        StringBuilder s          = new StringBuilder();
        List <string> ToUserList = new List <string>();

        #region 事务开启

        TransactionOptions transactionOption = new TransactionOptions();
        transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
        using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOption))
        {
            #endregion

            BLL.MerchantBLL mbll = new BLL.MerchantBLL();
            mbll.ShenHeDingdan(DingDanId, 1, "通过审核");
            s.Append("SELECT * FROM dbo.DingDanDetailView WITH(NOLOCK) WHERE DingDanId='" + DingDanId + "' ORDER BY DingDanDetailTypeId ");
            s.Append(" SELECT *  FROM dbo.DingDanView  WITH(NOLOCK) WHERE DingDanId='" + DingDanId + "' ");

            DataSet   ds       = DAL.DalComm.BackData(s.ToString());
            DataTable dtDetail = ds.Tables[0];
            DataTable dtInfo   = ds.Tables[1];
            if (dtInfo.Rows.Count != 1)
            {
                throw new Exception("这是个什么订单?");
            }
            DataRow  drInfo       = dtInfo.Rows[0];
            decimal  MerId        = decimal.Parse(drInfo["MerchantId"].ToString());
            decimal  amount       = decimal.Parse(drInfo["Amount"].ToString());
            DateTime PeiSongTime1 = DateTime.Parse(drInfo["PeiSongTime1"].ToString());
            DateTime PeiSongTime2 = DateTime.Parse(drInfo["PeiSongTime2"].ToString());
            amount = Math.Round(amount, 2);
            w.Append("编号:\n " + DingDanId + " \n");

            if (SendMemo.Trim() != "")
            {
                w.Append("调度备注:" + SendMemo + " \n");
            }

            w.Append("总金额:" + amount + " \n");
            w.Append("物流:" + PeiSongTime1.ToString("yy年MM月dd日 hh时mm分") + "-" + PeiSongTime2.ToString("yy年MM月dd日 hh时mm分") + "");
            w.Append("(" + drInfo["PeiSongTypeName"] + ") \n");
            var url = "http://www.sjdfcs.com/App/AppDingDanList_PeiHuo.aspx?DingDanId=" + DingDanId + "";

            w.Append("<a href='" + wbll.QyWxUrl(url, MerId) + "' >查看详细</a> \n");
            if (dtDetail.Rows.Count == 0)
            {
                throw new Exception("这个订单[" + DingDanId + "]没有明细吗?");
            }
            s.Clear();
            foreach (DataRow drUser in dtUser.Rows)
            {
                ToUserList.Add(drUser["QyWxPtUserId"].ToString());
                s.Append(" UPDATE dbo.DingDanInfo SET PeiHuoUserId='" + drUser["UserId"].ToString() + "',Status=20 WHERE DingDanId='" + DingDanId + "' ");
            }
            DAL.DalComm.ExReInt(s.ToString());



            #region 暂时无用

            //foreach (DataRow drDetail in dtDetail.Rows)
            //{


            //    decimal Price = decimal.Parse(drDetail["Price"].ToString());
            //    Price = Math.Round(Price, 2);
            //    decimal Quantity = decimal.Parse(drDetail["Quantity"].ToString());
            //    Quantity = Math.Round(Quantity);

            //    string 规格 = drDetail["规格"].ToString().Trim();

            //    int DingDanDetailTypeId = int.Parse(drDetail["DingDanDetailTypeId"].ToString());
            //    if (DingDanDetailTypeId == 10)
            //    {

            //        w.Append("配送费:" + Price + "元 \n");

            //    }
            //    else
            //    {


            //        //如果是产品
            //        w.Append("[" + drDetail["产品编号"] + "]");
            //        w.Append("" + drDetail["产品名称"] + ",");
            //        if (规格 != "")
            //        {
            //            w.Append("规格:" + drDetail["规格"] + ",");

            //        }

            //        w.Append("单价:" + Price + "元,");
            //        w.Append("数量:" + Quantity + "" + drDetail["计量单位"] + "");
            //        w.Append(" \n ");
            //    }
            //}
            #endregion



            #region 事务关闭

            transactionScope.Complete();
        }
        #endregion
        string jsonStr = wbll.SendQyTextMsg(ToUserList, w.ToString(), QyWxPtAppId);

        ReDict.Add("ReJson", jsonStr);
        ReTrue();
    }