|
|
@@ -80,13 +80,15 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
80
|
80
|
modelOrder.F_Stock = input.F_Stock;
|
|
81
|
81
|
modelOrder.F_Remark = input.F_Remark;
|
|
82
|
82
|
|
|
|
83
|
+ modelOrder.F_RealPrice = input.F_RealPrice;
|
|
|
84
|
+
|
|
83
|
85
|
//选填 关联属性
|
|
84
|
86
|
modelOrder.F_VipId = input.F_VipId;
|
|
85
|
87
|
|
|
86
|
88
|
modelOrder.F_Type = input.F_Type;
|
|
87
|
89
|
modelOrder.F_State = input.F_State;
|
|
88
|
90
|
modelOrder.F_Status = input.F_Status;
|
|
89
|
|
- modelOrder.F_UseActivity = input.F_UseActivity;
|
|
|
91
|
+
|
|
90
|
92
|
//必须属性 系统生成
|
|
91
|
93
|
modelOrder.F_AddTime = DateTime.Now;
|
|
92
|
94
|
modelOrder.F_AddUser = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid).Value, 0);
|
|
|
@@ -95,35 +97,87 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
95
|
97
|
//计算属性 商品计算
|
|
96
|
98
|
decimal F_Score = 0.00M;
|
|
97
|
99
|
decimal totle = 0.00M;
|
|
98
|
|
- decimal F_ShouldPrice = 0.00M;
|
|
99
|
|
- decimal F_RealPrice = 0.00M;
|
|
|
100
|
+ decimal ActivityMoney = 0.00M;
|
|
|
101
|
+ string UseActivity = "";
|
|
|
102
|
+ string UseActivity4 = ",";
|
|
100
|
103
|
List<T_Bus_OrderDetail> modelDetailList = new List<T_Bus_OrderDetail>();
|
|
101
|
|
- if (input.OrderDetail != null && input.OrderDetail.Count > 0)
|
|
|
104
|
+
|
|
|
105
|
+
|
|
|
106
|
+ modelOrder.F_UseActivity = input.F_UseActivity;
|
|
|
107
|
+
|
|
|
108
|
+ if (input.OrderDetailList != null && input.OrderDetailList.Count > 0)
|
|
102
|
109
|
{
|
|
103
|
110
|
int n = 1;
|
|
104
|
|
- foreach (OrderDetailInput m in input.OrderDetail)
|
|
|
111
|
+ int n2 = input.OrderDetailList.Count + 1;
|
|
|
112
|
+ if (input.UseActList != null && input.UseActList.Count > 0)
|
|
|
113
|
+ {
|
|
|
114
|
+ //遍历所有选中的活动
|
|
|
115
|
+ foreach (UseActInput act in input.UseActList)
|
|
|
116
|
+ {
|
|
|
117
|
+ UseActivity += act + ",";
|
|
|
118
|
+ //满赠,生日赠
|
|
|
119
|
+ if (act.type == 1 || act.type == 2)
|
|
|
120
|
+ {
|
|
|
121
|
+ T_Bus_Product m = await bus_productRepository.GetSingle(b => b.F_ProductId == act.gift.ObjToInt()); ;
|
|
|
122
|
+
|
|
|
123
|
+ T_Bus_OrderDetail modelDetail = new T_Bus_OrderDetail();
|
|
|
124
|
+ modelDetail.F_ProductName = m.F_ProductName;
|
|
|
125
|
+ modelDetail.F_ProductId = m.F_ProductId;
|
|
|
126
|
+ modelDetail.F_Id = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
127
|
+ modelDetail.F_OrderId = input.F_Id;
|
|
|
128
|
+ modelDetail.F_Count = 1;
|
|
|
129
|
+ modelDetail.F_Price = 0.00M;
|
|
|
130
|
+ modelDetail.F_DealPrice = 0.00M;
|
|
|
131
|
+ modelDetail.F_Sort = n2;
|
|
|
132
|
+ modelDetail.F_Remark = "赠品-活动:" + act.id;
|
|
|
133
|
+ modelDetail.F_AddUser = modelOrder.F_AddUser;
|
|
|
134
|
+ modelDetail.F_AddUserName = modelOrder.F_AddUserName;
|
|
|
135
|
+ modelDetail.F_TotlePrice = 0.00M;
|
|
|
136
|
+ modelDetail.F_Activity = act.id;
|
|
|
137
|
+
|
|
|
138
|
+ modelDetailList.Add(modelDetail);
|
|
|
139
|
+
|
|
|
140
|
+ n2++;
|
|
|
141
|
+ }
|
|
|
142
|
+ //满减
|
|
|
143
|
+ else if (act.type == 3)
|
|
|
144
|
+ {
|
|
|
145
|
+ ActivityMoney += act.money;
|
|
|
146
|
+ }
|
|
|
147
|
+ else if (act.type == 4)
|
|
|
148
|
+ {
|
|
|
149
|
+ UseActivity4 += act.gift + ",";
|
|
|
150
|
+ }
|
|
|
151
|
+ }
|
|
|
152
|
+ UseActivity = UseActivity.Trim(',');
|
|
|
153
|
+ }
|
|
|
154
|
+ foreach (OrderDetailInput m in input.OrderDetailList)
|
|
105
|
155
|
{
|
|
106
|
|
- T_Bus_Product modelProduct=await bus_productRepository.GetSingle(b => b.F_ProductId == m.F_ProductId);
|
|
|
156
|
+ T_Bus_Product modelProduct = await bus_productRepository.GetSingle(b => b.F_ProductId == m.F_ProductId);
|
|
107
|
157
|
|
|
108
|
158
|
T_Bus_OrderDetail modelDetail = new T_Bus_OrderDetail();
|
|
109
|
|
- modelDetail.F_ProductName = m.F_ProductName;
|
|
110
|
|
- modelDetail.F_ProductId = m.F_ProductId;
|
|
|
159
|
+ modelDetail.F_ProductName = modelProduct.F_ProductName;
|
|
|
160
|
+ modelDetail.F_ProductId = modelProduct.F_ProductId;
|
|
111
|
161
|
modelDetail.F_Id = Guid.NewGuid().ToString().Replace("-", "");
|
|
112
|
162
|
modelDetail.F_OrderId = input.F_Id;
|
|
113
|
163
|
modelDetail.F_Count = m.F_Count;
|
|
114
|
|
- modelDetail.F_Price = m.F_Price;
|
|
115
|
|
- modelDetail.F_DealPrice = m.F_DealPrice;
|
|
|
164
|
+ modelDetail.F_Price = modelProduct.F_MemberPrice;
|
|
|
165
|
+ //参加活动特价
|
|
|
166
|
+ if (UseActivity4.Contains("," + modelProduct.F_ProductId + ","))
|
|
|
167
|
+ modelDetail.F_DealPrice = modelProduct.F_SpecialPrice;
|
|
|
168
|
+ else
|
|
|
169
|
+ modelDetail.F_DealPrice = modelProduct.F_MemberPrice;
|
|
116
|
170
|
modelDetail.F_Sort = n;
|
|
117
|
171
|
modelDetail.F_Remark = m.F_Remark;
|
|
118
|
172
|
modelDetail.F_AddUser = modelOrder.F_AddUser;
|
|
119
|
173
|
modelDetail.F_AddUserName = modelOrder.F_AddUserName;
|
|
120
|
174
|
modelDetail.F_TotlePrice = modelDetail.F_DealPrice * modelDetail.F_Count;
|
|
121
|
|
- modelDetail.F_Activity = 0;
|
|
|
175
|
+ modelDetail.F_Activity = 0;
|
|
122
|
176
|
//是否有活动标签
|
|
123
|
177
|
if (m.Tags.IndexOf(".") > -1)
|
|
124
|
178
|
{
|
|
125
|
179
|
string[] tagarry = m.Tags.Split(',');
|
|
126
|
|
- string tag=tagarry.First(a => a.StartsWith(".")).ToString();
|
|
|
180
|
+ string tag = tagarry.First(a => a.StartsWith(".")).ToString();
|
|
127
|
181
|
T_Sys_Marketing modelactive = await bus_MarketingRepository.GetSingle(b => string.Format(",{0},", b.F_Commodity).Contains(string.Format(",{0},", tag)));
|
|
128
|
182
|
|
|
129
|
183
|
//此商品参加活动
|
|
|
@@ -132,44 +186,35 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
132
|
186
|
modelDetail.F_Activity = modelactive.F_ID;
|
|
133
|
187
|
}
|
|
134
|
188
|
}
|
|
135
|
|
-
|
|
|
189
|
+
|
|
136
|
190
|
totle += modelDetail.F_TotlePrice;
|
|
|
191
|
+ modelDetailList.Add(modelDetail);
|
|
137
|
192
|
|
|
138
|
193
|
n++;
|
|
139
|
194
|
}
|
|
140
|
195
|
|
|
141
|
196
|
|
|
142
|
197
|
}
|
|
143
|
|
- F_ShouldPrice = totle;
|
|
144
|
|
- //计算活动 单独写个方法
|
|
145
|
|
- if (modelOrder.F_UseActivity.Length>0)
|
|
146
|
|
- {
|
|
147
|
|
- //详细活动规则
|
|
148
|
|
- }
|
|
|
198
|
+
|
|
149
|
199
|
|
|
150
|
200
|
//计算结果
|
|
151
|
201
|
modelOrder.F_Score = F_Score;
|
|
152
|
202
|
modelOrder.F_TotlePrice = totle;
|
|
153
|
|
- modelOrder.F_ShouldPrice = F_ShouldPrice;
|
|
154
|
|
- modelOrder.F_RealPrice = F_RealPrice;
|
|
155
|
|
- //Expression<Func<T_Bus_Product, bool>> eq = a => a.F_ProductName == input.ProductName;
|
|
156
|
|
- //eq = eq.Or(b => b.F_PinyinShort == input.PinyinShort);
|
|
157
|
|
- //eq = eq.Or(b => b.F_ProductId == input.ProductId);
|
|
158
|
|
- //eq = eq.Or(b => b.F_ProductShortName == input.ProductShortName);
|
|
159
|
|
- //if (await _productRepository.GetCount(eq) > 0)
|
|
160
|
|
- //{
|
|
161
|
|
- // return Error("名称/条形码/简称 有重复");
|
|
162
|
|
- //}
|
|
163
|
|
-
|
|
164
|
|
- //List<ProductInput> inputlist = new List<ProductInput>();
|
|
165
|
|
- //inputlist.Add(input);
|
|
|
203
|
+ modelOrder.F_ShouldPrice = modelOrder.F_TotlePrice- ActivityMoney;
|
|
|
204
|
+ modelOrder.F_ActivityMoney = ActivityMoney;
|
|
|
205
|
+ modelOrder.F_UseActivity = UseActivity;
|
|
|
206
|
+
|
|
|
207
|
+
|
|
166
|
208
|
if (await bus_OrderRepository.Add(modelOrder) > 0)
|
|
167
|
209
|
{
|
|
168
|
|
- return Success("订单保存成功");
|
|
|
210
|
+ if (await bus_OrderDetailRepository.AddMany(modelDetailList))
|
|
|
211
|
+ return Success("订单添加成功");
|
|
|
212
|
+ else
|
|
|
213
|
+ return Error("订单添加失败,请重试!");
|
|
169
|
214
|
}
|
|
170
|
215
|
else
|
|
171
|
216
|
{
|
|
172
|
|
- return Error("订单保存失败,请重试!");
|
|
|
217
|
+ return Error("订单添加失败,请重试!");
|
|
173
|
218
|
}
|
|
174
|
219
|
|
|
175
|
220
|
}
|
|
|
@@ -182,7 +227,8 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
182
|
227
|
[HttpPost("getact")]
|
|
183
|
228
|
public async Task<IActionResult> GetAct([FromBody]List<OrderDetailInput> input)
|
|
184
|
229
|
{
|
|
185
|
|
- if(input.Count<1)
|
|
|
230
|
+ decimal def = 0.00M;
|
|
|
231
|
+ if (input.Count < 1)
|
|
186
|
232
|
return Error("请选择商品/数量");
|
|
187
|
233
|
|
|
188
|
234
|
//统计活动金额是否符合条件
|
|
|
@@ -190,6 +236,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
190
|
236
|
|
|
191
|
237
|
//选择活动
|
|
192
|
238
|
Dictionary<int, string> chooseact = new Dictionary<int, string>();
|
|
|
239
|
+ List<UseActInput> actlist = new List<UseActInput>();
|
|
193
|
240
|
foreach (OrderDetailInput m in input)
|
|
194
|
241
|
{
|
|
195
|
242
|
T_Bus_Product modelProduct = await bus_productRepository.GetSingle(b => b.F_ProductId == m.F_ProductId);
|
|
|
@@ -200,7 +247,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
200
|
247
|
string[] tagarry = m.Tags.Split(',');
|
|
201
|
248
|
string tag = tagarry.First(a => a.StartsWith(".")).ToString();
|
|
202
|
249
|
//标签内有效期
|
|
203
|
|
- T_Sys_Marketing modelactive = await bus_MarketingRepository.GetSingle(b => string.Format(",{0},", b.F_Commodity).Contains(string.Format(",{0},", tag))&&b.F_StartTime<=DateTime.Now&&b.F_EndTime>=DateTime.Now);
|
|
|
250
|
+ T_Sys_Marketing modelactive = await bus_MarketingRepository.GetSingle(b => string.Format(",{0},", b.F_Commodity).Contains(string.Format(",{0},", tag)) && b.F_StartTime <= DateTime.Now && b.F_EndTime >= DateTime.Now);
|
|
204
|
251
|
|
|
205
|
252
|
//此商品参加活动
|
|
206
|
253
|
if (modelactive != null)
|
|
|
@@ -209,16 +256,21 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
209
|
256
|
{
|
|
210
|
257
|
//满赠
|
|
211
|
258
|
//判断此人是否有参与活动的资格 默认暂不筛选
|
|
|
259
|
+ if (chooseact.ContainsKey(modelactive.F_ID))
|
|
|
260
|
+ continue;
|
|
212
|
261
|
if (totleact.ContainsKey(modelactive.F_ID))
|
|
213
|
262
|
{
|
|
214
|
263
|
totleact[modelactive.F_ID] = (decimal)modelProduct.F_MemberPrice * m.F_Count + totleact[modelactive.F_ID].ObjToDecimal();
|
|
215
|
264
|
}
|
|
216
|
265
|
else
|
|
217
|
266
|
{
|
|
218
|
|
- totleact.Add(modelactive.F_ID, (decimal)modelProduct.F_MemberPrice * m.F_Count);
|
|
|
267
|
+ totleact.Add(modelactive.F_ID, (decimal)modelProduct.F_MemberPrice * m.F_Count);
|
|
219
|
268
|
}
|
|
220
|
269
|
if ((decimal)modelactive.F_Money <= (decimal)totleact[modelactive.F_ID])
|
|
221
|
|
- chooseact.Add(modelactive.F_ID, modelactive.F_Gift);
|
|
|
270
|
+ {
|
|
|
271
|
+ chooseact.Add(modelactive.F_ID, "1_" + modelactive.F_Gift);
|
|
|
272
|
+ actlist.Add(new UseActInput { id = modelactive.F_ID, type = 1, gift = modelactive.F_Gift, money = def });
|
|
|
273
|
+ }
|
|
222
|
274
|
}
|
|
223
|
275
|
else if (modelactive.F_Type == 2)
|
|
224
|
276
|
{
|
|
|
@@ -226,7 +278,8 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
226
|
278
|
//TODO 判断此人是否有参与活动的资格 默认暂不筛选
|
|
227
|
279
|
if (chooseact.ContainsKey(modelactive.F_ID))
|
|
228
|
280
|
continue;
|
|
229
|
|
- chooseact.Add(modelactive.F_ID, modelactive.F_Commodity);
|
|
|
281
|
+ chooseact.Add(modelactive.F_ID, "2_" + modelactive.F_Commodity);
|
|
|
282
|
+ actlist.Add(new UseActInput { id = modelactive.F_ID, type = 2, gift = modelactive.F_Gift, money = def });
|
|
230
|
283
|
}
|
|
231
|
284
|
else if (modelactive.F_Type == 3)
|
|
232
|
285
|
{
|
|
|
@@ -243,7 +296,13 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
243
|
296
|
totleact.Add(modelactive.F_ID, (decimal)modelProduct.F_MemberPrice * m.F_Count);
|
|
244
|
297
|
}
|
|
245
|
298
|
if ((decimal)modelactive.F_Money <= (decimal)totleact[modelactive.F_ID])
|
|
246
|
|
- chooseact.Add(modelactive.F_ID, modelactive.F_AmountRange.ToString());
|
|
|
299
|
+ {
|
|
|
300
|
+ chooseact.Add(modelactive.F_ID, "3_" + modelactive.F_AmountRange.ToString());
|
|
|
301
|
+
|
|
|
302
|
+ decimal.TryParse(modelactive.F_AmountRange, out def);
|
|
|
303
|
+ actlist.Add(new UseActInput { id = modelactive.F_ID, type = 3, gift = "", money = def });
|
|
|
304
|
+ def = 0.00M;
|
|
|
305
|
+ }
|
|
247
|
306
|
}
|
|
248
|
307
|
else if (modelactive.F_Type == 4)
|
|
249
|
308
|
{
|
|
|
@@ -251,24 +310,23 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Order
|
|
251
|
310
|
//判断此人是否有参与活动的资格 默认暂不筛选
|
|
252
|
311
|
if (chooseact.ContainsKey(modelactive.F_ID))
|
|
253
|
312
|
{
|
|
254
|
|
- chooseact[modelactive.F_ID]= chooseact[modelactive.F_ID]+","+ m.F_ProductId.ToString();
|
|
|
313
|
+ chooseact[modelactive.F_ID] = chooseact[modelactive.F_ID] + "," + m.F_ProductId.ToString();
|
|
|
314
|
+ actlist.First(cc => cc.id == modelactive.F_ID).gift += "," + m.F_ProductId.ToString();
|
|
255
|
315
|
}
|
|
256
|
316
|
else
|
|
257
|
317
|
{
|
|
258
|
|
- chooseact.Add(modelactive.F_ID, m.F_ProductId.ToString());
|
|
|
318
|
+ chooseact.Add(modelactive.F_ID, "4_" + m.F_ProductId.ToString());
|
|
|
319
|
+ actlist.Add(new UseActInput { id = modelactive.F_ID, type = 4, gift = m.F_ProductId.ToString(), money = def });
|
|
259
|
320
|
}
|
|
260
|
|
-
|
|
261
|
|
- }
|
|
262
|
|
-
|
|
263
|
321
|
|
|
264
|
322
|
|
|
|
323
|
+ }
|
|
265
|
324
|
}
|
|
266
|
325
|
}
|
|
267
|
326
|
|
|
268
|
327
|
}
|
|
269
|
328
|
|
|
270
|
|
-
|
|
271
|
|
- return Success("订单保存成功", chooseact);
|
|
|
329
|
+ return Success("参与活动", actlist);
|
|
272
|
330
|
|
|
273
|
331
|
|
|
274
|
332
|
}
|