|
|
@@ -28,6 +28,7 @@ using NHibernate.Mapping;
|
|
|
using System.Reflection.Emit;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using System.Security.Cryptography;
|
|
|
+using NHibernate.Hql.Ast;
|
|
|
|
|
|
namespace SiteCore
|
|
|
{
|
|
|
@@ -2937,5 +2938,104 @@ namespace SiteCore
|
|
|
}
|
|
|
return price;
|
|
|
}
|
|
|
+
|
|
|
+ public static bool loginGetOrder(int userId)
|
|
|
+ {
|
|
|
+ DataTable dt = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ dt = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where ID = {0}", userId)).Tables[0];
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ if (dt == null || dt.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ DataRow dr = dt.Rows[0];
|
|
|
+ int isOpen = Convert.ToInt32(dr["isOpen"]);
|
|
|
+ int dayOrderReceive = Convert.ToInt32(dr["DayOrderReceive"]);//已经派了多少
|
|
|
+ int dayOrderLimit = Convert.ToInt32(dr["DayOrderLimit"]);//总的能派多少
|
|
|
+ int orderAmountLimit = Convert.ToInt32(dr["OrderAmountLimit"]);//能派的金额多少
|
|
|
+ int oldOrder = Convert.ToInt32(dr["OldOrder"]);//能派的金额多少
|
|
|
+ string orgShop = dr["OrgShop"].ToString();
|
|
|
+ string pemShop = dr["pemShop"].ToString();
|
|
|
+ string pemDesign = dr["pemDesign"].ToString();
|
|
|
+
|
|
|
+ if (isOpen == 0)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(orgShop) || string.IsNullOrEmpty(pemShop) || string.IsNullOrEmpty(pemDesign))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ string normolSql = string.Format("and payment <={0} and shopid in ({1}) and shopid in ({2}) and ProductId in ({3})", orderAmountLimit, orgShop, pemShop, pemDesign);
|
|
|
+ string orderSql = string.Format("select tid,ctid,IsOldCustomer,shopid,payment,ProductId from view_ErpTradeCell where orderstate=2 and productid<>0 and designuserid=0 and payment>0 and isrefund=0 and isDianziOrder = 0 {0} order by IsUrgency DESC, YEAR ( pay_time ), MONTH ( pay_time ), DAY ( pay_time ), payment DESC;", normolSql);
|
|
|
+ DataTable dataTable = DbHelper.DbConn.ExecuteDataset(orderSql).Tables[0];
|
|
|
+ if (dataTable == null || dataTable.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ designApiResponseVo result = null;
|
|
|
+ List<string> list = new List<string>();
|
|
|
+ foreach (DataRow row in dataTable.Rows)
|
|
|
+ {
|
|
|
+ if (dayOrderReceive >= dayOrderLimit)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ string IsOldCustomer = dr["IsOldCustomer"].ToString();
|
|
|
+ int ProductId = Convert.ToInt32(dr["ProductId"]);
|
|
|
+ CeErpShop ceErpShop = CeErpShop.Get(dr["shopid"]);
|
|
|
+ int shopUserId = 0;
|
|
|
+ if (ceErpShop != null)
|
|
|
+ {
|
|
|
+ shopUserId = ceErpShop.UserID;
|
|
|
+ }
|
|
|
+ bool isIn = false;
|
|
|
+ if ((IsOldCustomer == "1" && shopUserId == 241) || (shopUserId == 241 && Convert.ToDouble(dr["payment"]) >= 500))
|
|
|
+ {
|
|
|
+ if (oldOrder == 1)
|
|
|
+ {
|
|
|
+ //手绘 logo 画册 海报 宣传单
|
|
|
+ if ((IsOldCustomer == "1" && (ProductId == 28 || ProductId == 57 || ProductId == 40 || ProductId == 4 || ProductId == 13)))
|
|
|
+ {
|
|
|
+ result = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
|
|
|
+ if (result != null && result.code == 200)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ isIn = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (oldOrder == 0)
|
|
|
+ {
|
|
|
+ if (shopUserId != 82)
|
|
|
+ {
|
|
|
+ result = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
|
|
|
+ if (result != null && result.code == 200)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ isIn = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isIn)
|
|
|
+ {
|
|
|
+ DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where tid={0} and OrderState=2 and DesignUserId=0 ;", dr["tid"].ToString(), (int)OrderState.下单完成, userId, "3自动派单" + userId));
|
|
|
+ int rowCount = DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=3,IsAutoDispatch=1,WaitDesignTime=getdate(),UpdateTime=getdate(),DesignUserId={0},DispatchSort=0 where tid={1} and OrderState=2 and DesignUserId=0", userId, dr["tid"].ToString()));
|
|
|
+ dayOrderReceive += rowCount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|