diff --git a/CoreCms.Net.CodeGenerator/CrudTemplete/Controllers/Controller.tpl b/CoreCms.Net.CodeGenerator/CrudTemplete/Controllers/Controller.tpl index 36cd0629..9cc3df0b 100644 --- a/CoreCms.Net.CodeGenerator/CrudTemplete/Controllers/Controller.tpl +++ b/CoreCms.Net.CodeGenerator/CrudTemplete/Controllers/Controller.tpl @@ -398,6 +398,12 @@ namespace CoreCms.Net.Web.Admin.Controllers //{{field.ColumnDescription}} {{field.DataType}} var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault().ObjectToInt(0); if ({{field.DbColumnName}} > 0) + { + where = where.And(p => p.{{field.DbColumnName}} == {{field.DbColumnName}}); + }{% elsif field.DataType == 'decimal' %} + //{{field.ColumnDescription}} {{field.DataType}} + var {{field.DbColumnName}} = Request.Form["{{field.DbColumnName}}"].FirstOrDefault().ObjectToDecimal(0); + if ({{field.DbColumnName}} > 0) { where = where.And(p => p.{{field.DbColumnName}} == {{field.DbColumnName}}); }{% elsif field.DataType == 'datetime' %} diff --git a/CoreCms.Net.Model/Entities/Financial/CoreCmsInvoice.cs b/CoreCms.Net.Model/Entities/Financial/CoreCmsInvoice.cs index c395aa9a..1d2940c0 100644 --- a/CoreCms.Net.Model/Entities/Financial/CoreCmsInvoice.cs +++ b/CoreCms.Net.Model/Entities/Financial/CoreCmsInvoice.cs @@ -3,11 +3,13 @@ * ProjectName: 核心内容管理系统 * Web: https://www.corecms.net * Author: 大灰灰 - * Email: jianweie@163.com - * CreateTime: 2021-06-08 22:14:58 + * Email: jianweie@163.com + * CreateTime: 2022/3/29 13:39:43 * Description: 暂无 -***********************************************************************/ + ***********************************************************************/ + using SqlSugar; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace CoreCms.Net.Model.Entities @@ -15,100 +17,172 @@ namespace CoreCms.Net.Model.Entities /// /// 发票表 /// - [SugarTable("CoreCmsInvoice",TableDescription = "发票表")] public partial class CoreCmsInvoice { /// - /// 发票表 + /// 构造函数 /// public CoreCmsInvoice() { } - + /// /// 序列 /// [Display(Name = "序列")] - [SugarColumn(ColumnDescription = "序列", IsPrimaryKey = true, IsIdentity = true)] + + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + [Required(ErrorMessage = "请输入{0}")] - public System.Int32 id { get; set; } + + + + public System.Int32 id { get; set; } + + /// /// 开票类型 /// [Display(Name = "开票类型")] - [SugarColumn(ColumnDescription = "开票类型")] + [Required(ErrorMessage = "请输入{0}")] - public System.Int32 category { get; set; } + + + + public System.Int32 category { get; set; } + + /// /// 资源ID /// [Display(Name = "资源ID")] - [SugarColumn(ColumnDescription = "资源ID", IsNullable = true)] - [StringLength(32, ErrorMessage = "【{0}】不能超过{1}字符长度")] - public System.String sourceId { get; set; } + + + [StringLength(maximumLength:32,ErrorMessage = "{0}不能超过{1}字")] + + + public System.String sourceId { get; set; } + + /// /// 所属用户ID /// [Display(Name = "所属用户ID")] - [SugarColumn(ColumnDescription = "所属用户ID")] + [Required(ErrorMessage = "请输入{0}")] - public System.Int32 userId { get; set; } + + + + public System.Int32 userId { get; set; } + + /// /// 发票类型 /// [Display(Name = "发票类型")] - [SugarColumn(ColumnDescription = "发票类型")] + [Required(ErrorMessage = "请输入{0}")] - public System.Int32 type { get; set; } + + + + public System.Int32 type { get; set; } + + /// /// 发票抬头 /// [Display(Name = "发票抬头")] - [SugarColumn(ColumnDescription = "发票抬头")] + [Required(ErrorMessage = "请输入{0}")] - [StringLength(255, ErrorMessage = "【{0}】不能超过{1}字符长度")] - public System.String title { get; set; } + [StringLength(maximumLength:255,ErrorMessage = "{0}不能超过{1}字")] + + + public System.String title { get; set; } + + /// /// 发票税号 /// [Display(Name = "发票税号")] - [SugarColumn(ColumnDescription = "发票税号")] + [Required(ErrorMessage = "请输入{0}")] - [StringLength(32, ErrorMessage = "【{0}】不能超过{1}字符长度")] - public System.String taxNumber { get; set; } + [StringLength(maximumLength:32,ErrorMessage = "{0}不能超过{1}字")] + + + public System.String taxNumber { get; set; } + + /// /// 发票金额 /// [Display(Name = "发票金额")] - [SugarColumn(ColumnDescription = "发票金额")] + [Required(ErrorMessage = "请输入{0}")] - public System.Decimal amount { get; set; } + + + + public System.Decimal amount { get; set; } + + /// /// 开票状态 /// [Display(Name = "开票状态")] - [SugarColumn(ColumnDescription = "开票状态")] + [Required(ErrorMessage = "请输入{0}")] - public System.Int32 status { get; set; } + + + + public System.Int32 status { get; set; } + + /// /// 开票备注 /// [Display(Name = "开票备注")] - [SugarColumn(ColumnDescription = "开票备注", IsNullable = true)] - [StringLength(2000, ErrorMessage = "【{0}】不能超过{1}字符长度")] - public System.String remarks { get; set; } + + + [StringLength(maximumLength:2000,ErrorMessage = "{0}不能超过{1}字")] + + + public System.String remarks { get; set; } + + /// /// 创建时间 /// [Display(Name = "创建时间")] - [SugarColumn(ColumnDescription = "创建时间")] + [Required(ErrorMessage = "请输入{0}")] - public System.DateTime createTime { get; set; } + + + + public System.DateTime createTime { get; set; } + + /// /// 更新时间 /// [Display(Name = "更新时间")] - [SugarColumn(ColumnDescription = "更新时间", IsNullable = true)] - public System.DateTime? updateTime { get; set; } + + + + + + public System.DateTime? updateTime { get; set; } + + + /// + /// 发票下载地址 + /// + [Display(Name = "发票下载地址")] + + + [StringLength(maximumLength:500,ErrorMessage = "{0}不能超过{1}字")] + + + public System.String fileUrl { get; set; } + + } -} \ No newline at end of file +} diff --git a/CoreCms.Net.Repository/Financial/CoreCmsInvoiceRepository.cs b/CoreCms.Net.Repository/Financial/CoreCmsInvoiceRepository.cs index edf320a9..2f237619 100644 --- a/CoreCms.Net.Repository/Financial/CoreCmsInvoiceRepository.cs +++ b/CoreCms.Net.Repository/Financial/CoreCmsInvoiceRepository.cs @@ -65,6 +65,7 @@ namespace CoreCms.Net.Repository remarks = p.remarks, createTime = p.createTime, updateTime = p.updateTime, + fileUrl = p.fileUrl, userNickName = sc.nickName }) .MergeTable() @@ -88,6 +89,7 @@ namespace CoreCms.Net.Repository remarks = p.remarks, createTime = p.createTime, updateTime = p.updateTime, + fileUrl = p.fileUrl, userNickName = sc.nickName }) .MergeTable() diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/article/list/list.vue b/CoreCms.Net.Uni-App/CoreShop/pages/article/list/list.vue index 1df25ce7..dc258a7d 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/article/list/list.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/article/list/list.vue @@ -57,10 +57,7 @@ onLoad(options) { if (options.cid) { this.cid = Number(options.cid); - } else { - this.cid = 1; } - this.articleList(); if (options.current) { this.current = options.current; diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/member/merchant/detail/detail.vue b/CoreCms.Net.Uni-App/CoreShop/pages/member/merchant/detail/detail.vue index 024d5b75..b8fb3476 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/member/merchant/detail/detail.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/member/merchant/detail/detail.vue @@ -201,7 +201,14 @@ {{orderInfo.invoice.taxNumber|| '无'}} - + + 下载发票 + + + + + + @@ -502,6 +509,64 @@ ladingWrite(id) { this.$u.route('/pages/member/merchant/takeDelivery/index?id=' + id); }, + // 保存发票到本地 + saveInvoice() { + let _this = this; + // #ifdef MP || MP-ALIPAY || APP-PLUS || APP-PLUS-NVUE + _this.download(_this.orderInfo.invoice.fileUrl) + // #endif + }, + download(fileUrl) { + let _this = this + // #ifdef APP-PLUS || APP-PLUS-NVUE + uni.downloadFile({ + url: fileUrl, + success(res) { + uni.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success() { + _this.$refs.uToast.show({ message: '操作成功', type: 'success' }) + }, + fail() { + _this.$u.toast('发票保存失败') + } + }); + }, + fail() { + _this.$u.toast('下载失败') + } + }) + // #endif + + // #ifdef MP + uni.authorize({ + scope: 'scope.writePhotosAlbum', + success() { + // 先下载到本地 + uni.downloadFile({ + url: fileUrl, + success(res) { + uni.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success() { + _this.$refs.uToast.show({ message: '保存成功', type: 'success' }) + }, + fail() { + _this.$u.toast('发票保存失败') + } + }); + }, + fail() { + _this.$u.toast('下载失败') + } + }) + }, + fail() { + //console.log('授权失败') + } + }) + // #endif + } } } diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/member/order/detail/detail.vue b/CoreCms.Net.Uni-App/CoreShop/pages/member/order/detail/detail.vue index 89ddf8f8..90dd7174 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/member/order/detail/detail.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/member/order/detail/detail.vue @@ -230,7 +230,14 @@ {{orderInfo.invoice.taxNumber|| '无'}} - + + 下载发票 + + + + + + @@ -688,6 +695,64 @@ url: '/pages/member/invoice/index?id=' + this.orderInfo.invoice.id }); } + }, + // 保存发票到本地 + saveInvoice() { + let _this = this; + // #ifdef MP || MP-ALIPAY || APP-PLUS || APP-PLUS-NVUE + _this.download(_this.orderInfo.invoice.fileUrl) + // #endif + }, + download(fileUrl) { + let _this = this + // #ifdef APP-PLUS || APP-PLUS-NVUE + uni.downloadFile({ + url: fileUrl, + success(res) { + uni.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success() { + _this.$refs.uToast.show({ message: '操作成功', type: 'success' }) + }, + fail() { + _this.$u.toast('图片保存失败') + } + }); + }, + fail() { + _this.$u.toast('下载失败') + } + }) + // #endif + + // #ifdef MP + uni.authorize({ + scope: 'scope.writePhotosAlbum', + success() { + // 先下载到本地 + uni.downloadFile({ + url: fileUrl, + success(res) { + uni.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success() { + _this.$refs.uToast.show({ message: '保存成功', type: 'success' }) + }, + fail() { + _this.$u.toast('图片保存失败') + } + }); + }, + fail() { + _this.$u.toast('下载失败') + } + }) + }, + fail() { + //console.log('授权失败') + } + }) + // #endif } } } diff --git a/CoreCms.Net.Web.Admin/Controllers/Financial/CoreCmsBillPaymentsController.cs b/CoreCms.Net.Web.Admin/Controllers/Financial/CoreCmsBillPaymentsController.cs index 9226cb39..ab350947 100644 --- a/CoreCms.Net.Web.Admin/Controllers/Financial/CoreCmsBillPaymentsController.cs +++ b/CoreCms.Net.Web.Admin/Controllers/Financial/CoreCmsBillPaymentsController.cs @@ -24,9 +24,13 @@ using CoreCms.Net.Model.FromBody; using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Utility.Extensions; using CoreCms.Net.Utility.Helper; +using Essensoft.Paylink.WeChatPay; +using Essensoft.Paylink.WeChatPay.V2; +using Essensoft.Paylink.WeChatPay.V2.Request; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; using NPOI.HSSF.UserModel; using SqlSugar; @@ -44,17 +48,24 @@ namespace CoreCms.Net.Web.Admin.Controllers { private readonly ICoreCmsBillPaymentsServices _coreCmsBillPaymentsServices; private readonly IWebHostEnvironment _webHostEnvironment; + private readonly IWeChatPayClient _client; + private readonly IOptions _optionsAccessor; + /// /// 构造函数 /// /// /// + /// + /// public CoreCmsBillPaymentsController(IWebHostEnvironment webHostEnvironment - , ICoreCmsBillPaymentsServices coreCmsBillPaymentsServices) + , ICoreCmsBillPaymentsServices coreCmsBillPaymentsServices, IWeChatPayClient client, IOptions optionsAccessor) { _webHostEnvironment = webHostEnvironment; _coreCmsBillPaymentsServices = coreCmsBillPaymentsServices; + _client = client; + _optionsAccessor = optionsAccessor; } #region 获取列表============================================================ @@ -475,5 +486,71 @@ namespace CoreCms.Net.Web.Admin.Controllers } #endregion + + + #region 更新微信支付数据 + + // POST: Api/CoreCmsBillPayments/DoRefresh/10 + /// + /// 更新微信支付数据 + /// + /// + /// + [HttpPost] + [Description("更新微信支付数据")] + public async Task DoRefresh([FromBody] FMStringId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _coreCmsBillPaymentsServices.QueryByClauseAsync(p => p.paymentId == entity.id); + if (model == null) + { + jm.msg = "不存在此信息"; + return jm; + } + if (model.paymentCode != GlobalEnumVars.PaymentsTypes.wechatpay.ToString()) + { + jm.msg = "此更新暂时仅支持微信支付查询"; + return jm; + } + + if (model.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed) + { + jm.msg = "订单已经支付成功,无需更新"; + return jm; + } + + + var request = new WeChatPayOrderQueryRequest + { + //微信订单号 + //TransactionId = model.TransactionId, + //商户订单号 + OutTradeNo = model.paymentId + }; + var response = await _client.ExecuteAsync(request, _optionsAccessor.Value); + + if (response is { ReturnCode: WeChatPayCode.Success, ResultCode: WeChatPayCode.Success, TradeState: WeChatPayCode.Success }) + { + var money = Math.Round((decimal)response.TotalFee / 100, 2); + await _coreCmsBillPaymentsServices.ToUpdate(response.OutTradeNo, + (int)GlobalEnumVars.BillPaymentsStatus.Payed, + GlobalEnumVars.PaymentsTypes.wechatpay.ToString(), money, response.ResultCode, + response.TransactionId); + + jm.code = 0; + jm.msg = "刷新成功"; + jm.data = response; + } + else + { + jm.code = 1; + jm.msg = response.TradeStateDesc; + } + return jm; + } + + #endregion + } } \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/Controllers/Financial/CoreCmsInvoiceController.cs b/CoreCms.Net.Web.Admin/Controllers/Financial/CoreCmsInvoiceController.cs index 76f03830..d2a0a5a0 100644 --- a/CoreCms.Net.Web.Admin/Controllers/Financial/CoreCmsInvoiceController.cs +++ b/CoreCms.Net.Web.Admin/Controllers/Financial/CoreCmsInvoiceController.cs @@ -75,49 +75,22 @@ namespace CoreCms.Net.Web.Admin.Controllers var where = PredicateBuilder.True(); //获取排序字段 var orderField = Request.Form["orderField"].FirstOrDefault(); - Expression> orderEx; - switch (orderField) + Expression> orderEx = orderField switch { - case "id": - orderEx = p => p.id; - break; - case "category": - orderEx = p => p.category; - break; - case "sourceId": - orderEx = p => p.sourceId; - break; - case "userId": - orderEx = p => p.userId; - break; - case "type": - orderEx = p => p.type; - break; - case "title": - orderEx = p => p.title; - break; - case "taxNumber": - orderEx = p => p.taxNumber; - break; - case "amount": - orderEx = p => p.amount; - break; - case "status": - orderEx = p => p.status; - break; - case "remarks": - orderEx = p => p.remarks; - break; - case "createTime": - orderEx = p => p.createTime; - break; - case "updateTime": - orderEx = p => p.updateTime; - break; - default: - orderEx = p => p.id; - break; - } + "id" => p => p.id, + "category" => p => p.category, + "sourceId" => p => p.sourceId, + "userId" => p => p.userId, + "type" => p => p.type, + "title" => p => p.title, + "taxNumber" => p => p.taxNumber, + "amount" => p => p.amount, + "status" => p => p.status, + "remarks" => p => p.remarks, + "createTime" => p => p.createTime, + "updateTime" => p => p.updateTime, + _ => p => p.id + }; //设置排序方式 var orderDirection = Request.Form["orderDirection"].FirstOrDefault(); @@ -144,6 +117,9 @@ namespace CoreCms.Net.Web.Admin.Controllers //发票类型 int var type = Request.Form["type"].FirstOrDefault().ObjectToInt(0); if (type > 0) where = where.And(p => p.type == type); + //开票状态 int + var status = Request.Form["status"].FirstOrDefault().ObjectToInt(0); + if (status > 0) where = where.And(p => p.status == status); //发票抬头 nvarchar var title = Request.Form["title"].FirstOrDefault(); if (!string.IsNullOrEmpty(title)) where = where.And(p => p.title.Contains(title)); @@ -299,6 +275,7 @@ namespace CoreCms.Net.Web.Admin.Controllers oldModel.status = entity.status; oldModel.remarks = entity.remarks; oldModel.updateTime = DateTime.Now; + oldModel.fileUrl = entity.fileUrl; //事物处理过程结束 var bl = await _coreCmsInvoiceServices.UpdateAsync(oldModel); diff --git a/CoreCms.Net.Web.Admin/wwwroot/lib/custom/js/main.js b/CoreCms.Net.Web.Admin/wwwroot/lib/custom/js/main.js index afcb7ae0..f546d8d5 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/lib/custom/js/main.js +++ b/CoreCms.Net.Web.Admin/wwwroot/lib/custom/js/main.js @@ -186,6 +186,7 @@ var allWidget = { "icon": "icon-shangpin", "value": { "title": '商品组名称', + "lookTitle": "true", "lookMore": "true", "type": "auto", //auto自动获取 choose 手动选择 "classifyId": '', //所选分类id @@ -542,6 +543,18 @@ Vue.component('upload-img', { } } }) +Vue.component('upload-video', { + template: "#upload-video", + data: function () { + return {} + }, + props: ['index', "item"], + methods: { + upload: function () { + this.$emit('upload-video'); + } + } +}) Vue.component('upload-topslide-bg-img', { template: "#upload-topslide-bg-img", data: function () { @@ -1054,6 +1067,30 @@ Vue.component('layout-config', { }); }); }, + upVideo: function (index, item) { + var _that = this; + layui.use(['form', 'table'], function () { + layui.admin.popup({ + title: '上传视频', + area: ['800px', '300px'], + id: 'LAY-app-CoreCmsCommon-GetNoticeIds', + success: function (layero, indexChild) { + layui.view(this.id).render('common/getUpLoadVideo', null).done(function () { + layui.form.on('submit(LAY-app-getUpLoad-submit)', + function (data) { + console.log(data); + _that.$set(_that.selectWg.value.list[index], 'url', data.field.url) + layer.close(indexChild); + }); + }); + } + , btn: ['确定', '取消'] + , yes: function (index, layero) { + layero.contents().find("#LAY-app-getUpLoad-submit").click(); + } + }); + }); + }, upTopSlideBgImage: function (index, item) { var _that = this; layui.use(['admin', 'coreHelper', 'cropperImg'], diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/common/getUpLoad.html b/CoreCms.Net.Web.Admin/wwwroot/views/common/getUpLoad.html index 44480ced..0a0966b5 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/common/getUpLoad.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/common/getUpLoad.html @@ -51,11 +51,11 @@ , url: layui.setter.apiUrl + 'Api/Tools/UploadFiles' , before: function (obj) { obj.preview(function (index, file, result) { - $('#viewImgBox').attr('src', result); + $('#viewImgBoximageUrl').attr('src', result); }); } , done: function (res) { - if (res.code > 0) { return layer.msg('上传失败'); } + if (res.code > 0) { return layer.msg(res.msg); } layer.msg('上传成功'); $("#imagesUrl").val(res.data.fileUrl); } diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/common/getUpLoadVideo.html b/CoreCms.Net.Web.Admin/wwwroot/views/common/getUpLoadVideo.html new file mode 100644 index 00000000..73abd520 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/common/getUpLoadVideo.html @@ -0,0 +1,76 @@ + + + + \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/financial/billpayments/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/financial/billpayments/index.html index 0667e104..559b2d83 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/financial/billpayments/index.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/financial/billpayments/index.html @@ -11,7 +11,7 @@ /* 重写样式 */
@@ -69,6 +69,9 @@