快速報名
This commit is contained in:
@@ -41,6 +41,8 @@ namespace Model.ViewModel
|
||||
public string country { get; set; }
|
||||
public string country2 { get; set; }
|
||||
|
||||
public List<pro_order_detail> details { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class pro_order_detail
|
||||
|
||||
@@ -138,10 +138,109 @@ public class FollowerController : ApiController
|
||||
return count;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/follower/GetFollowerNew")]
|
||||
public IHttpActionResult GetFollowerNew([FromBody] Model.ViewModel.follower q)
|
||||
{
|
||||
|
||||
////var qry = _db.followers.Where(a => a.IsDel == false).AsQueryable();////不確定是否新增欄位? 先註解
|
||||
var qry = _db.followers.AsQueryable();
|
||||
|
||||
if (!string.IsNullOrEmpty(q.f_number))
|
||||
qry = qry.Where(o => o.f_number.Contains(q.f_number.Trim()));
|
||||
if (!string.IsNullOrEmpty(q.u_name))
|
||||
qry = qry.Where(o => o.u_name.Contains(q.u_name.Trim()));
|
||||
if (q.birthday.HasValue)
|
||||
qry = qry.Where(o => o.birthday >= q.birthday.Value);
|
||||
if (q.birthday2.HasValue)
|
||||
{
|
||||
var tmpBirthday2 = Convert.ToDateTime(q.birthday2.Value).AddDays(1);
|
||||
qry = qry.Where(o => o.birthday < tmpBirthday2);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(q.address))
|
||||
qry = qry.Where(o => o.address != null && o.address.Contains(q.address.Trim()));
|
||||
//if (q.num.HasValue && q.num.Value>0)
|
||||
// qry = qry.Where(o => o.num==q.num.Value);
|
||||
if (q.ept_self.HasValue && q.ept_self.Value)//排除自己
|
||||
{
|
||||
qry = qry.Where(o => o.num != q.num.Value);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(q.country))
|
||||
qry = qry.Where(o => o.country == q.country);
|
||||
if (!string.IsNullOrEmpty(q.country2))
|
||||
{
|
||||
if (q.country2 == "1")
|
||||
{
|
||||
qry = qry.Where(o => o.country == "158");
|
||||
}
|
||||
else if (q.country2 == "2")
|
||||
{
|
||||
qry = qry.Where(o => o.country != "158");
|
||||
|
||||
}
|
||||
}
|
||||
//if (!string.IsNullOrEmpty(q.phone_idcode)){
|
||||
// MyWeb.encrypt enc = new MyWeb.encrypt();
|
||||
// qry = qry.Where(o => o.phone ==enc.DecryptAutoKey(q.phone_idcode) || o.cellphone==enc.DecryptAutoKey(q.phone_idcode));
|
||||
//}
|
||||
|
||||
// 電話/證號搜尋 (使用 search_keywords HEX 編碼)
|
||||
if (!string.IsNullOrEmpty(q.phone_idcode) && GlobalVariables.UseSearchKeywords)
|
||||
{
|
||||
MyWeb.encrypt enc = new MyWeb.encrypt();
|
||||
string hexSearch = enc.ConvertToHex(q.phone_idcode.Trim());
|
||||
if (!string.IsNullOrEmpty(hexSearch))
|
||||
{
|
||||
qry = qry.Where(o => o.search_keywords != null && o.search_keywords.Contains(hexSearch));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MyWeb.encrypt encrypt = new MyWeb.encrypt();
|
||||
|
||||
var tdesc = publicFun.enum_desc<Model.follower.type>();
|
||||
var ret = new
|
||||
{
|
||||
list = qry.AsEnumerable().Select(x => new
|
||||
{
|
||||
num = x.num,
|
||||
f_number = x.f_number,
|
||||
u_name = x.u_name,
|
||||
sex = x.sex,
|
||||
birthday = x.birthday, //?.ToString("yyyy/MM/dd"),
|
||||
birthday2 = publicFun.chagenDate(x.birthday), //?.ToString("yyyy/MM/dd"),
|
||||
sign = Model.follower.chagenSign(x.birthday), //NULL??
|
||||
sexagenary = Model.follower.sexagenary(x.birthday),
|
||||
identity_type = x.identity_type,
|
||||
identity_type_desc = tdesc[x.identity_type ?? 1],//TryGetValue..
|
||||
id_code = x.id_code,
|
||||
id_codeDes = encrypt.DecryptAutoKey(x.id_code),
|
||||
passport = x.passport,
|
||||
passportDes = encrypt.DecryptAutoKey(x.passport),
|
||||
phone = x.phone,
|
||||
phoneDes = encrypt.DecryptAutoKey(x.phone), //--MyWeb.function X
|
||||
refugedate = x.refugedate,
|
||||
refuge_name = x.refuge_name,
|
||||
email = x.email,
|
||||
address = x.address,
|
||||
cellphone = x.cellphone,
|
||||
cellphoneDes = encrypt.DecryptAutoKey(x.cellphone),
|
||||
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
|
||||
if (ret.list == null) {
|
||||
return Ok(new {result="N",message="查無信眾"});
|
||||
} //throw new HttpResponseException(HttpStatusCode);
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/follower/GetFollower")]
|
||||
public IHttpActionResult GetFollower([FromBody] Model.ViewModel.follower q)
|
||||
{
|
||||
|
||||
////var qry = _db.followers.Where(a => a.IsDel == false).AsQueryable();////不確定是否新增欄位? 先註解
|
||||
var qry = _db.followers.AsQueryable();
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ public class orderController : ApiController
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HttpPost,HttpGet]
|
||||
[Route("api/order/GetItemList")]
|
||||
public IHttpActionResult GetItemList([FromBody] Model.ViewModel.pro_order_detail q, int page, int pageSize = 10,
|
||||
string sortBy = "", bool sortDesc = false)
|
||||
@@ -680,7 +680,109 @@ public class orderController : ApiController
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/order/SaveWithDetails")]
|
||||
public IHttpActionResult SaveWithDetails([FromBody] Model.ViewModel.pro_order item)
|
||||
{
|
||||
try
|
||||
{
|
||||
MyWeb.encrypt encrypt = new MyWeb.encrypt();
|
||||
Model.pro_order new_pro_order = new Model.pro_order();//新增
|
||||
|
||||
new_pro_order.order_no = createOrderNumber();
|
||||
var details = item.details;
|
||||
var last_order_no = details[0].order_no;
|
||||
//撈前次報名的資料塞進去
|
||||
var last_order = _db.pro_order.Where(x => x.order_no == last_order_no).FirstOrDefault();
|
||||
if (last_order != null)
|
||||
{
|
||||
new_pro_order.up_time = DateTime.Now;
|
||||
new_pro_order.reg_time = DateTime.Now;
|
||||
new_pro_order.phone = last_order.phone;
|
||||
new_pro_order.address = last_order.address;
|
||||
new_pro_order.keyin1 = last_order.keyin1;
|
||||
new_pro_order.f_num = item.f_num;
|
||||
new_pro_order.activity_num = item.activity_num;
|
||||
new_pro_order.demo = last_order.demo;
|
||||
new_pro_order.customize_data = last_order.customize_data;
|
||||
new_pro_order.send_receipt = last_order.send_receipt;
|
||||
new_pro_order.receipt_title = last_order.receipt_title;
|
||||
_db.pro_order.Add(new_pro_order);
|
||||
|
||||
|
||||
foreach (var item1 in details)
|
||||
{
|
||||
var last_detail = _db.pro_order_detail.Where(x => x.num == item1.num).FirstOrDefault();
|
||||
var detail = new pro_order_detail();
|
||||
detail.order_no = new_pro_order.order_no;
|
||||
detail.actItem_num = last_detail.actItem_num;
|
||||
detail.f_num_tablet = last_detail.f_num_tablet;
|
||||
detail.from_id = last_detail.from_id;
|
||||
detail.price = last_detail.price;
|
||||
detail.qty = last_detail.qty;
|
||||
detail.printed_files = last_detail.printed_files;
|
||||
detail.style = last_detail.style;
|
||||
detail.UpdateTime = DateTime.Now;
|
||||
detail.start_date = DateTime.Now;//這兩個要用活動的
|
||||
detail.due_date = DateTime.Now;//
|
||||
_db.pro_order_detail.Add(detail);
|
||||
}
|
||||
_db.SaveChanges();
|
||||
return Ok(new
|
||||
{
|
||||
result = "Y",
|
||||
message = "報名成功"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
result = "N",
|
||||
message = "沒有勾選任何功德項目"
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
result = "N",
|
||||
message = ex.Message+ex.InnerException+ex.StackTrace
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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 (!string.IsNullOrEmpty(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;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/order/SaveDetailData")]
|
||||
|
||||
Reference in New Issue
Block a user