Commit b3688afd authored by liudong1993's avatar liudong1993
parents a31dcc37 82288c52
......@@ -92,14 +92,14 @@ namespace Mall.Common.Plugin
//创建md5对象
byte[] inputBye;
//使用GB2312编码方式把字符串转化为字节数组.
if (!string.IsNullOrWhiteSpace(charset))
{
inputBye = Encoding.GetEncoding(charset).GetBytes(encypStr);
}
else
{
//if (!string.IsNullOrWhiteSpace(charset))
//{
// inputBye = Encoding.GetEncoding(charset).GetBytes(encypStr);
//}
//else
//{
inputBye = Encoding.GetEncoding("utf-8").GetBytes(encypStr);
}
// }
var outputBye = m5.ComputeHash(inputBye);
var retStr = BitConverter.ToString(outputBye);
retStr = retStr.Replace("-", "").ToUpper();
......
......@@ -46,7 +46,7 @@ namespace Mall.WebApi.App_Code
/// <param name="CustomerId"></param>
/// <param name="openid"></param>
/// <returns></returns>
public static string GetMinUnifiedOrder(string sOrderNo, string sProductName, decimal dPrice, string CustomerId, string openid, RB_MiniProgram_Extend model, IHttpContextAccessor _accessor,string IPAddress)
public static string GetMinUnifiedOrder(string sOrderNo, string sProductName, decimal dPrice, string CustomerId, string openid, RB_MiniProgram_Extend model, IHttpContextAccessor _accessor, string IPAddress)
{
var req = new Common.Pay.WeChatPat.RequestHandler();
req.SetKey(model.WeChatApiSecret);
......@@ -58,7 +58,7 @@ namespace Mall.WebApi.App_Code
req.SetParameter("attach", CustomerId);
req.SetParameter("out_trade_no", sOrderNo);
req.SetParameter("total_fee", (dPrice * 100).ToString("f0"));
req.SetParameter("spbill_create_ip",IPAddress);
req.SetParameter("spbill_create_ip", IPAddress);
req.SetParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
req.SetParameter("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
req.SetParameter("notify_url", Config.sTenpayNotify);
......@@ -329,8 +329,8 @@ namespace Mall.WebApi.App_Code
Url = "https://api.mch.weixin.qq.com/secapi/pay/refund",
PostParam = reqXml,
Encoding = Common.Pay.WeChatPat.HttpHelper.GetRequestEncoding(_accessor.HttpContext.Request),
CertPath = model.WeChatPayCertificateUrl,
CertPwd = model.WeChatApiSecret
CertPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Certs/WeChatApp/" + model.WeChatPayCertificateUrl),//"App_Data/Certs/WeChatApp/apiclient_cert.p12"),// model.WeChatPayCertificateUrl,
CertPwd = model.WeChatPayMerchants//证书密码默认为您的商户ID
});
var xe = XElement.Parse(result, LoadOptions.SetLineInfo);
......@@ -466,20 +466,20 @@ namespace Mall.WebApi.App_Code
req.SetParameter("mch_appid", model.MiniAppId);//微信开放平台审核通过的应用APPID
req.SetParameter("mchid", model.WeChatPayMerchants);//微信支付分配的商户号
req.SetParameter("nonce_str", GetNoncestr());//随机字符串,不长于32位
req.SetParameter("sign", req.CreateMd5Sign(_accessor, model.WeChatApiSecret));
req.SetParameter("partner_trade_no", sOrderNo);//商户订单号,需保持唯一性(只能是字母或者数字,不能包含有其它字符)
req.SetParameter("openid", openid);
req.SetParameter("check_name", "NO_CHECK");
req.SetParameter("amount", (dPrice * 100).ToString("f0"));
req.SetParameter("desc", "赞羊商城佣金提现");
req.SetParameter("sign", req.CreateMd5Sign(_accessor, model.WeChatApiSecret));
var reqXml = req.ParseXml();
var result = Common.Pay.WeChatPat.HttpHelper.Post(new HttpParam()
{
Url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers",
PostParam = reqXml,
Encoding = Common.Pay.WeChatPat.HttpHelper.GetRequestEncoding(_accessor.HttpContext.Request),
CertPath = model.WeChatPayCertificateUrl,
CertPwd = model.WeChatApiSecret
CertPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Certs/WeChatApp/" + model.WeChatPayCertificateUrl),//"App_Data/Certs/WeChatApp/apiclient_cert.p12"),// model.WeChatPayCertificateUrl,
CertPwd = model.WeChatPayMerchants//证书密码默认为您的商户ID
});
var xe = XElement.Parse(result, LoadOptions.SetLineInfo);
......
......@@ -52,18 +52,21 @@ namespace Mall.WebApi.Controllers.AppletWeChat
public ApiResult GetPayInfo()
{
var request = RequestParm;
var userInfo = AppletUserInfo;
var userModel = userModule.GetMemberUserInfo(21233);
if (userInfo != null)
var userInfo = AppletUserInfo; // new AppletUserInfo();
if (userInfo==null)
{
userInfo = new Common.AppletUserInfo();
userInfo.TenantId = userModel.TenantId;
userInfo.MallBaseId = userModel.MallBaseId;
userInfo.UserId = userModel.Id;
return ApiResult.Failed("请登录");
}
//var userModel = userModule.GetMemberUserInfo(21233);
//if (userInfo != null)
//{
// userInfo = new Common.AppletUserInfo();
// userInfo.TenantId = userModel.TenantId;
// userInfo.MallBaseId = userModel.MallBaseId;
// userInfo.UserId = userModel.Id;
//}
RB_Goods_Order_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Order_Extend>(request.msg.ToString());
string sPayInfo = string.Empty;
if (!demodel.OrderPayType.HasValue)
......@@ -105,15 +108,31 @@ namespace Mall.WebApi.Controllers.AppletWeChat
public ApiResult TestReturn()
{
RB_MiniProgram_Extend miniProgram = new RB_MiniProgram_Extend(); //2020年5月26号新增
miniProgram = new RB_MiniProgram_Extend { MiniAppId = "wxacd9f8cc3480d29e", WeChatApiSecret = "936110e2c2214340b9829a3608bde6b0", WeChatPayMerchants = "1562277941" }; // programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { MallBaseId = 1, TenantId =1 });
string RefundOrderNo = "2020052916044326411";
var pram = new Common.Pay.WeChatPat.PayParam()
{
TotalFee = Convert.ToInt32(0.01 * 100),
RefundFee = Convert.ToInt32(0.01 * 100),
OrderNumber = "202005291604432641",
RefundNumber = RefundOrderNo
};
var Robj = new App_Code.PayUtil().Refund(pram, miniProgram, _accessor);
return ApiResult.Success("", Robj);
}
public ApiResult TestTransfersOrder()
{
RB_MiniProgram_Extend miniProgram = new RB_MiniProgram_Extend(); //2020年5月26号新增
miniProgram = new RB_MiniProgram_Extend { MiniAppId = "wxacd9f8cc3480d29e", WeChatApiSecret = "936110e2c2214340b9829a3608bde6b0", WeChatPayMerchants = "1562277941" }; // programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { MallBaseId = 1, TenantId =1 });
string RefundOrderNo = "20200529160443264111";
var Robj = App_Code.PayUtil.GetTransfersOrder(RefundOrderNo, Convert.ToDecimal("0.01"), "21233", "ow_7I5XC1-RGwwk8QANBmWKYKmOc", miniProgram, _accessor); ;
return ApiResult.Success("", Robj);
}
}
}
\ No newline at end of file
......@@ -64,5 +64,53 @@ namespace Mall.WebApi.Controllers.File
}
}
/// <summary>
/// 上传文件到本地临时文件
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult UploadBlob()
{
try
{
var files = Request.Form.Files;
if (files.Count == 0)
{
return new ApiResult { resultCode = (int)ResultCode.Fail, message = "未选择文件", data = "" };
}
string filename = files[0].FileName;
string fileExtention = System.IO.Path.GetExtension(files[0].FileName);
//验证文件格式
List<string> ExtList = new List<string>() {
".p12"
};
if (!ExtList.Contains(fileExtention))
{
return new ApiResult { resultCode = (int)ResultCode.Fail, message = "文件格式有误", data = "" };
}
string path = Guid.NewGuid().ToString() + fileExtention;
string basepath = AppContext.BaseDirectory;
string path_server = basepath + "\\App_Data\\Certs\\WeChatApp\\" + path;
if (!Directory.Exists(basepath + "\\App_Data\\Certs\\WeChatApp\\"))
{
Directory.CreateDirectory(basepath + "\\App_Data\\Certs\\WeChatApp\\");
}
using (FileStream fstream = new FileStream(path_server, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
files[0].CopyTo(fstream);
}
return ApiResult.Success("", new { Name = filename, Path = path_server });
}
catch (Exception ex)
{
LogHelper.Write(ex, "UploadBlob");
return ApiResult.Failed();
}
}
}
}
......@@ -75,6 +75,12 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary>
private readonly UserModule userModule = new UserModule();
/// <summary>
/// 小程序基础配置
/// </summary>
private readonly MallBaseModule mallBaseModule = new MallBaseModule();
/// <summary>
/// 小程序首页
/// </summary>
......@@ -101,7 +107,7 @@ namespace Mall.WebApi.Controllers.MallBase
if (MiniAppId != null && !string.IsNullOrEmpty(MiniAppId))
{
//获取小程序信息
var miniProgram = programModule.GetMiniProgramModule(new Model.Extend.User.RB_MiniProgram_Extend() { MiniAppId = MiniAppId }, isGetHomeData: true,isGetNav:1);
var miniProgram = programModule.GetMiniProgramModule(new Model.Extend.User.RB_MiniProgram_Extend() { MiniAppId = MiniAppId }, isGetHomeData: true, isGetNav: 1);
if (miniProgram != null && miniProgram.MallBaseId > 0)
{
//底部导航
......@@ -441,10 +447,10 @@ namespace Mall.WebApi.Controllers.MallBase
cats.goodsList.Add(new GoodsDetailsItem2()
{
id = gItem.Id,
price = Math.Round(gItem?.SellingPrice ?? 0, 2) ,
price = Math.Round(gItem?.SellingPrice ?? 0, 2),
name = gItem.Name,
picUrl = Common.Config.GetFileUrl(gItem.CoverImage),
OriginalPrice= Math.Round(gItem?.OriginalPrice ?? 0, 2)
OriginalPrice = Math.Round(gItem?.OriginalPrice ?? 0, 2)
});
}
}
......@@ -1164,9 +1170,31 @@ namespace Mall.WebApi.Controllers.MallBase
};
}
}
//基础配置 Add By:W 2020年6月1号
var mallBaseModel = mallBaseModule.GetListRepository(new RB_MallBase_Extend { TenantId = miniProgram.TenantId ?? 0, MallBaseId = miniProgram.MallBaseId}).FirstOrDefault();
//获取物流配置
var setting = new {
contact_tel= mallBaseModel.ContactNumber,
over_time=mallBaseModel.CancelTime,
delivery_time=mallBaseModel.AutoReceiving,
after_sale_time= mallBaseModel.AfterTime,
payment_type= "",
send_type="",
kdniao_mch_id="",//快递鸟配置
kdniao_api_key="",
};
}
}
var user_info = new object();
if (RequestParm.OpenId != null && !string.IsNullOrWhiteSpace(RequestParm.OpenId))
{
......@@ -1177,7 +1205,7 @@ namespace Mall.WebApi.Controllers.MallBase
var objResult = new
{
home_pages = homePage,
navbar= navbar,
navbar = navbar,
user_info
};
return ApiResult.Success(data: objResult);
......@@ -1190,7 +1218,7 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public object PlusDataToObject(ComponentItem subItem, int TenantId,int MallBaseId)
public object PlusDataToObject(ComponentItem subItem, int TenantId, int MallBaseId)
{
var obj = new object();
switch (subItem.Id)
......@@ -1333,7 +1361,7 @@ namespace Mall.WebApi.Controllers.MallBase
price = Math.Round((gItem?.SellingPrice ?? 0), 2),
name = gItem.Name,
picUrl = Common.Config.GetFileUrl(gItem.CoverImage),
OriginalPrice= Math.Round((gItem?.OriginalPrice ?? 0), 2)
OriginalPrice = Math.Round((gItem?.OriginalPrice ?? 0), 2)
});
}
}
......@@ -1388,7 +1416,7 @@ namespace Mall.WebApi.Controllers.MallBase
childItem.name = tempGood?.Name ?? childItem.name;
childItem.price = Math.Round((tempGood?.SellingPrice ?? childItem.price), 2);
childItem.picUrl = tempGood?.CoverImage != null ? Common.Config.GetFileUrl(tempGood.CoverImage) : Common.Config.GetFileUrl(childItem.picUrl);
childItem.OriginalPrice= Math.Round((tempGood?.OriginalPrice ?? 0), 2);
childItem.OriginalPrice = Math.Round((tempGood?.OriginalPrice ?? 0), 2);
}
}
}
......@@ -1666,7 +1694,7 @@ namespace Mall.WebApi.Controllers.MallBase
account = miniProgram?.AccountMenuList.Select(qitem => new
{
icon_url = qitem.MenuIcon,
name = qitem.MenuName.Replace("我的","").Replace("明细","").Replace("记录", ""),
name = qitem.MenuName.Replace("我的", "").Replace("明细", "").Replace("记录", ""),
is_show = 1,
link_url = qitem.MenuUrl.Trim(),
}),
......@@ -1733,7 +1761,7 @@ namespace Mall.WebApi.Controllers.MallBase
}
else
{
return ApiResult.Failed(message:"请获取用户OpenId");
return ApiResult.Failed(message: "请获取用户OpenId");
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment