username@email.com
2024-01-12 0e5c4a8e17dcefcc10b2507da61b099be12451d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Transactions;
using DTO;
using IServices;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using zhengcaioa.IService;
using zhengcaioa.Models;
 
namespace zhengcaioa.Controllers.admin
{
    [CheckLogin]
    public class SimCostController : Controller
    {
        private readonly ILogger<SimController> _logger;
        private readonly ILiaotianService _liaotianService;
        private readonly IUserService _userService;
        private readonly ISimService _simService;
 
        public SimCostController(ILogger<SimController> logger, IUserService userService, ILiaotianService liaotianService, ISimService simService)
        {
            _logger = logger;
            _liaotianService = liaotianService;
            _userService = userService;
            _simService = simService;
        }
 
        /// <summary>
        /// 列表页
        /// </summary>
        /// <returns></returns>
        public IActionResult Index(int year,string sim)
        {
            //List<ActionEntity> actionlist = new List<ActionEntity>();
            //ActionEntity actionEntity = new ActionEntity();
            //actionEntity.OpenType = 0;
            //actionEntity.ActionUrl = "";
            //actionEntity.ActionFun = "Search";
            //actionEntity.PageIco = "fa fa-search";
            //actionEntity.ActionName = "查询";
            //actionlist.Add(actionEntity);
 
            //ActionEntity actionEntity1 = new ActionEntity();
            //actionEntity1.OpenType = 0;
            //actionEntity1.ActionUrl = "";
            //actionEntity1.ActionFun = "Add";
            //actionEntity1.PageIco = "fa fa-plus";
            //actionEntity1.ActionName = "新增";
            //actionlist.Add(actionEntity1);
 
 
            //ActionEntity actionEntity4 = new ActionEntity();
            //actionEntity4.OpenType = 0;
            //actionEntity4.ActionUrl = "";
            //actionEntity4.ActionFun = "UnBind";
            //actionEntity4.PageIco = "fa fa-remove";
            //actionEntity4.ActionName = "批量删除";
            //actionlist.Add(actionEntity4);
 
            //ViewData["ActionInfo"] = actionlist;
            ViewBag.Year = year;
            ViewBag.Sim = sim;
            //var js= _simService.SearchSimCostByPage(sim, year)
            return View();
        }
 
        /// <summary>
        /// 列表内容
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public IActionResult GetList(int year, string sim)
        {
            var list = _simService.SearchSimCostByPage(sim, year);
            
            //var result = new
            //{
            //    total:"1",
            //    page: 1, 
            //    records: list.Count,  
            //    rows: list
            //};
            return Json(list);
        }
 
        /// <summary>
        /// 编辑页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Edit(string id,decimal money,int year, int month,string sim)
        {           
            SimCost dto = new SimCost();
            dto.bill_month = month;
            dto.bill_amount = money;
            dto.sim_id = id;
            dto.sub_userid = sim;
            dto.bill_year = year;
            //if (!string.IsNullOrEmpty(id))
            //{
            //    dto = _simService.GetSimCost(int.Parse(id));
            //}
            ViewData.Model = dto;
            return View();
        }
 
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult SaveSimCost(SimCost data)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ResultEntity resultEntity = new ResultEntity();
            using (TransactionScope scope = new TransactionScope())
            {
                data.sub_userid = curentuser.Id;
                resultEntity = _simService.SaveCost(data);
                scope.Complete();
            }
            return new JsonResult(resultEntity);
        }
 
        /// <summary>
        /// 列表页
        /// </summary>
        /// <returns></returns>
        public IActionResult SimYear()
        {
            return View();
        }
 
        /// <summary>
        /// 列表内容
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public IActionResult GetSimYearList(SimCostDTOSearch search)
        {
            var list = _simService.SearchSimCostYearByPage(search);
            return new JsonResult(list);
        }
 
        [HttpPost]
        public IActionResult SaveSimYearCost(object data)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ResultEntity resultEntity = new ResultEntity();
            //using (TransactionScope scope = new TransactionScope())
            //{
            //    data.sub_userid = curentuser.Id;
            //    resultEntity = _simService.SaveCost(data);
            //    scope.Complete();
            //}
            return new JsonResult(resultEntity);
        }
 
        ///// <summary>
        ///// 解绑
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult UnBindSim(string id)
        //{
        //    var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
        //    ResultEntity resultEntity = new ResultEntity();
        //    using (TransactionScope scope = new TransactionScope())
        //    {
        //        resultEntity = _simService.UnBind(id, curentuser.Id);
        //        scope.Complete();
        //    }
        //    return new JsonResult(resultEntity);
        //}
    }
}