merge to main
This commit is contained in:
Generated
+1
-1
@@ -1,4 +1,4 @@
|
||||
// 已啟用模型 'D:\17168ERP\web\App_Code\Model\Model.edmx' 的 T4 程式碼產生。
|
||||
// 已啟用模型 'D:\merge\17168ERP\web\App_Code\Model\Model.edmx' 的 T4 程式碼產生。
|
||||
// 若要啟用舊版程式碼產生,請將 [程式碼產生策略] 設計工具屬性的值
|
||||
//變更為 [舊版 ObjectContext]。當模型在設計工具中開啟時,這個屬性便可
|
||||
//以在 [屬性] 視窗中使用。
|
||||
|
||||
@@ -599,7 +599,7 @@ public class orderController : ApiController
|
||||
//qry1 = qry1.Where(o => o.order_no == order_no);
|
||||
//var qry1 = prod.pro_order_detail.AsEnumerable();
|
||||
|
||||
var qry1 = prod.pro_order_detail.AsQueryable().include(o=>o.pro_order.activity.activity_relating);
|
||||
var qry1 = prod.pro_order_detail.AsQueryable().Include(o=>o.pro_order.activity.activity_relating);
|
||||
|
||||
|
||||
//if (!string.IsNullOrEmpty(q.subject))
|
||||
@@ -723,83 +723,7 @@ public class orderController : ApiController
|
||||
// c,
|
||||
// //pay_kind = tdesc2[c.payment.HasValue && x.keyin1.Value > 0 ? x.keyin1.Value : 1],
|
||||
//}),
|
||||
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++,
|
||||
num = x.num,
|
||||
order_no = x.order_no,
|
||||
actitem_num_selected = new
|
||||
{
|
||||
text = x.actItem_num.HasValue ? x.actItem.subject : "",
|
||||
val = x.actItem_num.HasValue ? x.actItem_num.Value : 0,
|
||||
},
|
||||
parent_num = x.parent_num,
|
||||
f_num_selected = new
|
||||
{
|
||||
text = x.f_num.HasValue ? x.follower.u_name : "",
|
||||
val = x.f_num.HasValue ? x.f_num.Value : 0,
|
||||
},
|
||||
f_num_tablet = x.f_num_tablet,
|
||||
print_id = x.print_id,
|
||||
address = x.address,
|
||||
due_date = x.due_date,
|
||||
start_date = x.start_date,
|
||||
extend_date = x.extend_date,
|
||||
from_id_selected = new
|
||||
{
|
||||
text = x.from_id.HasValue ? x.follower1.u_name : "",
|
||||
val = x.from_id.HasValue ? x.from_id : 0,
|
||||
},
|
||||
from_id_tablet = x.from_id_tablet,
|
||||
price = x.price ?? 0,
|
||||
qty = x.qty ?? 0,
|
||||
writeBedQty = bedDt.Where(b => b.bed_order.o_detail_id.Value == x.num && b.checkIn_date.HasValue && b.bed_kind_detail_id.HasValue).Count(), //已劃數量
|
||||
notBedQty = bedDt.Where(b => b.bed_order.o_detail_id.Value == x.num && (!b.checkIn_date.HasValue || !b.bed_kind_detail_id.HasValue)).Count(), //未劃數量
|
||||
//total = x.total.HasValue ? x.total.Value : 0,
|
||||
category = x.actItem?.category,
|
||||
//pay = x.pay ?? 0,
|
||||
pay = x.pro_order_record.Select(c => c.price).Sum(),
|
||||
pay_date = x.pay_date,
|
||||
keyin1_selected = new
|
||||
{
|
||||
text = tdesc[x.keyin1.HasValue && x.keyin1.Value > 0 ? x.keyin1.Value : 1],
|
||||
val = x.keyin1,
|
||||
},
|
||||
demo = x.demo,
|
||||
files = x.actItem?.actItem_files.Select(f => new
|
||||
{
|
||||
num = f.file.num,
|
||||
subject = f.file.subject,
|
||||
word = f.file.word,
|
||||
cuz_column = f.file.customize_data ?? "", //??
|
||||
paperset = f.file.paperset ?? "",
|
||||
}),
|
||||
customize_data = x.customize_data ?? "",
|
||||
customize_data_comb = new
|
||||
{
|
||||
from_id_cuz_data = "",
|
||||
activity_cuz_data = "",
|
||||
actitem_cuz_data = "",
|
||||
order_cuz_data = "",
|
||||
},
|
||||
printed_files = x.printed_files ?? "",
|
||||
isPackage = (x.actItem.act_bom
|
||||
.Any(ab => ab.package_num == null && ab.item_num != null)
|
||||
? 1 : 0),
|
||||
bom_order = (x.actItem.act_bom
|
||||
.Any(ab => ab.package_num == null && ab.item_num != null)
|
||||
? x.num.ToString()
|
||||
: (x.parent_num.ToString() + x.num.ToString())
|
||||
),
|
||||
//cash_record = x.pro_order_record.Select( c => new {
|
||||
// c,
|
||||
// //pay_kind = tdesc2[c.payment.HasValue && x.keyin1.Value > 0 ? x.keyin1.Value : 1],
|
||||
//}),
|
||||
|
||||
|
||||
};
|
||||
})
|
||||
|
||||
@@ -311,14 +311,14 @@ public partial class admin_activity_reg : MyWeb.config
|
||||
//var printInitValue = printInit.Text.Trim();
|
||||
//activity.print_init = !string.IsNullOrEmpty(printInitValue) ? printInitValue : null;
|
||||
activity.kind = Val(kind.Value);
|
||||
activity.category_kind = Val(category_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)
|
||||
int t_id = activity.num;
|
||||
if (t_id > 0)
|
||||
{
|
||||
RunAutoEnroll(_id);
|
||||
RunAutoEnroll(t_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);
|
||||
@@ -336,8 +336,8 @@ public partial class admin_activity_reg : MyWeb.config
|
||||
activity.reg_time = DateTime.Now;
|
||||
_db.activities.Add(activity);
|
||||
_db.SaveChanges();
|
||||
int _id = activity.num;
|
||||
if (_id > 0)
|
||||
t_id = activity.num;
|
||||
if (t_id > 0)
|
||||
{
|
||||
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);
|
||||
@@ -421,7 +421,7 @@ public partial class admin_activity_reg : MyWeb.config
|
||||
else
|
||||
{
|
||||
//activity.category_kind = Val(category_kind.Value);
|
||||
activity.category_kind = Val(category_kind.Value);
|
||||
//activity.category_kind = Val(category_kind.Value);
|
||||
_db.SaveChanges();
|
||||
|
||||
RunAutoEnroll(activity.num);
|
||||
@@ -524,84 +524,7 @@ private void RunAutoEnroll(int activityNum)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user