| | |
| | | using Microsoft.AspNetCore.Hosting; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.IdentityModel.Tokens; |
| | | using Newtonsoft.Json; |
| | | using NPOI.HSSF.UserModel; |
| | | using NPOI.SS.UserModel; |
| | |
| | | IRow row = sheet.GetRow(i); |
| | | if (row == null) continue; // 跳过空行 |
| | | |
| | | |
| | | ICell cell0 = row.GetCell(0); |
| | | if (cell0 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "市不能为空"; |
| | | return jm; |
| | | } |
| | | hang.shi = getcellvalue(cell0); |
| | | |
| | | ICell cell1 = row.GetCell(1); |
| | | if (cell1 == null) |
| | | { |
| | | jm.msg ="第" +(i+1) + "学校不能为空"; |
| | | jm.msg = "第" + (i + 1) + "区县不能为空"; |
| | | return jm; |
| | | } |
| | | hang.shipAddress = getcellvalue(cell1); |
| | | hang.quxian = getcellvalue(cell1); |
| | | |
| | | ICell cell2 = row.GetCell(2); |
| | | if (cell2 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "联系人不能为空"; |
| | | jm.msg ="第" +(i+1) + "片区不能为空"; |
| | | return jm; |
| | | } |
| | | hang.shipName = getcellvalue(cell2); |
| | | hang.pianqu = getcellvalue(cell2); |
| | | |
| | | ICell cell3 = row.GetCell(3); |
| | | if (cell3 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "联系电话不能为空"; |
| | | jm.msg = "第" + (i + 1) + "学校不能为空"; |
| | | return jm; |
| | | } |
| | | hang.shipMobile = getcellvalue(cell3); |
| | | hang.shipAddress = getcellvalue(cell3); |
| | | |
| | | ICell cell4 = row.GetCell(4); |
| | | if (cell4 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "商品名称不能为空"; |
| | | jm.msg = "第" + (i + 1) + "联系人不能为空"; |
| | | return jm; |
| | | } |
| | | hang.name = getcellvalue(cell4); |
| | | hang.shipName = getcellvalue(cell4); |
| | | |
| | | ICell cell5 = row.GetCell(5); |
| | | if (cell5 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "规格不能为空"; |
| | | jm.msg = "第" + (i + 1) + "联系电话不能为空"; |
| | | return jm; |
| | | } |
| | | hang.specification = getcellvalue(cell5); |
| | | hang.shipMobile = getcellvalue(cell5); |
| | | |
| | | ICell cell6 = row.GetCell(6); |
| | | if (cell6 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "单价(元)不能为空"; |
| | | jm.msg = "第" + (i + 1) + "收货地址不能为空"; |
| | | return jm; |
| | | } |
| | | hang.price = decimal.Parse(getcellvalue(cell6)); |
| | | hang.shouhuoAddress = getcellvalue(cell6); |
| | | |
| | | ICell cell7 = row.GetCell(7); |
| | | if (cell7 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "商品名称不能为空"; |
| | | return jm; |
| | | } |
| | | hang.name = getcellvalue(cell7); |
| | | |
| | | ICell cell8 = row.GetCell(8); |
| | | if (cell8 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "规格不能为空"; |
| | | return jm; |
| | | } |
| | | hang.specification = getcellvalue(cell8); |
| | | |
| | | |
| | | ICell cell9 = row.GetCell(9); |
| | | if (cell9 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "单价(元)不能为空"; |
| | | return jm; |
| | | } |
| | | hang.price = decimal.Parse(getcellvalue(cell9)); |
| | | |
| | | |
| | | ICell cell10 = row.GetCell(10); |
| | | if (cell10 == null) |
| | | { |
| | | jm.msg = "第" + (i + 1) + "数量不能为空"; |
| | | return jm; |
| | | } |
| | | hang.nums = int.Parse(getcellvalue(cell7)); ; |
| | | hang.nums = int.Parse(getcellvalue(cell10)); |
| | | |
| | | lie.Add(hang); |
| | | |
| | | } |
| | | } |
| | | lie = lie.OrderBy(x => x.shipAddress).ThenBy(x => x.specification).ToList(); |
| | | // lie = lie.OrderBy(x => x.shipAddress).ThenBy(x => x.specification).ToList(); |
| | | string url = string.Empty; |
| | | url = "121212"; |
| | | |
| | | string pianqu = ""; |
| | | if (lie!=null && lie.Count > 0) |
| | | { |
| | | var order = new List<JiHuaOrder>(); |
| | |
| | | { |
| | | if (i == 0 ) |
| | | { |
| | | |
| | | order.Add(lie[i]); |
| | | pianqu = lie[i].pianqu; |
| | | //if(lie.Count == 1) |
| | | //{ |
| | | // //保存订单 |
| | |
| | | } |
| | | else |
| | | { |
| | | if(lie[i].shipAddress == lie[i - 1].shipAddress) |
| | | if(string.IsNullOrEmpty(lie[i].shipAddress)) |
| | | { |
| | | order.Add(lie[i]); |
| | | } |
| | | else |
| | | { |
| | | //保存订单 |
| | | jm = await _coreCmsPlanOrderServices.ToAddJiHua(lie, _user.ID, _user.Name); |
| | | jm = await _coreCmsPlanOrderServices.ToAddJiHua(order, _user.ID, _user.Name); |
| | | if (jm.code == 1) |
| | | { |
| | | return jm; |
| | | } |
| | | order = new List<JiHuaOrder>(); |
| | | if (string.IsNullOrEmpty(lie[i].shi)) |
| | | { |
| | | lie[i].shi = lie[0].shi; |
| | | } |
| | | if (string.IsNullOrEmpty(lie[i].quxian)) |
| | | { |
| | | lie[i].quxian = lie[0].quxian; |
| | | } |
| | | if (string.IsNullOrEmpty(lie[i].pianqu)) |
| | | { |
| | | lie[i].pianqu = pianqu; |
| | | } |
| | | else |
| | | { |
| | | pianqu = lie[i].pianqu; |
| | | } |
| | | order.Add(lie[i]); |
| | | } |
| | | } |
| | |
| | | if (i == lie.Count - 1) |
| | | { |
| | | //保存订单 |
| | | jm = await _coreCmsPlanOrderServices.ToAddJiHua(lie, _user.ID, _user.Name); |
| | | jm = await _coreCmsPlanOrderServices.ToAddJiHua(order, _user.ID, _user.Name); |
| | | if (jm.code == 1) |
| | | { |
| | | return jm; |