using System; using System.Collections.Generic; using System.Data; using System.Data.OracleClient; using WX.CRM.Common; using WX.CRM.Model.MAP; namespace WX.CRM.DAL.Wx { public class WX_COMMISSION_DAL { /// /// 检查分成是否正确 /// /// public string CheckCommission() { string ret; try { OracleParameter[] p = { new OracleParameter("v_ret", OracleType.VarChar) }; p[0].Size = 4000; p[0].Direction = ParameterDirection.ReturnValue; OracleHelper.ExecuteNonQuery(CommandType.StoredProcedure, "PACK_WX_REPORT.CheckCommission", p); ret = p[0].Value.ToString(); } catch (Exception ex) { LogHelper.Error("CheckCommission:" + ex.ToString()); throw; } return ret; } /// /// 分成结算 /// /// /// /// /// public string SaleUserCommissionBalance(DateTime month, decimal pOperator, string remark) { string ret; try { var p = new List() { new OracleParameter() { ParameterName = "p_month", OracleType = OracleType.DateTime, Value =month }, new OracleParameter() { ParameterName = "p_operator", OracleType = OracleType.Number, Value =pOperator }, string.IsNullOrEmpty(remark) ? new OracleParameter() { ParameterName = "p_remark", OracleType = OracleType.VarChar, Value = DBNull.Value } : new OracleParameter() { ParameterName = "p_remark", OracleType = OracleType.VarChar, Value =remark }, new OracleParameter() { ParameterName = "p_data", OracleType=OracleType.Cursor,Direction = ParameterDirection.Output } }; var ds = OracleHelper.DataQueray(CommandType.StoredProcedure, "PACK_WX_REPORT.SaleUserCommissionBalance", p.ToArray()); ret = ds.Tables[0].Rows[0][0].ToString(); } catch (Exception ex) { LogHelper.Error("SaleUserCommissionBalance:" + ex.ToString()); throw; } return ret; } /// /// 撤销结算 /// /// /// public void SaleUserCommissionUnBalance(DateTime month, decimal pOperator) { try { var p = new List() { new OracleParameter() { ParameterName = "p_month", OracleType = OracleType.DateTime, Value =month }, new OracleParameter() { ParameterName = "p_operator", OracleType = OracleType.Number, Value =pOperator } }; OracleHelper.ExecuteNonQuery(CommandType.StoredProcedure, "PACK_WX_REPORT.SaleUserCommissionUnBalance", p.ToArray()); } catch (Exception ex) { LogHelper.Error("SaleUserCommissionUnBalance:" + ex.ToString()); throw; } } /// /// 结算报表 /// /// /// public DataSet CommissionBalanceReport(DateTime month) { try { var p = new List() { new OracleParameter() { ParameterName = "p_month", OracleType = OracleType.DateTime, Value = month }, new OracleParameter() { ParameterName = "p_data", OracleType=OracleType.Cursor,Direction = ParameterDirection.Output }, new OracleParameter() { ParameterName = "p_dataCount", OracleType=OracleType.Cursor,Direction = ParameterDirection.Output } }; var ds = OracleHelper.DataQueray(CommandType.StoredProcedure, "PACK_WX_REPORT.CommissionBalanceReport", p.ToArray()); return ds; } catch (Exception ex) { LogHelper.Error("CommissionBalanceReport:" + ex.ToString()); throw; } } /// /// 个人分成报表 /// /// /// /// /// /// /// /// public DataSet GetSaleUserCommission(QueryUserComboDto usercomboDto, DateTime? sTime, DateTime? eTime) { var parms = new List() { sTime.HasValue ? new OracleParameter() { ParameterName = "p_sTime", OracleType = OracleType.DateTime, Value = sTime.Value } : new OracleParameter() { ParameterName = "p_sTime", OracleType = OracleType.DateTime, Value = DBNull.Value }, eTime.HasValue ? new OracleParameter() { ParameterName = "p_eTime", OracleType = OracleType.DateTime, Value = eTime.Value } : new OracleParameter() { ParameterName = "p_eTime", OracleType = OracleType.DateTime, Value = DBNull.Value }, new OracleParameter() { ParameterName = "p_data", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output }, new OracleParameter() { ParameterName = "p_data2", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output }, new OracleParameter() { ParameterName = "p_data3", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; var procName = "PACK_WX_REPORT.SaleUserCommission"; var year = sTime.Value.Year; if (year < 2023) procName = "PACK_WX_REPORT.SaleUserCommission_old"; return OracleHelper.DataQueray(CommandType.StoredProcedure, procName, parms.ToArray()); } public DataSet GetUserNewsOrderReport(QueryUserComboDto usercomboDto, DateTime? sTime, DateTime? eTime) { var param = new List() { sTime.HasValue ? new OracleParameter() { ParameterName = "p_sTime", OracleType = OracleType.DateTime, Value = sTime.Value } : new OracleParameter() { ParameterName = "p_sTime", OracleType = OracleType.DateTime, Value = DBNull.Value }, eTime.HasValue ? new OracleParameter() { ParameterName = "p_eTime", OracleType = OracleType.DateTime, Value = eTime.Value } : new OracleParameter() { ParameterName = "p_eTime", OracleType = OracleType.DateTime, Value = DBNull.Value }, new OracleParameter() { ParameterName = "p_data", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output }, new OracleParameter() { ParameterName = "p_data2", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; return OracleHelper.DataQueray(CommandType.StoredProcedure, "PACK_WX_REPORT.UserNewOrderCommission", param.ToArray()); } public DataSet GetGroupNewsOrderReport(QueryUserComboDto usercomboDto, DateTime? sTime, DateTime? eTime) { var param = new List() { //string.IsNullOrEmpty(usercomboDto.groupIds) ? new OracleParameter() { ParameterName = "p_groupId", OracleType = OracleType.VarChar, Value = DBNull.Value }: new OracleParameter() { ParameterName = "p_groupId", OracleType = OracleType.VarChar, Value = usercomboDto.groupIds }, //string.IsNullOrEmpty(usercomboDto.deptId) ? new OracleParameter() { ParameterName = "p_deptId", OracleType = OracleType.VarChar, Value = DBNull.Value }: new OracleParameter() { ParameterName = "p_deptId", OracleType = OracleType.VarChar, Value = usercomboDto.deptId }, //usercomboDto.companyId.HasValue ? new OracleParameter() { ParameterName = "p_companyId", OracleType = OracleType.Number, Value = usercomboDto.companyId.Value } : new OracleParameter() { ParameterName = "p_companyId", OracleType = OracleType.Number, Value = DBNull.Value }, sTime.HasValue ? new OracleParameter() { ParameterName = "p_sTime", OracleType = OracleType.DateTime, Value = sTime.Value } : new OracleParameter() { ParameterName = "p_sTime", OracleType = OracleType.DateTime, Value = DBNull.Value }, eTime.HasValue ? new OracleParameter() { ParameterName = "p_eTime", OracleType = OracleType.DateTime, Value = eTime.Value } : new OracleParameter() { ParameterName = "p_eTime", OracleType = OracleType.DateTime, Value = DBNull.Value }, new OracleParameter() { ParameterName = "p_data", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output }, new OracleParameter() { ParameterName = "p_data2", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; var ds = OracleHelper.DataQueray(CommandType.StoredProcedure, "PACK_WX_REPORT.GroupNewOrderCommission", param.ToArray()); return ds; } public DataSet GetSaleUserMonthCommission(string groupId, string inneruserId, decimal eId, decimal isDismiss) { var conn = new OracleConnection(OracleHelper.AYCRMConn); if (conn.State == ConnectionState.Closed) conn.Open(); try { using (var trans = conn.BeginTransaction()) { var parms = new List() { new OracleParameter() { ParameterName = "p_groupId", OracleType = OracleType.VarChar, Value = groupId }, new OracleParameter() { ParameterName = "p_inneruserId", OracleType = OracleType.VarChar, Value = inneruserId }, eId > 0 ? new OracleParameter() { ParameterName = "p_eId", OracleType = OracleType.Number, Value = eId } : new OracleParameter() { ParameterName = "p_eId", OracleType = OracleType.Number, Value = DBNull.Value }, isDismiss < 0 ? new OracleParameter() { ParameterName = "p_isDisMiss", OracleType = OracleType.Number, Value = DBNull.Value} : new OracleParameter() {ParameterName = "p_isDisMiss", OracleType = OracleType.Number, Value = isDismiss }, new OracleParameter() { ParameterName = "p_data", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output }, new OracleParameter() { ParameterName = "p_data2", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; DataSet ds = OracleHelper.DataQueray(trans, CommandType.StoredProcedure, "PACK_WX_REPORT.SaleUserMonthCommission", parms.ToArray()); trans.Commit(); return ds; } } catch (Exception ex) { LogHelper.Error(ex); return null; } finally { conn.Close(); } } /// /// 组分成报表 /// /// /// /// /// /// /// /// public DataSet GetSaleGroupCommission(QueryUserComboDto usercomboDto, DateTime? sTime, DateTime? eTime) { var parms = new List() { sTime.HasValue ? new OracleParameter() { ParameterName = "p_sTime", OracleType = OracleType.DateTime, Value = sTime.Value } : new OracleParameter() { ParameterName = "p_sTime", OracleType = OracleType.DateTime, Value = DBNull.Value }, eTime.HasValue ? new OracleParameter() { ParameterName = "p_eTime", OracleType = OracleType.DateTime, Value = eTime.Value } : new OracleParameter() { ParameterName = "p_eTime", OracleType = OracleType.DateTime, Value = DBNull.Value }, new OracleParameter() { ParameterName = "p_data", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output }, new OracleParameter() { ParameterName = "p_data2", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output }, new OracleParameter() { ParameterName = "p_data3", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output }, new OracleParameter() { ParameterName = "p_data4", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; var procName = "PACK_WX_REPORT.SaleGroupCommission_new"; var year = sTime.Value.Year; if (year < 2023) procName = "PACK_WX_REPORT.SaleGroupCommission"; return OracleHelper.DataQueray(CommandType.StoredProcedure, procName, parms.ToArray()); } public DataSet GetUserYeJi(DateTime month, decimal? eid) { var conn = new OracleConnection(OracleHelper.AYCRMConn); if (conn.State == ConnectionState.Closed) conn.Open(); try { using (var trans = conn.BeginTransaction()) { var parms = new List() { eid.HasValue ? new OracleParameter() { ParameterName = "p_eid", OracleType = OracleType.Number, Value = eid.Value } : new OracleParameter() { ParameterName = "p_eid", OracleType = OracleType.Number, Value = DBNull.Value }, new OracleParameter() { ParameterName = "p_month", OracleType = OracleType.DateTime, Value = month }, new OracleParameter() { ParameterName = "p_list", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; DataSet ds = OracleHelper.DataQueray(trans, CommandType.StoredProcedure, "PACK_WX_SETTLEMENT.GetUserYeJi", parms.ToArray()); trans.Commit(); return ds; } } catch (Exception ex) { LogHelper.Error(ex); return null; } finally { conn.Close(); } } public DataSet GetUserTuiKuan(DateTime month, decimal? eid) { var conn = new OracleConnection(OracleHelper.AYCRMConn); if (conn.State == ConnectionState.Closed) conn.Open(); try { using (var trans = conn.BeginTransaction()) { var parms = new List() { eid.HasValue ? new OracleParameter() { ParameterName = "p_eid", OracleType = OracleType.Number, Value = eid.Value } : new OracleParameter() { ParameterName = "p_eid", OracleType = OracleType.Number, Value = DBNull.Value }, new OracleParameter() { ParameterName = "p_month", OracleType = OracleType.DateTime, Value = month }, new OracleParameter() { ParameterName = "p_list", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; DataSet ds = OracleHelper.DataQueray(trans, CommandType.StoredProcedure, "PACK_WX_SETTLEMENT.GetUserTuiKuan", parms.ToArray()); trans.Commit(); return ds; } } catch (Exception ex) { LogHelper.Error(ex); return null; } finally { conn.Close(); } } public DataSet GetUserYuLiu(DateTime month, decimal? eid) { var conn = new OracleConnection(OracleHelper.AYCRMConn); if (conn.State == ConnectionState.Closed) conn.Open(); try { using (var trans = conn.BeginTransaction()) { var parms = new List() { eid.HasValue ? new OracleParameter() { ParameterName = "p_eid", OracleType = OracleType.Number, Value = eid.Value } : new OracleParameter() { ParameterName = "p_eid", OracleType = OracleType.Number, Value = DBNull.Value }, new OracleParameter() { ParameterName = "p_month", OracleType = OracleType.DateTime, Value = month }, new OracleParameter() { ParameterName = "p_list", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; DataSet ds = OracleHelper.DataQueray(trans, CommandType.StoredProcedure, "PACK_WX_SETTLEMENT.GetUserYuLiu", parms.ToArray()); trans.Commit(); return ds; } } catch (Exception ex) { LogHelper.Error(ex); return null; } finally { conn.Close(); } } public DataSet GetSaleGrouperWageQuery(DateTime month) { var conn = new OracleConnection(OracleHelper.AYCRMConn); if (conn.State == ConnectionState.Closed) conn.Open(); try { using (var trans = conn.BeginTransaction()) { var parms = new List() { //new OracleParameter() { ParameterName = "p_groupId", OracleType = OracleType.VarChar, Value = DBNull.Value }, new OracleParameter() { ParameterName = "p_month", OracleType = OracleType.DateTime, Value = month }, new OracleParameter() { ParameterName = "p_list", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; DataSet ds = OracleHelper.DataQueray(trans, CommandType.StoredProcedure, "PACK_WX_SETTLEMENT.SaleGrouperWageQuery", parms.ToArray()); trans.Commit(); return ds; } } catch (Exception ex) { LogHelper.Error(ex); return null; } finally { conn.Close(); } } public DataSet GetSaleGrouperSiglenWageQuery(DateTime month) { var conn = new OracleConnection(OracleHelper.AYCRMConn); if (conn.State == ConnectionState.Closed) conn.Open(); try { using (var trans = conn.BeginTransaction()) { var parms = new List() { new OracleParameter() { ParameterName = "p_month", OracleType = OracleType.DateTime, Value = month }, new OracleParameter() { ParameterName = "p_list", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; DataSet ds = OracleHelper.DataQueray(trans, CommandType.StoredProcedure, "PACK_WX_SETTLEMENT.SaleGrouperSiglenWageQuery", parms.ToArray()); trans.Commit(); return ds; } } catch (Exception ex) { LogHelper.Error(ex); return null; } finally { conn.Close(); } } public DataSet GetUserCommissionDetail(decimal? inneruserId, DateTime sTime, DateTime eTime) { var conn = new OracleConnection(OracleHelper.AYCRMConn); if (conn.State == ConnectionState.Closed) conn.Open(); try { using (var trans = conn.BeginTransaction()) { var parms = new List() { //new OracleParameter() { ParameterName = "p_inneruserId", OracleType = OracleType.Number, Value = inneruserId }, new OracleParameter() { ParameterName = "p_sTime", OracleType = OracleType.DateTime, Value = sTime }, new OracleParameter() { ParameterName = "p_eTime", OracleType = OracleType.DateTime, Value = eTime }, new OracleParameter() { ParameterName = "p_data", OracleType = OracleType.Cursor, Direction = ParameterDirection.Output } }; if (inneruserId.HasValue) { parms.Add(new OracleParameter() { ParameterName = "p_inneruserId", OracleType = OracleType.Number, Value = inneruserId }); } else { parms.Add(new OracleParameter() { ParameterName = "p_inneruserId", OracleType = OracleType.Number, Value = DBNull.Value }); } DataSet ds = OracleHelper.DataQueray(trans, CommandType.StoredProcedure, "PACK_WX_REPORT.GetUserCommissionDetail", parms.ToArray()); trans.Commit(); return ds; } } catch (Exception ex) { LogHelper.Error(ex); return null; } finally { conn.Close(); } } } }