| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 |
- 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.Main1;
- using MySystem.Service.Main1;
- using LitJson;
- using Library;
- using MySystem.Service.KxsMain;
- namespace MySystem.Areas.Api.Controllers.v1.Main1
- {
- [Area("Api")]
- [Route("/v1/QrCodePlateMain/[controller]/[action]")]
- public class MerchantAddInfoController : BaseController
- {
- public MerchantAddInfoController(IHttpContextAccessor accessor) : base(accessor)
- {
- }
- #region 进件管理-直连商户列表
- [Authorize]
- public JsonResult DirectList(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Other = new Dictionary<string, object>();
- List<Dictionary<string, object>> dataList = DirectListDo(value, out Other);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
- }
- private List<Dictionary<string, object>> DirectListDo(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 WeChatStatus = data["WeChatStatus"].ToString(); //微信状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
- string AliPayStatus = data["AliPayStatus"].ToString(); //支付宝状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
- 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"; //个体工商户
- 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["WeChatStatus"].ToString()))
- {
- condition += " and Status=" + WeChatStatus + "";
- }
- if (!string.IsNullOrEmpty(data["AliPayStatus"].ToString()))
- {
- condition += " and QueryCount=" + AliPayStatus + "";
- }
- 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 status = int.Parse(subdata["Status"].ToString());
- var queryCount = int.Parse(subdata["QueryCount"].ToString());
- //商户Id
- var MerchantId = int.Parse(subdata["Id"].ToString());
- //主体类型
- var subjectType = 0;
- if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_ENTERPRISE") subjectType = 1; //企业公司
- if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_INDIVIDUAL") subjectType = 2; //个体工商户
- curData.Add("Id", subdata["Id"].ToString()); //Id
- curData.Add("SubjectType", subjectType); //主体类型(1 企业 2 个体)
- 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("WeChatStatus", status); //微信状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
- curData.Add("AliPayStatus", queryCount); //支付宝状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
- dataList.Add(curData);
- }
- Other.Add("Count", count); //总数
- return dataList;
- }
- #endregion
- #region 进件管理-直连查看失败原因
- [Authorize]
- public JsonResult DirectQueryFailReason(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = DirectQueryFailReasonDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- private Dictionary<string, object> DirectQueryFailReasonDo(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 DirectDetail(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = DirectDetailDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- private Dictionary<string, object> DirectDetailDo(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 DirectSubmit(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = DirectSubmitDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson DirectSubmitDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- var info = MerchantAddInfoUtil.DirectSubmitDo(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 DirectQueryMerchantTradeInfo(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Other = new Dictionary<string, object>();
- List<Dictionary<string, object>> dataList = DirectQueryMerchantTradeInfoDo(value, out Other);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
- }
- private List<Dictionary<string, object>> DirectQueryMerchantTradeInfoDo(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 AliPID = data["AliPID"].ToString(); //支付宝PID
- string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
- string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
- string IsAct = data["IsAct"].ToString(); //激活状态(0 未激活 1 已激活)
- string ActDate = data["ActDate"].ToString(); //激活时间
- 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(AliPID))
- {
- condition += " and AlipayPid='" + AliPID + "'";
- }
- if (!string.IsNullOrEmpty(WeChatNo))
- {
- condition += " and SubMchid='" + WeChatNo + "'";
- }
- if (!string.IsNullOrEmpty(SubjectType))
- {
- if (SubjectType == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
- if (SubjectType == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
- 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 + ")";
- }
- 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("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; //个体工商户
- curData.Add("AliPID", subdata["AlipayPid"].ToString()); //支付宝PID
- curData.Add("AliPayToken", subdata["AlipayAuthToken"].ToString()); //支付宝token
- curData.Add("WeChatNo", subdata["SubMchid"].ToString()); //微信商户号
- curData.Add("SubjectType", subjectType); //主体类型(1 企业 2 个体 3 小微)
- 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 DirectEditAlipayOrWeChatStatus(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = DirectEditAlipayOrWeChatStatusDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson DirectEditAlipayOrWeChatStatusDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
- int Kind = int.Parse(function.CheckInt(data["Kind"].ToString())); //类型(0 所有 1 支付宝 2 微信)
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var query = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == MerchantId) ?? new MerchantAddInfo();
- var querys = main1db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId) ?? new MerchantInfo();
- Dictionary<string, object> fields = new Dictionary<string, object>();
- if (Kind == 0)
- {
- query.QueryCount = 2;
- query.Status = 2;
- querys.QueryCount = 2;
- querys.Status = 2;
- }
- if (Kind == 1)
- {
- query.QueryCount = 2;
- querys.QueryCount = 2;
- }
- if (Kind == 2)
- {
- query.Status = 2;
- querys.Status = 2;
- }
- main1db.SaveChanges();
- return new AppResultJson() { Status = "1", Info = "修改成功", Data = Obj };
- }
- #endregion
- #region 商户管理-直连添加支付宝PID和微信商户号
- [Authorize]
- public JsonResult DirectAddPIDOrWeChatNo(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = DirectAddPIDOrWeChatNoDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson DirectAddPIDOrWeChatNoDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- string AliPPID = data["AliPPID"].ToString(); //支付宝PID
- string AliPayToken = data["AliPayToken"].ToString(); //支付宝token
- string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- // var query = MerchantAddInfoService.Query(int.Parse(MerchantId));
- var Id = int.Parse(MerchantId);
- var query = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
- Dictionary<string, object> fields = new Dictionary<string, object>();
- if (query.Id > 0)
- {
- if (string.IsNullOrEmpty(query.AlipayPid))
- {
- // fields.Add("AlipayPid", AliPPID); //支付宝PID
- query.AlipayPid = AliPPID;
- }
- if (!string.IsNullOrEmpty(AliPayToken))
- {
- // fields.Add("AlipayAuthToken", AliPayToken); //支付宝token
- query.AlipayAuthToken = AliPayToken;
- }
- if (string.IsNullOrEmpty(query.SubMchid))
- {
- // fields.Add("SubMchid", WeChatNo); //微信商户号
- query.SubMchid = WeChatNo;
- }
- }
- main1db.SaveChanges();
- // AppResultJson resultJson = MerchantAddInfoService.Edit(fields, int.Parse(MerchantId), false);
- return new AppResultJson() { Status = "1", Info = "添加成功", Data = Obj };
- }
- #endregion
- #region 节点操作-直联提交微信商户进件
- [Authorize]
- public JsonResult DirectWeChatMerchantAdd(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = DirectWeChatMerchantAddDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson DirectWeChatMerchantAddDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- var merAddInfo = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
- var merInfo = main1db.MerchantInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantInfo();
- merAddInfo.Status = 0;
- merInfo.Status = 0;
- RedisDbconn.Instance.AddList("MerchantConfirmQueue", "{\"MerchantId\":\"" + id + "\",\"Kind\":\"2\"}");
- main1db.SaveChanges();
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 节点操作-直联提交支付宝商户进件
- [Authorize]
- public JsonResult DirectAlipayMerchantAdd(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = DirectAlipayMerchantAddDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson DirectAlipayMerchantAddDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- int id = int.Parse(function.CheckInt(data["id"].ToString()));
- var merAddInfo = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
- var merInfo = main1db.MerchantInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantInfo();
- merAddInfo.QueryCount = 0;
- merInfo.QueryCount = 0;
- RedisDbconn.Instance.AddList("MerchantConfirmQueue", "{\"MerchantId\":\"" + id + "\",\"Kind\":\"1\"}");
- main1db.SaveChanges();
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 节点操作-直联查询微信商户审核状态
- [Authorize]
- public JsonResult DirectWeChatMerchantQueryAudit(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = DirectWeChatMerchantQueryAuditDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- private Dictionary<string, object> DirectWeChatMerchantQueryAuditDo(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("WeChatSignUrl", query.WeChatSignUrl); //微信签约地址
- Obj.Add("WeChatRemark", query.WeChatRemark); //微信备注
- Obj.Add("WeChatMerchantId", query.WeChatMerchantId); //微信商户号
- Obj.Add("Status", query.Status); //微信审核状态
- if (query.Status < 2)
- {
- RedisDbconn.Instance.AddList("WeChatSignQueue", new MerchantSign()
- {
- BusinessCode = query.BusinessCode,
- MerchantAddInfoId = id,
- Status = ""
- });
- }
- return Obj;
- }
- #endregion
- #region 节点操作-直联查询支付宝商户审核状态
- [Authorize]
- public JsonResult DirectAlipayMerchantQueryAudit(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = DirectAlipayMerchantQueryAuditDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- private Dictionary<string, object> DirectAlipayMerchantQueryAuditDo(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("AlipayPid", query.AlipayPid); //支付宝唯一标识
- Obj.Add("AlipayAuthToken", query.AlipayAuthToken); //支付宝商家令牌
- Obj.Add("AlipaySignUrl", query.AlipaySignUrl); //支付宝签约地址
- Obj.Add("AlipayRemark", query.AlipayRemark); //支付宝备注
- Obj.Add("Status", query.QueryCount); //支付宝审核状态
- if (query.Status < 2)
- {
- RedisDbconn.Instance.AddList("AlipaySignQueue", new MerchantSign()
- {
- BusinessCode = query.SeoTitle,
- MerchantAddInfoId = id,
- Status = ""
- });
- }
- return Obj;
- }
- #endregion
- #region 商户管理-直连查询商户交易信息导出
- [Authorize]
- public JsonResult ExportDirectQueryMerchantTradeInfo(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = ExportDirectQueryMerchantTradeInfoDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson ExportDirectQueryMerchantTradeInfoDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantName = data["MerchantName"].ToString(); //商户名称
- string Mobile = data["Mobile"].ToString(); //手机号码
- string MakerCode = data["MakerCode"].ToString(); //所属创客
- string AliPID = data["AliPID"].ToString(); //支付宝PID
- string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
- string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
- 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(AliPID))
- {
- condition += " and AlipayPid='" + AliPID + "'";
- }
- if (!string.IsNullOrEmpty(WeChatNo))
- {
- condition += " and SubMchid='" + WeChatNo + "'";
- }
- if (!string.IsNullOrEmpty(SubjectType))
- {
- if (SubjectType == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
- if (SubjectType == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
- 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',a.AlipayPid '支付宝PID',a.AlipayAuthToken '支付宝token',a.SubMchid '微信商户号',(CASE WHEN a.SubjectType='SUBJECT_TYPE_ENTERPRISE' THEN '企业公司' WHEN a.SubjectType='SUBJECT_TYPE_INDIVIDUAL' THEN '个体工商户' ELSE '' end) SubjectType,(SELECT SUM(TradeCount) TradeCount FROM MerchantAmountSummay WHERE 1=1 AND MerchantId=a.Id) '订单总数',(SELECT SUM(TotalActual) TotalActual FROM MerchantAmountSummay WHERE 1=1 AND MerchantId=a.Id)' 实收总金额',(SELECT SUM(TradeAmount) TradeAmount FROM MerchantAmountSummay WHERE 1=1 AND MerchantId=a.Id) '营业总金额' FROM(SELECT Id,CertMerchantName,MobilePhone,SubjectType,AlipayPid,AlipayAuthToken,SubMchid FROM MerchantAddInfo WHERE 1=1 " + condition + " AND (Status=2 or QueryCount=2)) a LEFT JOIN (SELECT Id,IsAct,UserId FROM MerchantInfo WHERE 1=1 AND Status=2 or QueryCount=2) b ON a.Id=b.Id LEFT JOIN (SELECT MerchantId,UpdateDate FROM 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 DirectResetMerchantAmount(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = DirectResetMerchantAmountDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson DirectResetMerchantAmountDo(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("ResetMerchantStatDataQueue", info);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- }
- }
|