|
|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data;
- /// <summary>
- /// 网站配置
- /// </summary>
-
- namespace Basic.BLL
- {
- public class order
- {
-
- public static int GetPayNum(string orderid)
- {
- int Num = 0;
- Basic.DAL.order dalo = new Basic.DAL.order();
- Basic.Model.order modelo = dalo.GetModel(orderid);
- if (modelo != null)
- {
- modelo.paynum++;
- dalo.Update(modelo);
- Num = modelo.paynum;
- }
- return Num;
- }
-
- public static void assetOrder(string orderid, string paytype)
- {
-
- if (orderid.IndexOf("_") != (-1))
- {
- orderid = orderid.Split('_')[0];
- }
-
- try
- {
- Basic.DAL.order dalo = new Basic.DAL.order();
- Basic.Model.order modelo = dalo.GetModel(orderid);
- DateTime dtPay = DateTime.Now;
- if (modelo != null)
- {
- #region 将订单状态标记为已结算
- modelo.paystate = 1;
- modelo.zhifutype = paytype;
- modelo.paydate =dtPay.ToString("yyyy-MM-dd HH:mm:ss") ;
-
- #endregion
-
- #region 将订单的商品库存减少
- Basic.DAL.orderdetail dalod = new Basic.DAL.orderdetail();
- DataTable dstOd = dalod.GetList(0, " orderid='" + orderid + "' ", " id desc").Tables[0];
-
-
- string strProInfo = "";
-
-
-
- for (int i = 0; i < dstOd.Rows.Count; i++)
- {
- //if (i < 3)
- //{
- // strProInfo += dstOd.Rows[i]["product_name"].ToString() + dstOd.Rows[i]["attribute"].ToString() + " ,";
- //}
- int count = Convert.ToInt32(dstOd.Rows[i]["count"].ToString());
- int proid = Convert.ToInt32(dstOd.Rows[i]["product_id"].ToString());
- Basic.DAL.product dalp = new Basic.DAL.product();
- Basic.Model.product modelp = dalp.GetModel(proid);
- modelp.kucun -= count;
- #region 不同的款式也要精确一下,去扣相应的库存
- string strAttri = dstOd.Rows[i]["attribute_id"].ToString();
- if (!(strAttri == "" || strAttri == "0,"))
- {
- Basic.DAL.product_attribute_value dalpav = new Basic.DAL.product_attribute_value();
- Basic.Model.product_attribute_value modelpav = dalpav.GetModel(proid, ("-" + strAttri.Replace(",", "-") + "-"));
- if (modelpav != null)
- {
- modelpav.count -= count;
- dalpav.Update(modelpav);
- string[] ArrayProAttr = modelp.attribute_content.Split('|');
- string strAttrContent = "";
- for (int m = 0; m < ArrayProAttr.Length - 1; m++)
- {
- string strAttrId = ArrayProAttr[m].Split(',')[0];
- string strAttrCount = ArrayProAttr[m].Split(',')[1];
- if (strAttrId == dstOd.Rows[i]["attribute_id"].ToString().Replace(",", "-") + "_0")
- {
- int intAttrCount = Convert.ToInt32(strAttrCount) - count;
- strAttrContent += strAttrId + "," + intAttrCount.ToString() + "|";
- }
- else
- {
- strAttrContent += ArrayProAttr[m] + "|";
- }
- }
- if (ArrayProAttr.Length > 1)
- {
- modelp.attribute_content = strAttrContent;
- }
- }
- }
- //销量增加
- modelp.sales += count;
- dalp.Update(modelp);
- #endregion
- }
- strProInfo = dstOd.Rows.Count + "件";
- //strProInfo = strProInfo.Trim(',');
- //if (dstOd.Rows.Count > 3)
- //{
- // strProInfo += "等";
- //}
- //发信息给管理员通知他付款了。
- //wxutil.WX_Util.log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "_即将发短信:" + strProInfo + "__" + orderid + "<br/>");
-
- if (modelo.smsstatus == "" || modelo.smsstatus==null) { modelo.smsstatus = "|"; }
-
-
- if (modelo.smsstatus.IndexOf("|pay|") == (-1))
- {
- //通知管理员
- if (Basic.Tools.SendSms.SendPayTz(orderid, strProInfo, modelo.price.ToString(), modelo.userid, paytype, dtPay) == "发送成功")
- {
- modelo.smsstatus += "pay|";
- }
- }
- if (modelo.smsstatus.IndexOf("|pay2|") == (-1))
- {
- //通知会员
- if (Basic.Tools.SendSms.SendPayTz2(orderid, strProInfo, modelo.price.ToString(), modelo.userid, paytype, dtPay) == "发送成功")
- {
- modelo.smsstatus += "pay2|";
- }
- }
-
- dalo.Update(modelo);
-
- #endregion
- }
- }
- catch (Exception ex)
- {
- wxutil.WX_Util.log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "_error:" + ex.Message.ToString() + " ex.StackTrace:" + ex.StackTrace + "<br/>");
- }
- }
- }
- }
|