| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using Microsoft.AspNetCore.Authorization;
- using System.Web;
- using MySystem.Models.Main2;
- using MySystem.Service.Main2;
- using LitJson;
- using Library;
- using MySystem.Service.KxsMain;
- namespace MySystem.Areas.Api.Controllers.v1.Main2
- {
- [Area("Api")]
- [Route("/v1/QrCodePlateMain/[controller]/[action]")]
- public class MerchantAddInfoController : BaseController
- {
- public MerchantAddInfoController(IHttpContextAccessor accessor) : base(accessor)
- {
- }
- #region 进件管理-银联商户列表
- [Authorize]
- public JsonResult UnionPayList(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Other = new Dictionary<string, object>();
- List<Dictionary<string, object>> dataList = UnionPayListDo(value, out Other);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
- }
- private List<Dictionary<string, object>> UnionPayListDo(string value, out Dictionary<string, object> Other)
- {
- JsonData data = JsonMapper.ToObject(value);
- string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
- string CertMerchantName = data["CertMerchantName"].ToString(); //商户名称
- string ServicePhone = data["ServicePhone"].ToString(); //客服电话
- string MakerCode = data["MakerCode"].ToString(); //所属创客编号
- string HDStatus = data["HDStatus"].ToString(); //好哒状态(-1 审核失败 0 待审核 3 已通过)
- string WeChatStatus = data["WeChatStatus"].ToString(); //微信状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
- string AliPayStatus = data["AliPayStatus"].ToString(); //支付宝状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
- string AgentName = data["Channel"].ToString(); //所属创客编号
- int BrandId = 0; //品牌(0 银联 1 好哒)
- int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
- int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
- string condition = "";
- var merIds = MerchantInfoUtil.QuerySenedMerchantId();
- condition = " and Id in (" + merIds + ")";
- if (!string.IsNullOrEmpty(data["SubjectType"].ToString()))
- {
- if (data["SubjectType"].ToString() == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
- if (data["SubjectType"].ToString() == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
- if (data["SubjectType"].ToString() == "3") SubjectType = "SUBJECT_TYPE_SMALL"; //小微商户
- condition += " and SubjectType='" + SubjectType + "'";
- }
- if (!string.IsNullOrEmpty(data["CertMerchantName"].ToString()))
- {
- condition += " and CertMerchantName like '%" + CertMerchantName + "%'";
- }
- if (!string.IsNullOrEmpty(data["ServicePhone"].ToString()))
- {
- condition += " and ServicePhone='" + ServicePhone + "'";
- }
- if (!string.IsNullOrEmpty(data["MakerCode"].ToString()))
- {
- var Ids = MerchantInfoUtil.QueryMerchantIdByMakerCode(MakerCode);
- condition += " and Id in (" + Ids + ")";
- }
- if (!string.IsNullOrEmpty(data["HDStatus"].ToString()))
- {
- if (int.Parse(HDStatus) == 3)
- {
- condition += " and HdStatus in(1,2,3)";
- }
- else
- {
- condition += " and Status=" + HDStatus + "";
- }
- }
- if (!string.IsNullOrEmpty(data["WeChatStatus"].ToString()))
- {
- condition += " and Status=" + WeChatStatus + "";
- }
- if (!string.IsNullOrEmpty(data["AliPayStatus"].ToString()))
- {
- condition += " and QueryCount=" + AliPayStatus + "";
- }
- if (!string.IsNullOrEmpty(data["BrandId"].ToString()))
- {
- BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString())); //品牌(0 银联 1 好哒)
- condition += " and BrandId=" + BrandId + "";
- }
- if (!string.IsNullOrEmpty(data["Channel"].ToString()))
- {
- condition += " and AgentName='" + AgentName + "'";
- }
- List<RelationData> relationData = new List<RelationData>();
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- Other = new Dictionary<string, object>();
- int count = 0;
- List<Dictionary<string, object>> source = MerchantAddInfoService.List(relationData, condition, out count, pageNum, pageSize);
- foreach (Dictionary<string, object> subdata in source)
- {
- Dictionary<string, object> curData = new Dictionary<string, object>();
- var hdStatus = int.Parse(subdata["HdStatus"].ToString());
- var status = int.Parse(subdata["Status"].ToString());
- var queryCount = int.Parse(subdata["QueryCount"].ToString());
- if (hdStatus != 3)
- {
- hdStatus = status;
- }
- //商户Id
- var MerchantId = int.Parse(subdata["Id"].ToString());
- //父商户Id
- var ParentId = int.Parse(subdata["ParentId"].ToString());
- //主体类型
- var subjectType = 0;
- if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_ENTERPRISE") subjectType = 1; //企业公司
- if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_INDIVIDUAL") subjectType = 2; //个体工商户
- if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_SMALL") subjectType = 3; //小微商户
- curData.Add("Id", subdata["Id"].ToString()); //Id
- curData.Add("BrandId", subdata["BrandId"].ToString()); //品牌(0 银联 1 好哒)
- curData.Add("SubjectType", subjectType); //主体类型(1 企业 2 个体 3 小微)
- curData.Add("CertMerchantName", subdata["CertMerchantName"].ToString()); //商户名称
- curData.Add("ServicePhone", subdata["ServicePhone"].ToString()); //客服电话
- curData.Add("BizStoreAddress", subdata["BizStoreAddress"].ToString()); //门店地址
- curData.Add("CreateDate", subdata["CreateDate"].ToString() == "" ? "" : DateTime.Parse(subdata["CreateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //进件时间
- var userInfo = UsersService.Query(MerchantInfoService.Query(MerchantId).UserId);
- curData.Add("MakerCode", userInfo.MakerCode); //所属创客编号
- curData.Add("RealName", userInfo.RealName); //所属创客姓名
- curData.Add("HDStatus", hdStatus); //好哒状态(-1 审核失败 0 待审核 3 已通过)
- curData.Add("WeChatStatus", status); //微信状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
- curData.Add("AliPayStatus", queryCount); //支付宝状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
- curData.Add("ParentName", MerchantInfoService.Query(ParentId).Name);
- curData.Add("UpdateDate", subdata["UpdateDate"].ToString() == "" ? "" : DateTime.Parse(subdata["UpdateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"));
- curData.Add("Channel", subdata["AgentName"].ToString()); //进件通道
- dataList.Add(curData);
- }
- Other.Add("Count", count); //总数
- return dataList;
- }
- #endregion
- #region 进件管理-获取商户门店号
- [Authorize]
- public JsonResult UnionPayGetStoreNo(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionPayGetStoreNoDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionPayGetStoreNoDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString()));
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var merAddInfo = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == MerchantId) ?? new MerchantAddInfo();
- var merInfo = main2db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId) ?? new MerchantInfo();
- merAddInfo.Status = 0;
- merInfo.Status = 0;
- RedisDbconn.Instance.AddList("UnionPayGetStoreNoQueue", MerchantId.ToString());
- main2db.SaveChanges();
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 进件管理-银联查看失败原因
- [Authorize]
- public JsonResult UnionPayQueryFailReason(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = UnionPayQueryFailReasonDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- private Dictionary<string, object> UnionPayQueryFailReasonDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var query = MerchantAddInfoService.Query(int.Parse(MerchantId));
- Obj.Add("HdReason", query.WeChatRemark); //好哒原因
- Obj.Add("WeChatReason", query.WeChatRemark); //微信原因
- Obj.Add("AlipayReason", query.AlipayRemark); //支付宝原因
- return Obj;
- }
- #endregion
- #region 进件管理-银联进件详情
- [Authorize]
- public JsonResult UnionPayDetail(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = UnionPayDetailDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- private Dictionary<string, object> UnionPayDetailDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- Obj = MerchantAddInfoUtil.MerchantAddInfoDetail(int.Parse(MerchantId));
- return Obj;
- }
- #endregion
- #region 进件管理-银联提交进件
- [Authorize]
- public JsonResult UnionPaySubmit(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionPaySubmitDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionPaySubmitDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- var info = MerchantAddInfoUtil.UnionPaySubmitDo(int.Parse(MerchantId));
- if (info == "success")
- {
- return new AppResultJson() { Status = "1", Info = "成功", Data = info };
- }
- else
- {
- return new AppResultJson() { Status = "-1", Info = "失败", Data = info };
- }
- }
- #endregion
- #region 商户管理-银联查询商户交易信息
- [Authorize]
- public JsonResult UnionPayQueryMerchantTradeInfo(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Other = new Dictionary<string, object>();
- List<Dictionary<string, object>> dataList = UnionPayQueryMerchantTradeInfoDo(value, out Other);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
- }
- private List<Dictionary<string, object>> UnionPayQueryMerchantTradeInfoDo(string value, out Dictionary<string, object> Other)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantName = data["MerchantName"].ToString(); //商户名称
- string Mobile = data["Mobile"].ToString(); //手机号码
- string MakerCode = data["MakerCode"].ToString(); //所属创客
- string MatchNo = data["MatchNo"].ToString(); //商户号
- string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体 3 小微)
- string IsAct = data["IsAct"].ToString(); //激活状态(0 未激活 1 已激活)
- string ActDate = data["ActDate"].ToString(); //激活时间
- int BrandId = 0; //品牌(0 银联 1 好哒)
- int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
- int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
- string condition = "";
- var merIds = MerchantInfoUtil.QueryAnyIsOkMerchantId();
- condition = " and Id in (" + merIds + ")";
- if (!string.IsNullOrEmpty(MerchantName))
- {
- condition += " and CertMerchantName like '%" + MerchantName + "%'";
- }
- if (!string.IsNullOrEmpty(Mobile))
- {
- condition += " and MobilePhone='" + Mobile + "'";
- }
- if (!string.IsNullOrEmpty(MakerCode))
- {
- var Ids = MerchantInfoUtil.QueryMerchantIdByMakerCode(MakerCode);
- condition += " and Id in (" + Ids + ")";
- }
- if (!string.IsNullOrEmpty(MatchNo))
- {
- condition += " and MchtNo='" + MatchNo + "'";
- }
- if (!string.IsNullOrEmpty(SubjectType))
- {
- if (SubjectType == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
- if (SubjectType == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
- if (SubjectType == "3") SubjectType = "SUBJECT_TYPE_SMALL"; //小微
- condition += " and SubjectType='" + SubjectType + "'";
- }
- if (!string.IsNullOrEmpty(IsAct))
- {
- var Ids = MerchantInfoUtil.QueryIsActMerchantId(int.Parse(IsAct));
- condition += " and Id in (" + Ids + ")";
- }
- if (!string.IsNullOrEmpty(data["ActDate"].ToString()))
- {
- string[] datelist = ActDate.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- var Ids = MerchantInfoUtil.QueryActDateMerchantId(start, end);
- condition += " and Id in (" + Ids + ")";
- }
- if (!string.IsNullOrEmpty(data["BrandId"].ToString()))
- {
- BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString())); //品牌(0 银联 1 好哒)
- condition += " and BrandId=" + BrandId + "";
- }
- List<RelationData> relationData = new List<RelationData>();
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- Other = new Dictionary<string, object>();
- int count = 0;
- List<Dictionary<string, object>> source = MerchantAddInfoService.List(relationData, condition, out count, pageNum, pageSize);
- foreach (Dictionary<string, object> subdata in source)
- {
- Dictionary<string, object> curData = new Dictionary<string, object>();
- //商户Id
- var MerchantId = int.Parse(subdata["Id"].ToString());
- var merInfo = MerchantInfoService.Query(MerchantId);
- var userInfo = UsersService.Query(merInfo.UserId);
- curData.Add("MerchantId", subdata["Id"].ToString()); //商户Id
- curData.Add("BrandId", subdata["BrandId"].ToString()); //品牌(0 银联 1 好哒)
- curData.Add("IsAct", merInfo.IsAct); //激活状态(0 未激活 1 已激活)
- var actDate = "";
- var order = MerchantDepositOrderService.Query(" and Status>0 and MerchantId=" + MerchantId + "");
- if (order.Id > 0)
- {
- actDate = order.UpdateDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
- }
- curData.Add("ActDate", actDate); //激活时间
- curData.Add("MerchantName", subdata["CertMerchantName"].ToString()); //商户名称
- curData.Add("Mobile", subdata["MobilePhone"].ToString()); //手机号码
- curData.Add("MakerCode", userInfo.MakerCode); //所属创客
- curData.Add("RealName", userInfo.RealName); //所属创客姓名
- var subjectType = 0;
- if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_ENTERPRISE") subjectType = 1; //企业公司
- if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_INDIVIDUAL") subjectType = 2; //个体工商户
- if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_SMALL") subjectType = 3; //小微
- curData.Add("SubjectType", subjectType); //主体类型(1 企业 2 个体 3 小微)
- curData.Add("MatchNo", subdata["MchtNo"].ToString()); //商户号
- var amountInfo = MerchantAmountSummayService.Sum("TradeCount,TotalActual,TradeAmount", " and MerchantId=" + MerchantId + "");
- curData.Add("OrderCount", decimal.Parse(amountInfo["TradeCount"].ToString())); //订单总数
- curData.Add("InComeAmount", decimal.Parse(amountInfo["TotalActual"].ToString()).ToString("f2")); //实收总金额
- curData.Add("TradeAmount", decimal.Parse(amountInfo["TradeAmount"].ToString()).ToString("f2")); //营业总金额
- dataList.Add(curData);
- }
- Other.Add("Count", count); //总数
- return dataList;
- }
- #endregion
- #region 节点操作-银联提交微信开户意愿
- [Authorize]
- public JsonResult UnionWeChatMerchantOpenAccount(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionWeChatMerchantOpenAccountDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionWeChatMerchantOpenAccountDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var merAddInfo = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
- if (merAddInfo.HdStatus != 3)
- {
- return new AppResultJson() { Status = "-1", Info = "商户未添加分账接收方账户", Data = Obj };
- }
- var merInfo = main2db.MerchantInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantInfo();
- merAddInfo.Status = 0;
- merAddInfo.ApplymentId = null;
- merAddInfo.WeChatSignUrl = null;
- merInfo.Status = 0;
- main2db.SaveChanges();
- RedisDbconn.Instance.AddList("WeChatForHaoDaQueue", id.ToString());
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 节点操作-银联提交支付宝开户意愿
- [Authorize]
- public JsonResult UnionAlipayMerchantOpenAccount(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionAlipayMerchantOpenAccountDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionAlipayMerchantOpenAccountDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var merAddInfo = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
- if (merAddInfo.HdStatus != 3)
- {
- return new AppResultJson() { Status = "-1", Info = "商户未添加分账接收方账户", Data = Obj };
- }
- var merInfo = main2db.MerchantInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantInfo();
- merAddInfo.QueryCount = 0;
- merAddInfo.SeoTitle = null;
- merAddInfo.AlipaySignUrl = null;
- merInfo.QueryCount = 0;
- main2db.SaveChanges();
- RedisDbconn.Instance.AddList("AlipayForHaoDaQueue", id.ToString());
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 节点操作-银联提交进件
- [Authorize]
- public JsonResult UnionMerchantAdd(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionMerchantAddDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionMerchantAddDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var merAddInfo = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
- var merInfo = main2db.MerchantInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantInfo();
- merAddInfo.Status = 0;
- merAddInfo.QueryCount = 0;
- merInfo.Status = 0;
- merInfo.QueryCount = 0;
- RedisDbconn.Instance.AddList("MerchantConfirmHdQueue", "{\"MerchantId\":\"" + id + "\"}");
- main2db.SaveChanges();
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 节点操作-银联绑定微信appid
- [Authorize]
- public JsonResult UnionMerchantBindWeChatAppId(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionMerchantBindWeChatAppIdDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionMerchantBindWeChatAppIdDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- var merAddInfo = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
- merAddInfo.HdBindWeChat = 0;
- main2db.SaveChanges();
- return new AppResultJson() { Status = "1", Info = "" };
- }
- #endregion
- #region 节点操作-银联获取好哒认证结果
- [Authorize]
- public JsonResult UnionMerchantGetAuth(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = UnionMerchantGetAuthDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- private Dictionary<string, object> UnionMerchantGetAuthDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- MerchantAddInfo query = new MerchantAddInfo();
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- query = MerchantAddInfoService.Query(id);
- Obj.Add("WeChatMerchantId", query.WeChatMerchantId); //微信商户号
- Obj.Add("AliMerchantId", query.AliMerchantId); //支付宝商户号
- Obj.Add("WeChatStatus", ""); //微信认证状态
- Obj.Add("AlipayStatus", ""); //支付宝认证状态
- return Obj;
- }
- #endregion
- #region 节点操作-银联获取审核状态
- [Authorize]
- public JsonResult UnionMerchantQueryStatus(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = UnionMerchantQueryStatusDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- private Dictionary<string, object> UnionMerchantQueryStatusDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- MerchantAddInfo query = new MerchantAddInfo();
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- query = MerchantAddInfoService.Query(id);
- Obj.Add("AlipaySignUrl", query.AlipaySignUrl); //支付宝签约地址
- Obj.Add("WeChatSignUrl", query.WeChatSignUrl); //微信签约地址
- Obj.Add("MchtNo", query.MchtNo); //好哒商户号
- Obj.Add("OutMchtNo", query.OutMchtNo); //慧掌柜商户号
- Obj.Add("StoreNo", query.StoreNo); //门店号
- Obj.Add("ToAcctNo", query.ToAcctNo); //分账接收方
- Obj.Add("HdPassDate", query.HdPassDate == null ? "" : query.HdPassDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //好哒审核通过时间
- Obj.Add("HdBindWeChat", query.HdBindWeChat); //好哒绑定微信状态
- string HdRemark = "";
- string WeChatRemark = "";
- string AlipayRemark = "";
- int HdStatus = 0;
- int WeChatStatus = 0;
- int AlipayStatus = 0;
- if (query.HdStatus == 0 && query.Status == -1)
- {
- HdStatus = -1;
- HdRemark = query.WeChatRemark;
- }
- if (query.HdStatus == 3)
- {
- WeChatStatus = query.Status;
- AlipayStatus = query.QueryCount;
- WeChatRemark = query.WeChatRemark;
- AlipayRemark = query.AlipayRemark;
- }
- Obj.Add("HdStatus", HdStatus); //好哒进件状态
- Obj.Add("HdRemark", HdRemark); //好哒备注
- Obj.Add("WeChatRemark", WeChatRemark); //微信备注
- Obj.Add("AlipayRemark", AlipayRemark); //支付宝备注
- Obj.Add("WeChatStatus", WeChatStatus); //微信审核状态
- Obj.Add("AlipayStatus", AlipayStatus); //微信审核状态
- return Obj;
- }
- #endregion
- #region 节点操作-好哒同步审核结果
- [Authorize]
- public JsonResult SycnMerchantQueryStatus(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- MerchantAddInfo add = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == id);
- if(add != null)
- {
- if(add.BrandId != 1)
- {
- return Json(new AppResultJson() { Status = "-1", Info = "不是好哒商户", Data = Obj });
- }
- if(!string.IsNullOrEmpty(add.OutMchtNo))
- {
- add.Status = 2;
- add.QueryCount = 2;
- add.HdStatus = 1;
- add.HdPassDate = DateTime.Now;
- }
- else
- {
- add.Status = 0;
- add.QueryCount = 0;
- }
- MerchantInfo mer = main2db.MerchantInfo.FirstOrDefault(m => m.Id == id);
- if(mer != null)
- {
- if(!string.IsNullOrEmpty(add.OutMchtNo))
- {
- mer.Status = 2;
- mer.QueryCount = 2;
- }
- else
- {
- mer.Status = 0;
- mer.QueryCount = 0;
- }
- }
- main2db.SaveChanges();
- return Json(new AppResultJson() { Status = "1", Info = "已同步", Data = Obj });
- }
- return Json(new AppResultJson() { Status = "-1", Info = "同步失败", Data = Obj });
- }
- #endregion
- #region 节点操作-删除商户
- [Authorize]
- public JsonResult DeleteMerchant(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- MerchantAddInfo add = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == id);
- if(add != null)
- {
- if(add.Status == 2 || add.QueryCount == 2)
- {
- return Json(new AppResultJson() { Status = "-1", Info = "已签约的商户不能删除", Data = Obj });
- }
- main2db.MerchantAddInfo.Remove(add);
- }
- MerchantInfo mer = main2db.MerchantInfo.FirstOrDefault(m => m.Id == id);
- if(mer != null)
- {
- main2db.MerchantInfo.Remove(mer);
- }
- main2db.SaveChanges();
- return Json(new AppResultJson() { Status = "1", Info = "已删除", Data = Obj });
- }
- #endregion
- #region 进件管理-银联修改商户名称
- [Authorize]
- public JsonResult UnionPayEditMerchantName(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionPayEditMerchantNameDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionPayEditMerchantNameDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- string MerchantName = data["MerchantName"].ToString(); //新商户名称
- string MerchantShortName = data["MerchantShortName"].ToString(); //新商户简称
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var Id = int.Parse(MerchantId);
- var query = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
- var merInfo = main2db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
- if (query.Id > 0)
- {
- if (!string.IsNullOrEmpty(MerchantName))
- {
- query.CertMerchantName = MerchantName;
- merInfo.Name = MerchantName;
- }
- if (!string.IsNullOrEmpty(MerchantShortName))
- {
- query.MerchantShortname = MerchantShortName;
- }
- }
- main2db.SaveChanges();
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 商户管理-银联查询商户交易信息导出
- [Authorize]
- public JsonResult ExportUnionPayQueryMerchantTradeInfo(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = ExportUnionPayQueryMerchantTradeInfoDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson ExportUnionPayQueryMerchantTradeInfoDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantName = data["MerchantName"].ToString(); //商户名称
- string Mobile = data["Mobile"].ToString(); //手机号码
- string MakerCode = data["MakerCode"].ToString(); //所属创客
- string MatchNo = data["MatchNo"].ToString(); //商户号
- string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体 3 小微)
- string IsAct = data["IsAct"].ToString(); //激活状态(0 未激活 1 已激活)
- string ActDate = data["ActDate"].ToString(); //激活时间
- string condition = "";
- var merIds = MerchantInfoUtil.QueryAnyIsOkMerchantId();
- condition = " and Id in (" + merIds + ")";
- if (!string.IsNullOrEmpty(MerchantName))
- {
- condition += " and CertMerchantName like '%" + MerchantName + "%'";
- }
- if (!string.IsNullOrEmpty(Mobile))
- {
- condition += " and MobilePhone='" + Mobile + "'";
- }
- if (!string.IsNullOrEmpty(MakerCode))
- {
- var Ids = MerchantInfoUtil.QueryMerchantIdByMakerCode(MakerCode);
- condition += " and Id in (" + Ids + ")";
- }
- if (!string.IsNullOrEmpty(MatchNo))
- {
- condition += " and MchtNo='" + MatchNo + "'";
- }
- if (!string.IsNullOrEmpty(SubjectType))
- {
- if (SubjectType == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
- if (SubjectType == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
- if (SubjectType == "3") SubjectType = "SUBJECT_TYPE_SMALL"; //小微
- condition += " and SubjectType='" + SubjectType + "'";
- }
- if (!string.IsNullOrEmpty(IsAct))
- {
- var Ids = MerchantInfoUtil.QueryIsActMerchantId(int.Parse(IsAct));
- condition += " and Id in (" + Ids + ")";
- }
- if (!string.IsNullOrEmpty(data["ActDate"].ToString()))
- {
- string[] datelist = ActDate.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = datelist[0];
- string end = datelist[1];
- var Ids = MerchantInfoUtil.QueryActDateMerchantId(start, end);
- condition += " and Id in (" + Ids + ")";
- }
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var Sql = "SELECT a.Id '商户Id',(CASE WHEN b.IsAct=0 THEN '未激活' WHEN b.IsAct=1 THEN '已激活' ELSE '' end) '激活状态',c.UpdateDate '激活时间',a.CertMerchantName '商户名称',a.MobilePhone '手机号码',b.UserId '所属创客Id',(CASE WHEN a.SubjectType='SUBJECT_TYPE_ENTERPRISE' THEN '企业公司' WHEN a.SubjectType='SUBJECT_TYPE_INDIVIDUAL' THEN '个体工商户' WHEN a.SubjectType='SUBJECT_TYPE_SMALL' THEN '小微' ELSE '' end) '主体类型',a.MchtNo '商户号',(SELECT SUM(TradeCount) TradeCount FROM QrCodePlateMainServer2.MerchantAmountSummay WHERE 1=1 AND MerchantId=a.Id) '订单总数',(SELECT SUM(TotalActual) TotalActual FROM QrCodePlateMainServer2.MerchantAmountSummay WHERE 1=1 AND MerchantId=a.Id)' 实收总金额',(SELECT SUM(TradeAmount) TradeAmount FROM QrCodePlateMainServer2.MerchantAmountSummay WHERE 1=1 AND MerchantId=a.Id) '营业总金额' FROM(SELECT Id,CertMerchantName,MobilePhone,MchtNo,SubjectType FROM QrCodePlateMainServer2.MerchantAddInfo WHERE 1=1 " + condition + " AND (Status=2 or QueryCount=2)) a LEFT JOIN (SELECT Id,IsAct,UserId FROM QrCodePlateMainServer2.MerchantInfo WHERE 1=1 AND Status=2 or QueryCount=2) b ON a.Id=b.Id LEFT JOIN (SELECT MerchantId,UpdateDate FROM QrCodePlateMainServer2.MerchantDepositOrder WHERE `Status`>0)c ON a.Id=c.MerchantId ORDER BY a.Id";
- var FileName = "商户管理-银联查询商户交易信息" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- string SendData = "{\"Operater\":\"" + AppConfig.LoginSession.sysId + "\",\"SqlString\":\"" + Sql + "\",\"FileName\":\"" + FileName + "\",\"MaxCount\":\"0\"}";
- RedisDbconn.Instance.AddList("ExportQueue", SendData);
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 银联结算管理-银联结算记录
- [Authorize]
- public JsonResult UnionPaySettlementRecordList(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Other = new Dictionary<string, object>();
- List<Dictionary<string, object>> dataList = UnionPaySettlementRecordListDo(value, out Other);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
- }
- private List<Dictionary<string, object>> UnionPaySettlementRecordListDo(string value, out Dictionary<string, object> Other)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantName = data["MerchantName"].ToString(); //商户名称
- string MerchantNo = data["MerchantNo"].ToString(); //商户号
- string SettlementDate = data["SettlementDate"].ToString(); //结算时间(必填)
- string SettleStatus = data["SettleStatus"].ToString(); //出款状态(0 入账成功 1 入账失败 2 结算超时 3 入账受理成功 4 已提交结算请求)
- string pageSize = data["page_size"].ToString();
- string pageNum = data["page_num"].ToString();
- var MerchantId = 0;
- string StartDate = "";
- string EndDate = "";
- if (!string.IsNullOrEmpty(data["MerchantName"].ToString()))
- {
- var merAddInfo = MerchantAddInfoService.Query(" and CertMerchantName='" + MerchantName + "'");
- MerchantId = merAddInfo.Id;
- }
- if (!string.IsNullOrEmpty(data["MerchantNo"].ToString()))
- {
- var merAddInfo = MerchantAddInfoService.Query(" and MchtNo='" + MerchantNo + "'");
- MerchantId = merAddInfo.Id;
- }
- if (!string.IsNullOrEmpty(data["SettlementDate"].ToString()))
- {
- string[] datelist = SettlementDate.Split(new string[] { " - " }, StringSplitOptions.None);
- StartDate = datelist[0];
- EndDate = datelist[1];
- }
- Other = new Dictionary<string, object>();
- var dataList = MySelfUtil.CardInComeRecordList(MerchantId, StartDate, EndDate, SettleStatus, pageSize, pageNum, out Other);
- Other = Other;
- return dataList;
- }
- #endregion
- #region 重置交易额-银联重置商户交易额
- [Authorize]
- public JsonResult UnionPayResetMerchantAmount(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionPayResetMerchantAmountDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionPayResetMerchantAmountDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- string TradeDate = data["TradeDate"].ToString(); //交易时间
- if (string.IsNullOrEmpty(data["MerchantId"].ToString()) || string.IsNullOrEmpty(data["TradeDate"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "商户Id和交易时间不能为空" };
- }
- string[] datelist = TradeDate.Split(new string[] { " - " }, StringSplitOptions.None);
- string start = DateTime.Parse(datelist[0]).ToString("yyyyMMdd");
- string end = DateTime.Parse(datelist[1]).ToString("yyyyMMdd");
- string info = "{\"MerchantId\":\"" + MerchantId + "\",\"StartDate\":\"" + start + "\",\"EndDate\": \"" + end + "\"}";
- RedisDbconn.Instance.AddList("ResetMerchantStatDataQueue2", info);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- return new AppResultJson() { Status = "1", Info = "成功", Data = Obj };
- }
- #endregion
- #region 商户管理-修改商户进件通道
- [Authorize]
- public JsonResult SetMerchantChannel(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- string channel = data["channel"].ToString();
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- MerchantAddInfo add = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == id);
- if(add != null)
- {
- add.AgentName = channel;
- main2db.SaveChanges();
- }
- return Json(new AppResultJson() { Status = "1", Info = "已修改", Data = Obj });
- }
- #endregion
- #region 商户管理-商户进件通道列表
- [Authorize]
- public JsonResult MerchantChannelList(string value)
- {
- List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
- Dictionary<string, object> item = new Dictionary<string, object>();
- item.Add("Id", "1");
- item.Add("Name", "蒲晓敏,T1715836(盒伙人)");
- list.Add(item);
- item = new Dictionary<string, object>();
- item.Add("Id", "2");
- item.Add("Name", "蒲晓敏,T1805778(盒伙人)");
- list.Add(item);
- item = new Dictionary<string, object>();
- item.Add("Id", "3");
- item.Add("Name", "蒲晓敏,Y5710589(迅易通)");
- list.Add(item);
- item = new Dictionary<string, object>();
- item.Add("Id", "4");
- item.Add("Name", "蒲晓敏,Y7009274(迅易通)");
- list.Add(item);
- item = new Dictionary<string, object>();
- item.Add("Id", "5");
- item.Add("Name", "蒲晓敏,Y5718505(迅易通)");
- list.Add(item);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = list });
- }
- #endregion
- }
- }
|