1057 lines
50 KiB
C#
1057 lines
50 KiB
C#
using Core.Web.App_Start;
|
||
using Core.Web.WebHelper;
|
||
using CRM.Core.BLL;
|
||
using CRM.Core.BLL.Application.Refund;
|
||
using CRM.Core.BLL.Base;
|
||
using CRM.Core.BLL.EventBus.Events;
|
||
using CRM.Core.BLL.Util;
|
||
using CRM.Core.BLL.Wx;
|
||
using CRM.Core.Common.EventBus;
|
||
using CRM.Core.Common.Layui;
|
||
using CRM.Core.Common.WebHelper;
|
||
using CRM.Core.DTO;
|
||
using CRM.Core.DTO.Ord;
|
||
using CRM.Core.Model.Entity;
|
||
using CRM.Core.Model.Enum;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Text;
|
||
using System.Web;
|
||
using System.Web.Mvc;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.Common.BlowFish;
|
||
using WX.CRM.WebHelper;
|
||
|
||
namespace Core.Web.Controllers
|
||
{
|
||
public class OrderRefundController : BaseController
|
||
{
|
||
private CACHE_BL _cache = new CACHE_BL();
|
||
private WX_SZZYORDER_BL _order = new WX_SZZYORDER_BL();
|
||
private WX_SzzyOrderRefund_BL _orderRefund = new WX_SzzyOrderRefund_BL();
|
||
private WX_SzzyOrderPay_BL _orderPay = new WX_SzzyOrderPay_BL();
|
||
private BAS_PARAMETER_BL paramter_bl = new BAS_PARAMETER_BL();
|
||
private SecurityHelper sHelper = new SecurityHelper();
|
||
private WX_SzzyOrderDeposit_BL _orderDeposit = new WX_SzzyOrderDeposit_BL();
|
||
private Wx_SzzyOrderRefundContract_BL _orderRefundContract = new Wx_SzzyOrderRefundContract_BL();
|
||
private WX_PRODUCT_BL _subProduct = new WX_PRODUCT_BL();
|
||
private Wx_SzzyOrder_HandGift_BL _SzzyOrder_HandGift_BL = new Wx_SzzyOrder_HandGift_BL();
|
||
private RefundServices _refundService = new RefundServices();
|
||
|
||
[HttpGet]
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_NotButton, true)]
|
||
public ActionResult Index()
|
||
{
|
||
ViewBag.companyList = _cache.GetCompanyVirtual();
|
||
ViewBag.rightCode = RightsConfig.CONST_退款管理;
|
||
var apiUrl = _cache.GetValue_Parameter("Core_ZxdService_Api2");
|
||
ViewBag.ApiUrl = apiUrl;
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_NotButton, false)]
|
||
public JsonResult Index(OrderRefundSelectDto info, Laypage pager)
|
||
{
|
||
|
||
info.pager = pager;
|
||
var list = _orderRefund.GetList(info);
|
||
|
||
//var sumList = _orderRefund.GetList(where, p => p.id, new Laypage() { page = 1, limit = int.MaxValue });
|
||
var sum = list.Sum(m => m.refundprice);
|
||
var data = new LayuiData<OrderRefundView>()
|
||
{
|
||
msg = "数据加载成功!",
|
||
count = info.pager.count,
|
||
code = 0,
|
||
data = list,
|
||
totalRow = new { refundprice = sum }
|
||
};
|
||
return Json(data, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[HttpGet]
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_Other1, true)]
|
||
public ActionResult Add()
|
||
{
|
||
//var order = _order.GetModel(orderid);
|
||
//var model = new WX_SzzyOrderRefund() { orderid = Convert.ToInt32(order.ORDERID) };
|
||
var RefundReasonType1 = _cache.GetValue_Parameter("RefundReasonType");
|
||
ViewBag.RefundReasonTypeList = JsonHelper.JsonDivertToObj<List<RefundReasonType>>(RefundReasonType1);
|
||
var apiUrl = _cache.GetValue_Parameter("Core_ZxdService_Api2");
|
||
ViewBag.ApiUrl = apiUrl;
|
||
return View(new WX_SzzyOrderRefund());
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_Other1, false)]
|
||
public JsonResult Add(OrderRefundDto dto)
|
||
{
|
||
try
|
||
{
|
||
dto.isacturalrefund = 1;//默认先都是实际退款
|
||
if (ModelState.IsValid)
|
||
{
|
||
var order = _order.GetModel(dto.orderid);
|
||
if (order == null)
|
||
return Json(new retMsg { result = false, retmsg = "请输入正确的订单号!" }, JsonRequestBehavior.AllowGet);
|
||
if (dto.refundprice <= 0)
|
||
{
|
||
return Json(new retMsg { result = false, retmsg = "退款金额必须大于零!" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
if (order.ARRIVALPAY == null || order.ARRIVALPAY.Value <= 0)
|
||
{
|
||
return Json(new retMsg { result = false, retmsg = "无可退金额!" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
//var payTypeName = _cache.GetList_Parameter(ParameterGroup.OrderPayType).FirstOrDefault(p => p.PARAVALUE == orderRefundDto.refundtype.ToString()).PARANAME;
|
||
//dto. = payTypeName;
|
||
|
||
dto.creator = Eid;
|
||
dto.creatorname = UserName;
|
||
dto.applytype = 1;//合规申请
|
||
|
||
//dto.id = int.Parse(new SEQUENCES_BL().Seq_OrderRefund().ToString());
|
||
//LogHelper.Info("orderRefundDto.id:" + orderRefundDto.id.ToString());
|
||
|
||
//_orderRefund.Add(orderRefundDto);
|
||
|
||
var url = new BAS_PARAMETER_BL().GetValue_Parameter(Parameter.Core_ZxdService_OrderRefund);//直接调用中心点订单接口
|
||
|
||
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||
request.Method = "POST";
|
||
//request.ContentType = "application/x-www-form-urlencoded";
|
||
// request.ContentType = "application/json";
|
||
//dto.companycode = companyCode;
|
||
dto.companycode = order.companycode;
|
||
dto.creator = Convert.ToInt32(Eid);
|
||
dto.creatorname = UserName;
|
||
LogHelper.Info("合规发起强制退款:" + dto.ToJson());
|
||
var jiami = sHelper.encyptData("UPWEBSITE", dto.ToJson());
|
||
var content = HttpUtility.UrlEncode(jiami);
|
||
var sing = HttpUtility.UrlEncode(sHelper.signData("UPWEBSITE", jiami));
|
||
|
||
request.Headers.Add("content", content);
|
||
request.Headers.Add("clientid", "UPWEBSITE");
|
||
request.Headers.Add("sign", sing);
|
||
|
||
//没有参数的时候必须加上这句,这个是HTTP POST要求必须带参数,不然就需要说明长度是0
|
||
request.ContentLength = 0;
|
||
|
||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||
{
|
||
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
|
||
string result = reader.ReadToEnd();
|
||
LogHelper.Info(result);
|
||
var retmsg = sHelper.decyptData(SecurityHelper.OrderClientIdKey, result);
|
||
var retmessage = JsonHelper.JsonDivertToObj<retMsg>(retmsg);
|
||
if (retmessage.result)
|
||
{
|
||
#region 数据同步给坐席
|
||
|
||
try
|
||
{
|
||
int refid = Convert.ToInt32(retmessage.retmsg);//返回的退款ID
|
||
var refinfo = _orderRefund.Get(m => m.id == refid);
|
||
//同步数据给坐席
|
||
var host = Utility.GetSettingOrNullByKey("DataSyncApiUrl");
|
||
var syncurl = host + "/api/DataSync";
|
||
var para = new SYNC_PUSH_DTO()
|
||
{
|
||
bidatatype = "Client_RefundInfo",
|
||
deptcode = order.companycode,
|
||
jsontext = refinfo.ToJson()
|
||
};
|
||
var rep = Utility.PostAjaxData(syncurl, para.ToJson(), Encoding.UTF8);
|
||
var ret = Utility.JSONToObject<retMsg>(rep);
|
||
}
|
||
catch (Exception xx)
|
||
{
|
||
LogHelper.Error("同步给坐席出现问题:" + xx.ToString());
|
||
return Json(new retMsg { result = true, retmsg = "提交总部成功,但本地提交异常,请重新提交" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
return Json(new retMsg { result = true, retmsg = "提交成功" }, JsonRequestBehavior.AllowGet);
|
||
|
||
#endregion 数据同步给坐席
|
||
}
|
||
else
|
||
{
|
||
if (retmessage.retcode == (int)EnumInterfaceErrcode.调用成功但有错误)
|
||
{
|
||
return Json(new retMsg { result = false, retmsg = retmessage.retmsg }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
else
|
||
{
|
||
return Json(new retMsg { result = false, retmsg = "提交失败,请稍后重试或者联系管理员!" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
}
|
||
}
|
||
|
||
return Json(new retMsg { result = true }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
return Json(new retMsg { result = false, retmsg = "实体验证未通过" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
return Json(new retMsg { result = false, retmsg = ex.ToString() }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
}
|
||
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_Other4, true)]
|
||
public JsonResult UploadRetraceRefundFile(int id, string retrace_refund_file)
|
||
{
|
||
try
|
||
{
|
||
|
||
retMsg retMsg = new retMsg()
|
||
{
|
||
result = false,
|
||
retmsg = "修改失败"
|
||
};
|
||
var model = _orderRefund.Get(p => p.id == id);
|
||
LogHelper.Debug($"Before:{model.ToJson()}");
|
||
//退款成功,则修改退款申请列表的退款状态
|
||
if (model != null)
|
||
{
|
||
var updatestring = new List<string>
|
||
{
|
||
"retrace_refund_file"
|
||
};
|
||
model.retrace_refund_file = retrace_refund_file;
|
||
LogHelper.Debug($"After:{model.ToJson()}");
|
||
var result = _orderRefund.Update(model, updatestring);
|
||
if (result)
|
||
{
|
||
retMsg.result = true;
|
||
}
|
||
}
|
||
|
||
return Json(retMsg, JsonRequestBehavior.AllowGet);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex);
|
||
return Json(new retMsg
|
||
{
|
||
result = false,
|
||
retmsg = ex.ToString()
|
||
}, JsonRequestBehavior.AllowGet);
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 退款剩余价值计算
|
||
/// </summary>
|
||
/// <param name="order"></param>
|
||
/// <param name="isOriginalPrice"></param>
|
||
/// <returns></returns>
|
||
private decimal GetOrderRefundPrice(WX_SZZYORDER order, int? isOriginalPrice = null)
|
||
{
|
||
if (order.ISOPEN == 0)
|
||
return 0;
|
||
var refundDay = "";
|
||
if (string.IsNullOrEmpty(refundDay))
|
||
{
|
||
refundDay = "7";
|
||
}
|
||
if (isOriginalPrice.HasValue)
|
||
{
|
||
if (isOriginalPrice.Value == 1)
|
||
{
|
||
return order.ARRIVALPAY.Value > order.NEEDPAY.Value ? order.ARRIVALPAY.Value : order.NEEDPAY.Value;
|
||
}
|
||
}
|
||
if (order.ORDERSTATUS == "180")
|
||
{
|
||
//新订单,全退
|
||
return order.NEEDPAY.Value;
|
||
}
|
||
else if (order.ORDERSTATUS == "200")
|
||
{
|
||
//已经确认支付过的订单,还未开通的订单
|
||
return order.ARRIVALPAY.Value;
|
||
}
|
||
else if (order.ORDERSTATUS == "220" || order.ORDERSTATUS == "205")
|
||
{
|
||
//已经开通的订单
|
||
if (order.OTIME.Value.AddDays(int.Parse(refundDay)) >= DateTime.Now)
|
||
{
|
||
//LogHelper.Info("7天全退:" + order.ARRIVALPAY.Value.ToString());
|
||
//7天内,全退
|
||
return order.ARRIVALPAY.Value;
|
||
}
|
||
else
|
||
{
|
||
//如果结束时间小于当前时间,说明已经过期,直接返回0
|
||
if (order.ENDTIME.Value < DateTime.Now)
|
||
return 0;
|
||
//7天之后,按使用月份返回
|
||
//var allMonth = order.ENDTIME.Value.Year * 12 + order.ENDTIME.Value.Month - order.OTIME.Value.Year * 12 - order.OTIME.Value.Month;
|
||
//var useMonth = DateTime.Now.Year * 12 + DateTime.Now.Month - order.OTIME.Value.Year * 12 - order.OTIME.Value.Month;
|
||
//var avgPrice = order.ARRIVALPAY.Value / allMonth;
|
||
var allDay = (order.ENDTIME.Value - order.OTIME.Value).Days;
|
||
var useDay = (DateTime.Now - order.OTIME.Value).Days;
|
||
var avgPrice = order.ARRIVALPAY.Value / allDay;
|
||
|
||
return avgPrice * (allDay - useDay - 1);
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
[HttpGet]
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_Other1, true)]
|
||
public ActionResult Audit(int id)
|
||
{
|
||
var model = _orderRefund.Get(p => p.id == id);
|
||
var order = _order.Get(p => p.ORDERID == model.orderid);
|
||
var contract = _orderRefundContract.Get(p => p.OrderId == model.orderid);
|
||
|
||
int? isCompliance = null;
|
||
if (order != null)
|
||
{
|
||
var subProductList = _subProduct.GetSubProductListByProductId(0, 0, null);
|
||
var subProduct = subProductList.FirstOrDefault(p => p.SUBPRODUCTID == order.SUBPRODUCTID);
|
||
if (subProduct != null)
|
||
{
|
||
isCompliance = subProduct.IsCompliance;
|
||
}
|
||
}
|
||
|
||
ViewBag.ContractStatus = contract == null ? 0 : contract.ContractStatus;
|
||
ViewBag.IsOpen = order == null ? 0 : order.ISOPEN;
|
||
ViewBag.ArrivalTime = order == null ? null : order.ARRIVALTIME;
|
||
ViewBag.RefundTime = model.refunddate;
|
||
ViewBag.IsCompliance = isCompliance;
|
||
model.isacturalrefund = model.isacturalrefund ?? 1;//如果为空,默认需要退款
|
||
return View(model);
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_Other1, false)]
|
||
public JsonResult Audit(WX_SzzyOrderRefund orderRefundDto, int status)
|
||
{
|
||
try
|
||
{
|
||
/*
|
||
var curMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
|
||
var url = paramter_bl.GetValue_Parameter(Parameter.UserCenter_RiaService_refund);//封装出来的接口
|
||
var url2 = paramter_bl.GetValue_Parameter(Parameter.UserCenter_RiaService_closeFreeOrder);
|
||
|
||
var orderRefund = _orderRefund.Get(p => p.id == orderRefundDto.id);
|
||
orderRefund.att2 = orderRefundDto.att2;
|
||
|
||
var deposit = _orderDeposit.Get(p => p.id == orderRefund.orderid);
|
||
if (deposit != null)
|
||
{
|
||
//订金退款
|
||
//deposit.isuse = 2;//退款
|
||
//_orderDeposit.Update(deposit);
|
||
|
||
orderRefund.auditstatus = 1;
|
||
orderRefund.auditor = int.Parse(UserId.ToString());
|
||
orderRefund.auditorname = UserName;
|
||
orderRefund.audittime = DateTime.Now;
|
||
|
||
retMsg audret = _orderRefund.Audit(orderRefund, null);
|
||
if (audret.result)
|
||
{
|
||
EventBus.Instance.Publish(new DepositRefundOrderEvent(deposit.id, (int)orderRefund.id, orderRefund.auditstatus, orderRefund.auditor.Value, orderRefund.auditorname, orderRefund.audittime.Value, deposit.isuse, deposit.companycode));
|
||
}
|
||
return Json(audret, JsonRequestBehavior.AllowGet);
|
||
}
|
||
else
|
||
{
|
||
var order = _order.GetModel(orderRefund.orderid);
|
||
|
||
if (status == 220)
|
||
{
|
||
//只退款,不修改订单状态,不关闭权限
|
||
orderRefund.auditstatus = 1;
|
||
orderRefund.auditor = int.Parse(UserId.ToString());
|
||
orderRefund.auditorname = UserName;
|
||
orderRefund.audittime = DateTime.Now;
|
||
orderRefund.att2 = orderRefundDto.att2;
|
||
|
||
retMsg audret = _orderRefund.Audit(orderRefund, order);
|
||
if (audret.result)
|
||
{
|
||
//推送订单状态
|
||
EventBus.Instance.Publish(new RefundOrderEvent(Convert.ToInt32(order.ORDERID), order.ORDERSTATUS, order.ORDERSTATUSNAME, order.companycode, (int)orderRefund.id, orderRefund.auditstatus, orderRefund.auditor.Value, orderRefund.auditorname, orderRefund.audittime.Value, Convert.ToInt32(order.ISOPEN.Value), orderRefund.channel));
|
||
}
|
||
return Json(audret, JsonRequestBehavior.AllowGet);
|
||
}
|
||
else
|
||
{
|
||
var subProductList = _subProduct.GetSubProductListByProductId(0, 0, null);
|
||
var subProduct = subProductList.FirstOrDefault(p => p.SUBPRODUCTID == order.SUBPRODUCTID);
|
||
//正常订单退款
|
||
var contract = _orderRefundContract.Get(p => p.OrderId == orderRefund.orderid);
|
||
if (orderRefund.isacturalrefund == 1 && (contract == null || contract.ContractStatus != 2) && order.ISOPEN == 1 && subProduct.IsCompliance == 1)
|
||
{
|
||
return Json(new retMsg { result = false, retmsg = "该退款方式需要签退款协议,请确认!" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
var handblOrderList = handbl.GetListByMainOrderId(orderRefund.orderid);
|
||
if (handblOrderList != null && handblOrderList.Any())
|
||
{
|
||
HandleGiftController handleGiftController = new HandleGiftController();
|
||
foreach (var handblOrder in handblOrderList)
|
||
{
|
||
var handleResult = handleGiftController.Close2(handblOrder.orderid, "");
|
||
var result = handleResult.Data as retMsg;
|
||
if (!result.result)
|
||
{
|
||
return handleResult;
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(order.activeproductext))
|
||
{
|
||
#region 随单 赠送订单退款
|
||
|
||
var activeProductExt = Utility.JSONToObject<List<ActiveProduct>>(order.activeproductext);
|
||
activeProductExt.Reverse();
|
||
var i = 0;
|
||
foreach (var item in activeProductExt)
|
||
{
|
||
var refundReq = new freeOrderClose { userName = order.SOFTUSERNAME, orderId = item.SzzyOrderId.ToString(), flag = "0" };
|
||
var param = JsonHelper.ObjDivertToJson(sHelper.createAjaxSignEncodingStr(JsonHelper.ObjDivertToJson(refundReq), SecurityHelper.OrderClientIdKey));
|
||
var refundRet = Utility.PostAjaxData(url2, param, Encoding.UTF8);
|
||
var refundRetMsg = JsonHelper.JsonDivertToObj<freeOrderCloseRes>(refundRet);
|
||
if (refundRetMsg.iRet == 0)
|
||
{
|
||
i++;
|
||
}
|
||
else
|
||
{
|
||
LogHelper.Error("执行退款--赠送订单关闭失败:参数:" + refundRet + "--执行结果:+" + refundRet);
|
||
}
|
||
}
|
||
//手工赠送订单退款
|
||
var handgiftOrder = _SzzyOrder_HandGift_BL.GetList(order.ORDERID);
|
||
foreach (var item in handgiftOrder)
|
||
{
|
||
//审核通过后才有权限id
|
||
if (item.orderstatus == 1&&item.szzyorderid.HasValue)
|
||
{
|
||
var refundReq = new freeOrderClose { userName = order.SOFTUSERNAME, orderId = item.szzyorderid.ToString(), flag = "0" };
|
||
var param = JsonHelper.ObjDivertToJson(sHelper.createAjaxSignEncodingStr(JsonHelper.ObjDivertToJson(refundReq), SecurityHelper.OrderClientIdKey));
|
||
var refundRet = Utility.PostAjaxData(url2, param, Encoding.UTF8);
|
||
var refundRetMsg = JsonHelper.JsonDivertToObj<freeOrderCloseRes>(refundRet);
|
||
if (refundRetMsg.iRet == 0)
|
||
{
|
||
i++;
|
||
}
|
||
else
|
||
{
|
||
LogHelper.Error("执行退款--手工赠送订单关闭失败:参数:" + refundRet + "--执行结果:+" + refundRet);
|
||
}
|
||
}
|
||
}
|
||
var giftCount = activeProductExt.Count + handgiftOrder.Count;
|
||
if (i == giftCount)
|
||
{
|
||
return RefundNode(order, orderRefund, status);
|
||
}
|
||
else
|
||
{
|
||
return Json(new retMsg { result = false, retmsg = "付费订单退款成功,但赠送订单退款失败,请重试!" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
#endregion 随单 赠送订单退款
|
||
}
|
||
else
|
||
{
|
||
return RefundNode(order, orderRefund, status);
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
|
||
var retmsg = _refundService.Audit(orderRefundDto, status, int.Parse(UserId.ToString()), UserName);
|
||
|
||
return Json(retmsg, JsonRequestBehavior.AllowGet);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
return Json(new retMsg
|
||
{
|
||
result = false,
|
||
retmsg = ex.ToString()
|
||
}, JsonRequestBehavior.AllowGet);
|
||
}
|
||
}
|
||
|
||
private JsonResult RefundNode(WX_SZZYORDER order, WX_SzzyOrderRefund orderRefund, int status)
|
||
{
|
||
var curMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
|
||
var url = paramter_bl.GetValue_Parameter(Parameter.UserCenter_RiaService_refund);//封装出来的接口
|
||
|
||
#region =================调用NodeJs退款订单========================
|
||
|
||
LogHelper.Info("====调用NodeJs创建订单===");
|
||
RefundOrderReq suorder = new RefundOrderReq
|
||
{
|
||
orderId = order.SZZYORDERID.ToString(),
|
||
refundStatus = 200,//退款状态
|
||
cancelAmount = Convert.ToInt32(orderRefund.refundprice * 100)//退款金额
|
||
};
|
||
|
||
string json = JsonHelper.ObjDivertToJson(suorder);
|
||
LogHelper.Info("Node.JS接口参数json=>:" + json);
|
||
json = JsonHelper.ObjDivertToJson(sHelper.createAjaxSignEncodingStr(json, SecurityHelper.OrderClientIdKey));
|
||
string retmsg = Utility.PostAjaxData(url, json, Encoding.UTF8);//返回信息
|
||
|
||
RefundOrderRsp retmessage = JsonHelper.JsonDivertToObj<RefundOrderRsp>(retmsg);
|
||
LogHelper.Info("Node.JS接口返回数据json=>:" + retmsg);
|
||
|
||
#endregion =================调用NodeJs退款订单========================
|
||
|
||
#region =================调用NodeJs修改订单状态========================
|
||
|
||
if (retmessage.retCode == (int)NodeJsOrderEnum.调用成功 || retmessage.retCode == (int)NodeJsOrderEnum.已经开通)
|
||
{
|
||
LogHelper.Info("====调用NodeJs创建订单===");
|
||
suorder.refundStatus = 220;//退款状态
|
||
|
||
json = JsonHelper.ObjDivertToJson(suorder);
|
||
LogHelper.Info("Node.JS接口参数json=>:" + json);
|
||
json = JsonHelper.ObjDivertToJson(sHelper.createAjaxSignEncodingStr(json, SecurityHelper.OrderClientIdKey));
|
||
retmsg = Utility.PostAjaxData(url, json, Encoding.UTF8);//返回信息
|
||
LogHelper.Info("Node.JS接口返回数据json=>:" + retmsg);
|
||
|
||
//retmsg = sHelper.decyptData(SecurityHelper.OrderClientIdKey, retmsg);
|
||
|
||
retmessage = JsonHelper.JsonDivertToObj<RefundOrderRsp>(retmsg);
|
||
orderRefund.auditstatus = 1;
|
||
orderRefund.auditor = int.Parse(UserId.ToString());
|
||
orderRefund.auditorname = UserName;
|
||
orderRefund.audittime = DateTime.Now;
|
||
// orderRefund.att2 = orderRefundDto.att2;
|
||
orderRefund.refunddate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
||
|
||
if (retmessage.retCode == (int)NodeJsOrderEnum.调用成功)//开通成功
|
||
{
|
||
if (status == 70)
|
||
{
|
||
order.ORDERSTATUS = "70";
|
||
order.ORDERSTATUSNAME = "已取消";
|
||
}
|
||
else
|
||
{
|
||
order.ORDERSTATUS = "90";
|
||
order.ORDERSTATUSNAME = "已退款";
|
||
}
|
||
//if (order.ARRIVALTIME >= curMonth)
|
||
//{
|
||
// order.ISOPEN = 0;
|
||
//}
|
||
|
||
//_order.Update(order);//修改退款状态
|
||
|
||
retMsg audret = _orderRefund.Audit(orderRefund, order);
|
||
if (audret.result)
|
||
{
|
||
//推送订单状态
|
||
EventBus.Instance.Publish(new RefundOrderEvent(Convert.ToInt32(order.ORDERID), order.ORDERSTATUS, order.ORDERSTATUSNAME, order.companycode, (int)orderRefund.id, orderRefund.auditstatus, orderRefund.auditor.Value, orderRefund.auditorname, orderRefund.audittime.Value, Convert.ToInt32(order.ISOPEN.Value), orderRefund.channel));
|
||
}
|
||
return Json(audret, JsonRequestBehavior.AllowGet);
|
||
}
|
||
else if (retmessage.retCode == (int)NodeJsOrderEnum.已经开通)//已经退款过
|
||
{
|
||
if (status == 70)
|
||
{
|
||
order.ORDERSTATUS = "70";
|
||
order.ORDERSTATUSNAME = "已取消";
|
||
}
|
||
else
|
||
{
|
||
order.ORDERSTATUS = "90";
|
||
order.ORDERSTATUSNAME = "已退款";
|
||
}
|
||
//if (order.ARRIVALTIME >= curMonth)
|
||
//{
|
||
// order.ISOPEN = 0;
|
||
//}
|
||
|
||
//_order.Update(order);//修改退款状态
|
||
|
||
var audret = _orderRefund.Audit(orderRefund, order);
|
||
if (audret.result)
|
||
{
|
||
//推送订单状态
|
||
EventBus.Instance.Publish(new RefundOrderEvent(Convert.ToInt32(order.ORDERID), order.ORDERSTATUS, order.ORDERSTATUSNAME, order.companycode, (int)orderRefund.id, orderRefund.auditstatus, orderRefund.auditor.Value, orderRefund.auditorname, orderRefund.audittime.Value, Convert.ToInt32(order.ISOPEN.Value), orderRefund.channel));
|
||
}
|
||
return Json(audret, JsonRequestBehavior.AllowGet);
|
||
}
|
||
else
|
||
{
|
||
return Json(new retMsg { result = false, retmsg = string.IsNullOrEmpty(retmessage.retMsg) ? Utility.GetCheckEnumNameByValue<NodeJsOrderEnum>(retmessage.retCode) : retmessage.retMsg }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(new retMsg { result = false, retmsg = string.IsNullOrEmpty(retmessage.retMsg) ? Utility.GetCheckEnumNameByValue<NodeJsOrderEnum>(retmessage.retCode) : retmessage.retMsg }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
#endregion =================调用NodeJs修改订单状态========================
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_Delete, false)]
|
||
public JsonResult Delete(int id)
|
||
{
|
||
var orderRefund = _orderRefund.Get(p => p.id == id);
|
||
if (orderRefund != null)
|
||
{
|
||
if (orderRefund.auditstatus == 1)
|
||
{
|
||
return Json(new retMsg { result = false, retmsg = "audit" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
else
|
||
{
|
||
orderRefund.isdelete = 1;
|
||
var res = _orderRefund.Update(orderRefund);
|
||
if (res)
|
||
{
|
||
EventBus.Instance.Publish(new DeleteRefundOrderEvent(Convert.ToInt32(orderRefund.id), orderRefund.companycode));
|
||
return Json(new retMsg { result = true, retmsg = "ok" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
else
|
||
return Json(new retMsg { result = false, retmsg = "error" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
}
|
||
return Json(new retMsg { result = false, retmsg = "error" }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[HttpGet]
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_Other3, false)]
|
||
public FileResult ExportData(string param)
|
||
{
|
||
var dto = JsonConvert.DeserializeObject<OrderRefundSelectDto>(param);
|
||
Laypage pager = new Laypage
|
||
{
|
||
page = 1,
|
||
limit = 100000,
|
||
};
|
||
//var list = _order.GetList(ref pager, dto);
|
||
dto.pager = pager;
|
||
var list = _orderRefund.GetList(dto);
|
||
LogHelper.Info($"导出查询到{list.Count}数据");
|
||
//List<WX_SZZYORDER_ExportView> res = new List<WX_SZZYORDER_ExportView>();
|
||
//foreach(var item in list)
|
||
//{
|
||
// res.Add(new WX_SZZYORDER_ExportView
|
||
// {
|
||
// ORDERID = item.ORDERID,
|
||
// RESID = item.RESID,
|
||
// CNAME = item.CNAME,
|
||
// SUBPRODUCTNAME = item.SUBPRODUCTNAME,
|
||
// ORDERSTATUSNAME = item.ORDERSTATUSNAME,
|
||
// OTIME = item.OTIME,
|
||
// ORIGINPAY = item.ORIGINPAY,
|
||
// ARRIVALPAY = item.ARRIVALPAY,
|
||
// ARRIVALTIME = item.ARRIVALTIME,
|
||
// NEEDPAY = item.NEEDPAY,
|
||
// OPENDAYS = item.OPENDAYS,
|
||
// CTIME = item.CTIME,
|
||
// UPGRADEORDERIDS = item.UPGRADEORDERIDS,
|
||
// MidProductName = item.MidProductName,
|
||
// CHANNELNAME = item.CHANNELNAME,
|
||
// giftdays = item.giftdays,
|
||
// CONTRACTCODE = item.CONTRACTCODE,
|
||
// ai_hgrecord_statusname = item.ai_hgrecord_statusname
|
||
// });
|
||
//}
|
||
|
||
string checkedFilds = Server.UrlDecode(Request.Cookies["checkedFilds"].Value);
|
||
string checkedTitle = Server.UrlDecode(Request.Cookies["checkedTitles"].Value);
|
||
Request.Cookies.Remove("checkedFilds");//用完后删除cookies
|
||
Request.Cookies.Remove("checkedTitles");//用完后删除cookies
|
||
|
||
//string checkedFilds = Request.QueryString["checkedFilds"];
|
||
//checkedFilds = checkedFilds.Replace("[]", "");
|
||
//string checkedTitles = Request.QueryString["checkedTitles"];
|
||
|
||
String file = string.Format("OrderList{0}.xls", DateTime.Now.ToLocalTime().ToString("yyyyMMddHHmmssfffff"));
|
||
return File(ExcelHelper.ExportListModelToExcel<OrderRefundView>(list, "OrderList", 30000, checkedFilds, checkedTitle, DataFormart), "application/ms-excel", file);
|
||
}
|
||
|
||
public string DataFormart(string key, object value)
|
||
{
|
||
string formartValue = string.Empty;
|
||
switch (key)
|
||
{
|
||
case "applytype":
|
||
if (Convert.ToInt32(value) == 1)
|
||
formartValue = "合规申请";
|
||
else
|
||
formartValue = "业务申请";
|
||
break;
|
||
|
||
case "isacturalrefund":
|
||
if (Convert.ToInt32(value) == 0)
|
||
formartValue = "退回余额";
|
||
else
|
||
formartValue = "需实际退款";
|
||
break;
|
||
case "innamelist":
|
||
if (Convert.ToInt32(value) == 1)
|
||
formartValue = "在名单";
|
||
else
|
||
formartValue = "";
|
||
break;
|
||
|
||
case "contractstatus":
|
||
if (value == null)
|
||
formartValue = "";
|
||
else if (Convert.ToInt32(value) == 1)
|
||
formartValue = "事业部通过";
|
||
else if (Convert.ToInt32(value) == 2)
|
||
formartValue = "总部通过";
|
||
else
|
||
formartValue = "未通过";
|
||
break;
|
||
|
||
default: formartValue = string.Format("{0}", value); break;
|
||
}
|
||
return formartValue;
|
||
}
|
||
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_退款管理, ToolBarConfig.CONST_Other1, false)]
|
||
public JsonResult UploadAtt()
|
||
{
|
||
var file = Request.Files[0];
|
||
|
||
var vPath = System.Configuration.ConfigurationManager.AppSettings["UploadTemFileDic"] + "/att";
|
||
var rootPath = Server.MapPath(vPath);
|
||
if (!System.IO.Directory.Exists(rootPath))
|
||
{
|
||
System.IO.Directory.CreateDirectory(rootPath);
|
||
}
|
||
var saveFileName = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName);
|
||
var urlPath = vPath + "/" + saveFileName;
|
||
var fileName = Path.Combine(rootPath, saveFileName);
|
||
file.SaveAs(fileName);
|
||
|
||
return Json(new retMsg { result = true, retcode = 1, retmsg = urlPath }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[HttpGet]
|
||
[AuthorizeRedirect(RightsConfig.CONST_合规订单列表, ToolBarConfig.CONST_Other3, true)]
|
||
public ActionResult Contract(int orderId, string id)
|
||
{
|
||
var model = _order.GetModel(orderId);
|
||
//todo:已经审核过的暂时不要统计进来,可以处理多退部分的场景
|
||
var refundOrder = _orderRefund.GetList(p => p.orderid == orderId && p.isacturalrefund != 0).Where(p => p.isdelete == 0);//需实际退款的数据才搞进来
|
||
var contract = _orderRefundContract.Get(p => p.OrderId == orderId);
|
||
if (model == null || !refundOrder.Any())
|
||
{
|
||
return View(model);
|
||
}
|
||
int refId = Convert.ToInt32(id);
|
||
var refundInfo = refundOrder.FirstOrDefault(m => m.id == refId);
|
||
//if (model.ISFINANCEPAY == 0)
|
||
//{
|
||
// return Content("该订单未开通不需要签退款协议!");
|
||
//}
|
||
|
||
var subProductList = _subProduct.GetSubProductListByProductId(0, 0, null);
|
||
var subProduct = subProductList.FirstOrDefault(p => p.SUBPRODUCTID == model.SUBPRODUCTID);
|
||
if (subProduct == null)
|
||
{
|
||
return Content("参数错误!");
|
||
}
|
||
//if (subProduct.IsCompliance == 0)
|
||
//{
|
||
// return Content("该订单不需要签退款协议!");
|
||
//}
|
||
|
||
var refundPrice = refundOrder.Where(m => m.auditstatus != 2).Sum(p => p.refundprice);//废弃的退款申请不能算进去
|
||
if (refundPrice > model.ARRIVALPAY)
|
||
{
|
||
return Content("退款金额不能大于到账金额,请确认!");
|
||
}
|
||
string url1 = paramter_bl.GetValue_Parameter(Parameter.UserCenter_RiaService_NewRefundContract);//合同地址
|
||
string url2 = paramter_bl.GetValue_Parameter(Parameter.UserCenter_RiaService_NewUnRefundContract);//合同作废地址
|
||
LogHelper.Info("退款合同金额计算:" + refundPrice);
|
||
var time = refundOrder.First().ctime;//第一次退款时间
|
||
var json2 = new
|
||
{
|
||
RefundPrice = refundPrice,
|
||
SoftUserName = model.SOFTUSERNAME,
|
||
OrderId = model.SZZYORDERID.ToString(),
|
||
ContractTime = time.ToString(),
|
||
ContractTimeStr = time.ToString("yyyy年MM月dd日"),// string.Format("{0:D}", time),
|
||
OldContractTimeStr = contract == null ? "" : contract.ContractTime.Value.ToString("yyyy年MM月dd日") //string.Format("{0:D}", contract.CONTRACTTIME)
|
||
};
|
||
|
||
string clientid = SecurityHelper.OrderClientIdKey;
|
||
string content = sHelper.encyptData(clientid, Utility.ConvertToJSON(json2));
|
||
string sign = sHelper.signData(clientid, content);
|
||
var htUrl = url1 + string.Format("?content={0}&sign={1}&clientId={2}&protocolType=", HttpUtility.UrlEncode(content), HttpUtility.UrlEncode(sign), clientid);//合同地址
|
||
|
||
|
||
#region 取消退款协议
|
||
var json3 = new
|
||
{
|
||
RefundPrice = refundPrice,
|
||
SoftUserName = model.SOFTUSERNAME,
|
||
OrderId = model.SZZYORDERID.ToString(),
|
||
ContractTime = time.ToString(),
|
||
ContractTimeStr = time.ToString("yyyy年MM月dd日"),// string.Format("{0:D}", time),
|
||
OldContractTimeStr = !refundInfo.customer_cancel_time.HasValue ? "" : refundInfo.customer_cancel_time.Value.ToString("yyyy年MM月dd日") //string.Format("{0:D}", contract.CONTRACTTIME)
|
||
};
|
||
|
||
string content2 = sHelper.encyptData(clientid, Utility.ConvertToJSON(json2));
|
||
string sign2 = sHelper.signData(clientid, content);
|
||
var cancelHtUrl = url2 + string.Format("?content={0}&sign={1}&clientId={2}&protocolType=", HttpUtility.UrlEncode(content2), HttpUtility.UrlEncode(sign2), clientid);//合同地址
|
||
ViewBag.cancelHtUrl = cancelHtUrl;
|
||
int showCancelUrl = 0;
|
||
if (refundInfo.auditstatus != 1 && contract != null)//退款状态不能是已退款
|
||
{
|
||
showCancelUrl = 1;
|
||
}
|
||
ViewBag.showCancelUrl = showCancelUrl;
|
||
|
||
|
||
|
||
var viewSource = "数智化合规系统";
|
||
var pageSource = "Audit:退款管理.风控";
|
||
var url = paramter_bl.GetValue_Parameter(Parameter.UserCenter_RiaService_SignPdf);
|
||
//风险揭示书
|
||
content = sHelper.encyptData(clientid, "UNT_DN" + model.SZZYORDERID.ToString());
|
||
sign = sHelper.signData(clientid, content);
|
||
string fxjssUrl = string.Format("{0}/{4}-关于退款协议的作废声明.pdf?content={1}&sign={2}&clientId={3}&employeeId={5}&employeeName={6}&viewSource={7}&pageSource={8}",
|
||
url,
|
||
HttpUtility.UrlEncode(content),
|
||
HttpUtility.UrlEncode(sign),
|
||
clientid,
|
||
model.SUBPRODUCTNAME,
|
||
Eid,
|
||
UserName,
|
||
viewSource,
|
||
pageSource
|
||
);
|
||
ViewBag.untkpdf = fxjssUrl;
|
||
ViewBag.showCancle = refundInfo.customer_cancel_time.HasValue;
|
||
|
||
#endregion
|
||
|
||
//=============================================
|
||
viewSource = "数智化合规系统";
|
||
pageSource = "Audit:退款管理.风控";
|
||
//风险揭示书
|
||
content = sHelper.encyptData(clientid, "T_DN" + model.SZZYORDERID.ToString());
|
||
sign = sHelper.signData(clientid, content);
|
||
fxjssUrl = string.Format("{0}/{4}-退款协议.pdf?content={1}&sign={2}&clientId={3}&employeeId={5}&employeeName={6}&viewSource={7}&pageSource={8}",
|
||
url,
|
||
HttpUtility.UrlEncode(content),
|
||
HttpUtility.UrlEncode(sign),
|
||
clientid,
|
||
model.SUBPRODUCTNAME,
|
||
Eid,
|
||
UserName,
|
||
viewSource,
|
||
pageSource
|
||
);
|
||
ViewBag.tkpdf = fxjssUrl;
|
||
try
|
||
{
|
||
var contractUrl = paramter_bl.GetValue_Parameter(Parameter.NewContractInfoUrl);
|
||
var contractInfo = $"{contractUrl}/v1/api/h5/getContractInfo";
|
||
var nowtime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||
var ctObj = new
|
||
{
|
||
uid = model.SOFTUSERNAME,
|
||
orderId = model.SZZYORDERID.Value.ToString(),
|
||
hqrTime = nowtime
|
||
};
|
||
var hqr = BlowFish.encode(ctObj.ToJson());
|
||
var para = new { hqr };
|
||
var res = Utility.PostAjaxData(contractInfo, para.ToJson(), Encoding.UTF8);
|
||
LogHelper.Info($"获取退款协议身份证信息{res}");
|
||
var faceInfo = JsonHelper.FromJson<ContractInfo>(res);
|
||
if (faceInfo.ret == 0)
|
||
{
|
||
if (faceInfo.hasRefundIdCard)
|
||
{
|
||
ViewBag.status = faceInfo.refundIdCard.state;
|
||
ViewBag.idCardName = faceInfo.refundIdCard.name;
|
||
ViewBag.idCardNo = faceInfo.refundIdCard.idCardNo;
|
||
ViewBag.idCardTypeDescribe = faceInfo.refundIdCard.idCardTypeDescribe;
|
||
var idcardUrl = $"{contractUrl}/v1/api/h5/getOrderRefundIdCard";
|
||
var frontobj = new
|
||
{
|
||
uid = model.SOFTUSERNAME,
|
||
orderId = model.SZZYORDERID.Value.ToString(),
|
||
cardFrontFile = faceInfo.refundIdCard.cardFrontFile
|
||
};
|
||
string facecontent = sHelper.encyptData(clientid, Utility.ConvertToJSON(frontobj));
|
||
string facesign = sHelper.signData(clientid, facecontent);
|
||
ViewBag.cardFrontFile = idcardUrl + string.Format("?content={0}&sign={1}&clientId={2}&protocolType=", HttpUtility.UrlEncode(facecontent), HttpUtility.UrlEncode(facesign), clientid);
|
||
var backobj = new
|
||
{
|
||
uid = model.SOFTUSERNAME,
|
||
orderId = model.SZZYORDERID.Value.ToString(),
|
||
cardReverseSideFile = faceInfo.refundIdCard.cardReverseSideFile
|
||
};
|
||
var backcontent = sHelper.encyptData(clientid, Utility.ConvertToJSON(backobj));
|
||
var backsign = sHelper.signData(clientid, backcontent);
|
||
ViewBag.cardReverseSideFile = idcardUrl + string.Format("?content={0}&sign={1}&clientId={2}&protocolType=", HttpUtility.UrlEncode(backcontent), HttpUtility.UrlEncode(backsign), clientid);
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error($"获取合同人脸或者身份证失败{ex.Message}");
|
||
}
|
||
ViewBag.htUrl = htUrl;//合同Url
|
||
ViewBag.contract = contract == null ? string.Empty : contract.Contract;
|
||
ViewBag.contractstatus = contract == null ? 0 : contract.ContractStatus;
|
||
ViewBag.contractKey = contract == null ? string.Empty : contract.ContractKey;
|
||
ViewBag.IdCardStatus = model?.RefundIdCardStatus;
|
||
ViewBag.IdCardRemark = model?.RefundIdCardRemark;
|
||
return View(model);
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_合规订单列表, ToolBarConfig.CONST_Other3, false)]
|
||
public JsonResult Contract(int orderId, int status)
|
||
{
|
||
var refundOrder = _orderRefundContract.Get(p => p.OrderId == orderId);
|
||
var order = _order.Get(p => p.ORDERID == orderId);
|
||
|
||
if (refundOrder != null && order != null)
|
||
{
|
||
refundOrder.ContractStatus = status;
|
||
_orderRefundContract.Update(refundOrder);
|
||
|
||
EventBus.Instance.Publish(new FinishRefundContractEvent(orderId, status, order.companycode, Eid, UserName));
|
||
}
|
||
|
||
return Json(new retMsg { result = true }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_合规订单列表, ToolBarConfig.CONST_Other3, false)]
|
||
public JsonResult ContractPass(int orderId, int status)
|
||
{
|
||
var order = _order.Get(p => p.ORDERID == orderId);
|
||
var orderRefundContract = _orderRefundContract.Get(p => p.OrderId == orderId);
|
||
if (orderRefundContract == null && order != null)
|
||
{
|
||
var contract = new Wx_SzzyOrderRefundContract(orderId, "DN" + order.SZZYORDERID.ToString(), order.ARRIVALPAY.HasValue ? order.ARRIVALPAY.Value : 0, status, DateTime.Now, "pass", order.CHANNEL);
|
||
_orderRefundContract.Add(contract);
|
||
}
|
||
|
||
return Json(new retMsg { result = true }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[HttpGet]
|
||
[AuthorizeRedirect(RightsConfig.CONST_查看流水, ToolBarConfig.CONST_Other1, true)]
|
||
public ActionResult QueryRefundInfo()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_查看流水, ToolBarConfig.CONST_Other1, false)]
|
||
public JsonResult QueryRefundInfo(Laypage pager, string umid)
|
||
{
|
||
try
|
||
{
|
||
List<OrderDepositView> list = _orderDeposit.GetDepositByUmid(umid, pager);
|
||
|
||
var data = new LayuiData<OrderDepositView>()
|
||
{
|
||
msg = "数据加载成功!",
|
||
count = pager.count,
|
||
code = 0,
|
||
data = list
|
||
};
|
||
return Json(data, JsonRequestBehavior.AllowGet);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
return Json(new retMsg
|
||
{
|
||
result = false,
|
||
retmsg = ex.ToString()
|
||
}, JsonRequestBehavior.AllowGet);
|
||
}
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_合规订单列表, ToolBarConfig.CONST_Other9, false)]
|
||
public JsonResult IdCardAudit(IdCardAuditDto dto)
|
||
{
|
||
var order = _order.Get(p => p.ORDERID == dto.OrderId);
|
||
var contractInfo = _cache.GetValue_Parameter("NewContractInfoUrl");
|
||
var url = $"{contractInfo}/v1/api/h5/setOrderRefundIdCardState";
|
||
var nowtime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||
var ctObj = new
|
||
{
|
||
uid = order.SOFTUSERNAME,
|
||
orderId = order.SZZYORDERID.Value.ToString(),
|
||
hqrTime = nowtime,
|
||
orderIdCardState = dto.Status == -1 ? 0 : dto.Status
|
||
};
|
||
var hqr = BlowFish.encode(ctObj.ToJson());
|
||
var para = new { hqr };
|
||
var res = Utility.PostAjaxData(url, para.ToJson(), Encoding.UTF8);
|
||
var data = JsonConvert.DeserializeObject<IdCardApiResult>(res);
|
||
if (data.ret == 0)
|
||
{
|
||
order.RefundIdCardStatus = dto.Status;
|
||
order.RefundIdCardRemark = dto.Remark;
|
||
_order.Update(order);
|
||
}
|
||
return Json(data, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
public class IdCardApiResult
|
||
{
|
||
public int ret { get; set; }
|
||
public string msg { get; set; }
|
||
}
|
||
|
||
public class ContractInfo
|
||
{
|
||
public int ret { get; set; }
|
||
public bool hasFaceVerify { get; set; }
|
||
public bool hasOrderIdCard { get; set; }
|
||
public bool hasRefundIdCard { get; set; }
|
||
|
||
public string msg { get; set; }
|
||
public string faceVerify { get; set; }
|
||
public orderIdCardInfo orderIdCard { get; set; }
|
||
public orderIdCardInfo refundIdCard { get; set; }
|
||
}
|
||
|
||
public class orderIdCardInfo
|
||
{
|
||
public string state { get; set; }
|
||
public string name { get; set; }
|
||
public string idCardNo { get; set; }
|
||
public int idCardType { get; set; }
|
||
public string idCardTypeDescribe { get; set; }
|
||
public string cardFrontFile { get; set; }
|
||
public string cardReverseSideFile { get; set; }
|
||
}
|
||
} |