|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+using System;
|
|
|
2
|
+using System.Collections.Generic;
|
|
|
3
|
+using System.Common;
|
|
|
4
|
+using System.IRepositories;
|
|
|
5
|
+using System.Linq;
|
|
|
6
|
+using System.Model;
|
|
|
7
|
+using System.Security.Claims;
|
|
|
8
|
+using System.Threading.Tasks;
|
|
|
9
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
10
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
11
|
+using TVShoppingCallCenter_ZLJ.Models.Inputs;
|
|
|
12
|
+
|
|
|
13
|
+namespace TVShoppingCallCenter_ZLJ.Controllers.Customer
|
|
|
14
|
+{
|
|
|
15
|
+ [Authorize]
|
|
|
16
|
+ [Produces("application/json")]
|
|
|
17
|
+ [Route("api/[controller]")]
|
|
|
18
|
+ public class VIPInfoController : BaseController
|
|
|
19
|
+ {
|
|
|
20
|
+ private readonly ICus_VIPInfoRepository _cus_vip_infoRepository;
|
|
|
21
|
+ private readonly ISys_UserAccountRepository _sys_user_accountRepository;
|
|
|
22
|
+
|
|
|
23
|
+ public VIPInfoController(ICus_VIPInfoRepository cus_vip_infoRepository, ISys_UserAccountRepository sys_user_accountRepository)
|
|
|
24
|
+ {
|
|
|
25
|
+ _cus_vip_infoRepository = cus_vip_infoRepository;
|
|
|
26
|
+ _sys_user_accountRepository = sys_user_accountRepository;
|
|
|
27
|
+ }
|
|
|
28
|
+
|
|
|
29
|
+ [HttpGet]
|
|
|
30
|
+ public IActionResult Index()
|
|
|
31
|
+ {
|
|
|
32
|
+ return Success("成功");
|
|
|
33
|
+ }
|
|
|
34
|
+
|
|
|
35
|
+ /// <summary>
|
|
|
36
|
+ /// 添加会员
|
|
|
37
|
+ /// </summary>
|
|
|
38
|
+ /// <param name="input"></param>
|
|
|
39
|
+ /// <returns></returns>
|
|
|
40
|
+ [HttpPost("add")]
|
|
|
41
|
+ public async Task<IActionResult> AddAsync(VIPInfoInput input)
|
|
|
42
|
+ {
|
|
|
43
|
+ if (string.IsNullOrEmpty(input.name ))
|
|
|
44
|
+ return Error("请输入名字");
|
|
|
45
|
+ if (string.IsNullOrEmpty(input.phone ))
|
|
|
46
|
+ return Error("请输入手机号");
|
|
|
47
|
+
|
|
|
48
|
+ var model = new T_Cus_VipInfo();
|
|
|
49
|
+ model.F_VIPCode = input .vipcode ;//会员卡号
|
|
|
50
|
+ model.F_Name = input.name;
|
|
|
51
|
+ model.F_Birthday = input.birthday ;
|
|
|
52
|
+ model.F_Phone = input.phone;
|
|
|
53
|
+ model.F_Recommender = input.recommender;
|
|
|
54
|
+ model.F_Sex = input.sex;
|
|
|
55
|
+ model.F_Label = input.label;
|
|
|
56
|
+ model.F_State = input.state;
|
|
|
57
|
+ model.F_Note = input.note;
|
|
|
58
|
+ model.F_City = input.city;
|
|
|
59
|
+ model.F_Nickname = input.nickname;
|
|
|
60
|
+ model.F_Address = input.address;
|
|
|
61
|
+ model.F_Address1 = input.address1;
|
|
|
62
|
+ model.F_RegTime = DateTime.Now;
|
|
|
63
|
+ model.F_CreateBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
|
|
|
64
|
+ model.F_CreateOn = DateTime.Now;
|
|
|
65
|
+
|
|
|
66
|
+ if (await _cus_vip_infoRepository.GetCount(x => x.F_VIPCode == model.F_VIPCode && x.F_Name == input.name) > 0)
|
|
|
67
|
+ {
|
|
|
68
|
+ return Error("添加失败,存在相同会员信息");
|
|
|
69
|
+ }
|
|
|
70
|
+ var res = await _cus_vip_infoRepository.Add(model);
|
|
|
71
|
+ if (res > 0)
|
|
|
72
|
+ {
|
|
|
73
|
+ return Success("添加成功");
|
|
|
74
|
+ }
|
|
|
75
|
+ else
|
|
|
76
|
+ {
|
|
|
77
|
+ return Error("添加失败");
|
|
|
78
|
+ }
|
|
|
79
|
+ }
|
|
|
80
|
+
|
|
|
81
|
+ /// <summary>
|
|
|
82
|
+ /// 修改会员信息
|
|
|
83
|
+ /// </summary>
|
|
|
84
|
+ [HttpPost("update")]
|
|
|
85
|
+ public async Task<IActionResult> UpdateAsync(VIPInfoInput input)
|
|
|
86
|
+ {
|
|
|
87
|
+ if (string.IsNullOrEmpty(input.name))
|
|
|
88
|
+ return Error("请输入名字");
|
|
|
89
|
+ if (string.IsNullOrEmpty(input.phone))
|
|
|
90
|
+ return Error("请输入手机号");
|
|
|
91
|
+
|
|
|
92
|
+ var model = await _cus_vip_infoRepository.GetSingle(x => x.F_ID == input.id);
|
|
|
93
|
+ if (model == null)
|
|
|
94
|
+ return Error("操作失败");
|
|
|
95
|
+ //model.F_VIPCode = input.vipcode;//会员卡号
|
|
|
96
|
+ model.F_Name = input.name;
|
|
|
97
|
+ model.F_Birthday = input.birthday;
|
|
|
98
|
+ model.F_Phone = input.phone;
|
|
|
99
|
+ model.F_Recommender = input.recommender;
|
|
|
100
|
+ model.F_Sex = input.sex;
|
|
|
101
|
+ model.F_Label = input.label;
|
|
|
102
|
+ model.F_State = input.state;
|
|
|
103
|
+ model.F_Note = input.note;
|
|
|
104
|
+ model.F_City = input.city;
|
|
|
105
|
+ model.F_Nickname = input.nickname;
|
|
|
106
|
+ model.F_Address = input.address;
|
|
|
107
|
+ model.F_Address1 = input.address1;
|
|
|
108
|
+ model.F_RegTime = DateTime.Now;
|
|
|
109
|
+ model.F_LastModifyOn = DateTime.Now.ToLocalTime();
|
|
|
110
|
+ model.F_LastModifyBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
|
|
|
111
|
+ bool b = await _cus_vip_infoRepository.Update(model);
|
|
|
112
|
+ if (b)
|
|
|
113
|
+ return Success("修改成功");
|
|
|
114
|
+ return Error("修改失败");
|
|
|
115
|
+ }
|
|
|
116
|
+
|
|
|
117
|
+ /// <summary>
|
|
|
118
|
+ /// 删除会员信息 by ids
|
|
|
119
|
+ /// </summary>
|
|
|
120
|
+ /// <param name="ids"></param>
|
|
|
121
|
+ /// <returns></returns>
|
|
|
122
|
+ [HttpPost("delete")]
|
|
|
123
|
+ public async Task<IActionResult> Remove(int[] ids)
|
|
|
124
|
+ {
|
|
|
125
|
+ var res = 0;
|
|
|
126
|
+ if (ids != null && ids.Length > 0)
|
|
|
127
|
+ {
|
|
|
128
|
+ foreach (var item in ids)
|
|
|
129
|
+ {
|
|
|
130
|
+ var ml = await _cus_vip_infoRepository.GetSingle(x => x.F_ID == item);
|
|
|
131
|
+ ml.F_State = (int)EnumDelState.Delete;
|
|
|
132
|
+ ml.F_DeleteOn = DateTime.Now.ToLocalTime();
|
|
|
133
|
+ ml.F_DeleteBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
|
|
|
134
|
+ if (_cus_vip_infoRepository.Update(ml).Result)
|
|
|
135
|
+ res += 1;
|
|
|
136
|
+ }
|
|
|
137
|
+ if (res == ids.Length)
|
|
|
138
|
+ return Success("删除成功");
|
|
|
139
|
+ else if (res > 0 && res < ids.Length)
|
|
|
140
|
+ return Error("部分删除失败,请查看后重新操作");
|
|
|
141
|
+ else
|
|
|
142
|
+ return Error("删除失败,请查看后重新操作");
|
|
|
143
|
+ }
|
|
|
144
|
+ else
|
|
|
145
|
+ return Error("请选择要删除的记录");
|
|
|
146
|
+ }
|
|
|
147
|
+ }
|
|
|
148
|
+}
|