From f2165d5dcc0776cc41a3d0e7210f6eb992181ad4 Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Tue, 10 May 2022 10:02:35 +0800
Subject: [PATCH] Add unit test
---
.../SqlServerTest/SqlServerTest.csproj | 1 +
Src/Asp.Net/SqlServerTest/UnitTest/Main.cs | 1 +
.../SqlServerTest/UnitTest/UCustom020.cs | 463 ++++++++++++++++++
3 files changed, 465 insertions(+)
create mode 100644 Src/Asp.Net/SqlServerTest/UnitTest/UCustom020.cs
diff --git a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
index 70e6fdc68..07fc29913 100644
--- a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
+++ b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
@@ -95,6 +95,7 @@
+
diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs
index 8210451b9..7952a8d84 100644
--- a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs
+++ b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs
@@ -31,6 +31,7 @@ namespace OrmTest
}
public static void Init()
{
+ UCustom020.Init();
UCustom019.Init();
UnitManyToMany.Init();
UCustom018.Init();
diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom020.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom020.cs
new file mode 100644
index 000000000..795d5a057
--- /dev/null
+++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom020.cs
@@ -0,0 +1,463 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SqlSugar;
+namespace OrmTest
+{
+ public class UCustom020
+ {
+ // See https://aka.ms/new-console-template for more information
+
+ public static void Init()
+ {
+ var db = NewUnitTest.Db;
+ if(!db.DbMaintenance.IsAnyTable("js_crm_customer", false))
+ {
+ db.CodeFirst.InitTables();
+ }
+ //建表
+ if (!db.DbMaintenance.IsAnyTable("js_crm_customertypelevelnew", false))
+ {
+ db.CodeFirst.InitTables();
+ }
+
+ var param = new CustomerReq() { TabType = 3 };
+
+ //用例代码
+ var result = db.Queryable().Where(customer => customer.CustomerLevelId == SqlFunc.Subqueryable().Where(n => SqlFunc.Between(n.CustomerTypeNewId, 1, 2)).GroupBy(n => n.CustomerLevelId).Select(n => n.CustomerLevelId)).ToList();
+
+ }
+
+ public class CustomerReq
+{
+ public int? TabType { get; set; }
+}
+
+ ///
+ /// 客户信息
+ ///
+ [SugarTable("js_crm_customer")]
+ public class CustomerModel
+ {
+ ///
+ /// 系统编号
+ ///
+ [SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
+ public string Id { get; set; }
+ ///
+ /// 客户编号
+ ///
+ [SugarColumn(ColumnName = "Number")]
+ public string Number { get; set; }
+ ///
+ /// 密码
+ ///
+ [SugarColumn(ColumnName = "Password")]
+ public string Password { get; set; }
+ ///
+ /// 加密方式
+ ///
+ [SugarColumn(ColumnName = "PasswordFormat")]
+ public int? PasswordFormat { get; set; }
+ ///
+ /// 加密密匙
+ ///
+ [SugarColumn(ColumnName = "PasswordSalt")]
+ public string PasswordSalt { get; set; }
+ ///
+ /// 客户姓名
+ ///
+ [SugarColumn(ColumnName = "Name")]
+ public string Name { get; set; }
+ ///
+ /// 性别(0=男;1=女;2=保密;)
+ ///
+ [SugarColumn(ColumnName = "Gender")]
+ public int? Gender { get; set; }
+ ///
+ /// 区县编号
+ ///
+ [SugarColumn(ColumnName = "RegionId")]
+ public string RegionId { get; set; }
+ ///
+ /// 详细地址
+ ///
+ [SugarColumn(ColumnName = "Address")]
+ public string Address { get; set; }
+ ///
+ /// 联系方式1
+ ///
+ [SugarColumn(ColumnName = "CellPhone")]
+ public string CellPhone { get; set; }
+ ///
+ /// 联系方式2
+ ///
+ [SugarColumn(ColumnName = "CellPhone2")]
+ public string CellPhone2 { get; set; }
+ ///
+ /// 联系方式3
+ ///
+ [SugarColumn(ColumnName = "CellPhone3")]
+ public string CellPhone3 { get; set; }
+ ///
+ /// 创建日期
+ ///
+ [SugarColumn(ColumnName = "CreateDate")]
+ public DateTime? CreateDate { get; set; }
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(ColumnName = "CeateUserId")]
+ public string CeateUserId { get; set; }
+ ///
+ /// 消费金额
+ ///
+ [SugarColumn(ColumnName = "CostTotal")]
+ public decimal? CostTotal { get; set; }
+ ///
+ /// 意向产品(多产品ID用逗号隔开)
+ ///
+ [SugarColumn(ColumnName = "LikeProduct")]
+ public string LikeProduct { get; set; }
+ ///
+ /// 归属人
+ ///
+ [SugarColumn(ColumnName = "ManageUserId")]
+ public string ManageUserId { get; set; }
+ ///
+ /// 跟进次数
+ ///
+ [SugarColumn(ColumnName = "FollowupTimes")]
+ public int? FollowupTimes { get; set; }
+ ///
+ /// 成交次数
+ ///
+ [SugarColumn(ColumnName = "Volamount")]
+ public int? Volamount { get; set; }
+ ///
+ /// 客户等级
+ ///
+ [SugarColumn(ColumnName = "Grade")]
+ public int? Grade { get; set; }
+ ///
+ /// 上级编号
+ ///
+ [SugarColumn(ColumnName = "CustomerParentId")]
+ public string CustomerParentId { get; set; }
+ ///
+ /// 客户状态
+ ///
+ [SugarColumn(ColumnName = "CustomerStatus")]
+ public int? CustomerStatus { get; set; }
+ ///
+ /// 客户来源编号
+ ///
+ [SugarColumn(ColumnName = "CustomerSourceId")]
+ public string CustomerSourceId { get; set; }
+ ///
+ /// 备注
+ ///
+ [SugarColumn(ColumnName = "Remark")]
+ public string Remark { get; set; }
+ ///
+ /// 是否可用
+ ///
+ [SugarColumn(ColumnName = "IsEnabled")]
+ public int? IsEnabled { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "WxId")]
+ public string WxId { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "HurTime")]
+ public DateTime? HurTime { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "RegionPaht")]
+ public string RegionPaht { get; set; }
+ ///
+ /// 分配时间
+ ///
+ [SugarColumn(ColumnName = "Ftime")]
+ public DateTime? Ftime { get; set; }
+ ///
+ /// 预约下次沟通时间
+ ///
+ [SugarColumn(ColumnName = "Gtime")]
+ public DateTime? Gtime { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "LikeProduct2")]
+ public string LikeProduct2 { get; set; }
+ ///
+ /// 最后一次访问时间
+ ///
+ [SugarColumn(ColumnName = "lastvisitdate")]
+ public DateTime? Lastvisitdate { get; set; }
+ ///
+ /// 客户等级
+ ///
+ [SugarColumn(ColumnName = "CustomerLevel")]
+ public string CustomerLevel { get; set; }
+ ///
+ /// 推广链接
+ ///
+ [SugarColumn(ColumnName = "PromotionUrl")]
+ public string PromotionUrl { get; set; }
+ ///
+ /// 年龄
+ ///
+ [SugarColumn(ColumnName = "Age")]
+ public int? Age { get; set; }
+ ///
+ /// 年龄段
+ ///
+ [SugarColumn(ColumnName = "AgeSection")]
+ public int? AgeSection { get; set; }
+ ///
+ /// 体重
+ ///
+ [SugarColumn(ColumnName = "Weight")]
+ public decimal? Weight { get; set; }
+ ///
+ /// 身高
+ ///
+ [SugarColumn(ColumnName = "Height")]
+ public decimal? Height { get; set; }
+ ///
+ /// 号码归属地
+ ///
+ [SugarColumn(ColumnName = "Location")]
+ public string Location { get; set; }
+ ///
+ /// 生日
+ ///
+ [SugarColumn(ColumnName = "Birthday")]
+ public DateTime? Birthday { get; set; }
+ ///
+ /// 其他疾病
+ ///
+ [SugarColumn(ColumnName = "OtherDisease")]
+ public string OtherDisease { get; set; }
+ ///
+ /// 过敏 如果为空或长度等于0则选中无
+ ///
+ [SugarColumn(ColumnName = "Allergy")]
+ public string Allergy { get; set; }
+ ///
+ /// 运动习惯 0 常常 1 偶尔 2 较少
+ ///
+ [SugarColumn(ColumnName = "SportHabit")]
+ public int? SportHabit { get; set; }
+ ///
+ /// 饮食习惯
+ ///
+ [SugarColumn(ColumnName = "DietaryHabit")]
+ public string DietaryHabit { get; set; }
+ ///
+ /// 婚姻状况 0 未婚 1 已婚
+ ///
+ [SugarColumn(ColumnName = "MaritalStatus")]
+ public int? MaritalStatus { get; set; }
+ ///
+ /// 睡眠状况 0 较好 1 一般 2 不好
+ ///
+ [SugarColumn(ColumnName = "SleepStatus")]
+ public int? SleepStatus { get; set; }
+ ///
+ /// 需求,以 | 分割
+ ///
+ [SugarColumn(ColumnName = "Need")]
+ public string Need { get; set; }
+ ///
+ /// 订单数量
+ ///
+ [SugarColumn(ColumnName = "ordercount")]
+ public int? Ordercount { get; set; }
+ ///
+ /// 最后沟通时间
+ ///
+ [SugarColumn(ColumnName = "communicationdate")]
+ public DateTime? Communicationdate { get; set; }
+ ///
+ /// 已减体重
+ ///
+ [SugarColumn(ColumnName = "ReduceWeight")]
+ public decimal? ReduceWeight { get; set; }
+ ///
+ /// 最后下单时间
+ ///
+ [SugarColumn(ColumnName = "lastorderdate")]
+ public DateTime? Lastorderdate { get; set; }
+ ///
+ /// 脂玫乐编号
+ ///
+ [SugarColumn(ColumnName = "ZmlId")]
+ public string ZmlId { get; set; }
+ ///
+ /// 脂玫乐绑定码
+ ///
+ [SugarColumn(ColumnName = "ZmlInviteCode")]
+ public string ZmlInviteCode { get; set; }
+ ///
+ /// 广告客户来源计划编号
+ ///
+ [SugarColumn(ColumnName = "PlanId")]
+ public string PlanId { get; set; }
+ ///
+ /// 互联网医院ID
+ ///
+ [SugarColumn(ColumnName = "HospitalId")]
+ public string HospitalId { get; set; }
+ ///
+ /// 广告客户来源账户编号
+ ///
+ [SugarColumn(ColumnName = "AccountId")]
+ public long? AccountId { get; set; }
+ ///
+ /// 是否通过电话取得联系(通话记录中有呼入或呼出记录)
+ ///
+ [SugarColumn(ColumnName = "IsContact")]
+ public int? IsContact { get; set; }
+ ///
+ /// 真实创建时间(入库时间)
+ ///
+ [SugarColumn(ColumnName = "RealCreateDate")]
+ public DateTime? RealCreateDate { get; set; }
+ ///
+ /// 是否有投诉记录
+ ///
+ [SugarColumn(ColumnName = "IsComplaint")]
+ public int? IsComplaint { get; set; }
+ ///
+ /// 0:未锁定 1:已锁定
+ ///
+ [SugarColumn(ColumnName = "IsLock")]
+ public int? IsLock { get; set; }
+ ///
+ /// 部门分类编号
+ ///
+ [SugarColumn(ColumnName = "DeptClassifyId")]
+ public int? DeptClassifyId { get; set; }
+ ///
+ /// 复购进线时间
+ ///
+ [SugarColumn(ColumnName = "RePurchaseLeadTime")]
+ public DateTime? RePurchaseLeadTime { get; set; }
+ ///
+ /// 蜕变日记开启服务
+ ///
+ [SugarColumn(ColumnName = "IsOpenDiary")]
+ public int? IsOpenDiary { get; set; }
+ ///
+ /// 蜕变日记用户开启
+ ///
+ [SugarColumn(ColumnName = "IsUserOpenDiary")]
+ public int? IsUserOpenDiary { get; set; }
+ ///
+ /// 客户标记
+ ///
+ [SugarColumn(ColumnName = "CustomerFlag")]
+ public string CustomerFlag { get; set; }
+ ///
+ /// 最后编辑时间
+ ///
+ [SugarColumn(ColumnName = "LastModifyTime")]
+ public DateTime? LastModifyTime { get; set; }
+ ///
+ /// 进线类型 0 员工创建 1 未接来电 2 其他系统导入 3 excel导入 4 飞鱼广告进线 5 快手广告进线
+ ///
+ [SugarColumn(ColumnName = "InlineType")]
+ public int? InlineType { get; set; }
+ ///
+ /// 微信号
+ ///
+ [SugarColumn(ColumnName = "wechatnumber")]
+ public string Wechatnumber { get; set; }
+ ///
+ /// 客户阶段
+ ///
+ [SugarColumn(ColumnName = "CustomerLevelId")]
+ public int? CustomerLevelId { get; set; }
+
+
+
+ }
+
+ ///
+ ///
+ ///
+ [SugarTable("js_crm_customertypelevelnew")]
+ public class CustomertypelevelNewModel
+ {
+ ///
+ /// 客户分类等级Id
+ ///
+ [SugarColumn(ColumnName = "CustomerLevelId", IsPrimaryKey = true, IsIdentity = true)]
+ public int CustomerLevelId { get; set; }
+ ///
+ /// 客户分类等级名称
+ ///
+ [SugarColumn(ColumnName = "CustomerLevelName")]
+ public string CustomerLevelName { get; set; }
+ ///
+ /// 新分类Id
+ ///
+ [SugarColumn(ColumnName = "CustomerTypeNewId")]
+ public int? CustomerTypeNewId { get; set; }
+ ///
+ /// 排序
+ ///
+ [SugarColumn(ColumnName = "LevelSort")]
+ public int? LevelSort { get; set; }
+ ///
+ /// 自动流转勾选 1 是 0否
+ ///
+ [SugarColumn(ColumnName = "RoamEnable")]
+ public bool? RoamEnable { get; set; }
+ ///
+ /// 自动流转到客户分类Id
+ ///
+ [SugarColumn(ColumnName = "RoamCusTypeNewId")]
+ public int? RoamCusTypeNewId { get; set; }
+ ///
+ /// 自动流转到客户分类明细Id
+ ///
+ [SugarColumn(ColumnName = "RoamCusTypeLevelId")]
+ public int? RoamCusTypeLevelId { get; set; }
+ ///
+ /// 限制条件 1.不限制 2.需要审核 3.订单签收
+ ///
+ [SugarColumn(ColumnName = "Restrictions")]
+ public int? Restrictions { get; set; }
+ ///
+ /// 是否删除 0否 1是
+ ///
+ [SugarColumn(ColumnName = "IsDelete")]
+ public bool? IsDelete { get; set; }
+ ///
+ /// 对应crm等级名称
+ ///
+ [SugarColumn(ColumnName = "CrmCustomerTypeName")]
+ public string CrmCustomerTypeName { get; set; }
+
+ ///
+ /// 创建日期
+ ///
+ [SugarColumn(ColumnName = "CreateData")]
+ public DateTime? CreateData { get; set; }
+ ///
+ /// 创建人员工Id
+ ///
+ [SugarColumn(ColumnName = "CreateUserId")]
+ public string CreateUserId { get; set; }
+ }
+ }
+}