merge
This commit is contained in:
@@ -597,7 +597,7 @@ public class orderController : ApiController
|
|||||||
//var qry1 = _db.pro_order_detail.AsEnumerable();
|
//var qry1 = _db.pro_order_detail.AsEnumerable();
|
||||||
//qry1 = qry1.Where(o => o.order_no == order_no);
|
//qry1 = qry1.Where(o => o.order_no == order_no);
|
||||||
//var qry1 = prod.pro_order_detail.AsEnumerable();
|
//var qry1 = prod.pro_order_detail.AsEnumerable();
|
||||||
var qry1 = prod.pro_order_detail.AsQueryable();
|
var qry1 = prod.pro_order_detail.AsQueryable().include(o=>o.pro_order.activity.activity_relating);
|
||||||
|
|
||||||
//if (!string.IsNullOrEmpty(q.subject))
|
//if (!string.IsNullOrEmpty(q.subject))
|
||||||
// qry = qry.Where(o => o.subject.Contains(q.subject));
|
// qry = qry.Where(o => o.subject.Contains(q.subject));
|
||||||
@@ -638,13 +638,19 @@ public class orderController : ApiController
|
|||||||
|
|
||||||
var ret = new
|
var ret = new
|
||||||
{
|
{
|
||||||
list = qry1_list.Select(x => new
|
list = qry1_list.Select(x => {
|
||||||
|
var tmpActivityRelating = x.pro_order?.activity?.activity_relating?.Where(a => a.actItem_num == x.actItem_num).FirstOrDefault();
|
||||||
|
return new
|
||||||
{
|
{
|
||||||
|
has_yang_limit = tmpActivityRelating?.has_yang_limit ?? false,
|
||||||
|
has_chao_limit = tmpActivityRelating?.has_chao_limit ?? false,
|
||||||
|
yang_limit_count = tmpActivityRelating?.yang_limit_count ?? 0,
|
||||||
|
chao_limit_count = tmpActivityRelating?.chao_limit_count ?? 0,
|
||||||
id = i++,
|
id = i++,
|
||||||
num = x.num,
|
num = x.num,
|
||||||
order_no = x.order_no,
|
order_no = x.order_no,
|
||||||
actitem_num_selected = new
|
actitem_num_selected = new
|
||||||
{
|
{
|
||||||
text = x.actItem_num.HasValue ? x.actItem.subject : "",
|
text = x.actItem_num.HasValue ? x.actItem.subject : "",
|
||||||
val = x.actItem_num.HasValue ? x.actItem_num.Value : 0,
|
val = x.actItem_num.HasValue ? x.actItem_num.Value : 0,
|
||||||
},
|
},
|
||||||
@@ -758,6 +764,10 @@ public class orderController : ApiController
|
|||||||
text = ar.actItem.subject,
|
text = ar.actItem.subject,
|
||||||
val = ar.actItem_num,
|
val = ar.actItem_num,
|
||||||
},
|
},
|
||||||
|
has_yang_limit = ar.has_yang_limit ?? false,
|
||||||
|
has_chao_limit = ar.has_chao_limit ?? false,
|
||||||
|
yang_limit_count = ar.yang_limit_count ?? 0,
|
||||||
|
chao_limit_count = ar.chao_limit_count ?? 0,
|
||||||
parent_num = q.num,
|
parent_num = q.num,
|
||||||
f_num_selected = new
|
f_num_selected = new
|
||||||
{
|
{
|
||||||
@@ -838,6 +848,10 @@ public class orderController : ApiController
|
|||||||
text = x.actItem.subject,
|
text = x.actItem.subject,
|
||||||
val = x.actItem.num,
|
val = x.actItem.num,
|
||||||
},
|
},
|
||||||
|
has_yang_limit = x.has_yang_limit,
|
||||||
|
has_chao_limit = x.has_chao_limit,
|
||||||
|
yang_limit_count = x.yang_limit_count,
|
||||||
|
chao_limit_count = x.chao_limit_count,
|
||||||
f_num_selected = new
|
f_num_selected = new
|
||||||
{
|
{
|
||||||
text = "",
|
text = "",
|
||||||
@@ -922,8 +936,6 @@ public class orderController : ApiController
|
|||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
@@ -165,6 +165,8 @@
|
|||||||
{ text: '* 品項名稱', value: 'act_item_selected.text', sortable: false },
|
{ text: '* 品項名稱', value: 'act_item_selected.text', sortable: false },
|
||||||
{ text: '預設金額', value: 'price', sortable: false },
|
{ text: '預設金額', value: 'price', sortable: false },
|
||||||
{ text: '數量', value: 'qty', sortable: false },
|
{ text: '數量', value: 'qty', sortable: false },
|
||||||
|
{ text: '陽上/祈福人數限制', value: 'limit_yang', sortable: false },
|
||||||
|
{ text: '超渡人數限制', value: 'limit_chao', sortable: false },
|
||||||
{ text: '', value: 'actions', sortable: false, width: "200px" },
|
{ text: '', value: 'actions', sortable: false, width: "200px" },
|
||||||
],
|
],
|
||||||
footersDetail: {
|
footersDetail: {
|
||||||
@@ -191,6 +193,10 @@
|
|||||||
price: 0,
|
price: 0,
|
||||||
qty: 0,
|
qty: 0,
|
||||||
files: [],
|
files: [],
|
||||||
|
has_yang_limit: false,
|
||||||
|
has_chao_limit: false,
|
||||||
|
yang_limit_count: 0,
|
||||||
|
chao_limit_count: 0,
|
||||||
},
|
},
|
||||||
defaultItem: {
|
defaultItem: {
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -203,6 +209,10 @@
|
|||||||
price: 0,
|
price: 0,
|
||||||
qty: 0,
|
qty: 0,
|
||||||
files: [],
|
files: [],
|
||||||
|
has_yang_limit: false,
|
||||||
|
has_chao_limit: false,
|
||||||
|
yang_limit_count: 0,
|
||||||
|
chao_limit_count: 0,
|
||||||
},
|
},
|
||||||
//列印
|
//列印
|
||||||
data_table: {
|
data_table: {
|
||||||
@@ -267,10 +277,23 @@
|
|||||||
order_dialog: {
|
order_dialog: {
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
|
loading: false,
|
||||||
|
search: '',
|
||||||
|
headers: [
|
||||||
|
{ text: '訂單編號', value: 'order_no' },
|
||||||
|
{ text: '信眾編號', value: 'f_number' },
|
||||||
|
{ text: '信眾姓名', value: 'u_name' },
|
||||||
|
{ text: '聯絡電話', value: 'phone' },
|
||||||
|
{ text: '建立日期', value: 'order_date' },
|
||||||
|
],
|
||||||
|
items: [
|
||||||
|
{ order_no: "D", member_name: "S", order_date:"2025-12-07"}
|
||||||
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.search_dialog.current = this.search_dialog.controls.search1
|
this.search_dialog.current = this.search_dialog.controls.search1
|
||||||
|
this.loadUnfilledList();
|
||||||
//console.log("mounted");
|
//console.log("mounted");
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -482,6 +505,10 @@
|
|||||||
actItem_num: this.editedItem.act_item_selected.val,
|
actItem_num: this.editedItem.act_item_selected.val,
|
||||||
price: this.editedItem.price,
|
price: this.editedItem.price,
|
||||||
qty: this.editedItem.qty,
|
qty: this.editedItem.qty,
|
||||||
|
has_yang_limit: this.editedItem.has_yang_limit,
|
||||||
|
has_chao_limit: this.editedItem.has_chao_limit,
|
||||||
|
yang_limit_count: this.editedItem.yang_limit_count,
|
||||||
|
chao_limit_count: this.editedItem.chao_limit_count,
|
||||||
}
|
}
|
||||||
axios
|
axios
|
||||||
.post(HTTP_HOST + 'api/activity/SaveRelatingData', pro_order_detail)
|
.post(HTTP_HOST + 'api/activity/SaveRelatingData', pro_order_detail)
|
||||||
@@ -886,6 +913,113 @@
|
|||||||
const _date = $('#<%= startDate_solar.ClientID%>').val();
|
const _date = $('#<%= startDate_solar.ClientID%>').val();
|
||||||
return _subject + " " + _date;
|
return _subject + " " + _date;
|
||||||
},
|
},
|
||||||
|
loadUnfilledList() {
|
||||||
|
if (!this.this_id) return;
|
||||||
|
|
||||||
|
this.unfilled_list.loading = true;
|
||||||
|
|
||||||
|
axios.get(HTTP_HOST + 'api/activity/GetUnfilledOrdersByActivity/' + this.this_id)
|
||||||
|
.then(response => {
|
||||||
|
this.unfilled_list.items = response.data.list || [];
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
this.snackbar.text = "名單載入失敗:" + error;
|
||||||
|
this.snackbar.show = true;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.unfilled_list.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async printUnfilledList() {
|
||||||
|
if (!this.this_id) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await axios.get(
|
||||||
|
HTTP_HOST + `api/activity/GetUnfilledOrdersByActivity/${this.this_id}`,
|
||||||
|
{ params: { page: 1, pageSize: 99999 } }
|
||||||
|
);
|
||||||
|
|
||||||
|
const allItems = response.data.list || [];
|
||||||
|
|
||||||
|
if (allItems.length === 0) {
|
||||||
|
this.snackbar.text = "目前沒有未填寫品項的資料可供列印!";
|
||||||
|
this.snackbar.show = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const activityTitle = this.titleword();
|
||||||
|
|
||||||
|
const rows = allItems.map(item => `
|
||||||
|
<tr>
|
||||||
|
<td>${item.order_no}</td>
|
||||||
|
<td>${item.f_number || ''}</td>
|
||||||
|
<td>${item.u_name}</td>
|
||||||
|
<td>${item.phone}</td>
|
||||||
|
<td>${item.order_date}</td>
|
||||||
|
</tr>
|
||||||
|
`).join('');
|
||||||
|
|
||||||
|
const win = window.open('', '_blank');
|
||||||
|
win.document.write(`
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>未填寫品項名單 - ${activityTitle}</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: "Microsoft JhengHei", Arial, sans-serif; padding: 20px; color: #000; }
|
||||||
|
.header-container { text-align: center; margin-bottom: 30px; }
|
||||||
|
h2 { margin-bottom: 5px; font-size: 24px; }
|
||||||
|
h4 { margin-top: 0; color: #333; font-weight: normal; }
|
||||||
|
table { width: 100%; border-collapse: collapse; }
|
||||||
|
th, td { border: 1px solid #000; padding: 10px 8px; text-align: left; font-size: 14px; }
|
||||||
|
th { background-color: #eee; font-weight: bold; }
|
||||||
|
.text-center { text-align: center; }
|
||||||
|
@media print {
|
||||||
|
@page { margin: 1.5cm; }
|
||||||
|
button { display: none; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header-container">
|
||||||
|
<h2>尚未報名品項之信眾清單</h2>
|
||||||
|
<h4>活動名稱:${activityTitle}</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th width="18%">訂單編號</th>
|
||||||
|
<th width="15%">信眾編號</th>
|
||||||
|
<th width="20%">信眾姓名</th>
|
||||||
|
<th width="20%">聯絡電話</th>
|
||||||
|
<th width="27%">建單日期</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>${rows}</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div style="margin-top: 20px; text-align: right; font-size: 12px;">
|
||||||
|
列印時間:${new Date().toLocaleString()}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`);
|
||||||
|
|
||||||
|
win.document.close();
|
||||||
|
|
||||||
|
// 確保內容載入完成後再呼叫列印
|
||||||
|
setTimeout(() => {
|
||||||
|
win.print();
|
||||||
|
win.close();
|
||||||
|
}, 300);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error("列印出錯:", error);
|
||||||
|
this.snackbar.text = "讀取列印資料失敗:" + error;
|
||||||
|
this.snackbar.show = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
},
|
},
|
||||||
@@ -925,6 +1059,10 @@
|
|||||||
<%-- <button v-if="this_id!=''" class="nav-link" id="sec2-tab3" data-bs-toggle="tab" data-bs-target="#sec2-page3"
|
<%-- <button v-if="this_id!=''" class="nav-link" id="sec2-tab3" data-bs-toggle="tab" data-bs-target="#sec2-page3"
|
||||||
type="button" role="tab" aria-controls="profile" aria-selected="false">
|
type="button" role="tab" aria-controls="profile" aria-selected="false">
|
||||||
備品項目</button>--%>
|
備品項目</button>--%>
|
||||||
|
<button v-if="this_id!=''" class="nav-link" id="sec2-tab4" data-bs-toggle="tab" data-bs-target="#sec2-page4"
|
||||||
|
type="button" role="tab" aria-controls="profile" aria-selected="false" @click="loadUnfilledList">
|
||||||
|
未填寫名單
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -1098,6 +1236,53 @@
|
|||||||
<v-text-field v-model="editedItem.qty" :hide-details="true" dense single-line v-if="item.id === editedItem.id" ></v-text-field>
|
<v-text-field v-model="editedItem.qty" :hide-details="true" dense single-line v-if="item.id === editedItem.id" ></v-text-field>
|
||||||
<span v-else>{{item.qty}}</span>
|
<span v-else>{{item.qty}}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:item.limit_yang="{ item }">
|
||||||
|
<div class="d-flex align-center">
|
||||||
|
<v-text-field v-model="editedItem.yang_limit_count" v-if="item.id === editedItem.id"
|
||||||
|
type="number"
|
||||||
|
dense
|
||||||
|
:hide-details="true"
|
||||||
|
single-line
|
||||||
|
:disabled="!editedItem.has_yang_limit"
|
||||||
|
suffix="人" >
|
||||||
|
</v-text-field>
|
||||||
|
<v-checkbox v-if="item.id === editedItem.id"
|
||||||
|
v-model="editedItem.has_yang_limit"
|
||||||
|
label="不限"
|
||||||
|
hide-details
|
||||||
|
class="ml-2 mt-0"
|
||||||
|
:true-value="false"
|
||||||
|
:false-value="true"
|
||||||
|
:disabled="item.id !== editedItem.id">
|
||||||
|
</v-checkbox>
|
||||||
|
<span v-if="item.id !== editedItem.id && !item.has_yang_limit">不限</span>
|
||||||
|
<span v-if="item.id !== editedItem.id && item.has_yang_limit">{{item.yang_limit_count}} 人</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-slot:item.limit_chao="{ item }">
|
||||||
|
<div class="d-flex align-center">
|
||||||
|
<v-text-field v-model="editedItem.chao_limit_count" v-if="item.id === editedItem.id"
|
||||||
|
type="number"
|
||||||
|
dense
|
||||||
|
:hide-details="true"
|
||||||
|
single-line
|
||||||
|
:disabled="!editedItem.has_chao_limit"
|
||||||
|
suffix="人" >
|
||||||
|
</v-text-field>
|
||||||
|
<v-checkbox v-if="item.id === editedItem.id"
|
||||||
|
v-model="editedItem.has_chao_limit"
|
||||||
|
label="不限"
|
||||||
|
hide-details
|
||||||
|
class="ml-2 mt-0"
|
||||||
|
:true-value="false"
|
||||||
|
:false-value="true"
|
||||||
|
:disabled="item.id !== editedItem.id">
|
||||||
|
</v-checkbox>
|
||||||
|
<span v-if="item.id !== editedItem.id && !item.has_chao_limit">不限</span>
|
||||||
|
<span v-if="item.id !== editedItem.id && item.has_chao_limit">{{item.chao_limit_count}} 人</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<template v-slot:item.actions="{ item }">
|
<template v-slot:item.actions="{ item }">
|
||||||
<template v-if="item.id === editedItem.id">
|
<template v-if="item.id === editedItem.id">
|
||||||
<v-icon color="red" class="mr-2" @click="cancel">
|
<v-icon color="red" class="mr-2" @click="cancel">
|
||||||
@@ -1207,6 +1392,41 @@
|
|||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane fade" id="sec2-page4" role="tabpanel" aria-labelledby="sec2-tab4" v-if="this_id!=''">
|
||||||
|
<v-card class="mx-auto" outlined id="print-unfilled-area">
|
||||||
|
<v-data-table
|
||||||
|
:headers="unfilled_list.headers"
|
||||||
|
:items="unfilled_list.items"
|
||||||
|
:loading="unfilled_list.loading"
|
||||||
|
:search="unfilled_list.search"
|
||||||
|
class="elevation-1"
|
||||||
|
fixed-header
|
||||||
|
height="350px">
|
||||||
|
|
||||||
|
<template v-slot:top>
|
||||||
|
<v-toolbar flat color="white" class="d-print-none">
|
||||||
|
<div class="d-flex w-100">
|
||||||
|
<v-text-field
|
||||||
|
v-model="unfilled_list.search"
|
||||||
|
append-icon="mdi-magnify"
|
||||||
|
label="搜尋姓名或訂單號"
|
||||||
|
dense outlined single-line hide-details>
|
||||||
|
</v-text-field>
|
||||||
|
<v-btn color="primary" class="ml-2 white--text" @click="printUnfilledList">
|
||||||
|
<v-icon left>mdi-printer</v-icon>列印所有名單
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</v-toolbar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:item.status="{ item }">
|
||||||
|
<v-chip small color="error">未選品項</v-chip>
|
||||||
|
</template>
|
||||||
|
</v-data-table>
|
||||||
|
</v-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</asp:Panel>
|
</asp:Panel>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -235,7 +235,36 @@ public partial class admin_activity_reg : MyWeb.config
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 資料新增
|
#region 資料新增
|
||||||
|
protected string createOrderNumber()
|
||||||
|
{
|
||||||
|
Application.Lock();
|
||||||
|
string order_no = "AA" + DateTime.Now.ToString("yyMMdd");
|
||||||
|
|
||||||
|
var qry = _db.companies.AsQueryable();
|
||||||
|
//var prod = qry.Where(q => q.last_order_no.Contains(order_no)).FirstOrDefault();
|
||||||
|
var prod = qry.Where(q => q.num == 1).FirstOrDefault();
|
||||||
|
if (prod != null)
|
||||||
|
{
|
||||||
|
if (!isStrNull(prod.last_order_no) && prod.last_order_no.Contains(order_no))
|
||||||
|
{
|
||||||
|
int tmp = Convert.ToInt32(prod.last_order_no.Replace(order_no, "")) + 1;
|
||||||
|
order_no = order_no + tmp.ToString("0000");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
order_no = order_no + "0001";
|
||||||
|
}
|
||||||
|
|
||||||
|
prod.last_order_no = order_no;
|
||||||
|
_db.SaveChanges();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
order_no = "";
|
||||||
|
|
||||||
|
Application.UnLock();
|
||||||
|
|
||||||
|
return order_no;
|
||||||
|
}
|
||||||
protected void add_Click(object sender, EventArgs e)
|
protected void add_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Page.IsValid) {
|
if (Page.IsValid) {
|
||||||
@@ -281,7 +310,21 @@ public partial class admin_activity_reg : MyWeb.config
|
|||||||
// printInit 欄位
|
// printInit 欄位
|
||||||
//var printInitValue = printInit.Text.Trim();
|
//var printInitValue = printInit.Text.Trim();
|
||||||
//activity.print_init = !string.IsNullOrEmpty(printInitValue) ? printInitValue : null;
|
//activity.print_init = !string.IsNullOrEmpty(printInitValue) ? printInitValue : null;
|
||||||
if (activity.startDate_solar == null || activity.endDate_solar == null)
|
activity.kind = Val(kind.Value);
|
||||||
|
activity.category_kind = Val(category_kind.Value);
|
||||||
|
activity.reg_time = DateTime.Now;
|
||||||
|
_db.activities.Add(activity);
|
||||||
|
_db.SaveChanges();
|
||||||
|
int _id = activity.num;
|
||||||
|
if (_id > 0)
|
||||||
|
{
|
||||||
|
RunAutoEnroll(_id);
|
||||||
|
|
||||||
|
Model.admin_log admin_log = new Model.admin_log();
|
||||||
|
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Insert, subject.Text);
|
||||||
|
Response.Redirect("index.aspx");
|
||||||
|
}
|
||||||
|
else if (activity.startDate_solar == null || activity.endDate_solar == null)
|
||||||
{
|
{
|
||||||
L_msg.Type = alert_type.danger;
|
L_msg.Type = alert_type.danger;
|
||||||
L_msg.Text = "開始、結束日期必須填寫";
|
L_msg.Text = "開始、結束日期必須填寫";
|
||||||
@@ -378,8 +421,11 @@ public partial class admin_activity_reg : MyWeb.config
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//activity.category_kind = Val(category_kind.Value);
|
//activity.category_kind = Val(category_kind.Value);
|
||||||
|
activity.category_kind = Val(category_kind.Value);
|
||||||
_db.SaveChanges();
|
_db.SaveChanges();
|
||||||
|
|
||||||
|
RunAutoEnroll(activity.num);
|
||||||
|
|
||||||
Model.admin_log admin_log = new Model.admin_log();
|
Model.admin_log admin_log = new Model.admin_log();
|
||||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Update, subject.Text);
|
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Update, subject.Text);
|
||||||
}
|
}
|
||||||
@@ -399,6 +445,84 @@ public partial class admin_activity_reg : MyWeb.config
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void RunAutoEnroll(int activityNum)
|
||||||
|
{
|
||||||
|
var activity = _db.activities.FirstOrDefault(a => a.num == activityNum);
|
||||||
|
if (activity == null || !activity.startDate_solar.HasValue) return;
|
||||||
|
|
||||||
|
DateTime actDate = activity.startDate_solar.Value;
|
||||||
|
|
||||||
|
var validConfigs = _db.auto_enroll
|
||||||
|
.Where(ae => actDate >= ae.start_date && actDate <= ae.end_date)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
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);
|
||||||
|
if (follower == null) continue;
|
||||||
|
|
||||||
|
string newOrderNo = AutoOrderService.CreateAutoOrderNumber(_db);
|
||||||
|
|
||||||
|
Model.pro_order proOrder = new Model.pro_order
|
||||||
|
{
|
||||||
|
order_no = newOrderNo,
|
||||||
|
up_time = DateTime.Now,
|
||||||
|
reg_time = DateTime.Now,
|
||||||
|
keyin1 = "A01",
|
||||||
|
f_num = follower.num,
|
||||||
|
au_num = config.num,
|
||||||
|
phone = !string.IsNullOrEmpty(follower.cellphone) ? follower.cellphone : (follower.phone ?? ""),
|
||||||
|
activity_num = activity.num,
|
||||||
|
address = config.receipt_address ?? "",
|
||||||
|
receipt_title = config.receipt_title ?? "",
|
||||||
|
demo = "",
|
||||||
|
customize_data = ""
|
||||||
|
};
|
||||||
|
|
||||||
|
_db.pro_order.Add(proOrder);
|
||||||
|
|
||||||
|
CopyLatestOrderDetails(newOrderNo, config.f_num, (int)activity.kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
_db.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
Model.pro_order_detail newDetail = new Model.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
|
||||||
|
};
|
||||||
|
_db.pro_order_detail.Add(newDetail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user