mengjie лет назад: 5
Родитель
Сommit
6018a6d0f8

+ 13 - 0
代码/System.IRepositories/ICus_VIPInfoRepository.cs

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Common;
4
+using System.Model;
5
+using System.Text;
6
+
7
+namespace System.IRepositories
8
+{
9
+    public interface ICus_VIPInfoRepository : IRepository<T_Cus_VipInfo>
10
+    {
11
+    }
12
+   
13
+}

+ 175 - 0
代码/System.Model/T_Cus_VipInfo.cs

@@ -0,0 +1,175 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+
5
+namespace System.Model
6
+{
7
+    [Serializable]
8
+    public partial class T_Cus_VipInfo
9
+    {
10
+        public T_Cus_VipInfo()
11
+        { }
12
+        #region Model
13
+        private int _f_id;
14
+        private string _f_vipcode;
15
+        private string _f_name;
16
+        private DateTime? _f_birthday;
17
+        private string _f_phone;
18
+        private string _f_sex;
19
+        private string _f_label;
20
+        private string _f_recommender;
21
+        private int? _f_state;
22
+        private string _f_note;
23
+        private string _f_city;
24
+        private string _f_nickname;
25
+        private string _f_address;
26
+        private string _f_address1;
27
+        private DateTime? _f_regtime;
28
+        /// <summary>
29
+        /// id标识,自增
30
+        /// </summary>
31
+        public int F_ID
32
+        {
33
+            set { _f_id = value; }
34
+            get { return _f_id; }
35
+        }
36
+        /// <summary>
37
+        /// 会员编号
38
+        /// </summary>
39
+        public string F_VIPCode
40
+        {
41
+            set { _f_vipcode = value; }
42
+            get { return _f_vipcode; }
43
+        }
44
+        /// <summary>
45
+        /// 姓名
46
+        /// </summary>
47
+        public string F_Name
48
+        {
49
+            set { _f_name = value; }
50
+            get { return _f_name; }
51
+        }
52
+        /// <summary>
53
+        /// 生日
54
+        /// </summary>
55
+        public DateTime? F_Birthday
56
+        {
57
+            set { _f_birthday = value; }
58
+            get { return _f_birthday; }
59
+        }
60
+        /// <summary>
61
+        /// 手机号
62
+        /// </summary>
63
+        public string F_Phone
64
+        {
65
+            set { _f_phone = value; }
66
+            get { return _f_phone; }
67
+        }
68
+        /// <summary>
69
+        /// 性别
70
+        /// </summary>
71
+        public string F_Sex
72
+        {
73
+            set { _f_sex = value; }
74
+            get { return _f_sex; }
75
+        }
76
+        /// <summary>
77
+        /// 标签
78
+        /// </summary>
79
+        public string F_Label
80
+        {
81
+            set { _f_label = value; }
82
+            get { return _f_label; }
83
+        }
84
+        /// <summary>
85
+        /// 推荐人
86
+        /// </summary>
87
+        public string F_Recommender
88
+        {
89
+            set { _f_recommender = value; }
90
+            get { return _f_recommender; }
91
+        }
92
+        /// <summary>
93
+        /// 状态:0正常 1禁用 2删除
94
+        /// </summary>
95
+        public int? F_State
96
+        {
97
+            set { _f_state = value; }
98
+            get { return _f_state; }
99
+        }
100
+        /// <summary>
101
+        /// 备注
102
+        /// </summary>
103
+        public string F_Note
104
+        {
105
+            set { _f_note = value; }
106
+            get { return _f_note; }
107
+        }
108
+        /// <summary>
109
+        /// 所在城市
110
+        /// </summary>
111
+        public string F_City
112
+        {
113
+            set { _f_city = value; }
114
+            get { return _f_city; }
115
+        }
116
+        /// <summary>
117
+        /// 微信昵称
118
+        /// </summary>
119
+        public string F_Nickname
120
+        {
121
+            set { _f_nickname = value; }
122
+            get { return _f_nickname; }
123
+        }
124
+        /// <summary>
125
+        /// 地址
126
+        /// </summary>
127
+        public string F_Address
128
+        {
129
+            set { _f_address = value; }
130
+            get { return _f_address; }
131
+        }
132
+        /// <summary>
133
+        /// 地址备用
134
+        /// </summary>
135
+        public string F_Address1
136
+        {
137
+            set { _f_address1 = value; }
138
+            get { return _f_address1; }
139
+        }
140
+        /// <summary>
141
+        /// 注册时间
142
+        /// </summary>
143
+        public DateTime? F_RegTime
144
+        {
145
+            set { _f_regtime = value; }
146
+            get { return _f_regtime; }
147
+        }
148
+        /// <summary>
149
+        /// 添加时间
150
+        /// </summary>
151
+        public DateTime? F_CreateOn { get; set; }
152
+        /// <summary>
153
+        /// 添加工号
154
+        /// </summary>
155
+        public string F_CreateBy { get; set; }
156
+
157
+        /// <summary>
158
+        /// 最后一次修改时间
159
+        /// </summary>
160
+        public DateTime? F_LastModifyOn { get; set; }
161
+        /// <summary>
162
+        /// 最后一次修改工号
163
+        /// </summary>
164
+        public string F_LastModifyBy { get; set; }
165
+        /// <summary>
166
+        /// 删除时间
167
+        /// </summary>
168
+        public DateTime? F_DeleteOn { get; set; }
169
+        /// <summary>
170
+        /// 删除工号
171
+        /// </summary>
172
+        public string F_DeleteBy { get; set; }
173
+        #endregion Model
174
+    }
175
+}

+ 14 - 0
代码/System.Repositories/Cus_VIPInfoRepository.cs

@@ -0,0 +1,14 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Common;
4
+using System.IRepositories;
5
+using System.Model;
6
+using System.Text;
7
+
8
+namespace System.Repositories
9
+{
10
+    public class Cus_VIPInfoRepository : BaseRepository<T_Cus_VipInfo>, ICus_VIPInfoRepository
11
+    {
12
+    }
13
+    
14
+}

+ 148 - 0
代码/TVShoppingCallCenter_ZLJ/Controllers/Customer/VIPInfoController.cs

@@ -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
+}

+ 25 - 0
代码/TVShoppingCallCenter_ZLJ/Models/Inputs/VIPInfoInput.cs

@@ -0,0 +1,25 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace TVShoppingCallCenter_ZLJ.Models.Inputs
7
+{
8
+    public class VIPInfoInput
9
+    {
10
+        public int id { get; set; }
11
+        public string vipcode { get; set; }
12
+        public string name { get; set; }
13
+        public DateTime? birthday { get; set; }
14
+        public string phone { get; set; } = "";
15
+        public string sex { get; set; } = "";
16
+        public string label { get; set; } = "";
17
+        public string recommender { get; set; } = "";
18
+        public int? state { get; set; } = 0;
19
+        public string note { get; set; } = "";
20
+        public string city { get; set; } = "";
21
+        public string nickname { get; set; } = "";
22
+        public string address { get; set; } = "";
23
+        public string address1 { get; set; } = "";
24
+    }
25
+}