| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- 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;
- namespace MySystem.Areas.Api.Controllers.v1.Main2
- {
- [Area("Api")]
- [Route("/v1/QrCodePlateMain/[controller]/[action]")]
- public class MerchantInfoController : BaseController
- {
- public MerchantInfoController(IHttpContextAccessor accessor) : base(accessor)
- {
- }
- #region 商户激活-银联达标商户列表
- [Authorize]
- public JsonResult UnionPayQualifiedMerchants(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Other = new Dictionary<string, object>();
- List<Dictionary<string, object>> dataList = UnionPayQualifiedMerchantsDo(value, out Other);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
- }
- private List<Dictionary<string, object>> UnionPayQualifiedMerchantsDo(string value, out Dictionary<string, object> Other)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantName = data["MerchantName"].ToString(); //商户名称
- string MctNo = data["MctNo"].ToString(); //商户号
- int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
- int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
- string condition = " and IsAct=1 and ExamineStatus=1 and Months=10";
- if (!string.IsNullOrEmpty(MerchantName))
- {
- condition += " and Name like '%" + MerchantName + "%'";
- }
- if (!string.IsNullOrEmpty(MctNo))
- {
- var merAddInfo = MerchantAddInfoService.Query(" and MchtNo=" + MctNo + "");
- condition += " and Id=" + merAddInfo.Id + "";
- }
- 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 = MerchantInfoService.List(relationData, condition, out count, pageNum, pageSize);
- foreach (Dictionary<string, object> subdata in source)
- {
- Dictionary<string, object> curData = new Dictionary<string, object>();
- var MerchantId = int.Parse(subdata["Id"].ToString());
- var merAddInfo = MerchantAddInfoService.Query(MerchantId);
- var Status = -1;
- var order = MerchantDepositOrderService.Query(" and Status>0 and MerchantId=" + MerchantId + "");
- if (order.Id > 0) Status = int.Parse(subdata["Status"].ToString());
- curData.Add("Id", MerchantId); //Id
- curData.Add("MerchantName", merAddInfo.CertMerchantName); //商户名称
- curData.Add("MctNo", merAddInfo.MchtNo); //商户号
- curData.Add("UpdateDate", order.UpdateDate.ToString() == "" ? "" : DateTime.Parse(order.UpdateDate.ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //激活时间
- curData.Add("PayMode", order.Sort); //支付方式(1 支付宝 2 微信)
- curData.Add("Status", Status); //达标状态(-1 未参与 0 考核中 1 已通过 2 未通过 101 待领取 100 已领取 99 发放中)
- curData.Add("Months", subdata["Months"].ToString()); //达标月数
- dataList.Add(curData);
- }
- Other.Add("Count", count); //总数
- return dataList;
- }
- #endregion
- #region 商户管理-商户管理-银联重置登录密码
- [Authorize]
- public JsonResult UnionPayResetLoginPwd(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionPayResetLoginPwdDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionPayResetLoginPwdDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var Id = int.Parse(MerchantId);
- var query = main2db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
- var loginMobile = main1db.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == query.Mobile) ?? new Models.Main1.MerchantLoginInfo();
- Dictionary<string, object> fields = new Dictionary<string, object>();
- if (query.Id > 0)
- {
- query.LoginPwd = function.MD532(query.Mobile.Substring(query.Mobile.Length - 6, 6)); //登录密码
- query.UpdateMan = AppConfig.LoginSession.sysAdminName + "_" + AppConfig.LoginSession.sysRealName;
- if (loginMobile.Id > 0)
- {
- loginMobile.LoginPwd = query.LoginPwd; //登录密码
- loginMobile.UpdateMan = AppConfig.LoginSession.sysAdminName + "_" + AppConfig.LoginSession.sysRealName;
- }
- }
- main2db.SaveChanges();
- main1db.SaveChanges();
- return new AppResultJson() { Status = "1", Info = "该商户的登录密码已重置为手机号后6位", Data = Obj };
- }
- #endregion
- #region 商户管理-商户管理-银联修改手机号
- [Authorize]
- public JsonResult UnionPayEditMobile(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionPayEditMobileDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionPayEditMobileDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- string Mobile = data["Mobile"].ToString(); //新手机号
- string MobileCode = data["MobileCode"].ToString(); //短信验证码
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- if (Mobile.Length != 11 || !function.IsInt(Mobile) || Mobile.Substring(0, 1) != "1")
- {
- return new AppResultJson() { Status = "-1", Info = "手机号不正确" };
- }
- var mobilecheck = RedisDbconn.Instance.Get<string>("MobileCodeCheck:" + Mobile);
- if (mobilecheck == "")
- {
- return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
- }
- if (mobilecheck != MobileCode)
- {
- return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
- }
- RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
- var check = Service.Main1.MerchantLoginInfoService.Query(" and LoginMobile=" + Mobile + "");
- if (check.Id > 0)
- {
- return new AppResultJson() { Status = "-1", Info = "已存在相关登录手机号" };
- }
- var Id = int.Parse(MerchantId);
- var query = main2db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
- var loginMobile = main1db.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == query.Mobile) ?? new Models.Main1.MerchantLoginInfo();
- Dictionary<string, object> fields = new Dictionary<string, object>();
- if (query.Id > 0)
- {
- query.Mobile = Mobile;
- query.UpdateMan = AppConfig.LoginSession.sysAdminName + "_" + AppConfig.LoginSession.sysRealName;
- query.LoginPwd = function.MD532(Mobile.Substring(Mobile.Length - 6, 6)); //登录密码
- if (loginMobile.Id > 0)
- {
- loginMobile.LoginMobile = Mobile;
- loginMobile.LoginPwd = query.LoginPwd; //登录密码
- loginMobile.UpdateMan = AppConfig.LoginSession.sysAdminName + "_" + AppConfig.LoginSession.sysRealName;
- }
- }
- main2db.SaveChanges();
- main1db.SaveChanges();
- return new AppResultJson() { Status = "1", Info = "修改成功,新密码默认为该手机号后6位", Data = Obj };
- }
- #endregion
- #region 商户管理-商户管理-银联商户激活订单补全
- [Authorize]
- public JsonResult UnionPayActOrderCompletion(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionPayActOrderCompletionDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionPayActOrderCompletionDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- string OutTradeNo = data["OutTradeNo"].ToString(); //外部交易号(D或U开头)
- string TradeNo = data["TradeNo"].ToString(); //交易号(数字开头)
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- if (string.IsNullOrEmpty(OutTradeNo) || string.IsNullOrEmpty(TradeNo))
- {
- return new AppResultJson() { Status = "-1", Info = "外部交易号或交易号为空", Data = Obj };
- }
- if (OutTradeNo.StartsWith("U"))
- {
- RedisDbconn.Instance.AddList("AlipayCallBack2", "{\"out_trade_no\":\"" + OutTradeNo + "\",\"transaction_id\":\"" + TradeNo + "\",\"total_fee\":\"" + 0 + "\",\"pay_mode\":\"1\",\"openid\":\"\",\"attach\":\"\"}");
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- else
- {
- return new AppResultJson() { Status = "-1", Info = "外部交易号有误", Data = Obj };
- }
- }
- #endregion
- #region 商户管理-商户管理-银联商户支付订单补全
- [Authorize]
- public JsonResult UnionPayOrderCompletion(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = UnionPayOrderCompletionDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson UnionPayOrderCompletionDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string MerchantId = data["MerchantId"].ToString(); //商户Id
- string OutTradeNo = data["OutTradeNo"].ToString(); //外部交易号(G开头)
- string TradeNo = data["TradeNo"].ToString(); //交易号(数字开头)
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- if (string.IsNullOrEmpty(OutTradeNo) || string.IsNullOrEmpty(TradeNo))
- {
- return new AppResultJson() { Status = "-1", Info = "外部交易号或交易号为空", Data = Obj };
- }
- RedisDbconn.Instance.AddList("WeChatPayBackHd", "{\"outOrderNo\":\"" + TradeNo + "\",\"orderNo\":\"" + OutTradeNo + "\"}");
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 商户管理-注销
- [Authorize]
- public JsonResult Logout(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = LogoutDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- private AppResultJson LogoutDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
- function.WriteLog(DateTime.Now.ToString(), "注销商户日志");
- function.WriteLog(Id.ToString(), "注销商户日志");
- MerchantInfo info = main2db.MerchantInfo.FirstOrDefault(m => m.Id == Id);
- if(info != null)
- {
- function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(info), "注销商户日志");
- main2db.MerchantInfo.Remove(info);
- }
- MerchantAddInfo addInfo = main2db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id);
- if(addInfo != null)
- {
- function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(addInfo), "注销商户日志");
- main2db.MerchantAddInfo.Remove(addInfo);
- }
- main2db.SaveChanges();
- function.WriteLog("end\n\n", "注销商户日志");
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- }
- }
|