username@email.com
2022-07-15 283f3e33e15409f657c152881620103c95811768
zhengcaioa/zhengcaioa/Controllers/Finance/FiOrderrecievemoneyController.cs
@@ -18,6 +18,9 @@
using CommonToolsCore;
using Services;
using System.Transactions;
using System.Net.Http.Headers;
using Newtonsoft.Json.Linq;
using Microsoft.Extensions.Configuration;
namespace zhengcaioa.Controllers.Finance
{
@@ -35,12 +38,18 @@
        private readonly IProjectService _projectService;
        private readonly IUserService _userService;
        private readonly IFiCustomerrecievemoneyService _fiCustomerrecievemoneyService;
        private readonly IConfiguration _configuration;
        private readonly IHttpClientFactory _clientFactory;
        private readonly IFiMemberService _iMemberService;
        public FiOrderrecievemoneyController(ILogger<FiOrderrecievemoneyController> logger, ILiaotianService liaotianService, IFiOrderrecievemoneyService fiOrderrecievemoneyService, ICooperOrderService cooperOrderService, IFiSubjectService ifiSubjectService
            , IFiAccountService fiAccountService, IFiAccountRecordService iFiAccountRecordService, ICooperatecustomCustomerService cooperatecustomCustomerService
            , IProjectService projectService
            , IUserService userService
            , IFiCustomerrecievemoneyService fiCustomerrecievemoneyService)
            , IFiCustomerrecievemoneyService fiCustomerrecievemoneyService
              , IConfiguration configuration
            , IHttpClientFactory clientFactory
             , IFiMemberService iMemberService)
        {
            _logger = logger;
            _liaotianService = liaotianService;
@@ -53,6 +62,9 @@
            _projectService = projectService;
            _userService = userService;
            _fiCustomerrecievemoneyService = fiCustomerrecievemoneyService;
            _configuration = configuration;
            _clientFactory = clientFactory;
            _iMemberService = iMemberService;
        }
        public IActionResult Index()
@@ -200,6 +212,60 @@
                
                resultEntity = _fiOrderrecievemoneyService.save(data);
                if (data.WeishouMoney <= data.Recievemoney && cooperOrderDTO.OrderType == "05" )
                {
                    //开通会员
                    var fiMemberDTO = _iMemberService.Get(cooperOrderDTO.OrderType1);
                    //开通会员
                    string huiyuanurl = _configuration.GetSection("huiyuanurl").Value;
                    string OAWriteChangeAsync = _configuration.GetSection("OAWriteChangeAsync").Value;
                    Uri postUrl2 = new Uri(huiyuanurl + OAWriteChangeAsync);
                    JObject questions2 = new JObject();
                    questions2.Add("UserID", cooperatecustomCustomerDTO.HuiyuanId);
                    questions2.Add("PhoneNumber", cooperatecustomCustomerDTO.Tel);
                    questions2.Add("VIPName", fiMemberDTO.MemberType);
                    questions2.Add("UserName", cooperatecustomCustomerDTO.Name);
                    questions2.Add("FromName", "OA");
                    string requestJson2 = questions2.ToString();
                    string result2 = string.Empty;
                    using (HttpContent httpContent = new StringContent(requestJson2))
                    {
                        httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                        using (HttpClient httpClient = new HttpClient())
                        {
                            httpClient.Timeout = new TimeSpan(0, 0, 10);
                            HttpResponseMessage responseMessage = httpClient.PostAsync(postUrl2, httpContent).Result;
                            result2 = responseMessage.Content.ReadAsStringAsync().Result;
                        }
                    }
                    _logger.LogInformation("result2:" + result2);
                    JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2);
                    if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1")
                    {
                        cooperatecustomCustomerDTO.HuiyuanId = jobjectresult["UserID"].ToString();
                        _cooperatecustomCustomerService.save(cooperatecustomCustomerDTO);
                        resultEntity.Result = true;
                    }
                    else
                    {
                        resultEntity.Result = false;
                        resultEntity.Message = "写入会员权限失败";
                        return new JsonResult(resultEntity);
                    }
                }
                if (data.PayType != "03")
                {
                    FiAccountRecordDTO data1 = new FiAccountRecordDTO();