Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

147 linhas
6.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data;
  6. /// <summary>
  7. /// 网站配置
  8. /// </summary>
  9. namespace Basic.BLL
  10. {
  11. public class order
  12. {
  13. public static int GetPayNum(string orderid)
  14. {
  15. int Num = 0;
  16. Basic.DAL.order dalo = new Basic.DAL.order();
  17. Basic.Model.order modelo = dalo.GetModel(orderid);
  18. if (modelo != null)
  19. {
  20. modelo.paynum++;
  21. dalo.Update(modelo);
  22. Num = modelo.paynum;
  23. }
  24. return Num;
  25. }
  26. public static void assetOrder(string orderid, string paytype)
  27. {
  28. if (orderid.IndexOf("_") != (-1))
  29. {
  30. orderid = orderid.Split('_')[0];
  31. }
  32. try
  33. {
  34. Basic.DAL.order dalo = new Basic.DAL.order();
  35. Basic.Model.order modelo = dalo.GetModel(orderid);
  36. DateTime dtPay = DateTime.Now;
  37. if (modelo != null)
  38. {
  39. #region 将订单状态标记为已结算
  40. modelo.paystate = 1;
  41. modelo.zhifutype = paytype;
  42. modelo.paydate =dtPay.ToString("yyyy-MM-dd HH:mm:ss") ;
  43. #endregion
  44. #region 将订单的商品库存减少
  45. Basic.DAL.orderdetail dalod = new Basic.DAL.orderdetail();
  46. DataTable dstOd = dalod.GetList(0, " orderid='" + orderid + "' ", " id desc").Tables[0];
  47. string strProInfo = "";
  48. for (int i = 0; i < dstOd.Rows.Count; i++)
  49. {
  50. //if (i < 3)
  51. //{
  52. // strProInfo += dstOd.Rows[i]["product_name"].ToString() + dstOd.Rows[i]["attribute"].ToString() + " ,";
  53. //}
  54. int count = Convert.ToInt32(dstOd.Rows[i]["count"].ToString());
  55. int proid = Convert.ToInt32(dstOd.Rows[i]["product_id"].ToString());
  56. Basic.DAL.product dalp = new Basic.DAL.product();
  57. Basic.Model.product modelp = dalp.GetModel(proid);
  58. modelp.kucun -= count;
  59. #region 不同的款式也要精确一下,去扣相应的库存
  60. string strAttri = dstOd.Rows[i]["attribute_id"].ToString();
  61. if (!(strAttri == "" || strAttri == "0,"))
  62. {
  63. Basic.DAL.product_attribute_value dalpav = new Basic.DAL.product_attribute_value();
  64. Basic.Model.product_attribute_value modelpav = dalpav.GetModel(proid, ("-" + strAttri.Replace(",", "-") + "-"));
  65. if (modelpav != null)
  66. {
  67. modelpav.count -= count;
  68. dalpav.Update(modelpav);
  69. string[] ArrayProAttr = modelp.attribute_content.Split('|');
  70. string strAttrContent = "";
  71. for (int m = 0; m < ArrayProAttr.Length - 1; m++)
  72. {
  73. string strAttrId = ArrayProAttr[m].Split(',')[0];
  74. string strAttrCount = ArrayProAttr[m].Split(',')[1];
  75. if (strAttrId == dstOd.Rows[i]["attribute_id"].ToString().Replace(",", "-") + "_0")
  76. {
  77. int intAttrCount = Convert.ToInt32(strAttrCount) - count;
  78. strAttrContent += strAttrId + "," + intAttrCount.ToString() + "|";
  79. }
  80. else
  81. {
  82. strAttrContent += ArrayProAttr[m] + "|";
  83. }
  84. }
  85. if (ArrayProAttr.Length > 1)
  86. {
  87. modelp.attribute_content = strAttrContent;
  88. }
  89. }
  90. }
  91. //销量增加
  92. modelp.sales += count;
  93. dalp.Update(modelp);
  94. #endregion
  95. }
  96. strProInfo = dstOd.Rows.Count + "件";
  97. //strProInfo = strProInfo.Trim(',');
  98. //if (dstOd.Rows.Count > 3)
  99. //{
  100. // strProInfo += "等";
  101. //}
  102. //发信息给管理员通知他付款了。
  103. //wxutil.WX_Util.log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "_即将发短信:" + strProInfo + "__" + orderid + "<br/>");
  104. if (modelo.smsstatus == "" || modelo.smsstatus==null) { modelo.smsstatus = "|"; }
  105. if (modelo.smsstatus.IndexOf("|pay|") == (-1))
  106. {
  107. //通知管理员
  108. if (Basic.Tools.SendSms.SendPayTz(orderid, strProInfo, modelo.price.ToString(), modelo.userid, paytype, dtPay) == "发送成功")
  109. {
  110. modelo.smsstatus += "pay|";
  111. }
  112. }
  113. if (modelo.smsstatus.IndexOf("|pay2|") == (-1))
  114. {
  115. //通知会员
  116. if (Basic.Tools.SendSms.SendPayTz2(orderid, strProInfo, modelo.price.ToString(), modelo.userid, paytype, dtPay) == "发送成功")
  117. {
  118. modelo.smsstatus += "pay2|";
  119. }
  120. }
  121. dalo.Update(modelo);
  122. #endregion
  123. }
  124. }
  125. catch (Exception ex)
  126. {
  127. wxutil.WX_Util.log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "_error:" + ex.Message.ToString() + " ex.StackTrace:" + ex.StackTrace + "<br/>");
  128. }
  129. }
  130. }
  131. }