將全年報名移至獨立頁籤,並新增未報名品項名單列印功能

This commit is contained in:
2026-05-11 09:11:22 +08:00
parent 9a7c30bd21
commit 46494547db
12 changed files with 1508 additions and 646 deletions
+1
View File
@@ -94,6 +94,7 @@ namespace Model
public virtual DbSet<AncestralTabletRegistrant> AncestralTabletRegistrant { get; set; }
public virtual DbSet<AncestralTabletStatus> AncestralTabletStatus { get; set; }
public virtual DbSet<GuaDanOrderGuest> GuaDanOrderGuest { get; set; }
public virtual DbSet<auto_enroll> auto_enroll { get; set; }
public virtual int pager_eztrust(Nullable<int> startRowIndex, Nullable<int> pageSize, string tableName, string columnName, string sqlWhere, string orderBy, ObjectParameter rowCount)
{
+31 -5
View File
@@ -681,6 +681,31 @@ namespace Model
using System;
using System.Collections.Generic;
public partial class auto_enroll
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public auto_enroll()
{
this.pro_order = new HashSet<pro_order>();
}
public int num { get; set; }
public int f_num { get; set; }
public System.DateTime start_date { get; set; }
public System.DateTime end_date { get; set; }
public string receipt_title { get; set; }
public string receipt_address { get; set; }
public virtual follower followers { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<pro_order> pro_order { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class bed_kind
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
@@ -807,6 +832,7 @@ namespace Model
public string smtp_def { get; set; }
public string use_sender { get; set; }
public string bed_order_no { get; set; }
public string last_auto_order_no { get; set; }
}
}
namespace Model
@@ -908,6 +934,7 @@ namespace Model
this.transfer_register1 = new HashSet<transfer_register>();
this.GuaDanOrder = new HashSet<GuaDanOrder>();
this.GuaDanOrderGuest = new HashSet<GuaDanOrderGuest>();
this.auto_enroll = new HashSet<auto_enroll>();
}
public int num { get; set; }
@@ -942,11 +969,6 @@ namespace Model
public Nullable<int> appellation_id { get; set; }
public string follower_hash { get; set; }
public string search_keywords { get; set; }
public Nullable<bool> is_auto_enroll { get; set; }
public Nullable<System.DateTime> auto_enroll_start_date { get; set; }
public string auto_enroll_receipt_title { get; set; }
public string auto_enroll_receipt_address { get; set; }
public Nullable<bool> auto_enroll_is_receipt { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<activity_check> activity_check { get; set; }
@@ -977,6 +999,8 @@ namespace Model
public virtual ICollection<GuaDanOrder> GuaDanOrder { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<GuaDanOrderGuest> GuaDanOrderGuest { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<auto_enroll> auto_enroll { get; set; }
}
}
namespace Model
@@ -1350,6 +1374,7 @@ namespace Model
public Nullable<int> introducer { get; set; }
public Nullable<bool> send_receipt { get; set; }
public string receipt_title { get; set; }
public Nullable<int> au_num { get; set; }
public virtual activity activity { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
@@ -1358,6 +1383,7 @@ namespace Model
public virtual follower follower1 { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<pro_order_detail> pro_order_detail { get; set; }
public virtual auto_enroll auto_enroll { get; set; }
}
}
namespace Model
+112 -15
View File
@@ -334,6 +334,17 @@
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="title" Type="nvarchar" MaxLength="10" />
</EntityType>
<EntityType Name="auto_enroll">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="f_num" Type="int" Nullable="false" />
<Property Name="start_date" Type="date" Nullable="false" />
<Property Name="end_date" Type="date" Nullable="false" />
<Property Name="receipt_title" Type="nvarchar(max)" />
<Property Name="receipt_address" Type="nchar" MaxLength="200" />
</EntityType>
<EntityType Name="bed_kind">
<Key>
<PropertyRef Name="num" />
@@ -405,6 +416,7 @@
<Property Name="smtp_def" Type="nvarchar" MaxLength="1" />
<Property Name="use_sender" Type="nvarchar" MaxLength="1" />
<Property Name="bed_order_no" Type="nvarchar" MaxLength="20" />
<Property Name="last_auto_order_no" Type="nvarchar" MaxLength="20" />
</EntityType>
<EntityType Name="country">
<Key>
@@ -486,11 +498,6 @@
<Property Name="appellation_id" Type="int" />
<Property Name="follower_hash" Type="nvarchar" MaxLength="100" />
<Property Name="search_keywords" Type="varchar(max)" />
<Property Name="is_auto_enroll" Type="bit" />
<Property Name="auto_enroll_start_date" Type="datetime" />
<Property Name="auto_enroll_receipt_title" Type="nvarchar" MaxLength="50" />
<Property Name="auto_enroll_receipt_address" Type="nchar" MaxLength="200" />
<Property Name="auto_enroll_is_receipt" Type="bit" />
</EntityType>
<EntityType Name="followers_tablet">
<Key>
@@ -706,6 +713,7 @@
<Property Name="introducer" Type="int" />
<Property Name="send_receipt" Type="bit" />
<Property Name="receipt_title" Type="nvarchar(max)" />
<Property Name="au_num" Type="int" />
</EntityType>
<EntityType Name="pro_order_detail">
<Key>
@@ -1274,6 +1282,18 @@
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_auto_enroll_followers">
<End Role="followers" Type="Self.followers" Multiplicity="1" />
<End Role="auto_enroll" Type="Self.auto_enroll" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="followers">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="auto_enroll">
<PropertyRef Name="f_num" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_bed_kind_detail_bed_kind">
<End Role="bed_kind" Type="Self.bed_kind" Multiplicity="0..1" />
<End Role="bed_kind_detail" Type="Self.bed_kind_detail" Multiplicity="*" />
@@ -1652,6 +1672,18 @@
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_pro_order_auto_enroll">
<End Role="auto_enroll" Type="Self.auto_enroll" Multiplicity="0..1" />
<End Role="pro_order" Type="Self.pro_order" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="auto_enroll">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="pro_order">
<PropertyRef Name="au_num" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_pro_order_detail_actItem">
<End Role="actItem" Type="Self.actItem" Multiplicity="0..1">
<OnDelete Action="Cascade" />
@@ -2122,6 +2154,7 @@
<EntitySet Name="AncestralTabletRegistrant" EntityType="Self.AncestralTabletRegistrant" Schema="dbo" store:Type="Tables" />
<EntitySet Name="AncestralTabletStatus" EntityType="Self.AncestralTabletStatus" Schema="dbo" store:Type="Tables" />
<EntitySet Name="appellation" EntityType="Self.appellation" Schema="dbo" store:Type="Tables" />
<EntitySet Name="auto_enroll" EntityType="Self.auto_enroll" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_kind" EntityType="Self.bed_kind" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_kind_detail" EntityType="Self.bed_kind_detail" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_order" EntityType="Self.bed_order" Schema="dbo" store:Type="Tables" />
@@ -2253,6 +2286,10 @@
<End Role="AncestralTabletArea" EntitySet="AncestralTabletArea" />
<End Role="AncestralTabletArea1" EntitySet="AncestralTabletArea" />
</AssociationSet>
<AssociationSet Name="FK_auto_enroll_followers" Association="Self.FK_auto_enroll_followers">
<End Role="followers" EntitySet="followers" />
<End Role="auto_enroll" EntitySet="auto_enroll" />
</AssociationSet>
<AssociationSet Name="FK_bed_kind_detail_bed_kind" Association="Self.FK_bed_kind_detail_bed_kind">
<End Role="bed_kind" EntitySet="bed_kind" />
<End Role="bed_kind_detail" EntitySet="bed_kind_detail" />
@@ -2377,6 +2414,10 @@
<End Role="activity" EntitySet="activity" />
<End Role="pro_order" EntitySet="pro_order" />
</AssociationSet>
<AssociationSet Name="FK_pro_order_auto_enroll" Association="Self.FK_pro_order_auto_enroll">
<End Role="auto_enroll" EntitySet="auto_enroll" />
<End Role="pro_order" EntitySet="pro_order" />
</AssociationSet>
<AssociationSet Name="FK_pro_order_detail_actItem" Association="Self.FK_pro_order_detail_actItem">
<End Role="actItem" EntitySet="actItem" />
<End Role="pro_order_detail" EntitySet="pro_order_detail" />
@@ -2905,6 +2946,7 @@
<Property Name="smtp_def" Type="String" MaxLength="1" FixedLength="false" Unicode="true" />
<Property Name="use_sender" Type="String" MaxLength="1" FixedLength="false" Unicode="true" />
<Property Name="bed_order_no" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="last_auto_order_no" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
</EntityType>
<EntityType Name="country">
<Key>
@@ -2983,11 +3025,7 @@
<NavigationProperty Name="GuaDanOrder" Relationship="Model.FK_GuaDanOrder_Followers" FromRole="follower" ToRole="GuaDanOrder" />
<Property Name="search_keywords" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<NavigationProperty Name="GuaDanOrderGuest" Relationship="Model.FK_GuaDanOrderGuest_FOLLOWERS" FromRole="follower" ToRole="GuaDanOrderGuest" />
<Property Name="is_auto_enroll" Type="Boolean" />
<Property Name="auto_enroll_start_date" Type="DateTime" Precision="3" />
<Property Name="auto_enroll_receipt_title" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="auto_enroll_receipt_address" Type="String" MaxLength="200" FixedLength="true" Unicode="true" />
<Property Name="auto_enroll_is_receipt" Type="Boolean" />
<NavigationProperty Name="auto_enroll" Relationship="Model.FK_auto_enroll_followers" FromRole="follower" ToRole="auto_enroll" />
</EntityType>
<EntityType Name="followers_tablet">
<Key>
@@ -3166,6 +3204,8 @@
<NavigationProperty Name="pro_order_detail" Relationship="Self.FK_pro_order_detail_pro_order" FromRole="pro_order" ToRole="pro_order_detail" />
<Property Name="send_receipt" Type="Boolean" />
<Property Name="receipt_title" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="au_num" Type="Int32" />
<NavigationProperty Name="auto_enroll" Relationship="Model.FK_pro_order_auto_enroll" FromRole="pro_order" ToRole="auto_enroll" />
</EntityType>
<EntityType Name="pro_order_detail">
<Key>
@@ -4563,6 +4603,15 @@
<End Role="GuaDanOrderGuest" EntitySet="GuaDanOrderGuest" />
<End Role="RegionAndRoomAndBedSchedule" EntitySet="RegionAndRoomAndBedSchedule" />
</AssociationSet>
<EntitySet Name="auto_enroll" EntityType="Model.auto_enroll" />
<AssociationSet Name="FK_auto_enroll_followers" Association="Model.FK_auto_enroll_followers">
<End Role="follower" EntitySet="followers" />
<End Role="auto_enroll" EntitySet="auto_enroll" />
</AssociationSet>
<AssociationSet Name="FK_pro_order_auto_enroll" Association="Model.FK_pro_order_auto_enroll">
<End Role="auto_enroll" EntitySet="auto_enroll" />
<End Role="pro_order" EntitySet="pro_order" />
</AssociationSet>
</EntityContainer>
<ComplexType Name="sp_helpdiagramdefinition_Result">
<Property Type="Int32" Name="version" Nullable="true" />
@@ -5280,6 +5329,45 @@
</Dependent>
</ReferentialConstraint>
</Association>
<EntityType Name="auto_enroll">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="f_num" Type="Int32" Nullable="false" />
<Property Name="start_date" Type="DateTime" Precision="0" Nullable="false" />
<Property Name="end_date" Type="DateTime" Precision="0" Nullable="false" />
<Property Name="receipt_title" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="receipt_address" Type="String" MaxLength="200" FixedLength="true" Unicode="true" />
<NavigationProperty Name="followers" Relationship="Model.FK_auto_enroll_followers" FromRole="auto_enroll" ToRole="follower" />
<NavigationProperty Name="pro_order" Relationship="Model.FK_pro_order_auto_enroll" FromRole="auto_enroll" ToRole="pro_order" />
</EntityType>
<Association Name="FK_auto_enroll_followers">
<End Type="Model.follower" Role="follower" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Type="Model.auto_enroll" Role="auto_enroll" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="follower">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="auto_enroll">
<PropertyRef Name="f_num" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_pro_order_auto_enroll">
<End Type="Model.auto_enroll" Role="auto_enroll" Multiplicity="0..1" />
<End Type="Model.pro_order" Role="pro_order" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="auto_enroll">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="pro_order">
<PropertyRef Name="au_num" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
@@ -5606,6 +5694,7 @@
<EntitySetMapping Name="companies">
<EntityTypeMapping TypeName="Model.company">
<MappingFragment StoreEntitySet="company">
<ScalarProperty Name="last_auto_order_no" ColumnName="last_auto_order_no" />
<ScalarProperty Name="num" ColumnName="num" />
<ScalarProperty Name="com_name" ColumnName="com_name" />
<ScalarProperty Name="com_mail" ColumnName="com_mail" />
@@ -5657,11 +5746,6 @@
<EntitySetMapping Name="followers">
<EntityTypeMapping TypeName="Model.follower">
<MappingFragment StoreEntitySet="followers">
<ScalarProperty Name="auto_enroll_is_receipt" ColumnName="auto_enroll_is_receipt" />
<ScalarProperty Name="auto_enroll_receipt_address" ColumnName="auto_enroll_receipt_address" />
<ScalarProperty Name="auto_enroll_receipt_title" ColumnName="auto_enroll_receipt_title" />
<ScalarProperty Name="auto_enroll_start_date" ColumnName="auto_enroll_start_date" />
<ScalarProperty Name="is_auto_enroll" ColumnName="is_auto_enroll" />
<ScalarProperty Name="search_keywords" ColumnName="search_keywords" />
<ScalarProperty Name="follower_hash" ColumnName="follower_hash" />
<ScalarProperty Name="num" ColumnName="num" />
@@ -5845,6 +5929,7 @@
<EntitySetMapping Name="pro_order">
<EntityTypeMapping TypeName="Model.pro_order">
<MappingFragment StoreEntitySet="pro_order">
<ScalarProperty Name="au_num" ColumnName="au_num" />
<ScalarProperty Name="receipt_title" ColumnName="receipt_title" />
<ScalarProperty Name="send_receipt" ColumnName="send_receipt" />
<ScalarProperty Name="order_no" ColumnName="order_no" />
@@ -6338,6 +6423,18 @@
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="auto_enroll">
<EntityTypeMapping TypeName="Model.auto_enroll">
<MappingFragment StoreEntitySet="auto_enroll">
<ScalarProperty Name="receipt_address" ColumnName="receipt_address" />
<ScalarProperty Name="receipt_title" ColumnName="receipt_title" />
<ScalarProperty Name="end_date" ColumnName="end_date" />
<ScalarProperty Name="start_date" ColumnName="start_date" />
<ScalarProperty Name="f_num" ColumnName="f_num" />
<ScalarProperty Name="num" ColumnName="num" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
+3
View File
@@ -162,6 +162,9 @@
<AssociationConnector Association="Model.FK_GuaDanOrderGuest_RoomUuid" />
<AssociationConnector Association="Model.FK_GuaDanOrderGuest_StatusCode" />
<AssociationConnector Association="Model.FK_Schedule_GuaDanOrderGuest" />
<EntityTypeShape EntityType="Model.auto_enroll" Width="1.5" PointX="5.25" PointY="37.875" />
<AssociationConnector Association="Model.FK_auto_enroll_followers" />
<AssociationConnector Association="Model.FK_pro_order_auto_enroll" />
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
+336 -8
View File
@@ -1,16 +1,20 @@
using System;
using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Office2010.Excel;
using Model;
using MyWeb;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using PagedList;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Entity;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using PagedList;
using Newtonsoft.Json;
using System.Collections;
using DocumentFormat.OpenXml.Office2010.Excel;
using MyWeb;
using System.Data.Entity;
using System.Diagnostics;
using System.Web.Razor.Tokenizer;
// api/Follower
//[ezAuthorize(Roles = "admin")]//群組:*
@@ -532,6 +536,203 @@ public class FollowerController : ApiController
}
[HttpGet]
[Route("api/follower/GetAutoEnrollList/{id}")]
public IHttpActionResult GetAutoEnrollList(int id)
{
var prod = _db.auto_enroll.Where(q => q.f_num == id).ToList();
var ret = new
{
list = prod.Select(x => new
{
num = x.num,
auto_enroll_start_date = x.start_date.ToString("yyyy-MM-dd"),
auto_enroll_end_date = x.end_date.ToString("yyyy-MM-dd"),
auto_enroll_receipt_title = x.receipt_title?? "",
auto_enroll_receipt_address = x.receipt_address?? "",
}),
};
return Ok(ret);
}
[HttpPost]
[Route("api/follower/SaveAutoEnrollList")]
public IHttpActionResult SaveAutoEnrollList([FromBody] Model.auto_enroll item)
{
Model.auto_enroll autoEnroll;
if (item.num == 0)
{
// ===== 新增 =====
autoEnroll = new Model.auto_enroll()
{
f_num = item.f_num,
start_date = item.start_date,
end_date = item.end_date,
receipt_title = string.IsNullOrEmpty(item.receipt_title) ? null : item.receipt_title.Trim(),
receipt_address = string.IsNullOrEmpty(item.receipt_address) ? null : item.receipt_address.Trim(),
}
;
_db.auto_enroll.Add(autoEnroll);
_db.SaveChanges();
CreateOrdersForActivities(item.f_num, autoEnroll.num, item.start_date, item.end_date, item.receipt_title, item.receipt_address);
}
else
{
// ===== 更新 =====
autoEnroll = _db.auto_enroll.Where(q => q.num == item.num).FirstOrDefault();
if (autoEnroll == null) return NotFound();
autoEnroll.start_date = item.start_date;
autoEnroll.end_date = item.end_date;
autoEnroll.receipt_title = item.receipt_title?.Trim() ?? null;
autoEnroll.receipt_address = item.receipt_address?.Trim() ?? null;
_db.SaveChanges();
CreateOrdersForActivities(item.f_num, autoEnroll.num, item.start_date, item.end_date, item.receipt_title, item.receipt_address);
}
try
{
var ret = new
{
num = autoEnroll.num,
start_date = autoEnroll.start_date.ToString("yyyy-MM-dd"),
end_date = autoEnroll.end_date.ToString("yyyy-MM-dd"),
receipt_title = autoEnroll.receipt_title,
receipt_address = autoEnroll.receipt_address,
};
return Ok(ret);
}
catch(Exception ex)
{
return InternalServerError(ex);
}
}
[HttpPost]
[Route("api/follower/GetAffectedOrders")]
public IHttpActionResult GetAffectedOrders([FromBody] Model.auto_enroll item, bool is_delete = false)
{
if (item == null) return BadRequest();
try
{
IQueryable<pro_order> query = _db.pro_order
.Where(o => o.f_num == item.f_num
&& o.order_no.StartsWith("AU")
&& o.au_num == item.num);
if (is_delete)
{
// 刪除:查期間內所有自動報名訂單
query = query.Where(o =>
o.activity.startDate_solar >= item.start_date &&
o.activity.startDate_solar <= item.end_date
);
}
else
{
// 修改:查不在新範圍內的訂單
query = query.Where(o =>
o.activity.startDate_solar < item.start_date ||
o.activity.startDate_solar > item.end_date
);
}
var rawOrders = query.Select(o => new
{
o.order_no,
o.activity.subject,
o.activity.startDate_solar
}).ToList();
var affectedOrders = rawOrders.Select(o => new
{
order_no = o.order_no,
activityname = o.subject,
activitydate = o.startDate_solar?.ToString("yyyy/MM/dd") ?? ""
}).ToList();
return Ok(new
{
count = affectedOrders.Count,
list = affectedOrders
});
}
catch (Exception ex)
{
return InternalServerError(ex.GetBaseException());
}
}
[HttpDelete]
[Route("api/follower/DeleteAutoEnroll/{id}")]
public IHttpActionResult DeleteAutoEnroll(int id)
{
try
{
var prod = _db.auto_enroll.Where(q => q.num == id).FirstOrDefault();
if (prod != null)
{
_db.auto_enroll.Remove(prod);
_db.SaveChanges();
return Ok();
}
else return NotFound();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet]
[Route("api/follower/GetUnfilledActivityOrders/{id}")]
public IHttpActionResult GetUnfilledActivityOrders(int id, int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
try
{
var config = _db.auto_enroll.FirstOrDefault(x => x.num == id);
if (config == null) return NotFound();
var query = from o in _db.pro_order
join a in _db.activities on o.activity_num equals a.num
where o.f_num == config.f_num
&& a.startDate_solar >= config.start_date
&& a.startDate_solar <= config.end_date
&& !_db.pro_order_detail.Any(d => d.order_no == o.order_no)
select new { o, a };
int totalCount = query.Count();
var pagedData = query
.OrderByDescending(x => x.o.order_no)
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToList()
.Select(x => new {
order_no = x.o.order_no,
startdate = x.a.startDate_solar?.ToString("yyyy/MM/dd") ?? "",
enddate = x.a.endDate_solar?.ToString("yyyy/MM/dd") ?? "",
activityname = x.a.subject,
category = x.a.activity_category_kind?.kind ?? ""
});
return Ok(new
{
list = pagedData,
count = totalCount,
page = page,
pageSize = pageSize
});
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost]
[Route("api/follower/GetTabletList")]
@@ -733,5 +934,132 @@ public class FollowerController : ApiController
};
return Ok(data);
}
private void CreateOrdersForActivities(int f_num, int au_num, DateTime start_date, DateTime end_date, string receipt_title, string receipt_address)
{
var follower = _db.followers.Where(x => x.num == f_num).FirstOrDefault();
var activities = _db.activities
.Where(x =>
x.startDate_solar >= start_date &&
x.startDate_solar <= end_date
)
.ToList();
foreach (var activity in activities)
{
var existOrder = _db.pro_order
.Where(o => o.activity_num == activity.num && o.f_num == f_num)
.FirstOrDefault();
if (existOrder != null) {
existOrder.au_num = au_num;
_db.SaveChanges();
continue;
}
string newOrderNo = AutoOrderService.CreateAutoOrderNumber(_db);
string finalPhone = follower?.cellphone ?? follower?.phone ?? "";
var newOrder = new pro_order
{
order_no = newOrderNo,
up_time = DateTime.Now,
reg_time = DateTime.Now,
keyin1 = "A01",
f_num = f_num,
au_num = au_num,
phone = finalPhone,
address = string.IsNullOrEmpty(receipt_address) ? "" : receipt_address,
activity_num = activity.num,
receipt_title = receipt_title ?? "",
demo = "",
customize_data = "",
};
_db.pro_order.Add(newOrder);
// 抓取同活動分類的上一筆訂單,複製品項
var latestOrder = _db.pro_order
.Where(o =>
o.f_num == f_num &&
o.activity.kind == activity.kind &&
o.order_no != newOrderNo &&
_db.pro_order_detail.Any(d => d.order_no == o.order_no)
)
.OrderByDescending(o => o.order_no)
.FirstOrDefault();
if (latestOrder != null)
{
var prevDetails = _db.pro_order_detail
.Where(d => d.order_no == latestOrder.order_no)
.ToList();
foreach (var detail in prevDetails)
{
var newDetail = new pro_order_detail
{
order_no = newOrderNo,
actItem_num = detail.actItem_num,
parent_num = detail.parent_num,
print_id = detail.print_id,
f_num = detail.f_num,
f_num_tablet = detail.f_num_tablet,
address = detail.address,
from_id = detail.from_id,
from_id_tablet = detail.from_id_tablet,
bed_type = detail.bed_type,
qty = detail.qty,
price = detail.price,
start_date = DateTime.Today,
pay = detail.pay,
keyin1 = detail.keyin1,
demo = detail.demo,
customize_data = detail.customize_data,
printed_files = detail.printed_files,
UpdateTime = DateTime.Now,
};
_db.pro_order_detail.Add(newDetail);
}
}
}
_db.SaveChanges();
}
}
public static class AutoOrderService
{
private static readonly object _lock = new object();
public static string CreateAutoOrderNumber(Model.ezEntities _db)
{
lock (_lock)
{
string prefix = "AU" + DateTime.Now.ToString("yyMMdd");
var company = _db.companies.FirstOrDefault(q => q.num == 1);
if (company == null) return "";
string order_no;
if (!string.IsNullOrEmpty(company.last_auto_order_no) && company.last_auto_order_no.StartsWith(prefix))
{
string serialStr = company.last_auto_order_no.Replace(prefix, "");
int nextSerial = int.Parse(serialStr) + 1;
order_no = prefix + nextSerial.ToString("0000");
}
else
{
order_no = prefix + "0001";
}
company.last_auto_order_no = order_no;
_db.SaveChanges();
return order_no;
}
}
}
+140 -8
View File
@@ -803,7 +803,7 @@ public class activityController : ApiController
//已有值
var count = qry.Count(); //pageSize = count;//一次取回??
var qryList = (pageSize > 0) ? qry.OrderBy(a=>a.num).ToPagedList(page, pageSize).ToList() : qry.ToList();
var qryList = (pageSize > 0) ? qry.OrderBy(a => a.num).ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qryList.Select(x => new
@@ -959,10 +959,10 @@ public class activityController : ApiController
},
price = x.price ?? 0,
qty = x.qty ?? 0,
has_yang_limit = x.has_yang_limit?? false,
has_chao_limit = x.has_yang_limit?? false,
yang_limit_count = x.yang_limit_count?? 0,
chao_limit_count = x.chao_limit_count?? 0,
has_yang_limit = x.has_yang_limit ?? false,
has_chao_limit = x.has_yang_limit ?? false,
yang_limit_count = x.yang_limit_count ?? 0,
chao_limit_count = x.chao_limit_count ?? 0,
files = x.actItem?.actItem_files.Select(f => new
{
num = f.file.num,
@@ -1180,7 +1180,7 @@ public class activityController : ApiController
if (item.qty.HasValue) { _data.qty = item.qty.Value; }
else { _data.qty = null; }
_data.reg_time = DateTime.Now;
if (item.has_yang_limit.HasValue) { _data.has_yang_limit = item.has_yang_limit; }
if (item.has_yang_limit.HasValue) { _data.has_yang_limit = item.has_yang_limit; }
if (item.yang_limit_count >= 0) { _data.yang_limit_count = item.yang_limit_count.Value; }
if (item.has_chao_limit.HasValue) { _data.has_chao_limit = item.has_chao_limit; }
if (item.chao_limit_count >= 0) { _data.chao_limit_count = item.chao_limit_count.Value; }
@@ -1560,13 +1560,13 @@ public class activityController : ApiController
var r1 = qry.ToList();
var r2 = r1.Select(x => new { num = x.num, subject = x.subject });
var count = qry.Count();
// 計算昨天和今天的日期範圍
var yesterdayStart = _now.Date.AddDays(-1);
var yesterdayEnd = _now.Date;
var todayStart = _now.Date;
var todayEnd = _now.Date.AddDays(1);
var ret = new
{
list = r1.Select(x => new
@@ -1620,4 +1620,136 @@ public class activityController : ApiController
return Ok(ret);
}
[HttpGet]
[Route("api/activity/GetUnfilledOrdersByActivity/{num}")]
public IHttpActionResult GetUnfilledOrdersByActivity(int num)
{
try
{
var activityExists = _db.activities.Any(a => a.num == num);
if (!activityExists) return NotFound();
var query = from o in _db.pro_order
join f in _db.followers on o.f_num equals f.num into fg
from f in fg.DefaultIfEmpty()
where o.activity_num == num
&& !_db.pro_order_detail.Any(d => d.order_no == o.order_no)
select new { o, f };
MyWeb.encrypt encrypt = new MyWeb.encrypt();
var unfilledOrders = query.ToList().Select(x => new
{
order_no = x.o.order_no,
f_number = x.f.f_number,
u_name = x.f != null ? x.f.u_name : "未知",
phone = !string.IsNullOrEmpty(x.f.cellphone) ? encrypt.DecryptAutoKey(x.f.cellphone) : (encrypt.DecryptAutoKey(x.f.phone) ?? ""),
order_date = x.o.reg_time.HasValue ? x.o.reg_time.Value.ToString("yyyy/MM/dd") : "",
}).ToList();
return Ok(new
{
list = unfilledOrders,
count = unfilledOrders.Count
});
}
catch (Exception ex)
{
return InternalServerError(ex.GetBaseException());
}
}
[HttpPost]
[Route("api/activity/TriggerAutoEnroll/{activity_num}")]
public IHttpActionResult TriggerAutoEnroll(int activity_num)
{
try
{
var activity = _db.activities.FirstOrDefault(a => a.num == activity_num);
if (activity == null) return NotFound();
if (!activity.startDate_solar.HasValue) return BadRequest("該活動沒有設定開始日期,無法執行自動報名。");
DateTime actDate = activity.startDate_solar.Value;
var validConfigs = _db.auto_enroll
.Where(ae => actDate >= ae.start_date && actDate <= ae.end_date)
.ToList();
int successCount = 0;
foreach (var config in validConfigs)
{
if (_db.pro_order.Any(o => o.activity_num == activity_num && o.f_num == config.f_num))
continue;
var follower = _db.followers.FirstOrDefault(f => f.num == config.f_num);
string newOrderNo = AutoOrderService.CreateAutoOrderNumber(_db);
var newOrder = new pro_order
{
order_no = newOrderNo,
up_time = DateTime.Now,
reg_time = DateTime.Now,
keyin1 = "A01",
f_num = config.f_num,
au_num = config.num,
phone = follower?.cellphone ?? follower?.phone ?? "",
address = config.receipt_address ?? "",
activity_num = activity_num,
receipt_title = config.receipt_title ?? "",
demo = "系統於新增活動時自動報名",
};
_db.pro_order.Add(newOrder);
CopyLatestOrderDetails(newOrderNo, config.f_num, (int)activity.kind);
successCount++;
}
_db.SaveChanges();
return Ok(new
{
message = $"自動報名執行完畢,共為 {successCount} 位信眾完成報名。",
count = successCount
});
}
catch (Exception ex)
{
return InternalServerError(ex.GetBaseException());
}
}
private void CopyLatestOrderDetails(string newOrderNo, int f_num, int activityKind)
{
var latestOrder = _db.pro_order
.Where(o => o.f_num == f_num && o.activity.kind == activityKind && _db.pro_order_detail.Any(d => d.order_no == o.order_no))
.OrderByDescending(o => o.order_no)
.FirstOrDefault();
if (latestOrder != null)
{
var prevDetails = _db.pro_order_detail.Where(d => d.order_no == latestOrder.order_no).ToList();
foreach (var detail in prevDetails)
{
_db.pro_order_detail.Add(new pro_order_detail
{
order_no = newOrderNo,
actItem_num = detail.actItem_num,
parent_num = detail.parent_num,
print_id = detail.print_id,
f_num = detail.f_num,
f_num_tablet = detail.f_num_tablet,
address = detail.address,
from_id = detail.from_id,
from_id_tablet = detail.from_id_tablet,
qty = detail.qty,
price = detail.price,
start_date = DateTime.Today,
pay = 0,
UpdateTime = DateTime.Now
});
}
}
}
}
+1 -1
View File
@@ -383,7 +383,7 @@ public class orderController : ApiController
}
var tdesc = publicFun.enum_desc<Model.pro_order.detailKeyin1>();;
var tdesc = publicFun.enum_desc<Model.pro_order.detailKeyin1>();
int i = 1;
//已有值